@relai-team/access-sdk 0.11.0 → 0.12.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 +72 -0
- package/dist/index.cjs +41 -9
- package/dist/index.d.cts +84 -1
- package/dist/index.d.ts +84 -1
- package/dist/index.js +41 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -84,6 +84,45 @@ await relai.auth.verifyOtp("dana.the.courier.abc12345@test.relai.us", "455606");
|
|
|
84
84
|
Test end-users receive no email, never appear among your real customers, and are
|
|
85
85
|
refused by production keys.
|
|
86
86
|
|
|
87
|
+
## Finding Exchange Zones
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
// Nearest first. Returns an ARRAY.
|
|
91
|
+
const zones = await relai.exchangeZones.near({ lat: 40.7128, lng: -74.006, radiusM: 5000 });
|
|
92
|
+
|
|
93
|
+
// Everything your key can reach.
|
|
94
|
+
const all = await relai.exchangeZones.list({ minNodes: 2 });
|
|
95
|
+
|
|
96
|
+
// Full detail: towers, compartments, and your app's end-user prices.
|
|
97
|
+
const ez = await relai.exchangeZones.get(zones[0].id);
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
`near` and `list` return the first page (25 by default, `limit` up to 100) as a
|
|
101
|
+
plain array. When you need to walk past it, `page` gives you the envelope and
|
|
102
|
+
the cursor:
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
let cursor: string | undefined;
|
|
106
|
+
do {
|
|
107
|
+
const page = await relai.exchangeZones.page({ limit: 100, cursor });
|
|
108
|
+
for (const z of page.data) render(z);
|
|
109
|
+
cursor = page.next_cursor ?? undefined;
|
|
110
|
+
} while (cursor);
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
What your key can see follows the environment: a **sandbox** key sees your app's
|
|
114
|
+
simulated Exchange Zones, a **production** key sees live ones.
|
|
115
|
+
|
|
116
|
+
## Who is signed in
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
const me = await relai.me();
|
|
120
|
+
// { user_id, email, name, app: { id, environment } }
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Requires a session, so call it after `auth.verifyOtp`. A guest (no bearer token)
|
|
124
|
+
gets `401 unauthorized`: a shared guest identity is not a person to report.
|
|
125
|
+
|
|
87
126
|
## How an open works
|
|
88
127
|
|
|
89
128
|
`relai.unlock(...)` runs the full server-owns-trust sequence:
|
|
@@ -144,6 +183,39 @@ Server-side (secret key), `relai.overrideLinks.request({ nodeId })` mints a
|
|
|
144
183
|
single-use override code that opens a node with no paywall (10 free per org per
|
|
145
184
|
month, then $1.00 each). Redeem via `overrideCode` on the open.
|
|
146
185
|
|
|
186
|
+
### Guest mode: no account, no sign-in call
|
|
187
|
+
|
|
188
|
+
**There is no `signInAsGuest()`, and there is nothing missing.** A guest is not
|
|
189
|
+
a kind of session, it is the absence of one: a request counts as a guest request
|
|
190
|
+
when it carries your publishable key and no end-user bearer token. That is
|
|
191
|
+
exactly what this client sends before anyone calls `auth.verifyOtp(...)`, so a
|
|
192
|
+
fresh `RelaiClient` is already making guest calls.
|
|
193
|
+
|
|
194
|
+
```ts
|
|
195
|
+
const relai = new RelaiClient({ publishableKey: "pk_sandbox_..." });
|
|
196
|
+
// No auth.startOtp, no auth.verifyOtp. That is the whole trick.
|
|
197
|
+
|
|
198
|
+
const order = await relai.orders.create({ exchangeZoneId: ez.id });
|
|
199
|
+
const drop = await relai.unlock({ orderId: order.id, intent: Intents.Occupy, transport });
|
|
200
|
+
const code = drop.access_link.code; // hand this to whoever picks up
|
|
201
|
+
|
|
202
|
+
// Any device, still no account:
|
|
203
|
+
await relai.unlock({ orderId: order.id, intent: Intents.MakeAvailable, accessLink: code, transport });
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Guest mode is a **per-app setting** you turn on in the Relai portal, not
|
|
207
|
+
something the SDK can enable, and it requires open access plus the open handoff
|
|
208
|
+
mode. With it off, every call without a bearer token answers `401 unauthorized`
|
|
209
|
+
("Missing end-user bearer token (and guest mode is off for this app)"). If your
|
|
210
|
+
anonymous calls are failing, check that message before your code.
|
|
211
|
+
|
|
212
|
+
Everyone using your app anonymously shares **one** guest identity, so the access
|
|
213
|
+
link is the only thing that tells two guests apart, and it is the only thing that
|
|
214
|
+
authorizes a guest pick-up. A guest cannot pick up without one (even on an order
|
|
215
|
+
a guest created), be a directed recipient, re-open a node, start a
|
|
216
|
+
pay-as-you-go hold, or cancel an order. Late fees on a guest pick-up bill your
|
|
217
|
+
organization, since there is no individual to charge.
|
|
218
|
+
|
|
147
219
|
## Your end users (server only)
|
|
148
220
|
|
|
149
221
|
`relai.endUsers` reads the people using your app: name, email, and access tag.
|
package/dist/index.cjs
CHANGED
|
@@ -326,20 +326,38 @@ var ExchangeZonesModule = class {
|
|
|
326
326
|
constructor(http) {
|
|
327
327
|
this.http = http;
|
|
328
328
|
}
|
|
329
|
-
/**
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
if (input.maxNodes !== void 0) query["max_nodes"] = input.maxNodes;
|
|
335
|
-
return this.http.request({ path: "/exchange-zones", query });
|
|
336
|
-
}
|
|
337
|
-
list(input) {
|
|
329
|
+
/**
|
|
330
|
+
* ONE page of Exchange Zones, plus the cursor to continue. `list` and `near`
|
|
331
|
+
* wrap this and hand back just the array, which is what most callers want.
|
|
332
|
+
*/
|
|
333
|
+
async page(input) {
|
|
338
334
|
const query = {};
|
|
335
|
+
if (input?.near) query["near"] = `${input.near.lat},${input.near.lng}`;
|
|
336
|
+
if (input?.radiusM !== void 0) query["radius"] = input.radiusM;
|
|
339
337
|
if (input?.minNodes !== void 0) query["min_nodes"] = input.minNodes;
|
|
340
338
|
if (input?.maxNodes !== void 0) query["max_nodes"] = input.maxNodes;
|
|
339
|
+
if (input?.limit !== void 0) query["limit"] = input.limit;
|
|
340
|
+
if (input?.cursor !== void 0) query["cursor"] = input.cursor;
|
|
341
341
|
return this.http.request({ path: "/exchange-zones", query });
|
|
342
342
|
}
|
|
343
|
+
/**
|
|
344
|
+
* Nearby Exchange Zones, closest first.
|
|
345
|
+
*
|
|
346
|
+
* Returns the ARRAY, not the `{ data, next_cursor }` envelope the endpoint
|
|
347
|
+
* sends: this used to return the envelope while its type promised an array,
|
|
348
|
+
* so `zones.length` was undefined and `.map` threw. Use `page()` when you need
|
|
349
|
+
* to read past the first page.
|
|
350
|
+
*/
|
|
351
|
+
async near(input) {
|
|
352
|
+
const { lat, lng, ...rest } = input;
|
|
353
|
+
const page = await this.page({ ...rest, near: { lat, lng } });
|
|
354
|
+
return page.data;
|
|
355
|
+
}
|
|
356
|
+
/** Every Exchange Zone your key can reach. Returns the array; see `page()` to paginate. */
|
|
357
|
+
async list(input) {
|
|
358
|
+
const page = await this.page(input);
|
|
359
|
+
return page.data;
|
|
360
|
+
}
|
|
343
361
|
/** Full detail: towers → nodes (includes each tower's parent_ble_id). */
|
|
344
362
|
get(exchangeZoneId) {
|
|
345
363
|
return this.http.request({ path: `/exchange-zones/${exchangeZoneId}` });
|
|
@@ -659,6 +677,20 @@ var RelaiClient = class {
|
|
|
659
677
|
flushTelemetry() {
|
|
660
678
|
return this.telemetryUploader.flush();
|
|
661
679
|
}
|
|
680
|
+
/**
|
|
681
|
+
* The signed-in end user, plus which app and environment they are in.
|
|
682
|
+
*
|
|
683
|
+
* Requires a session: call after `auth.verifyOtp`. A guest (no bearer token)
|
|
684
|
+
* gets `401 unauthorized`, because a shared guest identity is not a person to
|
|
685
|
+
* report. This is the client-side counterpart to `endUsers.list()`, which is
|
|
686
|
+
* server-only precisely because it returns OTHER people's details.
|
|
687
|
+
*
|
|
688
|
+
* Documented in the README and the build guide since 0.5, implemented in
|
|
689
|
+
* 0.12.0: it was named in both and never actually existed.
|
|
690
|
+
*/
|
|
691
|
+
me() {
|
|
692
|
+
return this.http.request({ path: "/me" });
|
|
693
|
+
}
|
|
662
694
|
/**
|
|
663
695
|
* Open a node: request the grant, then drive the physical unlock over the
|
|
664
696
|
* given transport (challenge → mint → write → ack). Throws
|
package/dist/index.d.cts
CHANGED
|
@@ -227,6 +227,28 @@ interface ExchangeZone {
|
|
|
227
227
|
timezone: string;
|
|
228
228
|
is_simulated: boolean;
|
|
229
229
|
}
|
|
230
|
+
/**
|
|
231
|
+
* One page of Exchange Zones, and the cursor to continue.
|
|
232
|
+
*
|
|
233
|
+
* `exchangeZones.list()` and `.near()` hand back the array on this and drop the
|
|
234
|
+
* cursor, because most callers want the nearest few and nothing more. Reach for
|
|
235
|
+
* `.page()` when you actually need to walk past the first page.
|
|
236
|
+
*/
|
|
237
|
+
interface ExchangeZonePage {
|
|
238
|
+
data: ExchangeZone[];
|
|
239
|
+
/** Pass as `cursor` for the next page. `null` means this was the last one. */
|
|
240
|
+
next_cursor: string | null;
|
|
241
|
+
}
|
|
242
|
+
/** The signed-in end user, and which app and environment they are signed into. */
|
|
243
|
+
interface Me {
|
|
244
|
+
user_id: string;
|
|
245
|
+
email: string | null;
|
|
246
|
+
name: string | null;
|
|
247
|
+
app: {
|
|
248
|
+
id: string;
|
|
249
|
+
environment: "sandbox" | "production";
|
|
250
|
+
};
|
|
251
|
+
}
|
|
230
252
|
interface TowerNode {
|
|
231
253
|
id: string;
|
|
232
254
|
tower_id: string;
|
|
@@ -304,6 +326,22 @@ declare class MemoryTokenStorage implements TokenStorage {
|
|
|
304
326
|
set(tokens: TokenPair): void;
|
|
305
327
|
clear(): void;
|
|
306
328
|
}
|
|
329
|
+
/**
|
|
330
|
+
* End-user identity: email OTP in, tokens held, tokens refreshed.
|
|
331
|
+
*
|
|
332
|
+
* GUEST MODE. There is deliberately no `signInAsGuest()`. A guest is not a kind
|
|
333
|
+
* of session, it is the absence of one: a request counts as a guest request when
|
|
334
|
+
* it carries the publishable key and NO end-user bearer token, which is exactly
|
|
335
|
+
* what this client sends while `isSignedIn` is false. So on an app with guest
|
|
336
|
+
* mode enabled (a portal setting, requiring open access and the open handoff
|
|
337
|
+
* mode), orders, unlocks, access-link resolution and telemetry all work without
|
|
338
|
+
* calling anything here at all. With guest mode off, those calls answer
|
|
339
|
+
* `401 unauthorized`.
|
|
340
|
+
*
|
|
341
|
+
* Every anonymous caller on an app shares ONE guest identity, so the single-use
|
|
342
|
+
* access link is the only credential that distinguishes two guests, and it is
|
|
343
|
+
* required for a guest pick-up even on an order a guest created.
|
|
344
|
+
*/
|
|
307
345
|
declare class AuthModule {
|
|
308
346
|
private readonly http;
|
|
309
347
|
private readonly storage;
|
|
@@ -338,7 +376,35 @@ declare class AuthModule {
|
|
|
338
376
|
declare class ExchangeZonesModule {
|
|
339
377
|
private readonly http;
|
|
340
378
|
constructor(http: HttpClient);
|
|
341
|
-
/**
|
|
379
|
+
/**
|
|
380
|
+
* ONE page of Exchange Zones, plus the cursor to continue. `list` and `near`
|
|
381
|
+
* wrap this and hand back just the array, which is what most callers want.
|
|
382
|
+
*/
|
|
383
|
+
page(input?: {
|
|
384
|
+
/** Filter to zones near a point, closest first. */
|
|
385
|
+
near?: {
|
|
386
|
+
lat: number;
|
|
387
|
+
lng: number;
|
|
388
|
+
};
|
|
389
|
+
/** Metres around `near`. Server clamps to 1..50000, default 2000. Ignored without `near`. */
|
|
390
|
+
radiusM?: number;
|
|
391
|
+
/** Only zones with at least this many compartments. */
|
|
392
|
+
minNodes?: number;
|
|
393
|
+
/** Only zones with at most this many compartments. */
|
|
394
|
+
maxNodes?: number;
|
|
395
|
+
/** 1 to 100. Defaults to 25. */
|
|
396
|
+
limit?: number;
|
|
397
|
+
/** `next_cursor` from a previous page. */
|
|
398
|
+
cursor?: string;
|
|
399
|
+
}): Promise<ExchangeZonePage>;
|
|
400
|
+
/**
|
|
401
|
+
* Nearby Exchange Zones, closest first.
|
|
402
|
+
*
|
|
403
|
+
* Returns the ARRAY, not the `{ data, next_cursor }` envelope the endpoint
|
|
404
|
+
* sends: this used to return the envelope while its type promised an array,
|
|
405
|
+
* so `zones.length` was undefined and `.map` threw. Use `page()` when you need
|
|
406
|
+
* to read past the first page.
|
|
407
|
+
*/
|
|
342
408
|
near(input: {
|
|
343
409
|
lat: number;
|
|
344
410
|
lng: number;
|
|
@@ -347,10 +413,15 @@ declare class ExchangeZonesModule {
|
|
|
347
413
|
minNodes?: number;
|
|
348
414
|
/** Only zones with at most this many compartments. */
|
|
349
415
|
maxNodes?: number;
|
|
416
|
+
/** 1 to 100. Defaults to 25. */
|
|
417
|
+
limit?: number;
|
|
350
418
|
}): Promise<ExchangeZone[]>;
|
|
419
|
+
/** Every Exchange Zone your key can reach. Returns the array; see `page()` to paginate. */
|
|
351
420
|
list(input?: {
|
|
352
421
|
minNodes?: number;
|
|
353
422
|
maxNodes?: number;
|
|
423
|
+
/** 1 to 100. Defaults to 25. */
|
|
424
|
+
limit?: number;
|
|
354
425
|
}): Promise<ExchangeZone[]>;
|
|
355
426
|
/** Full detail: towers → nodes (includes each tower's parent_ble_id). */
|
|
356
427
|
get(exchangeZoneId: string): Promise<ExchangeZoneDetail>;
|
|
@@ -796,6 +867,18 @@ declare class RelaiClient {
|
|
|
796
867
|
sent: number;
|
|
797
868
|
remaining: number;
|
|
798
869
|
}>;
|
|
870
|
+
/**
|
|
871
|
+
* The signed-in end user, plus which app and environment they are in.
|
|
872
|
+
*
|
|
873
|
+
* Requires a session: call after `auth.verifyOtp`. A guest (no bearer token)
|
|
874
|
+
* gets `401 unauthorized`, because a shared guest identity is not a person to
|
|
875
|
+
* report. This is the client-side counterpart to `endUsers.list()`, which is
|
|
876
|
+
* server-only precisely because it returns OTHER people's details.
|
|
877
|
+
*
|
|
878
|
+
* Documented in the README and the build guide since 0.5, implemented in
|
|
879
|
+
* 0.12.0: it was named in both and never actually existed.
|
|
880
|
+
*/
|
|
881
|
+
me(): Promise<Me>;
|
|
799
882
|
/**
|
|
800
883
|
* Open a node: request the grant, then drive the physical unlock over the
|
|
801
884
|
* given transport (challenge → mint → write → ack). Throws
|
package/dist/index.d.ts
CHANGED
|
@@ -227,6 +227,28 @@ interface ExchangeZone {
|
|
|
227
227
|
timezone: string;
|
|
228
228
|
is_simulated: boolean;
|
|
229
229
|
}
|
|
230
|
+
/**
|
|
231
|
+
* One page of Exchange Zones, and the cursor to continue.
|
|
232
|
+
*
|
|
233
|
+
* `exchangeZones.list()` and `.near()` hand back the array on this and drop the
|
|
234
|
+
* cursor, because most callers want the nearest few and nothing more. Reach for
|
|
235
|
+
* `.page()` when you actually need to walk past the first page.
|
|
236
|
+
*/
|
|
237
|
+
interface ExchangeZonePage {
|
|
238
|
+
data: ExchangeZone[];
|
|
239
|
+
/** Pass as `cursor` for the next page. `null` means this was the last one. */
|
|
240
|
+
next_cursor: string | null;
|
|
241
|
+
}
|
|
242
|
+
/** The signed-in end user, and which app and environment they are signed into. */
|
|
243
|
+
interface Me {
|
|
244
|
+
user_id: string;
|
|
245
|
+
email: string | null;
|
|
246
|
+
name: string | null;
|
|
247
|
+
app: {
|
|
248
|
+
id: string;
|
|
249
|
+
environment: "sandbox" | "production";
|
|
250
|
+
};
|
|
251
|
+
}
|
|
230
252
|
interface TowerNode {
|
|
231
253
|
id: string;
|
|
232
254
|
tower_id: string;
|
|
@@ -304,6 +326,22 @@ declare class MemoryTokenStorage implements TokenStorage {
|
|
|
304
326
|
set(tokens: TokenPair): void;
|
|
305
327
|
clear(): void;
|
|
306
328
|
}
|
|
329
|
+
/**
|
|
330
|
+
* End-user identity: email OTP in, tokens held, tokens refreshed.
|
|
331
|
+
*
|
|
332
|
+
* GUEST MODE. There is deliberately no `signInAsGuest()`. A guest is not a kind
|
|
333
|
+
* of session, it is the absence of one: a request counts as a guest request when
|
|
334
|
+
* it carries the publishable key and NO end-user bearer token, which is exactly
|
|
335
|
+
* what this client sends while `isSignedIn` is false. So on an app with guest
|
|
336
|
+
* mode enabled (a portal setting, requiring open access and the open handoff
|
|
337
|
+
* mode), orders, unlocks, access-link resolution and telemetry all work without
|
|
338
|
+
* calling anything here at all. With guest mode off, those calls answer
|
|
339
|
+
* `401 unauthorized`.
|
|
340
|
+
*
|
|
341
|
+
* Every anonymous caller on an app shares ONE guest identity, so the single-use
|
|
342
|
+
* access link is the only credential that distinguishes two guests, and it is
|
|
343
|
+
* required for a guest pick-up even on an order a guest created.
|
|
344
|
+
*/
|
|
307
345
|
declare class AuthModule {
|
|
308
346
|
private readonly http;
|
|
309
347
|
private readonly storage;
|
|
@@ -338,7 +376,35 @@ declare class AuthModule {
|
|
|
338
376
|
declare class ExchangeZonesModule {
|
|
339
377
|
private readonly http;
|
|
340
378
|
constructor(http: HttpClient);
|
|
341
|
-
/**
|
|
379
|
+
/**
|
|
380
|
+
* ONE page of Exchange Zones, plus the cursor to continue. `list` and `near`
|
|
381
|
+
* wrap this and hand back just the array, which is what most callers want.
|
|
382
|
+
*/
|
|
383
|
+
page(input?: {
|
|
384
|
+
/** Filter to zones near a point, closest first. */
|
|
385
|
+
near?: {
|
|
386
|
+
lat: number;
|
|
387
|
+
lng: number;
|
|
388
|
+
};
|
|
389
|
+
/** Metres around `near`. Server clamps to 1..50000, default 2000. Ignored without `near`. */
|
|
390
|
+
radiusM?: number;
|
|
391
|
+
/** Only zones with at least this many compartments. */
|
|
392
|
+
minNodes?: number;
|
|
393
|
+
/** Only zones with at most this many compartments. */
|
|
394
|
+
maxNodes?: number;
|
|
395
|
+
/** 1 to 100. Defaults to 25. */
|
|
396
|
+
limit?: number;
|
|
397
|
+
/** `next_cursor` from a previous page. */
|
|
398
|
+
cursor?: string;
|
|
399
|
+
}): Promise<ExchangeZonePage>;
|
|
400
|
+
/**
|
|
401
|
+
* Nearby Exchange Zones, closest first.
|
|
402
|
+
*
|
|
403
|
+
* Returns the ARRAY, not the `{ data, next_cursor }` envelope the endpoint
|
|
404
|
+
* sends: this used to return the envelope while its type promised an array,
|
|
405
|
+
* so `zones.length` was undefined and `.map` threw. Use `page()` when you need
|
|
406
|
+
* to read past the first page.
|
|
407
|
+
*/
|
|
342
408
|
near(input: {
|
|
343
409
|
lat: number;
|
|
344
410
|
lng: number;
|
|
@@ -347,10 +413,15 @@ declare class ExchangeZonesModule {
|
|
|
347
413
|
minNodes?: number;
|
|
348
414
|
/** Only zones with at most this many compartments. */
|
|
349
415
|
maxNodes?: number;
|
|
416
|
+
/** 1 to 100. Defaults to 25. */
|
|
417
|
+
limit?: number;
|
|
350
418
|
}): Promise<ExchangeZone[]>;
|
|
419
|
+
/** Every Exchange Zone your key can reach. Returns the array; see `page()` to paginate. */
|
|
351
420
|
list(input?: {
|
|
352
421
|
minNodes?: number;
|
|
353
422
|
maxNodes?: number;
|
|
423
|
+
/** 1 to 100. Defaults to 25. */
|
|
424
|
+
limit?: number;
|
|
354
425
|
}): Promise<ExchangeZone[]>;
|
|
355
426
|
/** Full detail: towers → nodes (includes each tower's parent_ble_id). */
|
|
356
427
|
get(exchangeZoneId: string): Promise<ExchangeZoneDetail>;
|
|
@@ -796,6 +867,18 @@ declare class RelaiClient {
|
|
|
796
867
|
sent: number;
|
|
797
868
|
remaining: number;
|
|
798
869
|
}>;
|
|
870
|
+
/**
|
|
871
|
+
* The signed-in end user, plus which app and environment they are in.
|
|
872
|
+
*
|
|
873
|
+
* Requires a session: call after `auth.verifyOtp`. A guest (no bearer token)
|
|
874
|
+
* gets `401 unauthorized`, because a shared guest identity is not a person to
|
|
875
|
+
* report. This is the client-side counterpart to `endUsers.list()`, which is
|
|
876
|
+
* server-only precisely because it returns OTHER people's details.
|
|
877
|
+
*
|
|
878
|
+
* Documented in the README and the build guide since 0.5, implemented in
|
|
879
|
+
* 0.12.0: it was named in both and never actually existed.
|
|
880
|
+
*/
|
|
881
|
+
me(): Promise<Me>;
|
|
799
882
|
/**
|
|
800
883
|
* Open a node: request the grant, then drive the physical unlock over the
|
|
801
884
|
* given transport (challenge → mint → write → ack). Throws
|
package/dist/index.js
CHANGED
|
@@ -209,20 +209,38 @@ var ExchangeZonesModule = class {
|
|
|
209
209
|
constructor(http) {
|
|
210
210
|
this.http = http;
|
|
211
211
|
}
|
|
212
|
-
/**
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
if (input.maxNodes !== void 0) query["max_nodes"] = input.maxNodes;
|
|
218
|
-
return this.http.request({ path: "/exchange-zones", query });
|
|
219
|
-
}
|
|
220
|
-
list(input) {
|
|
212
|
+
/**
|
|
213
|
+
* ONE page of Exchange Zones, plus the cursor to continue. `list` and `near`
|
|
214
|
+
* wrap this and hand back just the array, which is what most callers want.
|
|
215
|
+
*/
|
|
216
|
+
async page(input) {
|
|
221
217
|
const query = {};
|
|
218
|
+
if (input?.near) query["near"] = `${input.near.lat},${input.near.lng}`;
|
|
219
|
+
if (input?.radiusM !== void 0) query["radius"] = input.radiusM;
|
|
222
220
|
if (input?.minNodes !== void 0) query["min_nodes"] = input.minNodes;
|
|
223
221
|
if (input?.maxNodes !== void 0) query["max_nodes"] = input.maxNodes;
|
|
222
|
+
if (input?.limit !== void 0) query["limit"] = input.limit;
|
|
223
|
+
if (input?.cursor !== void 0) query["cursor"] = input.cursor;
|
|
224
224
|
return this.http.request({ path: "/exchange-zones", query });
|
|
225
225
|
}
|
|
226
|
+
/**
|
|
227
|
+
* Nearby Exchange Zones, closest first.
|
|
228
|
+
*
|
|
229
|
+
* Returns the ARRAY, not the `{ data, next_cursor }` envelope the endpoint
|
|
230
|
+
* sends: this used to return the envelope while its type promised an array,
|
|
231
|
+
* so `zones.length` was undefined and `.map` threw. Use `page()` when you need
|
|
232
|
+
* to read past the first page.
|
|
233
|
+
*/
|
|
234
|
+
async near(input) {
|
|
235
|
+
const { lat, lng, ...rest } = input;
|
|
236
|
+
const page = await this.page({ ...rest, near: { lat, lng } });
|
|
237
|
+
return page.data;
|
|
238
|
+
}
|
|
239
|
+
/** Every Exchange Zone your key can reach. Returns the array; see `page()` to paginate. */
|
|
240
|
+
async list(input) {
|
|
241
|
+
const page = await this.page(input);
|
|
242
|
+
return page.data;
|
|
243
|
+
}
|
|
226
244
|
/** Full detail: towers → nodes (includes each tower's parent_ble_id). */
|
|
227
245
|
get(exchangeZoneId) {
|
|
228
246
|
return this.http.request({ path: `/exchange-zones/${exchangeZoneId}` });
|
|
@@ -535,6 +553,20 @@ var RelaiClient = class {
|
|
|
535
553
|
flushTelemetry() {
|
|
536
554
|
return this.telemetryUploader.flush();
|
|
537
555
|
}
|
|
556
|
+
/**
|
|
557
|
+
* The signed-in end user, plus which app and environment they are in.
|
|
558
|
+
*
|
|
559
|
+
* Requires a session: call after `auth.verifyOtp`. A guest (no bearer token)
|
|
560
|
+
* gets `401 unauthorized`, because a shared guest identity is not a person to
|
|
561
|
+
* report. This is the client-side counterpart to `endUsers.list()`, which is
|
|
562
|
+
* server-only precisely because it returns OTHER people's details.
|
|
563
|
+
*
|
|
564
|
+
* Documented in the README and the build guide since 0.5, implemented in
|
|
565
|
+
* 0.12.0: it was named in both and never actually existed.
|
|
566
|
+
*/
|
|
567
|
+
me() {
|
|
568
|
+
return this.http.request({ path: "/me" });
|
|
569
|
+
}
|
|
538
570
|
/**
|
|
539
571
|
* Open a node: request the grant, then drive the physical unlock over the
|
|
540
572
|
* given transport (challenge → mint → write → ack). Throws
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@relai-team/access-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.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",
|