API Reference
SDK Reference

SDK Reference

PartyLayerEnterprise

The main entry point for the PartyLayer SDK.

npm install @partylayer/enterprise-sdk

Constructor

import { PartyLayerEnterprise } from '@partylayer/enterprise-sdk';
 
const pl = new PartyLayerEnterprise({
  appId: 'app_xxxxx',
  apiKey: 'pk_live_xxxxx',
  auth: {
    providers: ['auth0', 'passkey', 'telegram'],
    auth0Domain: 'yourapp.auth0.com',
    auth0ClientId: 'your_client_id',
    passkeyRpName: 'My dApp',
    passkeyRpId: 'mydapp.com',
    telegramBotUsername: 'mybot',
  },
  wallet: {
    createOnLogin: true,
    showBalance: true,
  },
  guest: {
    enabled: true,
    sessionTtlMinutes: 1440,
    autoConvertOnLogin: true,
  },
  theme: {
    primaryColor: '#2E75B6',
    borderRadius: 'md',
    darkMode: false,
  },
  apiBaseUrl: 'https://api.partylayer.io/v1',
});

Properties

PropertyTypeDescription
authAuthModuleAuthentication methods
walletWalletModuleWallet and transaction methods
walletsExternalWalletManagerExternal wallet adapters
guestGuestModuleGuest session management

Methods

initialize(): Promise<void>

Initializes auth providers, restores sessions, and loads guest state.

connectExternalWallet(adapterName): Promise<ConnectedExternalWallet>

Connects a self-custody external wallet.

destroy(): void

Cleans up event listeners, disconnects wallets, and clears guest state.


AuthModule

login(provider?: string): Promise<AuthSession>

Triggers authentication. Supports 'auth0', 'passkey', and 'telegram'.

const session = await pl.auth.login('telegram');

register(email, name?): Promise<AuthSession>

Registers a new user with a passkey credential.

logout(): Promise<void>

Clears all provider sessions.

getSession(): Promise<AuthSession | null>

Returns the current session if authenticated.

getAccessToken(): Promise<string | null>

Returns a valid JWT. Tries all configured providers.

isAuthenticated(): Promise<boolean>

Checks if any provider has an active session.

MFA Methods

pl.auth.mfa.setup(method, userId)
pl.auth.mfa.verifySetup(method, code, userId)
pl.auth.mfa.challenge(method, userId)
pl.auth.mfa.verify(challengeId, code)
pl.auth.mfa.status(userId)
pl.auth.mfa.disable(userId, verificationToken)

submitWithMfa<T>(fn, mfaToken?): Promise<T>

Wraps a transaction. If server returns MFA_REQUIRED, emits mfa:required event.


WalletModule

get(): Promise<EmbeddedWallet>

Returns the user's embedded wallet.

submitTransaction(params): Promise<TransactionResult>

Submits a Daml command to Canton.

const result = await pl.wallet.submitTransaction({
  templateId: { package_id, module_name, entity_name },
  choice: 'ClaimReward',
  args: { amount: '100.0' },
  contractId: '00abcd...',
});

getContracts(templateName?): Promise<ActiveContract[]>

Queries active contracts for the user's party.

getTrustLevel(): Promise<TrustLevel>

Returns: 'embedded' | 'custodial' | 'self-custody'

requestUpgrade(targetLevel): Promise<void>

Initiates a trust level upgrade.


GuestModule

create(options?): Promise<GuestSessionWithToken>

Creates a guest session. Stores token in localStorage.

getSession(): GuestSession | null

Returns the current guest session.

fetch(id?): Promise<void>

Hydrates session from the server.

isActive(): boolean

Returns true if a guest session is active.

convert(params): Promise<GuestConvertResult>

Converts guest to a full user account.

expire(): Promise<void>

Expires the guest session on the server.

clear(): void

Clears local state without server call.


Event System

on(event, callback): void / off(event, callback): void

Subscribe/unsubscribe from SDK events.

Events

EventPayloadDescription
auth:login{ session: AuthSession }User logged in
auth:logout{}User logged out
session:expired{}Session expired
wallet:createdEmbeddedWalletNew wallet created
wallet:readyEmbeddedWalletWallet ready for use
tx:submittedTransactionResultTransaction submitted
tx:confirmedTransactionResultTransaction confirmed
tx:failedErrorTransaction failed
guest:createdGuestSessionGuest session created
guest:convertedGuestConvertResultGuest converted
guest:expired{}Guest session expired
mfa:required{ challengeUrl }MFA needed for action

Types

AuthSession

interface AuthSession {
  userId: string;
  email?: string;
  name?: string;
  picture?: string;
  accessToken: string;
  provider: 'auth0' | 'google' | 'email' | 'passkey' | 'telegram';
  expiresAt: number;
}

EmbeddedWallet

interface EmbeddedWallet {
  id: string;
  partyId: string;
  trustLevel: 'embedded' | 'custodial' | 'self-custody';
  address: string;
  isReady: boolean;
  mpcEnabled: boolean;
}

TransactionResult

interface TransactionResult {
  updateId: string;
  commandId: string;
  status: 'submitted' | 'completed' | 'failed';
}