@relai-team/access-sdk 0.18.0 → 0.18.2
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.cjs +23 -2
- package/dist/index.d.cts +50 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.js +23 -2
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -239,6 +239,7 @@ var HttpClient = class {
|
|
|
239
239
|
if (bearer) h["authorization"] = `Bearer ${bearer}`;
|
|
240
240
|
}
|
|
241
241
|
if (idem) h["idempotency-key"] = idem;
|
|
242
|
+
if (this.cfg.analytics === false) h["x-relai-analytics"] = "off";
|
|
242
243
|
return h;
|
|
243
244
|
}
|
|
244
245
|
async parseJson(res) {
|
|
@@ -478,6 +479,22 @@ var OrdersModule = class {
|
|
|
478
479
|
if (input.metadata !== void 0) body["metadata"] = input.metadata;
|
|
479
480
|
return this.http.request({ method: "POST", path: "/orders", body });
|
|
480
481
|
}
|
|
482
|
+
/**
|
|
483
|
+
* Fetch one order.
|
|
484
|
+
*
|
|
485
|
+
* WHO MAY READ IT, because this is the call most likely to surprise you:
|
|
486
|
+
*
|
|
487
|
+
* - A SECRET key reads any order of the app. Server-to-server.
|
|
488
|
+
* - A PUBLISHABLE key needs a signed-in end user, who must be the order's
|
|
489
|
+
* initiator or its recipient. A publishable key ships inside your app
|
|
490
|
+
* binary, so it proves nothing about who is asking.
|
|
491
|
+
* - A GUEST session reads only its own orders that have no recipient. Guest
|
|
492
|
+
* mode is one shared identity per app, so a guest order with no recipient
|
|
493
|
+
* names nobody, while a directed one names a real person.
|
|
494
|
+
*
|
|
495
|
+
* Every refusal is `not_found`, identical to an id that does not exist, so
|
|
496
|
+
* you cannot tell the two apart and should not try.
|
|
497
|
+
*/
|
|
481
498
|
get(orderId) {
|
|
482
499
|
return this.http.request({ path: `/orders/${orderId}` });
|
|
483
500
|
}
|
|
@@ -772,7 +789,10 @@ async function deliverOpen(deps, open, opts) {
|
|
|
772
789
|
action: ack.accepted ? "unlock_used" : "unlock_failed",
|
|
773
790
|
result: ack.accepted ? "success" : "failure",
|
|
774
791
|
transport: "ble",
|
|
775
|
-
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
792
|
+
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
793
|
+
// The Parent's own reject reason, so a failure is diagnosable
|
|
794
|
+
// rather than merely counted.
|
|
795
|
+
...ack.accepted ? {} : { reason: ack.rejectReason ?? "UNKNOWN" }
|
|
776
796
|
}
|
|
777
797
|
]
|
|
778
798
|
}).catch(() => void 0);
|
|
@@ -808,7 +828,8 @@ var RelaiClient = class {
|
|
|
808
828
|
...options.publishableKey !== void 0 ? { publishableKey: options.publishableKey } : {},
|
|
809
829
|
...options.secretKey !== void 0 ? { secretKey: options.secretKey } : {},
|
|
810
830
|
...options.fetchImpl !== void 0 ? { fetchImpl: options.fetchImpl } : {},
|
|
811
|
-
...options.maxRetries !== void 0 ? { maxRetries: options.maxRetries } : {}
|
|
831
|
+
...options.maxRetries !== void 0 ? { maxRetries: options.maxRetries } : {},
|
|
832
|
+
...options.analytics !== void 0 ? { analytics: options.analytics } : {}
|
|
812
833
|
};
|
|
813
834
|
this.http = new HttpClient(httpConfig);
|
|
814
835
|
auth = new AuthModule(this.http, storage);
|
package/dist/index.d.cts
CHANGED
|
@@ -12,6 +12,8 @@ interface HttpConfig {
|
|
|
12
12
|
* client drops it so `auth.isSignedIn` goes false.
|
|
13
13
|
*/
|
|
14
14
|
onTokenInvalid?: () => void;
|
|
15
|
+
/** False opts the app out of product analytics; telemetry is unaffected. */
|
|
16
|
+
analytics?: boolean | undefined;
|
|
15
17
|
fetchImpl?: typeof fetch;
|
|
16
18
|
maxRetries?: number;
|
|
17
19
|
}
|
|
@@ -341,6 +343,26 @@ interface TelemetryEvent {
|
|
|
341
343
|
result: "success" | "failure";
|
|
342
344
|
transport?: "ble" | "simulated";
|
|
343
345
|
at: string;
|
|
346
|
+
/**
|
|
347
|
+
* WHY it failed, on a failure (owner, 2026-08-11).
|
|
348
|
+
*
|
|
349
|
+
* Without this an open that did not work is a number and nothing else: the
|
|
350
|
+
* platform could say how often opens fail and never why. It is the Parent's
|
|
351
|
+
* `[AUTH] REJECT` reason (`TAG`, `NONCE`, `NOTREADY`, …), an API error code,
|
|
352
|
+
* or a transport reason like `timeout` / `not_connected`.
|
|
353
|
+
*
|
|
354
|
+
* A bounded vocabulary matters more than richness here, because this is
|
|
355
|
+
* grouped and counted, not read. Never put a raw error message in it.
|
|
356
|
+
*/
|
|
357
|
+
reason?: string;
|
|
358
|
+
/**
|
|
359
|
+
* 1 for the first try, 2 for the first retry, and so on.
|
|
360
|
+
*
|
|
361
|
+
* `NOTREADY` is retryable (firmware 1.1.0), so without this a recovered open
|
|
362
|
+
* looks identical to one that worked first time and the retry can never be
|
|
363
|
+
* shown to be worth having.
|
|
364
|
+
*/
|
|
365
|
+
attempt?: number;
|
|
344
366
|
}
|
|
345
367
|
/** One page of orders, newest first. `next_cursor` is null on the last page. */
|
|
346
368
|
interface OrderPage {
|
|
@@ -649,6 +671,22 @@ declare class OrdersModule {
|
|
|
649
671
|
promotionCode?: string;
|
|
650
672
|
metadata?: Record<string, string>;
|
|
651
673
|
}): Promise<Order>;
|
|
674
|
+
/**
|
|
675
|
+
* Fetch one order.
|
|
676
|
+
*
|
|
677
|
+
* WHO MAY READ IT, because this is the call most likely to surprise you:
|
|
678
|
+
*
|
|
679
|
+
* - A SECRET key reads any order of the app. Server-to-server.
|
|
680
|
+
* - A PUBLISHABLE key needs a signed-in end user, who must be the order's
|
|
681
|
+
* initiator or its recipient. A publishable key ships inside your app
|
|
682
|
+
* binary, so it proves nothing about who is asking.
|
|
683
|
+
* - A GUEST session reads only its own orders that have no recipient. Guest
|
|
684
|
+
* mode is one shared identity per app, so a guest order with no recipient
|
|
685
|
+
* names nobody, while a directed one names a real person.
|
|
686
|
+
*
|
|
687
|
+
* Every refusal is `not_found`, identical to an id that does not exist, so
|
|
688
|
+
* you cannot tell the two apart and should not try.
|
|
689
|
+
*/
|
|
652
690
|
get(orderId: string): Promise<Order>;
|
|
653
691
|
/**
|
|
654
692
|
* Request an open: one token + an unlock grant. On authenticated towers the
|
|
@@ -1099,6 +1137,18 @@ interface RelaiClientOptions {
|
|
|
1099
1137
|
* new RelaiClient({ publishableKey, stripe: Stripe });
|
|
1100
1138
|
*/
|
|
1101
1139
|
stripe?: StripeSdk;
|
|
1140
|
+
/**
|
|
1141
|
+
* Send `false` to opt this app out of Relai's PRODUCT ANALYTICS
|
|
1142
|
+
* (owner, 2026-08-11).
|
|
1143
|
+
*
|
|
1144
|
+
* Operational telemetry is unaffected and is not optional: Relai needs it to
|
|
1145
|
+
* reconcile orders and bill correctly, and an open that is never reported is
|
|
1146
|
+
* an order that never completes. What this turns off is the forwarding of a
|
|
1147
|
+
* curated subset to Relai's analytics tooling. Stated here rather than buried,
|
|
1148
|
+
* because "analytics" and "the thing that makes your orders work" being the
|
|
1149
|
+
* same switch would be a nasty surprise.
|
|
1150
|
+
*/
|
|
1151
|
+
analytics?: boolean;
|
|
1102
1152
|
}
|
|
1103
1153
|
interface UnlockInput {
|
|
1104
1154
|
orderId: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ interface HttpConfig {
|
|
|
12
12
|
* client drops it so `auth.isSignedIn` goes false.
|
|
13
13
|
*/
|
|
14
14
|
onTokenInvalid?: () => void;
|
|
15
|
+
/** False opts the app out of product analytics; telemetry is unaffected. */
|
|
16
|
+
analytics?: boolean | undefined;
|
|
15
17
|
fetchImpl?: typeof fetch;
|
|
16
18
|
maxRetries?: number;
|
|
17
19
|
}
|
|
@@ -341,6 +343,26 @@ interface TelemetryEvent {
|
|
|
341
343
|
result: "success" | "failure";
|
|
342
344
|
transport?: "ble" | "simulated";
|
|
343
345
|
at: string;
|
|
346
|
+
/**
|
|
347
|
+
* WHY it failed, on a failure (owner, 2026-08-11).
|
|
348
|
+
*
|
|
349
|
+
* Without this an open that did not work is a number and nothing else: the
|
|
350
|
+
* platform could say how often opens fail and never why. It is the Parent's
|
|
351
|
+
* `[AUTH] REJECT` reason (`TAG`, `NONCE`, `NOTREADY`, …), an API error code,
|
|
352
|
+
* or a transport reason like `timeout` / `not_connected`.
|
|
353
|
+
*
|
|
354
|
+
* A bounded vocabulary matters more than richness here, because this is
|
|
355
|
+
* grouped and counted, not read. Never put a raw error message in it.
|
|
356
|
+
*/
|
|
357
|
+
reason?: string;
|
|
358
|
+
/**
|
|
359
|
+
* 1 for the first try, 2 for the first retry, and so on.
|
|
360
|
+
*
|
|
361
|
+
* `NOTREADY` is retryable (firmware 1.1.0), so without this a recovered open
|
|
362
|
+
* looks identical to one that worked first time and the retry can never be
|
|
363
|
+
* shown to be worth having.
|
|
364
|
+
*/
|
|
365
|
+
attempt?: number;
|
|
344
366
|
}
|
|
345
367
|
/** One page of orders, newest first. `next_cursor` is null on the last page. */
|
|
346
368
|
interface OrderPage {
|
|
@@ -649,6 +671,22 @@ declare class OrdersModule {
|
|
|
649
671
|
promotionCode?: string;
|
|
650
672
|
metadata?: Record<string, string>;
|
|
651
673
|
}): Promise<Order>;
|
|
674
|
+
/**
|
|
675
|
+
* Fetch one order.
|
|
676
|
+
*
|
|
677
|
+
* WHO MAY READ IT, because this is the call most likely to surprise you:
|
|
678
|
+
*
|
|
679
|
+
* - A SECRET key reads any order of the app. Server-to-server.
|
|
680
|
+
* - A PUBLISHABLE key needs a signed-in end user, who must be the order's
|
|
681
|
+
* initiator or its recipient. A publishable key ships inside your app
|
|
682
|
+
* binary, so it proves nothing about who is asking.
|
|
683
|
+
* - A GUEST session reads only its own orders that have no recipient. Guest
|
|
684
|
+
* mode is one shared identity per app, so a guest order with no recipient
|
|
685
|
+
* names nobody, while a directed one names a real person.
|
|
686
|
+
*
|
|
687
|
+
* Every refusal is `not_found`, identical to an id that does not exist, so
|
|
688
|
+
* you cannot tell the two apart and should not try.
|
|
689
|
+
*/
|
|
652
690
|
get(orderId: string): Promise<Order>;
|
|
653
691
|
/**
|
|
654
692
|
* Request an open: one token + an unlock grant. On authenticated towers the
|
|
@@ -1099,6 +1137,18 @@ interface RelaiClientOptions {
|
|
|
1099
1137
|
* new RelaiClient({ publishableKey, stripe: Stripe });
|
|
1100
1138
|
*/
|
|
1101
1139
|
stripe?: StripeSdk;
|
|
1140
|
+
/**
|
|
1141
|
+
* Send `false` to opt this app out of Relai's PRODUCT ANALYTICS
|
|
1142
|
+
* (owner, 2026-08-11).
|
|
1143
|
+
*
|
|
1144
|
+
* Operational telemetry is unaffected and is not optional: Relai needs it to
|
|
1145
|
+
* reconcile orders and bill correctly, and an open that is never reported is
|
|
1146
|
+
* an order that never completes. What this turns off is the forwarding of a
|
|
1147
|
+
* curated subset to Relai's analytics tooling. Stated here rather than buried,
|
|
1148
|
+
* because "analytics" and "the thing that makes your orders work" being the
|
|
1149
|
+
* same switch would be a nasty surprise.
|
|
1150
|
+
*/
|
|
1151
|
+
analytics?: boolean;
|
|
1102
1152
|
}
|
|
1103
1153
|
interface UnlockInput {
|
|
1104
1154
|
orderId: string;
|
package/dist/index.js
CHANGED
|
@@ -86,6 +86,7 @@ var HttpClient = class {
|
|
|
86
86
|
if (bearer) h["authorization"] = `Bearer ${bearer}`;
|
|
87
87
|
}
|
|
88
88
|
if (idem) h["idempotency-key"] = idem;
|
|
89
|
+
if (this.cfg.analytics === false) h["x-relai-analytics"] = "off";
|
|
89
90
|
return h;
|
|
90
91
|
}
|
|
91
92
|
async parseJson(res) {
|
|
@@ -324,6 +325,22 @@ var OrdersModule = class {
|
|
|
324
325
|
if (input.metadata !== void 0) body["metadata"] = input.metadata;
|
|
325
326
|
return this.http.request({ method: "POST", path: "/orders", body });
|
|
326
327
|
}
|
|
328
|
+
/**
|
|
329
|
+
* Fetch one order.
|
|
330
|
+
*
|
|
331
|
+
* WHO MAY READ IT, because this is the call most likely to surprise you:
|
|
332
|
+
*
|
|
333
|
+
* - A SECRET key reads any order of the app. Server-to-server.
|
|
334
|
+
* - A PUBLISHABLE key needs a signed-in end user, who must be the order's
|
|
335
|
+
* initiator or its recipient. A publishable key ships inside your app
|
|
336
|
+
* binary, so it proves nothing about who is asking.
|
|
337
|
+
* - A GUEST session reads only its own orders that have no recipient. Guest
|
|
338
|
+
* mode is one shared identity per app, so a guest order with no recipient
|
|
339
|
+
* names nobody, while a directed one names a real person.
|
|
340
|
+
*
|
|
341
|
+
* Every refusal is `not_found`, identical to an id that does not exist, so
|
|
342
|
+
* you cannot tell the two apart and should not try.
|
|
343
|
+
*/
|
|
327
344
|
get(orderId) {
|
|
328
345
|
return this.http.request({ path: `/orders/${orderId}` });
|
|
329
346
|
}
|
|
@@ -611,7 +628,10 @@ async function deliverOpen(deps, open, opts) {
|
|
|
611
628
|
action: ack.accepted ? "unlock_used" : "unlock_failed",
|
|
612
629
|
result: ack.accepted ? "success" : "failure",
|
|
613
630
|
transport: "ble",
|
|
614
|
-
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
631
|
+
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
632
|
+
// The Parent's own reject reason, so a failure is diagnosable
|
|
633
|
+
// rather than merely counted.
|
|
634
|
+
...ack.accepted ? {} : { reason: ack.rejectReason ?? "UNKNOWN" }
|
|
615
635
|
}
|
|
616
636
|
]
|
|
617
637
|
}).catch(() => void 0);
|
|
@@ -647,7 +667,8 @@ var RelaiClient = class {
|
|
|
647
667
|
...options.publishableKey !== void 0 ? { publishableKey: options.publishableKey } : {},
|
|
648
668
|
...options.secretKey !== void 0 ? { secretKey: options.secretKey } : {},
|
|
649
669
|
...options.fetchImpl !== void 0 ? { fetchImpl: options.fetchImpl } : {},
|
|
650
|
-
...options.maxRetries !== void 0 ? { maxRetries: options.maxRetries } : {}
|
|
670
|
+
...options.maxRetries !== void 0 ? { maxRetries: options.maxRetries } : {},
|
|
671
|
+
...options.analytics !== void 0 ? { analytics: options.analytics } : {}
|
|
651
672
|
};
|
|
652
673
|
this.http = new HttpClient(httpConfig);
|
|
653
674
|
auth = new AuthModule(this.http, storage);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@relai-team/access-sdk",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.2",
|
|
4
4
|
"description": "Official Relai Access SDK, open Relai Exchange Zone nodes over BLE, backed by the Relai Access platform (server-owns-trust).",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"type": "module",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"sideEffects": false,
|
|
23
23
|
"scripts": {
|
|
24
24
|
"build": "tsup",
|
|
25
|
+
"prepack": "npm run build",
|
|
25
26
|
"typecheck": "tsc --noEmit",
|
|
26
27
|
"pretest": "npm run build",
|
|
27
28
|
"test": "vitest run",
|