@oneaddress/setup 1.4.0 → 1.4.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 +64 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -856,7 +856,7 @@ 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.4.0" : "?";
859
+ var WIZARD_VERSION = true ? "1.4.1" : "?";
860
860
  function printCompactHeader() {
861
861
  const INNER = 42;
862
862
  const TOP = fn("\u250C") + dm("\u2500".repeat(INNER)) + fn("\u2510");
@@ -5409,7 +5409,7 @@ async function scaffold(platform, outputDir, partnerId, webhookSecret, webhookUr
5409
5409
 
5410
5410
  // src/register.ts
5411
5411
  var import_node_crypto = require("crypto");
5412
- var PKG_VERSION = true ? "1.4.0" : "dev";
5412
+ var PKG_VERSION = true ? "1.4.1" : "dev";
5413
5413
  var REGISTER_URL = "https://partners.oneaddress.io/api/partner/installs";
5414
5414
  function hmacSha256(secret, message) {
5415
5415
  return (0, import_node_crypto.createHmac)("sha256", secret).update(message).digest("hex");
@@ -5536,6 +5536,67 @@ async function runConformance(webhookUrl, _partnerId, webhookSecret) {
5536
5536
  M2.warn(`Conformance: ${passed}/${tests.length} passed. Check your WEBHOOK_SECRET and timestamp enforcement.`);
5537
5537
  }
5538
5538
  }
5539
+ var VERIFY_DECRYPT_API = "https://partners.oneaddress.io/api/partner/verify-decrypt";
5540
+ async function runDecryptCheck(webhookSecret, partnerId) {
5541
+ async function callOnce() {
5542
+ try {
5543
+ const ts = String(Math.floor(Date.now() / 1e3));
5544
+ const sig = (0, import_node_crypto2.createHmac)("sha256", webhookSecret).update(`${ts}.`).digest("hex");
5545
+ const res2 = await fetch(VERIFY_DECRYPT_API, {
5546
+ method: "POST",
5547
+ headers: {
5548
+ "Content-Type": "application/json",
5549
+ "X-OneAddress-Timestamp": ts,
5550
+ "X-OneAddress-Signature": sig,
5551
+ "X-OneAddress-Partner": partnerId
5552
+ },
5553
+ // The portal-to-receiver probe can take a few seconds; give it room.
5554
+ signal: AbortSignal.timeout(2e4)
5555
+ });
5556
+ return { res: res2 };
5557
+ } catch (err) {
5558
+ return { netErr: err instanceof Error ? err.message : String(err) };
5559
+ }
5560
+ }
5561
+ let { res, netErr } = await callOnce();
5562
+ if (!res) {
5563
+ await new Promise((r2) => setTimeout(r2, 1500));
5564
+ ({ res, netErr } = await callOnce());
5565
+ }
5566
+ if (!res) {
5567
+ M2.warn(`Decrypt check skipped: could not reach the portal (${netErr}). Re-run once you are back online.`);
5568
+ return;
5569
+ }
5570
+ if (res.status === 404 || res.status === 405) {
5571
+ M2.info("Decrypt check skipped (the portal does not offer it yet). Your go-live switch will run the same check.");
5572
+ return;
5573
+ }
5574
+ if (res.status === 401 || res.status === 403) {
5575
+ M2.warn("Decrypt check skipped: the portal rejected your signing secret. Copy it again from your profile.");
5576
+ return;
5577
+ }
5578
+ if (!res.ok) {
5579
+ M2.warn(`Decrypt check skipped: the portal returned HTTP ${res.status}.`);
5580
+ return;
5581
+ }
5582
+ let data;
5583
+ try {
5584
+ data = await res.json();
5585
+ } catch {
5586
+ M2.warn("Decrypt check skipped: the portal returned an unexpected response.");
5587
+ return;
5588
+ }
5589
+ if (data.decrypted === true) {
5590
+ M2.success("Decrypt check passed \u2014 your receiver decrypted our encrypted test, so your key is correctly installed. Go-live will not surprise you.");
5591
+ return;
5592
+ }
5593
+ if (data.code) {
5594
+ M2.info(`Decrypt check not run yet: ${data.reason ?? "a setup step is still outstanding."}`);
5595
+ return;
5596
+ }
5597
+ const reason = data.reason ?? "Your receiver answered but could not decrypt our encrypted test, which almost always means the private key in your receiver does not match your registered encryption key.";
5598
+ M2.warn(`Decrypt check FAILED: ${reason}`);
5599
+ }
5539
5600
 
5540
5601
  // src/install.ts
5541
5602
  var import_node_child_process = require("child_process");
@@ -6556,6 +6617,7 @@ tunnel needing this wizard to stay open. Re-run once that URL loads in a browser
6556
6617
  await new Promise((r2) => setTimeout(r2, 200));
6557
6618
  s6.stop("Conformance checks:");
6558
6619
  await runConformance(webhookUrl, pid, secret);
6620
+ await runDecryptCheck(secret, pid);
6559
6621
  if (verifiesAccountReference) {
6560
6622
  M2.info(
6561
6623
  "You have declared that your receiver matches the account reference itself.\nRun `npm test` to include check-14, which sends an account reference that matches\nnothing and fails a receiver that reports it as applied. The three checks above\ncover signing and replay only."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oneaddress/setup",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "Interactive setup wizard for OneAddress partner webhook integrations",
5
5
  "main": "dist/index.js",
6
6
  "bin": {