@oneaddress/setup 1.6.0 → 1.6.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 +53 -22
  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.6.0" : "?";
859
+ var WIZARD_VERSION = true ? "1.6.1" : "?";
860
860
  function printCompactHeader() {
861
861
  const INNER = 42;
862
862
  const TOP = fn("\u250C") + dm("\u2500".repeat(INNER)) + fn("\u2510");
@@ -1667,6 +1667,18 @@ app.post('/webhook', webhookLimiter, async (req: Request, res: Response) => {
1667
1667
  return res.status(200).json({ status });
1668
1668
  }
1669
1669
 
1670
+ // A valid signed request that carries no address payload \u2014 a conformance ping,
1671
+ // or any event added after this receiver was generated \u2014 has already passed
1672
+ // timestamp + signature above, which is exactly what such a probe tests.
1673
+ // Acknowledge it here; only the real dispatch events below require decryption.
1674
+ // A real address.updated that arrives WITHOUT a payload still falls through to
1675
+ // the 422 below, because it IS a dispatch event.
1676
+ const DISPATCH_EVENTS = ['address.updated', 'address.verify', 'address.test', 'address.test-dispatch'];
1677
+ if (!DISPATCH_EVENTS.includes(event)) {
1678
+ console.log(\`[webhook] "\${event}" acknowledged (no address payload to decrypt)\`);
1679
+ return res.status(200).json({ ok: true, skipped: true });
1680
+ }
1681
+
1670
1682
  // 5. Decrypt the address payload. Two shapes possible, exactly one per event:
1671
1683
  // (a) D5 (2026+): body.session_envelope + body.session_key_share. Under D5,
1672
1684
  // address.updated no longer carries a cleartext \`customer\` block \u2014
@@ -2316,6 +2328,15 @@ async def webhook(request: Request) -> Response:
2316
2328
  if dispatch:
2317
2329
  seen_dispatches.add(dispatch)
2318
2330
 
2331
+ # A valid signed request that carries no address payload \u2014 a conformance
2332
+ # ping, or any event added after this receiver was generated \u2014 has already
2333
+ # passed timestamp + signature above, which is exactly what such a probe
2334
+ # tests. Acknowledge it here; only the real dispatch events below require
2335
+ # decryption. A real address.updated with no payload still 422s below.
2336
+ if event not in ("address.updated", "address.verify", "address.test", "address.test-dispatch"):
2337
+ print(f"[webhook] '{event}' acknowledged (no address payload to decrypt)")
2338
+ return Response(content='{"ok":true,"skipped":true}', media_type="application/json")
2339
+
2319
2340
  # Two possible payload shapes:
2320
2341
  # (a) D5 \u2014 body.session_envelope (str) + body.session_key_share (dict)
2321
2342
  # (b) Legacy \u2014 body.address_encrypted (dict)
@@ -4582,6 +4603,19 @@ func main() {
4582
4603
 
4583
4604
  event, _ := parsed["event"].(string)
4584
4605
 
4606
+ // A valid signed request that carries no address payload \u2014 a conformance
4607
+ // ping, or any event added after this receiver was generated \u2014 has already
4608
+ // passed timestamp + signature above, which is exactly what such a probe
4609
+ // tests. Acknowledge it here; only the real dispatch events below require
4610
+ // decryption. A real address.updated with no payload still 422s below.
4611
+ switch event {
4612
+ case "address.updated", "address.verify", "address.test", "address.test-dispatch":
4613
+ default:
4614
+ log.Printf("[webhook] %q acknowledged (no address payload to decrypt)", event)
4615
+ jsonResp(w, 200, map[string]any{"ok": true, "skipped": true})
4616
+ return
4617
+ }
4618
+
4585
4619
  // Two possible payload shapes \u2014 D5 takes precedence when both fields
4586
4620
  // are present. Production deployments holding multiple key rotations
4587
4621
  // should look up the right private key by session_key_share.key_id;
@@ -5782,7 +5816,7 @@ async function scaffold(platform, outputDir, partnerId, webhookSecret, webhookUr
5782
5816
 
5783
5817
  // src/register.ts
5784
5818
  var import_node_crypto = require("crypto");
5785
- var PKG_VERSION = true ? "1.6.0" : "dev";
5819
+ var PKG_VERSION = true ? "1.6.1" : "dev";
5786
5820
  var REGISTER_URL = "https://partners.oneaddress.io/api/partner/installs";
5787
5821
  function hmacSha256(secret, message) {
5788
5822
  return (0, import_node_crypto.createHmac)("sha256", secret).update(message).digest("hex");
@@ -6741,26 +6775,23 @@ async function main() {
6741
6775
  ]
6742
6776
  });
6743
6777
  assertNotCancelled(platform);
6744
- const outputDir = await he({
6745
- message: "Where to write the files?",
6746
- placeholder: "./oneaddress-webhook",
6747
- defaultValue: "./oneaddress-webhook"
6748
- });
6749
- assertNotCancelled(outputDir);
6750
- const outDir = outputDir.trim() || "./oneaddress-webhook";
6751
- if ((0, import_node_fs5.existsSync)(outDir)) {
6752
- const entries = (0, import_node_fs5.readdirSync)(outDir);
6753
- if (entries.length > 0) {
6754
- const overwrite = await ye({
6755
- message: `${outDir} already has files \u2014 overwrite?`,
6756
- initialValue: false
6757
- });
6758
- assertNotCancelled(overwrite);
6759
- if (!overwrite) {
6760
- xe("Choose a different output directory and run again.");
6761
- process.exit(0);
6762
- }
6763
- }
6778
+ let outDir;
6779
+ for (; ; ) {
6780
+ const outputDir = await he({
6781
+ message: "Where to write the files?",
6782
+ placeholder: "./oneaddress-webhook",
6783
+ defaultValue: "./oneaddress-webhook"
6784
+ });
6785
+ assertNotCancelled(outputDir);
6786
+ outDir = outputDir.trim() || "./oneaddress-webhook";
6787
+ if (!(0, import_node_fs5.existsSync)(outDir) || (0, import_node_fs5.readdirSync)(outDir).length === 0) break;
6788
+ const overwrite = await ye({
6789
+ message: `${outDir} already has files \u2014 overwrite?`,
6790
+ initialValue: false
6791
+ });
6792
+ assertNotCancelled(overwrite);
6793
+ if (overwrite) break;
6794
+ M2.info(`Keeping the files in ${outDir}. Enter a different directory to write into.`);
6764
6795
  }
6765
6796
  let accountRefReason = "";
6766
6797
  const accountRefDeclaration = await getVerifiesAccountReference(pid, secret, (r2) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oneaddress/setup",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "Interactive setup wizard for OneAddress partner webhook integrations",
5
5
  "main": "dist/index.js",
6
6
  "bin": {