@parity/product-deploy 0.8.3-rc.6 → 0.8.3-rc.8

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.
Files changed (59) hide show
  1. package/bin/bulletin-deploy +33 -7
  2. package/dist/allocations-B65Is4Md.d.ts +97 -0
  3. package/dist/auth/index.d.ts +7 -0
  4. package/dist/auth/index.js +25 -0
  5. package/dist/auth/vendor/index.d.ts +32 -0
  6. package/dist/auth/vendor/index.js +26 -0
  7. package/dist/auth/vendor/ui/index.d.ts +15 -0
  8. package/dist/auth/vendor/ui/index.js +10 -0
  9. package/dist/auth-DkRZBK-T.d.ts +122 -0
  10. package/dist/auth-config.d.ts +39 -0
  11. package/dist/auth-config.js +20 -0
  12. package/dist/bug-report.js +4 -4
  13. package/dist/chunk-327NAPBD.js +52 -0
  14. package/dist/{chunk-22CE57IY.js → chunk-3OWKSL7K.js} +1 -1
  15. package/dist/chunk-7DGFJC6E.js +379 -0
  16. package/dist/{chunk-3TOFKDMY.js → chunk-EGNMZHMR.js} +1 -1
  17. package/dist/chunk-JQKKMUCT.js +0 -0
  18. package/dist/{chunk-L5Z3TJD7.js → chunk-OCKCB72S.js} +6 -6
  19. package/dist/{chunk-YUIBBHS2.js → chunk-OFVBJOFB.js} +1 -1
  20. package/dist/chunk-RIRDBSBG.js +36 -0
  21. package/dist/{chunk-Y7F57J2T.js → chunk-RPU72Z4B.js} +606 -384
  22. package/dist/{chunk-6XDIJYDO.js → chunk-T4PAK4YK.js} +2 -2
  23. package/dist/{chunk-M6DM2NUT.js → chunk-WHMNBSG7.js} +8 -2
  24. package/dist/{chunk-3ASTLJSZ.js → chunk-YOQLRCQV.js} +2 -2
  25. package/dist/{chunk-LX77LVIM.js → chunk-YXGNQZZF.js} +17 -3
  26. package/dist/chunk-probe.js +3 -3
  27. package/dist/commands/login.d.ts +28 -0
  28. package/dist/commands/login.js +63 -0
  29. package/dist/commands/logout.d.ts +21 -0
  30. package/dist/commands/logout.js +37 -0
  31. package/dist/commands/whoami.d.ts +22 -0
  32. package/dist/commands/whoami.js +47 -0
  33. package/dist/deploy.d.ts +40 -3
  34. package/dist/deploy.js +17 -8
  35. package/dist/dotns.js +3 -3
  36. package/dist/index.d.ts +1 -0
  37. package/dist/index.js +13 -12
  38. package/dist/manifest/publish.js +10 -9
  39. package/dist/memory-report.js +2 -2
  40. package/dist/merkle.d.ts +3 -1
  41. package/dist/merkle.js +9 -8
  42. package/dist/personhood/bind-paid-alias.js +3 -3
  43. package/dist/personhood/bind-personal-id.js +2 -2
  44. package/dist/personhood/bootstrap.js +16 -16
  45. package/dist/personhood/claim-pgas.js +2 -2
  46. package/dist/personhood/people-client.js +3 -3
  47. package/dist/personhood/proof-validity.js +2 -2
  48. package/dist/personhood/reprove.js +5 -5
  49. package/dist/run-state.js +1 -1
  50. package/dist/signer-CriGqahj.d.ts +35 -0
  51. package/dist/storage-signer.d.ts +38 -0
  52. package/dist/storage-signer.js +28 -0
  53. package/dist/telemetry.d.ts +1 -1
  54. package/dist/telemetry.js +2 -2
  55. package/dist/version-check.js +3 -3
  56. package/package.json +17 -3
  57. package/dist/{chunk-LHLCPDGL.js → chunk-7URNKK6J.js} +3 -3
  58. package/dist/{chunk-7Y7RDOGT.js → chunk-EATOPQFR.js} +5 -5
  59. package/dist/{chunk-SLE4P6MO.js → chunk-EJI3MX4G.js} +3 -3
@@ -58,6 +58,7 @@ for (let i = 0; i < args.length; i++) {
58
58
  else if (args[i] === "--publish") { flags.publish = true; }
59
59
  else if (args[i] === "--unpublish") { flags.unpublish = true; }
60
60
  else if (args[i] === "--fail-on-publish-error") { flags.failOnPublishError = true; }
61
+ else if (args[i] === "--suri") { flags.suri = args[++i]; }
61
62
  else if (args[i] === "--version" || args[i] === "-V") { flags.version = true; }
62
63
  else if (args[i] === "--help" || args[i] === "-h") { flags.help = true; }
63
64
  else { positional.push(args[i]); }
@@ -123,6 +124,36 @@ if (flags.unpublish) {
123
124
  }
124
125
  }
125
126
 
127
+ // Sign-in subcommands: login / logout / whoami.
128
+ // Lazy-imported from dist so the SSO deps never load in headless/deploy mode.
129
+ {
130
+ const sub = positional[0];
131
+ if (sub === "login" || sub === "logout" || sub === "whoami") {
132
+ const envId = flags.env ?? DEFAULT_ENV_ID;
133
+ // The SSO adapter's polkadot-api client fires a benign `DestroyedError:
134
+ // Client destroyed` on orphaned pending-response promises during WS teardown,
135
+ // AFTER the command has done its work (e.g. logout already disconnected). The
136
+ // deploy path's handlers (below) aren't installed yet here, so guard the
137
+ // command path: swallow that + connection-teardown noise, surface anything else.
138
+ const benignTeardown = (e) => {
139
+ const s = e instanceof Error ? `${e.name ?? ""} ${e.message ?? ""}` : String(e);
140
+ return isConnectionError(e) || /DestroyedError|Client destroyed/.test(s);
141
+ };
142
+ process.on("unhandledRejection", (e) => { if (!benignTeardown(e)) { console.error(e); process.exit(1); } });
143
+ process.on("uncaughtException", (e) => { if (!benignTeardown(e)) { console.error(e); process.exit(1); } });
144
+ try {
145
+ const capSub = sub.charAt(0).toUpperCase() + sub.slice(1);
146
+ const mod = await import(`../dist/commands/${sub}.js`);
147
+ await mod[`run${capSub}`](envId, { suri: flags.suri });
148
+ } catch (err) {
149
+ console.error(`Error: ${err?.message ?? err}`);
150
+ process.exit(1);
151
+ }
152
+ await closeTelemetry();
153
+ process.exit(0);
154
+ }
155
+ }
156
+
126
157
  // `product` subcommand. Only `validate` is wired today. `publish` and `resolve` arrive in later phases.
127
158
  if (positional[0] === "product") {
128
159
  const verb = positional[1];
@@ -378,6 +409,7 @@ try {
378
409
  const result = await deploy(buildDir, domain, {
379
410
  mnemonic: flags.mnemonic,
380
411
  derivationPath: flags.derivationPath,
412
+ suri: flags.suri,
381
413
  rpc: flags.rpc,
382
414
  env: flags.env,
383
415
  poolSize: flags.poolSize,
@@ -435,13 +467,7 @@ try {
435
467
  ? `--config ${flags.config}`
436
468
  : `bulletin-deploy.config.{ts,js,mjs} via walking up from ${buildDirAbs}`;
437
469
  console.log("");
438
- console.log(`⚠ No bulletin-deploy.config.ts found (${where}).`);
439
- console.log(` ${domain} was published as legacy contenthash only.`);
440
- console.log(" Add a bulletin-deploy.config.ts to enable the product manifest:");
441
- console.log(" • product icon, displayName, description on the base name");
442
- console.log(" • per-modality subnames (app.<id>.dot, widget.<id>.dot, worker.<id>.dot)");
443
- console.log(" • each modality’s archive CID on its subname contenthash");
444
- console.log(" See: https://github.com/paritytech/triangle-js-sdks (Product Manifest RFC)");
470
+ console.log(`⚠ No bulletin-deploy.config.ts ${domain} published as legacy contenthash only. Add config to enable product manifest: https://github.com/paritytech/triangle-js-sdks`);
445
471
  }
446
472
  }
447
473
 
@@ -0,0 +1,97 @@
1
+ import { UserSession } from '@parity/product-sdk-terminal';
2
+
3
+ /**
4
+ * Thin wrapper over the RFC-0010 `host_request_resource_allocation` call.
5
+ * Lifted from playground-cli `src/utils/allowances/host.ts` (issue #411).
6
+ *
7
+ * `@parity/product-sdk-terminal` does not yet re-export this API at its
8
+ * package root, but the underlying `UserSession` (from `@novasamatech/host-papp`)
9
+ * exposes `requestResourceAllocation()`. We call it directly here and gate the
10
+ * shape locally so consumers stay decoupled from the deep import path. Replace
11
+ * this whole module with a `product-sdk-terminal` re-export once the SDK
12
+ * surfaces the same call.
13
+ *
14
+ * Wire format (SCALE-derived, mirrors host-papp's
15
+ * `dist/sso/sessionManager/scale/resourceAllocation.d.ts`):
16
+ * request → { callingProductId, resources: AllocatableResource[], onExisting }
17
+ * response → AllocationOutcome[] (one per resource, in order)
18
+ *
19
+ * The mobile app handles `hostRequestResourceAllocation` in
20
+ * `AllowanceHostCalls.kt` and routes the user through an approval UI.
21
+ */
22
+
23
+ /**
24
+ * Structural mirror of host-papp's `ApAllocatableResource` codec type. We
25
+ * declare it locally because host-papp's package root doesn't re-export the
26
+ * codec types yet — when it does (and product-sdk-terminal threads them
27
+ * through) this can be replaced with a direct import.
28
+ *
29
+ * StatementStoreAllowance — write to the SSS (host_chat, allowance ring).
30
+ * BulletInAllowance — write to Bulletin (TransactionStorage.store).
31
+ * SmartContractAllowance — PGAS sponsoring for Revive contract calls.
32
+ * The `value` is the derivation index of the
33
+ * product account (0 for the default account).
34
+ * AutoSigning — surrender the product-account signing key to
35
+ * the host so it can sign on the user's behalf
36
+ * without per-call prompts. Not used today.
37
+ */
38
+ type AllocatableResource = {
39
+ tag: "StatementStoreAllowance";
40
+ value: undefined;
41
+ } | {
42
+ tag: "BulletInAllowance";
43
+ value: undefined;
44
+ } | {
45
+ tag: "SmartContractAllowance";
46
+ value: number;
47
+ } | {
48
+ tag: "AutoSigning";
49
+ value: undefined;
50
+ };
51
+ /**
52
+ * Outcome of one allocation. We don't read the inner `Allocated` payload
53
+ * (allowance slot keys, derivation secrets) — the host stores them and uses
54
+ * them transparently on subsequent calls. We just need the tag to know
55
+ * whether the allocation succeeded.
56
+ */
57
+ type AllocationOutcome = {
58
+ tag: "Allocated";
59
+ value: unknown;
60
+ } | {
61
+ tag: "Rejected";
62
+ value: undefined;
63
+ } | {
64
+ tag: "NotAvailable";
65
+ value: undefined;
66
+ };
67
+ /** Tag-only view, handy for downstream code that doesn't care about payloads. */
68
+ type ResourceTag = AllocatableResource["tag"];
69
+ type OnExistingAllowancePolicy = "Ignore" | "Increase";
70
+ /**
71
+ * Default mobile-granted resource set for a CLI product account: write access
72
+ * to the statement store + Bulletin, plus PGAS sponsoring for the default
73
+ * (index 0) product account.
74
+ */
75
+ declare const DEFAULT_RESOURCES: AllocatableResource[];
76
+ /**
77
+ * Send a `host_request_resource_allocation` request over the user's active
78
+ * session. The host (mobile wallet) prompts the user to approve and returns
79
+ * one outcome per requested resource in order.
80
+ *
81
+ * Throws on transport-level failures (Statement Store unreachable, encryption
82
+ * error, etc.). Per-resource refusals are reported as `Rejected`/`NotAvailable`
83
+ * outcomes — callers inspect the array to decide whether to proceed.
84
+ */
85
+ declare function requestResourceAllocation(session: UserSession, productId: string, resources?: AllocatableResource[], onExisting?: OnExistingAllowancePolicy): Promise<AllocationOutcome[]>;
86
+ interface AllocationSummary {
87
+ granted: AllocatableResource[];
88
+ rejected: AllocatableResource[];
89
+ unavailable: AllocatableResource[];
90
+ }
91
+ /**
92
+ * Bucket allocation outcomes by tag. Order-sensitive: `outcomes[i]` maps to
93
+ * `resources[i]`. Outcomes without a matching resource are silently dropped.
94
+ */
95
+ declare function summarizeOutcomes(outcomes: AllocationOutcome[], resources: AllocatableResource[]): AllocationSummary;
96
+
97
+ export { type AllocatableResource as A, DEFAULT_RESOURCES as D, type OnExistingAllowancePolicy as O, type ResourceTag as R, type AllocationOutcome as a, type AllocationSummary as b, requestResourceAllocation as r, summarizeOutcomes as s };
@@ -0,0 +1,7 @@
1
+ export { A as AuthClient, a as AuthConfig, C as ConnectResult, L as LoginHandle, b as LoginStatus, c as LogoutHandle, d as LogoutStatus, S as SessionAddresses, e as SessionHandle, f as createAuthClient } from '../auth-DkRZBK-T.js';
2
+ export { renderQrCode } from '@parity/product-sdk-terminal';
3
+ export { R as ResolvedSigner, S as SignerNotAvailableError, r as resolveSigner } from '../signer-CriGqahj.js';
4
+ export { A as AllocatableResource, a as AllocationOutcome, b as AllocationSummary, D as DEFAULT_RESOURCES, r as requestResourceAllocation, s as summarizeOutcomes } from '../allocations-B65Is4Md.js';
5
+ export { renderLoginStatus, renderLogoutStatus } from './vendor/ui/index.js';
6
+ import 'polkadot-api';
7
+ import '@parity/product-sdk-tx';
@@ -0,0 +1,25 @@
1
+ import "../chunk-JQKKMUCT.js";
2
+ import {
3
+ DEFAULT_RESOURCES,
4
+ SignerNotAvailableError,
5
+ createAuthClient,
6
+ requestResourceAllocation,
7
+ resolveSigner,
8
+ summarizeOutcomes
9
+ } from "../chunk-7DGFJC6E.js";
10
+ import {
11
+ renderLoginStatus,
12
+ renderLogoutStatus,
13
+ renderQrCode
14
+ } from "../chunk-RIRDBSBG.js";
15
+ export {
16
+ DEFAULT_RESOURCES,
17
+ SignerNotAvailableError,
18
+ createAuthClient,
19
+ renderLoginStatus,
20
+ renderLogoutStatus,
21
+ renderQrCode,
22
+ requestResourceAllocation,
23
+ resolveSigner,
24
+ summarizeOutcomes
25
+ };
@@ -0,0 +1,32 @@
1
+ export { A as AuthClient, a as AuthConfig, C as ConnectResult, L as LoginHandle, b as LoginStatus, c as LogoutHandle, d as LogoutStatus, S as SessionAddresses, e as SessionHandle, f as createAuthClient } from '../../auth-DkRZBK-T.js';
2
+ import { UserSession } from '@parity/product-sdk-terminal';
3
+ import { PolkadotSigner } from 'polkadot-api';
4
+ export { R as ResolvedSigner, S as SignerNotAvailableError, a as SignerOptions, b as SignerSource, p as parseDevAccountName, r as resolveSigner } from '../../signer-CriGqahj.js';
5
+ export { A as AllocatableResource, a as AllocationOutcome, b as AllocationSummary, D as DEFAULT_RESOURCES, O as OnExistingAllowancePolicy, R as ResourceTag, r as requestResourceAllocation, s as summarizeOutcomes } from '../../allocations-B65Is4Md.js';
6
+ import '@parity/product-sdk-tx';
7
+
8
+ interface ProductAccountRef {
9
+ productId: string;
10
+ derivationIndex: number;
11
+ }
12
+ declare const INCOMPLETE_SESSION_MESSAGE = "Stored login session is missing the root account public key. Run \"logout\" and then \"login\" to pair again.";
13
+ declare function sessionRootPublicKey(session: UserSession): Uint8Array;
14
+ /**
15
+ * Soft-derive the product account public key off a wallet root.
16
+ *
17
+ * This is the single source of truth for product-account math. Both
18
+ * `createSessionSigner` (which builds the signer used to actually sign
19
+ * on-chain) and `deriveSessionAddresses` (which builds the display triple)
20
+ * go through here so a future change to derivation params can't silently
21
+ * desync the signer from what we print.
22
+ *
23
+ * sr25519 soft derivation is composable on public keys alone, so deriving
24
+ * from `rootAccountId` locally produces the SAME public key the mobile
25
+ * derives privately via `mnemonic + "/product/...{idx}"`. Algorithm parity
26
+ * with mobile/desktop is locked by the frozen vectors in
27
+ * `@parity/product-sdk-keys`'s `product-account.test.ts`.
28
+ */
29
+ declare function deriveProductPublicKey(rootAccountId: Uint8Array, ref: ProductAccountRef): Uint8Array;
30
+ declare function createSessionSigner(session: UserSession, ref: ProductAccountRef): PolkadotSigner;
31
+
32
+ export { INCOMPLETE_SESSION_MESSAGE, type ProductAccountRef, createSessionSigner, deriveProductPublicKey, sessionRootPublicKey };
@@ -0,0 +1,26 @@
1
+ import {
2
+ DEFAULT_RESOURCES,
3
+ INCOMPLETE_SESSION_MESSAGE,
4
+ SignerNotAvailableError,
5
+ createAuthClient,
6
+ createSessionSigner,
7
+ deriveProductPublicKey,
8
+ parseDevAccountName,
9
+ requestResourceAllocation,
10
+ resolveSigner,
11
+ sessionRootPublicKey,
12
+ summarizeOutcomes
13
+ } from "../../chunk-7DGFJC6E.js";
14
+ export {
15
+ DEFAULT_RESOURCES,
16
+ INCOMPLETE_SESSION_MESSAGE,
17
+ SignerNotAvailableError,
18
+ createAuthClient,
19
+ createSessionSigner,
20
+ deriveProductPublicKey,
21
+ parseDevAccountName,
22
+ requestResourceAllocation,
23
+ resolveSigner,
24
+ sessionRootPublicKey,
25
+ summarizeOutcomes
26
+ };
@@ -0,0 +1,15 @@
1
+ export { renderQrCode } from '@parity/product-sdk-terminal';
2
+ import { b as LoginStatus, d as LogoutStatus } from '../../../auth-DkRZBK-T.js';
3
+ import 'polkadot-api';
4
+ import '../../../allocations-B65Is4Md.js';
5
+
6
+ /**
7
+ * Pure formatters that map the `LoginStatus` / `LogoutStatus` streams to
8
+ * one-line terminal messages. No I/O, no terminal deps — `import type` only,
9
+ * so this module stays unit-testable without the SSO stack.
10
+ */
11
+
12
+ declare function renderLoginStatus(status: LoginStatus): string;
13
+ declare function renderLogoutStatus(status: LogoutStatus): string;
14
+
15
+ export { renderLoginStatus, renderLogoutStatus };
@@ -0,0 +1,10 @@
1
+ import {
2
+ renderLoginStatus,
3
+ renderLogoutStatus,
4
+ renderQrCode
5
+ } from "../../../chunk-RIRDBSBG.js";
6
+ export {
7
+ renderLoginStatus,
8
+ renderLogoutStatus,
9
+ renderQrCode
10
+ };
@@ -0,0 +1,122 @@
1
+ import { TerminalAdapter, UserSession } from '@parity/product-sdk-terminal';
2
+ import { PolkadotSigner } from 'polkadot-api';
3
+ import { A as AllocatableResource, O as OnExistingAllowancePolicy, a as AllocationOutcome } from './allocations-B65Is4Md.js';
4
+
5
+ /**
6
+ * Per-product configuration injected into `createAuthClient`. Lifting the
7
+ * sign-in glue out of playground-cli (issue #411) means the env-specific
8
+ * constants playground hard-coded in its `config.ts` (DAPP_ID, product id,
9
+ * metadata URL, People-chain endpoints) become consumer-supplied so the same
10
+ * package serves `playground` and `dot` (and future products) unchanged.
11
+ */
12
+ interface AuthConfig {
13
+ /** The dApp identity string. Scopes the on-disk session namespace
14
+ * (`~/.polkadot-apps/${dappId}_*`) and the SSO pairing — each product
15
+ * gets its own, independently-revocable session. */
16
+ dappId: string;
17
+ /** Product id used to derive the product account (`/product/{productId}/{index}`). */
18
+ productId: string;
19
+ /** Derivation index of the product account (0 = default). */
20
+ derivationIndex: number;
21
+ /** Hosted app-metadata doc (name/icon) the mobile wallet reads at pairing. */
22
+ metadataUrl: string;
23
+ /** People-parachain RPC endpoints the terminal adapter connects to. */
24
+ peopleEndpoints: string[];
25
+ }
26
+
27
+ /**
28
+ * The three addresses we surface from a paired session.
29
+ *
30
+ * - `rootAddress` — SS58 of `session.rootAccountId`, the `rootUserAccountId`
31
+ * the mobile app sent over the SSO handshake (bare-mnemonic sr25519 root on
32
+ * current mobile builds). Keyed by `Resources.Consumers` on the People
33
+ * parachain, so it's the right input for `lookupUsername`.
34
+ * - `productAddress` — SS58 of the product account derived via
35
+ * `product/{productId}/{index}` from `rootAccountId`. This is what actually
36
+ * signs on-chain transactions from the CLI.
37
+ * - `productH160` — the same product pubkey as a 20-byte EVM address (Revive /
38
+ * contracts view). Derived from the SAME pubkey as `productAddress`.
39
+ */
40
+ interface SessionAddresses {
41
+ rootAddress: string;
42
+ productAddress: string;
43
+ productH160: `0x${string}`;
44
+ }
45
+ type ConnectResult = {
46
+ kind: "existing";
47
+ address: string;
48
+ addresses: SessionAddresses;
49
+ } | {
50
+ kind: "qr";
51
+ qrCode: string;
52
+ login: LoginHandle;
53
+ };
54
+ type LoginStatus = {
55
+ step: "waiting";
56
+ } | {
57
+ step: "paired";
58
+ } | {
59
+ step: "pending";
60
+ stage: string;
61
+ } | {
62
+ step: "success";
63
+ address: string;
64
+ addresses: SessionAddresses;
65
+ } | {
66
+ step: "error";
67
+ message: string;
68
+ };
69
+ interface LoginHandle {
70
+ adapter: TerminalAdapter;
71
+ /** The authenticate() promise — already running since connect(). */
72
+ authPromise: ReturnType<TerminalAdapter["sso"]["authenticate"]>;
73
+ }
74
+ /**
75
+ * A session signer bundle — the signer plus an explicit `destroy()` that tears
76
+ * down the long-lived adapter the signer depends on. Callers MUST invoke
77
+ * `destroy()` once done — the WebSocket keeps the event loop alive.
78
+ */
79
+ interface SessionHandle {
80
+ address: string;
81
+ addresses: SessionAddresses;
82
+ signer: PolkadotSigner;
83
+ userSession: UserSession;
84
+ destroy(): void;
85
+ }
86
+ type LogoutStatus = {
87
+ step: "disconnecting";
88
+ address: string;
89
+ } | {
90
+ step: "success";
91
+ address: string;
92
+ } | {
93
+ step: "partial";
94
+ address: string;
95
+ reason: string;
96
+ } | {
97
+ step: "error";
98
+ message: string;
99
+ };
100
+ interface LogoutHandle {
101
+ adapter: TerminalAdapter;
102
+ address: string;
103
+ session: UserSession;
104
+ }
105
+ /** The product-bound auth surface returned by `createAuthClient`. */
106
+ interface AuthClient {
107
+ connect(): Promise<ConnectResult>;
108
+ waitForLogin(handle: LoginHandle, onStatus: (status: LoginStatus) => void): Promise<string | null>;
109
+ getSessionSigner(): Promise<SessionHandle | null>;
110
+ findSession(): Promise<LogoutHandle | null>;
111
+ waitForLogout(handle: LogoutHandle, onStatus: (status: LogoutStatus) => void): Promise<void>;
112
+ requestAllocation(session: UserSession, resources?: AllocatableResource[], onExisting?: OnExistingAllowancePolicy): Promise<AllocationOutcome[]>;
113
+ clearLocalAppStorage(dir?: string): Promise<void>;
114
+ }
115
+ /**
116
+ * Build an auth client bound to a product's `AuthConfig`. All adapter creation,
117
+ * address derivation, and session-storage scoping read from `config`, so the
118
+ * same code serves any product.
119
+ */
120
+ declare function createAuthClient(config: AuthConfig): AuthClient;
121
+
122
+ export { type AuthClient as A, type ConnectResult as C, type LoginHandle as L, type SessionAddresses as S, type AuthConfig as a, type LoginStatus as b, type LogoutHandle as c, type LogoutStatus as d, type SessionHandle as e, createAuthClient as f };
@@ -0,0 +1,39 @@
1
+ import { a as AuthConfig, A as AuthClient } from './auth-DkRZBK-T.js';
2
+ import { EnvironmentsDoc } from './environments.js';
3
+ import '@parity/product-sdk-terminal';
4
+ import 'polkadot-api';
5
+ import './allocations-B65Is4Md.js';
6
+
7
+ /** dApp identity that scopes the SSO session namespace on disk. Currently reuses
8
+ * playground's identity for dev; swap to e.g. "dot-deploy" when dot has its own
9
+ * hosted metadata document. */
10
+ declare const DOT_DAPP_ID = "dot-cli";
11
+ /** Product id used for product-account derivation (`/product/{productId}/{index}`).
12
+ * Reuses playground's product id so dev sessions are shared. */
13
+ declare const DOT_PRODUCT_ID = "playground.dot";
14
+ /** Derivation index (0 = default product account). */
15
+ declare const DOT_DERIVATION_INDEX = 0;
16
+ /** Metadata document URL the mobile wallet fetches at pairing to display the app name/icon.
17
+ * Reuses playground's hosted gist for dev — swap once dot has its own hosted doc. */
18
+ declare const DOT_TERMINAL_METADATA_URL = "https://gist.githubusercontent.com/ReinhardHatko/1967dd3f4afe78683cc0ba14d6ec8744/raw/c1625eb7ed7671b7e09a3fa2a25998dde33c70b8/metadata.json";
19
+ /**
20
+ * Returns true if there is a persisted SSO session file on disk.
21
+ * Does NOT load the SSO stack — uses only node fs/os/path.
22
+ * Safe to call from headless/pool paths.
23
+ */
24
+ declare function hasPersistedSession(): boolean;
25
+ /**
26
+ * Build an `AuthConfig` from the bundled environments document.
27
+ *
28
+ * Reads the People-parachain endpoint for `envId` and assembles the config that
29
+ * `createAuthClient` needs. Throws with a clear message if the people chain or
30
+ * its endpoint for `envId` is absent.
31
+ */
32
+ declare function buildAuthConfig(doc: EnvironmentsDoc, envId: string): AuthConfig;
33
+ /**
34
+ * Lazily create an auth client for the given environment. Imports the facade
35
+ * only when called so the SSO deps don't load in headless/mnemonic paths.
36
+ */
37
+ declare function getAuthClient(envId: string): Promise<AuthClient>;
38
+
39
+ export { DOT_DAPP_ID, DOT_DERIVATION_INDEX, DOT_PRODUCT_ID, DOT_TERMINAL_METADATA_URL, buildAuthConfig, getAuthClient, hasPersistedSession };
@@ -0,0 +1,20 @@
1
+ import {
2
+ DOT_DAPP_ID,
3
+ DOT_DERIVATION_INDEX,
4
+ DOT_PRODUCT_ID,
5
+ DOT_TERMINAL_METADATA_URL,
6
+ buildAuthConfig,
7
+ getAuthClient,
8
+ hasPersistedSession
9
+ } from "./chunk-327NAPBD.js";
10
+ import "./chunk-5K3RI5C2.js";
11
+ import "./chunk-ZOC4GITL.js";
12
+ export {
13
+ DOT_DAPP_ID,
14
+ DOT_DERIVATION_INDEX,
15
+ DOT_PRODUCT_ID,
16
+ DOT_TERMINAL_METADATA_URL,
17
+ buildAuthConfig,
18
+ getAuthClient,
19
+ hasPersistedSession
20
+ };
@@ -9,10 +9,10 @@ import {
9
9
  offerBugReport,
10
10
  scrubSecrets,
11
11
  setDeployContext
12
- } from "./chunk-6XDIJYDO.js";
13
- import "./chunk-YUIBBHS2.js";
14
- import "./chunk-M6DM2NUT.js";
15
- import "./chunk-LX77LVIM.js";
12
+ } from "./chunk-T4PAK4YK.js";
13
+ import "./chunk-OFVBJOFB.js";
14
+ import "./chunk-WHMNBSG7.js";
15
+ import "./chunk-YXGNQZZF.js";
16
16
  export {
17
17
  buildCliFlagsSummary,
18
18
  buildLabels,
@@ -0,0 +1,52 @@
1
+ import {
2
+ loadEnvironments
3
+ } from "./chunk-5K3RI5C2.js";
4
+
5
+ // src/auth-config.ts
6
+ import { existsSync } from "fs";
7
+ import { homedir } from "os";
8
+ import { join } from "path";
9
+ var DOT_DAPP_ID = "dot-cli";
10
+ var DOT_PRODUCT_ID = "playground.dot";
11
+ var DOT_DERIVATION_INDEX = 0;
12
+ var DOT_TERMINAL_METADATA_URL = "https://gist.githubusercontent.com/ReinhardHatko/1967dd3f4afe78683cc0ba14d6ec8744/raw/c1625eb7ed7671b7e09a3fa2a25998dde33c70b8/metadata.json";
13
+ function hasPersistedSession() {
14
+ return existsSync(join(homedir(), ".polkadot-apps", `${DOT_DAPP_ID}_SsoSessions.json`));
15
+ }
16
+ function buildAuthConfig(doc, envId) {
17
+ const peopleChain = doc.chains.find((c) => c.id === "people");
18
+ if (!peopleChain) {
19
+ throw new Error(
20
+ `No "people" chain found in environments doc. Add a "people" entry under "chains" in environments.json.`
21
+ );
22
+ }
23
+ const endpoint = peopleChain.endpoints[envId];
24
+ if (!endpoint) {
25
+ throw new Error(
26
+ `No people-chain endpoint for environment "${envId}". Available envs: ${Object.keys(peopleChain.endpoints).join(", ")}.`
27
+ );
28
+ }
29
+ const peopleEndpoints = Array.isArray(endpoint.wss) ? endpoint.wss : [endpoint.wss];
30
+ return {
31
+ dappId: DOT_DAPP_ID,
32
+ productId: DOT_PRODUCT_ID,
33
+ derivationIndex: DOT_DERIVATION_INDEX,
34
+ metadataUrl: DOT_TERMINAL_METADATA_URL,
35
+ peopleEndpoints
36
+ };
37
+ }
38
+ async function getAuthClient(envId) {
39
+ const { createAuthClient } = await import("./auth/index.js");
40
+ const { doc } = await loadEnvironments();
41
+ return createAuthClient(buildAuthConfig(doc, envId));
42
+ }
43
+
44
+ export {
45
+ DOT_DAPP_ID,
46
+ DOT_PRODUCT_ID,
47
+ DOT_DERIVATION_INDEX,
48
+ DOT_TERMINAL_METADATA_URL,
49
+ hasPersistedSession,
50
+ buildAuthConfig,
51
+ getAuthClient
52
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  captureWarning
3
- } from "./chunk-M6DM2NUT.js";
3
+ } from "./chunk-WHMNBSG7.js";
4
4
 
5
5
  // src/chunk-probe.ts
6
6
  import { Twox128, Blake2128Concat, decAnyMetadata, unifyMetadata } from "@polkadot-api/substrate-bindings";