@sylphx/sdk 0.5.0 → 0.8.0-rc.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/README.md +38 -0
- package/dist/health/index.js +521 -0
- package/dist/health/index.js.map +1 -0
- package/dist/health/index.mjs +485 -0
- package/dist/health/index.mjs.map +1 -0
- package/dist/index.d.cts +3313 -20506
- package/dist/index.d.ts +3313 -20506
- package/dist/index.js +8401 -1698
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8110 -1456
- package/dist/index.mjs.map +1 -1
- package/dist/nextjs/index.d.cts +24 -5697
- package/dist/nextjs/index.d.ts +24 -5697
- package/dist/nextjs/index.js +24 -25
- package/dist/nextjs/index.js.map +1 -1
- package/dist/nextjs/index.mjs +24 -25
- package/dist/nextjs/index.mjs.map +1 -1
- package/dist/react/index.d.cts +404 -6088
- package/dist/react/index.d.ts +404 -6088
- package/dist/react/index.js +1131 -618
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +1198 -684
- package/dist/react/index.mjs.map +1 -1
- package/dist/server/index.d.cts +116 -19551
- package/dist/server/index.d.ts +116 -19551
- package/dist/server/index.js +130 -63
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +130 -53
- package/dist/server/index.mjs.map +1 -1
- package/dist/web-analytics.js +0 -3
- package/dist/web-analytics.js.map +1 -1
- package/dist/web-analytics.mjs +0 -3
- package/dist/web-analytics.mjs.map +1 -1
- package/package.json +13 -6
package/dist/server/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// node_modules/jose/dist/webapi/lib/buffer_utils.js
|
|
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
|
-
// node_modules/jose/dist/webapi/lib/base64.js
|
|
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
|
-
// node_modules/jose/dist/webapi/util/base64url.js
|
|
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
|
-
// node_modules/jose/dist/webapi/util/errors.js
|
|
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
|
-
// node_modules/jose/dist/webapi/lib/crypto_key.js
|
|
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
|
-
// node_modules/jose/dist/webapi/lib/invalid_key_input.js
|
|
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
|
-
// node_modules/jose/dist/webapi/lib/is_key_like.js
|
|
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
|
-
// node_modules/jose/dist/webapi/lib/is_disjoint.js
|
|
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
|
-
// node_modules/jose/dist/webapi/lib/is_object.js
|
|
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
|
-
// node_modules/jose/dist/webapi/lib/check_key_length.js
|
|
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
|
-
// node_modules/jose/dist/webapi/lib/jwk_to_key.js
|
|
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
|
-
// node_modules/jose/dist/webapi/key/import.js
|
|
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
|
-
// node_modules/jose/dist/webapi/lib/validate_crit.js
|
|
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
|
-
// node_modules/jose/dist/webapi/lib/validate_algorithms.js
|
|
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
|
-
// node_modules/jose/dist/webapi/lib/is_jwk.js
|
|
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
|
-
// node_modules/jose/dist/webapi/lib/normalize_key.js
|
|
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
|
-
// node_modules/jose/dist/webapi/lib/check_key_type.js
|
|
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
|
-
// node_modules/jose/dist/webapi/lib/subtle_dsa.js
|
|
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
|
-
// node_modules/jose/dist/webapi/lib/get_sign_verify_key.js
|
|
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
|
-
// node_modules/jose/dist/webapi/lib/verify.js
|
|
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
|
-
// node_modules/jose/dist/webapi/jws/flattened/verify.js
|
|
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
|
-
// node_modules/jose/dist/webapi/jws/compact/verify.js
|
|
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
|
-
// node_modules/jose/dist/webapi/lib/jwt_claims_set.js
|
|
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
|
-
// node_modules/jose/dist/webapi/jwt/verify.js
|
|
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) {
|
|
@@ -1167,9 +1167,6 @@ var CIRCUIT_BREAKER_OPEN_DURATION_MS = 3e4;
|
|
|
1167
1167
|
var ETAG_CACHE_MAX_ENTRIES = 100;
|
|
1168
1168
|
var ETAG_CACHE_TTL_MS = 5 * 60 * 1e3;
|
|
1169
1169
|
|
|
1170
|
-
// src/rest-client.ts
|
|
1171
|
-
import createClient from "openapi-fetch";
|
|
1172
|
-
|
|
1173
1170
|
// src/errors.ts
|
|
1174
1171
|
var ERROR_CODE_STATUS = {
|
|
1175
1172
|
BAD_REQUEST: 400,
|
|
@@ -1566,6 +1563,92 @@ function isDevelopmentRuntime() {
|
|
|
1566
1563
|
}
|
|
1567
1564
|
|
|
1568
1565
|
// src/rest-client.ts
|
|
1566
|
+
async function runPipeline(middlewares, initial) {
|
|
1567
|
+
let request = initial;
|
|
1568
|
+
for (const mw of middlewares) {
|
|
1569
|
+
if (mw.onRequest) {
|
|
1570
|
+
const next = await mw.onRequest({ request });
|
|
1571
|
+
if (next) request = next;
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1574
|
+
let response = await fetch(request);
|
|
1575
|
+
for (const mw of middlewares) {
|
|
1576
|
+
if (mw.onResponse) {
|
|
1577
|
+
const next = await mw.onResponse({ request, response });
|
|
1578
|
+
if (next) response = next;
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
return response;
|
|
1582
|
+
}
|
|
1583
|
+
function buildUrl(baseUrl, path, params) {
|
|
1584
|
+
const url = `${baseUrl}${path}`;
|
|
1585
|
+
if (!params) return url;
|
|
1586
|
+
const entries = Object.entries(params).filter(([, v]) => v !== void 0);
|
|
1587
|
+
if (entries.length === 0) return url;
|
|
1588
|
+
const search = new URLSearchParams(
|
|
1589
|
+
entries.map(([k, v]) => [k, String(v)])
|
|
1590
|
+
).toString();
|
|
1591
|
+
return `${url}?${search}`;
|
|
1592
|
+
}
|
|
1593
|
+
function interpolatePath(path, pathParams) {
|
|
1594
|
+
if (!pathParams) return path;
|
|
1595
|
+
return path.replace(/\{(\w+)\}/g, (_match, key) => {
|
|
1596
|
+
const value = pathParams[key];
|
|
1597
|
+
if (value === void 0) return `{${key}}`;
|
|
1598
|
+
return encodeURIComponent(value);
|
|
1599
|
+
});
|
|
1600
|
+
}
|
|
1601
|
+
async function executeRequest(method, baseUrl, path, options, baseHeaders, middlewares) {
|
|
1602
|
+
const finalPath = interpolatePath(path, options?.params?.path);
|
|
1603
|
+
const url = buildUrl(baseUrl, finalPath, options?.params?.query);
|
|
1604
|
+
const headers = { ...baseHeaders, ...options?.headers };
|
|
1605
|
+
const init = { method, headers };
|
|
1606
|
+
if (options?.body !== void 0) {
|
|
1607
|
+
init.body = typeof options.body === "string" ? options.body : JSON.stringify(options.body);
|
|
1608
|
+
if (!headers["Content-Type"] && !headers["content-type"]) {
|
|
1609
|
+
headers["Content-Type"] = "application/json";
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
const request = new Request(url, init);
|
|
1613
|
+
const response = await runPipeline(middlewares, request);
|
|
1614
|
+
const contentType = response.headers.get("content-type") ?? "";
|
|
1615
|
+
let parsed;
|
|
1616
|
+
if (contentType.includes("json")) {
|
|
1617
|
+
try {
|
|
1618
|
+
parsed = await response.clone().json();
|
|
1619
|
+
} catch {
|
|
1620
|
+
parsed = void 0;
|
|
1621
|
+
}
|
|
1622
|
+
} else if (response.status !== 204 && response.status !== 205) {
|
|
1623
|
+
try {
|
|
1624
|
+
const text = await response.clone().text();
|
|
1625
|
+
parsed = text === "" ? void 0 : text;
|
|
1626
|
+
} catch {
|
|
1627
|
+
parsed = void 0;
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
if (response.ok) {
|
|
1631
|
+
return { data: parsed, response };
|
|
1632
|
+
}
|
|
1633
|
+
return { error: parsed, response };
|
|
1634
|
+
}
|
|
1635
|
+
function buildClient(baseUrl, baseHeaders) {
|
|
1636
|
+
const middlewares = [];
|
|
1637
|
+
const dispatch = (method) => (path, options) => executeRequest(method, baseUrl, path, options, baseHeaders, middlewares);
|
|
1638
|
+
const client = {
|
|
1639
|
+
GET: dispatch("GET"),
|
|
1640
|
+
POST: dispatch("POST"),
|
|
1641
|
+
PUT: dispatch("PUT"),
|
|
1642
|
+
PATCH: dispatch("PATCH"),
|
|
1643
|
+
DELETE: dispatch("DELETE"),
|
|
1644
|
+
HEAD: dispatch("HEAD"),
|
|
1645
|
+
OPTIONS: dispatch("OPTIONS"),
|
|
1646
|
+
use(...mws) {
|
|
1647
|
+
middlewares.push(...mws);
|
|
1648
|
+
}
|
|
1649
|
+
};
|
|
1650
|
+
return { client, middlewares };
|
|
1651
|
+
}
|
|
1569
1652
|
function createAuthMiddleware(config) {
|
|
1570
1653
|
return {
|
|
1571
1654
|
async onRequest({ request }) {
|
|
@@ -1892,23 +1975,20 @@ function validateClientConfig(config) {
|
|
|
1892
1975
|
}
|
|
1893
1976
|
function createRestClient(config) {
|
|
1894
1977
|
const { secretKey, baseUrl } = validateClientConfig(config);
|
|
1895
|
-
const client =
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
"Content-Type": "application/json",
|
|
1899
|
-
"x-app-secret": secretKey
|
|
1900
|
-
}
|
|
1978
|
+
const { client, middlewares } = buildClient(`${baseUrl}${SDK_API_PATH}`, {
|
|
1979
|
+
"Content-Type": "application/json",
|
|
1980
|
+
"x-app-secret": secretKey
|
|
1901
1981
|
});
|
|
1902
1982
|
if (config.deduplication !== false) {
|
|
1903
|
-
|
|
1983
|
+
middlewares.push(createDeduplicationMiddleware(config.deduplication));
|
|
1904
1984
|
}
|
|
1905
1985
|
if (config.circuitBreaker !== false) {
|
|
1906
|
-
|
|
1986
|
+
middlewares.push(createCircuitBreakerMiddleware(config.circuitBreaker));
|
|
1907
1987
|
}
|
|
1908
1988
|
if (config.etag !== false) {
|
|
1909
|
-
|
|
1989
|
+
middlewares.push(createETagMiddleware(config.etag));
|
|
1910
1990
|
}
|
|
1911
|
-
|
|
1991
|
+
middlewares.push(createRetryMiddleware(config.retry));
|
|
1912
1992
|
return client;
|
|
1913
1993
|
}
|
|
1914
1994
|
function createDynamicRestClient(config) {
|
|
@@ -1918,23 +1998,20 @@ function createDynamicRestClient(config) {
|
|
|
1918
1998
|
secretKey,
|
|
1919
1999
|
platformUrl: baseUrl
|
|
1920
2000
|
};
|
|
1921
|
-
const client =
|
|
1922
|
-
|
|
1923
|
-
headers: {
|
|
1924
|
-
"Content-Type": "application/json"
|
|
1925
|
-
}
|
|
2001
|
+
const { client, middlewares } = buildClient(`${baseUrl}${SDK_API_PATH}`, {
|
|
2002
|
+
"Content-Type": "application/json"
|
|
1926
2003
|
});
|
|
1927
2004
|
if (config.deduplication !== false) {
|
|
1928
|
-
|
|
2005
|
+
middlewares.push(createDeduplicationMiddleware(config.deduplication));
|
|
1929
2006
|
}
|
|
1930
|
-
|
|
2007
|
+
middlewares.push(createAuthMiddleware(validatedConfig));
|
|
1931
2008
|
if (config.circuitBreaker !== false) {
|
|
1932
|
-
|
|
2009
|
+
middlewares.push(createCircuitBreakerMiddleware(config.circuitBreaker));
|
|
1933
2010
|
}
|
|
1934
2011
|
if (config.etag !== false) {
|
|
1935
|
-
|
|
2012
|
+
middlewares.push(createETagMiddleware(config.etag));
|
|
1936
2013
|
}
|
|
1937
|
-
|
|
2014
|
+
middlewares.push(createRetryMiddleware(config.retry));
|
|
1938
2015
|
return client;
|
|
1939
2016
|
}
|
|
1940
2017
|
|
|
@@ -2059,14 +2136,14 @@ function freezeConfig(opts) {
|
|
|
2059
2136
|
ref: opts.slug
|
|
2060
2137
|
});
|
|
2061
2138
|
}
|
|
2062
|
-
function
|
|
2139
|
+
function createClient(input) {
|
|
2063
2140
|
if (typeof input === "string") {
|
|
2064
2141
|
return createConfigFromUrl(input);
|
|
2065
2142
|
}
|
|
2066
2143
|
return createConfigFromComponents(input);
|
|
2067
2144
|
}
|
|
2068
2145
|
function createServerClient(input) {
|
|
2069
|
-
const config =
|
|
2146
|
+
const config = createClient(input);
|
|
2070
2147
|
if (config.credentialType !== "sk") {
|
|
2071
2148
|
throw new SylphxError(
|
|
2072
2149
|
"[Sylphx] createServerClient() requires a secret key (sk_*). Use a SYLPHX_SECRET_URL with an sk_ credential, or pass { secretKey } in the components object.",
|
|
@@ -2132,7 +2209,7 @@ function createConfigFromComponents(input) {
|
|
|
2132
2209
|
const credentialType = match[1];
|
|
2133
2210
|
const env = match[2];
|
|
2134
2211
|
const slug = resolvedSlug.trim().toLowerCase();
|
|
2135
|
-
const domain = input.domain?.trim() || "sylphx.com";
|
|
2212
|
+
const domain = input.domain?.trim() || "api.sylphx.com";
|
|
2136
2213
|
const baseUrl = `https://${slug}.${domain}/v1`;
|
|
2137
2214
|
return freezeConfig({
|
|
2138
2215
|
credential: trimmedCred,
|
|
@@ -3087,8 +3164,8 @@ async function fetchOAuthProviders(options) {
|
|
|
3087
3164
|
const baseURL = (options.platformUrl ?? `https://${DEFAULT_SDK_API_HOST}`).trim();
|
|
3088
3165
|
const appId = validateAndSanitizeAppId(options.appId);
|
|
3089
3166
|
return cachedFetch({
|
|
3090
|
-
url: `${baseURL}/
|
|
3091
|
-
headers: { "
|
|
3167
|
+
url: `${baseURL}${SDK_API_PATH}/auth/oauth-providers`,
|
|
3168
|
+
headers: { "x-app-secret": appId },
|
|
3092
3169
|
fallback: { providers: [] },
|
|
3093
3170
|
label: "OAuth providers"
|
|
3094
3171
|
});
|
|
@@ -3239,7 +3316,7 @@ export {
|
|
|
3239
3316
|
InvalidConnectionUrlError,
|
|
3240
3317
|
createAI,
|
|
3241
3318
|
createAuthenticatedServerClient,
|
|
3242
|
-
|
|
3319
|
+
createClient,
|
|
3243
3320
|
createKv,
|
|
3244
3321
|
createServerClient,
|
|
3245
3322
|
createServerRestClient,
|