@oneaddress/setup 1.1.7 → 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 +44 -1
  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.7" : "?";
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");
@@ -3282,6 +3282,26 @@ async function startTunnel(port) {
3282
3282
  // src/register-url.ts
3283
3283
  var import_node_crypto3 = require("crypto");
3284
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
+ }
3285
3305
  async function registerWebhookUrl(partnerId, webhookSecret, webhookUrl) {
3286
3306
  try {
3287
3307
  const body = JSON.stringify({ webhook_url: webhookUrl });
@@ -3515,6 +3535,29 @@ async function main() {
3515
3535
  if (start.output) v2.warn(start.output.slice(0, 600));
3516
3536
  }
3517
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
+ }
3518
3561
  const hasPublicUrl = await me({
3519
3562
  message: "Do you have a public HTTPS URL where this server is reachable?",
3520
3563
  initialValue: false
package/package.json CHANGED
@@ -1,32 +1,32 @@
1
- {
2
- "name": "@oneaddress/setup",
3
- "version": "1.1.7",
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
+ }