@parity/product-sdk-auth
npm install @parity/product-sdk-authExports
Classes
| Name | Summary |
|---|---|
SignerNotAvailableError | — |
Functions
| Name | Summary |
|---|---|
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
| Name | Summary |
|---|---|
AllocationSummary | — |
AuthClient | The product-bound auth surface returned by createAuthClient. |
AuthConfig | Per-product configuration for createAuthClient, so the same sign-in flow |
LoginHandle | — |
LogoutHandle | — |
ResolvedSigner | — |
SessionAddresses | The addresses shown for a paired session. |
SessionHandle | A signer for the product account, with the adapter it signs through. Call destroy() when done. |
SignerOptions | — |
Type Aliases
| Name | Summary |
|---|---|
AllocatableResource | A resource the host can pre-allocate on behalf of the product (RFC 0010). |
AllocatableResource | A resource the host can pre-allocate on behalf of the product (RFC 0010). |
AllocationOutcome | Outcome of allocating a single resource (RFC 0010). |
AllocationOutcome | Outcome of allocating a single resource (RFC 0010). |
ConnectResult | — |
LoginStatus | — |
LogoutStatus | — |
ResourceTag | — |
SignerSource | — |
Variables
| Name | Summary |
|---|---|
DEFAULT_RESOURCES | What 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.
| Name | Kind | Source package |
|---|---|---|
createSessionSigner() | function | @parity/product-sdk-terminal |
deriveProductPublicKey() | function | @parity/product-sdk-terminal |
ProductAccountRef | interface | @parity/product-sdk-terminal |
sessionRootPublicKey() | function | @parity/product-sdk-terminal |
Classes
class SignerNotAvailableError
Extends: Error
Constructors
constructor
new SignerNotAvailableError(): SignerNotAvailableErrorFunctions
createAuthClient()
Build an auth client for one product’s AuthConfig.
createAuthClient(config: AuthConfig): AuthClientparseDevAccountName()
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 | nullrequestResourceAllocation()
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.
--suriflag → dev signer (dev name like //Alice, OR a BIP-39 mnemonic with optional//<path>derivation suffix)- Persisted QR session → session signer (via
authClient.getSessionSigner) - 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[]): AllocationSummaryInterfaces
interface AllocationSummary
Properties
granted
AllocatableResource[]rejected
AllocatableResource[]unavailable
AllocatableResource[]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
TerminalApprovalsAnswers the core’s reviews and permission requests. Defaults to approving them.
dappId
stringThe CLI’s own id. Names its storage directory, so each CLI is signed in independently.
derivationIndex
numberDerivation index of the product account; 0 is the default.
network
"paseo-next-v2" | TerminalNetworkChains to pair and sign over. Defaults to "paseo-next-v2".
productId
stringThe dotNS product id the CLI acts as, e.g. "my-cli.dot". The signing
account is derived under it (/product/{productId}/{index}).
storageDir
stringThis 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
TerminalAdaptersession
Promise<SessionUiInfo>The login started by connect(), resolving once the phone finishes pairing.
interface LogoutHandle
Properties
adapter
TerminalAdapteraddress
stringinterface ResolvedSigner
Properties
address
stringaddresses
SessionAddressesRoot / product / H160 triple — present for QR/mobile sessions only.
session
SessionUiInfoPresent for QR/mobile sessions; absent for local dev/SURI signers.
signer
CommonSignerTxCreatorsource
SignerSourceMethods
destroy
Tear down session adapter. Call in a finally block. No-op for dev signers.
destroy(): voidinterface 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
stringproductH160
`0x${string}`rootAddress
stringinterface SessionHandle
A signer for the product account, with the adapter it signs through. Call destroy() when done.
Properties
adapter
TerminalAdapteraddress
stringaddresses
SessionAddressessession
SessionUiInfosigner
CommonSignerTxCreatorMethods
destroy
destroy(): voidinterface SignerOptions
Properties
suri
stringSecret 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[] = ...