@rixl/sdk 0.29.2 → 0.29.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/dist/index.js +11 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3499,6 +3499,16 @@ const isTokenExpired = (expireAt) => {
|
|
|
3499
3499
|
return Date.now() >= expireAt;
|
|
3500
3500
|
};
|
|
3501
3501
|
|
|
3502
|
+
//#endregion
|
|
3503
|
+
//#region src/auth/utils/requires-action.ts
|
|
3504
|
+
/**
|
|
3505
|
+
* Whether a token response is limited scope: it names an action the user must
|
|
3506
|
+
* take before getting full tokens (e.g. `add_email`). The gateway emits every
|
|
3507
|
+
* field, so a full-scope response carries `requires_action: ""` too; only a
|
|
3508
|
+
* non-empty value counts.
|
|
3509
|
+
*/
|
|
3510
|
+
const isLimitedScopeTokenResponse = (result) => "requires_action" in result && Boolean(result.requires_action);
|
|
3511
|
+
|
|
3502
3512
|
//#endregion
|
|
3503
3513
|
//#region src/auth/authStore.ts
|
|
3504
3514
|
const isLogged = shared("isLogged", () => atom(initVals["isLogged"] === "true"));
|
|
@@ -3525,7 +3535,7 @@ const login = async (provider) => {
|
|
|
3525
3535
|
};
|
|
3526
3536
|
const refreshAccessToken = async (refresh) => {
|
|
3527
3537
|
const result = await refreshTokens("Bearer", refresh);
|
|
3528
|
-
if (!(
|
|
3538
|
+
if (!isLimitedScopeTokenResponse(result)) setTokens(result.access_token, result.refresh_token, result.expires_in);
|
|
3529
3539
|
};
|
|
3530
3540
|
const ensureValidAccessToken = async (refresh) => {
|
|
3531
3541
|
if (accessToken.get() && !isTokenExpired(expireAt.get())) return;
|
|
@@ -3832,9 +3842,6 @@ const initConfig = async (config) => {
|
|
|
3832
3842
|
updateTelegramAuthUrl();
|
|
3833
3843
|
}
|
|
3834
3844
|
};
|
|
3835
|
-
const isLimitedScopeTokenResponse = (result) => {
|
|
3836
|
-
return "requires_action" in result;
|
|
3837
|
-
};
|
|
3838
3845
|
const applyTokenExchangeResult = (result) => {
|
|
3839
3846
|
if (isLimitedScopeTokenResponse(result)) {
|
|
3840
3847
|
setLimitedAccessState(result.access_token, result.requires_action);
|