@sylphx/sdk 0.3.2 → 0.3.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 +15 -5
- package/dist/index.d.cts +16908 -5920
- package/dist/index.d.ts +16908 -5920
- package/dist/index.js +179 -145
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +179 -142
- package/dist/index.mjs.map +1 -1
- package/dist/nextjs/index.d.cts +5378 -1202
- package/dist/nextjs/index.d.ts +5378 -1202
- package/dist/nextjs/index.js +78 -37
- package/dist/nextjs/index.js.map +1 -1
- package/dist/nextjs/index.mjs +76 -37
- package/dist/nextjs/index.mjs.map +1 -1
- package/dist/react/index.d.cts +5353 -1212
- package/dist/react/index.d.ts +5353 -1212
- package/dist/react/index.js +118 -96
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +118 -96
- package/dist/react/index.mjs.map +1 -1
- package/dist/server/index.d.cts +14368 -3312
- package/dist/server/index.d.ts +14368 -3312
- package/dist/server/index.js +82 -47
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +80 -47
- package/dist/server/index.mjs.map +1 -1
- package/dist/web-analytics.js +1 -1
- package/dist/web-analytics.js.map +1 -1
- package/dist/web-analytics.mjs +1 -1
- package/dist/web-analytics.mjs.map +1 -1
- package/package.json +3 -3
package/dist/server/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//
|
|
1
|
+
// node_modules/jose/dist/webapi/lib/buffer_utils.js
|
|
2
2
|
var encoder = new TextEncoder();
|
|
3
3
|
var decoder = new TextDecoder();
|
|
4
4
|
var MAX_INT32 = 2 ** 32;
|
|
@@ -24,7 +24,7 @@ function encode(string) {
|
|
|
24
24
|
return bytes;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
//
|
|
27
|
+
// node_modules/jose/dist/webapi/lib/base64.js
|
|
28
28
|
function decodeBase64(encoded) {
|
|
29
29
|
if (Uint8Array.fromBase64) {
|
|
30
30
|
return Uint8Array.fromBase64(encoded);
|
|
@@ -37,7 +37,7 @@ function decodeBase64(encoded) {
|
|
|
37
37
|
return bytes;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
//
|
|
40
|
+
// node_modules/jose/dist/webapi/util/base64url.js
|
|
41
41
|
function decode(input) {
|
|
42
42
|
if (Uint8Array.fromBase64) {
|
|
43
43
|
return Uint8Array.fromBase64(typeof input === "string" ? input : decoder.decode(input), {
|
|
@@ -56,7 +56,7 @@ function decode(input) {
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
//
|
|
59
|
+
// node_modules/jose/dist/webapi/util/errors.js
|
|
60
60
|
var JOSEError = class extends Error {
|
|
61
61
|
static code = "ERR_JOSE_GENERIC";
|
|
62
62
|
code = "ERR_JOSE_GENERIC";
|
|
@@ -116,7 +116,7 @@ var JWSSignatureVerificationFailed = class extends JOSEError {
|
|
|
116
116
|
}
|
|
117
117
|
};
|
|
118
118
|
|
|
119
|
-
//
|
|
119
|
+
// node_modules/jose/dist/webapi/lib/crypto_key.js
|
|
120
120
|
var unusable = (name, prop = "algorithm.name") => new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`);
|
|
121
121
|
var isAlgorithm = (algorithm, name) => algorithm.name === name;
|
|
122
122
|
function getHashLength(hash) {
|
|
@@ -204,7 +204,7 @@ function checkSigCryptoKey(key, alg, usage) {
|
|
|
204
204
|
checkUsage(key, usage);
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
-
//
|
|
207
|
+
// node_modules/jose/dist/webapi/lib/invalid_key_input.js
|
|
208
208
|
function message(msg, actual, ...types) {
|
|
209
209
|
types = types.filter(Boolean);
|
|
210
210
|
if (types.length > 2) {
|
|
@@ -229,7 +229,7 @@ function message(msg, actual, ...types) {
|
|
|
229
229
|
var invalidKeyInput = (actual, ...types) => message("Key must be ", actual, ...types);
|
|
230
230
|
var withAlg = (alg, actual, ...types) => message(`Key for the ${alg} algorithm must be `, actual, ...types);
|
|
231
231
|
|
|
232
|
-
//
|
|
232
|
+
// node_modules/jose/dist/webapi/lib/is_key_like.js
|
|
233
233
|
var isCryptoKey = (key) => {
|
|
234
234
|
if (key?.[Symbol.toStringTag] === "CryptoKey")
|
|
235
235
|
return true;
|
|
@@ -242,7 +242,7 @@ var isCryptoKey = (key) => {
|
|
|
242
242
|
var isKeyObject = (key) => key?.[Symbol.toStringTag] === "KeyObject";
|
|
243
243
|
var isKeyLike = (key) => isCryptoKey(key) || isKeyObject(key);
|
|
244
244
|
|
|
245
|
-
//
|
|
245
|
+
// node_modules/jose/dist/webapi/lib/is_disjoint.js
|
|
246
246
|
function isDisjoint(...headers) {
|
|
247
247
|
const sources = headers.filter(Boolean);
|
|
248
248
|
if (sources.length === 0 || sources.length === 1) {
|
|
@@ -265,7 +265,7 @@ function isDisjoint(...headers) {
|
|
|
265
265
|
return true;
|
|
266
266
|
}
|
|
267
267
|
|
|
268
|
-
//
|
|
268
|
+
// node_modules/jose/dist/webapi/lib/is_object.js
|
|
269
269
|
var isObjectLike = (value) => typeof value === "object" && value !== null;
|
|
270
270
|
function isObject(input) {
|
|
271
271
|
if (!isObjectLike(input) || Object.prototype.toString.call(input) !== "[object Object]") {
|
|
@@ -281,7 +281,7 @@ function isObject(input) {
|
|
|
281
281
|
return Object.getPrototypeOf(input) === proto;
|
|
282
282
|
}
|
|
283
283
|
|
|
284
|
-
//
|
|
284
|
+
// node_modules/jose/dist/webapi/lib/check_key_length.js
|
|
285
285
|
function checkKeyLength(alg, key) {
|
|
286
286
|
if (alg.startsWith("RS") || alg.startsWith("PS")) {
|
|
287
287
|
const { modulusLength } = key.algorithm;
|
|
@@ -291,7 +291,7 @@ function checkKeyLength(alg, key) {
|
|
|
291
291
|
}
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
-
//
|
|
294
|
+
// node_modules/jose/dist/webapi/lib/jwk_to_key.js
|
|
295
295
|
function subtleMapping(jwk) {
|
|
296
296
|
let algorithm;
|
|
297
297
|
let keyUsages;
|
|
@@ -401,7 +401,7 @@ async function jwkToKey(jwk) {
|
|
|
401
401
|
return crypto.subtle.importKey("jwk", keyData, algorithm, jwk.ext ?? (jwk.d || jwk.priv ? false : true), jwk.key_ops ?? keyUsages);
|
|
402
402
|
}
|
|
403
403
|
|
|
404
|
-
//
|
|
404
|
+
// node_modules/jose/dist/webapi/key/import.js
|
|
405
405
|
async function importJWK(jwk, alg, options) {
|
|
406
406
|
if (!isObject(jwk)) {
|
|
407
407
|
throw new TypeError("JWK must be an object");
|
|
@@ -437,7 +437,7 @@ async function importJWK(jwk, alg, options) {
|
|
|
437
437
|
}
|
|
438
438
|
}
|
|
439
439
|
|
|
440
|
-
//
|
|
440
|
+
// node_modules/jose/dist/webapi/lib/validate_crit.js
|
|
441
441
|
function validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) {
|
|
442
442
|
if (joseHeader.crit !== void 0 && protectedHeader?.crit === void 0) {
|
|
443
443
|
throw new Err('"crit" (Critical) Header Parameter MUST be integrity protected');
|
|
@@ -468,7 +468,7 @@ function validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader,
|
|
|
468
468
|
return new Set(protectedHeader.crit);
|
|
469
469
|
}
|
|
470
470
|
|
|
471
|
-
//
|
|
471
|
+
// node_modules/jose/dist/webapi/lib/validate_algorithms.js
|
|
472
472
|
function validateAlgorithms(option, algorithms) {
|
|
473
473
|
if (algorithms !== void 0 && (!Array.isArray(algorithms) || algorithms.some((s) => typeof s !== "string"))) {
|
|
474
474
|
throw new TypeError(`"${option}" option must be an array of strings`);
|
|
@@ -479,13 +479,13 @@ function validateAlgorithms(option, algorithms) {
|
|
|
479
479
|
return new Set(algorithms);
|
|
480
480
|
}
|
|
481
481
|
|
|
482
|
-
//
|
|
482
|
+
// node_modules/jose/dist/webapi/lib/is_jwk.js
|
|
483
483
|
var isJWK = (key) => isObject(key) && typeof key.kty === "string";
|
|
484
484
|
var isPrivateJWK = (key) => key.kty !== "oct" && (key.kty === "AKP" && typeof key.priv === "string" || typeof key.d === "string");
|
|
485
485
|
var isPublicJWK = (key) => key.kty !== "oct" && key.d === void 0 && key.priv === void 0;
|
|
486
486
|
var isSecretJWK = (key) => key.kty === "oct" && typeof key.k === "string";
|
|
487
487
|
|
|
488
|
-
//
|
|
488
|
+
// node_modules/jose/dist/webapi/lib/normalize_key.js
|
|
489
489
|
var cache;
|
|
490
490
|
var handleJWK = async (key, jwk, alg, freeze = false) => {
|
|
491
491
|
cache ||= /* @__PURE__ */ new WeakMap();
|
|
@@ -656,7 +656,7 @@ async function normalizeKey(key, alg) {
|
|
|
656
656
|
throw new Error("unreachable");
|
|
657
657
|
}
|
|
658
658
|
|
|
659
|
-
//
|
|
659
|
+
// node_modules/jose/dist/webapi/lib/check_key_type.js
|
|
660
660
|
var tag = (key) => key?.[Symbol.toStringTag];
|
|
661
661
|
var jwkMatchesOp = (alg, key, usage) => {
|
|
662
662
|
if (key.use !== void 0) {
|
|
@@ -776,7 +776,7 @@ function checkKeyType(alg, key, usage) {
|
|
|
776
776
|
}
|
|
777
777
|
}
|
|
778
778
|
|
|
779
|
-
//
|
|
779
|
+
// node_modules/jose/dist/webapi/lib/subtle_dsa.js
|
|
780
780
|
function subtleAlgorithm(alg, algorithm) {
|
|
781
781
|
const hash = `SHA-${alg.slice(-3)}`;
|
|
782
782
|
switch (alg) {
|
|
@@ -808,7 +808,7 @@ function subtleAlgorithm(alg, algorithm) {
|
|
|
808
808
|
}
|
|
809
809
|
}
|
|
810
810
|
|
|
811
|
-
//
|
|
811
|
+
// node_modules/jose/dist/webapi/lib/get_sign_verify_key.js
|
|
812
812
|
async function getSigKey(alg, key, usage) {
|
|
813
813
|
if (key instanceof Uint8Array) {
|
|
814
814
|
if (!alg.startsWith("HS")) {
|
|
@@ -820,7 +820,7 @@ async function getSigKey(alg, key, usage) {
|
|
|
820
820
|
return key;
|
|
821
821
|
}
|
|
822
822
|
|
|
823
|
-
//
|
|
823
|
+
// node_modules/jose/dist/webapi/lib/verify.js
|
|
824
824
|
async function verify(alg, key, signature, data) {
|
|
825
825
|
const cryptoKey = await getSigKey(alg, key, "verify");
|
|
826
826
|
checkKeyLength(alg, cryptoKey);
|
|
@@ -832,7 +832,7 @@ async function verify(alg, key, signature, data) {
|
|
|
832
832
|
}
|
|
833
833
|
}
|
|
834
834
|
|
|
835
|
-
//
|
|
835
|
+
// node_modules/jose/dist/webapi/jws/flattened/verify.js
|
|
836
836
|
async function flattenedVerify(jws, key, options) {
|
|
837
837
|
if (!isObject(jws)) {
|
|
838
838
|
throw new JWSInvalid("Flattened JWS must be an object");
|
|
@@ -934,7 +934,7 @@ async function flattenedVerify(jws, key, options) {
|
|
|
934
934
|
return result;
|
|
935
935
|
}
|
|
936
936
|
|
|
937
|
-
//
|
|
937
|
+
// node_modules/jose/dist/webapi/jws/compact/verify.js
|
|
938
938
|
async function compactVerify(jws, key, options) {
|
|
939
939
|
if (jws instanceof Uint8Array) {
|
|
940
940
|
jws = decoder.decode(jws);
|
|
@@ -954,7 +954,7 @@ async function compactVerify(jws, key, options) {
|
|
|
954
954
|
return result;
|
|
955
955
|
}
|
|
956
956
|
|
|
957
|
-
//
|
|
957
|
+
// node_modules/jose/dist/webapi/lib/jwt_claims_set.js
|
|
958
958
|
var epoch = (date) => Math.floor(date.getTime() / 1e3);
|
|
959
959
|
var minute = 60;
|
|
960
960
|
var hour = minute * 60;
|
|
@@ -1111,7 +1111,7 @@ function validateClaimsSet(protectedHeader, encodedPayload, options = {}) {
|
|
|
1111
1111
|
return payload;
|
|
1112
1112
|
}
|
|
1113
1113
|
|
|
1114
|
-
//
|
|
1114
|
+
// node_modules/jose/dist/webapi/jwt/verify.js
|
|
1115
1115
|
async function jwtVerify(jwt, key, options) {
|
|
1116
1116
|
const verified = await compactVerify(jwt, key, options);
|
|
1117
1117
|
if (verified.protectedHeader.crit?.includes("b64") && verified.protectedHeader.b64 === false) {
|
|
@@ -1126,17 +1126,12 @@ async function jwtVerify(jwt, key, options) {
|
|
|
1126
1126
|
}
|
|
1127
1127
|
|
|
1128
1128
|
// src/constants.ts
|
|
1129
|
-
var DEFAULT_PLATFORM_URL = "https://sylphx.com";
|
|
1130
|
-
var ENV_PLATFORM_URL = "SYLPHX_PLATFORM_URL";
|
|
1131
|
-
var ENV_PLATFORM_URL_LEGACY = "SYLPHX_URL";
|
|
1132
1129
|
var ENV_SECRET_KEY = "SYLPHX_SECRET_KEY";
|
|
1133
|
-
function resolvePlatformUrl(explicit) {
|
|
1134
|
-
return (explicit || process.env[ENV_PLATFORM_URL] || process.env[ENV_PLATFORM_URL_LEGACY] || DEFAULT_PLATFORM_URL).trim();
|
|
1135
|
-
}
|
|
1136
1130
|
function resolveSecretKey(explicit) {
|
|
1137
1131
|
return explicit || process.env[ENV_SECRET_KEY];
|
|
1138
1132
|
}
|
|
1139
|
-
var SDK_API_PATH = `/
|
|
1133
|
+
var SDK_API_PATH = `/v1`;
|
|
1134
|
+
var DEFAULT_SDK_API_HOST = "api.sylphx.com";
|
|
1140
1135
|
var SDK_VERSION = "0.1.0";
|
|
1141
1136
|
var SDK_PLATFORM = typeof window !== "undefined" ? "browser" : typeof process !== "undefined" && process.versions?.node ? "node" : "unknown";
|
|
1142
1137
|
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
@@ -1859,7 +1854,7 @@ function createRetryMiddleware(retryConfig) {
|
|
|
1859
1854
|
function validateClientConfig(config) {
|
|
1860
1855
|
return {
|
|
1861
1856
|
secretKey: validateAndSanitizeSecretKey(config.secretKey),
|
|
1862
|
-
baseUrl: (config.platformUrl ||
|
|
1857
|
+
baseUrl: (config.platformUrl || `https://${DEFAULT_SDK_API_HOST}`).trim()
|
|
1863
1858
|
};
|
|
1864
1859
|
}
|
|
1865
1860
|
function createRestClient(config) {
|
|
@@ -1910,9 +1905,44 @@ function createDynamicRestClient(config) {
|
|
|
1910
1905
|
return client;
|
|
1911
1906
|
}
|
|
1912
1907
|
|
|
1908
|
+
// src/lib/ids.ts
|
|
1909
|
+
var B58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
1910
|
+
var B58_MAP = Object.fromEntries([...B58].map((c, i) => [c, i]));
|
|
1911
|
+
function encodeUserId(uuid) {
|
|
1912
|
+
const hex = uuid.replace(/-/g, "");
|
|
1913
|
+
if (hex.length !== 32)
|
|
1914
|
+
throw new Error("Invalid UUID: expected 32 hex chars after stripping dashes");
|
|
1915
|
+
let n = BigInt("0x" + hex);
|
|
1916
|
+
let r = "";
|
|
1917
|
+
while (n > 0n) {
|
|
1918
|
+
r = B58[Number(n % 58n)] + r;
|
|
1919
|
+
n /= 58n;
|
|
1920
|
+
}
|
|
1921
|
+
return `user_${r}`;
|
|
1922
|
+
}
|
|
1923
|
+
function decodeUserId(prefixedId) {
|
|
1924
|
+
if (!prefixedId.startsWith("user_")) return null;
|
|
1925
|
+
const enc = prefixedId.slice(5);
|
|
1926
|
+
if (!enc) return null;
|
|
1927
|
+
let n = 0n;
|
|
1928
|
+
for (const c of enc) {
|
|
1929
|
+
const i = B58_MAP[c] ?? -1;
|
|
1930
|
+
if (i === -1) return null;
|
|
1931
|
+
n = n * 58n + BigInt(i);
|
|
1932
|
+
}
|
|
1933
|
+
const hex = n.toString(16).padStart(32, "0");
|
|
1934
|
+
return [
|
|
1935
|
+
hex.slice(0, 8),
|
|
1936
|
+
hex.slice(8, 12),
|
|
1937
|
+
hex.slice(12, 16),
|
|
1938
|
+
hex.slice(16, 20),
|
|
1939
|
+
hex.slice(20)
|
|
1940
|
+
].join("-");
|
|
1941
|
+
}
|
|
1942
|
+
|
|
1913
1943
|
// src/server/ai.ts
|
|
1914
1944
|
function createAI(options = {}) {
|
|
1915
|
-
const baseURL = (options.platformUrl ||
|
|
1945
|
+
const baseURL = (options.platformUrl || `https://${DEFAULT_SDK_API_HOST}`).trim();
|
|
1916
1946
|
const rawApiKey = options.secretKey || process.env.SYLPHX_SECRET_KEY;
|
|
1917
1947
|
const apiKey = validateAndSanitizeSecretKey(rawApiKey);
|
|
1918
1948
|
const headers = {
|
|
@@ -2005,7 +2035,7 @@ function getAI() {
|
|
|
2005
2035
|
|
|
2006
2036
|
// src/server/kv.ts
|
|
2007
2037
|
function createKv(options = {}) {
|
|
2008
|
-
const platformUrl =
|
|
2038
|
+
const platformUrl = (options.platformUrl || `https://${DEFAULT_SDK_API_HOST}`).trim();
|
|
2009
2039
|
const secretKey = validateAndSanitizeSecretKey(resolveSecretKey(options.secretKey));
|
|
2010
2040
|
const headers = {
|
|
2011
2041
|
"Content-Type": "application/json",
|
|
@@ -2194,7 +2224,7 @@ function getKv() {
|
|
|
2194
2224
|
|
|
2195
2225
|
// src/server/streams.ts
|
|
2196
2226
|
function createStreams(options = {}) {
|
|
2197
|
-
const baseURL = (options.platformUrl ||
|
|
2227
|
+
const baseURL = (options.platformUrl || `https://${DEFAULT_SDK_API_HOST}`).trim();
|
|
2198
2228
|
const rawApiKey = options.secretKey || process.env.SYLPHX_SECRET_KEY;
|
|
2199
2229
|
const apiKey = validateAndSanitizeSecretKey(rawApiKey);
|
|
2200
2230
|
const headers = {
|
|
@@ -2277,7 +2307,7 @@ var jwksCache = null;
|
|
|
2277
2307
|
function resetJwksCache() {
|
|
2278
2308
|
jwksCache = null;
|
|
2279
2309
|
}
|
|
2280
|
-
async function getJwks(platformUrl =
|
|
2310
|
+
async function getJwks(platformUrl = `https://${DEFAULT_SDK_API_HOST}`) {
|
|
2281
2311
|
const now = Date.now();
|
|
2282
2312
|
if (jwksCache && jwksCache.expiresAt > now) {
|
|
2283
2313
|
return jwksCache.keys;
|
|
@@ -2298,7 +2328,7 @@ async function getJwks(platformUrl = DEFAULT_PLATFORM_URL) {
|
|
|
2298
2328
|
return data.keys;
|
|
2299
2329
|
}
|
|
2300
2330
|
async function verifyAccessToken(token, options) {
|
|
2301
|
-
const platformUrl = options.platformUrl ||
|
|
2331
|
+
const platformUrl = options.platformUrl || `https://${DEFAULT_SDK_API_HOST}`;
|
|
2302
2332
|
const keys = await getJwks(platformUrl);
|
|
2303
2333
|
if (!keys.length) {
|
|
2304
2334
|
throw new Error("No keys in JWKS");
|
|
@@ -2315,6 +2345,7 @@ async function verifyAccessToken(token, options) {
|
|
|
2315
2345
|
}
|
|
2316
2346
|
return {
|
|
2317
2347
|
sub: payload.sub,
|
|
2348
|
+
pid: payload.pid,
|
|
2318
2349
|
email: payload.email,
|
|
2319
2350
|
name: payload.name,
|
|
2320
2351
|
picture: payload.picture,
|
|
@@ -2471,7 +2502,7 @@ function sanitizeOptions(options) {
|
|
|
2471
2502
|
return {
|
|
2472
2503
|
...options,
|
|
2473
2504
|
secretKey: validateAndSanitizeSecretKey(options.secretKey),
|
|
2474
|
-
platformUrl: (options.platformUrl ??
|
|
2505
|
+
platformUrl: (options.platformUrl ?? `https://${DEFAULT_SDK_API_HOST}`).trim()
|
|
2475
2506
|
};
|
|
2476
2507
|
}
|
|
2477
2508
|
function sdkHeaders(secretKey) {
|
|
@@ -2486,7 +2517,7 @@ async function getOAuthProvidersWithInfo(options) {
|
|
|
2486
2517
|
return data.providers || [];
|
|
2487
2518
|
}
|
|
2488
2519
|
async function fetchOAuthProviders(options) {
|
|
2489
|
-
const baseURL = (options.platformUrl ??
|
|
2520
|
+
const baseURL = (options.platformUrl ?? `https://${DEFAULT_SDK_API_HOST}`).trim();
|
|
2490
2521
|
const appId = validateAndSanitizeAppId(options.appId);
|
|
2491
2522
|
return cachedFetch({
|
|
2492
2523
|
url: `${baseURL}/api/auth/providers`,
|
|
@@ -2496,7 +2527,7 @@ async function fetchOAuthProviders(options) {
|
|
|
2496
2527
|
});
|
|
2497
2528
|
}
|
|
2498
2529
|
async function getPlans(options) {
|
|
2499
|
-
const { secretKey, platformUrl =
|
|
2530
|
+
const { secretKey, platformUrl = `https://${DEFAULT_SDK_API_HOST}` } = sanitizeOptions(options);
|
|
2500
2531
|
return cachedFetch({
|
|
2501
2532
|
url: `${platformUrl}${SDK_API_PATH}/billing/plans`,
|
|
2502
2533
|
headers: sdkHeaders(secretKey),
|
|
@@ -2505,7 +2536,7 @@ async function getPlans(options) {
|
|
|
2505
2536
|
});
|
|
2506
2537
|
}
|
|
2507
2538
|
async function getConsentTypes(options) {
|
|
2508
|
-
const { secretKey, platformUrl =
|
|
2539
|
+
const { secretKey, platformUrl = `https://${DEFAULT_SDK_API_HOST}` } = sanitizeOptions(options);
|
|
2509
2540
|
return cachedFetch({
|
|
2510
2541
|
url: `${platformUrl}${SDK_API_PATH}/consent/types`,
|
|
2511
2542
|
headers: sdkHeaders(secretKey),
|
|
@@ -2514,7 +2545,7 @@ async function getConsentTypes(options) {
|
|
|
2514
2545
|
});
|
|
2515
2546
|
}
|
|
2516
2547
|
async function getFeatureFlags(options) {
|
|
2517
|
-
const { secretKey, platformUrl =
|
|
2548
|
+
const { secretKey, platformUrl = `https://${DEFAULT_SDK_API_HOST}` } = sanitizeOptions(options);
|
|
2518
2549
|
return cachedFetch({
|
|
2519
2550
|
url: `${platformUrl}${SDK_API_PATH}/flags`,
|
|
2520
2551
|
headers: sdkHeaders(secretKey),
|
|
@@ -2523,7 +2554,7 @@ async function getFeatureFlags(options) {
|
|
|
2523
2554
|
});
|
|
2524
2555
|
}
|
|
2525
2556
|
async function getAppMetadata(options) {
|
|
2526
|
-
const { secretKey, platformUrl =
|
|
2557
|
+
const { secretKey, platformUrl = `https://${DEFAULT_SDK_API_HOST}` } = sanitizeOptions(options);
|
|
2527
2558
|
return cachedFetch({
|
|
2528
2559
|
url: `${platformUrl}${SDK_API_PATH}/app`,
|
|
2529
2560
|
headers: sdkHeaders(secretKey),
|
|
@@ -2552,7 +2583,7 @@ async function getAppConfig(options) {
|
|
|
2552
2583
|
async function getReferralLeaderboard(options) {
|
|
2553
2584
|
const {
|
|
2554
2585
|
secretKey,
|
|
2555
|
-
platformUrl =
|
|
2586
|
+
platformUrl = `https://${DEFAULT_SDK_API_HOST}`,
|
|
2556
2587
|
limit = 10,
|
|
2557
2588
|
period = "all"
|
|
2558
2589
|
} = sanitizeOptions(options);
|
|
@@ -2570,7 +2601,7 @@ async function getEngagementLeaderboard(options) {
|
|
|
2570
2601
|
const {
|
|
2571
2602
|
secretKey,
|
|
2572
2603
|
leaderboardId,
|
|
2573
|
-
platformUrl =
|
|
2604
|
+
platformUrl = `https://${DEFAULT_SDK_API_HOST}`,
|
|
2574
2605
|
limit = 10
|
|
2575
2606
|
} = sanitizeOptions(options);
|
|
2576
2607
|
const url = new URL(
|
|
@@ -2591,7 +2622,7 @@ async function getEngagementLeaderboard(options) {
|
|
|
2591
2622
|
});
|
|
2592
2623
|
}
|
|
2593
2624
|
async function getDatabaseConnection(options) {
|
|
2594
|
-
const { secretKey, platformUrl =
|
|
2625
|
+
const { secretKey, platformUrl = `https://${DEFAULT_SDK_API_HOST}` } = sanitizeOptions(options);
|
|
2595
2626
|
try {
|
|
2596
2627
|
const response = await fetch(`${platformUrl}${SDK_API_PATH}/database/connection-string`, {
|
|
2597
2628
|
headers: sdkHeaders(secretKey),
|
|
@@ -2616,7 +2647,7 @@ async function getDatabaseConnection(options) {
|
|
|
2616
2647
|
}
|
|
2617
2648
|
}
|
|
2618
2649
|
async function getDatabaseStatus(options) {
|
|
2619
|
-
const { secretKey, platformUrl =
|
|
2650
|
+
const { secretKey, platformUrl = `https://${DEFAULT_SDK_API_HOST}` } = sanitizeOptions(options);
|
|
2620
2651
|
return cachedFetch({
|
|
2621
2652
|
url: `${platformUrl}${SDK_API_PATH}/database/status`,
|
|
2622
2653
|
headers: sdkHeaders(secretKey),
|
|
@@ -2636,8 +2667,10 @@ export {
|
|
|
2636
2667
|
createServerClient,
|
|
2637
2668
|
createStreams,
|
|
2638
2669
|
createWebhookHandler,
|
|
2670
|
+
decodeUserId,
|
|
2639
2671
|
detectEnvironment,
|
|
2640
2672
|
detectKeyType,
|
|
2673
|
+
encodeUserId,
|
|
2641
2674
|
getAI,
|
|
2642
2675
|
getAppConfig,
|
|
2643
2676
|
getAppMetadata,
|