@parity/product-deploy 0.8.3-rc.1 → 0.8.3-rc.11
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/README.md +53 -2
- package/bin/bulletin-deploy +54 -8
- package/dist/allocations-B65Is4Md.d.ts +97 -0
- package/dist/auth/index.d.ts +7 -0
- package/dist/auth/index.js +26 -0
- package/dist/auth/vendor/index.d.ts +32 -0
- package/dist/auth/vendor/index.js +27 -0
- package/dist/auth/vendor/ui/index.d.ts +15 -0
- package/dist/auth/vendor/ui/index.js +10 -0
- package/dist/auth-DkRZBK-T.d.ts +122 -0
- package/dist/auth-config.d.ts +39 -0
- package/dist/auth-config.js +20 -0
- package/dist/bug-report.js +4 -4
- package/dist/chunk-2OZVKA3D.js +410 -0
- package/dist/{chunk-UVFG2RDE.js → chunk-4CZ4GIWK.js} +677 -356
- package/dist/{chunk-VO46GTJM.js → chunk-4GX3KJPU.js} +12 -1
- package/dist/{chunk-B2Z4S2EL.js → chunk-4W6VNILJ.js} +2 -2
- package/dist/{chunk-BDS2LLCJ.js → chunk-AKCO2LGH.js} +1 -1
- package/dist/{chunk-C4GH5ARB.js → chunk-AMGKEAOH.js} +2 -2
- package/dist/chunk-JQKKMUCT.js +0 -0
- package/dist/{chunk-UNWYTYYZ.js → chunk-KFIIAUQU.js} +17 -3
- package/dist/{chunk-L5Z3TJD7.js → chunk-OCKCB72S.js} +6 -6
- package/dist/{chunk-P53IIXZ7.js → chunk-P2ZOBSCJ.js} +12 -5
- package/dist/chunk-RIRDBSBG.js +36 -0
- package/dist/{chunk-HLUEHUYE.js → chunk-X2Q5FPIQ.js} +1 -1
- package/dist/chunk-YUSHBZBX.js +52 -0
- package/dist/chunk-probe.js +3 -3
- package/dist/commands/login.d.ts +28 -0
- package/dist/commands/login.js +116 -0
- package/dist/commands/logout.d.ts +21 -0
- package/dist/commands/logout.js +37 -0
- package/dist/commands/whoami.d.ts +22 -0
- package/dist/commands/whoami.js +47 -0
- package/dist/deploy.d.ts +49 -3
- package/dist/deploy.js +19 -8
- package/dist/dotns.d.ts +7 -0
- package/dist/dotns.js +3 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +13 -12
- package/dist/manifest/publish.js +10 -9
- package/dist/memory-report.js +2 -2
- package/dist/merkle.d.ts +3 -1
- package/dist/merkle.js +9 -8
- package/dist/personhood/bind-paid-alias.js +3 -3
- package/dist/personhood/bind-personal-id.js +2 -2
- package/dist/personhood/bootstrap.js +16 -16
- package/dist/personhood/claim-pgas.js +2 -2
- package/dist/personhood/people-client.js +3 -3
- package/dist/personhood/proof-validity.js +2 -2
- package/dist/personhood/reprove.js +5 -5
- package/dist/run-state.js +1 -1
- package/dist/signer-CriGqahj.d.ts +35 -0
- package/dist/storage-signer.d.ts +38 -0
- package/dist/storage-signer.js +28 -0
- package/dist/telemetry.d.ts +1 -1
- package/dist/telemetry.js +2 -2
- package/dist/version-check.js +3 -3
- package/package.json +17 -3
- package/tools/release-retry-wrapper.mjs +1 -0
- package/dist/{chunk-LHLCPDGL.js → chunk-7URNKK6J.js} +3 -3
- package/dist/{chunk-7Y7RDOGT.js → chunk-EATOPQFR.js} +5 -5
- package/dist/{chunk-SLE4P6MO.js → chunk-EJI3MX4G.js} +3 -3
package/README.md
CHANGED
|
@@ -1,5 +1,56 @@
|
|
|
1
1
|
# bulletin-deploy
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
CLI tool for deploying web apps to the [Polkadot Bulletin Chain](https://github.com/paritytech/polkadot-bulletin-chain) via [DotNS](https://github.com/paritytech/dotns).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install -g bulletin-deploy
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
# Build your app, then deploy:
|
|
15
|
+
bulletin-deploy ./dist my-app.dot
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Session-based signing (mobile wallet)
|
|
19
|
+
|
|
20
|
+
Sign in once with your mobile Polkadot wallet — no mnemonic on disk:
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
bulletin-deploy login # Scan QR code with your Polkadot wallet app
|
|
24
|
+
bulletin-deploy whoami # Show the currently signed-in address
|
|
25
|
+
bulletin-deploy logout # Sign out and clear the session
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
After `login`, subsequent deploys will use the session signer automatically.
|
|
29
|
+
|
|
30
|
+
## Options
|
|
31
|
+
|
|
32
|
+
Run `bulletin-deploy --help` for the full option reference.
|
|
33
|
+
|
|
34
|
+
Key options:
|
|
35
|
+
|
|
36
|
+
| Option | Description |
|
|
37
|
+
|--------|-------------|
|
|
38
|
+
| `--env <id>` | Target environment (default: `paseo-next-v2`). Run `--list-environments` to see available IDs. |
|
|
39
|
+
| `--mnemonic "..."` | DotNS owner mnemonic (or set `MNEMONIC` env var). Alternative to session signing. |
|
|
40
|
+
| `--js-merkle` | Use pure-JS merkleization (no IPFS Kubo binary required). |
|
|
41
|
+
| `--publish` | List the domain in the on-chain Publisher registry after deploy. |
|
|
42
|
+
| `--config <path>` | Explicit path to `bulletin-deploy.config.ts` for product deploys. |
|
|
43
|
+
| `--tag "..."` | Label the deploy in telemetry. |
|
|
44
|
+
| `--version` | Print the installed version and exit. |
|
|
45
|
+
|
|
46
|
+
## Environments
|
|
47
|
+
|
|
48
|
+
bulletin-deploy ships with built-in environment presets (RPC endpoints, contract addresses). Use `--list-environments` to print the table. Override individual fields with `--environment-file <path>` or `--contract KEY=0x...`.
|
|
49
|
+
|
|
50
|
+
## Telemetry
|
|
51
|
+
|
|
52
|
+
Anonymous deploy telemetry is sent to Sentry by default. Set `BULLETIN_DEPLOY_UPDATE_CHECK=0` to disable the version check. The DSN is baked into the published package; source builds are silent.
|
|
53
|
+
|
|
54
|
+
## Contributing
|
|
55
|
+
|
|
56
|
+
See [docs-internal/](docs-internal/) for design notes and investigation logs (internal; not published to npm).
|
package/bin/bulletin-deploy
CHANGED
|
@@ -8,6 +8,16 @@ import { loadRunState, writeRunState, shouldSkipStaleWarning, shouldShowOomHint,
|
|
|
8
8
|
import { loadEnvironments, listEnvironments, formatEnvironmentTable, DEFAULT_ENV_ID } from "../dist/environments.js";
|
|
9
9
|
import * as fs from "fs";
|
|
10
10
|
|
|
11
|
+
// Suppress "@parity/product-sdk-logger" localStorage warning in Node.js v22+.
|
|
12
|
+
// The logger tries to read log-level config from localStorage which doesn't exist
|
|
13
|
+
// in Node.js — it emits a NoSuchNativeMethod warning we cannot fix upstream.
|
|
14
|
+
const _origEmitWarning = process.emitWarning.bind(process);
|
|
15
|
+
process.emitWarning = (warning, ...rest) => {
|
|
16
|
+
const msg = typeof warning === "string" ? warning : warning?.message ?? String(warning);
|
|
17
|
+
if (msg.includes("localStorage") || msg.includes("local storage")) return;
|
|
18
|
+
_origEmitWarning(warning, ...rest);
|
|
19
|
+
};
|
|
20
|
+
|
|
11
21
|
// Install early so anything printed during flag parsing / preflight is
|
|
12
22
|
// available to the bug-report log tail.
|
|
13
23
|
installLogCapture();
|
|
@@ -58,6 +68,7 @@ for (let i = 0; i < args.length; i++) {
|
|
|
58
68
|
else if (args[i] === "--publish") { flags.publish = true; }
|
|
59
69
|
else if (args[i] === "--unpublish") { flags.unpublish = true; }
|
|
60
70
|
else if (args[i] === "--fail-on-publish-error") { flags.failOnPublishError = true; }
|
|
71
|
+
else if (args[i] === "--suri") { flags.suri = args[++i]; }
|
|
61
72
|
else if (args[i] === "--version" || args[i] === "-V") { flags.version = true; }
|
|
62
73
|
else if (args[i] === "--help" || args[i] === "-h") { flags.help = true; }
|
|
63
74
|
else { positional.push(args[i]); }
|
|
@@ -123,6 +134,36 @@ if (flags.unpublish) {
|
|
|
123
134
|
}
|
|
124
135
|
}
|
|
125
136
|
|
|
137
|
+
// Sign-in subcommands: login / logout / whoami.
|
|
138
|
+
// Lazy-imported from dist so the SSO deps never load in headless/deploy mode.
|
|
139
|
+
{
|
|
140
|
+
const sub = positional[0];
|
|
141
|
+
if (sub === "login" || sub === "logout" || sub === "whoami") {
|
|
142
|
+
const envId = flags.env ?? DEFAULT_ENV_ID;
|
|
143
|
+
// The SSO adapter's polkadot-api client fires a benign `DestroyedError:
|
|
144
|
+
// Client destroyed` on orphaned pending-response promises during WS teardown,
|
|
145
|
+
// AFTER the command has done its work (e.g. logout already disconnected). The
|
|
146
|
+
// deploy path's handlers (below) aren't installed yet here, so guard the
|
|
147
|
+
// command path: swallow that + connection-teardown noise, surface anything else.
|
|
148
|
+
const benignTeardown = (e) => {
|
|
149
|
+
const s = e instanceof Error ? `${e.name ?? ""} ${e.message ?? ""}` : String(e);
|
|
150
|
+
return isConnectionError(e) || /DestroyedError|Client destroyed/.test(s);
|
|
151
|
+
};
|
|
152
|
+
process.on("unhandledRejection", (e) => { if (!benignTeardown(e)) { console.error(e); process.exit(1); } });
|
|
153
|
+
process.on("uncaughtException", (e) => { if (!benignTeardown(e)) { console.error(e); process.exit(1); } });
|
|
154
|
+
try {
|
|
155
|
+
const capSub = sub.charAt(0).toUpperCase() + sub.slice(1);
|
|
156
|
+
const mod = await import(`../dist/commands/${sub}.js`);
|
|
157
|
+
await mod[`run${capSub}`](envId, { suri: flags.suri });
|
|
158
|
+
} catch (err) {
|
|
159
|
+
console.error(`Error: ${err?.message ?? err}`);
|
|
160
|
+
process.exit(1);
|
|
161
|
+
}
|
|
162
|
+
await closeTelemetry();
|
|
163
|
+
process.exit(0);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
126
167
|
// `product` subcommand. Only `validate` is wired today. `publish` and `resolve` arrive in later phases.
|
|
127
168
|
if (positional[0] === "product") {
|
|
128
169
|
const verb = positional[1];
|
|
@@ -171,6 +212,9 @@ if (flags.help || positional.length === 0) {
|
|
|
171
212
|
|
|
172
213
|
Usage:
|
|
173
214
|
bulletin-deploy <build-dir> <domain.dot> Deploy an app
|
|
215
|
+
bulletin-deploy login Sign in with your Polkadot wallet (mobile)
|
|
216
|
+
bulletin-deploy logout Sign out and clear the session
|
|
217
|
+
bulletin-deploy whoami Show the currently signed-in address
|
|
174
218
|
|
|
175
219
|
Options:
|
|
176
220
|
--env <id> Target environment from environments.json (default: paseo-next-v2).
|
|
@@ -259,7 +303,14 @@ if (!flags.help && !flags.version) {
|
|
|
259
303
|
console.error("");
|
|
260
304
|
markRelaunchOomHintShown();
|
|
261
305
|
} else if (prev.status === "crashed" && prev.reason) {
|
|
262
|
-
|
|
306
|
+
const reasonMap = {
|
|
307
|
+
"unhandled": "crashed unexpectedly",
|
|
308
|
+
"uncaught": "crashed unexpectedly",
|
|
309
|
+
"SIGINT": "was interrupted (Ctrl-C)",
|
|
310
|
+
"SIGTERM": "was stopped",
|
|
311
|
+
};
|
|
312
|
+
const friendly = reasonMap[prev.reason] ?? "did not exit cleanly";
|
|
313
|
+
console.error(` Previous deploy ${friendly}. Continuing.`);
|
|
263
314
|
} else if (prev.status === "running") {
|
|
264
315
|
console.error(` Previous deploy did not exit cleanly. Continuing.`);
|
|
265
316
|
}
|
|
@@ -378,6 +429,7 @@ try {
|
|
|
378
429
|
const result = await deploy(buildDir, domain, {
|
|
379
430
|
mnemonic: flags.mnemonic,
|
|
380
431
|
derivationPath: flags.derivationPath,
|
|
432
|
+
suri: flags.suri,
|
|
381
433
|
rpc: flags.rpc,
|
|
382
434
|
env: flags.env,
|
|
383
435
|
poolSize: flags.poolSize,
|
|
@@ -435,13 +487,7 @@ try {
|
|
|
435
487
|
? `--config ${flags.config}`
|
|
436
488
|
: `bulletin-deploy.config.{ts,js,mjs} via walking up from ${buildDirAbs}`;
|
|
437
489
|
console.log("");
|
|
438
|
-
console.log(`⚠ No bulletin-deploy.config.ts
|
|
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)");
|
|
490
|
+
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
491
|
}
|
|
446
492
|
}
|
|
447
493
|
|
|
@@ -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,26 @@
|
|
|
1
|
+
import "../chunk-JQKKMUCT.js";
|
|
2
|
+
import {
|
|
3
|
+
DEFAULT_RESOURCES,
|
|
4
|
+
SignerNotAvailableError,
|
|
5
|
+
createAuthClient,
|
|
6
|
+
requestResourceAllocation,
|
|
7
|
+
resolveSigner,
|
|
8
|
+
summarizeOutcomes
|
|
9
|
+
} from "../chunk-2OZVKA3D.js";
|
|
10
|
+
import {
|
|
11
|
+
renderLoginStatus,
|
|
12
|
+
renderLogoutStatus,
|
|
13
|
+
renderQrCode
|
|
14
|
+
} from "../chunk-RIRDBSBG.js";
|
|
15
|
+
import "../chunk-ZOC4GITL.js";
|
|
16
|
+
export {
|
|
17
|
+
DEFAULT_RESOURCES,
|
|
18
|
+
SignerNotAvailableError,
|
|
19
|
+
createAuthClient,
|
|
20
|
+
renderLoginStatus,
|
|
21
|
+
renderLogoutStatus,
|
|
22
|
+
renderQrCode,
|
|
23
|
+
requestResourceAllocation,
|
|
24
|
+
resolveSigner,
|
|
25
|
+
summarizeOutcomes
|
|
26
|
+
};
|
|
@@ -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,27 @@
|
|
|
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-2OZVKA3D.js";
|
|
14
|
+
import "../../chunk-ZOC4GITL.js";
|
|
15
|
+
export {
|
|
16
|
+
DEFAULT_RESOURCES,
|
|
17
|
+
INCOMPLETE_SESSION_MESSAGE,
|
|
18
|
+
SignerNotAvailableError,
|
|
19
|
+
createAuthClient,
|
|
20
|
+
createSessionSigner,
|
|
21
|
+
deriveProductPublicKey,
|
|
22
|
+
parseDevAccountName,
|
|
23
|
+
requestResourceAllocation,
|
|
24
|
+
resolveSigner,
|
|
25
|
+
sessionRootPublicKey,
|
|
26
|
+
summarizeOutcomes
|
|
27
|
+
};
|
|
@@ -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,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-YUSHBZBX.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
|
+
};
|
package/dist/bug-report.js
CHANGED
|
@@ -9,10 +9,10 @@ import {
|
|
|
9
9
|
offerBugReport,
|
|
10
10
|
scrubSecrets,
|
|
11
11
|
setDeployContext
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-AMGKEAOH.js";
|
|
13
|
+
import "./chunk-AKCO2LGH.js";
|
|
14
|
+
import "./chunk-P2ZOBSCJ.js";
|
|
15
|
+
import "./chunk-KFIIAUQU.js";
|
|
16
16
|
export {
|
|
17
17
|
buildCliFlagsSummary,
|
|
18
18
|
buildLabels,
|