@relai-team/access-sdk 0.12.2 → 0.12.4

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.
package/dist/index.cjs CHANGED
@@ -171,7 +171,12 @@ var HttpClient = class {
171
171
  await sleep(retryDelayMs(res, i));
172
172
  continue;
173
173
  }
174
- throw await this.toApiError(res);
174
+ const apiErr = await this.toApiError(res);
175
+ if (apiErr.code === "idempotency_in_progress" && i < this.cfg.maxRetries) {
176
+ await sleep(retryDelayMs(res, i));
177
+ continue;
178
+ }
179
+ throw apiErr;
175
180
  }
176
181
  throw lastErr instanceof Error ? lastErr : new exports.RelaiError("Request failed");
177
182
  }
@@ -917,7 +922,14 @@ var SimAuthenticatedTransport = class {
917
922
  method: "POST",
918
923
  headers: {
919
924
  "content-type": "application/json",
920
- authorization: `Bearer ${this.publishableKey}`
925
+ // `x-relai-key`, NOT an Authorization bearer. The sim-Parent endpoints
926
+ // authenticate with the API key like every other /v1 route
927
+ // (`requireApiKey` reads this header and nothing else); the bearer
928
+ // scheme is for END-USER JWTs, which a Parent endpoint has no concept
929
+ // of. Sending the bearer meant every call here 401'd with
930
+ // `missing_publishable_key`, so this transport had never worked, in any
931
+ // released version, despite both docs pages recommending it.
932
+ "x-relai-key": this.publishableKey
921
933
  },
922
934
  body: JSON.stringify(body ?? {})
923
935
  });
package/dist/index.js CHANGED
@@ -55,7 +55,12 @@ var HttpClient = class {
55
55
  await sleep(retryDelayMs(res, i));
56
56
  continue;
57
57
  }
58
- throw await this.toApiError(res);
58
+ const apiErr = await this.toApiError(res);
59
+ if (apiErr.code === "idempotency_in_progress" && i < this.cfg.maxRetries) {
60
+ await sleep(retryDelayMs(res, i));
61
+ continue;
62
+ }
63
+ throw apiErr;
59
64
  }
60
65
  throw lastErr instanceof Error ? lastErr : new RelaiError("Request failed");
61
66
  }
@@ -789,7 +794,14 @@ var SimAuthenticatedTransport = class {
789
794
  method: "POST",
790
795
  headers: {
791
796
  "content-type": "application/json",
792
- authorization: `Bearer ${this.publishableKey}`
797
+ // `x-relai-key`, NOT an Authorization bearer. The sim-Parent endpoints
798
+ // authenticate with the API key like every other /v1 route
799
+ // (`requireApiKey` reads this header and nothing else); the bearer
800
+ // scheme is for END-USER JWTs, which a Parent endpoint has no concept
801
+ // of. Sending the bearer meant every call here 401'd with
802
+ // `missing_publishable_key`, so this transport had never worked, in any
803
+ // released version, despite both docs pages recommending it.
804
+ "x-relai-key": this.publishableKey
793
805
  },
794
806
  body: JSON.stringify(body ?? {})
795
807
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@relai-team/access-sdk",
3
- "version": "0.12.2",
3
+ "version": "0.12.4",
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",