@relai-team/access-sdk 0.14.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 +17 -0
- package/dist/index.cjs +42 -0
- package/dist/index.d.cts +39 -1
- package/dist/index.d.ts +39 -1
- package/dist/index.js +42 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -451,6 +451,23 @@ There is deliberately no `payment.authorized`: Relai checkout intents capture
|
|
|
451
451
|
immediately, so success IS the capture. The published contract listed one until
|
|
452
452
|
0.13.0, and omitted `order.abandoned`, which really is delivered.
|
|
453
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
|
+
|
|
454
471
|
## When a payment gate is broken, not declined
|
|
455
472
|
|
|
456
473
|
`unlock()` presents the Stripe Payment Sheet when the platform answers 402
|
package/dist/index.cjs
CHANGED
|
@@ -420,6 +420,48 @@ var OrdersModule = class {
|
|
|
420
420
|
constructor(http) {
|
|
421
421
|
this.http = http;
|
|
422
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
|
+
}
|
|
423
465
|
/**
|
|
424
466
|
* Create an order. On DIRECTED-handoff apps, name the pick-up recipient by
|
|
425
467
|
* `recipient` (exact email or `@access-tag`) or by `recipientUserId` (from
|
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 {
|
|
@@ -545,6 +550,39 @@ declare class ExchangeZonesModule {
|
|
|
545
550
|
declare class OrdersModule {
|
|
546
551
|
private readonly http;
|
|
547
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>;
|
|
548
586
|
/**
|
|
549
587
|
* Create an order. On DIRECTED-handoff apps, name the pick-up recipient by
|
|
550
588
|
* `recipient` (exact email or `@access-tag`) or by `recipientUserId` (from
|
|
@@ -1440,4 +1478,4 @@ declare class RelaiTransportError extends RelaiError {
|
|
|
1440
1478
|
constructor(message: string);
|
|
1441
1479
|
}
|
|
1442
1480
|
|
|
1443
|
-
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, 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 };
|
|
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 {
|
|
@@ -545,6 +550,39 @@ declare class ExchangeZonesModule {
|
|
|
545
550
|
declare class OrdersModule {
|
|
546
551
|
private readonly http;
|
|
547
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>;
|
|
548
586
|
/**
|
|
549
587
|
* Create an order. On DIRECTED-handoff apps, name the pick-up recipient by
|
|
550
588
|
* `recipient` (exact email or `@access-tag`) or by `recipientUserId` (from
|
|
@@ -1440,4 +1478,4 @@ declare class RelaiTransportError extends RelaiError {
|
|
|
1440
1478
|
constructor(message: string);
|
|
1441
1479
|
}
|
|
1442
1480
|
|
|
1443
|
-
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, 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 };
|
|
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
|
@@ -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
|
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",
|