@cross-deck/node 1.3.1 → 1.5.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.
- package/CHANGELOG.md +101 -0
- package/README.md +120 -0
- package/dist/auto-events/index.d.mts +1 -1
- package/dist/auto-events/index.d.ts +1 -1
- package/dist/contracts.json +552 -0
- package/dist/{crossdeck-server-DhnHvUhh.d.mts → crossdeck-server-CY4PZk-j.d.mts} +200 -12
- package/dist/{crossdeck-server-DhnHvUhh.d.ts → crossdeck-server-CY4PZk-j.d.ts} +200 -12
- package/dist/index.cjs +1020 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +150 -21
- package/dist/index.d.ts +150 -21
- package/dist/index.mjs +1005 -69
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -3
package/dist/index.mjs
CHANGED
|
@@ -316,10 +316,85 @@ function byteLength(s) {
|
|
|
316
316
|
return s.length * 4;
|
|
317
317
|
}
|
|
318
318
|
|
|
319
|
+
// src/_diagnostic-telemetry.ts
|
|
320
|
+
import * as https from "https";
|
|
321
|
+
|
|
319
322
|
// src/_version.ts
|
|
320
|
-
var SDK_VERSION = "1.
|
|
323
|
+
var SDK_VERSION = "1.5.1";
|
|
321
324
|
var SDK_NAME = "@cross-deck/node";
|
|
322
325
|
|
|
326
|
+
// src/_diagnostic-telemetry.ts
|
|
327
|
+
var DIAGNOSTIC_TELEMETRY_ENDPOINT = "https://api.cross-deck.com/v1/sdk/diagnostic";
|
|
328
|
+
var DIAGNOSTIC_TELEMETRY_PUBLISHABLE_KEY = "cd_pub_RELIABILITY_PLACEHOLDER_TO_BE_PROVISIONED";
|
|
329
|
+
function isDiagnosticTelemetryEnabled() {
|
|
330
|
+
return !DIAGNOSTIC_TELEMETRY_PUBLISHABLE_KEY.startsWith(
|
|
331
|
+
"cd_pub_RELIABILITY_PLACEHOLDER"
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
var DIAGNOSTIC_TELEMETRY_ALLOWED_KEYS = /* @__PURE__ */ new Set([
|
|
335
|
+
"contract_id",
|
|
336
|
+
"sdk_version",
|
|
337
|
+
"sdk_platform",
|
|
338
|
+
"failure_reason",
|
|
339
|
+
"run_context",
|
|
340
|
+
"run_id",
|
|
341
|
+
"test_file",
|
|
342
|
+
"test_name",
|
|
343
|
+
"device_class"
|
|
344
|
+
]);
|
|
345
|
+
function filterDiagnosticPayload(payload) {
|
|
346
|
+
const filtered = {};
|
|
347
|
+
for (const [k, v] of Object.entries(payload)) {
|
|
348
|
+
if (DIAGNOSTIC_TELEMETRY_ALLOWED_KEYS.has(k) && typeof v === "string") {
|
|
349
|
+
filtered[k] = v;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
return filtered;
|
|
353
|
+
}
|
|
354
|
+
function sendDiagnosticTelemetry(payload) {
|
|
355
|
+
if (!isDiagnosticTelemetryEnabled()) return;
|
|
356
|
+
const filtered = filterDiagnosticPayload(payload);
|
|
357
|
+
if (Object.keys(filtered).length === 0) return;
|
|
358
|
+
const body = JSON.stringify(filtered);
|
|
359
|
+
let parsed;
|
|
360
|
+
try {
|
|
361
|
+
parsed = new URL(DIAGNOSTIC_TELEMETRY_ENDPOINT);
|
|
362
|
+
} catch {
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
try {
|
|
366
|
+
const req = https.request({
|
|
367
|
+
method: "POST",
|
|
368
|
+
hostname: parsed.hostname,
|
|
369
|
+
port: parsed.port || 443,
|
|
370
|
+
path: parsed.pathname + parsed.search,
|
|
371
|
+
// Short timeout — reliability telemetry must never stall the
|
|
372
|
+
// host server. A failed POST is acceptable; a hung POST is not.
|
|
373
|
+
timeout: 5e3,
|
|
374
|
+
headers: {
|
|
375
|
+
"Content-Type": "application/json",
|
|
376
|
+
"Content-Length": Buffer.byteLength(body, "utf8").toString(),
|
|
377
|
+
Authorization: `Bearer ${DIAGNOSTIC_TELEMETRY_PUBLISHABLE_KEY}`,
|
|
378
|
+
"Crossdeck-Sdk-Version": `${SDK_NAME}@${SDK_VERSION}`
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
req.on("error", () => {
|
|
382
|
+
});
|
|
383
|
+
req.on("timeout", () => {
|
|
384
|
+
try {
|
|
385
|
+
req.destroy();
|
|
386
|
+
} catch {
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
req.on("response", (res) => {
|
|
390
|
+
res.resume();
|
|
391
|
+
});
|
|
392
|
+
req.write(body);
|
|
393
|
+
req.end();
|
|
394
|
+
} catch {
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
323
398
|
// src/http.ts
|
|
324
399
|
var DEFAULT_BASE_URL = "https://api.cross-deck.com/v1";
|
|
325
400
|
var DEFAULT_TIMEOUT_MS = 15e3;
|
|
@@ -2349,6 +2424,63 @@ var EntitlementCache = class {
|
|
|
2349
2424
|
}
|
|
2350
2425
|
};
|
|
2351
2426
|
|
|
2427
|
+
// src/consent.ts
|
|
2428
|
+
var EMAIL_PATTERN = /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g;
|
|
2429
|
+
var CARD_PATTERN = /\b\d(?:[ -]?\d){12,18}\b/g;
|
|
2430
|
+
var REPLACEMENT_EMAIL = "<email>";
|
|
2431
|
+
var REPLACEMENT_CARD = "<card>";
|
|
2432
|
+
function scrubPii(value) {
|
|
2433
|
+
if (!value) return value;
|
|
2434
|
+
return value.replace(EMAIL_PATTERN, REPLACEMENT_EMAIL).replace(CARD_PATTERN, REPLACEMENT_CARD);
|
|
2435
|
+
}
|
|
2436
|
+
function scrubPiiFromProperties(properties) {
|
|
2437
|
+
const out = {};
|
|
2438
|
+
for (const k of Object.keys(properties)) {
|
|
2439
|
+
out[k] = scrubValue(properties[k]);
|
|
2440
|
+
}
|
|
2441
|
+
return out;
|
|
2442
|
+
}
|
|
2443
|
+
function scrubValue(v) {
|
|
2444
|
+
if (typeof v === "string") return scrubPii(v);
|
|
2445
|
+
if (Array.isArray(v)) return v.map(scrubValue);
|
|
2446
|
+
if (v && typeof v === "object" && v.constructor === Object) {
|
|
2447
|
+
return scrubPiiFromProperties(v);
|
|
2448
|
+
}
|
|
2449
|
+
return v;
|
|
2450
|
+
}
|
|
2451
|
+
|
|
2452
|
+
// src/idempotency-key.ts
|
|
2453
|
+
import { createHash } from "crypto";
|
|
2454
|
+
function formatAsUuid(hex) {
|
|
2455
|
+
return [
|
|
2456
|
+
hex.slice(0, 8),
|
|
2457
|
+
hex.slice(8, 12),
|
|
2458
|
+
hex.slice(12, 16),
|
|
2459
|
+
hex.slice(16, 20),
|
|
2460
|
+
hex.slice(20, 32)
|
|
2461
|
+
].join("-");
|
|
2462
|
+
}
|
|
2463
|
+
function sha256Hex(input) {
|
|
2464
|
+
return createHash("sha256").update(input, "utf8").digest("hex");
|
|
2465
|
+
}
|
|
2466
|
+
function deriveIdempotencyKeyForPurchase(body) {
|
|
2467
|
+
let identifier;
|
|
2468
|
+
if (body.rail === "apple") {
|
|
2469
|
+
identifier = body.signedTransactionInfo ?? "";
|
|
2470
|
+
} else if (body.rail === "google") {
|
|
2471
|
+
identifier = body.purchaseToken ?? "";
|
|
2472
|
+
} else {
|
|
2473
|
+
identifier = "";
|
|
2474
|
+
}
|
|
2475
|
+
if (!identifier) {
|
|
2476
|
+
throw new Error(
|
|
2477
|
+
`deriveIdempotencyKeyForPurchase: no stable identifier in body (rail=${body.rail}). Apple needs signedTransactionInfo; Google needs purchaseToken.`
|
|
2478
|
+
);
|
|
2479
|
+
}
|
|
2480
|
+
const namespaced = `crossdeck:purchases/sync:${body.rail}:${identifier}`;
|
|
2481
|
+
return formatAsUuid(sha256Hex(namespaced));
|
|
2482
|
+
}
|
|
2483
|
+
|
|
2352
2484
|
// src/debug.ts
|
|
2353
2485
|
var SENSITIVE_KEY_PATTERNS = [
|
|
2354
2486
|
/^email$/i,
|
|
@@ -2408,6 +2540,10 @@ var CrossdeckServer = class extends EventEmitter {
|
|
|
2408
2540
|
baseUrl;
|
|
2409
2541
|
appId;
|
|
2410
2542
|
env;
|
|
2543
|
+
/** PII scrubber toggle. Default true — parity with Web/RN/Swift.
|
|
2544
|
+
* Pre-v1.4.0 the Node SDK shipped track() payloads UNREDACTED,
|
|
2545
|
+
* a privacy contract drift versus the README. */
|
|
2546
|
+
scrubPii;
|
|
2411
2547
|
secretKeyPrefix;
|
|
2412
2548
|
/**
|
|
2413
2549
|
* Process-stable pseudo-anonymous ID. Used as the default identity
|
|
@@ -2453,6 +2589,15 @@ var CrossdeckServer = class extends EventEmitter {
|
|
|
2453
2589
|
errorContext = {};
|
|
2454
2590
|
errorTags = {};
|
|
2455
2591
|
errorBeforeSend = null;
|
|
2592
|
+
/**
|
|
2593
|
+
* Dedup gate for `sdk.shutdown`. Both `shutdown()` (async) and
|
|
2594
|
+
* `shutdownSync()` need to emit so direct callers of EITHER see
|
|
2595
|
+
* the event (the async path's listener guarantees pre-launch
|
|
2596
|
+
* tests, the sync path covers `Symbol.dispose` + tests that call
|
|
2597
|
+
* `shutdownSync()` directly). Without this flag, `shutdown()`'s
|
|
2598
|
+
* tail call into `shutdownSync()` would emit twice.
|
|
2599
|
+
*/
|
|
2600
|
+
didEmitShutdown = false;
|
|
2456
2601
|
constructor(options) {
|
|
2457
2602
|
super();
|
|
2458
2603
|
if (!options.secretKey || !options.secretKey.startsWith("cd_sk_")) {
|
|
@@ -2467,6 +2612,7 @@ var CrossdeckServer = class extends EventEmitter {
|
|
|
2467
2612
|
this.baseUrl = options.baseUrl ?? DEFAULT_BASE_URL;
|
|
2468
2613
|
this.env = inferEnvFromKey(options.secretKey);
|
|
2469
2614
|
this.secretKeyPrefix = maskSecretKey(options.secretKey);
|
|
2615
|
+
this.scrubPii = options.scrubPii !== false;
|
|
2470
2616
|
this.http = new HttpClient({
|
|
2471
2617
|
secretKey: options.secretKey,
|
|
2472
2618
|
baseUrl: this.baseUrl,
|
|
@@ -2506,7 +2652,9 @@ var CrossdeckServer = class extends EventEmitter {
|
|
|
2506
2652
|
this.eventQueue = new EventQueue({
|
|
2507
2653
|
http: this.http,
|
|
2508
2654
|
batchSize: options.eventFlushBatchSize ?? 20,
|
|
2509
|
-
|
|
2655
|
+
// v1.4.0 Phase 3.3 — flush interval default parity at 2000ms
|
|
2656
|
+
// across every SDK. Per-instance override stays.
|
|
2657
|
+
intervalMs: options.eventFlushIntervalMs ?? 2e3,
|
|
2510
2658
|
envelope: () => ({
|
|
2511
2659
|
appId: this.appId,
|
|
2512
2660
|
// Ship env on every batch so the backend can cross-check
|
|
@@ -2885,6 +3033,34 @@ var CrossdeckServer = class extends EventEmitter {
|
|
|
2885
3033
|
* `uncaughtException` has no per-request context; without the
|
|
2886
3034
|
* auto-fill, the event would be rejected at queue enqueue.
|
|
2887
3035
|
*/
|
|
3036
|
+
/**
|
|
3037
|
+
* Emit `crossdeck.contract_failed` to the Crossdeck reliability
|
|
3038
|
+
* endpoint — single-fire, one-way, never visible in the customer's
|
|
3039
|
+
* dashboard. Goes over a dedicated HTTP path with the reliability
|
|
3040
|
+
* publishable key embedded at build time; the customer's track()
|
|
3041
|
+
* pipeline never carries `crossdeck.*` events. This is the
|
|
3042
|
+
* independent-controller flow described in Privacy Policy §6
|
|
3043
|
+
* ("Flow B"). The wire shape is fixed by the schema-lock contract
|
|
3044
|
+
* at `contracts/diagnostics/contract-failed-payload-schema-lock.json`.
|
|
3045
|
+
*/
|
|
3046
|
+
reportContractFailure(input) {
|
|
3047
|
+
const payload = {
|
|
3048
|
+
contract_id: input.contractId,
|
|
3049
|
+
sdk_version: SDK_VERSION,
|
|
3050
|
+
sdk_platform: "node",
|
|
3051
|
+
failure_reason: input.failureReason,
|
|
3052
|
+
run_context: input.runContext,
|
|
3053
|
+
run_id: input.runId
|
|
3054
|
+
};
|
|
3055
|
+
if (input.testRef) {
|
|
3056
|
+
payload.test_file = input.testRef.file;
|
|
3057
|
+
payload.test_name = input.testRef.name;
|
|
3058
|
+
}
|
|
3059
|
+
if (input.deviceClass) {
|
|
3060
|
+
payload.device_class = input.deviceClass;
|
|
3061
|
+
}
|
|
3062
|
+
sendDiagnosticTelemetry(payload);
|
|
3063
|
+
}
|
|
2888
3064
|
track(event) {
|
|
2889
3065
|
if (!event.name) {
|
|
2890
3066
|
throw new CrossdeckError({
|
|
@@ -2893,7 +3069,8 @@ var CrossdeckServer = class extends EventEmitter {
|
|
|
2893
3069
|
message: "track(event) requires a non-empty event.name."
|
|
2894
3070
|
});
|
|
2895
3071
|
}
|
|
2896
|
-
const
|
|
3072
|
+
const validated = sanitizePropertyBag(event.properties, "event properties") ?? {};
|
|
3073
|
+
const sanitized = this.scrubPii ? scrubPiiFromProperties(validated) : validated;
|
|
2897
3074
|
if (this.debug.enabled) {
|
|
2898
3075
|
const flagged = findSensitivePropertyKeys(sanitized);
|
|
2899
3076
|
if (flagged.length > 0) {
|
|
@@ -3029,11 +3206,25 @@ var CrossdeckServer = class extends EventEmitter {
|
|
|
3029
3206
|
});
|
|
3030
3207
|
}
|
|
3031
3208
|
const rail = input.rail ?? "apple";
|
|
3032
|
-
|
|
3033
|
-
|
|
3209
|
+
const body = { ...input, rail };
|
|
3210
|
+
const idempotencyKey = options?.idempotencyKey ?? deriveIdempotencyKeyForPurchase(body);
|
|
3211
|
+
const result = await this.http.request("POST", "/purchases/sync", {
|
|
3212
|
+
body,
|
|
3213
|
+
idempotencyKey,
|
|
3034
3214
|
signal: options?.signal,
|
|
3035
3215
|
timeoutMs: options?.timeoutMs
|
|
3036
3216
|
});
|
|
3217
|
+
try {
|
|
3218
|
+
const sourceProductId = result.entitlements[0]?.source.productId;
|
|
3219
|
+
const sourceSubscriptionId = result.entitlements[0]?.source.subscriptionId;
|
|
3220
|
+
const props = { rail };
|
|
3221
|
+
if (sourceProductId) props.productId = sourceProductId;
|
|
3222
|
+
if (sourceSubscriptionId) props.subscriptionId = sourceSubscriptionId;
|
|
3223
|
+
if (result.idempotent_replay) props.idempotent_replay = true;
|
|
3224
|
+
this.track({ name: "purchase.completed", properties: props });
|
|
3225
|
+
} catch {
|
|
3226
|
+
}
|
|
3227
|
+
return result;
|
|
3037
3228
|
}
|
|
3038
3229
|
// ============================================================
|
|
3039
3230
|
// Manual entitlement controls + audit — direct HTTP
|
|
@@ -3325,12 +3516,56 @@ var CrossdeckServer = class extends EventEmitter {
|
|
|
3325
3516
|
};
|
|
3326
3517
|
}
|
|
3327
3518
|
/**
|
|
3328
|
-
* Tear down handlers and clear in-memory state.
|
|
3329
|
-
*
|
|
3330
|
-
* `flush
|
|
3519
|
+
* Tear down handlers and clear in-memory state.
|
|
3520
|
+
*
|
|
3521
|
+
* **v1.4.0 bank-grade contract:** `shutdown()` AWAITS `flush()`
|
|
3522
|
+
* before dropping the queue, so callers don't silently lose
|
|
3523
|
+
* every queued event on a clean shutdown. The pre-v1.4.0
|
|
3524
|
+
* behaviour (sync `eventQueue.reset()` with no flush) was the
|
|
3525
|
+
* default for both `shutdown()` and `[Symbol.dispose]`; only
|
|
3526
|
+
* `await using` + `[Symbol.asyncDispose]` flushed correctly.
|
|
3527
|
+
*
|
|
3528
|
+
* Production servers should still prefer `await server.flush()`
|
|
3529
|
+
* (visible) followed by `server.shutdown()` so the flush
|
|
3530
|
+
* outcome is observable — `shutdown()`'s internal flush swallows
|
|
3531
|
+
* errors as a best-effort drain.
|
|
3532
|
+
*
|
|
3533
|
+
* Use [[shutdownSync]] only when the runtime cannot await
|
|
3534
|
+
* (e.g. inside `Symbol.dispose` — see below).
|
|
3535
|
+
*/
|
|
3536
|
+
async shutdown(reason = "shutdown") {
|
|
3537
|
+
if (!this.didEmitShutdown) {
|
|
3538
|
+
this.emit("sdk.shutdown", { reason });
|
|
3539
|
+
this.didEmitShutdown = true;
|
|
3540
|
+
}
|
|
3541
|
+
try {
|
|
3542
|
+
await this.flush();
|
|
3543
|
+
} catch {
|
|
3544
|
+
}
|
|
3545
|
+
this.shutdownSync(reason);
|
|
3546
|
+
}
|
|
3547
|
+
/**
|
|
3548
|
+
* Synchronous teardown — drops the in-memory queue WITHOUT
|
|
3549
|
+
* flushing, then clears all in-memory state. Used by
|
|
3550
|
+
* `[Symbol.dispose]` (which has no await) and tests that need
|
|
3551
|
+
* an unconditional sync wipe. Production code should use
|
|
3552
|
+
* [[shutdown]] (async) instead so queued events are flushed.
|
|
3553
|
+
*
|
|
3554
|
+
* A queue with items at sync-shutdown logs a warning recommending
|
|
3555
|
+
* `[Symbol.asyncDispose]` or `await server.shutdown()` — silent
|
|
3556
|
+
* loss is incompatible with the bank-grade contract.
|
|
3331
3557
|
*/
|
|
3332
|
-
|
|
3333
|
-
this.
|
|
3558
|
+
shutdownSync(reason = "shutdown") {
|
|
3559
|
+
if (!this.didEmitShutdown) {
|
|
3560
|
+
this.emit("sdk.shutdown", { reason });
|
|
3561
|
+
this.didEmitShutdown = true;
|
|
3562
|
+
}
|
|
3563
|
+
const queuedCount = this.eventQueue.getStats().buffered;
|
|
3564
|
+
if (queuedCount > 0 && reason !== "asyncDispose") {
|
|
3565
|
+
console.warn(
|
|
3566
|
+
`[crossdeck] shutdownSync() dropped ${queuedCount} queued event(s) without flushing. Use \`await server.shutdown()\` or \`await using server = ...\` with \`[Symbol.asyncDispose]\` to drain the buffer before teardown.`
|
|
3567
|
+
);
|
|
3568
|
+
}
|
|
3334
3569
|
this.errorTracker?.uninstall();
|
|
3335
3570
|
this.flushOnExit?.uninstall();
|
|
3336
3571
|
this.eventQueue.reset();
|
|
@@ -3444,28 +3679,28 @@ var CrossdeckServer = class extends EventEmitter {
|
|
|
3444
3679
|
* // ... use server ...
|
|
3445
3680
|
* // at end of block, server[Symbol.dispose]() runs automatically
|
|
3446
3681
|
*
|
|
3447
|
-
*
|
|
3448
|
-
*
|
|
3449
|
-
*
|
|
3450
|
-
*
|
|
3682
|
+
* **`Symbol.dispose` is synchronous so it CANNOT await the queue
|
|
3683
|
+
* flush.** A queue with pending events at sync-dispose time will
|
|
3684
|
+
* be DROPPED — `shutdownSync` warns to the console when this
|
|
3685
|
+
* happens. For the common case of "drain the queue before
|
|
3686
|
+
* exit", switch to `await using` + `[Symbol.asyncDispose]` (or
|
|
3687
|
+
* call `await server.shutdown()` explicitly before the variable
|
|
3688
|
+
* goes out of scope).
|
|
3451
3689
|
*/
|
|
3452
3690
|
[Symbol.dispose]() {
|
|
3453
|
-
this.
|
|
3691
|
+
this.shutdownSync("dispose");
|
|
3454
3692
|
}
|
|
3455
3693
|
/**
|
|
3456
3694
|
* Async disposal hook — runs when an `await using` declaration
|
|
3457
|
-
* exits scope. Awaits
|
|
3458
|
-
*
|
|
3459
|
-
*
|
|
3695
|
+
* exits scope. Awaits the bank-grade `shutdown()` which flushes
|
|
3696
|
+
* the queue THEN tears down. Use this variant for any code path
|
|
3697
|
+
* that owns queued events at exit (serverless handlers,
|
|
3698
|
+
* background workers, end-of-request hooks).
|
|
3460
3699
|
*
|
|
3461
3700
|
* await using server = new CrossdeckServer({ ... });
|
|
3462
3701
|
*/
|
|
3463
3702
|
async [Symbol.asyncDispose]() {
|
|
3464
|
-
|
|
3465
|
-
await this.flush();
|
|
3466
|
-
} catch {
|
|
3467
|
-
}
|
|
3468
|
-
this.shutdown("asyncDispose");
|
|
3703
|
+
await this.shutdown("asyncDispose");
|
|
3469
3704
|
}
|
|
3470
3705
|
// ============================================================
|
|
3471
3706
|
reportCapturedError(captured) {
|
|
@@ -3885,18 +4120,43 @@ var _CROSSDECK_ERROR_CODES = Object.freeze([
|
|
|
3885
4120
|
retryable: false
|
|
3886
4121
|
},
|
|
3887
4122
|
// ----- Webhook verification (Node-specific) -----
|
|
4123
|
+
// v1.4.0 Phase 7.2 — distinguishable codes. Pre-v1.4.0 the
|
|
4124
|
+
// helper used webhook_invalid_signature for nearly every failure
|
|
4125
|
+
// mode so a customer couldn't separate replay-attack signals
|
|
4126
|
+
// from wrong-secret signals in alerting.
|
|
3888
4127
|
{
|
|
3889
|
-
code: "
|
|
4128
|
+
code: "webhook_signature_mismatch",
|
|
3890
4129
|
type: "authentication_error",
|
|
3891
|
-
description: "
|
|
3892
|
-
resolution: "Confirm the secret matches
|
|
4130
|
+
description: "Webhook HMAC didn't verify against any configured secret (wrong-secret / stale rotation signal).",
|
|
4131
|
+
resolution: "Confirm the secret matches dashboard \u2192 Webhooks. If you rotated, include both the old and new secret as an array until receivers cut over.",
|
|
3893
4132
|
retryable: false
|
|
3894
4133
|
},
|
|
3895
4134
|
{
|
|
3896
|
-
code: "
|
|
4135
|
+
code: "webhook_timestamp_outside_tolerance",
|
|
4136
|
+
type: "authentication_error",
|
|
4137
|
+
description: "Webhook timestamp drift exceeds the configured replay-tolerance window (default 5 minutes; replay-attack signal).",
|
|
4138
|
+
resolution: "Verify NTP on the receiving host. A spike on this code warrants its own alert separate from signature_mismatch \u2014 replay attacks look like this.",
|
|
4139
|
+
retryable: false
|
|
4140
|
+
},
|
|
4141
|
+
{
|
|
4142
|
+
code: "webhook_timestamp_missing",
|
|
3897
4143
|
type: "authentication_error",
|
|
3898
|
-
description: "
|
|
3899
|
-
resolution: "
|
|
4144
|
+
description: "Webhook signature header is absent or has no `t=` timestamp segment \u2014 the timestamp gate cannot be verified.",
|
|
4145
|
+
resolution: "Confirm the request actually came from Crossdeck (signature headers are always present on real deliveries). A missing header is either a misconfigured intermediary or a forged request.",
|
|
4146
|
+
retryable: false
|
|
4147
|
+
},
|
|
4148
|
+
{
|
|
4149
|
+
code: "webhook_payload_not_json",
|
|
4150
|
+
type: "authentication_error",
|
|
4151
|
+
description: "Webhook signature verified but the body isn't valid JSON \u2014 payload tampered post-signing or source bug.",
|
|
4152
|
+
resolution: "Inspect the raw payload. If it's not JSON, either the request was modified in transit or the sender has a bug \u2014 file a support ticket with the raw body.",
|
|
4153
|
+
retryable: false
|
|
4154
|
+
},
|
|
4155
|
+
{
|
|
4156
|
+
code: "webhook_invalid_tolerance",
|
|
4157
|
+
type: "configuration_error",
|
|
4158
|
+
description: "verifyWebhookSignature() called with a non-finite / negative / above-24h-cap replayToleranceMs (would silently disable replay protection).",
|
|
4159
|
+
resolution: "Pass a finite number between 0 and 86_400_000ms (24h). Default (5 minutes) is correct for almost every scenario. Pre-v1.4.0 accepted Infinity/NaN and silently dropped the check.",
|
|
3900
4160
|
retryable: false
|
|
3901
4161
|
},
|
|
3902
4162
|
{
|
|
@@ -3905,6 +4165,101 @@ var _CROSSDECK_ERROR_CODES = Object.freeze([
|
|
|
3905
4165
|
description: "verifyWebhookSignature() was called without a signing secret.",
|
|
3906
4166
|
resolution: "Pass the secret from your Crossdeck dashboard \u2192 Webhooks page. Never hardcode in source \u2014 read from an env var.",
|
|
3907
4167
|
retryable: false
|
|
4168
|
+
},
|
|
4169
|
+
{
|
|
4170
|
+
code: "webhook_invalid_signature",
|
|
4171
|
+
type: "authentication_error",
|
|
4172
|
+
description: "DEPRECATED in v1.4.0 \u2014 split into webhook_signature_mismatch / webhook_timestamp_missing / webhook_timestamp_outside_tolerance / webhook_payload_not_json for alerting clarity.",
|
|
4173
|
+
resolution: "Migrate alert rules to the more specific v1.4.0 codes \u2014 they distinguish replay-attack signals from wrong-secret signals.",
|
|
4174
|
+
retryable: false
|
|
4175
|
+
},
|
|
4176
|
+
{
|
|
4177
|
+
code: "webhook_replay_window_exceeded",
|
|
4178
|
+
type: "authentication_error",
|
|
4179
|
+
description: "DEPRECATED in v1.4.0 \u2014 renamed to webhook_timestamp_outside_tolerance.",
|
|
4180
|
+
resolution: "Update alerts to webhook_timestamp_outside_tolerance.",
|
|
4181
|
+
retryable: false
|
|
4182
|
+
},
|
|
4183
|
+
// ----- Backend-emitted codes (v1.4.0 Phase 6.2 backfill) -----
|
|
4184
|
+
// Mirror of backend/src/api/v1-errors.ts ApiErrorCode. Same set
|
|
4185
|
+
// as the Web SDK ships — keep these synchronised so a developer
|
|
4186
|
+
// hitting any code via either SDK gets the same remediation.
|
|
4187
|
+
{
|
|
4188
|
+
code: "missing_api_key",
|
|
4189
|
+
type: "authentication_error",
|
|
4190
|
+
description: "No Authorization header (or Crossdeck-Api-Key header) on the request.",
|
|
4191
|
+
resolution: "Confirm the CrossdeckServer was constructed with a cd_sk_\u2026 secretKey. Re-check env vars in production deployments.",
|
|
4192
|
+
retryable: false
|
|
4193
|
+
},
|
|
4194
|
+
{
|
|
4195
|
+
code: "invalid_api_key",
|
|
4196
|
+
type: "authentication_error",
|
|
4197
|
+
description: "The secret key is malformed, unknown, or doesn't resolve to a project.",
|
|
4198
|
+
resolution: "Copy the key from Crossdeck dashboard \u2192 API keys. Server SDK requires cd_sk_test_ / cd_sk_live_ \u2014 client SDK keys (cd_pub_\u2026) won't work on the Node SDK.",
|
|
4199
|
+
retryable: false
|
|
4200
|
+
},
|
|
4201
|
+
{
|
|
4202
|
+
code: "key_revoked",
|
|
4203
|
+
type: "authentication_error",
|
|
4204
|
+
description: "The secret key was revoked in the dashboard.",
|
|
4205
|
+
resolution: "Mint a fresh key in dashboard \u2192 API keys \u2192 Create new. The revoked key cannot be reactivated.",
|
|
4206
|
+
retryable: false
|
|
4207
|
+
},
|
|
4208
|
+
{
|
|
4209
|
+
code: "env_mismatch",
|
|
4210
|
+
type: "permission_error",
|
|
4211
|
+
description: "The key's env prefix doesn't match the resolved app's configured env.",
|
|
4212
|
+
resolution: "Use a cd_sk_live_ key with a production app, cd_sk_test_ with a sandbox app. Crossing breaks the env lock.",
|
|
4213
|
+
retryable: false
|
|
4214
|
+
},
|
|
4215
|
+
{
|
|
4216
|
+
code: "idempotency_key_in_use",
|
|
4217
|
+
type: "invalid_request_error",
|
|
4218
|
+
description: "An Idempotency-Key was reused for a request with a different body (Stripe-grade contract).",
|
|
4219
|
+
resolution: "Server SDK derives keys deterministically from the body since v1.4.0; this should only fire if you passed options.idempotencyKey explicitly. Use a fresh key per logical operation.",
|
|
4220
|
+
retryable: false
|
|
4221
|
+
},
|
|
4222
|
+
{
|
|
4223
|
+
code: "rate_limited",
|
|
4224
|
+
type: "rate_limit_error",
|
|
4225
|
+
description: "Request rate exceeded the project's per-second cap.",
|
|
4226
|
+
resolution: "Honour Retry-After (managed retries do this automatically). For custom paths, throttle to <100 req/s/key.",
|
|
4227
|
+
retryable: true
|
|
4228
|
+
},
|
|
4229
|
+
{
|
|
4230
|
+
code: "internal_error",
|
|
4231
|
+
type: "internal_error",
|
|
4232
|
+
description: "Server-side issue. Safe to retry with backoff.",
|
|
4233
|
+
resolution: "Managed retries handle this automatically. If a code path surfaces it to your code, contact support with the requestId.",
|
|
4234
|
+
retryable: true
|
|
4235
|
+
},
|
|
4236
|
+
{
|
|
4237
|
+
code: "google_not_supported",
|
|
4238
|
+
type: "invalid_request_error",
|
|
4239
|
+
description: "POST /purchases/sync with rail=google is gated until the Play Developer API reconciliation worker ships.",
|
|
4240
|
+
resolution: "Until v1.5+, Google Play purchases verify via Real-time Developer Notifications. The Android SDK auto-track path handles this transparently.",
|
|
4241
|
+
retryable: false
|
|
4242
|
+
},
|
|
4243
|
+
{
|
|
4244
|
+
code: "stripe_not_supported",
|
|
4245
|
+
type: "invalid_request_error",
|
|
4246
|
+
description: "POST /purchases/sync with rail=stripe is unsupported \u2014 Stripe webhooks deliver evidence server-side.",
|
|
4247
|
+
resolution: "Wire Stripe via the standard Checkout / Customer Portal flow; Crossdeck reconciles via the platform webhook automatically.",
|
|
4248
|
+
retryable: false
|
|
4249
|
+
},
|
|
4250
|
+
{
|
|
4251
|
+
code: "missing_required_param",
|
|
4252
|
+
type: "invalid_request_error",
|
|
4253
|
+
description: "A required field is absent from the request body.",
|
|
4254
|
+
resolution: "The error.message identifies the missing field. Refer to the SDK's TypeScript types for canonical shapes.",
|
|
4255
|
+
retryable: false
|
|
4256
|
+
},
|
|
4257
|
+
{
|
|
4258
|
+
code: "invalid_param_value",
|
|
4259
|
+
type: "invalid_request_error",
|
|
4260
|
+
description: "A field is present but the value failed validation.",
|
|
4261
|
+
resolution: "Read error.message for the field + reason. SDK-managed call sites should never emit this \u2014 file a bug if you do.",
|
|
4262
|
+
retryable: false
|
|
3908
4263
|
}
|
|
3909
4264
|
]);
|
|
3910
4265
|
function isCrossdeckErrorCode(code) {
|
|
@@ -3918,6 +4273,7 @@ function getErrorCode(code) {
|
|
|
3918
4273
|
// src/webhooks.ts
|
|
3919
4274
|
import { createHmac, timingSafeEqual } from "crypto";
|
|
3920
4275
|
var DEFAULT_REPLAY_TOLERANCE_MS = 5 * 60 * 1e3;
|
|
4276
|
+
var MAX_REPLAY_TOLERANCE_MS = 24 * 60 * 60 * 1e3;
|
|
3921
4277
|
function verifyWebhookSignature(payload, signatureHeader, secret, options = {}) {
|
|
3922
4278
|
const secrets = normaliseSecrets(secret);
|
|
3923
4279
|
if (secrets.length === 0) {
|
|
@@ -3927,34 +4283,56 @@ function verifyWebhookSignature(payload, signatureHeader, secret, options = {})
|
|
|
3927
4283
|
message: "verifyWebhookSignature requires a non-empty secret. Read it from process.env.CROSSDECK_WEBHOOK_SECRET \u2014 never hardcode in source."
|
|
3928
4284
|
});
|
|
3929
4285
|
}
|
|
4286
|
+
const requestedTolerance = options.replayToleranceMs;
|
|
4287
|
+
let tolerance;
|
|
4288
|
+
if (requestedTolerance === void 0) {
|
|
4289
|
+
tolerance = DEFAULT_REPLAY_TOLERANCE_MS;
|
|
4290
|
+
} else if (typeof requestedTolerance !== "number" || !Number.isFinite(requestedTolerance)) {
|
|
4291
|
+
throw new CrossdeckError({
|
|
4292
|
+
type: "configuration_error",
|
|
4293
|
+
code: "webhook_invalid_tolerance",
|
|
4294
|
+
message: `replayToleranceMs must be a finite non-negative number \u2264 ${MAX_REPLAY_TOLERANCE_MS} (24h). Got: ${String(requestedTolerance)}. Pre-v1.4.0 accepted Infinity/NaN/null and silently disabled replay protection \u2014 v1.4.0 rejects loudly.`
|
|
4295
|
+
});
|
|
4296
|
+
} else if (requestedTolerance < 0) {
|
|
4297
|
+
throw new CrossdeckError({
|
|
4298
|
+
type: "configuration_error",
|
|
4299
|
+
code: "webhook_invalid_tolerance",
|
|
4300
|
+
message: `replayToleranceMs must be \u2265 0. Got ${requestedTolerance}.`
|
|
4301
|
+
});
|
|
4302
|
+
} else if (requestedTolerance > MAX_REPLAY_TOLERANCE_MS) {
|
|
4303
|
+
throw new CrossdeckError({
|
|
4304
|
+
type: "configuration_error",
|
|
4305
|
+
code: "webhook_invalid_tolerance",
|
|
4306
|
+
message: `replayToleranceMs must not exceed ${MAX_REPLAY_TOLERANCE_MS}ms (24h). Got ${requestedTolerance}ms \u2014 a window that wide defeats replay protection.`
|
|
4307
|
+
});
|
|
4308
|
+
} else {
|
|
4309
|
+
tolerance = requestedTolerance;
|
|
4310
|
+
}
|
|
3930
4311
|
const header = normaliseHeader(signatureHeader);
|
|
3931
4312
|
const parsed = parseSignatureHeader(header);
|
|
3932
4313
|
if (!parsed) {
|
|
3933
4314
|
throw new CrossdeckError({
|
|
3934
4315
|
type: "authentication_error",
|
|
3935
|
-
code: "
|
|
3936
|
-
message: "Webhook signature header is missing or
|
|
4316
|
+
code: "webhook_timestamp_missing",
|
|
4317
|
+
message: "Webhook signature header is missing, malformed, or has no `t=` timestamp segment. Expected 'Crossdeck-Signature: t=<unix>,v1=<hex>'."
|
|
3937
4318
|
});
|
|
3938
4319
|
}
|
|
3939
|
-
const
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
message: `Webhook timestamp is ${drift}ms outside the ${tolerance}ms replay-tolerance window. Either the request is replayed or the receiving clock is skewed \u2014 verify NTP on the host.`
|
|
3949
|
-
});
|
|
3950
|
-
}
|
|
4320
|
+
const now = (options.now ?? Date.now)();
|
|
4321
|
+
const timestampMs = parsed.timestampSec * 1e3;
|
|
4322
|
+
const drift = Math.abs(now - timestampMs);
|
|
4323
|
+
if (drift > tolerance) {
|
|
4324
|
+
throw new CrossdeckError({
|
|
4325
|
+
type: "authentication_error",
|
|
4326
|
+
code: "webhook_timestamp_outside_tolerance",
|
|
4327
|
+
message: `Webhook timestamp is ${drift}ms outside the ${tolerance}ms replay-tolerance window. Either the request is replayed or the receiving clock is skewed \u2014 verify NTP on the host.`
|
|
4328
|
+
});
|
|
3951
4329
|
}
|
|
3952
4330
|
const signedPayload = `${parsed.timestampSec}.${payload}`;
|
|
3953
4331
|
const expectedBuf = Buffer.from(parsed.signature, "hex");
|
|
3954
4332
|
if (expectedBuf.length === 0) {
|
|
3955
4333
|
throw new CrossdeckError({
|
|
3956
4334
|
type: "authentication_error",
|
|
3957
|
-
code: "
|
|
4335
|
+
code: "webhook_signature_mismatch",
|
|
3958
4336
|
message: "Webhook signature is not a valid hex string."
|
|
3959
4337
|
});
|
|
3960
4338
|
}
|
|
@@ -3965,8 +4343,8 @@ function verifyWebhookSignature(payload, signatureHeader, secret, options = {})
|
|
|
3965
4343
|
if (!anyMatch) {
|
|
3966
4344
|
throw new CrossdeckError({
|
|
3967
4345
|
type: "authentication_error",
|
|
3968
|
-
code: "
|
|
3969
|
-
message: "Webhook signature did not verify. Confirm the secret matches your Crossdeck dashboard \u2192 Webhooks page (and that you're not on a stale rotation)."
|
|
4346
|
+
code: "webhook_signature_mismatch",
|
|
4347
|
+
message: "Webhook signature did not verify against any configured secret. Confirm the secret matches your Crossdeck dashboard \u2192 Webhooks page (and that you're not on a stale rotation)."
|
|
3970
4348
|
});
|
|
3971
4349
|
}
|
|
3972
4350
|
try {
|
|
@@ -3974,7 +4352,7 @@ function verifyWebhookSignature(payload, signatureHeader, secret, options = {})
|
|
|
3974
4352
|
} catch {
|
|
3975
4353
|
throw new CrossdeckError({
|
|
3976
4354
|
type: "authentication_error",
|
|
3977
|
-
code: "
|
|
4355
|
+
code: "webhook_payload_not_json",
|
|
3978
4356
|
message: "Webhook signature verified but the payload is not valid JSON. Either the payload was tampered with after signing, or the webhook source is misconfigured."
|
|
3979
4357
|
});
|
|
3980
4358
|
}
|
|
@@ -4012,35 +4390,593 @@ function normaliseSecrets(input) {
|
|
|
4012
4390
|
return arr.filter((s) => typeof s === "string" && s.length > 0);
|
|
4013
4391
|
}
|
|
4014
4392
|
|
|
4015
|
-
// src/
|
|
4016
|
-
var
|
|
4017
|
-
var
|
|
4018
|
-
var
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4393
|
+
// src/_contracts-bundled.ts
|
|
4394
|
+
var BUNDLED_IN = "@cross-deck/node@1.5.1";
|
|
4395
|
+
var SDK_VERSION2 = "1.5.1";
|
|
4396
|
+
var BUNDLED_CONTRACTS = Object.freeze([
|
|
4397
|
+
{
|
|
4398
|
+
"id": "contract-failed-payload-schema-lock",
|
|
4399
|
+
"pillar": "diagnostics",
|
|
4400
|
+
"status": "enforced",
|
|
4401
|
+
"claim": "The `crossdeck.contract_failed` event payload contains ONLY the named diagnostic fields and never any end-user personal data. The wire shape is fixed \u2014 adding a new field requires (1) a pull request that updates this contract's `allowedFields` set, (2) a Privacy Policy \xA76 amendment, and (3) the Customer Disclosure Template / SDK Data Collection Reference \xA7B updates. Per-SDK assertion tests enforce the field set on every release. The `verification_phase` field is a categorical bucket \u2014 values are restricted to `boot` (the SDK self-test ran on Crossdeck.start) or `hot_path` (a verifier observed a real customer-triggered operation). The categorical nature is what preserves the diagnostic-only-not-personal classification. This is the structural guarantee that backs the independent-controller lawful basis in the Privacy Policy: the payload remains diagnostic-only, not personal, so the legitimate-interest analysis stays valid as the SDK evolves.",
|
|
4402
|
+
"appliesTo": [
|
|
4403
|
+
"web",
|
|
4404
|
+
"node",
|
|
4405
|
+
"swift",
|
|
4406
|
+
"android",
|
|
4407
|
+
"react-native"
|
|
4408
|
+
],
|
|
4409
|
+
"allowedFields": {
|
|
4410
|
+
"required": [
|
|
4411
|
+
"contract_id",
|
|
4412
|
+
"sdk_version",
|
|
4413
|
+
"sdk_platform",
|
|
4414
|
+
"failure_reason",
|
|
4415
|
+
"run_context",
|
|
4416
|
+
"run_id"
|
|
4417
|
+
],
|
|
4418
|
+
"optional": [
|
|
4419
|
+
"test_file",
|
|
4420
|
+
"test_name",
|
|
4421
|
+
"device_class",
|
|
4422
|
+
"verification_phase"
|
|
4423
|
+
],
|
|
4424
|
+
"forbidden": [
|
|
4425
|
+
"anonymousId",
|
|
4426
|
+
"developerUserId",
|
|
4427
|
+
"crossdeckCustomerId",
|
|
4428
|
+
"email",
|
|
4429
|
+
"ip",
|
|
4430
|
+
"user_agent",
|
|
4431
|
+
"message",
|
|
4432
|
+
"stack",
|
|
4433
|
+
"stack_trace",
|
|
4434
|
+
"frames",
|
|
4435
|
+
"exception_message",
|
|
4436
|
+
"url",
|
|
4437
|
+
"path",
|
|
4438
|
+
"screen",
|
|
4439
|
+
"title",
|
|
4440
|
+
"label",
|
|
4441
|
+
"text",
|
|
4442
|
+
"ariaLabel",
|
|
4443
|
+
"accessibilityLabel",
|
|
4444
|
+
"contentDescription",
|
|
4445
|
+
"session_id",
|
|
4446
|
+
"sessionId"
|
|
4447
|
+
]
|
|
4448
|
+
},
|
|
4449
|
+
"transport": "Telemetry is single-fire to the Crossdeck reliability endpoint only \u2014 NOT the customer's appId. The customer's track() pipeline never carries `crossdeck.*` events; the customer's dashboard never shows individual contract failures. Operational telemetry flows one-way to the Crossdeck operations team for SDK reliability purposes (legitimate interest, independent-controller flow per Privacy Policy \xA76). The reliability endpoint is hardcoded at SDK build time; the publishable key for the reliability project is embedded as a constant and rejects writes that don't match the schema.",
|
|
4450
|
+
"codeRef": [
|
|
4451
|
+
"sdks/web/src/crossdeck.ts",
|
|
4452
|
+
"sdks/node/src/crossdeck-server.ts",
|
|
4453
|
+
"sdks/swift/Sources/Crossdeck/Crossdeck.swift",
|
|
4454
|
+
"sdks/swift/Sources/Crossdeck/_DiagnosticTelemetry.swift",
|
|
4455
|
+
"sdks/android/crossdeck/src/main/kotlin/com/crossdeck/Crossdeck.kt",
|
|
4456
|
+
"sdks/android/crossdeck/src/main/kotlin/com/crossdeck/_DiagnosticTelemetry.kt",
|
|
4457
|
+
"sdks/react-native/src/crossdeck.ts",
|
|
4458
|
+
"backend/src/api/v1-sdk-diagnostic.ts",
|
|
4459
|
+
"sdks/web/src/_diagnostic-telemetry.ts",
|
|
4460
|
+
"sdks/node/src/_diagnostic-telemetry.ts",
|
|
4461
|
+
"sdks/react-native/src/_diagnostic-telemetry.ts"
|
|
4462
|
+
],
|
|
4463
|
+
"testRef": [
|
|
4464
|
+
{
|
|
4465
|
+
"file": "sdks/web/tests/contract-failed-schema-lock.test.ts",
|
|
4466
|
+
"name": "reportContractFailure payload conforms to schema-lock"
|
|
4467
|
+
},
|
|
4468
|
+
{
|
|
4469
|
+
"file": "sdks/node/tests/contract-failed-schema-lock.test.ts",
|
|
4470
|
+
"name": "reportContractFailure payload conforms to schema-lock"
|
|
4471
|
+
},
|
|
4472
|
+
{
|
|
4473
|
+
"file": "sdks/swift/Tests/CrossdeckTests/ContractFailedSchemaLockTests.swift",
|
|
4474
|
+
"name": "test_reportContractFailure_payloadFieldsAreInAllowList"
|
|
4475
|
+
},
|
|
4476
|
+
{
|
|
4477
|
+
"file": "sdks/swift/Tests/CrossdeckTests/ContractFailedSchemaLockTests.swift",
|
|
4478
|
+
"name": "test_reportContractFailure_doesNotEnterCustomerTrackPipeline"
|
|
4479
|
+
},
|
|
4480
|
+
{
|
|
4481
|
+
"file": "sdks/android/crossdeck/src/test/kotlin/com/crossdeck/ContractFailedSchemaLockTest.kt",
|
|
4482
|
+
"name": "reportContractFailure payload conforms to schema-lock"
|
|
4483
|
+
},
|
|
4484
|
+
{
|
|
4485
|
+
"file": "sdks/android/crossdeck/src/test/kotlin/com/crossdeck/ContractFailedSchemaLockTest.kt",
|
|
4486
|
+
"name": "reportContractFailure does not enter customer track pipeline"
|
|
4487
|
+
},
|
|
4488
|
+
{
|
|
4489
|
+
"file": "sdks/react-native/tests/contract-failed-schema-lock.test.ts",
|
|
4490
|
+
"name": "reportContractFailure payload conforms to schema-lock"
|
|
4491
|
+
},
|
|
4492
|
+
{
|
|
4493
|
+
"file": "backend/tests/unit/v1-sdk-diagnostic.test.ts",
|
|
4494
|
+
"name": "forbidden fields are enumerated in the schema-lock contract"
|
|
4495
|
+
},
|
|
4496
|
+
{
|
|
4497
|
+
"file": "backend/tests/unit/v1-sdk-diagnostic.test.ts",
|
|
4498
|
+
"name": "required fields are enumerated in the schema-lock contract"
|
|
4499
|
+
},
|
|
4500
|
+
{
|
|
4501
|
+
"file": "backend/tests/unit/v1-sdk-diagnostic.test.ts",
|
|
4502
|
+
"name": "regression guard: never returns a raw IP"
|
|
4503
|
+
},
|
|
4504
|
+
{
|
|
4505
|
+
"file": "backend/tests/unit/v1-sdk-diagnostic.test.ts",
|
|
4506
|
+
"name": "verification_phase is in the optional field set"
|
|
4507
|
+
}
|
|
4508
|
+
],
|
|
4509
|
+
"registeredAt": "2026-05-27",
|
|
4510
|
+
"firstRegisteredIn": "Diagnostic telemetry single-fire + schema-lock \u2014 independent-controller flow",
|
|
4511
|
+
"privacyReferences": [
|
|
4512
|
+
"legal/privacy/index.html#sdk-diagnostic",
|
|
4513
|
+
"legal/customer-disclosure/index.html#flow-b",
|
|
4514
|
+
"legal/security/index.html#diagnostic",
|
|
4515
|
+
"legal/sdk-data/index.html#b-diagnostic"
|
|
4516
|
+
],
|
|
4517
|
+
"bundledIn": "@cross-deck/node@1.5.1"
|
|
4518
|
+
},
|
|
4519
|
+
{
|
|
4520
|
+
"id": "documentation-honesty",
|
|
4521
|
+
"pillar": "webhooks",
|
|
4522
|
+
"status": "enforced",
|
|
4523
|
+
"claim": "Customer-facing documentation honestly tags outbound webhook delivery as ROADMAP (no signer, no worker, no scheduler in backend/src yet). The Node verifier helper exists today for fixture authoring + locking the validation contract surface BEFORE delivery ships \u2014 its jsdoc carries an explicit `[ROADMAP]` disclaimer so a developer reading the source doesn't assume Crossdeck sends webhooks today. The rail-webhooks doc no longer claims state surfaces 'through the dashboard, SDKs, and outbound webhooks' \u2014 outbound is gated to the explicit roadmap section.",
|
|
4524
|
+
"appliesTo": [
|
|
4525
|
+
"node",
|
|
4526
|
+
"backend"
|
|
4527
|
+
],
|
|
4528
|
+
"codeRef": [
|
|
4529
|
+
"sdks/node/src/webhooks.ts",
|
|
4530
|
+
"docs/rail-webhooks/index.html",
|
|
4531
|
+
"docs/webhooks-receive/index.html"
|
|
4532
|
+
],
|
|
4533
|
+
"testRef": [
|
|
4534
|
+
{
|
|
4535
|
+
"file": "sdks/node/src/webhooks.ts",
|
|
4536
|
+
"name": "[ROADMAP \u2014 v1.4.0 honesty note]"
|
|
4537
|
+
},
|
|
4538
|
+
{
|
|
4539
|
+
"file": "docs/rail-webhooks/index.html",
|
|
4540
|
+
"name": "Outbound push-to-your-backend webhooks are <strong>roadmap</strong>"
|
|
4541
|
+
},
|
|
4542
|
+
{
|
|
4543
|
+
"file": "docs/webhooks-receive/index.html",
|
|
4544
|
+
"name": "This feature is on the roadmap"
|
|
4545
|
+
}
|
|
4546
|
+
],
|
|
4547
|
+
"registeredAt": "2026-05-26",
|
|
4548
|
+
"firstRegisteredIn": "bank-grade reconciliation v1.4.0 \u2014 phase 7.1",
|
|
4549
|
+
"bundledIn": "@cross-deck/node@1.5.1"
|
|
4550
|
+
},
|
|
4551
|
+
{
|
|
4552
|
+
"id": "error-envelope-shape",
|
|
4553
|
+
"pillar": "errors",
|
|
4554
|
+
"status": "enforced",
|
|
4555
|
+
"claim": "Every v1 REST endpoint returns errors in a Stripe-shape envelope: `{ error: { type, code, message, request_id } }` where `type` is one of authentication_error / permission_error / invalid_request_error / rate_limit_error / internal_error (the wire vocabulary in backend/src/api/v1-errors.ts ApiErrorType). HTTP status parity: invalid_request_error \u2192 400, authentication_error \u2192 401, permission_error \u2192 403, rate_limit_error \u2192 429, internal_error \u2192 500. SDK-side clients parse this shape via `crossdeckErrorFromResponse` (Web/Node/RN) / `crossdeckErrorFrom(response:)` (Swift) / `crossdeckErrorFromResponse` (Android) and surface the request_id verbatim so support traces are end-to-end joinable. Firebase callable endpoints (managed-keys / dashboard auth) use the Firebase HttpsError envelope instead \u2014 this contract applies to REST /v1/* only.",
|
|
4556
|
+
"appliesTo": [
|
|
4557
|
+
"web",
|
|
4558
|
+
"node",
|
|
4559
|
+
"react-native",
|
|
4560
|
+
"swift",
|
|
4561
|
+
"android",
|
|
4562
|
+
"backend"
|
|
4563
|
+
],
|
|
4564
|
+
"codeRef": [
|
|
4565
|
+
"backend/src/api/v1-errors.ts",
|
|
4566
|
+
"sdks/web/src/errors.ts",
|
|
4567
|
+
"sdks/node/src/errors.ts",
|
|
4568
|
+
"sdks/react-native/src/errors.ts",
|
|
4569
|
+
"sdks/swift/Sources/Crossdeck/Errors.swift",
|
|
4570
|
+
"sdks/android/crossdeck/src/main/kotlin/com/crossdeck/Errors.kt"
|
|
4571
|
+
],
|
|
4572
|
+
"testRef": [
|
|
4573
|
+
{
|
|
4574
|
+
"file": "sdks/swift/Tests/CrossdeckTests/ErrorsTests.swift",
|
|
4575
|
+
"name": "test_errorEnvelope_fallsBackOnGarbageBody"
|
|
4576
|
+
},
|
|
4577
|
+
{
|
|
4578
|
+
"file": "sdks/swift/Tests/CrossdeckTests/ErrorsTests.swift",
|
|
4579
|
+
"name": "test_errorEnvelope_reads_XRequestId_fallback"
|
|
4580
|
+
},
|
|
4581
|
+
{
|
|
4582
|
+
"file": "sdks/android/crossdeck/src/test/kotlin/com/crossdeck/ErrorTypeWireVocabTest.kt",
|
|
4583
|
+
"name": "backend 500 response parses to INTERNAL_ERROR"
|
|
4584
|
+
}
|
|
4585
|
+
],
|
|
4586
|
+
"registeredAt": "2026-05-26",
|
|
4587
|
+
"firstRegisteredIn": "bank-grade reconciliation v1.4.0 \u2014 phase 8 (codifies existing contract)",
|
|
4588
|
+
"bundledIn": "@cross-deck/node@1.5.1"
|
|
4589
|
+
},
|
|
4590
|
+
{
|
|
4591
|
+
"id": "flush-interval-parity",
|
|
4592
|
+
"pillar": "analytics",
|
|
4593
|
+
"status": "enforced",
|
|
4594
|
+
"claim": "Every Crossdeck SDK defaults its event-queue flush interval to 2000ms \u2014 the Stripe-adjacent industry norm. Pre-v1.4.0 the defaults disagreed (Web/Node 1500ms; RN/Swift/Android 5000ms), so cross-platform funnels saw events landing at different cadences. Per-instance override stays \u2014 call sites can still tune it freely.",
|
|
4595
|
+
"appliesTo": [
|
|
4596
|
+
"web",
|
|
4597
|
+
"node",
|
|
4598
|
+
"react-native",
|
|
4599
|
+
"swift",
|
|
4600
|
+
"android"
|
|
4601
|
+
],
|
|
4602
|
+
"codeRef": [
|
|
4603
|
+
"sdks/web/src/crossdeck.ts",
|
|
4604
|
+
"sdks/node/src/crossdeck-server.ts",
|
|
4605
|
+
"sdks/react-native/src/crossdeck.ts",
|
|
4606
|
+
"sdks/swift/Sources/Crossdeck/EventQueue.swift",
|
|
4607
|
+
"sdks/android/crossdeck/src/main/kotlin/com/crossdeck/EventQueue.kt"
|
|
4608
|
+
],
|
|
4609
|
+
"testRef": [
|
|
4610
|
+
{
|
|
4611
|
+
"file": "sdks/swift/Sources/Crossdeck/EventQueue.swift",
|
|
4612
|
+
"name": "flushIntervalMs: Int = 2_000"
|
|
4613
|
+
},
|
|
4614
|
+
{
|
|
4615
|
+
"file": "sdks/android/crossdeck/src/main/kotlin/com/crossdeck/EventQueue.kt",
|
|
4616
|
+
"name": "flushIntervalMs: Long = 2_000L"
|
|
4617
|
+
},
|
|
4618
|
+
{
|
|
4619
|
+
"file": "sdks/web/src/crossdeck.ts",
|
|
4620
|
+
"name": "options.eventFlushIntervalMs ?? 2000"
|
|
4621
|
+
},
|
|
4622
|
+
{
|
|
4623
|
+
"file": "sdks/node/src/crossdeck-server.ts",
|
|
4624
|
+
"name": "options.eventFlushIntervalMs ?? 2000"
|
|
4625
|
+
},
|
|
4626
|
+
{
|
|
4627
|
+
"file": "sdks/react-native/src/crossdeck.ts",
|
|
4628
|
+
"name": "options.eventFlushIntervalMs ?? 2000"
|
|
4629
|
+
}
|
|
4630
|
+
],
|
|
4631
|
+
"registeredAt": "2026-05-26",
|
|
4632
|
+
"firstRegisteredIn": "bank-grade reconciliation v1.4.0 \u2014 phase 3.3",
|
|
4633
|
+
"bundledIn": "@cross-deck/node@1.5.1"
|
|
4634
|
+
},
|
|
4635
|
+
{
|
|
4636
|
+
"id": "idempotency-key-deterministic",
|
|
4637
|
+
"pillar": "revenue",
|
|
4638
|
+
"status": "enforced",
|
|
4639
|
+
"claim": "syncPurchases() on every SDK derives a deterministic Idempotency-Key from the request body (UUID-shaped SHA-256 of `crossdeck:purchases/sync:<rail>:<jws|token>`). Same input -> same key. Backend short-circuits same-key-same-body retries by returning the cached response (status + body) with `idempotent_replay: true` flag in the body AND `Idempotent-Replayed: true` response header. Same-key-different-body returns 400 `idempotency_key_in_use`. 24-hour TTL matches Stripe. Cache only stores 2xx responses \u2014 4xx/5xx pass through so callers can fix bugs and retry. Helper returns nil/throws on missing identifier (no silent random fallback). Cross-SDK parity is CI-pinned: deriveForPurchase('apple', 'eyJ.jws.sig') MUST equal 'a66b1640-efaf-bb4d-1261-6650033bf111' on every SDK.",
|
|
4640
|
+
"appliesTo": [
|
|
4641
|
+
"web",
|
|
4642
|
+
"node",
|
|
4643
|
+
"react-native",
|
|
4644
|
+
"swift",
|
|
4645
|
+
"android",
|
|
4646
|
+
"backend"
|
|
4647
|
+
],
|
|
4648
|
+
"codeRef": [
|
|
4649
|
+
"sdks/web/src/idempotency-key.ts",
|
|
4650
|
+
"sdks/web/src/crossdeck.ts",
|
|
4651
|
+
"sdks/react-native/src/idempotency-key.ts",
|
|
4652
|
+
"sdks/react-native/src/crossdeck.ts",
|
|
4653
|
+
"sdks/node/src/idempotency-key.ts",
|
|
4654
|
+
"sdks/node/src/crossdeck-server.ts",
|
|
4655
|
+
"sdks/swift/Sources/Crossdeck/IdempotencyKey.swift",
|
|
4656
|
+
"sdks/swift/Sources/Crossdeck/Crossdeck.swift",
|
|
4657
|
+
"sdks/android/crossdeck/src/main/kotlin/com/crossdeck/IdempotencyKey.kt",
|
|
4658
|
+
"sdks/android/crossdeck/src/main/kotlin/com/crossdeck/Crossdeck.kt",
|
|
4659
|
+
"backend/src/lib/idempotency-response-cache.ts",
|
|
4660
|
+
"backend/src/api/v1-purchases.ts"
|
|
4661
|
+
],
|
|
4662
|
+
"testRef": [
|
|
4663
|
+
{
|
|
4664
|
+
"file": "sdks/web/tests/idempotency-key.test.ts",
|
|
4665
|
+
"name": "cross-SDK oracle \u2014 apple JWS pins canonical vector"
|
|
4666
|
+
},
|
|
4667
|
+
{
|
|
4668
|
+
"file": "sdks/web/tests/idempotency-key.test.ts",
|
|
4669
|
+
"name": "is deterministic: same body twice -> identical key"
|
|
4670
|
+
},
|
|
4671
|
+
{
|
|
4672
|
+
"file": "sdks/web/tests/idempotency-key.test.ts",
|
|
4673
|
+
"name": "same identifier under different rails -> different keys"
|
|
4674
|
+
},
|
|
4675
|
+
{
|
|
4676
|
+
"file": "sdks/web/tests/idempotency-key.test.ts",
|
|
4677
|
+
"name": "never silently falls back to a random key on missing identifier"
|
|
4678
|
+
},
|
|
4679
|
+
{
|
|
4680
|
+
"file": "sdks/react-native/tests/idempotency-key.test.ts",
|
|
4681
|
+
"name": "is deterministic"
|
|
4682
|
+
},
|
|
4683
|
+
{
|
|
4684
|
+
"file": "sdks/react-native/tests/idempotency-key.test.ts",
|
|
4685
|
+
"name": "cross-SDK oracle \u2014 apple JWS pins canonical vector"
|
|
4686
|
+
},
|
|
4687
|
+
{
|
|
4688
|
+
"file": "sdks/node/tests/idempotency-key.test.ts",
|
|
4689
|
+
"name": "is deterministic"
|
|
4690
|
+
},
|
|
4691
|
+
{
|
|
4692
|
+
"file": "sdks/node/tests/idempotency-key.test.ts",
|
|
4693
|
+
"name": "rail namespacing prevents cross-rail collisions"
|
|
4694
|
+
},
|
|
4695
|
+
{
|
|
4696
|
+
"file": "sdks/node/tests/idempotency-key.test.ts",
|
|
4697
|
+
"name": "apple JWS produces the canonical pinned UUID across all 5 SDKs"
|
|
4698
|
+
},
|
|
4699
|
+
{
|
|
4700
|
+
"file": "backend/tests/unit/idempotency-response-cache.test.ts",
|
|
4701
|
+
"name": "is deterministic for the same input"
|
|
4702
|
+
},
|
|
4703
|
+
{
|
|
4704
|
+
"file": "backend/tests/unit/idempotency-response-cache.test.ts",
|
|
4705
|
+
"name": "injects idempotent_replay: true into a JSON object body"
|
|
4706
|
+
},
|
|
4707
|
+
{
|
|
4708
|
+
"file": "backend/tests/unit/idempotency-response-cache.test.ts",
|
|
4709
|
+
"name": "matches Stripe's 24-hour idempotency window"
|
|
4710
|
+
},
|
|
4711
|
+
{
|
|
4712
|
+
"file": "sdks/swift/Tests/CrossdeckTests/IdempotencyKeyTests.swift",
|
|
4713
|
+
"name": "test_crossSdkOracle_appleJWS"
|
|
4714
|
+
},
|
|
4715
|
+
{
|
|
4716
|
+
"file": "sdks/swift/Tests/CrossdeckTests/IdempotencyKeyTests.swift",
|
|
4717
|
+
"name": "test_railNamespacing_preventsCrossRailCollisions"
|
|
4718
|
+
},
|
|
4719
|
+
{
|
|
4720
|
+
"file": "sdks/swift/Tests/CrossdeckTests/IdempotencyKeyTests.swift",
|
|
4721
|
+
"name": "test_missingIdentifier_returnsNil"
|
|
4722
|
+
},
|
|
4723
|
+
{
|
|
4724
|
+
"file": "sdks/android/crossdeck/src/test/kotlin/com/crossdeck/IdempotencyKeyTest.kt",
|
|
4725
|
+
"name": "cross-SDK oracle for apple JWS"
|
|
4726
|
+
},
|
|
4727
|
+
{
|
|
4728
|
+
"file": "sdks/android/crossdeck/src/test/kotlin/com/crossdeck/IdempotencyKeyTest.kt",
|
|
4729
|
+
"name": "rail namespacing prevents cross-rail collisions"
|
|
4730
|
+
},
|
|
4731
|
+
{
|
|
4732
|
+
"file": "sdks/android/crossdeck/src/test/kotlin/com/crossdeck/IdempotencyKeyTest.kt",
|
|
4733
|
+
"name": "missing identifier returns null - never silent random fallback"
|
|
4734
|
+
}
|
|
4735
|
+
],
|
|
4736
|
+
"registeredAt": "2026-05-26",
|
|
4737
|
+
"firstRegisteredIn": "bank-grade reconciliation v1.4.0 \u2014 phase 2.2.a + 2.2.b + 2.2.c",
|
|
4738
|
+
"bundledIn": "@cross-deck/node@1.5.1"
|
|
4739
|
+
},
|
|
4740
|
+
{
|
|
4741
|
+
"id": "node-pii-scrubber",
|
|
4742
|
+
"pillar": "analytics",
|
|
4743
|
+
"status": "enforced",
|
|
4744
|
+
"claim": "Node SDK's track() applies scrubPiiFromProperties on the enqueue path \u2014 parity with Web/RN/Swift. Pre-v1.4.0 the Node SDK was the ONLY one that skipped this, shipping every track() payload UNREDACTED despite the README promising parity. CrossdeckServerOptions.scrubPii defaults to true; explicit false opts out for regulator-required audit trails with a documented blast-radius warning.",
|
|
4745
|
+
"appliesTo": [
|
|
4746
|
+
"node"
|
|
4747
|
+
],
|
|
4748
|
+
"codeRef": [
|
|
4749
|
+
"sdks/node/src/crossdeck-server.ts",
|
|
4750
|
+
"sdks/node/src/types.ts",
|
|
4751
|
+
"sdks/node/src/consent.ts"
|
|
4752
|
+
],
|
|
4753
|
+
"testRef": [
|
|
4754
|
+
{
|
|
4755
|
+
"file": "sdks/node/tests/track-pii-scrub.test.ts",
|
|
4756
|
+
"name": "by default redacts email-shaped values to <email>"
|
|
4757
|
+
},
|
|
4758
|
+
{
|
|
4759
|
+
"file": "sdks/node/tests/track-pii-scrub.test.ts",
|
|
4760
|
+
"name": "redacts card-number-shaped values to <card>"
|
|
4761
|
+
},
|
|
4762
|
+
{
|
|
4763
|
+
"file": "sdks/node/tests/track-pii-scrub.test.ts",
|
|
4764
|
+
"name": "walks nested maps + arrays"
|
|
4765
|
+
},
|
|
4766
|
+
{
|
|
4767
|
+
"file": "sdks/node/tests/track-pii-scrub.test.ts",
|
|
4768
|
+
"name": "scrubPii: false preserves the raw payload (opt-out)"
|
|
4769
|
+
},
|
|
4770
|
+
{
|
|
4771
|
+
"file": "sdks/node/tests/track-pii-scrub.test.ts",
|
|
4772
|
+
"name": "scrubPii: true is the default when option is omitted"
|
|
4773
|
+
}
|
|
4774
|
+
],
|
|
4775
|
+
"registeredAt": "2026-05-26",
|
|
4776
|
+
"firstRegisteredIn": "bank-grade reconciliation v1.4.0 \u2014 phase 3.1",
|
|
4777
|
+
"bundledIn": "@cross-deck/node@1.5.1"
|
|
4778
|
+
},
|
|
4779
|
+
{
|
|
4780
|
+
"id": "node-shutdown-awaits-flush",
|
|
4781
|
+
"pillar": "lifecycle",
|
|
4782
|
+
"status": "enforced",
|
|
4783
|
+
"claim": "Node SDK's async shutdown() awaits the internal flush() before tearing down the queue. A queue with pending events at sync-shutdown time (shutdownSync() or [Symbol.dispose]) logs a console.warn with the dropped-event count \u2014 silent loss is incompatible with the bank-grade contract. [Symbol.asyncDispose] is equivalent to await server.shutdown().",
|
|
4784
|
+
"appliesTo": [
|
|
4785
|
+
"node"
|
|
4786
|
+
],
|
|
4787
|
+
"codeRef": [
|
|
4788
|
+
"sdks/node/src/crossdeck-server.ts"
|
|
4789
|
+
],
|
|
4790
|
+
"testRef": [
|
|
4791
|
+
{
|
|
4792
|
+
"file": "sdks/node/tests/shutdown-flush.test.ts",
|
|
4793
|
+
"name": "async shutdown() flushes queued events before clearing"
|
|
4794
|
+
},
|
|
4795
|
+
{
|
|
4796
|
+
"file": "sdks/node/tests/shutdown-flush.test.ts",
|
|
4797
|
+
"name": "async shutdown() proceeds with teardown even if flush fails"
|
|
4798
|
+
},
|
|
4799
|
+
{
|
|
4800
|
+
"file": "sdks/node/tests/shutdown-flush.test.ts",
|
|
4801
|
+
"name": "sync shutdownSync() warns when the buffer has events at teardown"
|
|
4802
|
+
},
|
|
4803
|
+
{
|
|
4804
|
+
"file": "sdks/node/tests/shutdown-flush.test.ts",
|
|
4805
|
+
"name": "[Symbol.asyncDispose] equals await server.shutdown()"
|
|
4806
|
+
}
|
|
4807
|
+
],
|
|
4808
|
+
"registeredAt": "2026-05-26",
|
|
4809
|
+
"firstRegisteredIn": "bank-grade reconciliation v1.4.0 \u2014 phase 5.4",
|
|
4810
|
+
"bundledIn": "@cross-deck/node@1.5.1"
|
|
4811
|
+
},
|
|
4812
|
+
{
|
|
4813
|
+
"id": "sdk-error-codes-catalogue",
|
|
4814
|
+
"pillar": "errors",
|
|
4815
|
+
"status": "enforced",
|
|
4816
|
+
"claim": "Web + Node SDK error-codes catalogues include EVERY backend-emitted ApiErrorCode with a description + resolution. Pre-v1.4.0 the catalogues documented codes the SDK threw ITSELF but ZERO backend codes \u2014 a developer hitting `invalid_api_key` / `origin_not_allowed` / `bundle_id_not_allowed` / `env_mismatch` / `idempotency_key_in_use` etc. got `undefined` from getErrorCode() and had to hunt for guidance. v1.4.0 backfills the catalogue from backend/src/api/v1-errors.ts so every wire code has a canonical 'what does this mean / what should I do' answer Stripe-style.",
|
|
4817
|
+
"appliesTo": [
|
|
4818
|
+
"web",
|
|
4819
|
+
"node"
|
|
4820
|
+
],
|
|
4821
|
+
"codeRef": [
|
|
4822
|
+
"sdks/web/src/error-codes.ts",
|
|
4823
|
+
"sdks/node/src/error-codes.ts",
|
|
4824
|
+
"backend/src/api/v1-errors.ts"
|
|
4825
|
+
],
|
|
4826
|
+
"testRef": [
|
|
4827
|
+
{
|
|
4828
|
+
"file": "sdks/web/tests/error-codes-backfill.test.ts",
|
|
4829
|
+
"name": "includes backend code"
|
|
4830
|
+
},
|
|
4831
|
+
{
|
|
4832
|
+
"file": "sdks/web/tests/error-codes-backfill.test.ts",
|
|
4833
|
+
"name": "invalid_api_key resolution points at the dashboard"
|
|
4834
|
+
},
|
|
4835
|
+
{
|
|
4836
|
+
"file": "sdks/web/tests/error-codes-backfill.test.ts",
|
|
4837
|
+
"name": "idempotency_key_in_use resolution mentions Stripe-grade contract"
|
|
4838
|
+
},
|
|
4839
|
+
{
|
|
4840
|
+
"file": "sdks/web/tests/error-codes-backfill.test.ts",
|
|
4841
|
+
"name": "identity-lock codes carry permission_error type"
|
|
4842
|
+
},
|
|
4843
|
+
{
|
|
4844
|
+
"file": "sdks/web/tests/error-codes-backfill.test.ts",
|
|
4845
|
+
"name": "no entry has an empty description or resolution"
|
|
4846
|
+
}
|
|
4847
|
+
],
|
|
4848
|
+
"registeredAt": "2026-05-26",
|
|
4849
|
+
"firstRegisteredIn": "bank-grade reconciliation v1.4.0 \u2014 phase 6.2",
|
|
4850
|
+
"bundledIn": "@cross-deck/node@1.5.1"
|
|
4851
|
+
},
|
|
4852
|
+
{
|
|
4853
|
+
"id": "sync-purchases-funnel-parity",
|
|
4854
|
+
"pillar": "analytics",
|
|
4855
|
+
"status": "enforced",
|
|
4856
|
+
"claim": "Manual syncPurchases() emits a `purchase.completed` analytics event on success across ALL SDKs (Web / Node / RN / Swift / Android). Pre-v1.4.0 only Swift/Android auto-track emitted it \u2014 Web/Node/RN manual calls + Swift/Android manual calls fired ZERO analytics. Schema mirrors the auto-track event name + rail/productId/subscriptionId so cross-platform funnels reconcile on every payment path. When the backend short-circuits via the v1.4.0 idempotency cache, the event also carries `idempotent_replay: true`.",
|
|
4857
|
+
"appliesTo": [
|
|
4858
|
+
"web",
|
|
4859
|
+
"node",
|
|
4860
|
+
"react-native",
|
|
4861
|
+
"swift",
|
|
4862
|
+
"android"
|
|
4863
|
+
],
|
|
4864
|
+
"codeRef": [
|
|
4865
|
+
"sdks/web/src/crossdeck.ts",
|
|
4866
|
+
"sdks/node/src/crossdeck-server.ts",
|
|
4867
|
+
"sdks/react-native/src/crossdeck.ts",
|
|
4868
|
+
"sdks/swift/Sources/Crossdeck/Crossdeck.swift",
|
|
4869
|
+
"sdks/android/crossdeck/src/main/kotlin/com/crossdeck/Crossdeck.kt"
|
|
4870
|
+
],
|
|
4871
|
+
"testRef": [
|
|
4872
|
+
{
|
|
4873
|
+
"file": "sdks/web/tests/sync-purchases-funnel.test.ts",
|
|
4874
|
+
"name": "emits purchase.completed after a successful sync"
|
|
4875
|
+
},
|
|
4876
|
+
{
|
|
4877
|
+
"file": "sdks/web/tests/sync-purchases-funnel.test.ts",
|
|
4878
|
+
"name": "carries idempotent_replay=true when backend replied from cache"
|
|
4879
|
+
}
|
|
4880
|
+
],
|
|
4881
|
+
"registeredAt": "2026-05-26",
|
|
4882
|
+
"firstRegisteredIn": "bank-grade reconciliation v1.4.0 \u2014 phase 3.5",
|
|
4883
|
+
"bundledIn": "@cross-deck/node@1.5.1"
|
|
4884
|
+
},
|
|
4885
|
+
{
|
|
4886
|
+
"id": "verifier-timestamp-mandatory",
|
|
4887
|
+
"pillar": "webhooks",
|
|
4888
|
+
"status": "enforced",
|
|
4889
|
+
"claim": "Node verifyWebhookSignature() enforces a MANDATORY timestamp window. Pre-v1.4.0 the helper silently disabled replay protection on tolerance=0 (`if (tolerance > 0)` skipped the check) and on Infinity/NaN/null (`Math.abs(...) > Infinity = false`). v1.4.0 rejects non-finite / negative / above-24h-cap tolerances at the boundary with typed `webhook_invalid_tolerance` and always runs the drift check. Verification failures are surfaced via distinguishable codes: `webhook_signature_mismatch` (wrong-secret signal), `webhook_timestamp_outside_tolerance` (replay-attack signal \u2014 alert separately), `webhook_timestamp_missing` (header absent/malformed), `webhook_payload_not_json` (tampered post-signing), `webhook_missing_secret`, `webhook_invalid_tolerance` \u2014 replaces the pre-1.4.0 single `webhook_invalid_signature` catch-all.",
|
|
4890
|
+
"appliesTo": [
|
|
4891
|
+
"node"
|
|
4892
|
+
],
|
|
4893
|
+
"codeRef": [
|
|
4894
|
+
"sdks/node/src/webhooks.ts",
|
|
4895
|
+
"sdks/node/src/error-codes.ts"
|
|
4896
|
+
],
|
|
4897
|
+
"testRef": [
|
|
4898
|
+
{
|
|
4899
|
+
"file": "sdks/node/tests/webhooks.test.ts",
|
|
4900
|
+
"name": "tolerance of 0 still enforces the replay window (v1.4.0 \u2014 cannot disable)"
|
|
4901
|
+
},
|
|
4902
|
+
{
|
|
4903
|
+
"file": "sdks/node/tests/webhooks.test.ts",
|
|
4904
|
+
"name": "rejects Infinity tolerance (would silently disable replay protection)"
|
|
4905
|
+
},
|
|
4906
|
+
{
|
|
4907
|
+
"file": "sdks/node/tests/webhooks.test.ts",
|
|
4908
|
+
"name": "rejects NaN tolerance"
|
|
4909
|
+
},
|
|
4910
|
+
{
|
|
4911
|
+
"file": "sdks/node/tests/webhooks.test.ts",
|
|
4912
|
+
"name": "rejects negative tolerance"
|
|
4913
|
+
},
|
|
4914
|
+
{
|
|
4915
|
+
"file": "sdks/node/tests/webhooks.test.ts",
|
|
4916
|
+
"name": "rejects tolerance above the 24h cap"
|
|
4917
|
+
},
|
|
4918
|
+
{
|
|
4919
|
+
"file": "sdks/node/tests/webhooks.test.ts",
|
|
4920
|
+
"name": "rejects non-number tolerance (null / string)"
|
|
4921
|
+
},
|
|
4922
|
+
{
|
|
4923
|
+
"file": "sdks/node/tests/webhooks.test.ts",
|
|
4924
|
+
"name": "accepts tolerance exactly at the 24h cap"
|
|
4925
|
+
},
|
|
4926
|
+
{
|
|
4927
|
+
"file": "sdks/node/tests/webhooks.test.ts",
|
|
4928
|
+
"name": "malformed header (no t= or no v1=) throws webhook_timestamp_missing"
|
|
4929
|
+
},
|
|
4930
|
+
{
|
|
4931
|
+
"file": "sdks/node/tests/webhooks.test.ts",
|
|
4932
|
+
"name": "valid signature but non-JSON payload throws webhook_payload_not_json"
|
|
4933
|
+
}
|
|
4934
|
+
],
|
|
4935
|
+
"registeredAt": "2026-05-26",
|
|
4936
|
+
"firstRegisteredIn": "bank-grade reconciliation v1.4.0 \u2014 phase 7.2",
|
|
4937
|
+
"bundledIn": "@cross-deck/node@1.5.1"
|
|
4028
4938
|
}
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4939
|
+
]);
|
|
4940
|
+
|
|
4941
|
+
// src/contracts.ts
|
|
4942
|
+
var CrossdeckContracts = {
|
|
4943
|
+
all() {
|
|
4944
|
+
return BUNDLED_CONTRACTS.filter((c) => c.status === "enforced");
|
|
4945
|
+
},
|
|
4946
|
+
allIncludingHistorical() {
|
|
4947
|
+
return BUNDLED_CONTRACTS;
|
|
4948
|
+
},
|
|
4949
|
+
byId(id) {
|
|
4950
|
+
return BUNDLED_CONTRACTS.find((c) => c.id === id);
|
|
4951
|
+
},
|
|
4952
|
+
byPillar(pillar) {
|
|
4953
|
+
return BUNDLED_CONTRACTS.filter(
|
|
4954
|
+
(c) => c.pillar === pillar && c.status === "enforced"
|
|
4955
|
+
);
|
|
4956
|
+
},
|
|
4957
|
+
withStatus(status) {
|
|
4958
|
+
return BUNDLED_CONTRACTS.filter((c) => c.status === status);
|
|
4959
|
+
},
|
|
4960
|
+
sdkVersion: SDK_VERSION2,
|
|
4961
|
+
bundledIn: BUNDLED_IN,
|
|
4962
|
+
/**
|
|
4963
|
+
* Resolve a failing test back to the contract it exercises.
|
|
4964
|
+
* Used by test-framework hooks to find the contract id of a
|
|
4965
|
+
* failed contract test so `reportContractFailure(...)` can stamp
|
|
4966
|
+
* the right `contract_id` on the emitted event.
|
|
4967
|
+
*/
|
|
4968
|
+
findByTestName(name) {
|
|
4969
|
+
return BUNDLED_CONTRACTS.find(
|
|
4970
|
+
(c) => c.testRef.some((ref) => ref.name === name)
|
|
4971
|
+
);
|
|
4036
4972
|
}
|
|
4037
|
-
|
|
4038
|
-
}
|
|
4973
|
+
};
|
|
4039
4974
|
export {
|
|
4040
4975
|
CROSSDECK_API_VERSION,
|
|
4041
4976
|
CROSSDECK_ERROR_CODES,
|
|
4042
4977
|
CrossdeckAuthenticationError,
|
|
4043
4978
|
CrossdeckConfigurationError,
|
|
4979
|
+
CrossdeckContracts,
|
|
4044
4980
|
CrossdeckError,
|
|
4045
4981
|
CrossdeckInternalError,
|
|
4046
4982
|
CrossdeckNetworkError,
|