@relai-team/access-sdk 0.12.1 → 0.12.3

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
@@ -376,7 +376,14 @@ them (delivery is enabled server-side per app):
376
376
  ```ts
377
377
  await fetch(`${baseUrl}/push/tokens`, {
378
378
  method: "POST",
379
- headers: { authorization: `Bearer ${endUserAccessToken}`, "content-type": "application/json" },
379
+ headers: {
380
+ // BOTH headers. The route authenticates the app with the API key first and
381
+ // the person with the bearer second, so a bearer alone answers
382
+ // 401 missing_publishable_key while your token is perfectly valid.
383
+ "x-relai-key": publishableKey,
384
+ authorization: `Bearer ${endUserAccessToken}`,
385
+ "content-type": "application/json",
386
+ },
380
387
  body: JSON.stringify({ token: expoPushToken, platform: "expo" }),
381
388
  });
382
389
  // DELETE the same route on sign-out.
@@ -408,6 +415,20 @@ await client.flushTelemetry();
408
415
  The queue caps at 500 items (oldest dropped) and self-heals from a corrupt
409
416
  blob. Telemetry never blocks or fails an unlock.
410
417
 
418
+ ## The contract this package is checked against
419
+
420
+ The platform publishes its OpenAPI 3.1 description at
421
+ [access.relai.us/openapi.json](https://access.relai.us/openapi.json), public and
422
+ unauthenticated. This package vendors a copy, generates types from it, and fails
423
+ its own typecheck if the hand-written wire types drift from it.
424
+
425
+ ```bash
426
+ npm run spec:sync # refresh the vendored spec and regenerate
427
+ npm run spec:check # fail if the committed types are stale
428
+ ```
429
+
430
+ Generate your own client from the same URL if you would rather not use this one.
431
+
411
432
  ## Verifying webhooks (partner backends)
412
433
 
413
434
  ```ts
package/dist/index.cjs CHANGED
@@ -917,7 +917,14 @@ var SimAuthenticatedTransport = class {
917
917
  method: "POST",
918
918
  headers: {
919
919
  "content-type": "application/json",
920
- authorization: `Bearer ${this.publishableKey}`
920
+ // `x-relai-key`, NOT an Authorization bearer. The sim-Parent endpoints
921
+ // authenticate with the API key like every other /v1 route
922
+ // (`requireApiKey` reads this header and nothing else); the bearer
923
+ // scheme is for END-USER JWTs, which a Parent endpoint has no concept
924
+ // of. Sending the bearer meant every call here 401'd with
925
+ // `missing_publishable_key`, so this transport had never worked, in any
926
+ // released version, despite both docs pages recommending it.
927
+ "x-relai-key": this.publishableKey
921
928
  },
922
929
  body: JSON.stringify(body ?? {})
923
930
  });
package/dist/index.js CHANGED
@@ -789,7 +789,14 @@ var SimAuthenticatedTransport = class {
789
789
  method: "POST",
790
790
  headers: {
791
791
  "content-type": "application/json",
792
- authorization: `Bearer ${this.publishableKey}`
792
+ // `x-relai-key`, NOT an Authorization bearer. The sim-Parent endpoints
793
+ // authenticate with the API key like every other /v1 route
794
+ // (`requireApiKey` reads this header and nothing else); the bearer
795
+ // scheme is for END-USER JWTs, which a Parent endpoint has no concept
796
+ // of. Sending the bearer meant every call here 401'd with
797
+ // `missing_publishable_key`, so this transport had never worked, in any
798
+ // released version, despite both docs pages recommending it.
799
+ "x-relai-key": this.publishableKey
793
800
  },
794
801
  body: JSON.stringify(body ?? {})
795
802
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@relai-team/access-sdk",
3
- "version": "0.12.1",
3
+ "version": "0.12.3",
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",
@@ -24,7 +24,10 @@
24
24
  "build": "tsup",
25
25
  "typecheck": "tsc --noEmit",
26
26
  "test": "vitest run",
27
- "test:watch": "vitest"
27
+ "test:watch": "vitest",
28
+ "spec:types": "openapi-typescript openapi.json -o src/generated/api.ts",
29
+ "spec:check": "npm run spec:types && git diff --exit-code src/generated/api.ts",
30
+ "spec:sync": "curl -fsS https://access.relai.us/openapi.json -o openapi.json && npm run spec:types"
28
31
  },
29
32
  "keywords": [
30
33
  "relai",
@@ -34,8 +37,8 @@
34
37
  "exchange-zone"
35
38
  ],
36
39
  "peerDependencies": {
37
- "react-native-ble-plx": ">=3.0.0",
38
- "@stripe/stripe-react-native": ">=0.38"
40
+ "@stripe/stripe-react-native": ">=0.38",
41
+ "react-native-ble-plx": ">=3.0.0"
39
42
  },
40
43
  "peerDependenciesMeta": {
41
44
  "react-native-ble-plx": {
@@ -47,6 +50,7 @@
47
50
  },
48
51
  "devDependencies": {
49
52
  "@types/node": "^20.14.0",
53
+ "openapi-typescript": "^7.13.0",
50
54
  "tsup": "^8.3.0",
51
55
  "typescript": "^5.6.0",
52
56
  "vitest": "^2.1.0"