@oneaddress/setup 1.1.6 → 1.1.8

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 (2) hide show
  1. package/dist/index.js +56 -8
  2. 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.6" : "?";
838
+ var WIZARD_VERSION = true ? "1.1.8" : "?";
839
839
  function printHeader() {
840
840
  const BAR_LEN = 85;
841
841
  const TOP_BAR = fn("\u250C") + dm("\u2500".repeat(BAR_LEN)) + fn("\u2510");
@@ -3169,13 +3169,18 @@ async function startServer(platform, outputDir, port = 3001) {
3169
3169
  }
3170
3170
  serverOutput = "";
3171
3171
  const manualCommand = `cd ${outputDir} && ${spec.cmd} ${spec.args.join(" ")}`;
3172
- serverProcess = (0, import_node_child_process2.spawn)(spec.cmd, spec.args, {
3173
- cwd: outputDir,
3174
- stdio: ["ignore", "pipe", "pipe"],
3175
- detached: false,
3176
- shell: process.platform === "win32",
3177
- env: { ...process.env }
3178
- });
3172
+ const isWin = process.platform === "win32";
3173
+ serverProcess = (0, import_node_child_process2.spawn)(
3174
+ isWin ? "cmd.exe" : spec.cmd,
3175
+ isWin ? ["/c", spec.cmd, ...spec.args] : spec.args,
3176
+ {
3177
+ cwd: outputDir,
3178
+ stdio: ["ignore", "pipe", "pipe"],
3179
+ detached: false,
3180
+ shell: false,
3181
+ env: { ...process.env }
3182
+ }
3183
+ );
3179
3184
  serverProcess.stdout?.on("data", (d2) => {
3180
3185
  serverOutput += d2.toString();
3181
3186
  });
@@ -3277,6 +3282,26 @@ async function startTunnel(port) {
3277
3282
  // src/register-url.ts
3278
3283
  var import_node_crypto3 = require("crypto");
3279
3284
  var PORTAL_API = "https://partners.oneaddress.io/api/partner/webhook-url";
3285
+ async function getExistingWebhookUrl(partnerId, webhookSecret) {
3286
+ try {
3287
+ const ts = String(Math.floor(Date.now() / 1e3));
3288
+ const sig = (0, import_node_crypto3.createHmac)("sha256", webhookSecret).update(`${ts}.`).digest("hex");
3289
+ const res = await fetch(PORTAL_API, {
3290
+ method: "GET",
3291
+ headers: {
3292
+ "X-OneAddress-Timestamp": ts,
3293
+ "X-OneAddress-Signature": sig,
3294
+ "X-OneAddress-Partner": partnerId
3295
+ },
3296
+ signal: AbortSignal.timeout(8e3)
3297
+ });
3298
+ if (!res.ok) return void 0;
3299
+ const data = await res.json();
3300
+ return data.webhook_url ?? null;
3301
+ } catch {
3302
+ return void 0;
3303
+ }
3304
+ }
3280
3305
  async function registerWebhookUrl(partnerId, webhookSecret, webhookUrl) {
3281
3306
  try {
3282
3307
  const body = JSON.stringify({ webhook_url: webhookUrl });
@@ -3510,6 +3535,29 @@ async function main() {
3510
3535
  if (start.output) v2.warn(start.output.slice(0, 600));
3511
3536
  }
3512
3537
  let webhookUrl = "";
3538
+ const existingUrl = await getExistingWebhookUrl(pid, secret);
3539
+ if (existingUrl) {
3540
+ v2.warn(
3541
+ `A webhook URL is already registered for this partner:
3542
+ ${existingUrl}
3543
+ Continuing will overwrite it.`
3544
+ );
3545
+ const continueAnyway = await me({
3546
+ message: "Overwrite the existing webhook URL?",
3547
+ initialValue: false
3548
+ });
3549
+ assertNotCancelled(continueAnyway);
3550
+ if (!continueAnyway) {
3551
+ fe("Setup cancelled \u2014 your existing webhook URL was not changed.");
3552
+ for (const fn2 of cleanupFns) {
3553
+ try {
3554
+ fn2();
3555
+ } catch {
3556
+ }
3557
+ }
3558
+ process.exit(0);
3559
+ }
3560
+ }
3513
3561
  const hasPublicUrl = await me({
3514
3562
  message: "Do you have a public HTTPS URL where this server is reachable?",
3515
3563
  initialValue: false
package/package.json CHANGED
@@ -1,32 +1,32 @@
1
- {
2
- "name": "@oneaddress/setup",
3
- "version": "1.1.6",
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.8",
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
+ }