@oneaddress/setup 1.3.0 → 1.3.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.
Files changed (2) hide show
  1. package/dist/index.js +57 -14
  2. package/package.json +3 -2
package/dist/index.js CHANGED
@@ -856,8 +856,31 @@ var _R = ["\u2588\u2588\u2588\u2588\u2588\u2588 ", "\u2588\u2588 \u2588\u2588"
856
856
  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 "];
857
857
  var ONE_ROWS = Array.from({ length: 7 }, (_3, i) => [_O[i], _N[i], _E[i]].join(" "));
858
858
  var ADDR_ROWS = Array.from({ length: 7 }, (_3, i) => [_A[i], _D2[i], _D2[i], _R[i], _E[i], _S[i], _S[i]].join(" "));
859
- var WIZARD_VERSION = true ? "1.3.0" : "?";
859
+ var WIZARD_VERSION = true ? "1.3.1" : "?";
860
+ function printCompactHeader() {
861
+ const INNER = 42;
862
+ const TOP = fn("\u250C") + dm("\u2500".repeat(INNER)) + fn("\u2510");
863
+ const BOT = fn("\u2514") + dm("\u2500".repeat(INNER)) + fn("\u2518");
864
+ const S3 = dm("\u2502");
865
+ const blank = ` ${S3}${" ".repeat(INNER)}${S3}`;
866
+ const row = (content, visibleLen) => ` ${S3} ${content}${" ".repeat(Math.max(0, INNER - 2 - visibleLen))}${S3}`;
867
+ const ver = `v${WIZARD_VERSION} \xB7 partners.oneaddress.io`;
868
+ console.log("");
869
+ console.log(" " + TOP);
870
+ console.log(blank);
871
+ console.log(row(wb("One ") + ab("Address"), "One Address".length));
872
+ console.log(row(mi("Partner Setup Wizard"), "Partner Setup Wizard".length));
873
+ console.log(row(fn(ver), ver.length));
874
+ console.log(blank);
875
+ console.log(" " + BOT);
876
+ console.log("");
877
+ }
860
878
  function printHeader() {
879
+ const cols = typeof process !== "undefined" && process.stdout && process.stdout.columns ? process.stdout.columns : 80;
880
+ if (cols < 88) {
881
+ printCompactHeader();
882
+ return;
883
+ }
861
884
  const BAR_LEN = 85;
862
885
  const TOP_BAR = fn("\u250C") + dm("\u2500".repeat(BAR_LEN)) + fn("\u2510");
863
886
  const BOT_BAR = fn("\u2514") + dm("\u2500".repeat(BAR_LEN)) + fn("\u2518");
@@ -5201,7 +5224,7 @@ async function scaffold(platform, outputDir, partnerId, webhookSecret, webhookUr
5201
5224
 
5202
5225
  // src/register.ts
5203
5226
  var import_node_crypto = require("crypto");
5204
- var PKG_VERSION = true ? "1.3.0" : "dev";
5227
+ var PKG_VERSION = true ? "1.3.1" : "dev";
5205
5228
  var REGISTER_URL = "https://partners.oneaddress.io/api/partner/installs";
5206
5229
  function hmacSha256(secret, message) {
5207
5230
  return (0, import_node_crypto.createHmac)("sha256", secret).update(message).digest("hex");
@@ -5686,7 +5709,13 @@ async function startTunnel(port) {
5686
5709
  // src/register-url.ts
5687
5710
  var import_node_crypto4 = require("crypto");
5688
5711
  var PORTAL_API = "https://partners.oneaddress.io/api/partner/webhook-url";
5689
- async function getExistingWebhookUrl(partnerId, webhookSecret) {
5712
+ function describeReadFailure(status) {
5713
+ if (status === 401) return "the portal rejected the signature (HTTP 401), which means your Webhook signing secret does not match the one on your profile. Copy it again from partners.oneaddress.io \u2192 Webhook \u2192 Webhook signing secret.";
5714
+ if (status === 404) return "the portal has no active partner for this account (HTTP 404), which usually means it is not approved yet.";
5715
+ if (status === 400) return "the portal rejected the request (HTTP 400).";
5716
+ return `the portal returned HTTP ${status}.`;
5717
+ }
5718
+ async function getExistingWebhookUrl(partnerId, webhookSecret, onError) {
5690
5719
  try {
5691
5720
  const ts = String(Math.floor(Date.now() / 1e3));
5692
5721
  const sig = (0, import_node_crypto4.createHmac)("sha256", webhookSecret).update(`${ts}.`).digest("hex");
@@ -5699,14 +5728,18 @@ async function getExistingWebhookUrl(partnerId, webhookSecret) {
5699
5728
  },
5700
5729
  signal: AbortSignal.timeout(8e3)
5701
5730
  });
5702
- if (!res.ok) return void 0;
5731
+ if (!res.ok) {
5732
+ onError?.(describeReadFailure(res.status));
5733
+ return void 0;
5734
+ }
5703
5735
  const data = await res.json();
5704
5736
  return data.webhook_url ?? null;
5705
- } catch {
5737
+ } catch (err) {
5738
+ onError?.(`could not reach the portal (${err instanceof Error ? err.message : "network error"})`);
5706
5739
  return void 0;
5707
5740
  }
5708
5741
  }
5709
- async function getVerifiesAccountReference(partnerId, webhookSecret) {
5742
+ async function getVerifiesAccountReference(partnerId, webhookSecret, onError) {
5710
5743
  try {
5711
5744
  const ts = String(Math.floor(Date.now() / 1e3));
5712
5745
  const sig = (0, import_node_crypto4.createHmac)("sha256", webhookSecret).update(`${ts}.`).digest("hex");
@@ -5719,13 +5752,17 @@ async function getVerifiesAccountReference(partnerId, webhookSecret) {
5719
5752
  },
5720
5753
  signal: AbortSignal.timeout(8e3)
5721
5754
  });
5722
- if (!res.ok) return void 0;
5755
+ if (!res.ok) {
5756
+ onError?.(describeReadFailure(res.status));
5757
+ return void 0;
5758
+ }
5723
5759
  const data = await res.json();
5724
5760
  const v2 = data.verifies_account_reference;
5725
5761
  if (v2 === true || v2 === false) return v2;
5726
5762
  if (v2 === null) return null;
5727
5763
  return void 0;
5728
- } catch {
5764
+ } catch (err) {
5765
+ onError?.(`could not reach the portal (${err instanceof Error ? err.message : "network error"})`);
5729
5766
  return void 0;
5730
5767
  }
5731
5768
  }
@@ -5997,9 +6034,9 @@ async function main() {
5997
6034
  M2.info(" 3. Get it live with a passing conformance check \u2014 in under 5 minutes");
5998
6035
  M2.info("\nOpen partners.oneaddress.io \u2192 My Profile to find the two values below.\n");
5999
6036
  const webhookSecret = await ge({
6000
- message: "Your Webhook Secret (min 20 chars)",
6037
+ message: "Your Webhook signing secret (min 20 chars)",
6001
6038
  validate: (v2) => {
6002
- if (!v2.trim()) return "Webhook Secret is required";
6039
+ if (!v2.trim()) return "Webhook signing secret is required";
6003
6040
  if (v2.length < 20) return "That looks too short \u2014 paste the full secret from My Profile";
6004
6041
  }
6005
6042
  });
@@ -6059,11 +6096,14 @@ async function main() {
6059
6096
  }
6060
6097
  }
6061
6098
  }
6062
- const accountRefDeclaration = await getVerifiesAccountReference(pid, secret);
6099
+ let accountRefReason = "";
6100
+ const accountRefDeclaration = await getVerifiesAccountReference(pid, secret, (r2) => {
6101
+ accountRefReason = r2;
6102
+ });
6063
6103
  const verifiesAccountReference = accountRefDeclaration === true;
6064
6104
  if (accountRefDeclaration === void 0) {
6065
6105
  M2.warn(
6066
- "Could not read your account-reference declaration from the portal.\nConformance check-14 has been left out of the generated `npm test`, so a\npassing run does NOT mean your receiver matches account references correctly.\nSet it at partners.oneaddress.io \u2192 My Profile, then re-run this wizard."
6106
+ "Could not read your account-reference declaration from the portal.\n" + (accountRefReason ? "Reason: " + accountRefReason + "\n" : "") + "Conformance check-14 has been left out of the generated `npm test`, so a\npassing run does NOT mean your receiver matches account references correctly.\nSet it at partners.oneaddress.io \u2192 My Profile, then re-run this wizard."
6067
6107
  );
6068
6108
  }
6069
6109
  const s1 = Y2();
@@ -6137,7 +6177,10 @@ async function main() {
6137
6177
  if (start.output) M2.warn(start.output.slice(0, 600));
6138
6178
  }
6139
6179
  let webhookUrl = "";
6140
- const existingUrlResult = await getExistingWebhookUrl(pid, secret);
6180
+ let existingUrlReason = "";
6181
+ const existingUrlResult = await getExistingWebhookUrl(pid, secret, (r2) => {
6182
+ existingUrlReason = r2;
6183
+ });
6141
6184
  if (typeof existingUrlResult === "string") {
6142
6185
  M2.warn(
6143
6186
  `A webhook URL is already registered for this partner:
@@ -6156,7 +6199,7 @@ Continuing will overwrite it.`
6156
6199
  }
6157
6200
  } else if (existingUrlResult === void 0) {
6158
6201
  M2.warn(
6159
- "Could not check whether a webhook URL is already registered (portal API unreachable). Any URL you register now will overwrite an existing one without warning."
6202
+ "Could not check whether a webhook URL is already registered" + (existingUrlReason ? ": " + existingUrlReason : " (portal API unreachable).") + "\nAny URL you register now will overwrite an existing one without warning."
6160
6203
  );
6161
6204
  const continueAnyway = await ye({
6162
6205
  message: "Continue anyway?",
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@oneaddress/setup",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "Interactive setup wizard for OneAddress partner webhook integrations",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
7
7
  "oneaddress-setup": "dist/index.js"
8
8
  },
9
9
  "files": [
10
- "LICENSE", "dist",
10
+ "LICENSE",
11
+ "dist",
11
12
  "README.md"
12
13
  ],
13
14
  "scripts": {