@01.software/sdk 0.8.0 → 0.9.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 +16 -18
- package/dist/{const-dv0zuAxG.d.cts → const-DZ04SC2y.d.cts} +1 -1
- package/dist/{const-CCh99Gxu.d.ts → const-hXu9oG66.d.ts} +1 -1
- package/dist/index.cjs +48 -164
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -33
- package/dist/index.d.ts +21 -33
- package/dist/index.js +48 -164
- package/dist/index.js.map +1 -1
- package/dist/{payload-types-FfZ2Zxp1.d.cts → payload-types-DICC2-Zr.d.cts} +120 -25
- package/dist/{payload-types-FfZ2Zxp1.d.ts → payload-types-DICC2-Zr.d.ts} +120 -25
- package/dist/{realtime-DupPIYx-.d.cts → realtime-D7HtUpqt.d.cts} +2 -2
- package/dist/{realtime-DupPIYx-.d.ts → realtime-D7HtUpqt.d.ts} +2 -2
- package/dist/realtime.cjs +8 -7
- package/dist/realtime.cjs.map +1 -1
- package/dist/realtime.d.cts +6 -6
- package/dist/realtime.d.ts +6 -6
- package/dist/realtime.js +8 -7
- package/dist/realtime.js.map +1 -1
- package/dist/{server-DxhuG-_s.d.cts → server-JR9TvKZ5.d.cts} +0 -2
- package/dist/{server-DxhuG-_s.d.ts → server-JR9TvKZ5.d.ts} +0 -2
- package/dist/ui/canvas/server.cjs +1 -2
- package/dist/ui/canvas/server.cjs.map +1 -1
- package/dist/ui/canvas/server.d.cts +1 -1
- package/dist/ui/canvas/server.d.ts +1 -1
- package/dist/ui/canvas/server.js +1 -2
- package/dist/ui/canvas/server.js.map +1 -1
- package/dist/ui/canvas.cjs +1 -2
- package/dist/ui/canvas.cjs.map +1 -1
- package/dist/ui/canvas.d.cts +2 -2
- package/dist/ui/canvas.d.ts +2 -2
- package/dist/ui/canvas.js +1 -2
- package/dist/ui/canvas.js.map +1 -1
- package/dist/ui/form.d.cts +1 -1
- package/dist/ui/form.d.ts +1 -1
- package/dist/ui/video.d.cts +1 -1
- package/dist/ui/video.d.ts +1 -1
- package/dist/{webhook-B9MDrH22.d.ts → webhook-BD9ivfyR.d.ts} +2 -2
- package/dist/{webhook-t7JGFLKQ.d.cts → webhook-D8ogsafv.d.cts} +2 -2
- package/dist/webhook.d.cts +3 -3
- package/dist/webhook.d.ts +3 -3
- package/package.json +3 -13
- package/dist/auth.cjs +0 -109
- package/dist/auth.cjs.map +0 -1
- package/dist/auth.d.cts +0 -36
- package/dist/auth.d.ts +0 -36
- package/dist/auth.js +0 -86
- package/dist/auth.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,82 +1,3 @@
|
|
|
1
|
-
// src/core/internal/utils/jwt.ts
|
|
2
|
-
import { SignJWT, jwtVerify, decodeJwt } from "jose";
|
|
3
|
-
async function createServerToken(clientKey, secretKey, expiresIn = "1h") {
|
|
4
|
-
if (!clientKey || !secretKey) {
|
|
5
|
-
throw new Error("clientKey and secretKey are required.");
|
|
6
|
-
}
|
|
7
|
-
const secret = new TextEncoder().encode(secretKey);
|
|
8
|
-
return new SignJWT({ clientKey }).setProtectedHeader({ alg: "HS256" }).setIssuedAt().setExpirationTime(expiresIn).sign(secret);
|
|
9
|
-
}
|
|
10
|
-
async function verifyServerToken(token, secretKey) {
|
|
11
|
-
if (!token || !secretKey) {
|
|
12
|
-
throw new Error("token and secretKey are required.");
|
|
13
|
-
}
|
|
14
|
-
const secret = new TextEncoder().encode(secretKey);
|
|
15
|
-
const { payload } = await jwtVerify(token, secret, {
|
|
16
|
-
algorithms: ["HS256"]
|
|
17
|
-
});
|
|
18
|
-
if (!payload.clientKey || typeof payload.clientKey !== "string") {
|
|
19
|
-
throw new Error("Invalid token payload: clientKey is missing");
|
|
20
|
-
}
|
|
21
|
-
return {
|
|
22
|
-
clientKey: payload.clientKey,
|
|
23
|
-
iat: payload.iat,
|
|
24
|
-
exp: payload.exp
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
function decodeServerToken(token) {
|
|
28
|
-
if (!token) {
|
|
29
|
-
throw new Error("token is required.");
|
|
30
|
-
}
|
|
31
|
-
const payload = decodeJwt(token);
|
|
32
|
-
if (!payload.clientKey || typeof payload.clientKey !== "string") {
|
|
33
|
-
throw new Error("Invalid token payload: clientKey is missing");
|
|
34
|
-
}
|
|
35
|
-
return {
|
|
36
|
-
clientKey: payload.clientKey,
|
|
37
|
-
iat: payload.iat,
|
|
38
|
-
exp: payload.exp
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// src/core/internal/utils/encoding.ts
|
|
43
|
-
function createApiKey(clientKey, secretKey) {
|
|
44
|
-
if (!clientKey || !secretKey) {
|
|
45
|
-
throw new Error("clientKey and secretKey are required.");
|
|
46
|
-
}
|
|
47
|
-
if (typeof Buffer !== "undefined") {
|
|
48
|
-
return Buffer.from(`${clientKey}:${secretKey}`).toString("base64");
|
|
49
|
-
}
|
|
50
|
-
return btoa(`${clientKey}:${secretKey}`);
|
|
51
|
-
}
|
|
52
|
-
function parseApiKey(apiKey) {
|
|
53
|
-
if (!apiKey) {
|
|
54
|
-
throw new Error("apiKey is required.");
|
|
55
|
-
}
|
|
56
|
-
try {
|
|
57
|
-
let decoded;
|
|
58
|
-
if (typeof Buffer !== "undefined") {
|
|
59
|
-
decoded = Buffer.from(apiKey, "base64").toString("utf-8");
|
|
60
|
-
} else {
|
|
61
|
-
decoded = atob(apiKey);
|
|
62
|
-
}
|
|
63
|
-
const colonIndex = decoded.indexOf(":");
|
|
64
|
-
if (colonIndex === -1) {
|
|
65
|
-
throw new Error("Invalid format: missing colon separator");
|
|
66
|
-
}
|
|
67
|
-
const clientKey = decoded.substring(0, colonIndex);
|
|
68
|
-
const secretKey = decoded.substring(colonIndex + 1);
|
|
69
|
-
if (!clientKey || !secretKey) {
|
|
70
|
-
throw new Error("Invalid format: empty clientKey or secretKey");
|
|
71
|
-
}
|
|
72
|
-
return { clientKey, secretKey };
|
|
73
|
-
} catch {
|
|
74
|
-
throw new Error(
|
|
75
|
-
'Invalid API key. Expected Base64 encoded "clientKey:secretKey"'
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
1
|
// src/core/internal/errors/index.ts
|
|
81
2
|
var SDKError = class extends Error {
|
|
82
3
|
constructor(code, message, status, details, userMessage, suggestion) {
|
|
@@ -197,7 +118,6 @@ function isUsageLimitError(error) {
|
|
|
197
118
|
return error instanceof UsageLimitError;
|
|
198
119
|
}
|
|
199
120
|
var createNetworkError = (message, status, details, userMessage, suggestion) => new NetworkError(message, status, details, userMessage, suggestion);
|
|
200
|
-
var createValidationError = (message, details, userMessage, suggestion) => new ValidationError(message, details, userMessage, suggestion);
|
|
201
121
|
var createApiError = (message, status, details, userMessage, suggestion) => new ApiError(message, status, details, userMessage, suggestion);
|
|
202
122
|
var createConfigError = (message, details, userMessage, suggestion) => new ConfigError(message, details, userMessage, suggestion);
|
|
203
123
|
var createTimeoutError = (message, details, userMessage, suggestion) => new TimeoutError(message, details, userMessage, suggestion);
|
|
@@ -291,24 +211,24 @@ async function delay(ms) {
|
|
|
291
211
|
}
|
|
292
212
|
async function httpFetch(url, options) {
|
|
293
213
|
const {
|
|
294
|
-
|
|
214
|
+
publishableKey,
|
|
295
215
|
secretKey,
|
|
296
216
|
customerToken,
|
|
297
217
|
timeout = DEFAULT_TIMEOUT,
|
|
298
|
-
baseUrl = resolveApiUrl(),
|
|
299
218
|
debug,
|
|
300
219
|
retry,
|
|
301
220
|
onUnauthorized,
|
|
302
221
|
...requestInit
|
|
303
222
|
} = options || {};
|
|
223
|
+
const baseUrl = resolveApiUrl();
|
|
304
224
|
const retryConfig = {
|
|
305
225
|
maxRetries: retry?.maxRetries ?? 3,
|
|
306
226
|
retryableStatuses: retry?.retryableStatuses ?? DEFAULT_RETRYABLE_STATUSES,
|
|
307
227
|
retryDelay: retry?.retryDelay ?? ((attempt) => Math.min(1e3 * 2 ** attempt, 1e4))
|
|
308
228
|
};
|
|
309
229
|
let authToken;
|
|
310
|
-
if (secretKey
|
|
311
|
-
authToken =
|
|
230
|
+
if (secretKey) {
|
|
231
|
+
authToken = secretKey;
|
|
312
232
|
} else if (customerToken) {
|
|
313
233
|
authToken = customerToken;
|
|
314
234
|
}
|
|
@@ -317,8 +237,8 @@ async function httpFetch(url, options) {
|
|
|
317
237
|
for (let attempt = 0; attempt <= retryConfig.maxRetries; attempt++) {
|
|
318
238
|
try {
|
|
319
239
|
const headers = new Headers(requestInit.headers);
|
|
320
|
-
if (
|
|
321
|
-
headers.set("X-
|
|
240
|
+
if (publishableKey) {
|
|
241
|
+
headers.set("X-Publishable-Key", publishableKey);
|
|
322
242
|
}
|
|
323
243
|
if (authToken) {
|
|
324
244
|
headers.set("Authorization", `Bearer ${authToken}`);
|
|
@@ -509,23 +429,18 @@ async function parseApiResponse(response, endpoint) {
|
|
|
509
429
|
// src/core/api/base-api.ts
|
|
510
430
|
var BaseApi = class {
|
|
511
431
|
constructor(apiName, options) {
|
|
512
|
-
if (!options.clientKey) {
|
|
513
|
-
throw createConfigError(`clientKey is required for ${apiName}.`);
|
|
514
|
-
}
|
|
515
432
|
if (!options.secretKey) {
|
|
516
433
|
throw createConfigError(`secretKey is required for ${apiName}.`);
|
|
517
434
|
}
|
|
518
|
-
this.
|
|
435
|
+
this.publishableKey = options.publishableKey ?? "";
|
|
519
436
|
this.secretKey = options.secretKey;
|
|
520
|
-
this.baseUrl = options.baseUrl;
|
|
521
437
|
}
|
|
522
438
|
async request(endpoint, body, options) {
|
|
523
439
|
const method = options?.method ?? "POST";
|
|
524
440
|
const response = await httpFetch(endpoint, {
|
|
525
441
|
method,
|
|
526
|
-
|
|
442
|
+
publishableKey: this.publishableKey,
|
|
527
443
|
secretKey: this.secretKey,
|
|
528
|
-
baseUrl: this.baseUrl,
|
|
529
444
|
...body !== void 0 && { body: JSON.stringify(body) },
|
|
530
445
|
...options?.headers && { headers: options.headers }
|
|
531
446
|
});
|
|
@@ -588,28 +503,23 @@ var OrderApi = class extends BaseApi {
|
|
|
588
503
|
// src/core/api/cart-api.ts
|
|
589
504
|
var CartApi = class {
|
|
590
505
|
constructor(options) {
|
|
591
|
-
if (!options.clientKey) {
|
|
592
|
-
throw createConfigError("clientKey is required for CartApi.");
|
|
593
|
-
}
|
|
594
506
|
if (!options.secretKey && !options.customerToken) {
|
|
595
507
|
throw createConfigError(
|
|
596
508
|
"Either secretKey or customerToken is required for CartApi."
|
|
597
509
|
);
|
|
598
510
|
}
|
|
599
|
-
this.
|
|
511
|
+
this.publishableKey = options.publishableKey ?? "";
|
|
600
512
|
this.secretKey = options.secretKey;
|
|
601
513
|
this.customerToken = options.customerToken;
|
|
602
|
-
this.baseUrl = options.baseUrl;
|
|
603
514
|
this.onUnauthorized = options.onUnauthorized;
|
|
604
515
|
}
|
|
605
516
|
async execute(endpoint, method, body) {
|
|
606
517
|
const token = typeof this.customerToken === "function" ? this.customerToken() : this.customerToken;
|
|
607
518
|
const response = await httpFetch(endpoint, {
|
|
608
519
|
method,
|
|
609
|
-
|
|
520
|
+
publishableKey: this.publishableKey,
|
|
610
521
|
secretKey: this.secretKey,
|
|
611
522
|
customerToken: token ?? void 0,
|
|
612
|
-
baseUrl: this.baseUrl,
|
|
613
523
|
...token && this.onUnauthorized && { onUnauthorized: this.onUnauthorized },
|
|
614
524
|
...body !== void 0 && { body: JSON.stringify(body) }
|
|
615
525
|
});
|
|
@@ -856,21 +766,16 @@ var CollectionQueryBuilder = class {
|
|
|
856
766
|
// src/core/collection/http-client.ts
|
|
857
767
|
import { stringify } from "qs-esm";
|
|
858
768
|
var HttpClient = class {
|
|
859
|
-
constructor(
|
|
860
|
-
|
|
861
|
-
throw createValidationError("clientKey is required.");
|
|
862
|
-
}
|
|
863
|
-
this.clientKey = clientKey;
|
|
769
|
+
constructor(publishableKey, secretKey, getCustomerToken, onUnauthorized) {
|
|
770
|
+
this.publishableKey = publishableKey;
|
|
864
771
|
this.secretKey = secretKey;
|
|
865
|
-
this.baseUrl = baseUrl;
|
|
866
772
|
this.getCustomerToken = getCustomerToken;
|
|
867
773
|
this.onUnauthorized = onUnauthorized;
|
|
868
774
|
}
|
|
869
775
|
get defaultOptions() {
|
|
870
776
|
const opts = {
|
|
871
|
-
|
|
872
|
-
secretKey: this.secretKey
|
|
873
|
-
baseUrl: this.baseUrl
|
|
777
|
+
publishableKey: this.publishableKey,
|
|
778
|
+
secretKey: this.secretKey
|
|
874
779
|
};
|
|
875
780
|
const token = this.getCustomerToken?.();
|
|
876
781
|
if (token) {
|
|
@@ -985,9 +890,6 @@ function buildPayloadFormData(data, file, filename) {
|
|
|
985
890
|
return formData;
|
|
986
891
|
}
|
|
987
892
|
var CollectionClient = class extends HttpClient {
|
|
988
|
-
constructor(clientKey, secretKey, baseUrl, getCustomerToken, onUnauthorized) {
|
|
989
|
-
super(clientKey, secretKey, baseUrl, getCustomerToken, onUnauthorized);
|
|
990
|
-
}
|
|
991
893
|
from(collection) {
|
|
992
894
|
return new CollectionQueryBuilder(this, collection);
|
|
993
895
|
}
|
|
@@ -1189,23 +1091,18 @@ var COLLECTIONS = [
|
|
|
1189
1091
|
// src/core/community/community-client.ts
|
|
1190
1092
|
var CommunityClient = class {
|
|
1191
1093
|
constructor(options) {
|
|
1192
|
-
|
|
1193
|
-
throw createConfigError("clientKey is required for CommunityClient.");
|
|
1194
|
-
}
|
|
1195
|
-
this.clientKey = options.clientKey;
|
|
1094
|
+
this.publishableKey = options.publishableKey ?? "";
|
|
1196
1095
|
this.secretKey = options.secretKey;
|
|
1197
1096
|
this.customerToken = options.customerToken;
|
|
1198
|
-
this.baseUrl = options.baseUrl;
|
|
1199
1097
|
this.onUnauthorized = options.onUnauthorized;
|
|
1200
1098
|
}
|
|
1201
1099
|
async execute(endpoint, method, body) {
|
|
1202
1100
|
const token = typeof this.customerToken === "function" ? this.customerToken() : this.customerToken;
|
|
1203
1101
|
const response = await httpFetch(endpoint, {
|
|
1204
1102
|
method,
|
|
1205
|
-
|
|
1103
|
+
publishableKey: this.publishableKey,
|
|
1206
1104
|
secretKey: this.secretKey,
|
|
1207
1105
|
customerToken: token ?? void 0,
|
|
1208
|
-
baseUrl: this.baseUrl,
|
|
1209
1106
|
...token && this.onUnauthorized && { onUnauthorized: this.onUnauthorized },
|
|
1210
1107
|
...body !== void 0 && { body: JSON.stringify(body) }
|
|
1211
1108
|
});
|
|
@@ -1382,10 +1279,10 @@ function safeGetItem(key) {
|
|
|
1382
1279
|
}
|
|
1383
1280
|
}
|
|
1384
1281
|
var CustomerAuth = class {
|
|
1385
|
-
constructor(
|
|
1282
|
+
constructor(publishableKey, options) {
|
|
1386
1283
|
this.refreshPromise = null;
|
|
1387
|
-
this.
|
|
1388
|
-
this.baseUrl =
|
|
1284
|
+
this.publishableKey = publishableKey;
|
|
1285
|
+
this.baseUrl = resolveApiUrl();
|
|
1389
1286
|
const persist = options?.persist ?? true;
|
|
1390
1287
|
if (persist) {
|
|
1391
1288
|
const key = typeof persist === "string" ? persist : "customer-token";
|
|
@@ -1571,7 +1468,7 @@ var CustomerAuth = class {
|
|
|
1571
1468
|
*/
|
|
1572
1469
|
async requestJson(path, init) {
|
|
1573
1470
|
const headers = new Headers(init.headers);
|
|
1574
|
-
headers.set("X-
|
|
1471
|
+
headers.set("X-Publishable-Key", this.publishableKey);
|
|
1575
1472
|
if (!headers.has("Content-Type") && init.body) {
|
|
1576
1473
|
headers.set("Content-Type", "application/json");
|
|
1577
1474
|
}
|
|
@@ -2064,11 +1961,11 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
2064
1961
|
// src/core/client/client.ts
|
|
2065
1962
|
var Client = class {
|
|
2066
1963
|
constructor(options) {
|
|
2067
|
-
|
|
2068
|
-
|
|
1964
|
+
const publishableKey = options.publishableKey;
|
|
1965
|
+
if (!publishableKey) {
|
|
1966
|
+
throw createConfigError("publishableKey is required.");
|
|
2069
1967
|
}
|
|
2070
|
-
this.config = { ...options };
|
|
2071
|
-
this.baseUrl = resolveApiUrl();
|
|
1968
|
+
this.config = { ...options, publishableKey };
|
|
2072
1969
|
const metadata = {
|
|
2073
1970
|
timestamp: Date.now(),
|
|
2074
1971
|
userAgent: typeof window !== "undefined" ? window.navigator?.userAgent : "Node.js"
|
|
@@ -2076,8 +1973,7 @@ var Client = class {
|
|
|
2076
1973
|
this.state = { metadata };
|
|
2077
1974
|
this.queryClient = getQueryClient();
|
|
2078
1975
|
this.customer = new CustomerAuth(
|
|
2079
|
-
this.config.
|
|
2080
|
-
this.baseUrl,
|
|
1976
|
+
this.config.publishableKey,
|
|
2081
1977
|
options.customer
|
|
2082
1978
|
);
|
|
2083
1979
|
const onUnauthorized = async () => {
|
|
@@ -2089,21 +1985,18 @@ var Client = class {
|
|
|
2089
1985
|
}
|
|
2090
1986
|
};
|
|
2091
1987
|
this.cart = new CartApi({
|
|
2092
|
-
|
|
1988
|
+
publishableKey: this.config.publishableKey,
|
|
2093
1989
|
customerToken: () => this.customer.getToken(),
|
|
2094
|
-
baseUrl: this.baseUrl,
|
|
2095
1990
|
onUnauthorized
|
|
2096
1991
|
});
|
|
2097
1992
|
this.community = new CommunityClient({
|
|
2098
|
-
|
|
1993
|
+
publishableKey: this.config.publishableKey,
|
|
2099
1994
|
customerToken: () => this.customer.getToken(),
|
|
2100
|
-
baseUrl: this.baseUrl,
|
|
2101
1995
|
onUnauthorized
|
|
2102
1996
|
});
|
|
2103
1997
|
this.collections = new CollectionClient(
|
|
2104
|
-
this.config.
|
|
1998
|
+
this.config.publishableKey,
|
|
2105
1999
|
void 0,
|
|
2106
|
-
this.baseUrl,
|
|
2107
2000
|
() => this.customer.getToken(),
|
|
2108
2001
|
onUnauthorized
|
|
2109
2002
|
);
|
|
@@ -2135,43 +2028,39 @@ var ServerClient = class {
|
|
|
2135
2028
|
"ServerClient must not be used in a browser environment. This risks exposing your secretKey in client bundles. Use createClient() for browser code instead."
|
|
2136
2029
|
);
|
|
2137
2030
|
}
|
|
2138
|
-
if (!options.clientKey) {
|
|
2139
|
-
throw createConfigError("clientKey is required.");
|
|
2140
|
-
}
|
|
2141
2031
|
if (!options.secretKey) {
|
|
2142
2032
|
throw createConfigError("secretKey is required.");
|
|
2143
2033
|
}
|
|
2144
|
-
|
|
2145
|
-
|
|
2034
|
+
if (!options.publishableKey) {
|
|
2035
|
+
throw createConfigError(
|
|
2036
|
+
"publishableKey is required. It is used for rate limiting and monthly quota enforcement via the X-Publishable-Key header. Get it from Console > Settings > API Keys."
|
|
2037
|
+
);
|
|
2038
|
+
}
|
|
2039
|
+
this.config = { ...options, publishableKey: options.publishableKey };
|
|
2146
2040
|
const metadata = {
|
|
2147
2041
|
timestamp: Date.now(),
|
|
2148
2042
|
userAgent: "Node.js"
|
|
2149
2043
|
};
|
|
2150
2044
|
this.state = { metadata };
|
|
2151
2045
|
this.api = new OrderApi({
|
|
2152
|
-
|
|
2153
|
-
secretKey: this.config.secretKey
|
|
2154
|
-
baseUrl: this.baseUrl
|
|
2046
|
+
publishableKey: this.config.publishableKey,
|
|
2047
|
+
secretKey: this.config.secretKey
|
|
2155
2048
|
});
|
|
2156
2049
|
this.cart = new CartApi({
|
|
2157
|
-
|
|
2158
|
-
secretKey: this.config.secretKey
|
|
2159
|
-
baseUrl: this.baseUrl
|
|
2050
|
+
publishableKey: this.config.publishableKey,
|
|
2051
|
+
secretKey: this.config.secretKey
|
|
2160
2052
|
});
|
|
2161
2053
|
this.community = new CommunityClient({
|
|
2162
|
-
|
|
2163
|
-
secretKey: this.config.secretKey
|
|
2164
|
-
baseUrl: this.baseUrl
|
|
2054
|
+
publishableKey: this.config.publishableKey,
|
|
2055
|
+
secretKey: this.config.secretKey
|
|
2165
2056
|
});
|
|
2166
2057
|
this.product = new ProductApi({
|
|
2167
|
-
|
|
2168
|
-
secretKey: this.config.secretKey
|
|
2169
|
-
baseUrl: this.baseUrl
|
|
2058
|
+
publishableKey: this.config.publishableKey,
|
|
2059
|
+
secretKey: this.config.secretKey
|
|
2170
2060
|
});
|
|
2171
2061
|
this.collections = new CollectionClient(
|
|
2172
|
-
this.config.
|
|
2173
|
-
this.config.secretKey
|
|
2174
|
-
this.baseUrl
|
|
2062
|
+
this.config.publishableKey,
|
|
2063
|
+
this.config.secretKey
|
|
2175
2064
|
);
|
|
2176
2065
|
this.queryClient = getQueryClient();
|
|
2177
2066
|
this.query = new QueryHooks(this.queryClient, this.collections);
|
|
@@ -2197,9 +2086,9 @@ var MAX_RECONNECT_DELAY = 3e4;
|
|
|
2197
2086
|
var RECONNECT_BACKOFF_FACTOR = 2;
|
|
2198
2087
|
var MAX_NO_TOKEN_RETRIES = 5;
|
|
2199
2088
|
var RealtimeConnection = class {
|
|
2200
|
-
constructor(baseUrl,
|
|
2089
|
+
constructor(baseUrl, publishableKey, getToken, collections) {
|
|
2201
2090
|
this.baseUrl = baseUrl;
|
|
2202
|
-
this.
|
|
2091
|
+
this.publishableKey = publishableKey;
|
|
2203
2092
|
this.getToken = getToken;
|
|
2204
2093
|
this.collections = collections;
|
|
2205
2094
|
this.abortController = null;
|
|
@@ -2252,7 +2141,7 @@ var RealtimeConnection = class {
|
|
|
2252
2141
|
try {
|
|
2253
2142
|
const response = await fetch(url, {
|
|
2254
2143
|
headers: {
|
|
2255
|
-
"X-
|
|
2144
|
+
"X-Publishable-Key": this.publishableKey,
|
|
2256
2145
|
Authorization: `Bearer ${token}`
|
|
2257
2146
|
},
|
|
2258
2147
|
signal
|
|
@@ -2546,13 +2435,10 @@ export {
|
|
|
2546
2435
|
UsageLimitError,
|
|
2547
2436
|
ValidationError,
|
|
2548
2437
|
collectionKeys,
|
|
2549
|
-
createApiKey,
|
|
2550
2438
|
createClient,
|
|
2551
2439
|
createServerClient,
|
|
2552
|
-
createServerToken,
|
|
2553
2440
|
createTypedWebhookHandler,
|
|
2554
2441
|
customerKeys,
|
|
2555
|
-
decodeServerToken,
|
|
2556
2442
|
formatOrderName,
|
|
2557
2443
|
generateOrderNumber,
|
|
2558
2444
|
getImageLqip,
|
|
@@ -2577,8 +2463,6 @@ export {
|
|
|
2577
2463
|
isUsageLimitError,
|
|
2578
2464
|
isValidWebhookEvent,
|
|
2579
2465
|
isValidationError,
|
|
2580
|
-
|
|
2581
|
-
resolveRelation,
|
|
2582
|
-
verifyServerToken
|
|
2466
|
+
resolveRelation
|
|
2583
2467
|
};
|
|
2584
2468
|
//# sourceMappingURL=index.js.map
|