@parity/product-sdk-auth 0.2.9 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -11,8 +11,8 @@ import { seedToAccount } from '@parity/product-sdk-keys';
11
11
  var DEFAULT_RESOURCES = [
12
12
  { tag: "BulletInAllowance", value: void 0 },
13
13
  { tag: "StatementStoreAllowance", value: void 0 },
14
- // derivation index 0 = the default product account.
15
- { tag: "SmartContractAllowance", value: 0 }
14
+ // index 0 = the default product account.
15
+ { tag: "SmartContractAllowance", value: { tag: "Index", value: 0 } }
16
16
  ];
17
17
  async function requestResourceAllocation(session, productId, resources = DEFAULT_RESOURCES, onExisting = "Ignore") {
18
18
  return sendResourceAllocation(session, productId, resources, onExisting);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/allocations.ts","../src/auth.ts","../src/signer.ts"],"names":["ss58Encode"],"mappings":";;;;;;;;;;AAwDO,IAAM,iBAAA,GAA2C;AAAA,EACpD,EAAE,GAAA,EAAK,mBAAA,EAAqB,KAAA,EAAO,MAAA,EAAU;AAAA,EAC7C,EAAE,GAAA,EAAK,yBAAA,EAA2B,KAAA,EAAO,MAAA,EAAU;AAAA;AAAA,EAEnD,EAAE,GAAA,EAAK,wBAAA,EAA0B,KAAA,EAAO,CAAA;AAC5C;AAWA,eAAsB,0BAClB,OAAA,EACA,SAAA,EACA,SAAA,GAAmC,iBAAA,EACnC,aAAwC,QAAA,EACZ;AAC5B,EAAA,OAAO,sBAAA,CAAuB,OAAA,EAAS,SAAA,EAAW,SAAA,EAAW,UAAU,CAAA;AAC3E;AAYO,SAAS,iBAAA,CACZ,UACA,SAAA,EACiB;AACjB,EAAA,MAAM,UAAiC,EAAC;AACxC,EAAA,MAAM,WAAkC,EAAC;AACzC,EAAA,MAAM,cAAqC,EAAC;AAC5C,EAAA,QAAA,CAAS,OAAA,CAAQ,CAAC,OAAA,EAAS,CA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","file":"index.js","sourcesContent":["// Copyright (C) Parity Technologies (UK) Ltd.\n// SPDX-License-Identifier: Apache-2.0\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n/**\n * RFC-0010 `host_request_resource_allocation` helpers for auth consumers.\n *\n * The wire call, and the resource / outcome types, live in\n * `@parity/product-sdk-terminal` (derived from `UserSession` so they can't\n * drift from the host codec). This module delegates the wire call to terminal's\n * `sendResourceAllocation` — the cache-free primitive — and layers on the\n * auth-consumer conveniences (`DEFAULT_RESOURCES`, `summarizeOutcomes`) plus a\n * `productId`-based signature so headless callers don't need a `TerminalAdapter`.\n *\n * The mobile app handles `hostRequestResourceAllocation` in\n * `AllowanceHostCalls.kt` and routes the user through an approval UI.\n */\n\nimport type { UserSession } from \"@parity/product-sdk-terminal\";\nimport {\n type AllocatableResource,\n type ApAllocationOutcome,\n type OnExistingAllowancePolicy,\n sendResourceAllocation,\n} from \"@parity/product-sdk-terminal\";\n\nexport type { AllocatableResource, OnExistingAllowancePolicy } from \"@parity/product-sdk-terminal\";\n\n/**\n * Outcome of one allocation. Re-exported from terminal's wire-derived type\n * under the name auth consumers already use. We don't read the inner\n * `Allocated` payload (allowance slot keys, derivation secrets) — the host\n * stores them and uses them transparently on subsequent calls. We just need\n * the tag to know whether the allocation succeeded.\n */\nexport type AllocationOutcome = ApAllocationOutcome;\n\n/** Tag-only view, handy for downstream code that doesn't care about payloads. */\nexport type ResourceTag = AllocatableResource[\"tag\"];\n\n/**\n * Default mobile-granted resource set for a CLI product account: write access\n * to the statement store + Bulletin, plus PGAS sponsoring for the default\n * (index 0) product account.\n */\nexport const DEFAULT_RESOURCES: AllocatableResource[] = [\n { tag: \"BulletInAllowance\", value: undefined },\n { tag: \"StatementStoreAllowance\", value: undefined },\n // derivation index 0 = the default product account.\n { tag: \"SmartContractAllowance\", value: 0 },\n];\n\n/**\n * Send a `host_request_resource_allocation` request over the user's active\n * session. The host (mobile wallet) prompts the user to approve and returns\n * one outcome per requested resource in order.\n *\n * Throws on transport-level failures (Statement Store unreachable, encryption\n * error, etc.). Per-resource refusals are reported as `Rejected`/`NotAvailable`\n * outcomes — callers inspect the array to decide whether to proceed.\n */\nexport async function requestResourceAllocation(\n session: UserSession,\n productId: string,\n resources: AllocatableResource[] = DEFAULT_RESOURCES,\n onExisting: OnExistingAllowancePolicy = \"Ignore\",\n): Promise<AllocationOutcome[]> {\n return sendResourceAllocation(session, productId, resources, onExisting);\n}\n\nexport interface AllocationSummary {\n granted: AllocatableResource[];\n rejected: AllocatableResource[];\n unavailable: AllocatableResource[];\n}\n\n/**\n * Bucket allocation outcomes by tag. Order-sensitive: `outcomes[i]` maps to\n * `resources[i]`. Outcomes without a matching resource are silently dropped.\n */\nexport function summarizeOutcomes(\n outcomes: AllocationOutcome[],\n resources: AllocatableResource[],\n): AllocationSummary {\n const granted: AllocatableResource[] = [];\n const rejected: AllocatableResource[] = [];\n const unavailable: AllocatableResource[] = [];\n outcomes.forEach((outcome, i) => {\n const resource = resources[i];\n if (!resource) return;\n if (outcome.tag === \"Allocated\") granted.push(resource);\n else if (outcome.tag === \"Rejected\") rejected.push(resource);\n else unavailable.push(resource);\n });\n return { granted, rejected, unavailable };\n}\n","// Copyright (C) Parity Technologies (UK) Ltd.\n// SPDX-License-Identifier: Apache-2.0\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n/**\n * QR login flow — pure business logic, no UI. Lifted from playground-cli\n * `src/utils/auth.ts` (issue #411); the env-specific config playground imported\n * from its `config.ts` is now injected via `createAuthClient(config)`.\n *\n * Flow:\n * 1. `connect()` — starts adapter + auth, returns existing address OR QR code\n * 2. Print QR code to stdout (if needed) — before any UI mounts\n * 3. `waitForLogin()` — awaits the already-running auth to complete\n * 4. `getSessionSigner()` — gets a working signer for tx signing (separate adapter)\n * 5. `requestAllocation()` — RFC-0010 resource allocation (needed before a fresh session can sign)\n * 6. `findSession()` / `waitForLogout()` — sign out flow, mirror image of connect/waitForLogin\n */\n\nimport type { Dirent } from \"node:fs\";\nimport { readdir, unlink } from \"node:fs/promises\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { deriveH160, ss58Encode } from \"@parity/product-sdk-address\";\nimport {\n createTerminalAdapter,\n waitForSessions,\n renderQrCode,\n type TerminalAdapter,\n type PairingStatus,\n type UserSession,\n} from \"@parity/product-sdk-terminal\";\nimport type { PolkadotSigner } from \"polkadot-api\";\nimport {\n createSessionSigner,\n deriveProductPublicKey,\n sessionRootPublicKey,\n} from \"./sessionSigner.js\";\nimport {\n requestResourceAllocation,\n DEFAULT_RESOURCES,\n type AllocatableResource,\n type AllocationOutcome,\n type OnExistingAllowancePolicy,\n} from \"./allocations.js\";\nimport type { AuthConfig } from \"./types.js\";\n\n/** How long we wait for the statement store to publish the pairing QR. */\nconst QR_TIMEOUT_MS = 60_000;\n\n/**\n * The three addresses we surface from a paired session.\n *\n * - `rootAddress` — SS58 of `session.rootAccountId`, the `rootUserAccountId`\n * the mobile app sent over the SSO handshake (bare-mnemonic sr25519 root on\n * current mobile builds). Keyed by `Resources.Consumers` on the People\n * parachain, so it's the right input for `lookupUsername` from\n * `@parity/product-sdk-individuality`, which reads that account's usernames.\n * - `productAddress` — SS58 of the product account derived via\n * `product/{productId}/{index}` from `rootAccountId`. This is what actually\n * signs on-chain transactions from the CLI.\n * - `productH160` — the same product pubkey as a 20-byte EVM address (Revive /\n * contracts view). Derived from the SAME pubkey as `productAddress`.\n */\nexport interface SessionAddresses {\n rootAddress: string;\n productAddress: string;\n productH160: `0x${string}`;\n}\n\nexport type ConnectResult =\n | { kind: \"existing\"; address: string; addresses: SessionAddresses }\n | { kind: \"qr\"; qrCode: string; login: LoginHandle };\n\nexport type LoginStatus =\n | { step: \"waiting\" }\n | { step: \"paired\" }\n | { step: \"pending\"; stage: string }\n | { step: \"success\"; address: string; addresses: SessionAddresses }\n | { step: \"error\"; message: string };\n\nexport interface LoginHandle {\n adapter: TerminalAdapter;\n /** The authenticate() promise — already running since connect(). */\n authPromise: ReturnType<TerminalAdapter[\"sso\"][\"authenticate\"]>;\n}\n\n/**\n * A session signer bundle — the signer plus an explicit `destroy()` that tears\n * down the long-lived adapter the signer depends on. Callers MUST invoke\n * `destroy()` once done — the WebSocket keeps the event loop alive.\n */\nexport interface SessionHandle {\n address: string;\n addresses: SessionAddresses;\n signer: PolkadotSigner;\n userSession: UserSession;\n destroy(): void;\n}\n\nexport type LogoutStatus =\n | { step: \"disconnecting\"; address: string }\n | { step: \"success\"; address: string }\n | { step: \"partial\"; address: string; reason: string }\n | { step: \"error\"; message: string };\n\nexport interface LogoutHandle {\n adapter: TerminalAdapter;\n address: string;\n session: UserSession;\n}\n\n/** The product-bound auth surface returned by `createAuthClient`. */\nexport interface AuthClient {\n connect(): Promise<ConnectResult>;\n waitForLogin(\n handle: LoginHandle,\n onStatus: (status: LoginStatus) => void,\n ): Promise<string | null>;\n getSessionSigner(): Promise<SessionHandle | null>;\n findSession(): Promise<LogoutHandle | null>;\n waitForLogout(handle: LogoutHandle, onStatus: (status: LogoutStatus) => void): Promise<void>;\n requestAllocation(\n session: UserSession,\n resources?: AllocatableResource[],\n onExisting?: OnExistingAllowancePolicy,\n ): Promise<AllocationOutcome[]>;\n clearLocalAppStorage(dir?: string): Promise<void>;\n}\n\n/**\n * Build an auth client bound to a product's `AuthConfig`. All adapter creation,\n * address derivation, and session-storage scoping read from `config`, so the\n * same code serves any product.\n */\nexport function createAuthClient(config: AuthConfig): AuthClient {\n const ref = { productId: config.productId, derivationIndex: config.derivationIndex };\n\n function createAdapter(): TerminalAdapter {\n return createTerminalAdapter({\n appId: config.dappId,\n endpoints: config.peopleEndpoints,\n });\n }\n\n /**\n * Compute the three display addresses from a paired session. Shares\n * `deriveProductPublicKey` with `createSessionSigner` so the signing key and\n * the display SS58/H160 are computed by exactly one function.\n */\n function deriveSessionAddresses(session: UserSession): SessionAddresses {\n const rootBytes = sessionRootPublicKey(session);\n const productPubkey = deriveProductPublicKey(session, ref);\n return {\n rootAddress: ss58Encode(rootBytes),\n productAddress: ss58Encode(productPubkey),\n productH160: deriveH160(productPubkey),\n };\n }\n\n function createSigner(session: UserSession): PolkadotSigner {\n return createSessionSigner(session, ref);\n }\n\n function sessionRemoteAddress(session: UserSession): string | null {\n const raw = (session as { remoteAccount?: { accountId?: Uint8Array } }).remoteAccount\n ?.accountId;\n const accountId = raw ? new Uint8Array(raw) : new Uint8Array();\n return accountId.length === 32 ? ss58Encode(accountId) : null;\n }\n\n function sessionLogoutAddress(session: UserSession): string {\n try {\n return deriveSessionAddresses(session).productAddress;\n } catch {\n return sessionRemoteAddress(session) ?? \"(stored session)\";\n }\n }\n\n /**\n * Connect to the statement store and resolve the login state. Returns\n * immediately if an existing session is found (address only). Otherwise\n * kicks off authenticate(), waits for the QR payload, and returns the QR\n * code + a handle to await the auth result.\n */\n async function connect(): Promise<ConnectResult> {\n const adapter = createAdapter();\n\n const sessions = await waitForSessions(adapter);\n if (sessions.length > 0) {\n // The pairing adapter isn't handed back on the existing-session path\n // (ConnectResult.existing carries no handle), so tear it down before\n // returning — including if deriveSessionAddresses throws on a stale\n // session — or its WebSocket leaks for the process lifetime.\n try {\n const addresses = deriveSessionAddresses(sessions[0]);\n return { kind: \"existing\", address: addresses.productAddress, addresses };\n } finally {\n adapter.destroy().catch(() => {});\n }\n }\n\n // Start authenticate — this triggers the pairing flow and QR emission.\n const authPromise = adapter.sso.authenticate();\n\n // Captured so the loser of the race can be cancelled: if the QR payload\n // wins, an un-cleared setTimeout stays armed and keeps the Node event\n // loop alive, hanging the CLI for up to QR_TIMEOUT_MS after login.\n let timeoutHandle: ReturnType<typeof setTimeout> | undefined;\n try {\n const qrCode = await Promise.race([\n new Promise<string>((resolve) => {\n let done = false;\n // biome-ignore lint/style/useConst: self-referential — the callback calls unsub() to unsubscribe itself, so it can't be const.\n let unsub: (() => void) | undefined;\n unsub = adapter.sso.pairingStatus.subscribe(async (status: PairingStatus) => {\n if (status.step === \"pairing\" && !done) {\n done = true;\n unsub?.();\n resolve(await renderQrCode(status.payload));\n }\n });\n }),\n new Promise<never>((_, reject) => {\n timeoutHandle = setTimeout(\n () =>\n reject(\n new Error(\n `Login service did not respond within ${Math.round(\n QR_TIMEOUT_MS / 1000,\n )}s — try again`,\n ),\n ),\n QR_TIMEOUT_MS,\n );\n }),\n ]);\n\n return { kind: \"qr\", qrCode, login: { adapter, authPromise } };\n } catch (err) {\n // Release the WebSocket so we don't leak on the error path. `.catch()`\n // swallows the post-destroy `DestroyedError` that polkadot-api's\n // raw-client surfaces when a pending chainHead unsubscribe races the\n // WS close.\n adapter.destroy().catch(() => {});\n throw err;\n } finally {\n // Clear the timeout regardless of which promise won — on the QR-win\n // path this disarms the still-pending timer; on the timeout/error\n // path it's a harmless no-op.\n clearTimeout(timeoutHandle);\n }\n }\n\n /**\n * Wait for the already-running login to complete. Call after the QR code is\n * displayed. Reports status via callback. Returns the SS58 address on\n * success, or null on failure.\n */\n async function waitForLogin(\n { adapter, authPromise }: LoginHandle,\n onStatus: (status: LoginStatus) => void,\n ): Promise<string | null> {\n onStatus({ step: \"waiting\" });\n\n const unsubPairing = adapter.sso.pairingStatus.subscribe((status: PairingStatus) => {\n if (status.step === \"finished\") {\n onStatus({ step: \"paired\" });\n } else if (status.step === \"pending\") {\n onStatus({ step: \"pending\", stage: status.stage });\n } else if (status.step === \"pairingError\") {\n onStatus({ step: \"error\", message: status.message });\n }\n });\n\n let authenticated = false;\n let address: string | null = null;\n try {\n const result = await authPromise;\n result.match(\n (session) => {\n if (session) {\n authenticated = true;\n } else {\n // Ok channel but no session — pairing resolved without\n // producing a session. Surface it rather than returning\n // null with no status, which would hang the caller.\n onStatus({\n step: \"error\",\n message: \"Login did not produce a session\",\n });\n }\n },\n (error) => {\n onStatus({ step: \"error\", message: error.message });\n },\n );\n if (authenticated) {\n const sessions = await waitForSessions(adapter, 3000);\n if (sessions.length > 0) {\n const addresses = deriveSessionAddresses(sessions[0]);\n address = addresses.productAddress;\n onStatus({ step: \"success\", address, addresses });\n } else {\n onStatus({\n step: \"error\",\n message: \"Login succeeded but the local session was not available\",\n });\n }\n }\n } finally {\n unsubPairing();\n // The pairing adapter isn't needed after login — getSessionSigner()\n // builds its own — so tear it down to release the WebSocket.\n adapter.destroy().catch(() => {});\n }\n\n return address;\n }\n\n /**\n * Get a working signer from a persisted session. The returned handle owns a\n * terminal adapter that stays alive while the signer is in use (signing goes\n * through the adapter's WebSocket). Call `destroy()` when done. Returns null\n * if no session exists.\n */\n async function getSessionSigner(): Promise<SessionHandle | null> {\n const adapter = createAdapter();\n\n const sessions = await waitForSessions(adapter, 3000);\n if (sessions.length === 0) {\n adapter.destroy().catch(() => {});\n return null;\n }\n\n const session = sessions[0];\n // createSigner / deriveSessionAddresses derive the product key and can\n // throw on a stale session (missing rootAccountId). Destroy the adapter\n // on that path — the handle that owns `destroy` is never returned, so\n // without this the WebSocket leaks.\n let signer: PolkadotSigner;\n let addresses: SessionAddresses;\n try {\n signer = createSigner(session);\n addresses = deriveSessionAddresses(session);\n } catch (err) {\n adapter.destroy().catch(() => {});\n throw err;\n }\n\n let destroyed = false;\n const destroy = () => {\n if (destroyed) return;\n destroyed = true;\n adapter.destroy().catch(() => {});\n };\n\n return {\n address: addresses.productAddress,\n addresses,\n signer,\n userSession: session,\n destroy,\n };\n }\n\n /**\n * RFC-0010 resource allocation over the user's active session — grants the\n * statement-store / Bulletin / smart-contract allowances the product account\n * needs before it can sign. The mobile wallet prompts the user to approve.\n */\n async function requestAllocation(\n session: UserSession,\n resources: AllocatableResource[] = DEFAULT_RESOURCES,\n onExisting: OnExistingAllowancePolicy = \"Ignore\",\n ): Promise<AllocationOutcome[]> {\n return requestResourceAllocation(session, config.productId, resources, onExisting);\n }\n\n /**\n * Look up the currently paired session, if any. Returns a handle ready for\n * `waitForLogout()`, or null when no session is signed in (adapter destroyed\n * on the null path).\n */\n async function findSession(): Promise<LogoutHandle | null> {\n const adapter = createAdapter();\n const sessions = await waitForSessions(adapter, 3000);\n if (sessions.length === 0) {\n try {\n await adapter.destroy();\n } catch {\n // best-effort\n }\n return null;\n }\n const session = sessions[0];\n const address = sessionLogoutAddress(session);\n return { adapter, address, session };\n }\n\n /**\n * Disconnect the given session. Sends a `Disconnected` statement so the\n * paired mobile app drops its side, then clears the local `${dappId}_*`\n * files. Always releases the adapter before returning.\n */\n async function waitForLogout(\n handle: LogoutHandle,\n onStatus: (status: LogoutStatus) => void,\n ): Promise<void> {\n const { adapter, address, session } = handle;\n\n try {\n onStatus({ step: \"disconnecting\", address });\n const result = await adapter.sessions.disconnect(session);\n if (result.isOk()) {\n await clearLocalAppStorage();\n onStatus({ step: \"success\", address });\n return;\n }\n const reason = result.error.message || \"remote unreachable\";\n await clearLocalAppStorage();\n onStatus({ step: \"partial\", address, reason });\n } catch (err) {\n const reason = err instanceof Error ? err.message : String(err);\n try {\n await clearLocalAppStorage();\n onStatus({ step: \"partial\", address, reason });\n } catch (cleanupErr) {\n const msg = cleanupErr instanceof Error ? cleanupErr.message : String(cleanupErr);\n onStatus({ step: \"error\", message: msg });\n }\n } finally {\n try {\n await adapter.destroy();\n } catch {\n // best-effort\n }\n }\n }\n\n /**\n * Best-effort removal of this app's persisted state under `~/.polkadot-apps/`.\n * Scoped by `${dappId}_` prefix so files belonging to other polkadot apps\n * sharing the directory are left alone. Errors are swallowed.\n */\n async function clearLocalAppStorage(\n dir: string = join(homedir(), \".polkadot-apps\"),\n ): Promise<void> {\n let entries: Dirent[];\n try {\n entries = await readdir(dir, { withFileTypes: true });\n } catch {\n return;\n }\n const prefix = `${config.dappId}_`;\n await Promise.all(\n entries\n .filter((entry) => entry.isFile() && entry.name.startsWith(prefix))\n .map((entry) =>\n unlink(join(dir, entry.name)).catch(() => {\n // best-effort\n }),\n ),\n );\n }\n\n return {\n connect,\n waitForLogin,\n getSessionSigner,\n findSession,\n waitForLogout,\n requestAllocation,\n clearLocalAppStorage,\n };\n}\n","// Copyright (C) Parity Technologies (UK) Ltd.\n// SPDX-License-Identifier: Apache-2.0\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n/**\n * Unified signer resolution — \"give me a PolkadotSigner, I don't care how.\"\n * Lifted from playground-cli `src/utils/signer.ts` (issue #411).\n *\n * Dev accounts (`--suri //Alice`) and QR mobile sessions both produce the same\n * `PolkadotSigner` interface. Consumers call `resolveSigner(authClient)` once at\n * startup and thread the result through all operations. The `authClient` (from\n * `createAuthClient`) supplies the session branch, so this module stays free of\n * product-specific config.\n */\n\nimport { ss58Encode } from \"@parity/product-sdk-address\";\nimport { createDevSigner, getDevPublicKey, type DevAccountName } from \"@parity/product-sdk-tx\";\nimport { seedToAccount } from \"@parity/product-sdk-keys\";\nimport type { PolkadotSigner } from \"polkadot-api\";\nimport type { AuthClient, SessionAddresses, SessionHandle } from \"./auth.js\";\n\nexport type SignerSource = \"dev\" | \"session\";\n\nexport interface ResolvedSigner {\n signer: PolkadotSigner;\n address: string;\n source: SignerSource;\n /** Present for QR/mobile sessions; absent for local dev/SURI signers. */\n userSession?: SessionHandle[\"userSession\"];\n /** Root / product / H160 triple — present for QR/mobile sessions only. */\n addresses?: SessionAddresses;\n /** Tear down session adapter. Call in a finally block. No-op for dev signers. */\n destroy(): void;\n}\n\nexport interface SignerOptions {\n /** Secret URI like \"//Alice\". Takes priority over session. */\n suri?: string;\n}\n\nexport class SignerNotAvailableError extends Error {\n constructor() {\n super('No signer available. Run \"login\" to sign in, or pass --suri //Alice for dev.');\n this.name = \"SignerNotAvailableError\";\n }\n}\n\nconst DEV_NAMES: readonly DevAccountName[] = [\"Alice\", \"Bob\", \"Charlie\", \"Dave\", \"Eve\", \"Ferdie\"];\n\n/**\n * Parse a well-known dev-account SURI (`//Alice`, `//Bob`, …).\n *\n * Requires the `//` hard-derivation prefix and an exact-case name, matching\n * Substrate SURI semantics (and `createDevSigner`, which derives `//${name}`).\n * A bare `Alice` or a different case is NOT a dev SURI — it falls through to the\n * mnemonic path in `resolveSigner`, where it fails as an invalid mnemonic.\n */\nexport function parseDevAccountName(suri: string): DevAccountName | null {\n if (!suri.startsWith(\"//\")) return null;\n const name = suri.slice(2);\n return DEV_NAMES.find((n) => n === name) ?? null;\n}\n\n/**\n * Resolve a PolkadotSigner.\n *\n * 1. `--suri` flag → dev signer (dev name like //Alice, OR a BIP-39 mnemonic\n * with optional `//<path>` derivation suffix)\n * 2. Persisted QR session → session signer (via `authClient.getSessionSigner`)\n * 3. Neither → `SignerNotAvailableError`\n */\nexport async function resolveSigner(\n authClient: AuthClient,\n options?: SignerOptions,\n): Promise<ResolvedSigner> {\n if (options?.suri) {\n const devName = parseDevAccountName(options.suri);\n if (devName) {\n return {\n signer: createDevSigner(devName),\n address: ss58Encode(getDevPublicKey(devName)),\n source: \"dev\",\n destroy() {},\n };\n }\n // Mnemonic path. Split off an optional `//<path>` derivation suffix so\n // callers can target a sub-account of the same seed without a separate flag.\n const sepIdx = options.suri.indexOf(\"//\");\n const mnemonic = (sepIdx === -1 ? options.suri : options.suri.slice(0, sepIdx)).trim();\n const path = sepIdx === -1 ? \"\" : options.suri.slice(sepIdx);\n try {\n const account = seedToAccount(mnemonic, path);\n return {\n signer: account.signer,\n address: ss58Encode(account.publicKey),\n source: \"dev\",\n destroy() {},\n };\n } catch {\n throw new Error(\n `Unrecognized SURI \"${options.suri}\". ` +\n `Expected a dev name (${DEV_NAMES.join(\", \")}) or a BIP-39 mnemonic.`,\n );\n }\n }\n\n const session = await authClient.getSessionSigner();\n if (session) {\n return { ...session, source: \"session\" };\n }\n\n throw new SignerNotAvailableError();\n}\n"]}
1
+ {"version":3,"sources":["../src/allocations.ts","../src/auth.ts","../src/signer.ts"],"names":["ss58Encode"],"mappings":";;;;;;;;;;AAwDO,IAAM,iBAAA,GAA2C;AAAA,EACpD,EAAE,GAAA,EAAK,mBAAA,EAAqB,KAAA,EAAO,MAAA,EAAU;AAAA,EAC7C,EAAE,GAAA,EAAK,yBAAA,EAA2B,KAAA,EAAO,MAAA,EAAU;AAAA;AAAA,EAEnD,EAAE,KAAK,wBAAA,EAA0B,KAAA,EAAO,EAAE,GAAA,EAAK,OAAA,EAAS,KAAA,EAAO,CAAA,EAAE;AACrE;AAWA,eAAsB,0BAClB,OAAA,EACA,SAAA,EACA,SAAA,GAAmC,iBAAA,EACnC,aAAwC,QAAA,EACZ;AAC5B,EAAA,OAAO,sBAAA,CAAuB,OAAA,EAAS,SAAA,EAAW,SAAA,EAAW,UAAU,CAAA;AAC3E;AAYO,SAAS,iBAAA,CACZ,UACA,SAAA,EACiB;AACjB,EAAA,MAAM,UAAiC,EAAC;AACxC,EAAA,MAAM,WAAkC,EAAC;AACzC,EAAA,MAAM,cAAqC,EAAC;AAC5C,EAAA,QAAA,CAAS,OAAA,CAAQ,CAAC,OAAA,EAAS,CAAA,KAAM;AAC7B,IAAA,MAAM,QAAA,GAAW,UAAU,CAAC,CAAA;AAC5B,IAAA,IAAI,CAAC,QAAA,EAAU;AACf,IAAA,IAAI,OAAA,CAAQ,GAAA,KAAQ,W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AA;AAAA,QACR,OAAA,GAAU;AAAA,QAAC;AAAA,OACf;AAAA,IACJ;AAGA,IAAA,MAAM,MAAA,GAAS,OAAA,CAAQ,IAAA,CAAK,OAAA,CAAQ,IAAI,CAAA;AACxC,IAAA,MAAM,QAAA,GAAA,CAAY,MAAA,KAAW,EAAA,GAAK,OAAA,CAAQ,IAAA,GAAO,OAAA,CAAQ,IAAA,CAAK,KAAA,CAAM,CAAA,EAAG,MAAM,CAAA,EAAG,IAAA,EAAK;AACrF,IAAA,MAAM,OAAO,MAAA,KAAW,EAAA,GAAK,KAAK,OAAA,CAAQ,IAAA,CAAK,MAAM,MAAM,CAAA;AAC3D,IAAA,IAAI;AACA,MAAA,MAAM,OAAA,GAAU,aAAA,CAAc,QAAA,EAAU,IAAI,CAAA;AAC5C,MAAA,OAAO;AAAA,QACH,QAAQ,OAAA,CAAQ,MAAA;AAAA,QAChB,OAAA,EAASA,UAAAA,CAAW,OAAA,CAAQ,SAAS,CAAA;AAAA,QACrC,MAAA,EAAQ,KAAA;AAAA,QACR,OAAA,GAAU;AAAA,QAAC;AAAA,OACf;AAAA,IACJ,CAAA,CAAA,MAAQ;AACJ,MAAA,MAAM,IAAI,KAAA;AAAA,QACN,sBAAsB,OAAA,CAAQ,IAAI,2BACN,SAAA,CAAU,IAAA,CAAK,IAAI,CAAC,CAAA,uBAAA;AAAA,OACpD;AAAA,IACJ;AAAA,EACJ;AAEA,EAAA,MAAM,OAAA,GAAU,MAAM,UAAA,CAAW,gBAAA,EAAiB;AAClD,EAAA,IAAI,OAAA,EAAS;AACT,IAAA,OAAO,EAAE,GAAG,OAAA,EAAS,MAAA,EAAQ,SAAA,EAAU;AAAA,EAC3C;AAEA,EAAA,MAAM,IAAI,uBAAA,EAAwB;AACtC","file":"index.js","sourcesContent":["// Copyright (C) Parity Technologies (UK) Ltd.\n// SPDX-License-Identifier: Apache-2.0\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n/**\n * RFC-0010 `host_request_resource_allocation` helpers for auth consumers.\n *\n * The wire call, and the resource / outcome types, live in\n * `@parity/product-sdk-terminal` (derived from `UserSession` so they can't\n * drift from the host codec). This module delegates the wire call to terminal's\n * `sendResourceAllocation` — the cache-free primitive — and layers on the\n * auth-consumer conveniences (`DEFAULT_RESOURCES`, `summarizeOutcomes`) plus a\n * `productId`-based signature so headless callers don't need a `TerminalAdapter`.\n *\n * The mobile app handles `hostRequestResourceAllocation` in\n * `AllowanceHostCalls.kt` and routes the user through an approval UI.\n */\n\nimport type { UserSession } from \"@parity/product-sdk-terminal\";\nimport {\n type AllocatableResource,\n type ApAllocationOutcome,\n type OnExistingAllowancePolicy,\n sendResourceAllocation,\n} from \"@parity/product-sdk-terminal\";\n\nexport type { AllocatableResource, OnExistingAllowancePolicy } from \"@parity/product-sdk-terminal\";\n\n/**\n * Outcome of one allocation. Re-exported from terminal's wire-derived type\n * under the name auth consumers already use. We don't read the inner\n * `Allocated` payload (allowance slot keys, derivation secrets) — the host\n * stores them and uses them transparently on subsequent calls. We just need\n * the tag to know whether the allocation succeeded.\n */\nexport type AllocationOutcome = ApAllocationOutcome;\n\n/** Tag-only view, handy for downstream code that doesn't care about payloads. */\nexport type ResourceTag = AllocatableResource[\"tag\"];\n\n/**\n * Default mobile-granted resource set for a CLI product account: write access\n * to the statement store + Bulletin, plus PGAS sponsoring for the default\n * (index 0) product account.\n */\nexport const DEFAULT_RESOURCES: AllocatableResource[] = [\n { tag: \"BulletInAllowance\", value: undefined },\n { tag: \"StatementStoreAllowance\", value: undefined },\n // index 0 = the default product account.\n { tag: \"SmartContractAllowance\", value: { tag: \"Index\", value: 0 } },\n];\n\n/**\n * Send a `host_request_resource_allocation` request over the user's active\n * session. The host (mobile wallet) prompts the user to approve and returns\n * one outcome per requested resource in order.\n *\n * Throws on transport-level failures (Statement Store unreachable, encryption\n * error, etc.). Per-resource refusals are reported as `Rejected`/`NotAvailable`\n * outcomes — callers inspect the array to decide whether to proceed.\n */\nexport async function requestResourceAllocation(\n session: UserSession,\n productId: string,\n resources: AllocatableResource[] = DEFAULT_RESOURCES,\n onExisting: OnExistingAllowancePolicy = \"Ignore\",\n): Promise<AllocationOutcome[]> {\n return sendResourceAllocation(session, productId, resources, onExisting);\n}\n\nexport interface AllocationSummary {\n granted: AllocatableResource[];\n rejected: AllocatableResource[];\n unavailable: AllocatableResource[];\n}\n\n/**\n * Bucket allocation outcomes by tag. Order-sensitive: `outcomes[i]` maps to\n * `resources[i]`. Outcomes without a matching resource are silently dropped.\n */\nexport function summarizeOutcomes(\n outcomes: AllocationOutcome[],\n resources: AllocatableResource[],\n): AllocationSummary {\n const granted: AllocatableResource[] = [];\n const rejected: AllocatableResource[] = [];\n const unavailable: AllocatableResource[] = [];\n outcomes.forEach((outcome, i) => {\n const resource = resources[i];\n if (!resource) return;\n if (outcome.tag === \"Allocated\") granted.push(resource);\n else if (outcome.tag === \"Rejected\") rejected.push(resource);\n else unavailable.push(resource);\n });\n return { granted, rejected, unavailable };\n}\n","// Copyright (C) Parity Technologies (UK) Ltd.\n// SPDX-License-Identifier: Apache-2.0\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n/**\n * QR login flow — pure business logic, no UI. Lifted from playground-cli\n * `src/utils/auth.ts` (issue #411); the env-specific config playground imported\n * from its `config.ts` is now injected via `createAuthClient(config)`.\n *\n * Flow:\n * 1. `connect()` — starts adapter + auth, returns existing address OR QR code\n * 2. Print QR code to stdout (if needed) — before any UI mounts\n * 3. `waitForLogin()` — awaits the already-running auth to complete\n * 4. `getSessionSigner()` — gets a working signer for tx signing (separate adapter)\n * 5. `requestAllocation()` — RFC-0010 resource allocation (needed before a fresh session can sign)\n * 6. `findSession()` / `waitForLogout()` — sign out flow, mirror image of connect/waitForLogin\n */\n\nimport type { Dirent } from \"node:fs\";\nimport { readdir, unlink } from \"node:fs/promises\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { deriveH160, ss58Encode } from \"@parity/product-sdk-address\";\nimport {\n createTerminalAdapter,\n waitForSessions,\n renderQrCode,\n type TerminalAdapter,\n type PairingStatus,\n type UserSession,\n} from \"@parity/product-sdk-terminal\";\nimport type { PolkadotSigner } from \"polkadot-api\";\nimport {\n createSessionSigner,\n deriveProductPublicKey,\n sessionRootPublicKey,\n} from \"./sessionSigner.js\";\nimport {\n requestResourceAllocation,\n DEFAULT_RESOURCES,\n type AllocatableResource,\n type AllocationOutcome,\n type OnExistingAllowancePolicy,\n} from \"./allocations.js\";\nimport type { AuthConfig } from \"./types.js\";\n\n/** How long we wait for the statement store to publish the pairing QR. */\nconst QR_TIMEOUT_MS = 60_000;\n\n/**\n * The three addresses we surface from a paired session.\n *\n * - `rootAddress` — SS58 of `session.rootAccountId`, the `rootUserAccountId`\n * the mobile app sent over the SSO handshake (bare-mnemonic sr25519 root on\n * current mobile builds). Keyed by `Resources.Consumers` on the People\n * parachain, so it's the right input for `lookupUsername` from\n * `@parity/product-sdk-individuality`, which reads that account's usernames.\n * - `productAddress` — SS58 of the product account derived via\n * `product/{productId}/{index}` from `rootAccountId`. This is what actually\n * signs on-chain transactions from the CLI.\n * - `productH160` — the same product pubkey as a 20-byte EVM address (Revive /\n * contracts view). Derived from the SAME pubkey as `productAddress`.\n */\nexport interface SessionAddresses {\n rootAddress: string;\n productAddress: string;\n productH160: `0x${string}`;\n}\n\nexport type ConnectResult =\n | { kind: \"existing\"; address: string; addresses: SessionAddresses }\n | { kind: \"qr\"; qrCode: string; login: LoginHandle };\n\nexport type LoginStatus =\n | { step: \"waiting\" }\n | { step: \"paired\" }\n | { step: \"pending\"; stage: string }\n | { step: \"success\"; address: string; addresses: SessionAddresses }\n | { step: \"error\"; message: string };\n\nexport interface LoginHandle {\n adapter: TerminalAdapter;\n /** The authenticate() promise — already running since connect(). */\n authPromise: ReturnType<TerminalAdapter[\"sso\"][\"authenticate\"]>;\n}\n\n/**\n * A session signer bundle — the signer plus an explicit `destroy()` that tears\n * down the long-lived adapter the signer depends on. Callers MUST invoke\n * `destroy()` once done — the WebSocket keeps the event loop alive.\n */\nexport interface SessionHandle {\n address: string;\n addresses: SessionAddresses;\n signer: PolkadotSigner;\n userSession: UserSession;\n destroy(): void;\n}\n\nexport type LogoutStatus =\n | { step: \"disconnecting\"; address: string }\n | { step: \"success\"; address: string }\n | { step: \"partial\"; address: string; reason: string }\n | { step: \"error\"; message: string };\n\nexport interface LogoutHandle {\n adapter: TerminalAdapter;\n address: string;\n session: UserSession;\n}\n\n/** The product-bound auth surface returned by `createAuthClient`. */\nexport interface AuthClient {\n connect(): Promise<ConnectResult>;\n waitForLogin(\n handle: LoginHandle,\n onStatus: (status: LoginStatus) => void,\n ): Promise<string | null>;\n getSessionSigner(): Promise<SessionHandle | null>;\n findSession(): Promise<LogoutHandle | null>;\n waitForLogout(handle: LogoutHandle, onStatus: (status: LogoutStatus) => void): Promise<void>;\n requestAllocation(\n session: UserSession,\n resources?: AllocatableResource[],\n onExisting?: OnExistingAllowancePolicy,\n ): Promise<AllocationOutcome[]>;\n clearLocalAppStorage(dir?: string): Promise<void>;\n}\n\n/**\n * Build an auth client bound to a product's `AuthConfig`. All adapter creation,\n * address derivation, and session-storage scoping read from `config`, so the\n * same code serves any product.\n */\nexport function createAuthClient(config: AuthConfig): AuthClient {\n const ref = { productId: config.productId, derivationIndex: config.derivationIndex };\n\n function createAdapter(): TerminalAdapter {\n return createTerminalAdapter({\n appId: config.dappId,\n endpoints: config.peopleEndpoints,\n });\n }\n\n /**\n * Compute the three display addresses from a paired session. Shares\n * `deriveProductPublicKey` with `createSessionSigner` so the signing key and\n * the display SS58/H160 are computed by exactly one function.\n */\n function deriveSessionAddresses(session: UserSession): SessionAddresses {\n const rootBytes = sessionRootPublicKey(session);\n const productPubkey = deriveProductPublicKey(session, ref);\n return {\n rootAddress: ss58Encode(rootBytes),\n productAddress: ss58Encode(productPubkey),\n productH160: deriveH160(productPubkey),\n };\n }\n\n function createSigner(session: UserSession): PolkadotSigner {\n return createSessionSigner(session, ref);\n }\n\n function sessionRemoteAddress(session: UserSession): string | null {\n const raw = (session as { remoteAccount?: { accountId?: Uint8Array } }).remoteAccount\n ?.accountId;\n const accountId = raw ? new Uint8Array(raw) : new Uint8Array();\n return accountId.length === 32 ? ss58Encode(accountId) : null;\n }\n\n function sessionLogoutAddress(session: UserSession): string {\n try {\n return deriveSessionAddresses(session).productAddress;\n } catch {\n return sessionRemoteAddress(session) ?? \"(stored session)\";\n }\n }\n\n /**\n * Connect to the statement store and resolve the login state. Returns\n * immediately if an existing session is found (address only). Otherwise\n * kicks off authenticate(), waits for the QR payload, and returns the QR\n * code + a handle to await the auth result.\n */\n async function connect(): Promise<ConnectResult> {\n const adapter = createAdapter();\n\n const sessions = await waitForSessions(adapter);\n if (sessions.length > 0) {\n // The pairing adapter isn't handed back on the existing-session path\n // (ConnectResult.existing carries no handle), so tear it down before\n // returning — including if deriveSessionAddresses throws on a stale\n // session — or its WebSocket leaks for the process lifetime.\n try {\n const addresses = deriveSessionAddresses(sessions[0]);\n return { kind: \"existing\", address: addresses.productAddress, addresses };\n } finally {\n adapter.destroy().catch(() => {});\n }\n }\n\n // Start authenticate — this triggers the pairing flow and QR emission.\n const authPromise = adapter.sso.authenticate();\n\n // Captured so the loser of the race can be cancelled: if the QR payload\n // wins, an un-cleared setTimeout stays armed and keeps the Node event\n // loop alive, hanging the CLI for up to QR_TIMEOUT_MS after login.\n let timeoutHandle: ReturnType<typeof setTimeout> | undefined;\n try {\n const qrCode = await Promise.race([\n new Promise<string>((resolve) => {\n let done = false;\n // biome-ignore lint/style/useConst: self-referential — the callback calls unsub() to unsubscribe itself, so it can't be const.\n let unsub: (() => void) | undefined;\n unsub = adapter.sso.pairingStatus.subscribe(async (status: PairingStatus) => {\n if (status.step === \"pairing\" && !done) {\n done = true;\n unsub?.();\n resolve(await renderQrCode(status.payload));\n }\n });\n }),\n new Promise<never>((_, reject) => {\n timeoutHandle = setTimeout(\n () =>\n reject(\n new Error(\n `Login service did not respond within ${Math.round(\n QR_TIMEOUT_MS / 1000,\n )}s — try again`,\n ),\n ),\n QR_TIMEOUT_MS,\n );\n }),\n ]);\n\n return { kind: \"qr\", qrCode, login: { adapter, authPromise } };\n } catch (err) {\n // Release the WebSocket so we don't leak on the error path. `.catch()`\n // swallows the post-destroy `DestroyedError` that polkadot-api's\n // raw-client surfaces when a pending chainHead unsubscribe races the\n // WS close.\n adapter.destroy().catch(() => {});\n throw err;\n } finally {\n // Clear the timeout regardless of which promise won — on the QR-win\n // path this disarms the still-pending timer; on the timeout/error\n // path it's a harmless no-op.\n clearTimeout(timeoutHandle);\n }\n }\n\n /**\n * Wait for the already-running login to complete. Call after the QR code is\n * displayed. Reports status via callback. Returns the SS58 address on\n * success, or null on failure.\n */\n async function waitForLogin(\n { adapter, authPromise }: LoginHandle,\n onStatus: (status: LoginStatus) => void,\n ): Promise<string | null> {\n onStatus({ step: \"waiting\" });\n\n const unsubPairing = adapter.sso.pairingStatus.subscribe((status: PairingStatus) => {\n if (status.step === \"finished\") {\n onStatus({ step: \"paired\" });\n } else if (status.step === \"pending\") {\n onStatus({ step: \"pending\", stage: status.stage });\n } else if (status.step === \"pairingError\") {\n onStatus({ step: \"error\", message: status.message });\n }\n });\n\n let authenticated = false;\n let address: string | null = null;\n try {\n const result = await authPromise;\n result.match(\n (session) => {\n if (session) {\n authenticated = true;\n } else {\n // Ok channel but no session — pairing resolved without\n // producing a session. Surface it rather than returning\n // null with no status, which would hang the caller.\n onStatus({\n step: \"error\",\n message: \"Login did not produce a session\",\n });\n }\n },\n (error) => {\n onStatus({ step: \"error\", message: error.message });\n },\n );\n if (authenticated) {\n const sessions = await waitForSessions(adapter, 3000);\n if (sessions.length > 0) {\n const addresses = deriveSessionAddresses(sessions[0]);\n address = addresses.productAddress;\n onStatus({ step: \"success\", address, addresses });\n } else {\n onStatus({\n step: \"error\",\n message: \"Login succeeded but the local session was not available\",\n });\n }\n }\n } finally {\n unsubPairing();\n // The pairing adapter isn't needed after login — getSessionSigner()\n // builds its own — so tear it down to release the WebSocket.\n adapter.destroy().catch(() => {});\n }\n\n return address;\n }\n\n /**\n * Get a working signer from a persisted session. The returned handle owns a\n * terminal adapter that stays alive while the signer is in use (signing goes\n * through the adapter's WebSocket). Call `destroy()` when done. Returns null\n * if no session exists.\n */\n async function getSessionSigner(): Promise<SessionHandle | null> {\n const adapter = createAdapter();\n\n const sessions = await waitForSessions(adapter, 3000);\n if (sessions.length === 0) {\n adapter.destroy().catch(() => {});\n return null;\n }\n\n const session = sessions[0];\n // createSigner / deriveSessionAddresses derive the product key and can\n // throw on a stale session (missing rootAccountId). Destroy the adapter\n // on that path — the handle that owns `destroy` is never returned, so\n // without this the WebSocket leaks.\n let signer: PolkadotSigner;\n let addresses: SessionAddresses;\n try {\n signer = createSigner(session);\n addresses = deriveSessionAddresses(session);\n } catch (err) {\n adapter.destroy().catch(() => {});\n throw err;\n }\n\n let destroyed = false;\n const destroy = () => {\n if (destroyed) return;\n destroyed = true;\n adapter.destroy().catch(() => {});\n };\n\n return {\n address: addresses.productAddress,\n addresses,\n signer,\n userSession: session,\n destroy,\n };\n }\n\n /**\n * RFC-0010 resource allocation over the user's active session — grants the\n * statement-store / Bulletin / smart-contract allowances the product account\n * needs before it can sign. The mobile wallet prompts the user to approve.\n */\n async function requestAllocation(\n session: UserSession,\n resources: AllocatableResource[] = DEFAULT_RESOURCES,\n onExisting: OnExistingAllowancePolicy = \"Ignore\",\n ): Promise<AllocationOutcome[]> {\n return requestResourceAllocation(session, config.productId, resources, onExisting);\n }\n\n /**\n * Look up the currently paired session, if any. Returns a handle ready for\n * `waitForLogout()`, or null when no session is signed in (adapter destroyed\n * on the null path).\n */\n async function findSession(): Promise<LogoutHandle | null> {\n const adapter = createAdapter();\n const sessions = await waitForSessions(adapter, 3000);\n if (sessions.length === 0) {\n try {\n await adapter.destroy();\n } catch {\n // best-effort\n }\n return null;\n }\n const session = sessions[0];\n const address = sessionLogoutAddress(session);\n return { adapter, address, session };\n }\n\n /**\n * Disconnect the given session. Sends a `Disconnected` statement so the\n * paired mobile app drops its side, then clears the local `${dappId}_*`\n * files. Always releases the adapter before returning.\n */\n async function waitForLogout(\n handle: LogoutHandle,\n onStatus: (status: LogoutStatus) => void,\n ): Promise<void> {\n const { adapter, address, session } = handle;\n\n try {\n onStatus({ step: \"disconnecting\", address });\n const result = await adapter.sessions.disconnect(session);\n if (result.isOk()) {\n await clearLocalAppStorage();\n onStatus({ step: \"success\", address });\n return;\n }\n const reason = result.error.message || \"remote unreachable\";\n await clearLocalAppStorage();\n onStatus({ step: \"partial\", address, reason });\n } catch (err) {\n const reason = err instanceof Error ? err.message : String(err);\n try {\n await clearLocalAppStorage();\n onStatus({ step: \"partial\", address, reason });\n } catch (cleanupErr) {\n const msg = cleanupErr instanceof Error ? cleanupErr.message : String(cleanupErr);\n onStatus({ step: \"error\", message: msg });\n }\n } finally {\n try {\n await adapter.destroy();\n } catch {\n // best-effort\n }\n }\n }\n\n /**\n * Best-effort removal of this app's persisted state under `~/.polkadot-apps/`.\n * Scoped by `${dappId}_` prefix so files belonging to other polkadot apps\n * sharing the directory are left alone. Errors are swallowed.\n */\n async function clearLocalAppStorage(\n dir: string = join(homedir(), \".polkadot-apps\"),\n ): Promise<void> {\n let entries: Dirent[];\n try {\n entries = await readdir(dir, { withFileTypes: true });\n } catch {\n return;\n }\n const prefix = `${config.dappId}_`;\n await Promise.all(\n entries\n .filter((entry) => entry.isFile() && entry.name.startsWith(prefix))\n .map((entry) =>\n unlink(join(dir, entry.name)).catch(() => {\n // best-effort\n }),\n ),\n );\n }\n\n return {\n connect,\n waitForLogin,\n getSessionSigner,\n findSession,\n waitForLogout,\n requestAllocation,\n clearLocalAppStorage,\n };\n}\n","// Copyright (C) Parity Technologies (UK) Ltd.\n// SPDX-License-Identifier: Apache-2.0\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n/**\n * Unified signer resolution — \"give me a PolkadotSigner, I don't care how.\"\n * Lifted from playground-cli `src/utils/signer.ts` (issue #411).\n *\n * Dev accounts (`--suri //Alice`) and QR mobile sessions both produce the same\n * `PolkadotSigner` interface. Consumers call `resolveSigner(authClient)` once at\n * startup and thread the result through all operations. The `authClient` (from\n * `createAuthClient`) supplies the session branch, so this module stays free of\n * product-specific config.\n */\n\nimport { ss58Encode } from \"@parity/product-sdk-address\";\nimport { createDevSigner, getDevPublicKey, type DevAccountName } from \"@parity/product-sdk-tx\";\nimport { seedToAccount } from \"@parity/product-sdk-keys\";\nimport type { PolkadotSigner } from \"polkadot-api\";\nimport type { AuthClient, SessionAddresses, SessionHandle } from \"./auth.js\";\n\nexport type SignerSource = \"dev\" | \"session\";\n\nexport interface ResolvedSigner {\n signer: PolkadotSigner;\n address: string;\n source: SignerSource;\n /** Present for QR/mobile sessions; absent for local dev/SURI signers. */\n userSession?: SessionHandle[\"userSession\"];\n /** Root / product / H160 triple — present for QR/mobile sessions only. */\n addresses?: SessionAddresses;\n /** Tear down session adapter. Call in a finally block. No-op for dev signers. */\n destroy(): void;\n}\n\nexport interface SignerOptions {\n /** Secret URI like \"//Alice\". Takes priority over session. */\n suri?: string;\n}\n\nexport class SignerNotAvailableError extends Error {\n constructor() {\n super('No signer available. Run \"login\" to sign in, or pass --suri //Alice for dev.');\n this.name = \"SignerNotAvailableError\";\n }\n}\n\nconst DEV_NAMES: readonly DevAccountName[] = [\"Alice\", \"Bob\", \"Charlie\", \"Dave\", \"Eve\", \"Ferdie\"];\n\n/**\n * Parse a well-known dev-account SURI (`//Alice`, `//Bob`, …).\n *\n * Requires the `//` hard-derivation prefix and an exact-case name, matching\n * Substrate SURI semantics (and `createDevSigner`, which derives `//${name}`).\n * A bare `Alice` or a different case is NOT a dev SURI — it falls through to the\n * mnemonic path in `resolveSigner`, where it fails as an invalid mnemonic.\n */\nexport function parseDevAccountName(suri: string): DevAccountName | null {\n if (!suri.startsWith(\"//\")) return null;\n const name = suri.slice(2);\n return DEV_NAMES.find((n) => n === name) ?? null;\n}\n\n/**\n * Resolve a PolkadotSigner.\n *\n * 1. `--suri` flag → dev signer (dev name like //Alice, OR a BIP-39 mnemonic\n * with optional `//<path>` derivation suffix)\n * 2. Persisted QR session → session signer (via `authClient.getSessionSigner`)\n * 3. Neither → `SignerNotAvailableError`\n */\nexport async function resolveSigner(\n authClient: AuthClient,\n options?: SignerOptions,\n): Promise<ResolvedSigner> {\n if (options?.suri) {\n const devName = parseDevAccountName(options.suri);\n if (devName) {\n return {\n signer: createDevSigner(devName),\n address: ss58Encode(getDevPublicKey(devName)),\n source: \"dev\",\n destroy() {},\n };\n }\n // Mnemonic path. Split off an optional `//<path>` derivation suffix so\n // callers can target a sub-account of the same seed without a separate flag.\n const sepIdx = options.suri.indexOf(\"//\");\n const mnemonic = (sepIdx === -1 ? options.suri : options.suri.slice(0, sepIdx)).trim();\n const path = sepIdx === -1 ? \"\" : options.suri.slice(sepIdx);\n try {\n const account = seedToAccount(mnemonic, path);\n return {\n signer: account.signer,\n address: ss58Encode(account.publicKey),\n source: \"dev\",\n destroy() {},\n };\n } catch {\n throw new Error(\n `Unrecognized SURI \"${options.suri}\". ` +\n `Expected a dev name (${DEV_NAMES.join(\", \")}) or a BIP-39 mnemonic.`,\n );\n }\n }\n\n const session = await authClient.getSessionSigner();\n if (session) {\n return { ...session, source: \"session\" };\n }\n\n throw new SignerNotAvailableError();\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parity/product-sdk-auth",
3
- "version": "0.2.9",
3
+ "version": "0.3.0",
4
4
  "description": "Authentication and session signing for Polkadot CLI apps — QR/mobile sign-in",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -24,9 +24,9 @@
24
24
  "dependencies": {
25
25
  "polkadot-api": "^2.1.6",
26
26
  "@parity/product-sdk-address": "0.2.0",
27
- "@parity/product-sdk-terminal": "0.8.1",
28
- "@parity/product-sdk-keys": "0.3.23",
29
- "@parity/product-sdk-tx": "0.4.6"
27
+ "@parity/product-sdk-tx": "0.4.8",
28
+ "@parity/product-sdk-terminal": "0.9.0",
29
+ "@parity/product-sdk-keys": "0.3.25"
30
30
  },
31
31
  "devDependencies": {
32
32
  "tsup": "^8.5.1",
@@ -25,7 +25,7 @@ describe("summarizeOutcomes", () => {
25
25
  const resources: AllocatableResource[] = [
26
26
  { tag: "BulletInAllowance", value: undefined },
27
27
  { tag: "StatementStoreAllowance", value: undefined },
28
- { tag: "SmartContractAllowance", value: 0 },
28
+ { tag: "SmartContractAllowance", value: { tag: "Index", value: 0 } },
29
29
  ];
30
30
 
31
31
  // A minimal valid `Allocated` payload. `summarizeOutcomes` only reads the
@@ -57,8 +57,8 @@ export type ResourceTag = AllocatableResource["tag"];
57
57
  export const DEFAULT_RESOURCES: AllocatableResource[] = [
58
58
  { tag: "BulletInAllowance", value: undefined },
59
59
  { tag: "StatementStoreAllowance", value: undefined },
60
- // derivation index 0 = the default product account.
61
- { tag: "SmartContractAllowance", value: 0 },
60
+ // index 0 = the default product account.
61
+ { tag: "SmartContractAllowance", value: { tag: "Index", value: 0 } },
62
62
  ];
63
63
 
64
64
  /**