@oneaddress/setup 1.1.7 → 1.1.9
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.js +64 -3
- package/package.json +32 -32
package/dist/index.js
CHANGED
|
@@ -835,7 +835,7 @@ var _R = ["\u2588\u2588\u2588\u2588\u2588\u2588 ", "\u2588\u2588 \u2588\u2588"
|
|
|
835
835
|
var _S = [" \u2588\u2588\u2588\u2588\u2588\u2588", "\u2588\u2588 ", "\u2588\u2588 ", " \u2588\u2588\u2588\u2588\u2588 ", " \u2588\u2588", " \u2588\u2588", "\u2588\u2588\u2588\u2588\u2588\u2588 "];
|
|
836
836
|
var ONE_ROWS = Array.from({ length: 7 }, (_2, i) => [_O[i], _N[i], _E[i]].join(" "));
|
|
837
837
|
var ADDR_ROWS = Array.from({ length: 7 }, (_2, i) => [_A[i], _D2[i], _D2[i], _R[i], _E[i], _S[i], _S[i]].join(" "));
|
|
838
|
-
var WIZARD_VERSION = true ? "1.1.
|
|
838
|
+
var WIZARD_VERSION = true ? "1.1.9" : "?";
|
|
839
839
|
function printHeader() {
|
|
840
840
|
const BAR_LEN = 85;
|
|
841
841
|
const TOP_BAR = fn("\u250C") + dm("\u2500".repeat(BAR_LEN)) + fn("\u2510");
|
|
@@ -1080,6 +1080,15 @@ export async function verifyAddress(customer: Customer, address: Address): Promi
|
|
|
1080
1080
|
* \u2551 To wire up your database: edit src/store.ts instead. \u2551
|
|
1081
1081
|
* \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D
|
|
1082
1082
|
*/
|
|
1083
|
+
// Node.js 22.5+ required for the built-in node:sqlite module used by src/store.ts.
|
|
1084
|
+
// Fail fast with a clear message rather than a cryptic ERR_UNSUPPORTED_FEATURE later.
|
|
1085
|
+
const [nodeMajor, nodeMinor] = process.versions.node.split('.').map(Number);
|
|
1086
|
+
if (nodeMajor < 22 || (nodeMajor === 22 && nodeMinor < 5)) {
|
|
1087
|
+
console.error(\`[startup] Node.js 22.5+ is required (you are running \${process.version}).\`);
|
|
1088
|
+
console.error('[startup] Upgrade Node.js: https://nodejs.org/en/download');
|
|
1089
|
+
process.exit(1);
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1083
1092
|
import 'dotenv/config';
|
|
1084
1093
|
import express, { Request, Response } from 'express';
|
|
1085
1094
|
import { verifySignature, decryptAddress, isFreshTimestamp } from '@oneaddress/partner-sdk';
|
|
@@ -3031,8 +3040,17 @@ async function runConformance(webhookUrl, _partnerId, webhookSecret) {
|
|
|
3031
3040
|
body: validBody,
|
|
3032
3041
|
signal: AbortSignal.timeout(8e3)
|
|
3033
3042
|
});
|
|
3034
|
-
|
|
3035
|
-
|
|
3043
|
+
let bodyOk = true;
|
|
3044
|
+
if (t.expectOk) {
|
|
3045
|
+
try {
|
|
3046
|
+
const json = await res.json();
|
|
3047
|
+
bodyOk = json.ok === true;
|
|
3048
|
+
} catch {
|
|
3049
|
+
bodyOk = false;
|
|
3050
|
+
}
|
|
3051
|
+
}
|
|
3052
|
+
const gotOk = res.ok && bodyOk;
|
|
3053
|
+
const pass = t.expectOk ? gotOk : !res.ok;
|
|
3036
3054
|
if (pass) {
|
|
3037
3055
|
v2.success(` \u2713 ${t.name} (${res.status})`);
|
|
3038
3056
|
passed++;
|
|
@@ -3282,6 +3300,26 @@ async function startTunnel(port) {
|
|
|
3282
3300
|
// src/register-url.ts
|
|
3283
3301
|
var import_node_crypto3 = require("crypto");
|
|
3284
3302
|
var PORTAL_API = "https://partners.oneaddress.io/api/partner/webhook-url";
|
|
3303
|
+
async function getExistingWebhookUrl(partnerId, webhookSecret) {
|
|
3304
|
+
try {
|
|
3305
|
+
const ts = String(Math.floor(Date.now() / 1e3));
|
|
3306
|
+
const sig = (0, import_node_crypto3.createHmac)("sha256", webhookSecret).update(`${ts}.`).digest("hex");
|
|
3307
|
+
const res = await fetch(PORTAL_API, {
|
|
3308
|
+
method: "GET",
|
|
3309
|
+
headers: {
|
|
3310
|
+
"X-OneAddress-Timestamp": ts,
|
|
3311
|
+
"X-OneAddress-Signature": sig,
|
|
3312
|
+
"X-OneAddress-Partner": partnerId
|
|
3313
|
+
},
|
|
3314
|
+
signal: AbortSignal.timeout(8e3)
|
|
3315
|
+
});
|
|
3316
|
+
if (!res.ok) return void 0;
|
|
3317
|
+
const data = await res.json();
|
|
3318
|
+
return data.webhook_url ?? null;
|
|
3319
|
+
} catch {
|
|
3320
|
+
return void 0;
|
|
3321
|
+
}
|
|
3322
|
+
}
|
|
3285
3323
|
async function registerWebhookUrl(partnerId, webhookSecret, webhookUrl) {
|
|
3286
3324
|
try {
|
|
3287
3325
|
const body = JSON.stringify({ webhook_url: webhookUrl });
|
|
@@ -3515,6 +3553,29 @@ async function main() {
|
|
|
3515
3553
|
if (start.output) v2.warn(start.output.slice(0, 600));
|
|
3516
3554
|
}
|
|
3517
3555
|
let webhookUrl = "";
|
|
3556
|
+
const existingUrl = await getExistingWebhookUrl(pid, secret);
|
|
3557
|
+
if (existingUrl) {
|
|
3558
|
+
v2.warn(
|
|
3559
|
+
`A webhook URL is already registered for this partner:
|
|
3560
|
+
${existingUrl}
|
|
3561
|
+
Continuing will overwrite it.`
|
|
3562
|
+
);
|
|
3563
|
+
const continueAnyway = await me({
|
|
3564
|
+
message: "Overwrite the existing webhook URL?",
|
|
3565
|
+
initialValue: false
|
|
3566
|
+
});
|
|
3567
|
+
assertNotCancelled(continueAnyway);
|
|
3568
|
+
if (!continueAnyway) {
|
|
3569
|
+
fe("Setup cancelled \u2014 your existing webhook URL was not changed.");
|
|
3570
|
+
for (const fn2 of cleanupFns) {
|
|
3571
|
+
try {
|
|
3572
|
+
fn2();
|
|
3573
|
+
} catch {
|
|
3574
|
+
}
|
|
3575
|
+
}
|
|
3576
|
+
process.exit(0);
|
|
3577
|
+
}
|
|
3578
|
+
}
|
|
3518
3579
|
const hasPublicUrl = await me({
|
|
3519
3580
|
message: "Do you have a public HTTPS URL where this server is reachable?",
|
|
3520
3581
|
initialValue: false
|
package/package.json
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@oneaddress/setup",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"description": "Interactive setup wizard for OneAddress partner webhook integrations",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"bin": {
|
|
7
|
-
"oneaddress-setup": "dist/index.js"
|
|
8
|
-
},
|
|
9
|
-
"files": [
|
|
10
|
-
"dist",
|
|
11
|
-
"README.md"
|
|
12
|
-
],
|
|
13
|
-
"scripts": {
|
|
14
|
-
"build": "tsup",
|
|
15
|
-
"prepare": "tsup",
|
|
16
|
-
"type-check": "tsc --noEmit"
|
|
17
|
-
},
|
|
18
|
-
"license": "UNLICENSED",
|
|
19
|
-
"publishConfig": {
|
|
20
|
-
"access": "public"
|
|
21
|
-
},
|
|
22
|
-
"dependencies": {
|
|
23
|
-
"@clack/prompts": "^0.9.0"
|
|
24
|
-
},
|
|
25
|
-
"devDependencies": {
|
|
26
|
-
"tsup": "^8.0.0",
|
|
27
|
-
"typescript": "^5.0.0"
|
|
28
|
-
},
|
|
29
|
-
"engines": {
|
|
30
|
-
"node": ">=18"
|
|
31
|
-
}
|
|
32
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@oneaddress/setup",
|
|
3
|
+
"version": "1.1.9",
|
|
4
|
+
"description": "Interactive setup wizard for OneAddress partner webhook integrations",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"oneaddress-setup": "dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsup",
|
|
15
|
+
"prepare": "tsup",
|
|
16
|
+
"type-check": "tsc --noEmit"
|
|
17
|
+
},
|
|
18
|
+
"license": "UNLICENSED",
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@clack/prompts": "^0.9.0"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"tsup": "^8.0.0",
|
|
27
|
+
"typescript": "^5.0.0"
|
|
28
|
+
},
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=18"
|
|
31
|
+
}
|
|
32
|
+
}
|