@parity/product-deploy 0.8.3-rc.8 → 0.9.0-rc.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.
Files changed (59) hide show
  1. package/LICENSE +674 -201
  2. package/README.md +59 -2
  3. package/assets/environments.json +0 -1
  4. package/bin/bulletin-deploy +21 -1
  5. package/dist/auth/index.d.ts +2 -3
  6. package/dist/auth/index.js +2 -1
  7. package/dist/auth/vendor/index.d.ts +2 -3
  8. package/dist/auth/vendor/index.js +2 -1
  9. package/dist/auth/vendor/ui/index.d.ts +1 -2
  10. package/dist/auth-C-Pel0AT.d.ts +235 -0
  11. package/dist/auth-config.d.ts +30 -8
  12. package/dist/auth-config.js +14 -6
  13. package/dist/bug-report.js +4 -4
  14. package/dist/{chunk-YXGNQZZF.js → chunk-2SR5D4CP.js} +19 -15
  15. package/dist/{chunk-OFVBJOFB.js → chunk-6NW5M3F5.js} +9 -20
  16. package/dist/{chunk-7DGFJC6E.js → chunk-DHY2ZXVZ.js} +81 -42
  17. package/dist/chunk-G56VYTUD.js +75 -0
  18. package/dist/{chunk-5K3RI5C2.js → chunk-GL3U7K2B.js} +0 -1
  19. package/dist/{chunk-327NAPBD.js → chunk-H4LWILH4.js} +32 -6
  20. package/dist/chunk-J7CYVTAW.js +43 -0
  21. package/dist/{chunk-WHMNBSG7.js → chunk-LCKLYFAZ.js} +5 -4
  22. package/dist/{chunk-3OWKSL7K.js → chunk-NP4SLURL.js} +1 -1
  23. package/dist/{chunk-T4PAK4YK.js → chunk-O2NWQLYB.js} +2 -2
  24. package/dist/{chunk-RPU72Z4B.js → chunk-RD2QHYTL.js} +242 -36
  25. package/dist/{chunk-EGNMZHMR.js → chunk-WZBAQCA5.js} +15 -4
  26. package/dist/{chunk-YOQLRCQV.js → chunk-YIKGVALU.js} +3 -3
  27. package/dist/chunk-probe.js +3 -3
  28. package/dist/commands/login.d.ts +34 -9
  29. package/dist/commands/login.js +186 -30
  30. package/dist/commands/logout.d.ts +1 -2
  31. package/dist/commands/logout.js +5 -3
  32. package/dist/commands/whoami.d.ts +1 -2
  33. package/dist/commands/whoami.js +7 -4
  34. package/dist/deploy.d.ts +19 -4
  35. package/dist/deploy.js +14 -9
  36. package/dist/dotns.d.ts +7 -0
  37. package/dist/dotns.js +4 -4
  38. package/dist/environments.js +1 -1
  39. package/dist/index.js +11 -10
  40. package/dist/manifest/publish.js +11 -10
  41. package/dist/manifest/types.d.ts +1 -1
  42. package/dist/memory-report.js +2 -2
  43. package/dist/merkle.js +10 -9
  44. package/dist/personhood/bootstrap.js +10 -10
  45. package/dist/personhood/people-client.js +4 -4
  46. package/dist/run-state.js +1 -1
  47. package/dist/{signer-CriGqahj.d.ts → signer-vR6KKC7V.d.ts} +1 -1
  48. package/dist/spinner.d.ts +21 -0
  49. package/dist/spinner.js +6 -0
  50. package/dist/sss-allowance.d.ts +29 -0
  51. package/dist/sss-allowance.js +8 -0
  52. package/dist/storage-signer.d.ts +94 -2
  53. package/dist/storage-signer.js +18 -9
  54. package/dist/telemetry.js +2 -2
  55. package/dist/version-check.d.ts +0 -3
  56. package/dist/version-check.js +3 -3
  57. package/package.json +19 -15
  58. package/dist/allocations-B65Is4Md.d.ts +0 -97
  59. package/dist/auth-DkRZBK-T.d.ts +0 -122
@@ -1,9 +1,3 @@
1
- import {
2
- bindPersonalIdToAccount
3
- } from "../chunk-7URNKK6J.js";
4
- import {
5
- runChainPrereqProbes
6
- } from "../chunk-XAB7WM3S.js";
7
1
  import {
8
2
  claimPgas
9
3
  } from "../chunk-EATOPQFR.js";
@@ -16,9 +10,15 @@ import {
16
10
  bindPaidAliasToAccount
17
11
  } from "../chunk-OCKCB72S.js";
18
12
  import "../chunk-EJI3MX4G.js";
13
+ import {
14
+ bindPersonalIdToAccount
15
+ } from "../chunk-7URNKK6J.js";
19
16
  import {
20
17
  bytesToHex
21
18
  } from "../chunk-ZYVGHDMU.js";
19
+ import {
20
+ runChainPrereqProbes
21
+ } from "../chunk-XAB7WM3S.js";
22
22
  import {
23
23
  DOTNS_CONTEXT_BYTES,
24
24
  PEOPLE_MEMBER_IDENTIFIER_HEX,
@@ -26,13 +26,13 @@ import {
26
26
  } from "../chunk-SI2ZUOYD.js";
27
27
  import {
28
28
  WS_HEARTBEAT_TIMEOUT_MS
29
- } from "../chunk-EGNMZHMR.js";
29
+ } from "../chunk-WZBAQCA5.js";
30
30
  import "../chunk-QS7YU76C.js";
31
- import "../chunk-WHMNBSG7.js";
32
- import "../chunk-YXGNQZZF.js";
31
+ import "../chunk-LCKLYFAZ.js";
32
+ import "../chunk-2SR5D4CP.js";
33
33
  import {
34
34
  loadEnvironments
35
- } from "../chunk-5K3RI5C2.js";
35
+ } from "../chunk-GL3U7K2B.js";
36
36
  import "../chunk-ZOC4GITL.js";
37
37
 
38
38
  // src/personhood/bootstrap.ts
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  WS_HEARTBEAT_TIMEOUT_MS
3
- } from "../chunk-EGNMZHMR.js";
3
+ } from "../chunk-WZBAQCA5.js";
4
4
  import "../chunk-QS7YU76C.js";
5
- import "../chunk-WHMNBSG7.js";
6
- import "../chunk-YXGNQZZF.js";
5
+ import "../chunk-LCKLYFAZ.js";
6
+ import "../chunk-2SR5D4CP.js";
7
7
  import {
8
8
  loadEnvironments
9
- } from "../chunk-5K3RI5C2.js";
9
+ } from "../chunk-GL3U7K2B.js";
10
10
  import "../chunk-ZOC4GITL.js";
11
11
 
12
12
  // src/personhood/people-client.ts
package/dist/run-state.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  shouldSkipStaleWarning,
8
8
  stateFilePath,
9
9
  writeRunState
10
- } from "./chunk-YXGNQZZF.js";
10
+ } from "./chunk-2SR5D4CP.js";
11
11
  export {
12
12
  VERSION,
13
13
  loadRunState,
@@ -1,6 +1,6 @@
1
1
  import { DevAccountName } from '@parity/product-sdk-tx';
2
2
  import { PolkadotSigner } from 'polkadot-api';
3
- import { e as SessionHandle, S as SessionAddresses, A as AuthClient } from './auth-DkRZBK-T.js';
3
+ import { h as SessionHandle, S as SessionAddresses, c as AuthClient } from './auth-C-Pel0AT.js';
4
4
 
5
5
  type SignerSource = "dev" | "session";
6
6
  interface ResolvedSigner {
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Minimal terminal spinner with an elapsed-time readout.
3
+ *
4
+ * Renders `⠙ <label>… (3s)` on a single line via carriage-return redraw, in the
5
+ * style of Claude Code's live status. Built for awaiting a single async op
6
+ * (e.g. polling on-chain authorization during login).
7
+ *
8
+ * Footgun-safe by design:
9
+ * - the redraw interval is .unref()'d, so it never keeps the Node event loop
10
+ * alive — callers that process.exit() still exit cleanly.
11
+ * - stop() is idempotent and always clears the interval.
12
+ * - in a non-TTY (CI / piped output) it prints one static line and no \r
13
+ * animation, so logs stay clean.
14
+ */
15
+ interface Spinner {
16
+ /** Stop the spinner, clear the line, and optionally print a final line. */
17
+ stop(finalLine?: string): void;
18
+ }
19
+ declare function startSpinner(label: string, stream?: NodeJS.WriteStream): Spinner;
20
+
21
+ export { type Spinner, startSpinner };
@@ -0,0 +1,6 @@
1
+ import {
2
+ startSpinner
3
+ } from "./chunk-J7CYVTAW.js";
4
+ export {
5
+ startSpinner
6
+ };
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Statement Store (SSS) allowance preflight — pure storage read, no signing.
3
+ *
4
+ * The People chain stores SSS allowances under a deterministic key:
5
+ * b":statement_allowance:" ++ raw_32_byte_account_pubkey
6
+ *
7
+ * We can check this via a single `state_getStorage` RPC call — no transaction,
8
+ * no phone dialog. Non-null, non-"0x" result means the allowance is present.
9
+ *
10
+ * Reference: substrate/primitives/statement-store/src/lib.rs
11
+ */
12
+ /**
13
+ * Build the hex-encoded storage key for an SSS allowance check.
14
+ *
15
+ * Format: 0x + hex(":statement_allowance:" + pubkey_32_bytes)
16
+ * No twox/blake2 hashing — the key is the raw concatenation.
17
+ */
18
+ declare function sssStorageKey(pubkey: Uint8Array): string;
19
+ /**
20
+ * Check whether a Statement Store allowance is present on the People chain.
21
+ *
22
+ * @returns
23
+ * - `true` — allowance present (continue)
24
+ * - `false` — allowance absent / expired (user must re-login)
25
+ * - `null` — could not determine (network error or timeout; caller decides whether to block)
26
+ */
27
+ declare function checkSSSAllowance(pubkey: Uint8Array, peopleEndpoints: string[], timeoutMs?: number): Promise<boolean | null>;
28
+
29
+ export { checkSSSAllowance, sssStorageKey };
@@ -0,0 +1,8 @@
1
+ import {
2
+ checkSSSAllowance,
3
+ sssStorageKey
4
+ } from "./chunk-G56VYTUD.js";
5
+ export {
6
+ checkSSSAllowance,
7
+ sssStorageKey
8
+ };
@@ -5,6 +5,11 @@ import { PolkadotSigner } from 'polkadot-api';
5
5
  * Returns null when not cached. storageDir defaults to os.homedir().
6
6
  *
7
7
  * Cache format: @parity/product-sdk-terminal host-cache.ts v1.
8
+ *
9
+ * NOTE: reads the pre-0.8.6 plaintext cache format (_AllowanceKeys.json). On host-papp 0.8.6+
10
+ * the cache is AES-encrypted and keyed by sessionId (_AllowanceKeys_<sessionId>.json), so
11
+ * this function returns null on 0.8.6+ installations. Use adapter.allowance.getBulletinSigner()
12
+ * for runtime checks instead.
8
13
  */
9
14
  declare function readBulletinSlotSigner(appId: string, storageDir?: string): Promise<{
10
15
  signer: PolkadotSigner;
@@ -24,9 +29,96 @@ declare function extractBulletinSlotKey(outcomes: {
24
29
  tag: string;
25
30
  value: unknown;
26
31
  }[]): `0x${string}` | null;
32
+ /**
33
+ * Typed error thrown by getSlotSignerProvider when the slot account is not
34
+ * usably authorized on-chain. The `reason` field lets callers produce
35
+ * targeted messages without string-matching.
36
+ *
37
+ * "missing" — no Authorizations entry found for the slot account.
38
+ * "expired" — entry exists but expiration ≤ current finalized block.
39
+ */
40
+ declare class BulletinSlotAuthError extends Error {
41
+ readonly reason: "missing" | "expired";
42
+ /** The on-chain expiration block (only set when reason === "expired"). */
43
+ readonly expiration?: number;
44
+ constructor(reason: "missing" | "expired", ss58: string, expiration?: number);
45
+ }
46
+ /**
47
+ * Pure active-test for a Bulletin Authorizations entry.
48
+ * Shared by getSlotSignerProvider (single probe) and the poll loop in
49
+ * waitForBulletinAuthorization (repeated probes).
50
+ *
51
+ * @param auth Raw value from TransactionStorage.Authorizations.getValue — null when absent.
52
+ * @param blockNumber Current finalized block number.
53
+ */
54
+ declare function isBulletinAuthActive(auth: {
55
+ expiration?: bigint | number;
56
+ } | null | undefined, blockNumber: number): {
57
+ active: true;
58
+ expiration: number;
59
+ } | {
60
+ active: false;
61
+ reason: "missing" | "expired";
62
+ expiration?: number;
63
+ };
64
+ /**
65
+ * Internal poll loop for waitForBulletinAuthorization.
66
+ * Injecting the query function keeps the loop unit-testable without a real WS connection.
67
+ *
68
+ * @param queryFn Async function that returns {auth, blockNumber} — mock in tests.
69
+ * @param opts pollMs (default 2000), timeoutMs (default 90000).
70
+ *
71
+ * Transient query errors (thrown by queryFn) are retried until the deadline — a
72
+ * flaky WS read is NOT treated as "unauthorized". Only a clean active-check
73
+ * returning false advances toward timeout.
74
+ */
75
+ declare function pollUntilBulletinAuthorized(queryFn: () => Promise<{
76
+ auth: {
77
+ expiration?: bigint | number;
78
+ } | null | undefined;
79
+ blockNumber: number;
80
+ }>, opts?: {
81
+ timeoutMs?: number;
82
+ pollMs?: number;
83
+ }): Promise<{
84
+ authorized: true;
85
+ expiration: number;
86
+ } | {
87
+ authorized: false;
88
+ reason: "timeout";
89
+ }>;
90
+ /**
91
+ * Open a Bulletin WS connection, poll Authorizations until the slot account's
92
+ * authorization lands on-chain, then destroy the connection and return.
93
+ *
94
+ * Intended for the fresh-login path in src/commands/login.ts to gate the
95
+ * success summary until the authorization is finalized (avoids the first-run
96
+ * race where deploy checks immediately after phone approval but before the
97
+ * on-chain tx is included).
98
+ *
99
+ * Does NOT print any progress — the caller (login.ts) owns the output via a
100
+ * spinner. Pass `quiet: true` to suppress connection status chatter so the
101
+ * caller's spinner owns the line.
102
+ *
103
+ * @returns `{ authorized: true, expiration }` on success;
104
+ * `{ authorized: false, reason: "timeout" }` after the configured timeout.
105
+ */
106
+ declare function waitForBulletinAuthorization(ss58: string, opts?: {
107
+ timeoutMs?: number;
108
+ pollMs?: number;
109
+ quiet?: boolean;
110
+ endpoints?: string[];
111
+ }): Promise<{
112
+ authorized: true;
113
+ expiration: number;
114
+ } | {
115
+ authorized: false;
116
+ reason: "timeout";
117
+ }>;
27
118
  /**
28
119
  * Create a Bulletin WS connection for the slot-account signer.
29
- * No authorization checkspool fallback is handled by the caller (selectStorageReconnect).
120
+ * Checks on-chain authorization (single probe no poll). Throws BulletinSlotAuthError
121
+ * with reason "missing" | "expired" so callers can distinguish and produce targeted messages.
30
122
  */
31
123
  declare function getSlotSignerProvider(signer: PolkadotSigner, ss58: string): Promise<{
32
124
  client: any;
@@ -35,4 +127,4 @@ declare function getSlotSignerProvider(signer: PolkadotSigner, ss58: string): Pr
35
127
  ss58: string;
36
128
  }>;
37
129
 
38
- export { extractBulletinSlotKey, getSlotSignerProvider, readBulletinSlotSigner, writeBulletinSlotKey };
130
+ export { BulletinSlotAuthError, extractBulletinSlotKey, getSlotSignerProvider, isBulletinAuthActive, pollUntilBulletinAuthorized, readBulletinSlotSigner, waitForBulletinAuthorization, writeBulletinSlotKey };
@@ -1,28 +1,37 @@
1
1
  import {
2
+ BulletinSlotAuthError,
2
3
  extractBulletinSlotKey,
3
4
  getSlotSignerProvider,
5
+ isBulletinAuthActive,
6
+ pollUntilBulletinAuthorized,
4
7
  readBulletinSlotSigner,
8
+ waitForBulletinAuthorization,
5
9
  writeBulletinSlotKey
6
- } from "./chunk-RPU72Z4B.js";
10
+ } from "./chunk-RD2QHYTL.js";
11
+ import "./chunk-G56VYTUD.js";
7
12
  import "./chunk-HOTQDYHD.js";
8
13
  import "./chunk-IW3X2MJF.js";
9
14
  import "./chunk-KOSF5FDO.js";
10
15
  import "./chunk-J3NIXHZZ.js";
11
16
  import "./chunk-S7EM5VMW.js";
12
- import "./chunk-327NAPBD.js";
13
- import "./chunk-T4PAK4YK.js";
14
- import "./chunk-OFVBJOFB.js";
15
- import "./chunk-3OWKSL7K.js";
17
+ import "./chunk-H4LWILH4.js";
18
+ import "./chunk-O2NWQLYB.js";
19
+ import "./chunk-6NW5M3F5.js";
20
+ import "./chunk-NP4SLURL.js";
16
21
  import "./chunk-C2TS5MER.js";
17
- import "./chunk-EGNMZHMR.js";
22
+ import "./chunk-WZBAQCA5.js";
18
23
  import "./chunk-QS7YU76C.js";
19
- import "./chunk-WHMNBSG7.js";
20
- import "./chunk-YXGNQZZF.js";
21
- import "./chunk-5K3RI5C2.js";
24
+ import "./chunk-LCKLYFAZ.js";
25
+ import "./chunk-2SR5D4CP.js";
26
+ import "./chunk-GL3U7K2B.js";
22
27
  import "./chunk-ZOC4GITL.js";
23
28
  export {
29
+ BulletinSlotAuthError,
24
30
  extractBulletinSlotKey,
25
31
  getSlotSignerProvider,
32
+ isBulletinAuthActive,
33
+ pollUntilBulletinAuthorized,
26
34
  readBulletinSlotSigner,
35
+ waitForBulletinAuthorization,
27
36
  writeBulletinSlotKey
28
37
  };
package/dist/telemetry.js CHANGED
@@ -33,8 +33,8 @@ import {
33
33
  truncateAddress,
34
34
  withDeploySpan,
35
35
  withSpan
36
- } from "./chunk-WHMNBSG7.js";
37
- import "./chunk-YXGNQZZF.js";
36
+ } from "./chunk-LCKLYFAZ.js";
37
+ import "./chunk-2SR5D4CP.js";
38
38
  export {
39
39
  VERSION,
40
40
  __setDeployRootSpanForTest,
@@ -3,8 +3,6 @@ import { Readable } from 'node:stream';
3
3
  interface VersionInfo {
4
4
  latest: string;
5
5
  minimumFromRegistry: string | null;
6
- minimumFromKillSwitch: string | null;
7
- killSwitchMessage: string | null;
8
6
  }
9
7
  declare function checkNodeVersion(enginesNode: string, currentVersion: string): string | null;
10
8
  declare function compareSemver(a: string, b: string): number;
@@ -20,7 +18,6 @@ type VersionVerdict = {
20
18
  action: "forced_update";
21
19
  currentVersion: string;
22
20
  minimumVersion: string;
23
- message: string | null;
24
21
  } | {
25
22
  action: "suggest_update";
26
23
  currentVersion: string;
@@ -11,9 +11,9 @@ import {
11
11
  isPreReleaseVersion,
12
12
  preReleaseWarning,
13
13
  promptYesNo
14
- } from "./chunk-OFVBJOFB.js";
15
- import "./chunk-WHMNBSG7.js";
16
- import "./chunk-YXGNQZZF.js";
14
+ } from "./chunk-6NW5M3F5.js";
15
+ import "./chunk-LCKLYFAZ.js";
16
+ import "./chunk-2SR5D4CP.js";
17
17
  export {
18
18
  assessVersion,
19
19
  checkNodeVersion,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parity/product-deploy",
3
- "version": "0.8.3-rc.8",
3
+ "version": "0.9.0-rc.0",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -43,15 +43,17 @@
43
43
  "tools/release-retry-wrapper.mjs"
44
44
  ],
45
45
  "scripts": {
46
- "build": "tsup src/index.ts src/deploy.ts src/dotns.ts src/pool.ts src/telemetry.ts src/memory-report.ts src/merkle.ts src/gh-pages-mirror.ts src/version-check.ts src/bug-report.ts src/run-state.ts src/environments.ts src/errors.ts src/manifest.ts src/chunk-probe.ts src/manifest-embed.ts src/manifest-fetch.ts src/manifest-roundtrip.ts src/incremental-stats.ts src/chunker.ts src/personhood/encoding.ts src/personhood/hashing.ts src/personhood/constants.ts src/personhood/member-key.ts src/personhood/people-client.ts src/personhood/proof-validity.ts src/personhood/reprove.ts src/personhood/bind-personal-id.ts src/personhood/claim-pgas.ts src/personhood/bind-paid-alias.ts src/personhood/bootstrap.ts src/personhood/chain-prereqs.ts src/manifest/types.ts src/manifest/schema.ts src/manifest/byte-budget.ts src/manifest/config-load.ts src/manifest/publish.ts src/auth/index.ts src/auth/vendor/index.ts src/auth/vendor/ui/index.ts src/auth-config.ts src/commands/login.ts src/commands/logout.ts src/commands/whoami.ts src/storage-signer.ts --format esm --dts --clean --target node22",
46
+ "build": "tsup src/index.ts src/deploy.ts src/dotns.ts src/pool.ts src/telemetry.ts src/memory-report.ts src/merkle.ts src/gh-pages-mirror.ts src/version-check.ts src/bug-report.ts src/run-state.ts src/environments.ts src/errors.ts src/manifest.ts src/chunk-probe.ts src/manifest-embed.ts src/manifest-fetch.ts src/manifest-roundtrip.ts src/incremental-stats.ts src/chunker.ts src/personhood/encoding.ts src/personhood/hashing.ts src/personhood/constants.ts src/personhood/member-key.ts src/personhood/people-client.ts src/personhood/proof-validity.ts src/personhood/reprove.ts src/personhood/bind-personal-id.ts src/personhood/claim-pgas.ts src/personhood/bind-paid-alias.ts src/personhood/bootstrap.ts src/personhood/chain-prereqs.ts src/manifest/types.ts src/manifest/schema.ts src/manifest/byte-budget.ts src/manifest/config-load.ts src/manifest/publish.ts src/auth/index.ts src/auth/vendor/index.ts src/auth/vendor/ui/index.ts src/auth-config.ts src/commands/login.ts src/commands/logout.ts src/commands/whoami.ts src/storage-signer.ts src/spinner.ts src/sss-allowance.ts --format esm --dts --clean --target node22",
47
47
  "refresh-environments": "node scripts/refresh-environments.mjs",
48
+ "postinstall": "patch-package",
48
49
  "prepare": "npm run build",
49
- "test": "npm run build && node --test test/test.js test/cli-help.test.js test/helpers/e2e-helpers.test.js test/environments.test.js test/refresh-environments.test.js test/chunk-sharing-report.test.js test/product-manifest.test.js test/cache-savings-totals.test.js test/error-pattern-signature.test.js test/exit-codes.test.js test/probe-env-health.test.js test/e2e-chain-calls.test.js test/auth-config.test.js test/whoami.test.js test/login.test.js test/logout.test.js test/auth-resolve.test.js",
50
+ "test": "npm run build && node --test test/test.js test/cli-help.test.js test/helpers/e2e-helpers.test.js test/environments.test.js test/refresh-environments.test.js test/chunk-sharing-report.test.js test/product-manifest.test.js test/cache-savings-totals.test.js test/error-pattern-signature.test.js test/exit-codes.test.js test/probe-env-health.test.js test/e2e-chain-calls.test.js test/auth-config.test.js test/whoami.test.js test/login.test.js test/logout.test.js test/auth-resolve.test.js test/storage-signer.test.js test/spinner.test.js test/sss-allowance.test.js && npm run test:vendor",
50
51
  "test:e2e": "npm run build && node --test test/e2e.test.js",
51
52
  "test:e2e:smoke": "bash scripts/e2e-pass.sh smoke",
52
53
  "test:e2e:pr": "bash scripts/e2e-pass.sh pr",
53
54
  "test:e2e:nightly": "bash scripts/e2e-pass.sh nightly",
54
- "benchmark": "npm run build && node benchmark.js"
55
+ "benchmark": "npm run build && node benchmark.js",
56
+ "test:vendor": "vitest run src/auth/vendor"
55
57
  },
56
58
  "dependencies": {
57
59
  "@ipld/car": "^5.4.3",
@@ -59,7 +61,7 @@
59
61
  "@noble/hashes": "^1.7.2",
60
62
  "@parity/product-sdk-address": "^0.1.1",
61
63
  "@parity/product-sdk-keys": "^0.3.0",
62
- "@parity/product-sdk-terminal": "^0.2.1",
64
+ "@parity/product-sdk-terminal": "^0.3.1",
63
65
  "@parity/product-sdk-tx": "^0.2.4",
64
66
  "@polkadot-api/metadata-builders": "^0.14.2",
65
67
  "@polkadot-api/substrate-bindings": "^0.20.2",
@@ -74,26 +76,28 @@
74
76
  "multiformats": "^13.4.1",
75
77
  "polkadot-api": "^2.1.3",
76
78
  "verifiablejs": "1.3.0-beta.4",
77
- "viem": "^2.30.5"
79
+ "viem": "^2.30.5",
80
+ "ws": "^8.20.1"
78
81
  },
79
82
  "devDependencies": {
80
83
  "@types/node": "^22.0.0",
84
+ "@types/ws": "^8.18.1",
85
+ "patch-package": "^8.0.1",
81
86
  "tsup": "^8.5.0",
82
87
  "typescript": "^5.9.3",
83
- "vitest": "^3.0.0",
84
- "ws": "^8.20.1"
88
+ "vitest": "^4.1.0"
85
89
  },
86
90
  "overrides": {
87
91
  "@polkadot-api/json-rpc-provider": "^0.2.0",
88
- "@novasamatech/host-api": "0.7.9-4",
89
- "@novasamatech/host-papp": "0.7.9-4",
90
- "@novasamatech/product-sdk": "0.7.9-4",
91
- "@novasamatech/scale": "0.7.9-4",
92
- "@novasamatech/statement-store": "0.7.9-4",
93
- "@novasamatech/storage-adapter": "0.7.9-4"
92
+ "@novasamatech/host-api": "0.8.6",
93
+ "@novasamatech/host-papp": "0.8.6",
94
+ "@novasamatech/scale": "0.8.6",
95
+ "@novasamatech/statement-store": "0.8.6",
96
+ "@novasamatech/storage-adapter": "0.8.6"
94
97
  },
95
98
  "minimumVersion": "0.5.6",
96
99
  "engines": {
97
100
  "node": ">=22"
98
- }
101
+ },
102
+ "license": "GPL-3.0-or-later"
99
103
  }
@@ -1,97 +0,0 @@
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 };
@@ -1,122 +0,0 @@
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 };