@relai-team/access-sdk 0.13.0 → 0.15.0
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/README.md +55 -2
- package/dist/{chunk-U4CSAG73.js → chunk-B2T3KFBF.js} +9 -1
- package/dist/{chunk-3WZBCXG3.js → chunk-BIHTDL4L.js} +21 -6
- package/dist/errors-NKRGOFB3.js +1 -0
- package/dist/index.cjs +74 -6
- package/dist/index.d.cts +97 -3
- package/dist/index.d.ts +97 -3
- package/dist/index.js +48 -6
- package/dist/payment-sheet-B3X5QQMO.js +1 -0
- package/package.json +1 -1
- package/dist/errors-N4TYPXJ4.js +0 -1
- package/dist/payment-sheet-XIZYASSI.js +0 -1
package/README.md
CHANGED
|
@@ -411,10 +411,18 @@ Faults: `jammed_door`, `dead_battery`, `out_of_service`, and `clear`.
|
|
|
411
411
|
|
|
412
412
|
```ts
|
|
413
413
|
const app = await relai.app.self();
|
|
414
|
-
app.plan;
|
|
415
|
-
app.real_token_balance; // remaining
|
|
414
|
+
app.plan; // { id, name } or null when unmetered
|
|
415
|
+
app.real_token_balance; // remaining REAL opens
|
|
416
|
+
app.sim_token_balance; // remaining SIMULATED opens (0.14.0)
|
|
416
417
|
```
|
|
417
418
|
|
|
419
|
+
An open against a simulated Exchange Zone draws from `sim_token_balance`, not
|
|
420
|
+
the real one, and hitting zero raises `quota_exceeded` on the open exactly as it
|
|
421
|
+
does for real opens. A sandbox can dead-end mid-test, so check this before a
|
|
422
|
+
long test run, not after.
|
|
423
|
+
|
|
424
|
+
Null on either means "no active plan". It does NOT mean unlimited.
|
|
425
|
+
|
|
418
426
|
Worth calling at launch. Without it the first sign that an app is out of real
|
|
419
427
|
opens is a door that did not open, which is both the worst moment to find out
|
|
420
428
|
and the worst possible messenger. Warn while there is still time to top up.
|
|
@@ -443,6 +451,51 @@ There is deliberately no `payment.authorized`: Relai checkout intents capture
|
|
|
443
451
|
immediately, so success IS the capture. The published contract listed one until
|
|
444
452
|
0.13.0, and omitted `order.abandoned`, which really is delivered.
|
|
445
453
|
|
|
454
|
+
## Listing orders
|
|
455
|
+
|
|
456
|
+
```ts
|
|
457
|
+
// Signed in: only this user's orders, as sender or recipient.
|
|
458
|
+
const open = await relai.orders.list({ status: "open" });
|
|
459
|
+
|
|
460
|
+
// Every page, cursors handled for you.
|
|
461
|
+
for await (const order of relai.orders.all({ status: "open" })) {
|
|
462
|
+
render(order);
|
|
463
|
+
}
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
A secret key lists every order of the app. A publishable key needs a signed-in
|
|
467
|
+
end user and returns only theirs, because a publishable key ships inside your
|
|
468
|
+
binary. Guest identities are refused: guest mode is one shared user per app, so
|
|
469
|
+
there is no identity to scope by, and a guest app has to keep its own order ids.
|
|
470
|
+
|
|
471
|
+
## When a payment gate is broken, not declined
|
|
472
|
+
|
|
473
|
+
`unlock()` presents the Stripe Payment Sheet when the platform answers 402
|
|
474
|
+
`payment_required`. If the gate itself is unusable, the SDK throws
|
|
475
|
+
`RelaiConfigError` rather than letting the 402 surface:
|
|
476
|
+
|
|
477
|
+
```ts
|
|
478
|
+
import { RelaiConfigError } from "@relai-team/access-sdk";
|
|
479
|
+
|
|
480
|
+
try {
|
|
481
|
+
await relai.unlock({ orderId, intent: "occupy", transport });
|
|
482
|
+
} catch (err) {
|
|
483
|
+
if (err instanceof RelaiConfigError) {
|
|
484
|
+
// Relai's side is misconfigured. Retrying will not help and the person did
|
|
485
|
+
// nothing wrong. `err.field` names the offending value.
|
|
486
|
+
report(`Relai configuration problem: ${err.field}`);
|
|
487
|
+
} else if (err instanceof RelaiApiError && err.code === "payment_required") {
|
|
488
|
+
// A real payment outcome: declined, or the sheet was cancelled.
|
|
489
|
+
showPaymentNeeded();
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
Before 0.14.0 these were the same thing. The key was checked for PRESENCE, so a
|
|
495
|
+
malformed value reached Stripe, failed there, and the SDK rethrew the original
|
|
496
|
+
402. An app could not tell "your card was declined" from "Relai's Stripe key is
|
|
497
|
+
wrong", and neither could the person holding the phone.
|
|
498
|
+
|
|
446
499
|
## Offline-durable telemetry
|
|
447
500
|
|
|
448
501
|
Every open reports best-effort telemetry. If the network is down when a node
|
|
@@ -34,6 +34,14 @@ var RelaiLateFeeDue = class extends RelaiApiError {
|
|
|
34
34
|
this.clientSecret = typeof cs === "string" ? cs : null;
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
+
var RelaiConfigError = class extends RelaiError {
|
|
38
|
+
constructor(field, message) {
|
|
39
|
+
super(message);
|
|
40
|
+
this.name = "RelaiConfigError";
|
|
41
|
+
this.code = "invalid_gate_configuration";
|
|
42
|
+
this.field = field;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
37
45
|
var RelaiMissingKeyError = class extends RelaiError {
|
|
38
46
|
constructor() {
|
|
39
47
|
super(
|
|
@@ -58,4 +66,4 @@ var RelaiTransportError = class extends RelaiError {
|
|
|
58
66
|
}
|
|
59
67
|
};
|
|
60
68
|
|
|
61
|
-
export { RelaiApiError, RelaiError, RelaiLateFeeDue, RelaiMissingKeyError, RelaiNetworkError, RelaiTransportError, RelaiUnlockRejected };
|
|
69
|
+
export { RelaiApiError, RelaiConfigError, RelaiError, RelaiLateFeeDue, RelaiMissingKeyError, RelaiNetworkError, RelaiTransportError, RelaiUnlockRejected };
|
|
@@ -1,14 +1,29 @@
|
|
|
1
1
|
// src/payment-sheet.ts
|
|
2
|
+
function isStripePublishableKey(v) {
|
|
3
|
+
return typeof v === "string" && /^pk_(test|live)_[A-Za-z0-9]/.test(v);
|
|
4
|
+
}
|
|
5
|
+
function redactForMessage(v) {
|
|
6
|
+
if (typeof v !== "string") return String(v);
|
|
7
|
+
return v.length <= 12 ? v : `${v.slice(0, 12)}\u2026(${v.length} chars)`;
|
|
8
|
+
}
|
|
2
9
|
function asPaymentRequired(details) {
|
|
3
|
-
if (!details || typeof details["
|
|
10
|
+
if (!details || typeof details["kind"] !== "string") return null;
|
|
4
11
|
return details;
|
|
5
12
|
}
|
|
6
13
|
async function presentRelaiPaymentSheet(details, stripe) {
|
|
7
|
-
if (!details.client_secret
|
|
8
|
-
|
|
9
|
-
|
|
14
|
+
if (!details.client_secret) {
|
|
15
|
+
const { RelaiConfigError } = await import('./errors-NKRGOFB3.js');
|
|
16
|
+
throw new RelaiConfigError(
|
|
17
|
+
"client_secret",
|
|
18
|
+
"Relai returned a payment gate with no client secret, so the payment sheet cannot be shown. This is a platform fault, not a declined payment. Quote the request id from the 402 to Relai support."
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
if (!isStripePublishableKey(details.publishable_key)) {
|
|
22
|
+
const { RelaiConfigError } = await import('./errors-NKRGOFB3.js');
|
|
23
|
+
throw new RelaiConfigError(
|
|
24
|
+
"publishable_key",
|
|
25
|
+
`Relai returned "${redactForMessage(details.publishable_key)}" as the Stripe publishable key, which is not one (it must start with pk_test_ or pk_live_). This is a platform misconfiguration, not a declined payment: retrying will not help, and no key on this device can substitute for it. Quote the request id from the 402 to Relai support.`
|
|
10
26
|
);
|
|
11
|
-
return false;
|
|
12
27
|
}
|
|
13
28
|
if (!stripe) {
|
|
14
29
|
console.warn(
|
|
@@ -33,4 +48,4 @@ async function presentRelaiPaymentSheet(details, stripe) {
|
|
|
33
48
|
return !error;
|
|
34
49
|
}
|
|
35
50
|
|
|
36
|
-
export { asPaymentRequired, presentRelaiPaymentSheet };
|
|
51
|
+
export { asPaymentRequired, isStripePublishableKey, presentRelaiPaymentSheet };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { RelaiApiError, RelaiConfigError, RelaiError, RelaiLateFeeDue, RelaiMissingKeyError, RelaiNetworkError, RelaiTransportError, RelaiUnlockRejected } from './chunk-B2T3KFBF.js';
|
package/dist/index.cjs
CHANGED
|
@@ -14,6 +14,7 @@ var __export = (target, all) => {
|
|
|
14
14
|
var errors_exports = {};
|
|
15
15
|
__export(errors_exports, {
|
|
16
16
|
RelaiApiError: () => exports.RelaiApiError,
|
|
17
|
+
RelaiConfigError: () => exports.RelaiConfigError,
|
|
17
18
|
RelaiError: () => exports.RelaiError,
|
|
18
19
|
RelaiLateFeeDue: () => exports.RelaiLateFeeDue,
|
|
19
20
|
RelaiMissingKeyError: () => exports.RelaiMissingKeyError,
|
|
@@ -21,7 +22,7 @@ __export(errors_exports, {
|
|
|
21
22
|
RelaiTransportError: () => exports.RelaiTransportError,
|
|
22
23
|
RelaiUnlockRejected: () => exports.RelaiUnlockRejected
|
|
23
24
|
});
|
|
24
|
-
exports.RelaiError = void 0; exports.RelaiApiError = void 0; exports.RelaiNetworkError = void 0; exports.RelaiLateFeeDue = void 0; exports.RelaiMissingKeyError = void 0; exports.RelaiUnlockRejected = void 0; exports.RelaiTransportError = void 0;
|
|
25
|
+
exports.RelaiError = void 0; exports.RelaiApiError = void 0; exports.RelaiNetworkError = void 0; exports.RelaiLateFeeDue = void 0; exports.RelaiConfigError = void 0; exports.RelaiMissingKeyError = void 0; exports.RelaiUnlockRejected = void 0; exports.RelaiTransportError = void 0;
|
|
25
26
|
var init_errors = __esm({
|
|
26
27
|
"src/errors.ts"() {
|
|
27
28
|
exports.RelaiError = class extends Error {
|
|
@@ -59,6 +60,14 @@ var init_errors = __esm({
|
|
|
59
60
|
this.clientSecret = typeof cs === "string" ? cs : null;
|
|
60
61
|
}
|
|
61
62
|
};
|
|
63
|
+
exports.RelaiConfigError = class extends exports.RelaiError {
|
|
64
|
+
constructor(field, message) {
|
|
65
|
+
super(message);
|
|
66
|
+
this.name = "RelaiConfigError";
|
|
67
|
+
this.code = "invalid_gate_configuration";
|
|
68
|
+
this.field = field;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
62
71
|
exports.RelaiMissingKeyError = class extends exports.RelaiError {
|
|
63
72
|
constructor() {
|
|
64
73
|
super(
|
|
@@ -89,18 +98,34 @@ var init_errors = __esm({
|
|
|
89
98
|
var payment_sheet_exports = {};
|
|
90
99
|
__export(payment_sheet_exports, {
|
|
91
100
|
asPaymentRequired: () => asPaymentRequired,
|
|
101
|
+
isStripePublishableKey: () => isStripePublishableKey,
|
|
92
102
|
presentRelaiPaymentSheet: () => presentRelaiPaymentSheet
|
|
93
103
|
});
|
|
104
|
+
function isStripePublishableKey(v) {
|
|
105
|
+
return typeof v === "string" && /^pk_(test|live)_[A-Za-z0-9]/.test(v);
|
|
106
|
+
}
|
|
107
|
+
function redactForMessage(v) {
|
|
108
|
+
if (typeof v !== "string") return String(v);
|
|
109
|
+
return v.length <= 12 ? v : `${v.slice(0, 12)}\u2026(${v.length} chars)`;
|
|
110
|
+
}
|
|
94
111
|
function asPaymentRequired(details) {
|
|
95
|
-
if (!details || typeof details["
|
|
112
|
+
if (!details || typeof details["kind"] !== "string") return null;
|
|
96
113
|
return details;
|
|
97
114
|
}
|
|
98
115
|
async function presentRelaiPaymentSheet(details, stripe) {
|
|
99
|
-
if (!details.client_secret
|
|
100
|
-
|
|
101
|
-
|
|
116
|
+
if (!details.client_secret) {
|
|
117
|
+
const { RelaiConfigError: RelaiConfigError2 } = await Promise.resolve().then(() => (init_errors(), errors_exports));
|
|
118
|
+
throw new RelaiConfigError2(
|
|
119
|
+
"client_secret",
|
|
120
|
+
"Relai returned a payment gate with no client secret, so the payment sheet cannot be shown. This is a platform fault, not a declined payment. Quote the request id from the 402 to Relai support."
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
if (!isStripePublishableKey(details.publishable_key)) {
|
|
124
|
+
const { RelaiConfigError: RelaiConfigError2 } = await Promise.resolve().then(() => (init_errors(), errors_exports));
|
|
125
|
+
throw new RelaiConfigError2(
|
|
126
|
+
"publishable_key",
|
|
127
|
+
`Relai returned "${redactForMessage(details.publishable_key)}" as the Stripe publishable key, which is not one (it must start with pk_test_ or pk_live_). This is a platform misconfiguration, not a declined payment: retrying will not help, and no key on this device can substitute for it. Quote the request id from the 402 to Relai support.`
|
|
102
128
|
);
|
|
103
|
-
return false;
|
|
104
129
|
}
|
|
105
130
|
if (!stripe) {
|
|
106
131
|
console.warn(
|
|
@@ -395,6 +420,48 @@ var OrdersModule = class {
|
|
|
395
420
|
constructor(http) {
|
|
396
421
|
this.http = http;
|
|
397
422
|
}
|
|
423
|
+
/**
|
|
424
|
+
* The caller's orders, newest first (0.15.0).
|
|
425
|
+
*
|
|
426
|
+
* Until this existed `/v1` could create an order and fetch one by id but not
|
|
427
|
+
* list them, so an app had to persist order ids on the device: reinstalling
|
|
428
|
+
* made the user's physical belongings unreachable from the app.
|
|
429
|
+
*
|
|
430
|
+
* WHAT YOU GET BACK depends on the key. A secret key lists every order of the
|
|
431
|
+
* app. A publishable key REQUIRES a signed-in end user and returns only orders
|
|
432
|
+
* where they are the sender or the recipient, because a publishable key ships
|
|
433
|
+
* inside your binary. Guest identities are refused: guest mode is one shared
|
|
434
|
+
* user per app, so there is no identity to scope by, and an app in guest mode
|
|
435
|
+
* has to keep its own order ids.
|
|
436
|
+
*/
|
|
437
|
+
async page(input) {
|
|
438
|
+
const query = {};
|
|
439
|
+
if (input?.status !== void 0) query["status"] = input.status;
|
|
440
|
+
if (input?.role !== void 0) query["role"] = input.role;
|
|
441
|
+
if (input?.exchangeZoneId !== void 0) query["ez_id"] = input.exchangeZoneId;
|
|
442
|
+
if (input?.limit !== void 0) query["limit"] = input.limit;
|
|
443
|
+
if (input?.cursor !== void 0) query["cursor"] = input.cursor;
|
|
444
|
+
return this.http.request({ path: "/orders", query });
|
|
445
|
+
}
|
|
446
|
+
/** First page only. Use `page()` when you need the cursor. */
|
|
447
|
+
async list(input) {
|
|
448
|
+
return (await this.page(input)).data;
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Every order, following cursors for you.
|
|
452
|
+
*
|
|
453
|
+
* `for await (const order of relai.orders.all({ status: "open" }))`. Stops on
|
|
454
|
+
* the first page with a null cursor, so it terminates even if a page is empty.
|
|
455
|
+
*/
|
|
456
|
+
async *all(input) {
|
|
457
|
+
let cursor = input?.cursor;
|
|
458
|
+
for (; ; ) {
|
|
459
|
+
const page = await this.page({ ...input, ...cursor ? { cursor } : {} });
|
|
460
|
+
for (const order of page.data) yield order;
|
|
461
|
+
if (!page.next_cursor) return;
|
|
462
|
+
cursor = page.next_cursor;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
398
465
|
/**
|
|
399
466
|
* Create an order. On DIRECTED-handoff apps, name the pick-up recipient by
|
|
400
467
|
* `recipient` (exact email or `@access-tag`) or by `recipientUserId` (from
|
|
@@ -1229,6 +1296,7 @@ exports.TelemetryModule = TelemetryModule;
|
|
|
1229
1296
|
exports.TelemetryUploader = TelemetryUploader;
|
|
1230
1297
|
exports.asPaymentRequired = asPaymentRequired;
|
|
1231
1298
|
exports.deliverOpen = deliverOpen;
|
|
1299
|
+
exports.isStripePublishableKey = isStripePublishableKey;
|
|
1232
1300
|
exports.parseNotifyLine = parseNotifyLine;
|
|
1233
1301
|
exports.presentRelaiPaymentSheet = presentRelaiPaymentSheet;
|
|
1234
1302
|
exports.verifyWebhook = verifyWebhook;
|
package/dist/index.d.cts
CHANGED
|
@@ -307,6 +307,11 @@ interface TelemetryEvent {
|
|
|
307
307
|
transport?: "ble" | "simulated";
|
|
308
308
|
at: string;
|
|
309
309
|
}
|
|
310
|
+
/** One page of orders, newest first. `next_cursor` is null on the last page. */
|
|
311
|
+
interface OrderPage {
|
|
312
|
+
data: Order[];
|
|
313
|
+
next_cursor: string | null;
|
|
314
|
+
}
|
|
310
315
|
type PushPlatform = "expo" | "ios" | "android" | "web";
|
|
311
316
|
type SandboxFault = "jammed_door" | "dead_battery" | "out_of_service" | "clear";
|
|
312
317
|
interface SandboxFaultResult {
|
|
@@ -318,7 +323,8 @@ interface AppSelf {
|
|
|
318
323
|
id: string;
|
|
319
324
|
name: string;
|
|
320
325
|
environment: ApiEnvironment;
|
|
321
|
-
|
|
326
|
+
/** Booleans by contract; empty today. */
|
|
327
|
+
feature_flags: Record<string, boolean>;
|
|
322
328
|
webhook_url: string | null;
|
|
323
329
|
/** Null when the app is unmetered (no active subscription). */
|
|
324
330
|
plan: {
|
|
@@ -327,6 +333,16 @@ interface AppSelf {
|
|
|
327
333
|
} | null;
|
|
328
334
|
/** Remaining real opens. Null when unmetered. Warn the user before this hits zero. */
|
|
329
335
|
real_token_balance: number | null;
|
|
336
|
+
/**
|
|
337
|
+
* Remaining SIMULATED opens (0.14.0). An open against a simulated Exchange
|
|
338
|
+
* Zone draws from this balance rather than the real one, and hitting zero
|
|
339
|
+
* raises `quota_exceeded` on the open exactly as it does for real opens, so a
|
|
340
|
+
* sandbox can dead-end mid-test with no warning.
|
|
341
|
+
*
|
|
342
|
+
* Null means "no active plan", NOT "unlimited": the same rule as
|
|
343
|
+
* `real_token_balance`, on purpose.
|
|
344
|
+
*/
|
|
345
|
+
sim_token_balance: number | null;
|
|
330
346
|
}
|
|
331
347
|
/**
|
|
332
348
|
* Every event the platform can deliver.
|
|
@@ -534,6 +550,39 @@ declare class ExchangeZonesModule {
|
|
|
534
550
|
declare class OrdersModule {
|
|
535
551
|
private readonly http;
|
|
536
552
|
constructor(http: HttpClient);
|
|
553
|
+
/**
|
|
554
|
+
* The caller's orders, newest first (0.15.0).
|
|
555
|
+
*
|
|
556
|
+
* Until this existed `/v1` could create an order and fetch one by id but not
|
|
557
|
+
* list them, so an app had to persist order ids on the device: reinstalling
|
|
558
|
+
* made the user's physical belongings unreachable from the app.
|
|
559
|
+
*
|
|
560
|
+
* WHAT YOU GET BACK depends on the key. A secret key lists every order of the
|
|
561
|
+
* app. A publishable key REQUIRES a signed-in end user and returns only orders
|
|
562
|
+
* where they are the sender or the recipient, because a publishable key ships
|
|
563
|
+
* inside your binary. Guest identities are refused: guest mode is one shared
|
|
564
|
+
* user per app, so there is no identity to scope by, and an app in guest mode
|
|
565
|
+
* has to keep its own order ids.
|
|
566
|
+
*/
|
|
567
|
+
page(input?: {
|
|
568
|
+
status?: "open" | "completed" | "cancelled";
|
|
569
|
+
/** Signed-in calls only: orders you SENT, or ones you are receiving. */
|
|
570
|
+
role?: "initiator" | "recipient";
|
|
571
|
+
exchangeZoneId?: string;
|
|
572
|
+
/** 1 to 100. Defaults to 25. */
|
|
573
|
+
limit?: number;
|
|
574
|
+
/** `next_cursor` from a previous page. */
|
|
575
|
+
cursor?: string;
|
|
576
|
+
}): Promise<OrderPage>;
|
|
577
|
+
/** First page only. Use `page()` when you need the cursor. */
|
|
578
|
+
list(input?: Parameters<OrdersModule["page"]>[0]): Promise<Order[]>;
|
|
579
|
+
/**
|
|
580
|
+
* Every order, following cursors for you.
|
|
581
|
+
*
|
|
582
|
+
* `for await (const order of relai.orders.all({ status: "open" }))`. Stops on
|
|
583
|
+
* the first page with a null cursor, so it terminates even if a page is empty.
|
|
584
|
+
*/
|
|
585
|
+
all(input?: Parameters<OrdersModule["page"]>[0]): AsyncGenerator<Order>;
|
|
537
586
|
/**
|
|
538
587
|
* Create an order. On DIRECTED-handoff apps, name the pick-up recipient by
|
|
539
588
|
* `recipient` (exact email or `@access-tag`) or by `recipientUserId` (from
|
|
@@ -953,7 +1002,28 @@ interface StripeSdk {
|
|
|
953
1002
|
error?: unknown;
|
|
954
1003
|
}>;
|
|
955
1004
|
}
|
|
956
|
-
/**
|
|
1005
|
+
/**
|
|
1006
|
+
* Is this a Stripe PUBLISHABLE key?
|
|
1007
|
+
*
|
|
1008
|
+
* Deliberately narrow. A publishable key is public by design and ships inside
|
|
1009
|
+
* every app binary, so the only thing worth checking is that it is the right
|
|
1010
|
+
* KIND of value. `sk_` is matched by the same prefix rule failing, which is what
|
|
1011
|
+
* we want: a secret key here would be a far worse bug than a missing one.
|
|
1012
|
+
*/
|
|
1013
|
+
declare function isStripePublishableKey(v: unknown): v is string;
|
|
1014
|
+
/**
|
|
1015
|
+
* Narrow an error's `details` into the payment-sheet shape, if it is one.
|
|
1016
|
+
*
|
|
1017
|
+
* Narrows on `kind` ALONE (owner, 2026-08-06). It used to also require a string
|
|
1018
|
+
* `client_secret`, which meant a gate arriving without one was not recognised as
|
|
1019
|
+
* a gate at all: `unlock()` saw null and rethrew the original 402, so a platform
|
|
1020
|
+
* fault surfaced to the app as "payment declined". That is the same ambiguity a
|
|
1021
|
+
* builder reported for `publishable_key`, one field over.
|
|
1022
|
+
*
|
|
1023
|
+
* `kind` is the discriminator that says "this IS a payment gate". Whether the
|
|
1024
|
+
* gate is USABLE is `presentRelaiPaymentSheet`'s judgement, and it now says so
|
|
1025
|
+
* with a `RelaiConfigError` naming the field.
|
|
1026
|
+
*/
|
|
957
1027
|
declare function asPaymentRequired(details: Record<string, unknown> | undefined): PaymentRequiredDetails | null;
|
|
958
1028
|
/**
|
|
959
1029
|
* Present the standard Stripe Payment Sheet for a gate. Returns true when the
|
|
@@ -1355,6 +1425,30 @@ declare class RelaiLateFeeDue extends RelaiApiError {
|
|
|
1355
1425
|
readonly clientSecret: string | null;
|
|
1356
1426
|
constructor(status: number, body: ApiErrorBody, ctx?: RelaiErrorContext);
|
|
1357
1427
|
}
|
|
1428
|
+
/**
|
|
1429
|
+
* The platform answered with a gate the app CANNOT act on, because a value it
|
|
1430
|
+
* needs is missing or malformed. A configuration fault, not a payment outcome.
|
|
1431
|
+
*
|
|
1432
|
+
* This exists because the two were indistinguishable (reported by a Relai 3
|
|
1433
|
+
* builder, 2026-08-06). `presentRelaiPaymentSheet` checked
|
|
1434
|
+
* `!details.publishable_key`, which is a presence check where a validity check
|
|
1435
|
+
* belongs: any non-empty string passed, went to `initStripe`, and was rejected
|
|
1436
|
+
* later by `initPaymentSheet`. That returned `false`, and `unlock()` rethrows
|
|
1437
|
+
* the original 402 on `false`, so an app receiving `payment_required` could not
|
|
1438
|
+
* tell "your card was declined" from "Relai's Stripe key is misconfigured".
|
|
1439
|
+
* Diagnosing it took a builder several steps and a packet capture.
|
|
1440
|
+
*
|
|
1441
|
+
* It is deliberately NOT a `payment_required` and never reaches the retry path:
|
|
1442
|
+
* retrying cannot fix it, and nothing the app or the person does will either.
|
|
1443
|
+
* `field` names the offending value so a support message can quote it.
|
|
1444
|
+
*/
|
|
1445
|
+
declare class RelaiConfigError extends RelaiError {
|
|
1446
|
+
readonly name = "RelaiConfigError";
|
|
1447
|
+
readonly code = "invalid_gate_configuration";
|
|
1448
|
+
/** The response field at fault, e.g. `publishable_key`. */
|
|
1449
|
+
readonly field: string;
|
|
1450
|
+
constructor(field: string, message: string);
|
|
1451
|
+
}
|
|
1358
1452
|
/**
|
|
1359
1453
|
* The "doorway" error: the SDK was called with no publishable key. Thrown
|
|
1360
1454
|
* locally (before any request) with actionable guidance, since it's the most
|
|
@@ -1384,4 +1478,4 @@ declare class RelaiTransportError extends RelaiError {
|
|
|
1384
1478
|
constructor(message: string);
|
|
1385
1479
|
}
|
|
1386
1480
|
|
|
1387
|
-
export { type AccessLinkTarget, AccessLinksModule, type AnyWebhookEvent, type ApiEnvironment, type ApiErrorBody, AppModule, type AppSelf, AuthModule, type BleDeviceLike, type BleManagerLike, BleTransport, type BleTransportOptions, type CommandAck, type DeliverOptions, type DiscoveredParent, type EndUser, type EndUserPage, EndUsersModule, type ExchangeZone, type ExchangeZoneDetail, type ExchangeZonePage, ExchangeZonesModule, type GrantAlgorithm, GrantsModule, type HandoffMode, type Intent, Intents, type KeyValueStorage, type Me, MemoryTelemetryQueue, MemoryTokenStorage, type MintedCommand, type NotifyLine, type Open, type Order, type OrderStatusFields, OrdersModule, type OverrideLink, OverrideLinksModule, type ParentTransport, type PaymentRequiredDetails, PushModule, type PushPlatform, type QueuedTelemetry, REJECT_REASONS, RELAI_RX_CHAR, RELAI_TX_CHAR, RELAI_UART_SERVICE, type RecipientMatch, RecipientsModule, RelaiApiError, RelaiClient, type RelaiClientOptions, RelaiError, type RelaiErrorContext, RelaiLateFeeDue, RelaiMissingKeyError, RelaiNetworkError, RelaiTransportError, RelaiUnlockRejected, type SandboxFault, type SandboxFaultResult, SandboxModule, type SelfBillingChoice, type Session, SimAuthenticatedTransport, type SimAuthenticatedTransportOptions, type SimulatedParentConfig, SimulatedTransport, StorageTelemetryQueue, type StorageTelemetryQueueOptions, type StripeSdk, type TelemetryAction, type TelemetryEvent, TelemetryModule, type TelemetryPayload, type TelemetryQueue, TelemetryUploader, type TokenPair, type TokenStorage, type Tower, type TowerNode, type TowerTelemetry, type UnlockDeps, type UnlockGrant, type UnlockInput, type UnlockResult, type VerifyWebhookInput, type WebhookEvent, type WebhookEventOf, type WebhookEventType, type WebhookPayloads, asPaymentRequired, deliverOpen, parseNotifyLine, presentRelaiPaymentSheet, verifyWebhook };
|
|
1481
|
+
export { type AccessLinkTarget, AccessLinksModule, type AnyWebhookEvent, type ApiEnvironment, type ApiErrorBody, AppModule, type AppSelf, AuthModule, type BleDeviceLike, type BleManagerLike, BleTransport, type BleTransportOptions, type CommandAck, type DeliverOptions, type DiscoveredParent, type EndUser, type EndUserPage, EndUsersModule, type ExchangeZone, type ExchangeZoneDetail, type ExchangeZonePage, ExchangeZonesModule, type GrantAlgorithm, GrantsModule, type HandoffMode, type Intent, Intents, type KeyValueStorage, type Me, MemoryTelemetryQueue, MemoryTokenStorage, type MintedCommand, type NotifyLine, type Open, type Order, type OrderPage, type OrderStatusFields, OrdersModule, type OverrideLink, OverrideLinksModule, type ParentTransport, type PaymentRequiredDetails, PushModule, type PushPlatform, type QueuedTelemetry, REJECT_REASONS, RELAI_RX_CHAR, RELAI_TX_CHAR, RELAI_UART_SERVICE, type RecipientMatch, RecipientsModule, RelaiApiError, RelaiClient, type RelaiClientOptions, RelaiConfigError, RelaiError, type RelaiErrorContext, RelaiLateFeeDue, RelaiMissingKeyError, RelaiNetworkError, RelaiTransportError, RelaiUnlockRejected, type SandboxFault, type SandboxFaultResult, SandboxModule, type SelfBillingChoice, type Session, SimAuthenticatedTransport, type SimAuthenticatedTransportOptions, type SimulatedParentConfig, SimulatedTransport, StorageTelemetryQueue, type StorageTelemetryQueueOptions, type StripeSdk, type TelemetryAction, type TelemetryEvent, TelemetryModule, type TelemetryPayload, type TelemetryQueue, TelemetryUploader, type TokenPair, type TokenStorage, type Tower, type TowerNode, type TowerTelemetry, type UnlockDeps, type UnlockGrant, type UnlockInput, type UnlockResult, type VerifyWebhookInput, type WebhookEvent, type WebhookEventOf, type WebhookEventType, type WebhookPayloads, asPaymentRequired, deliverOpen, isStripePublishableKey, parseNotifyLine, presentRelaiPaymentSheet, verifyWebhook };
|
package/dist/index.d.ts
CHANGED
|
@@ -307,6 +307,11 @@ interface TelemetryEvent {
|
|
|
307
307
|
transport?: "ble" | "simulated";
|
|
308
308
|
at: string;
|
|
309
309
|
}
|
|
310
|
+
/** One page of orders, newest first. `next_cursor` is null on the last page. */
|
|
311
|
+
interface OrderPage {
|
|
312
|
+
data: Order[];
|
|
313
|
+
next_cursor: string | null;
|
|
314
|
+
}
|
|
310
315
|
type PushPlatform = "expo" | "ios" | "android" | "web";
|
|
311
316
|
type SandboxFault = "jammed_door" | "dead_battery" | "out_of_service" | "clear";
|
|
312
317
|
interface SandboxFaultResult {
|
|
@@ -318,7 +323,8 @@ interface AppSelf {
|
|
|
318
323
|
id: string;
|
|
319
324
|
name: string;
|
|
320
325
|
environment: ApiEnvironment;
|
|
321
|
-
|
|
326
|
+
/** Booleans by contract; empty today. */
|
|
327
|
+
feature_flags: Record<string, boolean>;
|
|
322
328
|
webhook_url: string | null;
|
|
323
329
|
/** Null when the app is unmetered (no active subscription). */
|
|
324
330
|
plan: {
|
|
@@ -327,6 +333,16 @@ interface AppSelf {
|
|
|
327
333
|
} | null;
|
|
328
334
|
/** Remaining real opens. Null when unmetered. Warn the user before this hits zero. */
|
|
329
335
|
real_token_balance: number | null;
|
|
336
|
+
/**
|
|
337
|
+
* Remaining SIMULATED opens (0.14.0). An open against a simulated Exchange
|
|
338
|
+
* Zone draws from this balance rather than the real one, and hitting zero
|
|
339
|
+
* raises `quota_exceeded` on the open exactly as it does for real opens, so a
|
|
340
|
+
* sandbox can dead-end mid-test with no warning.
|
|
341
|
+
*
|
|
342
|
+
* Null means "no active plan", NOT "unlimited": the same rule as
|
|
343
|
+
* `real_token_balance`, on purpose.
|
|
344
|
+
*/
|
|
345
|
+
sim_token_balance: number | null;
|
|
330
346
|
}
|
|
331
347
|
/**
|
|
332
348
|
* Every event the platform can deliver.
|
|
@@ -534,6 +550,39 @@ declare class ExchangeZonesModule {
|
|
|
534
550
|
declare class OrdersModule {
|
|
535
551
|
private readonly http;
|
|
536
552
|
constructor(http: HttpClient);
|
|
553
|
+
/**
|
|
554
|
+
* The caller's orders, newest first (0.15.0).
|
|
555
|
+
*
|
|
556
|
+
* Until this existed `/v1` could create an order and fetch one by id but not
|
|
557
|
+
* list them, so an app had to persist order ids on the device: reinstalling
|
|
558
|
+
* made the user's physical belongings unreachable from the app.
|
|
559
|
+
*
|
|
560
|
+
* WHAT YOU GET BACK depends on the key. A secret key lists every order of the
|
|
561
|
+
* app. A publishable key REQUIRES a signed-in end user and returns only orders
|
|
562
|
+
* where they are the sender or the recipient, because a publishable key ships
|
|
563
|
+
* inside your binary. Guest identities are refused: guest mode is one shared
|
|
564
|
+
* user per app, so there is no identity to scope by, and an app in guest mode
|
|
565
|
+
* has to keep its own order ids.
|
|
566
|
+
*/
|
|
567
|
+
page(input?: {
|
|
568
|
+
status?: "open" | "completed" | "cancelled";
|
|
569
|
+
/** Signed-in calls only: orders you SENT, or ones you are receiving. */
|
|
570
|
+
role?: "initiator" | "recipient";
|
|
571
|
+
exchangeZoneId?: string;
|
|
572
|
+
/** 1 to 100. Defaults to 25. */
|
|
573
|
+
limit?: number;
|
|
574
|
+
/** `next_cursor` from a previous page. */
|
|
575
|
+
cursor?: string;
|
|
576
|
+
}): Promise<OrderPage>;
|
|
577
|
+
/** First page only. Use `page()` when you need the cursor. */
|
|
578
|
+
list(input?: Parameters<OrdersModule["page"]>[0]): Promise<Order[]>;
|
|
579
|
+
/**
|
|
580
|
+
* Every order, following cursors for you.
|
|
581
|
+
*
|
|
582
|
+
* `for await (const order of relai.orders.all({ status: "open" }))`. Stops on
|
|
583
|
+
* the first page with a null cursor, so it terminates even if a page is empty.
|
|
584
|
+
*/
|
|
585
|
+
all(input?: Parameters<OrdersModule["page"]>[0]): AsyncGenerator<Order>;
|
|
537
586
|
/**
|
|
538
587
|
* Create an order. On DIRECTED-handoff apps, name the pick-up recipient by
|
|
539
588
|
* `recipient` (exact email or `@access-tag`) or by `recipientUserId` (from
|
|
@@ -953,7 +1002,28 @@ interface StripeSdk {
|
|
|
953
1002
|
error?: unknown;
|
|
954
1003
|
}>;
|
|
955
1004
|
}
|
|
956
|
-
/**
|
|
1005
|
+
/**
|
|
1006
|
+
* Is this a Stripe PUBLISHABLE key?
|
|
1007
|
+
*
|
|
1008
|
+
* Deliberately narrow. A publishable key is public by design and ships inside
|
|
1009
|
+
* every app binary, so the only thing worth checking is that it is the right
|
|
1010
|
+
* KIND of value. `sk_` is matched by the same prefix rule failing, which is what
|
|
1011
|
+
* we want: a secret key here would be a far worse bug than a missing one.
|
|
1012
|
+
*/
|
|
1013
|
+
declare function isStripePublishableKey(v: unknown): v is string;
|
|
1014
|
+
/**
|
|
1015
|
+
* Narrow an error's `details` into the payment-sheet shape, if it is one.
|
|
1016
|
+
*
|
|
1017
|
+
* Narrows on `kind` ALONE (owner, 2026-08-06). It used to also require a string
|
|
1018
|
+
* `client_secret`, which meant a gate arriving without one was not recognised as
|
|
1019
|
+
* a gate at all: `unlock()` saw null and rethrew the original 402, so a platform
|
|
1020
|
+
* fault surfaced to the app as "payment declined". That is the same ambiguity a
|
|
1021
|
+
* builder reported for `publishable_key`, one field over.
|
|
1022
|
+
*
|
|
1023
|
+
* `kind` is the discriminator that says "this IS a payment gate". Whether the
|
|
1024
|
+
* gate is USABLE is `presentRelaiPaymentSheet`'s judgement, and it now says so
|
|
1025
|
+
* with a `RelaiConfigError` naming the field.
|
|
1026
|
+
*/
|
|
957
1027
|
declare function asPaymentRequired(details: Record<string, unknown> | undefined): PaymentRequiredDetails | null;
|
|
958
1028
|
/**
|
|
959
1029
|
* Present the standard Stripe Payment Sheet for a gate. Returns true when the
|
|
@@ -1355,6 +1425,30 @@ declare class RelaiLateFeeDue extends RelaiApiError {
|
|
|
1355
1425
|
readonly clientSecret: string | null;
|
|
1356
1426
|
constructor(status: number, body: ApiErrorBody, ctx?: RelaiErrorContext);
|
|
1357
1427
|
}
|
|
1428
|
+
/**
|
|
1429
|
+
* The platform answered with a gate the app CANNOT act on, because a value it
|
|
1430
|
+
* needs is missing or malformed. A configuration fault, not a payment outcome.
|
|
1431
|
+
*
|
|
1432
|
+
* This exists because the two were indistinguishable (reported by a Relai 3
|
|
1433
|
+
* builder, 2026-08-06). `presentRelaiPaymentSheet` checked
|
|
1434
|
+
* `!details.publishable_key`, which is a presence check where a validity check
|
|
1435
|
+
* belongs: any non-empty string passed, went to `initStripe`, and was rejected
|
|
1436
|
+
* later by `initPaymentSheet`. That returned `false`, and `unlock()` rethrows
|
|
1437
|
+
* the original 402 on `false`, so an app receiving `payment_required` could not
|
|
1438
|
+
* tell "your card was declined" from "Relai's Stripe key is misconfigured".
|
|
1439
|
+
* Diagnosing it took a builder several steps and a packet capture.
|
|
1440
|
+
*
|
|
1441
|
+
* It is deliberately NOT a `payment_required` and never reaches the retry path:
|
|
1442
|
+
* retrying cannot fix it, and nothing the app or the person does will either.
|
|
1443
|
+
* `field` names the offending value so a support message can quote it.
|
|
1444
|
+
*/
|
|
1445
|
+
declare class RelaiConfigError extends RelaiError {
|
|
1446
|
+
readonly name = "RelaiConfigError";
|
|
1447
|
+
readonly code = "invalid_gate_configuration";
|
|
1448
|
+
/** The response field at fault, e.g. `publishable_key`. */
|
|
1449
|
+
readonly field: string;
|
|
1450
|
+
constructor(field: string, message: string);
|
|
1451
|
+
}
|
|
1358
1452
|
/**
|
|
1359
1453
|
* The "doorway" error: the SDK was called with no publishable key. Thrown
|
|
1360
1454
|
* locally (before any request) with actionable guidance, since it's the most
|
|
@@ -1384,4 +1478,4 @@ declare class RelaiTransportError extends RelaiError {
|
|
|
1384
1478
|
constructor(message: string);
|
|
1385
1479
|
}
|
|
1386
1480
|
|
|
1387
|
-
export { type AccessLinkTarget, AccessLinksModule, type AnyWebhookEvent, type ApiEnvironment, type ApiErrorBody, AppModule, type AppSelf, AuthModule, type BleDeviceLike, type BleManagerLike, BleTransport, type BleTransportOptions, type CommandAck, type DeliverOptions, type DiscoveredParent, type EndUser, type EndUserPage, EndUsersModule, type ExchangeZone, type ExchangeZoneDetail, type ExchangeZonePage, ExchangeZonesModule, type GrantAlgorithm, GrantsModule, type HandoffMode, type Intent, Intents, type KeyValueStorage, type Me, MemoryTelemetryQueue, MemoryTokenStorage, type MintedCommand, type NotifyLine, type Open, type Order, type OrderStatusFields, OrdersModule, type OverrideLink, OverrideLinksModule, type ParentTransport, type PaymentRequiredDetails, PushModule, type PushPlatform, type QueuedTelemetry, REJECT_REASONS, RELAI_RX_CHAR, RELAI_TX_CHAR, RELAI_UART_SERVICE, type RecipientMatch, RecipientsModule, RelaiApiError, RelaiClient, type RelaiClientOptions, RelaiError, type RelaiErrorContext, RelaiLateFeeDue, RelaiMissingKeyError, RelaiNetworkError, RelaiTransportError, RelaiUnlockRejected, type SandboxFault, type SandboxFaultResult, SandboxModule, type SelfBillingChoice, type Session, SimAuthenticatedTransport, type SimAuthenticatedTransportOptions, type SimulatedParentConfig, SimulatedTransport, StorageTelemetryQueue, type StorageTelemetryQueueOptions, type StripeSdk, type TelemetryAction, type TelemetryEvent, TelemetryModule, type TelemetryPayload, type TelemetryQueue, TelemetryUploader, type TokenPair, type TokenStorage, type Tower, type TowerNode, type TowerTelemetry, type UnlockDeps, type UnlockGrant, type UnlockInput, type UnlockResult, type VerifyWebhookInput, type WebhookEvent, type WebhookEventOf, type WebhookEventType, type WebhookPayloads, asPaymentRequired, deliverOpen, parseNotifyLine, presentRelaiPaymentSheet, verifyWebhook };
|
|
1481
|
+
export { type AccessLinkTarget, AccessLinksModule, type AnyWebhookEvent, type ApiEnvironment, type ApiErrorBody, AppModule, type AppSelf, AuthModule, type BleDeviceLike, type BleManagerLike, BleTransport, type BleTransportOptions, type CommandAck, type DeliverOptions, type DiscoveredParent, type EndUser, type EndUserPage, EndUsersModule, type ExchangeZone, type ExchangeZoneDetail, type ExchangeZonePage, ExchangeZonesModule, type GrantAlgorithm, GrantsModule, type HandoffMode, type Intent, Intents, type KeyValueStorage, type Me, MemoryTelemetryQueue, MemoryTokenStorage, type MintedCommand, type NotifyLine, type Open, type Order, type OrderPage, type OrderStatusFields, OrdersModule, type OverrideLink, OverrideLinksModule, type ParentTransport, type PaymentRequiredDetails, PushModule, type PushPlatform, type QueuedTelemetry, REJECT_REASONS, RELAI_RX_CHAR, RELAI_TX_CHAR, RELAI_UART_SERVICE, type RecipientMatch, RecipientsModule, RelaiApiError, RelaiClient, type RelaiClientOptions, RelaiConfigError, RelaiError, type RelaiErrorContext, RelaiLateFeeDue, RelaiMissingKeyError, RelaiNetworkError, RelaiTransportError, RelaiUnlockRejected, type SandboxFault, type SandboxFaultResult, SandboxModule, type SelfBillingChoice, type Session, SimAuthenticatedTransport, type SimAuthenticatedTransportOptions, type SimulatedParentConfig, SimulatedTransport, StorageTelemetryQueue, type StorageTelemetryQueueOptions, type StripeSdk, type TelemetryAction, type TelemetryEvent, TelemetryModule, type TelemetryPayload, type TelemetryQueue, TelemetryUploader, type TokenPair, type TokenStorage, type Tower, type TowerNode, type TowerTelemetry, type UnlockDeps, type UnlockGrant, type UnlockInput, type UnlockResult, type VerifyWebhookInput, type WebhookEvent, type WebhookEventOf, type WebhookEventType, type WebhookPayloads, asPaymentRequired, deliverOpen, isStripePublishableKey, parseNotifyLine, presentRelaiPaymentSheet, verifyWebhook };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { RelaiApiError, RelaiTransportError, RelaiUnlockRejected, RelaiMissingKeyError, RelaiError, RelaiNetworkError } from './chunk-
|
|
2
|
-
export { RelaiApiError, RelaiError, RelaiLateFeeDue, RelaiMissingKeyError, RelaiNetworkError, RelaiTransportError, RelaiUnlockRejected } from './chunk-
|
|
3
|
-
export { asPaymentRequired, presentRelaiPaymentSheet } from './chunk-
|
|
1
|
+
import { RelaiApiError, RelaiTransportError, RelaiUnlockRejected, RelaiMissingKeyError, RelaiError, RelaiNetworkError } from './chunk-B2T3KFBF.js';
|
|
2
|
+
export { RelaiApiError, RelaiConfigError, RelaiError, RelaiLateFeeDue, RelaiMissingKeyError, RelaiNetworkError, RelaiTransportError, RelaiUnlockRejected } from './chunk-B2T3KFBF.js';
|
|
3
|
+
export { asPaymentRequired, isStripePublishableKey, presentRelaiPaymentSheet } from './chunk-BIHTDL4L.js';
|
|
4
4
|
|
|
5
5
|
// src/http.ts
|
|
6
6
|
var RETRYABLE_STATUS = /* @__PURE__ */ new Set([429, 500, 502, 503, 504]);
|
|
@@ -113,7 +113,7 @@ var HttpClient = class {
|
|
|
113
113
|
path: opts.path
|
|
114
114
|
};
|
|
115
115
|
if (body.error.code === "late_fee_due") {
|
|
116
|
-
const { RelaiLateFeeDue: RelaiLateFeeDue2 } = await import('./errors-
|
|
116
|
+
const { RelaiLateFeeDue: RelaiLateFeeDue2 } = await import('./errors-NKRGOFB3.js');
|
|
117
117
|
return new RelaiLateFeeDue2(res.status, body, ctx);
|
|
118
118
|
}
|
|
119
119
|
return new RelaiApiError(res.status, body, ctx);
|
|
@@ -266,6 +266,48 @@ var OrdersModule = class {
|
|
|
266
266
|
constructor(http) {
|
|
267
267
|
this.http = http;
|
|
268
268
|
}
|
|
269
|
+
/**
|
|
270
|
+
* The caller's orders, newest first (0.15.0).
|
|
271
|
+
*
|
|
272
|
+
* Until this existed `/v1` could create an order and fetch one by id but not
|
|
273
|
+
* list them, so an app had to persist order ids on the device: reinstalling
|
|
274
|
+
* made the user's physical belongings unreachable from the app.
|
|
275
|
+
*
|
|
276
|
+
* WHAT YOU GET BACK depends on the key. A secret key lists every order of the
|
|
277
|
+
* app. A publishable key REQUIRES a signed-in end user and returns only orders
|
|
278
|
+
* where they are the sender or the recipient, because a publishable key ships
|
|
279
|
+
* inside your binary. Guest identities are refused: guest mode is one shared
|
|
280
|
+
* user per app, so there is no identity to scope by, and an app in guest mode
|
|
281
|
+
* has to keep its own order ids.
|
|
282
|
+
*/
|
|
283
|
+
async page(input) {
|
|
284
|
+
const query = {};
|
|
285
|
+
if (input?.status !== void 0) query["status"] = input.status;
|
|
286
|
+
if (input?.role !== void 0) query["role"] = input.role;
|
|
287
|
+
if (input?.exchangeZoneId !== void 0) query["ez_id"] = input.exchangeZoneId;
|
|
288
|
+
if (input?.limit !== void 0) query["limit"] = input.limit;
|
|
289
|
+
if (input?.cursor !== void 0) query["cursor"] = input.cursor;
|
|
290
|
+
return this.http.request({ path: "/orders", query });
|
|
291
|
+
}
|
|
292
|
+
/** First page only. Use `page()` when you need the cursor. */
|
|
293
|
+
async list(input) {
|
|
294
|
+
return (await this.page(input)).data;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Every order, following cursors for you.
|
|
298
|
+
*
|
|
299
|
+
* `for await (const order of relai.orders.all({ status: "open" }))`. Stops on
|
|
300
|
+
* the first page with a null cursor, so it terminates even if a page is empty.
|
|
301
|
+
*/
|
|
302
|
+
async *all(input) {
|
|
303
|
+
let cursor = input?.cursor;
|
|
304
|
+
for (; ; ) {
|
|
305
|
+
const page = await this.page({ ...input, ...cursor ? { cursor } : {} });
|
|
306
|
+
for (const order of page.data) yield order;
|
|
307
|
+
if (!page.next_cursor) return;
|
|
308
|
+
cursor = page.next_cursor;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
269
311
|
/**
|
|
270
312
|
* Create an order. On DIRECTED-handoff apps, name the pick-up recipient by
|
|
271
313
|
* `recipient` (exact email or `@access-tag`) or by `recipientUserId` (from
|
|
@@ -658,9 +700,9 @@ var RelaiClient = class {
|
|
|
658
700
|
try {
|
|
659
701
|
open = await requestOpen();
|
|
660
702
|
} catch (err) {
|
|
661
|
-
const { RelaiApiError: RelaiApiError2 } = await import('./errors-
|
|
703
|
+
const { RelaiApiError: RelaiApiError2 } = await import('./errors-NKRGOFB3.js');
|
|
662
704
|
if (input.presentPaymentSheet !== false && err instanceof RelaiApiError2 && err.code === "payment_required") {
|
|
663
|
-
const { asPaymentRequired: asPaymentRequired2, presentRelaiPaymentSheet: presentRelaiPaymentSheet2 } = await import('./payment-sheet-
|
|
705
|
+
const { asPaymentRequired: asPaymentRequired2, presentRelaiPaymentSheet: presentRelaiPaymentSheet2 } = await import('./payment-sheet-B3X5QQMO.js');
|
|
664
706
|
const details = asPaymentRequired2(err.details);
|
|
665
707
|
if (!details || !await presentRelaiPaymentSheet2(details, this.stripe)) throw err;
|
|
666
708
|
open = await requestOpen();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { asPaymentRequired, isStripePublishableKey, presentRelaiPaymentSheet } from './chunk-BIHTDL4L.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@relai-team/access-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
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",
|
package/dist/errors-N4TYPXJ4.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { RelaiApiError, RelaiError, RelaiLateFeeDue, RelaiMissingKeyError, RelaiNetworkError, RelaiTransportError, RelaiUnlockRejected } from './chunk-U4CSAG73.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { asPaymentRequired, presentRelaiPaymentSheet } from './chunk-3WZBCXG3.js';
|