@oneaddress/setup 1.3.3 → 1.3.4
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.
- package/dist/index.js +82 -6
- 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.3.
|
|
859
|
+
var WIZARD_VERSION = true ? "1.3.4" : "?";
|
|
860
860
|
function printCompactHeader() {
|
|
861
861
|
const INNER = 42;
|
|
862
862
|
const TOP = fn("\u250C") + dm("\u2500".repeat(INNER)) + fn("\u2510");
|
|
@@ -1435,7 +1435,17 @@ app.post('/webhook', async (req: Request, res: Response) => {
|
|
|
1435
1435
|
// as "answered but could not decrypt", which is not what happened.
|
|
1436
1436
|
if (event === 'address.test' || event === 'address.test-dispatch') {
|
|
1437
1437
|
const index = typeof body.index === 'number' ? body.index : undefined;
|
|
1438
|
+
// Print the decrypted record as a verification line for the connection-
|
|
1439
|
+
// verification flow. The portal's verify page asks you to copy these lines
|
|
1440
|
+
// (shaped "N | name | address") out of this console and paste them at the
|
|
1441
|
+
// verify URL in your instruction email; decorative lines around them are
|
|
1442
|
+
// ignored, so pasting the whole block is fine. Returning { verification:true }
|
|
1443
|
+
// is what the go-live and receiver-verification decrypt proofs look for.
|
|
1444
|
+
const a = address as { street?: unknown; suburb?: unknown; state?: unknown; postcode?: unknown };
|
|
1445
|
+
const oneLine = [a.street, [a.suburb, a.state, a.postcode].filter(Boolean).join(' ')]
|
|
1446
|
+
.filter(Boolean).join(', ');
|
|
1438
1447
|
console.log(\`[webhook] \${event} verification probe decrypted OK\`);
|
|
1448
|
+
console.log(\`[verification] \${index ?? '?'} | \${ctx.name} | \${oneLine}\`);
|
|
1439
1449
|
return res.status(200).json({ verification: true, index });
|
|
1440
1450
|
}
|
|
1441
1451
|
|
|
@@ -1905,10 +1915,15 @@ async def webhook(request: Request) -> Response:
|
|
|
1905
1915
|
session_share = body.get("session_key_share")
|
|
1906
1916
|
legacy_enc = body.get("address_encrypted")
|
|
1907
1917
|
|
|
1918
|
+
# Decrypted display name, captured for the connection-verification probe
|
|
1919
|
+
# below. Identity comes ONLY from decryption, never a cleartext wire field.
|
|
1920
|
+
verified_name = ""
|
|
1921
|
+
|
|
1908
1922
|
if isinstance(session_envelope, str) and isinstance(session_share, dict):
|
|
1909
1923
|
try:
|
|
1910
1924
|
data = _decrypt_session(session_share, session_envelope, PRIVATE_KEY, PARTNER_ID)
|
|
1911
1925
|
address = data.get("new_address", {})
|
|
1926
|
+
verified_name = data.get("verified_name", "") or ""
|
|
1912
1927
|
except Exception as e:
|
|
1913
1928
|
print(f"[webhook] D5 decryption failed \u2014 check OA_PRIVATE_KEY_PEM matches key_id "
|
|
1914
1929
|
f"{session_share.get('key_id', '?')}: {e}")
|
|
@@ -1917,6 +1932,7 @@ async def webhook(request: Request) -> Response:
|
|
|
1917
1932
|
elif isinstance(legacy_enc, dict):
|
|
1918
1933
|
try:
|
|
1919
1934
|
address = _decrypt_address(legacy_enc, PRIVATE_KEY, PARTNER_ID)
|
|
1935
|
+
verified_name = address.get("fullName", "") or ""
|
|
1920
1936
|
except Exception as e:
|
|
1921
1937
|
print(f"[webhook] Decryption error (check OA_PRIVATE_KEY_PEM): {e}")
|
|
1922
1938
|
return Response(content='{"ok":false,"error":"decryption failed - partner key mismatch"}',
|
|
@@ -1977,8 +1993,18 @@ async def webhook(request: Request) -> Response:
|
|
|
1977
1993
|
# OneAddress connection-verification probe. Reaching here means the D5
|
|
1978
1994
|
# decrypt above succeeded (a wrong key returned 422), which is exactly
|
|
1979
1995
|
# what the check proves, so answer verification=true. Anything else reads
|
|
1980
|
-
# as "answered but could not decrypt", which is not what happened.
|
|
1996
|
+
# as "answered but could not decrypt", which is not what happened. We also
|
|
1997
|
+
# print the decrypted record as a "N | name | address" line: the portal's
|
|
1998
|
+
# verify page asks you to copy these lines from this console and paste
|
|
1999
|
+
# them at the verify URL in your instruction email. Decorative lines are
|
|
2000
|
+
# ignored, so pasting the whole block is fine.
|
|
2001
|
+
idx = body.get("index")
|
|
2002
|
+
_locality = " ".join(str(x) for x in [address.get("suburb", ""),
|
|
2003
|
+
address.get("state", ""),
|
|
2004
|
+
address.get("postcode", "")] if x)
|
|
2005
|
+
one_line = ", ".join(str(p) for p in [address.get("street", ""), _locality] if p)
|
|
1981
2006
|
print(f"[webhook] {event} verification probe decrypted OK")
|
|
2007
|
+
print(f"[verification] {idx if idx is not None else '?'} | {verified_name} | {one_line}")
|
|
1982
2008
|
return Response(content=json.dumps({"verification": True, "index": body.get("index")}),
|
|
1983
2009
|
media_type="application/json")
|
|
1984
2010
|
|
|
@@ -2542,10 +2568,22 @@ public class OneAddressWebhookController {
|
|
|
2542
2568
|
} else if ("address.test".equals(event) || "address.test-dispatch".equals(event)) {
|
|
2543
2569
|
// OneAddress connection-verification probe. Reaching here means the
|
|
2544
2570
|
// D5 decrypt above succeeded (a wrong key returned 422), which is
|
|
2545
|
-
// what the check proves, so answer verification=true.
|
|
2571
|
+
// what the check proves, so answer verification=true. We also print
|
|
2572
|
+
// the decrypted record as a "N | name | address" line: the portal's
|
|
2573
|
+
// verify page asks you to copy these lines from this console and
|
|
2574
|
+
// paste them at the verify URL in your instruction email.
|
|
2546
2575
|
if (dispatchId != null && !dispatchId.isBlank()) store.markProcessed(dispatchId, "verification:ok");
|
|
2547
2576
|
Object idx = body.get("index");
|
|
2577
|
+
java.util.function.Function<String, String> fld = k -> {
|
|
2578
|
+
Object v = address.get(k);
|
|
2579
|
+
return v == null ? "" : String.valueOf(v);
|
|
2580
|
+
};
|
|
2581
|
+
String oaLoc = java.util.stream.Stream.of(fld.apply("suburb"), fld.apply("state"), fld.apply("postcode"))
|
|
2582
|
+
.filter(s -> !s.isBlank()).collect(java.util.stream.Collectors.joining(" "));
|
|
2583
|
+
String oaLine = java.util.stream.Stream.of(fld.apply("street"), oaLoc)
|
|
2584
|
+
.filter(s -> !s.isBlank()).collect(java.util.stream.Collectors.joining(", "));
|
|
2548
2585
|
log.info("[OneAddress] {} verification probe decrypted OK", event);
|
|
2586
|
+
log.info("[verification] {} | {} | {}", idx == null ? "?" : idx, verifiedName, oaLine);
|
|
2549
2587
|
return ResponseEntity.ok("{\\"verification\\":true,\\"index\\":" + (idx == null ? "null" : idx.toString()) + "}");
|
|
2550
2588
|
} else {
|
|
2551
2589
|
log.info("[OneAddress] skipping unknown event: {}", event);
|
|
@@ -3404,10 +3442,20 @@ app.MapPost("/webhooks/oneaddress", async (HttpRequest request) =>
|
|
|
3404
3442
|
{
|
|
3405
3443
|
// OneAddress connection-verification probe. Reaching here means the D5
|
|
3406
3444
|
// decrypt above succeeded (a wrong key returned 422), which is what the
|
|
3407
|
-
// check proves, so answer verification=true.
|
|
3445
|
+
// check proves, so answer verification=true. We also print the decrypted
|
|
3446
|
+
// record as a "N | name | address" line: the portal's verify page asks
|
|
3447
|
+
// you to copy these lines from this console and paste them at the verify
|
|
3448
|
+
// URL in your instruction email.
|
|
3408
3449
|
int? index = body.TryGetProperty("index", out var idxEl) && idxEl.ValueKind == JsonValueKind.Number
|
|
3409
3450
|
? idxEl.GetInt32() : (int?)null;
|
|
3451
|
+
static string OaStr(JsonElement a, string k) =>
|
|
3452
|
+
a.TryGetProperty(k, out var el) && el.ValueKind == JsonValueKind.String ? (el.GetString() ?? "") : "";
|
|
3453
|
+
var oaLoc = string.Join(" ", new[] { OaStr(address, "suburb"), OaStr(address, "state"), OaStr(address, "postcode") }
|
|
3454
|
+
.Where(s => !string.IsNullOrWhiteSpace(s)));
|
|
3455
|
+
var oaLine = string.Join(", ", new[] { OaStr(address, "street"), oaLoc }
|
|
3456
|
+
.Where(s => !string.IsNullOrWhiteSpace(s)));
|
|
3410
3457
|
app.Logger.LogInformation("[OneAddress] {EventType} verification probe decrypted OK", eventType);
|
|
3458
|
+
app.Logger.LogInformation("[verification] {Line}", (index?.ToString() ?? "?") + " | " + verifiedName + " | " + oaLine);
|
|
3411
3459
|
return Results.Json(new { verification = true, index });
|
|
3412
3460
|
}
|
|
3413
3461
|
|
|
@@ -4252,6 +4300,9 @@ func main() {
|
|
|
4252
4300
|
// OneAddress connection-verification probe. Reaching this case means the
|
|
4253
4301
|
// decrypt above succeeded (a wrong key returned 422), which is what the
|
|
4254
4302
|
// check proves, so answer verification=true rather than the ok:true below.
|
|
4303
|
+
// We also print the decrypted record as a "N | name | address" line: the
|
|
4304
|
+
// portal's verify page asks you to copy these lines from this console and
|
|
4305
|
+
// paste them at the verify URL in your instruction email.
|
|
4255
4306
|
log.Printf("[webhook] %s verification probe decrypted OK", event)
|
|
4256
4307
|
if dispatch != "" {
|
|
4257
4308
|
_ = store.MarkProcessed(dispatch, "verification:ok")
|
|
@@ -4260,6 +4311,23 @@ func main() {
|
|
|
4260
4311
|
if v, ok := parsed["index"]; ok {
|
|
4261
4312
|
idx = v
|
|
4262
4313
|
}
|
|
4314
|
+
var locParts []string
|
|
4315
|
+
for _, s := range []string{str(address, "suburb"), str(address, "state"), str(address, "postcode")} {
|
|
4316
|
+
if s != "" {
|
|
4317
|
+
locParts = append(locParts, s)
|
|
4318
|
+
}
|
|
4319
|
+
}
|
|
4320
|
+
var lineParts []string
|
|
4321
|
+
for _, s := range []string{str(address, "street"), strings.Join(locParts, " ")} {
|
|
4322
|
+
if s != "" {
|
|
4323
|
+
lineParts = append(lineParts, s)
|
|
4324
|
+
}
|
|
4325
|
+
}
|
|
4326
|
+
idxStr := "?"
|
|
4327
|
+
if idx != nil {
|
|
4328
|
+
idxStr = fmt.Sprintf("%v", idx)
|
|
4329
|
+
}
|
|
4330
|
+
log.Printf("[verification] %s | %s | %s", idxStr, verifiedName, strings.Join(lineParts, ", "))
|
|
4263
4331
|
jsonResp(w, 200, map[string]any{"verification": true, "index": idx})
|
|
4264
4332
|
return
|
|
4265
4333
|
|
|
@@ -5105,8 +5173,16 @@ Route::post('/webhook', function (Request $request): Response {
|
|
|
5105
5173
|
if ($eventType === 'address.test' || $eventType === 'address.test-dispatch') {
|
|
5106
5174
|
// OneAddress connection-verification probe. Reaching here means the D5
|
|
5107
5175
|
// decrypt above succeeded (a wrong key returned 422), which is what the
|
|
5108
|
-
// check proves, so answer verification=true.
|
|
5176
|
+
// check proves, so answer verification=true. We also print the decrypted
|
|
5177
|
+
// record as a "N | name | address" line: the portal's verify page asks
|
|
5178
|
+
// you to copy these lines from this console and paste them at the verify
|
|
5179
|
+
// URL in your instruction email.
|
|
5180
|
+
$oaAddr = is_array($address) ? $address : [];
|
|
5181
|
+
$oaKeep = static fn($s) => $s !== null && $s !== '';
|
|
5182
|
+
$oaLoc = implode(' ', array_filter([$oaAddr['suburb'] ?? '', $oaAddr['state'] ?? '', $oaAddr['postcode'] ?? ''], $oaKeep));
|
|
5183
|
+
$oaLine = implode(', ', array_filter([$oaAddr['street'] ?? '', $oaLoc], $oaKeep));
|
|
5109
5184
|
\\Log::info('[OneAddress] verification probe decrypted OK', ['event' => $eventType]);
|
|
5185
|
+
\\Log::info('[verification] ' . ($body['index'] ?? '?') . ' | ' . $verifiedName . ' | ' . $oaLine);
|
|
5110
5186
|
return response()->json(['verification' => true, 'index' => $body['index'] ?? null]);
|
|
5111
5187
|
}
|
|
5112
5188
|
|
|
@@ -5296,7 +5372,7 @@ async function scaffold(platform, outputDir, partnerId, webhookSecret, webhookUr
|
|
|
5296
5372
|
|
|
5297
5373
|
// src/register.ts
|
|
5298
5374
|
var import_node_crypto = require("crypto");
|
|
5299
|
-
var PKG_VERSION = true ? "1.3.
|
|
5375
|
+
var PKG_VERSION = true ? "1.3.4" : "dev";
|
|
5300
5376
|
var REGISTER_URL = "https://partners.oneaddress.io/api/partner/installs";
|
|
5301
5377
|
function hmacSha256(secret, message) {
|
|
5302
5378
|
return (0, import_node_crypto.createHmac)("sha256", secret).update(message).digest("hex");
|