@parity/product-sdk-terminal 0.0.0-dev.312.0 → 0.0.0-dev.421.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.d.ts CHANGED
@@ -1,13 +1,50 @@
1
- import { T as TerminalAdapter } from './host-C3KVvc1j.js';
2
- export { A as AllocatableResource, a as ApAllocationOutcome, O as OnExistingAllowancePolicy, R as RequestResourceAllocationOptions, b as TerminalAdapterOptions, c as createTerminalAdapter, r as requestResourceAllocation, s as sendResourceAllocation } from './host-C3KVvc1j.js';
1
+ import { T as TerminalAdapter } from './host-_G9M0isV.js';
2
+ export { A as AllocatableResource, a as ApAllocationOutcome, O as OnExistingAllowancePolicy, R as RequestResourceAllocationOptions, b as TerminalAdapterOptions, c as createTerminalAdapter, i as isBenignTeardownError, r as requestResourceAllocation, s as sendResourceAllocation } from './host-_G9M0isV.js';
3
3
  import { UserSession } from '@novasamatech/host-papp';
4
- export { AllowanceError, AllowanceErrorReason, AllowanceService, HostMetadata, PairingStatus, PappAdapter, SS_PASEO_STABLE_STAGE_ENDPOINTS, SS_STABLE_STAGE_ENDPOINTS, SigningPayloadRequest, SigningPayloadResponse, SigningRawRequest, StoredUserSession, UserSession } from '@novasamatech/host-papp';
4
+ export { AllowanceError, AllowanceErrorReason, AllowanceService, HostMetadata, PairingStatus, PappAdapter, SS_STABLE_STAGE_ENDPOINTS, SigningPayloadRequest, SigningPayloadResponse, SigningRawRequest, StoredUserSession, UserSession } from '@novasamatech/host-papp';
5
5
  import { PolkadotSigner } from 'polkadot-api';
6
6
  export { AllowanceExpiredError, SignerError } from '@parity/product-sdk-signer/errors';
7
7
  import { StatementProver } from '@novasamatech/statement-store';
8
8
  import { StorageAdapter } from '@novasamatech/storage-adapter';
9
9
  import 'neverthrow';
10
10
 
11
+ /**
12
+ * Statement store networks terminal can pair against, keyed as `BULLETIN_RPCS`
13
+ * in `@parity/product-sdk-host`, where `paseo` is Paseo Next v2.
14
+ *
15
+ * Both sides of a pairing must sit on the same people chain. The Polkadot app's
16
+ * nightly build uses `paseo`, which is why it is the default.
17
+ */
18
+
19
+ declare const StatementStoreNetworks: {
20
+ paseo: string[];
21
+ previewnet: string[];
22
+ };
23
+
24
+ /** Network keys with built-in endpoints in {@link StatementStoreNetworks}. */
25
+ type StatementStoreEnvironment = keyof typeof StatementStoreNetworks;
26
+
27
+ /**
28
+ * The product-subtree public key of `//product//{productId}` (RFC-0022).
29
+ *
30
+ * The request is consent-free and cacheable. The disk layer is what makes that
31
+ * worth having: without it every CLI command would need the phone reachable
32
+ * just to render a product address.
33
+ */
34
+
35
+ interface ProductSubtreeOptions {
36
+ /** Names the cache file. Defaults to the productId. */
37
+ appId?: string;
38
+ storageDir?: string;
39
+ }
40
+ /**
41
+ * Fetch the subtree public key for `productId`, reaching the wallet only on a
42
+ * cold cache.
43
+ *
44
+ * @throws Error when the wallet rejects the request or returns a malformed key.
45
+ */
46
+ declare function getProductSubtreePublicKey(session: UserSession, productId: string, options?: ProductSubtreeOptions): Promise<Uint8Array>;
47
+
11
48
  /**
12
49
  * Create a PolkadotSigner from a QR-paired session.
13
50
  *
@@ -37,10 +74,10 @@ import 'neverthrow';
37
74
  * const [session] = adapter.sessions.sessions.read();
38
75
  *
39
76
  * // Default account — uses [adapter.appId, 0]:
40
- * const signer = createSessionSigner(session, adapter);
77
+ * const signer = await createSessionSigner(session, adapter);
41
78
  *
42
79
  * // Non-default derivation index, or a different productId:
43
- * const subSigner = createSessionSignerForAccount(session, {
80
+ * const subSigner = await createSessionSignerForAccount(session, {
44
81
  * productId: "my-product",
45
82
  * derivationIndex: 3,
46
83
  * });
@@ -52,7 +89,7 @@ import 'neverthrow';
52
89
  /**
53
90
  * Identifies which sub-account of a paired session should sign.
54
91
  *
55
- * Mirrors the `host-papp` wire format `productAccountId: [productId, derivationIndex]`:
92
+ * Mirrors the `host-papp` wire format `productAccountId: [productId, index]`:
56
93
  * `productId` is the dotNS-style identifier for the requesting product (matches
57
94
  * the adapter's `appId` in normal usage); `derivationIndex` is the BIP32-style
58
95
  * child-key index, where `0` is the session's default account.
@@ -66,46 +103,36 @@ interface ProductAccountRef {
66
103
  * The **product account's** sr25519 public key (32 bytes), as derived by the
67
104
  * host for `[productId, derivationIndex]`.
68
105
  *
69
- * PAPI stamps this into the extrinsic's signer address and verifies the
70
- * signature against it, so it must be the *product* account's key — not the
71
- * wallet's selected/root account (`session.remoteAccount.accountId`). A
72
- * mismatch produces an invalid signature.
106
+ * PAPI stamps this into the extrinsic's signer address and verifies against
107
+ * it, so a mismatch produces an invalid signature.
73
108
  *
74
- * When omitted, the signer soft-derives it from the session's root account
75
- * (`mnemonic + "/product/{productId}/{derivationIndex}"`), which is correct
76
- * for every product account. Supply it explicitly only to avoid the
77
- * re-derivation or when you've already derived it elsewhere.
109
+ * When omitted, the signer fetches the subtree key and derives it. Supply it
110
+ * to skip that round trip.
78
111
  */
79
112
  publicKey?: Uint8Array;
80
113
  }
114
+ interface SessionSignerOptions extends ProductSubtreeOptions {
115
+ /** Extension version of the supplied signTx bytes. Defaults to 0; does not change encoding. */
116
+ txExtVersion?: number;
117
+ }
81
118
  declare const INCOMPLETE_SESSION_MESSAGE = "Stored login session is missing the root account public key. Run \"logout\" and then \"login\" to pair again.";
82
119
  /**
83
- * The session's handshake-time root account public key (`rootUserAccountId` =
84
- * the user's bare-mnemonic keypair on current mobile builds). This is the
85
- * parent key product accounts soft-derive from. host-papp's live `UserSession`
86
- * doesn't surface it on the public type, so we read it structurally.
120
+ * The wallet's own root account key. Product accounts do **not** derive from it:
121
+ * RFC-0022 puts two hard junctions in between.
87
122
  *
88
123
  * @throws {@link INCOMPLETE_SESSION_MESSAGE} if the session predates the
89
- * `rootAccountId` field (a stale login that must re-pair).
124
+ * `rootAccountId` field.
90
125
  */
91
126
  declare function sessionRootPublicKey(session: UserSession): Uint8Array;
92
127
  /**
93
- * Soft-derive a product account's sr25519 public key from a paired session's
94
- * root account.
95
- *
96
- * This is the single source of truth for product-account math. The session
97
- * signer uses it to stamp the correct signer address; consumers that need the
98
- * product address *without* building a signer (e.g. a login-status display
99
- * triple) call it directly so the displayed address can't desync from what the
100
- * signer actually signs with.
128
+ * The product account's sr25519 public key for `ref`.
101
129
  *
102
- * sr25519 soft derivation is composable on public keys alone, so deriving from
103
- * `session.rootAccountId` locally produces the SAME key the host derives
104
- * privately via `mnemonic + "/product/{productId}/{derivationIndex}"`.
130
+ * The one place product-account math happens, so a displayed address cannot
131
+ * desync from what the signer signs with.
105
132
  *
106
- * @throws {@link INCOMPLETE_SESSION_MESSAGE} on a stale session with no root key.
133
+ * @throws Error when the wallet is unreachable on a cold cache.
107
134
  */
108
- declare function deriveProductPublicKey(session: UserSession, ref: ProductAccountRef): Uint8Array;
135
+ declare function deriveProductPublicKey(session: UserSession, ref: ProductAccountRef, options?: ProductSubtreeOptions): Promise<Uint8Array>;
109
136
  /**
110
137
  * Create a `PolkadotSigner` backed by a QR-paired mobile wallet session,
111
138
  * using the session's **default account** (`derivationIndex: 0`).
@@ -116,10 +143,10 @@ declare function deriveProductPublicKey(session: UserSession, ref: ProductAccoun
116
143
  * @param adapter The {@link TerminalAdapter} that loaded the session. Its `appId`
117
144
  * is used as the `productId` in the wire request.
118
145
  * @param publicKey The product account's sr25519 public key for
119
- * `[adapter.appId, 0]`. Optional — when omitted it's soft-derived from the
120
- * session root. See {@link ProductAccountRef.publicKey}.
146
+ * `[adapter.appId, 0]`. Optional — when omitted it's fetched and derived.
147
+ * See {@link ProductAccountRef.publicKey}.
121
148
  */
122
- declare function createSessionSigner(session: UserSession, adapter: TerminalAdapter, publicKey?: Uint8Array): PolkadotSigner;
149
+ declare function createSessionSigner(session: UserSession, adapter: TerminalAdapter, publicKey?: Uint8Array, options?: SessionSignerOptions): Promise<PolkadotSigner>;
123
150
  /**
124
151
  * Create a `PolkadotSigner` for a specific sub-account of a paired session.
125
152
  *
@@ -130,7 +157,7 @@ declare function createSessionSigner(session: UserSession, adapter: TerminalAdap
130
157
  * @param session The paired user session.
131
158
  * @param ref The product account to sign as: `{ productId, derivationIndex }`.
132
159
  */
133
- declare function createSessionSignerForAccount(session: UserSession, ref: ProductAccountRef): PolkadotSigner;
160
+ declare function createSessionSignerForAccount(session: UserSession, ref: ProductAccountRef, options?: SessionSignerOptions): Promise<PolkadotSigner>;
134
161
 
135
162
  /**
136
163
  * Get a `PolkadotSigner` for a Bulletin allowance slot.
@@ -259,4 +286,4 @@ declare function renderQrCode(data: string, options?: QrRenderOptions): Promise<
259
286
  */
260
287
  declare function createNodeStorageAdapter(appId: string, storageDir?: string): StorageAdapter;
261
288
 
262
- export { INCOMPLETE_SESSION_MESSAGE, type ProductAccountRef, type QrRenderOptions, TerminalAdapter, createNodeStorageAdapter, createSessionSigner, createSessionSignerForAccount, deriveProductPublicKey, getBulletinSigner, getStatementStoreProver, hasBulletinAllowance, hasStatementStoreAllowance, renderQrCode, sessionRootPublicKey, waitForSessions };
289
+ export { INCOMPLETE_SESSION_MESSAGE, type ProductAccountRef, type ProductSubtreeOptions, type QrRenderOptions, type SessionSignerOptions, type StatementStoreEnvironment, StatementStoreNetworks, TerminalAdapter, createNodeStorageAdapter, createSessionSigner, createSessionSignerForAccount, deriveProductPublicKey, getBulletinSigner, getProductSubtreePublicKey, getStatementStoreProver, hasBulletinAllowance, hasStatementStoreAllowance, renderQrCode, sessionRootPublicKey, waitForSessions };