@relai-team/access-sdk 0.10.0 → 0.11.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 CHANGED
@@ -144,6 +144,29 @@ Server-side (secret key), `relai.overrideLinks.request({ nodeId })` mints a
144
144
  single-use override code that opens a node with no paywall (10 free per org per
145
145
  month, then $1.00 each). Redeem via `overrideCode` on the open.
146
146
 
147
+ ## Your end users (server only)
148
+
149
+ `relai.endUsers` reads the people using your app: name, email, and access tag.
150
+
151
+ ```ts
152
+ // On YOUR SERVER, never in the app.
153
+ const relai = new RelaiClient({ secretKey: "sk_sandbox_…" });
154
+
155
+ const { data, total } = await relai.endUsers.list({ limit: 50, query: "@example.com" });
156
+ const person = await relai.endUsers.get(data[0].id);
157
+ ```
158
+
159
+ **Secret key only, and deliberately so.** A publishable key ships inside your
160
+ app binary where anyone who downloads it can read it, so a `pk_` that could
161
+ list end users would hand every customer's email to the public. From the phone,
162
+ `relai.me()` returns the one person holding the session, which is what a client
163
+ actually needs.
164
+
165
+ The environment comes from the key, like everywhere else: a **sandbox** key
166
+ lists your test identities, a **production** key lists your real users. An id
167
+ from one environment answers `not_found` in the other, and so does an id
168
+ belonging to somebody else's app.
169
+
147
170
  ## Relai checkout: end users pay, you write no payment code
148
171
 
149
172
  If the app is set to **Relai checkout** in the Relai portal (the default for
package/dist/index.cjs CHANGED
@@ -446,6 +446,37 @@ var OverrideLinksModule = class {
446
446
  return this.http.request({ method: "POST", path: "/override-links", body });
447
447
  }
448
448
  };
449
+ var EndUsersModule = class {
450
+ constructor(http) {
451
+ this.http = http;
452
+ }
453
+ /**
454
+ * Your app's end users (SERVER ONLY: secret key).
455
+ *
456
+ * Returns other people's names and email addresses, so it is deliberately out
457
+ * of reach of a publishable key: that key ships inside your app binary where
458
+ * anyone can read it. Call this from your backend. From the phone, `me()`
459
+ * returns the one person holding the session, which is all a client needs.
460
+ *
461
+ * The environment comes from the key, like everywhere else: a sandbox key
462
+ * lists your test identities, a production key lists your real users.
463
+ */
464
+ list(input) {
465
+ const query = {};
466
+ if (input?.limit !== void 0) query["limit"] = input.limit;
467
+ if (input?.offset !== void 0) query["offset"] = input.offset;
468
+ if (input?.query !== void 0) query["q"] = input.query;
469
+ return this.http.request({ path: "/end-users", query });
470
+ }
471
+ /**
472
+ * One end user by id (SERVER ONLY: secret key). Answers `not_found` for
473
+ * anyone outside this app and environment, including ids that exist
474
+ * elsewhere on the platform.
475
+ */
476
+ get(userId) {
477
+ return this.http.request({ path: `/end-users/${userId}` });
478
+ }
479
+ };
449
480
  var TelemetryModule = class {
450
481
  constructor(http) {
451
482
  this.http = http;
@@ -620,6 +651,7 @@ var RelaiClient = class {
620
651
  this.recipients = new RecipientsModule(this.http);
621
652
  this.accessLinks = new AccessLinksModule(this.http);
622
653
  this.overrideLinks = new OverrideLinksModule(this.http);
654
+ this.endUsers = new EndUsersModule(this.http);
623
655
  this.telemetry = new TelemetryModule(this.http);
624
656
  this.telemetryUploader = new TelemetryUploader(this.telemetry, options.telemetryQueue);
625
657
  }
@@ -1048,6 +1080,7 @@ var Intents = {
1048
1080
  exports.AccessLinksModule = AccessLinksModule;
1049
1081
  exports.AuthModule = AuthModule;
1050
1082
  exports.BleTransport = BleTransport;
1083
+ exports.EndUsersModule = EndUsersModule;
1051
1084
  exports.ExchangeZonesModule = ExchangeZonesModule;
1052
1085
  exports.GrantsModule = GrantsModule;
1053
1086
  exports.Intents = Intents;
package/dist/index.d.cts CHANGED
@@ -141,6 +141,31 @@ interface OverrideLink {
141
141
  billed_cents: number;
142
142
  free_per_month: number;
143
143
  }
144
+ /**
145
+ * One of your app's end users, as returned by the secret-key directory. Never
146
+ * reachable with a publishable key: see `EndUsersModule`.
147
+ */
148
+ interface EndUser {
149
+ id: string;
150
+ email: string;
151
+ name: string | null;
152
+ /** Their `@handle` for directed handoffs, when they have set one. */
153
+ access_tag: string | null;
154
+ first_seen_at: string | null;
155
+ last_seen_at: string | null;
156
+ /** Orders on THIS app, counted on either side of the handoff. */
157
+ order_count: number;
158
+ /** Which environment this record came from, echoing your key. */
159
+ environment?: "sandbox" | "production";
160
+ }
161
+ interface EndUserPage {
162
+ data: EndUser[];
163
+ /** Matching end users in total, not just on this page. */
164
+ total: number;
165
+ limit: number;
166
+ offset: number;
167
+ environment: "sandbox" | "production";
168
+ }
144
169
  /** The unlock grant carried on an Open (or returned by mint). */
145
170
  interface UnlockGrant {
146
171
  grant_id: string;
@@ -425,6 +450,34 @@ declare class OverrideLinksModule {
425
450
  expiresInHours?: number;
426
451
  }): Promise<OverrideLink>;
427
452
  }
453
+ declare class EndUsersModule {
454
+ private readonly http;
455
+ constructor(http: HttpClient);
456
+ /**
457
+ * Your app's end users (SERVER ONLY: secret key).
458
+ *
459
+ * Returns other people's names and email addresses, so it is deliberately out
460
+ * of reach of a publishable key: that key ships inside your app binary where
461
+ * anyone can read it. Call this from your backend. From the phone, `me()`
462
+ * returns the one person holding the session, which is all a client needs.
463
+ *
464
+ * The environment comes from the key, like everywhere else: a sandbox key
465
+ * lists your test identities, a production key lists your real users.
466
+ */
467
+ list(input?: {
468
+ /** 1 to 100. Defaults to 25. */
469
+ limit?: number;
470
+ offset?: number;
471
+ /** Case-insensitive substring match on email. */
472
+ query?: string;
473
+ }): Promise<EndUserPage>;
474
+ /**
475
+ * One end user by id (SERVER ONLY: secret key). Answers `not_found` for
476
+ * anyone outside this app and environment, including ids that exist
477
+ * elsewhere on the platform.
478
+ */
479
+ get(userId: string): Promise<EndUser>;
480
+ }
428
481
  declare class TelemetryModule {
429
482
  private readonly http;
430
483
  constructor(http: HttpClient);
@@ -729,6 +782,8 @@ declare class RelaiClient {
729
782
  readonly accessLinks: AccessLinksModule;
730
783
  /** SERVER ONLY (secret key): request paywall-bypassing override links. */
731
784
  readonly overrideLinks: OverrideLinksModule;
785
+ /** SERVER ONLY (secret key): your app's end users, name, email, access tag. */
786
+ readonly endUsers: EndUsersModule;
732
787
  readonly telemetry: TelemetryModule;
733
788
  /** Queue-and-retry telemetry uploader (used by unlock; flush opportunistically). */
734
789
  readonly telemetryUploader: TelemetryUploader;
@@ -1025,4 +1080,4 @@ declare class RelaiTransportError extends RelaiError {
1025
1080
  constructor(message: string);
1026
1081
  }
1027
1082
 
1028
- export { type AccessLinkTarget, AccessLinksModule, type ApiEnvironment, type ApiErrorBody, AuthModule, type BleDeviceLike, type BleManagerLike, BleTransport, type BleTransportOptions, type CommandAck, type DeliverOptions, type DiscoveredParent, type ExchangeZone, type ExchangeZoneDetail, ExchangeZonesModule, type GrantAlgorithm, GrantsModule, type HandoffMode, type Intent, Intents, type KeyValueStorage, MemoryTelemetryQueue, MemoryTokenStorage, type MintedCommand, type NotifyLine, type Open, type Order, OrdersModule, type OverrideLink, OverrideLinksModule, type ParentTransport, type PaymentRequiredDetails, type QueuedTelemetry, REJECT_REASONS, RELAI_RX_CHAR, RELAI_TX_CHAR, RELAI_UART_SERVICE, type RecipientMatch, RecipientsModule, RelaiApiError, RelaiClient, type RelaiClientOptions, RelaiError, RelaiLateFeeDue, RelaiMissingKeyError, RelaiTransportError, RelaiUnlockRejected, 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, asPaymentRequired, deliverOpen, parseNotifyLine, presentRelaiPaymentSheet, verifyWebhook };
1083
+ export { type AccessLinkTarget, AccessLinksModule, type ApiEnvironment, type ApiErrorBody, AuthModule, type BleDeviceLike, type BleManagerLike, BleTransport, type BleTransportOptions, type CommandAck, type DeliverOptions, type DiscoveredParent, type EndUser, type EndUserPage, EndUsersModule, type ExchangeZone, type ExchangeZoneDetail, ExchangeZonesModule, type GrantAlgorithm, GrantsModule, type HandoffMode, type Intent, Intents, type KeyValueStorage, MemoryTelemetryQueue, MemoryTokenStorage, type MintedCommand, type NotifyLine, type Open, type Order, OrdersModule, type OverrideLink, OverrideLinksModule, type ParentTransport, type PaymentRequiredDetails, type QueuedTelemetry, REJECT_REASONS, RELAI_RX_CHAR, RELAI_TX_CHAR, RELAI_UART_SERVICE, type RecipientMatch, RecipientsModule, RelaiApiError, RelaiClient, type RelaiClientOptions, RelaiError, RelaiLateFeeDue, RelaiMissingKeyError, RelaiTransportError, RelaiUnlockRejected, 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, asPaymentRequired, deliverOpen, parseNotifyLine, presentRelaiPaymentSheet, verifyWebhook };
package/dist/index.d.ts CHANGED
@@ -141,6 +141,31 @@ interface OverrideLink {
141
141
  billed_cents: number;
142
142
  free_per_month: number;
143
143
  }
144
+ /**
145
+ * One of your app's end users, as returned by the secret-key directory. Never
146
+ * reachable with a publishable key: see `EndUsersModule`.
147
+ */
148
+ interface EndUser {
149
+ id: string;
150
+ email: string;
151
+ name: string | null;
152
+ /** Their `@handle` for directed handoffs, when they have set one. */
153
+ access_tag: string | null;
154
+ first_seen_at: string | null;
155
+ last_seen_at: string | null;
156
+ /** Orders on THIS app, counted on either side of the handoff. */
157
+ order_count: number;
158
+ /** Which environment this record came from, echoing your key. */
159
+ environment?: "sandbox" | "production";
160
+ }
161
+ interface EndUserPage {
162
+ data: EndUser[];
163
+ /** Matching end users in total, not just on this page. */
164
+ total: number;
165
+ limit: number;
166
+ offset: number;
167
+ environment: "sandbox" | "production";
168
+ }
144
169
  /** The unlock grant carried on an Open (or returned by mint). */
145
170
  interface UnlockGrant {
146
171
  grant_id: string;
@@ -425,6 +450,34 @@ declare class OverrideLinksModule {
425
450
  expiresInHours?: number;
426
451
  }): Promise<OverrideLink>;
427
452
  }
453
+ declare class EndUsersModule {
454
+ private readonly http;
455
+ constructor(http: HttpClient);
456
+ /**
457
+ * Your app's end users (SERVER ONLY: secret key).
458
+ *
459
+ * Returns other people's names and email addresses, so it is deliberately out
460
+ * of reach of a publishable key: that key ships inside your app binary where
461
+ * anyone can read it. Call this from your backend. From the phone, `me()`
462
+ * returns the one person holding the session, which is all a client needs.
463
+ *
464
+ * The environment comes from the key, like everywhere else: a sandbox key
465
+ * lists your test identities, a production key lists your real users.
466
+ */
467
+ list(input?: {
468
+ /** 1 to 100. Defaults to 25. */
469
+ limit?: number;
470
+ offset?: number;
471
+ /** Case-insensitive substring match on email. */
472
+ query?: string;
473
+ }): Promise<EndUserPage>;
474
+ /**
475
+ * One end user by id (SERVER ONLY: secret key). Answers `not_found` for
476
+ * anyone outside this app and environment, including ids that exist
477
+ * elsewhere on the platform.
478
+ */
479
+ get(userId: string): Promise<EndUser>;
480
+ }
428
481
  declare class TelemetryModule {
429
482
  private readonly http;
430
483
  constructor(http: HttpClient);
@@ -729,6 +782,8 @@ declare class RelaiClient {
729
782
  readonly accessLinks: AccessLinksModule;
730
783
  /** SERVER ONLY (secret key): request paywall-bypassing override links. */
731
784
  readonly overrideLinks: OverrideLinksModule;
785
+ /** SERVER ONLY (secret key): your app's end users, name, email, access tag. */
786
+ readonly endUsers: EndUsersModule;
732
787
  readonly telemetry: TelemetryModule;
733
788
  /** Queue-and-retry telemetry uploader (used by unlock; flush opportunistically). */
734
789
  readonly telemetryUploader: TelemetryUploader;
@@ -1025,4 +1080,4 @@ declare class RelaiTransportError extends RelaiError {
1025
1080
  constructor(message: string);
1026
1081
  }
1027
1082
 
1028
- export { type AccessLinkTarget, AccessLinksModule, type ApiEnvironment, type ApiErrorBody, AuthModule, type BleDeviceLike, type BleManagerLike, BleTransport, type BleTransportOptions, type CommandAck, type DeliverOptions, type DiscoveredParent, type ExchangeZone, type ExchangeZoneDetail, ExchangeZonesModule, type GrantAlgorithm, GrantsModule, type HandoffMode, type Intent, Intents, type KeyValueStorage, MemoryTelemetryQueue, MemoryTokenStorage, type MintedCommand, type NotifyLine, type Open, type Order, OrdersModule, type OverrideLink, OverrideLinksModule, type ParentTransport, type PaymentRequiredDetails, type QueuedTelemetry, REJECT_REASONS, RELAI_RX_CHAR, RELAI_TX_CHAR, RELAI_UART_SERVICE, type RecipientMatch, RecipientsModule, RelaiApiError, RelaiClient, type RelaiClientOptions, RelaiError, RelaiLateFeeDue, RelaiMissingKeyError, RelaiTransportError, RelaiUnlockRejected, 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, asPaymentRequired, deliverOpen, parseNotifyLine, presentRelaiPaymentSheet, verifyWebhook };
1083
+ export { type AccessLinkTarget, AccessLinksModule, type ApiEnvironment, type ApiErrorBody, AuthModule, type BleDeviceLike, type BleManagerLike, BleTransport, type BleTransportOptions, type CommandAck, type DeliverOptions, type DiscoveredParent, type EndUser, type EndUserPage, EndUsersModule, type ExchangeZone, type ExchangeZoneDetail, ExchangeZonesModule, type GrantAlgorithm, GrantsModule, type HandoffMode, type Intent, Intents, type KeyValueStorage, MemoryTelemetryQueue, MemoryTokenStorage, type MintedCommand, type NotifyLine, type Open, type Order, OrdersModule, type OverrideLink, OverrideLinksModule, type ParentTransport, type PaymentRequiredDetails, type QueuedTelemetry, REJECT_REASONS, RELAI_RX_CHAR, RELAI_TX_CHAR, RELAI_UART_SERVICE, type RecipientMatch, RecipientsModule, RelaiApiError, RelaiClient, type RelaiClientOptions, RelaiError, RelaiLateFeeDue, RelaiMissingKeyError, RelaiTransportError, RelaiUnlockRejected, 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, asPaymentRequired, deliverOpen, parseNotifyLine, presentRelaiPaymentSheet, verifyWebhook };
package/dist/index.js CHANGED
@@ -329,6 +329,37 @@ var OverrideLinksModule = class {
329
329
  return this.http.request({ method: "POST", path: "/override-links", body });
330
330
  }
331
331
  };
332
+ var EndUsersModule = class {
333
+ constructor(http) {
334
+ this.http = http;
335
+ }
336
+ /**
337
+ * Your app's end users (SERVER ONLY: secret key).
338
+ *
339
+ * Returns other people's names and email addresses, so it is deliberately out
340
+ * of reach of a publishable key: that key ships inside your app binary where
341
+ * anyone can read it. Call this from your backend. From the phone, `me()`
342
+ * returns the one person holding the session, which is all a client needs.
343
+ *
344
+ * The environment comes from the key, like everywhere else: a sandbox key
345
+ * lists your test identities, a production key lists your real users.
346
+ */
347
+ list(input) {
348
+ const query = {};
349
+ if (input?.limit !== void 0) query["limit"] = input.limit;
350
+ if (input?.offset !== void 0) query["offset"] = input.offset;
351
+ if (input?.query !== void 0) query["q"] = input.query;
352
+ return this.http.request({ path: "/end-users", query });
353
+ }
354
+ /**
355
+ * One end user by id (SERVER ONLY: secret key). Answers `not_found` for
356
+ * anyone outside this app and environment, including ids that exist
357
+ * elsewhere on the platform.
358
+ */
359
+ get(userId) {
360
+ return this.http.request({ path: `/end-users/${userId}` });
361
+ }
362
+ };
332
363
  var TelemetryModule = class {
333
364
  constructor(http) {
334
365
  this.http = http;
@@ -496,6 +527,7 @@ var RelaiClient = class {
496
527
  this.recipients = new RecipientsModule(this.http);
497
528
  this.accessLinks = new AccessLinksModule(this.http);
498
529
  this.overrideLinks = new OverrideLinksModule(this.http);
530
+ this.endUsers = new EndUsersModule(this.http);
499
531
  this.telemetry = new TelemetryModule(this.http);
500
532
  this.telemetryUploader = new TelemetryUploader(this.telemetry, options.telemetryQueue);
501
533
  }
@@ -911,4 +943,4 @@ var Intents = {
911
943
  MakeAvailable: "make_available"
912
944
  };
913
945
 
914
- export { AccessLinksModule, AuthModule, BleTransport, ExchangeZonesModule, GrantsModule, Intents, MemoryTelemetryQueue, MemoryTokenStorage, OrdersModule, OverrideLinksModule, REJECT_REASONS, RELAI_RX_CHAR, RELAI_TX_CHAR, RELAI_UART_SERVICE, RecipientsModule, RelaiClient, SimAuthenticatedTransport, SimulatedTransport, StorageTelemetryQueue, TelemetryModule, TelemetryUploader, deliverOpen, parseNotifyLine, verifyWebhook };
946
+ export { AccessLinksModule, AuthModule, BleTransport, EndUsersModule, ExchangeZonesModule, GrantsModule, Intents, MemoryTelemetryQueue, MemoryTokenStorage, OrdersModule, OverrideLinksModule, REJECT_REASONS, RELAI_RX_CHAR, RELAI_TX_CHAR, RELAI_UART_SERVICE, RecipientsModule, RelaiClient, SimAuthenticatedTransport, SimulatedTransport, StorageTelemetryQueue, TelemetryModule, TelemetryUploader, deliverOpen, parseNotifyLine, verifyWebhook };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@relai-team/access-sdk",
3
- "version": "0.10.0",
3
+ "version": "0.11.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",