@snowcone-app/sdk 0.2.0 → 0.2.1
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/CHANGELOG.md +12 -0
- package/dist/index.cjs +3 -4
- package/dist/index.d.cts +14 -2
- package/dist/index.d.ts +14 -2
- package/dist/index.js +3 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#233](https://github.com/snowcone-app/snowcone-monorepo/pull/233) [`8b08283`](https://github.com/snowcone-app/snowcone-monorepo/commit/8b0828340ea0d2852655bffe8436f0cb71bde3aa) Thanks [@kevinsproles](https://github.com/kevinsproles)! - fix(realtime): `mintRealtimeGrant` now honors the keyless publishable path
|
|
8
|
+
|
|
9
|
+
Omitting `apiKey` (or passing `undefined`/`null`/`''`) no longer sends a
|
|
10
|
+
broken `Authorization: Bearer undefined` header that 401s. The header is now
|
|
11
|
+
sent only when a key is actually provided, so `mintRealtimeGrant({ shop })`
|
|
12
|
+
uses the publishable shop-id path exactly as documented. `apiKey` is now typed
|
|
13
|
+
as optional.
|
|
14
|
+
|
|
3
15
|
## 0.2.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
|
@@ -5486,12 +5486,11 @@ ${versionToSend}
|
|
|
5486
5486
|
var DEFAULT_GRANT_BASE = "https://api.snowcone.app";
|
|
5487
5487
|
async function mintRealtimeGrant(opts) {
|
|
5488
5488
|
const f = opts.fetch ?? globalThis.fetch;
|
|
5489
|
+
const headers = { "Content-Type": "application/json" };
|
|
5490
|
+
if (opts.apiKey) headers.Authorization = `Bearer ${opts.apiKey}`;
|
|
5489
5491
|
const res = await f(`${opts.base ?? DEFAULT_GRANT_BASE}/realtime/grant`, {
|
|
5490
5492
|
method: "POST",
|
|
5491
|
-
headers
|
|
5492
|
-
"Content-Type": "application/json",
|
|
5493
|
-
Authorization: `Bearer ${opts.apiKey}`
|
|
5494
|
-
},
|
|
5493
|
+
headers,
|
|
5495
5494
|
body: JSON.stringify({ shop: opts.shop })
|
|
5496
5495
|
});
|
|
5497
5496
|
if (!res.ok) {
|
package/dist/index.d.cts
CHANGED
|
@@ -2518,14 +2518,26 @@ declare const DEFAULT_GRANT_BASE = "https://api.snowcone.app";
|
|
|
2518
2518
|
* own the target `shop`. Returns a 60s grant your browser code opens the WS
|
|
2519
2519
|
* with (hand it down via your own endpoint + {@link fetchRealtimeGrant}).
|
|
2520
2520
|
*
|
|
2521
|
+
* Omit `apiKey` (or pass `undefined`/`null`/`''`) to use the **keyless
|
|
2522
|
+
* publishable path**: no `Authorization` header is sent and the grant is
|
|
2523
|
+
* authorized by the publishable `shop` id alone. Passing a key uses the
|
|
2524
|
+
* secret (sk_) path.
|
|
2525
|
+
*
|
|
2521
2526
|
* @example
|
|
2522
2527
|
* // your backend route: POST /api/realtime/grant
|
|
2523
2528
|
* const grant = await mintRealtimeGrant({ apiKey: process.env.SNOWCONE_API_KEY!, shop });
|
|
2524
2529
|
* return Response.json(grant);
|
|
2530
|
+
*
|
|
2531
|
+
* @example
|
|
2532
|
+
* // keyless publishable path — quick trials, no API key:
|
|
2533
|
+
* const grant = await mintRealtimeGrant({ shop });
|
|
2525
2534
|
*/
|
|
2526
2535
|
declare function mintRealtimeGrant(opts: {
|
|
2527
|
-
/**
|
|
2528
|
-
|
|
2536
|
+
/**
|
|
2537
|
+
* Secret API key (sk_) with the `mockups:realtime` or `mockups` scope.
|
|
2538
|
+
* Omit (or pass `undefined`/`null`/`''`) for the keyless publishable path.
|
|
2539
|
+
*/
|
|
2540
|
+
apiKey?: string | null;
|
|
2529
2541
|
/** Target shop id (= shop.id). Must belong to the key's organization. */
|
|
2530
2542
|
shop: string;
|
|
2531
2543
|
/** Backend base URL. Defaults to {@link DEFAULT_GRANT_BASE}. */
|
package/dist/index.d.ts
CHANGED
|
@@ -2518,14 +2518,26 @@ declare const DEFAULT_GRANT_BASE = "https://api.snowcone.app";
|
|
|
2518
2518
|
* own the target `shop`. Returns a 60s grant your browser code opens the WS
|
|
2519
2519
|
* with (hand it down via your own endpoint + {@link fetchRealtimeGrant}).
|
|
2520
2520
|
*
|
|
2521
|
+
* Omit `apiKey` (or pass `undefined`/`null`/`''`) to use the **keyless
|
|
2522
|
+
* publishable path**: no `Authorization` header is sent and the grant is
|
|
2523
|
+
* authorized by the publishable `shop` id alone. Passing a key uses the
|
|
2524
|
+
* secret (sk_) path.
|
|
2525
|
+
*
|
|
2521
2526
|
* @example
|
|
2522
2527
|
* // your backend route: POST /api/realtime/grant
|
|
2523
2528
|
* const grant = await mintRealtimeGrant({ apiKey: process.env.SNOWCONE_API_KEY!, shop });
|
|
2524
2529
|
* return Response.json(grant);
|
|
2530
|
+
*
|
|
2531
|
+
* @example
|
|
2532
|
+
* // keyless publishable path — quick trials, no API key:
|
|
2533
|
+
* const grant = await mintRealtimeGrant({ shop });
|
|
2525
2534
|
*/
|
|
2526
2535
|
declare function mintRealtimeGrant(opts: {
|
|
2527
|
-
/**
|
|
2528
|
-
|
|
2536
|
+
/**
|
|
2537
|
+
* Secret API key (sk_) with the `mockups:realtime` or `mockups` scope.
|
|
2538
|
+
* Omit (or pass `undefined`/`null`/`''`) for the keyless publishable path.
|
|
2539
|
+
*/
|
|
2540
|
+
apiKey?: string | null;
|
|
2529
2541
|
/** Target shop id (= shop.id). Must belong to the key's organization. */
|
|
2530
2542
|
shop: string;
|
|
2531
2543
|
/** Backend base URL. Defaults to {@link DEFAULT_GRANT_BASE}. */
|
package/dist/index.js
CHANGED
|
@@ -4653,12 +4653,11 @@ function createSvelteComponent(descriptor, svelte) {
|
|
|
4653
4653
|
var DEFAULT_GRANT_BASE = "https://api.snowcone.app";
|
|
4654
4654
|
async function mintRealtimeGrant(opts) {
|
|
4655
4655
|
const f = opts.fetch ?? globalThis.fetch;
|
|
4656
|
+
const headers = { "Content-Type": "application/json" };
|
|
4657
|
+
if (opts.apiKey) headers.Authorization = `Bearer ${opts.apiKey}`;
|
|
4656
4658
|
const res = await f(`${opts.base ?? DEFAULT_GRANT_BASE}/realtime/grant`, {
|
|
4657
4659
|
method: "POST",
|
|
4658
|
-
headers
|
|
4659
|
-
"Content-Type": "application/json",
|
|
4660
|
-
Authorization: `Bearer ${opts.apiKey}`
|
|
4661
|
-
},
|
|
4660
|
+
headers,
|
|
4662
4661
|
body: JSON.stringify({ shop: opts.shop })
|
|
4663
4662
|
});
|
|
4664
4663
|
if (!res.ok) {
|