@rixl/sdk 0.39.0 → 0.41.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/dist/index.js +48 -28
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -5,15 +5,6 @@ import * as v from "valibot";
|
|
|
5
5
|
//#region src/generated/core/bodySerializer.gen.ts
|
|
6
6
|
const jsonBodySerializer = { bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value) };
|
|
7
7
|
|
|
8
|
-
//#endregion
|
|
9
|
-
//#region src/generated/core/params.gen.ts
|
|
10
|
-
const extraPrefixes = Object.entries({
|
|
11
|
-
$body_: "body",
|
|
12
|
-
$headers_: "headers",
|
|
13
|
-
$path_: "path",
|
|
14
|
-
$query_: "query"
|
|
15
|
-
});
|
|
16
|
-
|
|
17
8
|
//#endregion
|
|
18
9
|
//#region src/generated/core/serverSentEvents.gen.ts
|
|
19
10
|
function createSseClient({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }) {
|
|
@@ -3398,23 +3389,59 @@ const onLogoutElsewhere = (handler) => {
|
|
|
3398
3389
|
|
|
3399
3390
|
//#endregion
|
|
3400
3391
|
//#region src/auth/authStore.ts
|
|
3401
|
-
const
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3392
|
+
const ensureSessionSync = () => {
|
|
3393
|
+
shared("sessionSyncInitialized", () => {
|
|
3394
|
+
onLogoutElsewhere(() => removeTokens());
|
|
3395
|
+
return true;
|
|
3396
|
+
});
|
|
3397
|
+
};
|
|
3398
|
+
const isLogged = shared("isLogged", () => {
|
|
3399
|
+
ensureSessionSync();
|
|
3400
|
+
const store = atom(initVals["isLogged"] === "true");
|
|
3401
|
+
store.subscribe((value) => setStoreCookie("isLogged", value));
|
|
3402
|
+
return store;
|
|
3403
|
+
});
|
|
3404
|
+
const accessToken = shared("accessToken", () => {
|
|
3405
|
+
ensureSessionSync();
|
|
3406
|
+
const store = atom(initVals["accessToken"]);
|
|
3407
|
+
store.subscribe((value) => setStoreCookie("accessToken", value));
|
|
3408
|
+
return store;
|
|
3409
|
+
});
|
|
3410
|
+
const refreshToken = shared("refreshToken", () => {
|
|
3411
|
+
ensureSessionSync();
|
|
3412
|
+
const store = atom(initVals["refreshToken"]);
|
|
3413
|
+
store.subscribe((value) => setStoreCookie("refreshToken", value));
|
|
3414
|
+
return store;
|
|
3415
|
+
});
|
|
3416
|
+
const expireAt = shared("expireAt", () => {
|
|
3417
|
+
const store = atom(Number(initVals["expireAt"]));
|
|
3418
|
+
store.subscribe((value) => setStoreCookie("expireAt", value));
|
|
3419
|
+
return store;
|
|
3420
|
+
});
|
|
3405
3421
|
const authError = shared("authError", () => atom(null));
|
|
3406
|
-
const requiresAction = shared("requiresAction", () =>
|
|
3407
|
-
const
|
|
3422
|
+
const requiresAction = shared("requiresAction", () => {
|
|
3423
|
+
const store = atom(initVals["requiresAction"] || null);
|
|
3424
|
+
store.subscribe((value) => setStoreCookie("requiresAction", value));
|
|
3425
|
+
return store;
|
|
3426
|
+
});
|
|
3427
|
+
const limitedAccessToken = shared("limitedAccessToken", () => {
|
|
3428
|
+
const store = atom(initVals["limitedAccessToken"] || null);
|
|
3429
|
+
store.subscribe((value) => setStoreCookie("limitedAccessToken", value));
|
|
3430
|
+
return store;
|
|
3431
|
+
});
|
|
3408
3432
|
const inFlight = shared("getTokenPromise", () => ({ promise: null }));
|
|
3409
|
-
const
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3433
|
+
const getProviderUrlAtom = (provider) => {
|
|
3434
|
+
switch (provider) {
|
|
3435
|
+
case "google": return googleAuthUrl;
|
|
3436
|
+
case "apple": return appleAuthUrl;
|
|
3437
|
+
case "microsoft": return microsoftAuthUrl;
|
|
3438
|
+
case "telegram": return telegramAuthUrl;
|
|
3439
|
+
default: return;
|
|
3440
|
+
}
|
|
3414
3441
|
};
|
|
3415
3442
|
const login = async (provider) => {
|
|
3416
3443
|
await initDeferred.promise;
|
|
3417
|
-
const authUrlAtom =
|
|
3444
|
+
const authUrlAtom = getProviderUrlAtom(provider);
|
|
3418
3445
|
if (!authUrlAtom) throw new Error(`Unsupported provider: ${provider}`);
|
|
3419
3446
|
const authUrl = authUrlAtom.get();
|
|
3420
3447
|
if (authUrl) window.location.href = authUrl;
|
|
@@ -3565,13 +3592,6 @@ const clearLimitedAccessState = () => {
|
|
|
3565
3592
|
requiresAction.set(null);
|
|
3566
3593
|
if (!(!!accessToken.get() && !!refreshToken.get())) isLogged.set(false);
|
|
3567
3594
|
};
|
|
3568
|
-
isLogged.subscribe((value) => setStoreCookie("isLogged", value));
|
|
3569
|
-
accessToken.subscribe((value) => setStoreCookie("accessToken", value));
|
|
3570
|
-
refreshToken.subscribe((value) => setStoreCookie("refreshToken", value));
|
|
3571
|
-
expireAt.subscribe((value) => setStoreCookie("expireAt", value));
|
|
3572
|
-
requiresAction.subscribe((value) => setStoreCookie("requiresAction", value));
|
|
3573
|
-
limitedAccessToken.subscribe((value) => setStoreCookie("limitedAccessToken", value));
|
|
3574
|
-
onLogoutElsewhere(removeTokens);
|
|
3575
3595
|
|
|
3576
3596
|
//#endregion
|
|
3577
3597
|
//#region src/auth/api-url.ts
|