Browser SDK

Browser SDK

Receive decision requests in your web app

Download

Installation


  npm install @noxy-network/browser-sdk@2.2.0
  # or
  yarn add @noxy-network/browser-sdk@2.2.0
  # or
  pnpm add @noxy-network/browser-sdk@2.2.0
  
Code

Quick Start


  import {
    createNoxyClient,
    NoxyDecisionOutcomeValues,
    NOXY_IDENTITY_TYPE,
  } from '@noxy-network/browser-sdk';

  const noxy = await createNoxyClient({
    // identity types: wallet (eoa/scw), email, phone, user_id
    identity: {
      identityType: NOXY_IDENTITY_TYPE.EMAIL,
      identityId: 'user@example.com',
    },
    network: {
      relayNodesUrl: 'wss://relay.noxy.network',
      appId: '__your-app-id__',
      appSigningSecret: '__your-app-signing-secret__',
    },
  });

  await noxy.on(async (decisionId, decision) => {
    const isApproved = await showConfirmDialog(decision);
    await noxy.submitDecisionOutcome({
      decisionId,
      outcome: isApproved ? NoxyDecisionOutcomeValues.APPROVE : NoxyDecisionOutcomeValues.REJECT,
      receivedAt: Date.now(),
    });
  });