@parity/product-deploy 0.8.3 → 0.9.0-rc.1
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/LICENSE +674 -201
- package/README.md +9 -3
- package/assets/environments.json +0 -1
- package/dist/auth/index.d.ts +2 -3
- package/dist/auth/index.js +1 -1
- package/dist/auth/vendor/index.d.ts +2 -3
- package/dist/auth/vendor/index.js +1 -1
- package/dist/auth/vendor/ui/index.d.ts +1 -2
- package/dist/auth-C-Pel0AT.d.ts +235 -0
- package/dist/auth-config.d.ts +30 -8
- package/dist/auth-config.js +14 -6
- package/dist/bug-report.js +4 -4
- package/dist/{chunk-DKGCOGRT.js → chunk-6VYOUYMI.js} +144 -37
- package/dist/{chunk-3LNKPUZ7.js → chunk-AG37IM3H.js} +1 -1
- package/dist/{chunk-2OZVKA3D.js → chunk-DHY2ZXVZ.js} +36 -28
- package/dist/{chunk-WF2XKCEZ.js → chunk-EZ352IGD.js} +1 -1
- package/dist/chunk-G56VYTUD.js +75 -0
- package/dist/{chunk-5K3RI5C2.js → chunk-GL3U7K2B.js} +0 -1
- package/dist/{chunk-JMHX3M4C.js → chunk-J3WABBZ7.js} +3 -3
- package/dist/chunk-J7CYVTAW.js +43 -0
- package/dist/{chunk-OCKCB72S.js → chunk-L5Z3TJD7.js} +6 -6
- package/dist/{chunk-S7S7WENB.js → chunk-NO3BNQFL.js} +2 -2
- package/dist/{chunk-HK3B5MKA.js → chunk-ODIIC66I.js} +9 -20
- package/dist/{chunk-XM5MFMMX.js → chunk-UFQ4EZP3.js} +20 -15
- package/dist/{chunk-YUSHBZBX.js → chunk-VQB3JWK7.js} +32 -6
- package/dist/{chunk-LRRQP7DH.js → chunk-XKTAIQJ4.js} +2 -2
- package/dist/chunk-probe.js +3 -3
- package/dist/commands/login.d.ts +34 -9
- package/dist/commands/login.js +171 -68
- package/dist/commands/logout.d.ts +1 -2
- package/dist/commands/logout.js +5 -3
- package/dist/commands/whoami.d.ts +1 -2
- package/dist/commands/whoami.js +7 -4
- package/dist/deploy.d.ts +7 -1
- package/dist/deploy.js +12 -9
- package/dist/dotns.js +4 -4
- package/dist/environments.js +1 -1
- package/dist/index.js +14 -13
- package/dist/manifest/publish.js +11 -10
- package/dist/manifest/types.d.ts +1 -1
- package/dist/memory-report.js +2 -2
- package/dist/merkle.js +10 -9
- package/dist/personhood/bind-paid-alias.js +3 -3
- package/dist/personhood/bind-personal-id.js +2 -2
- package/dist/personhood/bootstrap.js +17 -17
- package/dist/personhood/claim-pgas.js +2 -2
- package/dist/personhood/people-client.js +4 -4
- 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 → signer-vR6KKC7V.d.ts} +1 -1
- package/dist/spinner.d.ts +21 -0
- package/dist/spinner.js +6 -0
- package/dist/sss-allowance.d.ts +29 -0
- package/dist/sss-allowance.js +8 -0
- package/dist/storage-signer.d.ts +94 -2
- package/dist/storage-signer.js +18 -9
- package/dist/telemetry.js +2 -2
- package/dist/version-check.d.ts +0 -3
- package/dist/version-check.js +3 -3
- package/package.json +20 -15
- package/patches/@novasamatech+sdk-statement+0.6.0.patch +47 -0
- package/dist/allocations-B65Is4Md.d.ts +0 -97
- package/dist/auth-DkRZBK-T.d.ts +0 -122
- package/dist/{chunk-EATOPQFR.js → chunk-7Y7RDOGT.js} +5 -5
- package/dist/{chunk-7URNKK6J.js → chunk-LHLCPDGL.js} +3 -3
- package/dist/{chunk-EJI3MX4G.js → chunk-SLE4P6MO.js} +3 -3
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
VERSION
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-EZ352IGD.js";
|
|
4
4
|
|
|
5
5
|
// src/version-check.ts
|
|
6
6
|
import { execSync, execFileSync } from "child_process";
|
|
7
7
|
import { createInterface } from "readline";
|
|
8
8
|
var REGISTRY_URL = "https://registry.npmjs.org/bulletin-deploy/latest";
|
|
9
|
-
var KILL_SWITCH_URL = "https://raw.githubusercontent.com/paritytech/triangle-deploy/main/min-version.json";
|
|
10
9
|
var FETCH_TIMEOUT = 3e3;
|
|
11
10
|
function checkNodeVersion(enginesNode, currentVersion) {
|
|
12
11
|
const match = enginesNode.match(/(\d+)/);
|
|
@@ -58,26 +57,18 @@ async function fetchJson(url) {
|
|
|
58
57
|
}
|
|
59
58
|
}
|
|
60
59
|
async function fetchVersionInfo() {
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
fetchJson(KILL_SWITCH_URL)
|
|
64
|
-
]);
|
|
65
|
-
if (!registry && !killSwitch) return null;
|
|
60
|
+
const registry = await fetchJson(REGISTRY_URL);
|
|
61
|
+
if (!registry) return null;
|
|
66
62
|
return {
|
|
67
|
-
latest: registry
|
|
68
|
-
minimumFromRegistry: registry
|
|
69
|
-
minimumFromKillSwitch: killSwitch?.minimumVersion ?? null,
|
|
70
|
-
killSwitchMessage: killSwitch?.message ?? null
|
|
63
|
+
latest: registry.version ?? VERSION,
|
|
64
|
+
minimumFromRegistry: registry.minimumVersion ?? null
|
|
71
65
|
};
|
|
72
66
|
}
|
|
73
67
|
function handlePreflightVersionCheck(info) {
|
|
74
68
|
if (!info) return "ok";
|
|
75
|
-
|
|
76
|
-
if (effectiveMinimum && compareSemver(VERSION, effectiveMinimum) < 0) {
|
|
69
|
+
if (info.minimumFromRegistry && compareSemver(VERSION, info.minimumFromRegistry) < 0) {
|
|
77
70
|
console.error(`
|
|
78
|
-
bulletin-deploy ${VERSION} is no longer supported (minimum: ${
|
|
79
|
-
const ks = info.killSwitchMessage;
|
|
80
|
-
if (ks) console.error(` Reason: ${ks}`);
|
|
71
|
+
bulletin-deploy ${VERSION} is no longer supported (minimum: ${info.minimumFromRegistry}).`);
|
|
81
72
|
console.error(` Please update: npm install -g bulletin-deploy@latest
|
|
82
73
|
`);
|
|
83
74
|
return "abort";
|
|
@@ -165,9 +156,8 @@ function classifyErrorArea(msg) {
|
|
|
165
156
|
return null;
|
|
166
157
|
}
|
|
167
158
|
function assessVersion(currentVersion, info, internal) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
return { action: "forced_update", currentVersion, minimumVersion: effectiveMinimum, message: info.killSwitchMessage };
|
|
159
|
+
if (info.minimumFromRegistry && compareSemver(currentVersion, info.minimumFromRegistry) < 0) {
|
|
160
|
+
return { action: "forced_update", currentVersion, minimumVersion: info.minimumFromRegistry };
|
|
171
161
|
}
|
|
172
162
|
if (compareSemver(currentVersion, info.latest) < 0) {
|
|
173
163
|
return { action: "suggest_update", currentVersion, latestVersion: info.latest, internal };
|
|
@@ -190,7 +180,6 @@ async function handleFailedDeploy(error) {
|
|
|
190
180
|
case "forced_update":
|
|
191
181
|
console.error(`
|
|
192
182
|
bulletin-deploy ${verdict.currentVersion} is no longer supported (minimum: ${verdict.minimumVersion}).`);
|
|
193
|
-
if (verdict.message) console.error(` Reason: ${verdict.message}`);
|
|
194
183
|
console.error(` Please update: npm install -g bulletin-deploy@latest
|
|
195
184
|
`);
|
|
196
185
|
break;
|
|
@@ -6,7 +6,7 @@ import * as path from "path";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@parity/product-deploy",
|
|
9
|
-
version: "0.
|
|
9
|
+
version: "0.9.0-rc.1",
|
|
10
10
|
private: false,
|
|
11
11
|
repository: {
|
|
12
12
|
type: "git",
|
|
@@ -46,18 +46,21 @@ var package_default = {
|
|
|
46
46
|
"bin",
|
|
47
47
|
"docs",
|
|
48
48
|
"assets",
|
|
49
|
+
"patches",
|
|
49
50
|
"tools/release-retry-wrapper.mjs"
|
|
50
51
|
],
|
|
51
52
|
scripts: {
|
|
52
|
-
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",
|
|
53
|
+
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",
|
|
53
54
|
"refresh-environments": "node scripts/refresh-environments.mjs",
|
|
55
|
+
postinstall: "patch-package",
|
|
54
56
|
prepare: "npm run build",
|
|
55
|
-
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",
|
|
57
|
+
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",
|
|
56
58
|
"test:e2e": "npm run build && node --test test/e2e.test.js",
|
|
57
59
|
"test:e2e:smoke": "bash scripts/e2e-pass.sh smoke",
|
|
58
60
|
"test:e2e:pr": "bash scripts/e2e-pass.sh pr",
|
|
59
61
|
"test:e2e:nightly": "bash scripts/e2e-pass.sh nightly",
|
|
60
|
-
benchmark: "npm run build && node benchmark.js"
|
|
62
|
+
benchmark: "npm run build && node benchmark.js",
|
|
63
|
+
"test:vendor": "vitest run src/auth/vendor"
|
|
61
64
|
},
|
|
62
65
|
dependencies: {
|
|
63
66
|
"@ipld/car": "^5.4.3",
|
|
@@ -65,7 +68,7 @@ var package_default = {
|
|
|
65
68
|
"@noble/hashes": "^1.7.2",
|
|
66
69
|
"@parity/product-sdk-address": "^0.1.1",
|
|
67
70
|
"@parity/product-sdk-keys": "^0.3.0",
|
|
68
|
-
"@parity/product-sdk-terminal": "^0.
|
|
71
|
+
"@parity/product-sdk-terminal": "^0.3.1",
|
|
69
72
|
"@parity/product-sdk-tx": "^0.2.4",
|
|
70
73
|
"@polkadot-api/metadata-builders": "^0.14.2",
|
|
71
74
|
"@polkadot-api/substrate-bindings": "^0.20.2",
|
|
@@ -78,30 +81,32 @@ var package_default = {
|
|
|
78
81
|
"ipfs-unixfs-importer": "^16.1.4",
|
|
79
82
|
jiti: "^2.4.2",
|
|
80
83
|
multiformats: "^13.4.1",
|
|
84
|
+
"patch-package": "^8.0.1",
|
|
81
85
|
"polkadot-api": "^2.1.3",
|
|
82
86
|
verifiablejs: "1.3.0-beta.4",
|
|
83
|
-
viem: "^2.30.5"
|
|
87
|
+
viem: "^2.30.5",
|
|
88
|
+
ws: "^8.20.1"
|
|
84
89
|
},
|
|
85
90
|
devDependencies: {
|
|
86
91
|
"@types/node": "^22.0.0",
|
|
92
|
+
"@types/ws": "^8.18.1",
|
|
87
93
|
tsup: "^8.5.0",
|
|
88
94
|
typescript: "^5.9.3",
|
|
89
|
-
vitest: "^
|
|
90
|
-
ws: "^8.20.1"
|
|
95
|
+
vitest: "^4.1.0"
|
|
91
96
|
},
|
|
92
97
|
overrides: {
|
|
93
98
|
"@polkadot-api/json-rpc-provider": "^0.2.0",
|
|
94
|
-
"@novasamatech/host-api": "0.
|
|
95
|
-
"@novasamatech/host-papp": "0.
|
|
96
|
-
"@novasamatech/
|
|
97
|
-
"@novasamatech/
|
|
98
|
-
"@novasamatech/
|
|
99
|
-
"@novasamatech/storage-adapter": "0.7.9-4"
|
|
99
|
+
"@novasamatech/host-api": "0.8.6",
|
|
100
|
+
"@novasamatech/host-papp": "0.8.6",
|
|
101
|
+
"@novasamatech/scale": "0.8.6",
|
|
102
|
+
"@novasamatech/statement-store": "0.8.6",
|
|
103
|
+
"@novasamatech/storage-adapter": "0.8.6"
|
|
100
104
|
},
|
|
101
105
|
minimumVersion: "0.5.6",
|
|
102
106
|
engines: {
|
|
103
107
|
node: ">=22"
|
|
104
|
-
}
|
|
108
|
+
},
|
|
109
|
+
license: "GPL-3.0-or-later"
|
|
105
110
|
};
|
|
106
111
|
|
|
107
112
|
// src/run-state.ts
|
|
@@ -1,17 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
VERSION
|
|
3
|
+
} from "./chunk-EZ352IGD.js";
|
|
1
4
|
import {
|
|
2
5
|
loadEnvironments
|
|
3
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-GL3U7K2B.js";
|
|
4
7
|
|
|
5
8
|
// src/auth-config.ts
|
|
6
|
-
import { existsSync } from "fs";
|
|
9
|
+
import { existsSync, readdirSync } from "fs";
|
|
7
10
|
import { homedir } from "os";
|
|
8
11
|
import { join } from "path";
|
|
9
12
|
var DOT_DAPP_ID = "dot-cli";
|
|
10
13
|
var DOT_PRODUCT_ID = "playground.dot";
|
|
11
14
|
var DOT_DERIVATION_INDEX = 0;
|
|
12
|
-
var
|
|
15
|
+
var DOT_HOST_NAME = "bulletin-deploy";
|
|
16
|
+
var STALE_SESSION_MESSAGE = 'Stored login session could not be read \u2014 it may have been written by an older version. Run "bulletin-deploy logout", then "bulletin-deploy login" to pair again.';
|
|
13
17
|
function hasPersistedSession() {
|
|
14
|
-
|
|
18
|
+
const dir = join(homedir(), ".polkadot-apps");
|
|
19
|
+
if (!existsSync(dir)) return false;
|
|
20
|
+
const prefix = `${DOT_DAPP_ID}_SsoSessions`;
|
|
21
|
+
try {
|
|
22
|
+
return readdirSync(dir).some((f) => f.startsWith(prefix) && f.endsWith(".json"));
|
|
23
|
+
} catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
15
26
|
}
|
|
16
27
|
function buildAuthConfig(doc, envId) {
|
|
17
28
|
const peopleChain = doc.chains.find((c) => c.id === "people");
|
|
@@ -31,10 +42,22 @@ function buildAuthConfig(doc, envId) {
|
|
|
31
42
|
dappId: DOT_DAPP_ID,
|
|
32
43
|
productId: DOT_PRODUCT_ID,
|
|
33
44
|
derivationIndex: DOT_DERIVATION_INDEX,
|
|
34
|
-
|
|
45
|
+
hostName: DOT_HOST_NAME,
|
|
46
|
+
hostVersion: VERSION,
|
|
35
47
|
peopleEndpoints
|
|
36
48
|
};
|
|
37
49
|
}
|
|
50
|
+
function resolveBulletinEndpoints(doc, envId) {
|
|
51
|
+
const bulletinChain = doc.chains.find((c) => c.id === "bulletin");
|
|
52
|
+
const endpoint = bulletinChain?.endpoints[envId];
|
|
53
|
+
if (!endpoint) return null;
|
|
54
|
+
return Array.isArray(endpoint.wss) ? endpoint.wss : [endpoint.wss];
|
|
55
|
+
}
|
|
56
|
+
async function getPeopleChainEndpoints(envId) {
|
|
57
|
+
const { doc } = await loadEnvironments();
|
|
58
|
+
const config = buildAuthConfig(doc, envId);
|
|
59
|
+
return config.peopleEndpoints;
|
|
60
|
+
}
|
|
38
61
|
async function getAuthClient(envId) {
|
|
39
62
|
const { createAuthClient } = await import("./auth/index.js");
|
|
40
63
|
const { doc } = await loadEnvironments();
|
|
@@ -45,8 +68,11 @@ export {
|
|
|
45
68
|
DOT_DAPP_ID,
|
|
46
69
|
DOT_PRODUCT_ID,
|
|
47
70
|
DOT_DERIVATION_INDEX,
|
|
48
|
-
|
|
71
|
+
DOT_HOST_NAME,
|
|
72
|
+
STALE_SESSION_MESSAGE,
|
|
49
73
|
hasPersistedSession,
|
|
50
74
|
buildAuthConfig,
|
|
75
|
+
resolveBulletinEndpoints,
|
|
76
|
+
getPeopleChainEndpoints,
|
|
51
77
|
getAuthClient
|
|
52
78
|
};
|
|
@@ -2,11 +2,11 @@ import {
|
|
|
2
2
|
classifyErrorArea,
|
|
3
3
|
isInteractive,
|
|
4
4
|
promptYesNo
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-ODIIC66I.js";
|
|
6
6
|
import {
|
|
7
7
|
VERSION,
|
|
8
8
|
getCurrentSentryTraceId
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-EZ352IGD.js";
|
|
10
10
|
|
|
11
11
|
// src/bug-report.ts
|
|
12
12
|
import { execSync, execFileSync } from "child_process";
|
package/dist/chunk-probe.js
CHANGED
|
@@ -5,9 +5,9 @@ import {
|
|
|
5
5
|
_decodeStorageValue,
|
|
6
6
|
_resetProbeSession,
|
|
7
7
|
probeChunks
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-AG37IM3H.js";
|
|
9
|
+
import "./chunk-EZ352IGD.js";
|
|
10
|
+
import "./chunk-UFQ4EZP3.js";
|
|
11
11
|
export {
|
|
12
12
|
ChainProbeCrossValidationError,
|
|
13
13
|
ChainProbeMetadataError,
|
package/dist/commands/login.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { b as AllocationSummary } from '../allocations-B65Is4Md.js';
|
|
2
|
-
import '@parity/product-sdk-terminal';
|
|
3
|
-
|
|
4
1
|
/**
|
|
5
2
|
* login — QR/mobile sign-in command.
|
|
6
3
|
*
|
|
@@ -8,15 +5,43 @@ import '@parity/product-sdk-terminal';
|
|
|
8
5
|
* 1. connect() → existing session (already logged in) OR QR code
|
|
9
6
|
* 2. Print QR → user scans on phone
|
|
10
7
|
* 3. waitForLogin() → phone approves → paired
|
|
11
|
-
* 4.
|
|
12
|
-
*
|
|
13
|
-
*
|
|
8
|
+
* 4. getBulletinSigner() — resolves the slot account from host-papp's allowance service.
|
|
9
|
+
* Uses DOT_PRODUCT_ID ("playground.dot") as callingProductId, which matches what the
|
|
10
|
+
* mobile wallet allocated during pairing. A 60s timeout prevents hanging on unresponsive phones.
|
|
11
|
+
* 5. Print summarizeLogin() + slot address on success; map AllowanceError.reason → message on failure
|
|
12
|
+
* 6. Destroy adapters and exit
|
|
14
13
|
*/
|
|
15
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Map an AllowanceError.reason to a user-facing message.
|
|
16
|
+
*
|
|
17
|
+
* - NoSession: the paired session was not found (should not happen right after login)
|
|
18
|
+
* - Rejected: the user dismissed the wallet prompt
|
|
19
|
+
* - NotAvailable: the wallet has no allocation for this product (re-pair needed)
|
|
20
|
+
* - UnexpectedResponse: protocol-level error in the wire exchange
|
|
21
|
+
*/
|
|
22
|
+
declare function allocationErrorMessage(reason: string): string;
|
|
16
23
|
/**
|
|
17
24
|
* Format a post-login summary. Pure function, unit-testable.
|
|
25
|
+
*
|
|
26
|
+
* @param address SS58 product address (the identity signing on-chain)
|
|
27
|
+
* @param slotAddress SS58 slot account address for Bulletin storage, or null if not obtained
|
|
28
|
+
*/
|
|
29
|
+
declare function summarizeLogin(address: string, slotAddress: string | null): string;
|
|
30
|
+
/**
|
|
31
|
+
* Produce the on-chain authorization result message shown after the active-wait completes.
|
|
32
|
+
* Pure function — unit-testable without a real WS connection.
|
|
33
|
+
*
|
|
34
|
+
* - authorized = true → ✓ success message with expiration block (exit-0, show summarizeLogin).
|
|
35
|
+
* - authorized = false → soft-warning: active wait timed out before the authorization landed.
|
|
36
|
+
* Login is still valid — the slot is deterministic and often already authorized; the deploy
|
|
37
|
+
* path re-probes before use and falls back to the pool if still absent. isWarning=true so
|
|
38
|
+
* callers know it's a non-fatal outcome. The timeout bound (timeoutSeconds) is embedded in
|
|
39
|
+
* the message so users understand the ceiling that was used.
|
|
18
40
|
*/
|
|
19
|
-
declare function
|
|
41
|
+
declare function bulletinAuthSummary(authorized: boolean, expiration?: number, timeoutSeconds?: number): {
|
|
42
|
+
message: string;
|
|
43
|
+
isWarning: boolean;
|
|
44
|
+
};
|
|
20
45
|
interface LoginOptions {
|
|
21
46
|
suri?: string;
|
|
22
47
|
}
|
|
@@ -25,4 +50,4 @@ interface LoginOptions {
|
|
|
25
50
|
*/
|
|
26
51
|
declare function runLogin(envId: string, _opts?: LoginOptions): Promise<void>;
|
|
27
52
|
|
|
28
|
-
export { type LoginOptions, runLogin, summarizeLogin };
|
|
53
|
+
export { type LoginOptions, allocationErrorMessage, bulletinAuthSummary, runLogin, summarizeLogin };
|
package/dist/commands/login.js
CHANGED
|
@@ -1,116 +1,219 @@
|
|
|
1
1
|
import "../chunk-JQKKMUCT.js";
|
|
2
|
-
import
|
|
3
|
-
DEFAULT_RESOURCES,
|
|
4
|
-
summarizeOutcomes
|
|
5
|
-
} from "../chunk-2OZVKA3D.js";
|
|
2
|
+
import "../chunk-DHY2ZXVZ.js";
|
|
6
3
|
import {
|
|
7
4
|
renderLoginStatus
|
|
8
5
|
} from "../chunk-RIRDBSBG.js";
|
|
9
6
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
startSpinner
|
|
8
|
+
} from "../chunk-J7CYVTAW.js";
|
|
9
|
+
import {
|
|
10
|
+
waitForBulletinAuthorization
|
|
11
|
+
} from "../chunk-6VYOUYMI.js";
|
|
12
|
+
import {
|
|
13
|
+
checkSSSAllowance
|
|
14
|
+
} from "../chunk-G56VYTUD.js";
|
|
13
15
|
import "../chunk-HOTQDYHD.js";
|
|
14
16
|
import "../chunk-IW3X2MJF.js";
|
|
15
17
|
import "../chunk-KOSF5FDO.js";
|
|
16
18
|
import "../chunk-J3NIXHZZ.js";
|
|
17
19
|
import "../chunk-S7EM5VMW.js";
|
|
18
20
|
import {
|
|
19
|
-
|
|
20
|
-
getAuthClient
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
import "../chunk-
|
|
21
|
+
DOT_PRODUCT_ID,
|
|
22
|
+
getAuthClient,
|
|
23
|
+
getPeopleChainEndpoints,
|
|
24
|
+
resolveBulletinEndpoints
|
|
25
|
+
} from "../chunk-VQB3JWK7.js";
|
|
26
|
+
import "../chunk-XKTAIQJ4.js";
|
|
27
|
+
import "../chunk-ODIIC66I.js";
|
|
28
|
+
import "../chunk-AG37IM3H.js";
|
|
25
29
|
import "../chunk-C2TS5MER.js";
|
|
26
|
-
import "../chunk-
|
|
30
|
+
import "../chunk-NO3BNQFL.js";
|
|
27
31
|
import "../chunk-QS7YU76C.js";
|
|
28
|
-
import "../chunk-
|
|
29
|
-
import "../chunk-
|
|
30
|
-
import
|
|
32
|
+
import "../chunk-EZ352IGD.js";
|
|
33
|
+
import "../chunk-UFQ4EZP3.js";
|
|
34
|
+
import {
|
|
35
|
+
loadEnvironments
|
|
36
|
+
} from "../chunk-GL3U7K2B.js";
|
|
31
37
|
import "../chunk-ZOC4GITL.js";
|
|
32
38
|
|
|
33
39
|
// src/commands/login.ts
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
import { ss58Encode } from "@parity/product-sdk-address";
|
|
41
|
+
var ALLOCATION_TIMEOUT_MS = 6e4;
|
|
42
|
+
function allocationErrorMessage(reason) {
|
|
43
|
+
switch (reason) {
|
|
44
|
+
case "NoSession":
|
|
45
|
+
return "No active session found \u2014 try logging in again.";
|
|
46
|
+
case "Rejected":
|
|
47
|
+
return "Bulletin storage access was declined on your phone. Approve the request to enable storage signing.";
|
|
48
|
+
case "NotAvailable":
|
|
49
|
+
return "Bulletin storage is not available for this product on your phone.\n This may mean the wallet paired under a different product ID.\n Run: bulletin-deploy logout\n Then: bulletin-deploy login\n to re-pair and establish the allocation.";
|
|
50
|
+
case "UnexpectedResponse":
|
|
51
|
+
return "Unexpected response from the mobile wallet during storage allocation. Try again.";
|
|
52
|
+
default:
|
|
53
|
+
return `Allocation failed (${reason}).`;
|
|
41
54
|
}
|
|
42
|
-
|
|
43
|
-
|
|
55
|
+
}
|
|
56
|
+
function summarizeLogin(address, slotAddress) {
|
|
57
|
+
const lines = [`Signed in as: ${address}`];
|
|
58
|
+
if (slotAddress) {
|
|
59
|
+
lines.push(`Bulletin storage slot: ${slotAddress} \u2713`);
|
|
60
|
+
} else {
|
|
61
|
+
lines.push("Bulletin storage slot: not allocated (storage will fall back to pool)");
|
|
44
62
|
}
|
|
45
63
|
return lines.join("\n");
|
|
46
64
|
}
|
|
65
|
+
function bulletinAuthSummary(authorized, expiration, timeoutSeconds = 180) {
|
|
66
|
+
if (authorized) {
|
|
67
|
+
return {
|
|
68
|
+
message: `\u2713 Bulletin allowance authorized (until block ${expiration})`,
|
|
69
|
+
isWarning: false
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
message: ` Couldn't confirm on-chain authorization within ${timeoutSeconds}s. Your login is valid \u2014 your next deploy will use the slot once it's authorized, or fall back to the pool meanwhile.`,
|
|
74
|
+
isWarning: true
|
|
75
|
+
};
|
|
76
|
+
}
|
|
47
77
|
async function runLogin(envId, _opts = {}) {
|
|
78
|
+
let tearingDown = false;
|
|
79
|
+
const teardownFilter = (e) => {
|
|
80
|
+
const msg = String(e?.message ?? e);
|
|
81
|
+
if (tearingDown && /not connected|client destroyed|destroyederror/i.test(msg)) return;
|
|
82
|
+
console.error(e);
|
|
83
|
+
process.exit(1);
|
|
84
|
+
};
|
|
85
|
+
process.on("uncaughtException", teardownFilter);
|
|
86
|
+
process.on("unhandledRejection", teardownFilter);
|
|
48
87
|
const client = await getAuthClient(envId);
|
|
49
88
|
const result = await client.connect();
|
|
50
89
|
if (result.kind === "existing") {
|
|
51
|
-
const
|
|
52
|
-
if (
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
if (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
origErr(...args);
|
|
62
|
-
};
|
|
63
|
-
await Promise.race([
|
|
64
|
-
client.requestAllocation(sessionHandle2.userSession, DEFAULT_RESOURCES).catch(() => {
|
|
65
|
-
}),
|
|
66
|
-
new Promise((r) => setTimeout(r, 3e3))
|
|
67
|
-
]);
|
|
68
|
-
console.error = origErr;
|
|
69
|
-
sessionHandle2.destroy();
|
|
70
|
-
if (sssExpired) {
|
|
71
|
-
console.error(
|
|
72
|
-
`
|
|
90
|
+
const sessionHandle = await client.getSessionSigner();
|
|
91
|
+
if (sessionHandle) {
|
|
92
|
+
try {
|
|
93
|
+
const productPubkey = sessionHandle.signer.publicKey;
|
|
94
|
+
const peopleEndpoints = await getPeopleChainEndpoints(envId);
|
|
95
|
+
const allowed = await checkSSSAllowance(productPubkey, peopleEndpoints);
|
|
96
|
+
if (allowed === false) {
|
|
97
|
+
console.error(
|
|
98
|
+
`
|
|
73
99
|
Statement Store allowance has expired for ${result.address}.
|
|
74
100
|
Run: bulletin-deploy logout
|
|
75
101
|
Then: bulletin-deploy login
|
|
76
102
|
to re-pair and renew (allowance lasts ~2-3 days).`
|
|
77
|
-
|
|
78
|
-
|
|
103
|
+
);
|
|
104
|
+
tearingDown = true;
|
|
105
|
+
sessionHandle.destroy();
|
|
106
|
+
process.exit(1);
|
|
107
|
+
}
|
|
108
|
+
try {
|
|
109
|
+
await Promise.race([
|
|
110
|
+
Promise.resolve(
|
|
111
|
+
sessionHandle.adapter.allowance.getBulletinSigner(sessionHandle.userSession.id, DOT_PRODUCT_ID)
|
|
112
|
+
).then((r) => {
|
|
113
|
+
if (r.isErr()) {
|
|
114
|
+
console.warn(
|
|
115
|
+
`
|
|
116
|
+
Bulletin storage slot allowance not available \u2014 storage will fall back to pool.
|
|
117
|
+
Run: bulletin-deploy logout && bulletin-deploy login
|
|
118
|
+
to re-establish your allowance.`
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
}).catch(() => {
|
|
122
|
+
}),
|
|
123
|
+
new Promise((r) => setTimeout(r, 3e3))
|
|
124
|
+
]);
|
|
125
|
+
} catch {
|
|
126
|
+
}
|
|
127
|
+
} finally {
|
|
128
|
+
sessionHandle.destroy();
|
|
79
129
|
}
|
|
80
130
|
}
|
|
81
131
|
console.log(`Already signed in as: ${result.address}`);
|
|
132
|
+
tearingDown = true;
|
|
82
133
|
return;
|
|
83
134
|
}
|
|
84
135
|
console.log(result.qrCode);
|
|
85
|
-
console.log("Scan the QR code with your Polkadot
|
|
86
|
-
const
|
|
136
|
+
console.log("Scan the QR code with your Polkadot mobile app.");
|
|
137
|
+
const handle = await client.waitForLogin(result.login, (status) => {
|
|
87
138
|
const msg = renderLoginStatus(status);
|
|
88
139
|
if (msg) process.stdout.write(`\r${msg}`);
|
|
89
140
|
});
|
|
90
|
-
if (!
|
|
141
|
+
if (!handle) {
|
|
142
|
+
tearingDown = true;
|
|
91
143
|
console.error("\nLogin failed.");
|
|
144
|
+
process.exit(1);
|
|
92
145
|
return;
|
|
93
146
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
147
|
+
try {
|
|
148
|
+
console.log("\nRequesting Bulletin storage allowance \u2014 check your phone to approve.");
|
|
149
|
+
const bulletinSignerPromise = handle.adapter.allowance.getBulletinSigner(
|
|
150
|
+
handle.userSession.id,
|
|
151
|
+
DOT_PRODUCT_ID
|
|
152
|
+
);
|
|
153
|
+
const timeoutPromise = new Promise(
|
|
154
|
+
(_, reject) => setTimeout(
|
|
155
|
+
() => reject(new Error(
|
|
156
|
+
`Allocation request timed out after ${Math.round(ALLOCATION_TIMEOUT_MS / 1e3)}s \u2014 ensure your phone is unlocked and the Polkadot mobile app is open, then try logging in again.`
|
|
157
|
+
)),
|
|
158
|
+
ALLOCATION_TIMEOUT_MS
|
|
159
|
+
)
|
|
160
|
+
);
|
|
161
|
+
const signerResult = await Promise.race([bulletinSignerPromise, timeoutPromise]);
|
|
162
|
+
if (signerResult.isOk()) {
|
|
163
|
+
const slotSigner = signerResult.value;
|
|
164
|
+
const slotAddress = ss58Encode(slotSigner.publicKey);
|
|
165
|
+
const { doc } = await loadEnvironments();
|
|
166
|
+
const bulletinEndpoints = resolveBulletinEndpoints(doc, envId) ?? void 0;
|
|
167
|
+
const spinner = startSpinner("Confirming Bulletin authorization on-chain");
|
|
168
|
+
const onSigint = () => {
|
|
169
|
+
spinner.stop();
|
|
170
|
+
console.log(
|
|
171
|
+
"Cancelled \u2014 on-chain authorization not yet confirmed. Your login is saved; your next deploy will use the slot once it's authorized, or fall back to the pool meanwhile."
|
|
172
|
+
);
|
|
173
|
+
console.log("\n" + summarizeLogin(handle.address, slotAddress));
|
|
174
|
+
tearingDown = true;
|
|
175
|
+
handle.destroy();
|
|
176
|
+
process.exit(0);
|
|
177
|
+
};
|
|
178
|
+
process.once("SIGINT", onSigint);
|
|
179
|
+
let authResult;
|
|
180
|
+
try {
|
|
181
|
+
authResult = await waitForBulletinAuthorization(slotAddress, {
|
|
182
|
+
timeoutMs: Infinity,
|
|
183
|
+
quiet: true,
|
|
184
|
+
endpoints: bulletinEndpoints
|
|
185
|
+
});
|
|
186
|
+
} finally {
|
|
187
|
+
spinner.stop();
|
|
188
|
+
process.removeListener("SIGINT", onSigint);
|
|
104
189
|
}
|
|
105
|
-
|
|
106
|
-
|
|
190
|
+
const summary = bulletinAuthSummary(
|
|
191
|
+
authResult.authorized,
|
|
192
|
+
authResult.authorized ? authResult.expiration : void 0
|
|
193
|
+
);
|
|
194
|
+
console.log(summary.message);
|
|
195
|
+
console.log("\n" + summarizeLogin(handle.address, slotAddress));
|
|
196
|
+
} else {
|
|
197
|
+
const err = signerResult.error;
|
|
198
|
+
console.log("\n" + summarizeLogin(handle.address, null));
|
|
199
|
+
console.warn(` ${allocationErrorMessage(err.reason)}`);
|
|
107
200
|
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
201
|
+
} catch (err) {
|
|
202
|
+
await Promise.resolve(handle.userSession.abortPendingRequests()).catch(() => {
|
|
203
|
+
});
|
|
204
|
+
tearingDown = true;
|
|
205
|
+
console.error(`
|
|
206
|
+
Allocation failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
207
|
+
process.exit(1);
|
|
208
|
+
} finally {
|
|
209
|
+
tearingDown = true;
|
|
210
|
+
handle.destroy();
|
|
111
211
|
}
|
|
212
|
+
process.exit(0);
|
|
112
213
|
}
|
|
113
214
|
export {
|
|
215
|
+
allocationErrorMessage,
|
|
216
|
+
bulletinAuthSummary,
|
|
114
217
|
runLogin,
|
|
115
218
|
summarizeLogin
|
|
116
219
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { g as LogoutStatus } from '../auth-C-Pel0AT.js';
|
|
2
2
|
import '@parity/product-sdk-terminal';
|
|
3
3
|
import 'polkadot-api';
|
|
4
|
-
import '../allocations-B65Is4Md.js';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* logout — sign out the current session.
|
package/dist/commands/logout.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import "../chunk-JQKKMUCT.js";
|
|
2
|
-
import "../chunk-
|
|
2
|
+
import "../chunk-DHY2ZXVZ.js";
|
|
3
3
|
import {
|
|
4
4
|
renderLogoutStatus
|
|
5
5
|
} from "../chunk-RIRDBSBG.js";
|
|
6
6
|
import {
|
|
7
7
|
getAuthClient
|
|
8
|
-
} from "../chunk-
|
|
9
|
-
import "../chunk-
|
|
8
|
+
} from "../chunk-VQB3JWK7.js";
|
|
9
|
+
import "../chunk-EZ352IGD.js";
|
|
10
|
+
import "../chunk-UFQ4EZP3.js";
|
|
11
|
+
import "../chunk-GL3U7K2B.js";
|
|
10
12
|
import "../chunk-ZOC4GITL.js";
|
|
11
13
|
|
|
12
14
|
// src/commands/logout.ts
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { S as SessionAddresses } from '../auth-
|
|
1
|
+
import { S as SessionAddresses } from '../auth-C-Pel0AT.js';
|
|
2
2
|
import '@parity/product-sdk-terminal';
|
|
3
3
|
import 'polkadot-api';
|
|
4
|
-
import '../allocations-B65Is4Md.js';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* whoami — show the currently logged-in session account, or "not logged in".
|