Skip to Content
API ReferenceauthOverview

@parity/product-sdk-auth

npm install @parity/product-sdk-auth

Exports

Classes

NameSummary
SignerNotAvailableError—

Functions

NameSummary
createAuthClient()@parity/product-sdk-auth — QR/mobile sign-in + session signing for Polkadot
parseDevAccountName()Parse a well-known dev-account SURI (//Alice, //Bob, …).
requestResourceAllocation()Ask the paired wallet to allocate resources for productId. The wallet
resolveSigner()Resolve a PAPI 3 transaction creator.
summarizeOutcomes()Group resources by the outcome the wallet gave each; outcomes[i] answers resources[i].

Interfaces

NameSummary
AllocationSummary—
AuthClientThe product-bound auth surface returned by createAuthClient.
AuthConfigPer-product configuration for createAuthClient, so the same sign-in flow
LoginHandle—
LogoutHandle—
ResolvedSigner—
SessionAddressesThe addresses shown for a paired session.
SessionHandleA signer for the product account, with the adapter it signs through. Call destroy() when done.
SignerOptions—

Type Aliases

NameSummary
AllocatableResourceA resource the host can pre-allocate on behalf of the product (RFC 0010).
AllocatableResourceA resource the host can pre-allocate on behalf of the product (RFC 0010).
AllocationOutcomeOutcome of allocating a single resource (RFC 0010).
AllocationOutcomeOutcome of allocating a single resource (RFC 0010).
ConnectResult—
LoginStatus—
LogoutStatus—
ResourceTag—
SignerSource—

Variables

NameSummary
DEFAULT_RESOURCESWhat a CLI product account needs before it can publish and transact:

Re-exports

Convenience re-exports from leaf packages. Click through for the canonical documentation.

NameKindSource package
createSessionSigner()function@parity/product-sdk-terminal
deriveProductPublicKey()function@parity/product-sdk-terminal
ProductAccountRefinterface@parity/product-sdk-terminal
sessionRootPublicKey()function@parity/product-sdk-terminal

Classes

class SignerNotAvailableError

Extends: Error

Constructors

constructor
new SignerNotAvailableError(): SignerNotAvailableError

Functions

createAuthClient()

Build an auth client for one product’s AuthConfig.

createAuthClient(config: AuthConfig): AuthClient

parseDevAccountName()

Parse a well-known dev-account SURI (//Alice, //Bob, …).

Requires the // hard-derivation prefix and an exact-case name, matching Substrate SURI semantics (and createDevSigner, which derives //${name}). A bare Alice or a different case is NOT a dev SURI — it falls through to the mnemonic path in resolveSigner, where it fails as an invalid mnemonic.

parseDevAccountName(suri: string): DevAccountName | null

requestResourceAllocation()

Ask the paired wallet to allocate resources for productId. The wallet prompts the user and answers one outcome per resource, in order; refusals are outcomes, transport failures throw.

requestResourceAllocation(adapter: TerminalAdapter, productId: string, resources: AllocatableResource[] = DEFAULT_RESOURCES): Promise<AllocationOutcome[]>

resolveSigner()

Resolve a PAPI 3 transaction creator.

  1. --suri flag → dev signer (dev name like //Alice, OR a BIP-39 mnemonic with optional //<path> derivation suffix)
  2. Persisted QR session → session signer (via authClient.getSessionSigner)
  3. Neither → SignerNotAvailableError
resolveSigner(authClient: AuthClient, options?: SignerOptions): Promise<ResolvedSigner>

summarizeOutcomes()

Group resources by the outcome the wallet gave each; outcomes[i] answers resources[i].

summarizeOutcomes(outcomes: AllocationOutcome[], resources: AllocatableResource[]): AllocationSummary

Interfaces

interface AllocationSummary

Properties

granted
propertyAllocatableResource[]
rejected
propertyAllocatableResource[]
unavailable
propertyAllocatableResource[]

interface AuthClient

The product-bound auth surface returned by createAuthClient.

Methods

clearLocalAppStorage
clearLocalAppStorage(appsDir?: string): Promise<void>
connect
connect(): Promise<ConnectResult>
findSession
findSession(): Promise<LogoutHandle | null>
getSessionSigner
getSessionSigner(): Promise<SessionHandle | null>
requestAllocation
requestAllocation(session: SessionHandle, resources?: AllocatableResource[]): Promise<AllocationOutcome[]>
waitForLogin
waitForLogin(handle: LoginHandle, onStatus: (status: LoginStatus) => void): Promise<string | null>
waitForLogout
waitForLogout(handle: LogoutHandle, onStatus: (status: LogoutStatus) => void): Promise<void>

interface AuthConfig

Per-product configuration for createAuthClient, so the same sign-in flow serves every CLI product.

Properties

approvals
propertyoptionalTerminalApprovals

Answers the core’s reviews and permission requests. Defaults to approving them.

dappId
propertystring

The CLI’s own id. Names its storage directory, so each CLI is signed in independently.

derivationIndex
propertynumber

Derivation index of the product account; 0 is the default.

network
propertyoptional"paseo-next-v2" | TerminalNetwork

Chains to pair and sign over. Defaults to "paseo-next-v2".

productId
propertystring

The dotNS product id the CLI acts as, e.g. "my-cli.dot". The signing account is derived under it (/product/{productId}/{index}).

storageDir
propertyoptionalstring

This CLI’s own directory, holding the session in core/ and product/. Defaults to ~/.polkadot-apps/<dappId>. Logout removes only those two folders.

interface LoginHandle

Properties

adapter
propertyTerminalAdapter
session
propertyPromise<SessionUiInfo>

The login started by connect(), resolving once the phone finishes pairing.

interface LogoutHandle

Properties

adapter
propertyTerminalAdapter
address
propertystring

interface ResolvedSigner

Properties

address
propertystring
addresses
propertyoptionalSessionAddresses

Root / product / H160 triple — present for QR/mobile sessions only.

session
propertyoptionalSessionUiInfo

Present for QR/mobile sessions; absent for local dev/SURI signers.

signer
propertyCommonSignerTxCreator
source
propertySignerSource

Methods

destroy

Tear down session adapter. Call in a finally block. No-op for dev signers.

destroy(): void

interface SessionAddresses

The addresses shown for a paired session.

  • rootAddress: the wallet’s root account.
  • productAddress: the product account /product/{productId}/{index}, which signs.
  • productH160: the same product account as a 20-byte EVM address.

Properties

productAddress
propertystring
productH160
property`0x${string}`
rootAddress
propertystring

interface SessionHandle

A signer for the product account, with the adapter it signs through. Call destroy() when done.

Properties

adapter
propertyTerminalAdapter
address
propertystring
addresses
propertySessionAddresses
session
propertySessionUiInfo
signer
propertyCommonSignerTxCreator

Methods

destroy
destroy(): void

interface SignerOptions

Properties

suri
propertyoptionalstring

Secret URI like “//Alice”. Takes priority over session.

Type Aliases

type AllocatableResource

A resource the host can pre-allocate on behalf of the product (RFC 0010).

For the slot-table allowances (StatementStoreAllowance, BulletinAllowance, SmartContractAllowance), pre-allocation is opportunistic and the host may also fulfil the allowance implicitly on the first submission. AutoSigning must be requested explicitly through this call.

type AllocatableResource = Codec<AllocatableResource>

type AllocatableResource

A resource the host can pre-allocate on behalf of the product (RFC 0010).

For the slot-table allowances (StatementStoreAllowance, BulletinAllowance, SmartContractAllowance), pre-allocation is opportunistic and the host may also fulfil the allowance implicitly on the first submission. AutoSigning must be requested explicitly through this call.

type AllocatableResource = { tag: "StatementStoreAllowance"; value?: undefined } | { tag: "BulletinAllowance"; value?: undefined } | { tag: "SmartContractAllowance"; value: DerivationIndex } | { tag: "AutoSigning"; value?: undefined }

type AllocationOutcome

Outcome of allocating a single resource (RFC 0010).

type AllocationOutcome = Codec<AllocationOutcome>

type AllocationOutcome

Outcome of allocating a single resource (RFC 0010).

type AllocationOutcome = "Allocated" | "Rejected" | "NotAvailable"

type ConnectResult

type ConnectResult = { address: string; addresses: SessionAddresses; kind: "existing" } | { kind: "qr"; login: LoginHandle; qrCode: string }

type LoginStatus

type LoginStatus = { step: "waiting" } | { step: "paired" } | { address: string; addresses: SessionAddresses; step: "success" } | { message: string; step: "error" }

type LogoutStatus

type LogoutStatus = { address: string; step: "disconnecting" } | { address: string; step: "success" } | { address: string; reason: string; step: "partial" } | { message: string; step: "error" }

type ResourceTag

type ResourceTag = AllocatableResource["tag"]

type SignerSource

type SignerSource = "dev" | "session"

Variables

DEFAULT_RESOURCES

What a CLI product account needs before it can publish and transact: Bulletin and statement-store writes, and PGAS sponsoring for the default (index 0) account.

let DEFAULT_RESOURCES: AllocatableResource[] = ...