@oxyhq/core 5.5.0 → 6.0.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/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/HttpService.js +6 -3
- package/dist/cjs/OxyServices.base.js +7 -102
- package/dist/cjs/boot/coldBootV2.js +350 -0
- package/dist/cjs/boot/deviceBootReturn.js +152 -0
- package/dist/cjs/crypto/keyManager.js +95 -0
- package/dist/cjs/i18n/locales/en-US.json +13 -1
- package/dist/cjs/i18n/locales/es-ES.json +13 -1
- package/dist/cjs/i18n/locales/locales/en-US.json +13 -1
- package/dist/cjs/i18n/locales/locales/es-ES.json +13 -1
- package/dist/cjs/index.js +47 -44
- package/dist/cjs/mixins/OxyServices.accounts.js +6 -13
- package/dist/cjs/mixins/OxyServices.auth.js +66 -201
- package/dist/cjs/mixins/OxyServices.authorizedApps.js +38 -0
- package/dist/cjs/mixins/OxyServices.deviceBoot.js +119 -0
- package/dist/cjs/mixins/index.js +13 -17
- package/dist/cjs/session/SessionClient.js +40 -1
- package/dist/cjs/session/authStateStore.js +284 -0
- package/dist/cjs/session/refresh.js +264 -0
- package/dist/cjs/utils/accountUtils.js +1 -55
- package/dist/cjs/utils/authWebUrl.js +6 -15
- package/dist/cjs/utils/fapiAutoDetect.js +16 -64
- package/dist/cjs/utils/platform.js +19 -0
- package/dist/cjs/utils/ssoBounce.js +15 -362
- package/dist/cjs/utils/validationUtils.js +57 -0
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/HttpService.js +6 -3
- package/dist/esm/OxyServices.base.js +7 -102
- package/dist/esm/boot/coldBootV2.js +344 -0
- package/dist/esm/boot/deviceBootReturn.js +146 -0
- package/dist/esm/crypto/keyManager.js +95 -0
- package/dist/esm/i18n/locales/en-US.json +13 -1
- package/dist/esm/i18n/locales/es-ES.json +13 -1
- package/dist/esm/i18n/locales/locales/en-US.json +13 -1
- package/dist/esm/i18n/locales/locales/es-ES.json +13 -1
- package/dist/esm/index.js +28 -18
- package/dist/esm/mixins/OxyServices.accounts.js +6 -13
- package/dist/esm/mixins/OxyServices.auth.js +66 -201
- package/dist/esm/mixins/OxyServices.authorizedApps.js +35 -0
- package/dist/esm/mixins/OxyServices.deviceBoot.js +116 -0
- package/dist/esm/mixins/index.js +13 -17
- package/dist/esm/session/SessionClient.js +40 -1
- package/dist/esm/session/authStateStore.js +278 -0
- package/dist/esm/session/refresh.js +257 -0
- package/dist/esm/utils/accountUtils.js +0 -53
- package/dist/esm/utils/authWebUrl.js +6 -14
- package/dist/esm/utils/fapiAutoDetect.js +16 -63
- package/dist/esm/utils/platform.js +18 -0
- package/dist/esm/utils/ssoBounce.js +14 -345
- package/dist/esm/utils/validationUtils.js +56 -0
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/HttpService.d.ts +13 -0
- package/dist/types/OxyServices.base.d.ts +0 -52
- package/dist/types/OxyServices.d.ts +0 -25
- package/dist/types/boot/coldBootV2.d.ts +76 -0
- package/dist/types/boot/deviceBootReturn.d.ts +83 -0
- package/dist/types/crypto/keyManager.d.ts +21 -0
- package/dist/types/index.d.ts +15 -21
- package/dist/types/mixins/OxyServices.accounts.d.ts +0 -2
- package/dist/types/mixins/OxyServices.analytics.d.ts +0 -2
- package/dist/types/mixins/OxyServices.appData.d.ts +0 -2
- package/dist/types/mixins/OxyServices.assets.d.ts +0 -2
- package/dist/types/mixins/OxyServices.auth.d.ts +35 -77
- package/dist/types/mixins/{OxyServices.redirect.d.ts → OxyServices.authorizedApps.d.ts} +35 -33
- package/dist/types/mixins/OxyServices.civic.d.ts +0 -2
- package/dist/types/mixins/OxyServices.connectedApps.d.ts +0 -2
- package/dist/types/mixins/OxyServices.contacts.d.ts +0 -2
- package/dist/types/mixins/OxyServices.deviceBoot.d.ts +110 -0
- package/dist/types/mixins/OxyServices.devices.d.ts +0 -2
- package/dist/types/mixins/OxyServices.features.d.ts +0 -2
- package/dist/types/mixins/OxyServices.identity.d.ts +0 -2
- package/dist/types/mixins/OxyServices.language.d.ts +0 -2
- package/dist/types/mixins/OxyServices.links.d.ts +0 -2
- package/dist/types/mixins/OxyServices.location.d.ts +0 -2
- package/dist/types/mixins/OxyServices.nodes.d.ts +0 -2
- package/dist/types/mixins/OxyServices.payment.d.ts +0 -2
- package/dist/types/mixins/OxyServices.privacy.d.ts +0 -2
- package/dist/types/mixins/OxyServices.reputation.d.ts +0 -2
- package/dist/types/mixins/OxyServices.security.d.ts +0 -2
- package/dist/types/mixins/OxyServices.topics.d.ts +0 -2
- package/dist/types/mixins/OxyServices.user.d.ts +0 -2
- package/dist/types/mixins/OxyServices.utility.d.ts +0 -2
- package/dist/types/mixins/index.d.ts +6 -9
- package/dist/types/models/interfaces.d.ts +0 -67
- package/dist/types/session/SessionClient.d.ts +25 -0
- package/dist/types/session/authStateStore.d.ts +119 -0
- package/dist/types/session/refresh.d.ts +93 -0
- package/dist/types/utils/accountUtils.d.ts +0 -14
- package/dist/types/utils/authWebUrl.d.ts +6 -12
- package/dist/types/utils/fapiAutoDetect.d.ts +15 -38
- package/dist/types/utils/platform.d.ts +14 -0
- package/dist/types/utils/ssoBounce.d.ts +14 -280
- package/dist/types/utils/validationUtils.d.ts +15 -0
- package/package.json +2 -2
- package/src/HttpService.ts +19 -3
- package/src/OxyServices.base.ts +7 -112
- package/src/OxyServices.ts +0 -38
- package/src/boot/__tests__/coldBootV2.test.ts +317 -0
- package/src/boot/__tests__/deviceBootReturn.test.ts +158 -0
- package/src/boot/coldBootV2.ts +426 -0
- package/src/boot/deviceBootReturn.ts +195 -0
- package/src/crypto/__tests__/sharedDeviceToken.test.ts +24 -0
- package/src/crypto/keyManager.ts +101 -0
- package/src/i18n/locales/en-US.json +13 -1
- package/src/i18n/locales/es-ES.json +13 -1
- package/src/index.ts +74 -65
- package/src/mixins/OxyServices.accounts.ts +6 -13
- package/src/mixins/OxyServices.auth.ts +78 -253
- package/src/mixins/OxyServices.authorizedApps.ts +75 -0
- package/src/mixins/OxyServices.deviceBoot.ts +146 -0
- package/src/mixins/__tests__/OxyServices.deviceBoot.test.ts +107 -0
- package/src/mixins/__tests__/accounts.test.ts +17 -44
- package/src/mixins/__tests__/authorizedApps.test.ts +63 -0
- package/src/mixins/__tests__/passwordSignIn.test.ts +91 -0
- package/src/mixins/index.ts +16 -22
- package/src/models/interfaces.ts +0 -79
- package/src/session/SessionClient.ts +52 -1
- package/src/session/__tests__/SessionClient.additive.test.ts +92 -0
- package/src/session/__tests__/SessionClient.rest.test.ts +25 -0
- package/src/session/__tests__/SessionClient.state.test.ts +18 -5
- package/src/session/__tests__/authStateStore.test.ts +209 -0
- package/src/session/__tests__/refresh.test.ts +256 -0
- package/src/session/authStateStore.ts +335 -0
- package/src/session/refresh.ts +334 -0
- package/src/utils/__tests__/authWebUrl.test.ts +5 -29
- package/src/utils/__tests__/fapiAutoDetect.test.ts +5 -126
- package/src/utils/__tests__/validationUtils.test.ts +30 -0
- package/src/utils/accountUtils.ts +0 -62
- package/src/utils/authWebUrl.ts +6 -15
- package/src/utils/fapiAutoDetect.ts +16 -60
- package/src/utils/platform.ts +21 -0
- package/src/utils/ssoBounce.ts +14 -393
- package/src/utils/validationUtils.ts +62 -0
- package/dist/cjs/AuthManager.js +0 -1110
- package/dist/cjs/AuthManagerTypes.js +0 -13
- package/dist/cjs/CrossDomainAuth.js +0 -206
- package/dist/cjs/mixins/OxyServices.fedcm.js +0 -823
- package/dist/cjs/mixins/OxyServices.redirect.js +0 -95
- package/dist/cjs/mixins/OxyServices.silent.js +0 -204
- package/dist/cjs/mixins/OxyServices.sso.js +0 -208
- package/dist/cjs/utils/ssoEstablish.js +0 -110
- package/dist/cjs/utils/ssoReturn.js +0 -275
- package/dist/esm/AuthManager.js +0 -1105
- package/dist/esm/AuthManagerTypes.js +0 -12
- package/dist/esm/CrossDomainAuth.js +0 -201
- package/dist/esm/mixins/OxyServices.fedcm.js +0 -821
- package/dist/esm/mixins/OxyServices.redirect.js +0 -92
- package/dist/esm/mixins/OxyServices.silent.js +0 -202
- package/dist/esm/mixins/OxyServices.sso.js +0 -204
- package/dist/esm/utils/ssoEstablish.js +0 -107
- package/dist/esm/utils/ssoReturn.js +0 -271
- package/dist/types/AuthManager.d.ts +0 -380
- package/dist/types/AuthManagerTypes.d.ts +0 -81
- package/dist/types/CrossDomainAuth.d.ts +0 -164
- package/dist/types/mixins/OxyServices.fedcm.d.ts +0 -331
- package/dist/types/mixins/OxyServices.silent.d.ts +0 -132
- package/dist/types/mixins/OxyServices.sso.d.ts +0 -138
- package/dist/types/utils/ssoEstablish.d.ts +0 -85
- package/dist/types/utils/ssoReturn.d.ts +0 -156
- package/src/AuthManager.ts +0 -1269
- package/src/AuthManagerTypes.ts +0 -86
- package/src/CrossDomainAuth.ts +0 -243
- package/src/__tests__/authManager.cookiePath.test.ts +0 -390
- package/src/__tests__/authManager.security.test.ts +0 -377
- package/src/__tests__/crossDomainAuth.test.ts +0 -116
- package/src/__tests__/establishDeviceRefreshSlot.test.ts +0 -221
- package/src/mixins/OxyServices.fedcm.ts +0 -1026
- package/src/mixins/OxyServices.redirect.ts +0 -122
- package/src/mixins/OxyServices.silent.ts +0 -272
- package/src/mixins/OxyServices.sso.ts +0 -261
- package/src/mixins/__tests__/constructorAuthWebUrl.test.ts +0 -85
- package/src/mixins/__tests__/fedcm.test.ts +0 -667
- package/src/mixins/__tests__/sessionBaseUrl.test.ts +0 -61
- package/src/mixins/__tests__/silent.test.ts +0 -102
- package/src/mixins/__tests__/sso.test.ts +0 -228
- package/src/utils/__tests__/consumeSsoReturn.test.ts +0 -816
- package/src/utils/__tests__/ssoBounce.test.ts +0 -219
- package/src/utils/__tests__/ssoEstablish.test.ts +0 -204
- package/src/utils/__tests__/ssoReturn.test.ts +0 -276
- package/src/utils/ssoEstablish.ts +0 -174
- package/src/utils/ssoReturn.ts +0 -389
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OxyServicesRedirectAuthMixin = OxyServicesRedirectAuthMixin;
|
|
4
|
-
exports.RedirectAuthMixin = OxyServicesRedirectAuthMixin;
|
|
5
|
-
const OxyServices_errors_1 = require("../OxyServices.errors");
|
|
6
|
-
const ssoBounce_1 = require("../utils/ssoBounce");
|
|
7
|
-
/**
|
|
8
|
-
* Redirect-based authentication without bearer tokens in URLs.
|
|
9
|
-
*
|
|
10
|
-
* The redirect fallback now uses the same central SSO code-return contract as
|
|
11
|
-
* cold boot: the RP stores CSRF/destination state in sessionStorage, navigates
|
|
12
|
-
* to the central IdP, receives only an opaque one-time code in the URL fragment,
|
|
13
|
-
* and the provider's `sso-return` step exchanges that code for the real session.
|
|
14
|
-
*/
|
|
15
|
-
function OxyServicesRedirectAuthMixin(Base) {
|
|
16
|
-
return class extends Base {
|
|
17
|
-
constructor(...args) {
|
|
18
|
-
super(...args);
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Start a full-page redirect through the central SSO flow.
|
|
22
|
-
*
|
|
23
|
-
* No access token, refresh token, or session id is ever put in the URL or
|
|
24
|
-
* localStorage. The caller's provider must run `consumeSsoReturn` on startup
|
|
25
|
-
* to complete the code exchange and commit the session.
|
|
26
|
-
*/
|
|
27
|
-
signInWithRedirect(options = {}) {
|
|
28
|
-
if (typeof window === 'undefined' || typeof window.sessionStorage === 'undefined') {
|
|
29
|
-
throw new OxyServices_errors_1.OxyAuthenticationError('Redirect authentication requires browser sessionStorage');
|
|
30
|
-
}
|
|
31
|
-
const origin = window.location.origin;
|
|
32
|
-
const state = this.generateState();
|
|
33
|
-
const destination = options.preserveUrl === false
|
|
34
|
-
? (options.redirectUri || origin)
|
|
35
|
-
: (options.redirectUri || window.location.href);
|
|
36
|
-
window.sessionStorage.setItem((0, ssoBounce_1.ssoStateKey)(origin), state);
|
|
37
|
-
window.sessionStorage.setItem((0, ssoBounce_1.ssoGuardKey)(origin), String(Date.now()));
|
|
38
|
-
window.sessionStorage.setItem((0, ssoBounce_1.ssoDestKey)(origin), destination);
|
|
39
|
-
window.sessionStorage.setItem((0, ssoBounce_1.ssoAttemptedKey)(origin), '1');
|
|
40
|
-
window.location.assign((0, ssoBounce_1.buildSsoBounceUrl)(origin, state, this.config.authWebUrl));
|
|
41
|
-
}
|
|
42
|
-
signUpWithRedirect(options = {}) {
|
|
43
|
-
this.signInWithRedirect({ ...options, mode: 'signup' });
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Legacy token-query callbacks are intentionally rejected. Modern providers
|
|
47
|
-
* complete redirect auth through `consumeSsoReturn`, which accepts only
|
|
48
|
-
* `#oxy_sso=ok&code=...`.
|
|
49
|
-
*/
|
|
50
|
-
handleAuthCallback() {
|
|
51
|
-
if (typeof window === 'undefined') {
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
const url = new URL(window.location.href);
|
|
55
|
-
if (url.searchParams.has('access_token') || url.searchParams.has('session_id')) {
|
|
56
|
-
this.cleanAuthCallbackUrl(url);
|
|
57
|
-
throw new OxyServices_errors_1.OxyAuthenticationError('Legacy access-token redirect callbacks are no longer accepted.');
|
|
58
|
-
}
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
restoreSession() {
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
clearStoredSession() {
|
|
65
|
-
this.httpService.clearTokens();
|
|
66
|
-
}
|
|
67
|
-
getStoredSessionId() {
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
|
-
generateState() {
|
|
71
|
-
if (typeof crypto !== 'undefined' && crypto.randomUUID) {
|
|
72
|
-
return crypto.randomUUID();
|
|
73
|
-
}
|
|
74
|
-
if (typeof crypto !== 'undefined' && crypto.getRandomValues) {
|
|
75
|
-
const bytes = new Uint8Array(16);
|
|
76
|
-
crypto.getRandomValues(bytes);
|
|
77
|
-
return Array.from(bytes, b => b.toString(16).padStart(2, '0')).join('');
|
|
78
|
-
}
|
|
79
|
-
throw new Error('No secure random source available for state generation');
|
|
80
|
-
}
|
|
81
|
-
generateNonce() {
|
|
82
|
-
return this.generateState();
|
|
83
|
-
}
|
|
84
|
-
cleanAuthCallbackUrl(url) {
|
|
85
|
-
url.searchParams.delete('access_token');
|
|
86
|
-
url.searchParams.delete('session_id');
|
|
87
|
-
url.searchParams.delete('expires_at');
|
|
88
|
-
url.searchParams.delete('state');
|
|
89
|
-
url.searchParams.delete('nonce');
|
|
90
|
-
url.searchParams.delete('error');
|
|
91
|
-
url.searchParams.delete('error_description');
|
|
92
|
-
window.history.replaceState({}, '', url.toString());
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
}
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OxyServicesSilentAuthMixin = OxyServicesSilentAuthMixin;
|
|
4
|
-
exports.SilentAuthMixin = OxyServicesSilentAuthMixin;
|
|
5
|
-
const debugUtils_1 = require("../shared/utils/debugUtils");
|
|
6
|
-
const debug = (0, debugUtils_1.createDebugLogger)("SilentAuth");
|
|
7
|
-
/**
|
|
8
|
-
* Cross-domain silent browser auth helpers.
|
|
9
|
-
*
|
|
10
|
-
* The clean session model supports FedCM, tokenless redirect SSO, and silent
|
|
11
|
-
* iframe SSO. Bearer-token callback URLs are not part of this surface.
|
|
12
|
-
*/
|
|
13
|
-
function OxyServicesSilentAuthMixin(Base) {
|
|
14
|
-
var _a;
|
|
15
|
-
return _a = class extends Base {
|
|
16
|
-
constructor(...args) {
|
|
17
|
-
super(...args);
|
|
18
|
-
}
|
|
19
|
-
/** Resolve auth URL from config or static default (method, not getter — getters break in TS mixins) */
|
|
20
|
-
resolveAuthUrl() {
|
|
21
|
-
return (this.config.authWebUrl || this.constructor.DEFAULT_AUTH_URL);
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Silent sign-in using hidden iframe
|
|
25
|
-
*
|
|
26
|
-
* Attempts to automatically re-authenticate the user without any UI.
|
|
27
|
-
* This is what enables seamless SSO across all Oxy domains.
|
|
28
|
-
*
|
|
29
|
-
* How it works:
|
|
30
|
-
* 1. Creates hidden iframe pointing to auth.oxy.so/silent-auth
|
|
31
|
-
* 2. If user has valid session at auth.oxy.so, it exchanges an opaque SSO code
|
|
32
|
-
* 3. If not, iframe responds with null (no error thrown)
|
|
33
|
-
*
|
|
34
|
-
* This should be called on app startup to check for existing sessions.
|
|
35
|
-
*
|
|
36
|
-
* @param options - Silent auth options
|
|
37
|
-
* @returns Session if user is signed in, null otherwise
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* ```typescript
|
|
41
|
-
* useEffect(() => {
|
|
42
|
-
* const checkAuth = async () => {
|
|
43
|
-
* const session = await oxyServices.silentSignIn();
|
|
44
|
-
* if (session) {
|
|
45
|
-
* setUser(session.user);
|
|
46
|
-
* }
|
|
47
|
-
* };
|
|
48
|
-
* checkAuth();
|
|
49
|
-
* }, []);
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
async silentSignIn(options = {}) {
|
|
53
|
-
if (typeof window === "undefined") {
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
const timeout = options.timeout || this.constructor.SILENT_TIMEOUT;
|
|
57
|
-
const nonce = this.generateNonce();
|
|
58
|
-
const clientId = window.location.origin;
|
|
59
|
-
// Resolve the IdP origin for the iframe. An explicit per-apex override (the
|
|
60
|
-
// durable cross-domain reload path — see `SilentAuthOptions.authWebUrlOverride`)
|
|
61
|
-
// wins over the instance's configured central auth URL. The SAME origin is
|
|
62
|
-
// handed to `waitForIframeAuth` so the postMessage origin check matches the
|
|
63
|
-
// exact host the iframe was loaded from.
|
|
64
|
-
const authOrigin = options.authWebUrlOverride && options.authWebUrlOverride.length > 0
|
|
65
|
-
? options.authWebUrlOverride
|
|
66
|
-
: this.resolveAuthUrl();
|
|
67
|
-
const iframe = document.createElement("iframe");
|
|
68
|
-
iframe.style.display = "none";
|
|
69
|
-
iframe.style.position = "absolute";
|
|
70
|
-
iframe.style.width = "0";
|
|
71
|
-
iframe.style.height = "0";
|
|
72
|
-
iframe.style.border = "none";
|
|
73
|
-
const silentUrl = `${authOrigin}/auth/silent?` +
|
|
74
|
-
`client_id=${encodeURIComponent(clientId)}&` +
|
|
75
|
-
`nonce=${nonce}`;
|
|
76
|
-
iframe.src = silentUrl;
|
|
77
|
-
document.body.appendChild(iframe);
|
|
78
|
-
try {
|
|
79
|
-
const session = await this.waitForIframeAuth(iframe, timeout, authOrigin);
|
|
80
|
-
// Bail early on incomplete responses. The iframe contract requires
|
|
81
|
-
// both an access token and a session id; anything less is unusable.
|
|
82
|
-
// Returning `null` here (without installing the token) prevents a
|
|
83
|
-
// stale credential from being committed to HttpService when the
|
|
84
|
-
// user is actually signed out — that pattern caused a `getCurrentUser`
|
|
85
|
-
// -> 401 -> token-clear loop in consumer apps because callers gated
|
|
86
|
-
// on `session?.user` and never installed the user via
|
|
87
|
-
// `handleAuthSuccess`, while HttpService quietly held the token.
|
|
88
|
-
const accessToken = session
|
|
89
|
-
? session.accessToken
|
|
90
|
-
: undefined;
|
|
91
|
-
if (!session || !accessToken || !session.sessionId) {
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
// Snapshot the previous token so we can roll back if the user
|
|
95
|
-
// lookup below fails — this avoids leaving a half-committed session
|
|
96
|
-
// (token installed, user missing) which would let the next
|
|
97
|
-
// authenticated request 401 with no way to recover.
|
|
98
|
-
const previousAccessToken = this.httpService.getAccessToken();
|
|
99
|
-
this.httpService.setTokens(accessToken);
|
|
100
|
-
// The iframe typically returns `{ sessionId, accessToken }` without
|
|
101
|
-
// user data. Fetch the user explicitly so callers receive a
|
|
102
|
-
// fully-formed session and never need a second `/users/me` round
|
|
103
|
-
// trip. If this fails the session is unusable — revert the token
|
|
104
|
-
// and return null so the caller treats this exactly like a
|
|
105
|
-
// missing-session response.
|
|
106
|
-
if (!session.user) {
|
|
107
|
-
try {
|
|
108
|
-
const userData = await this.makeRequest("GET", `/session/user/${session.sessionId}`, undefined, { cache: false, retry: false });
|
|
109
|
-
if (!userData) {
|
|
110
|
-
throw new Error("Empty user response");
|
|
111
|
-
}
|
|
112
|
-
session.user = userData;
|
|
113
|
-
}
|
|
114
|
-
catch (userError) {
|
|
115
|
-
debug.warn("silentSignIn: failed to fetch user data, rolling back token", userError);
|
|
116
|
-
if (previousAccessToken) {
|
|
117
|
-
this.httpService.setTokens(previousAccessToken);
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
this.httpService.clearTokens();
|
|
121
|
-
}
|
|
122
|
-
return null;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
return session;
|
|
126
|
-
}
|
|
127
|
-
catch (error) {
|
|
128
|
-
return null;
|
|
129
|
-
}
|
|
130
|
-
finally {
|
|
131
|
-
document.body.removeChild(iframe);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Wait for authentication response from iframe
|
|
136
|
-
*
|
|
137
|
-
* @private
|
|
138
|
-
*/
|
|
139
|
-
async waitForIframeAuth(iframe, timeout, expectedOrigin) {
|
|
140
|
-
return new Promise((resolve) => {
|
|
141
|
-
const timeoutId = setTimeout(() => {
|
|
142
|
-
cleanup();
|
|
143
|
-
resolve(null); // Silent failure - don't throw
|
|
144
|
-
}, timeout);
|
|
145
|
-
const messageHandler = (event) => {
|
|
146
|
-
// Verify origin against the EXACT host the iframe was loaded from
|
|
147
|
-
// (`expectedOrigin`). For the per-apex durable-restore path this is
|
|
148
|
-
// `auth.<rp-apex>`, not the instance's central `resolveAuthUrl()` — so
|
|
149
|
-
// we must honour the caller-supplied origin, never re-derive it here.
|
|
150
|
-
if (event.origin !== expectedOrigin) {
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
const { type, session } = event.data;
|
|
154
|
-
if (type !== "oxy_silent_auth") {
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
cleanup();
|
|
158
|
-
resolve(session || null);
|
|
159
|
-
};
|
|
160
|
-
// Fail-fast on a load failure. When the per-apex `/auth/silent` host is
|
|
161
|
-
// unreachable, blocked by CSP `frame-ancestors`/`X-Frame-Options`, or the
|
|
162
|
-
// network drops, the iframe never posts a message — without this handler
|
|
163
|
-
// the silent restore would block for the FULL `timeout` (dead latency in
|
|
164
|
-
// the cold-boot critical path). `onerror`/`onabort` fire on a failed load,
|
|
165
|
-
// so resolve `null` immediately and let the next cold-boot step run. The
|
|
166
|
-
// success path posts a message and is handled above; these only catch the
|
|
167
|
-
// no-message failure modes.
|
|
168
|
-
const failFast = () => {
|
|
169
|
-
cleanup();
|
|
170
|
-
resolve(null);
|
|
171
|
-
};
|
|
172
|
-
iframe.onerror = failFast;
|
|
173
|
-
iframe.onabort = failFast;
|
|
174
|
-
const cleanup = () => {
|
|
175
|
-
clearTimeout(timeoutId);
|
|
176
|
-
iframe.onerror = null;
|
|
177
|
-
iframe.onabort = null;
|
|
178
|
-
window.removeEventListener("message", messageHandler);
|
|
179
|
-
};
|
|
180
|
-
window.addEventListener("message", messageHandler);
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Generate nonce for replay attack prevention
|
|
185
|
-
*
|
|
186
|
-
* @private
|
|
187
|
-
*/
|
|
188
|
-
generateNonce() {
|
|
189
|
-
if (typeof crypto !== "undefined" && crypto.randomUUID) {
|
|
190
|
-
return crypto.randomUUID();
|
|
191
|
-
}
|
|
192
|
-
if (typeof crypto !== "undefined" && crypto.getRandomValues) {
|
|
193
|
-
const bytes = new Uint8Array(16);
|
|
194
|
-
crypto.getRandomValues(bytes);
|
|
195
|
-
return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
196
|
-
}
|
|
197
|
-
throw new Error("No secure random source available for nonce generation");
|
|
198
|
-
}
|
|
199
|
-
},
|
|
200
|
-
_a.DEFAULT_AUTH_URL = "https://auth.oxy.so",
|
|
201
|
-
_a.SILENT_TIMEOUT = 5000 // 5 seconds
|
|
202
|
-
,
|
|
203
|
-
_a;
|
|
204
|
-
}
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Central Cross-Domain SSO (opaque-code) Mixin
|
|
4
|
-
*
|
|
5
|
-
* Implements the Relying-Party half of TRUE central cross-domain SSO
|
|
6
|
-
* (Google/Meta/Clerk style). The central IdP at `auth.oxy.so` owns the session;
|
|
7
|
-
* an RP bounces a top-level redirect (prompt=none) to `auth.oxy.so/sso`, which
|
|
8
|
-
* returns an OPAQUE single-use code in the redirect fragment. The RP then
|
|
9
|
-
* exchanges that code here for the real session.
|
|
10
|
-
*
|
|
11
|
-
* Security properties:
|
|
12
|
-
* - NO token/JWT ever travels in a URL — only the opaque code does. The real
|
|
13
|
-
* `accessToken` is delivered exclusively in this exchange response body.
|
|
14
|
-
* - The exchange is a CORS POST with NO credentials/cookies — the opaque code
|
|
15
|
-
* is the only bearer of authority, and the central store burns it atomically
|
|
16
|
-
* (single-use). Sending no cookies keeps the request a clean, ambient-
|
|
17
|
-
* authority-free bearer exchange that the central `POST /sso/exchange`
|
|
18
|
-
* endpoint validates by `Origin` against the code's bound `clientOrigin`.
|
|
19
|
-
* - The code is minted server-side bound to the RP origin and expires in
|
|
20
|
-
* seconds, so a leaked code is useless cross-origin and short-lived.
|
|
21
|
-
*
|
|
22
|
-
* On success the mixin plants the returned access token via
|
|
23
|
-
* `httpService.setTokens(...)` — mirroring `exchangeIdTokenForSession` /
|
|
24
|
-
* `verifyChallenge` — so callers do NOT need to plant tokens manually.
|
|
25
|
-
*/
|
|
26
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.generateSsoState = generateSsoState;
|
|
28
|
-
exports.OxyServicesSsoMixin = OxyServicesSsoMixin;
|
|
29
|
-
const debugUtils_1 = require("../shared/utils/debugUtils");
|
|
30
|
-
const ssoBounce_1 = require("../utils/ssoBounce");
|
|
31
|
-
const debug = (0, debugUtils_1.createDebugLogger)('SSO');
|
|
32
|
-
/**
|
|
33
|
-
* Generate a cryptographically secure state value for the SSO bounce.
|
|
34
|
-
*
|
|
35
|
-
* Exposed as a module-level helper (in addition to the instance method below)
|
|
36
|
-
* so consumers that do not yet hold an `OxyServices` instance can still mint a
|
|
37
|
-
* bounce state. Uses `crypto.randomUUID` with a `getRandomValues` fallback.
|
|
38
|
-
*/
|
|
39
|
-
function generateSsoState() {
|
|
40
|
-
if (typeof crypto !== 'undefined' && crypto.randomUUID) {
|
|
41
|
-
return crypto.randomUUID();
|
|
42
|
-
}
|
|
43
|
-
if (typeof crypto !== 'undefined' && crypto.getRandomValues) {
|
|
44
|
-
const bytes = new Uint8Array(16);
|
|
45
|
-
crypto.getRandomValues(bytes);
|
|
46
|
-
return Array.from(bytes, b => b.toString(16).padStart(2, '0')).join('');
|
|
47
|
-
}
|
|
48
|
-
throw new Error('No secure random source available for SSO state generation');
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Read the SSO bounce state stored for the current browser origin, if any.
|
|
52
|
-
*
|
|
53
|
-
* Returns `null` outside a browser (no `window`/`sessionStorage`) or when no
|
|
54
|
-
* state is stored — in which case the caller cannot (and must not) enforce a
|
|
55
|
-
* state match, e.g. native flows or pre-hydration callbacks that already
|
|
56
|
-
* validated the state before this exchange.
|
|
57
|
-
*/
|
|
58
|
-
function getStoredSsoStateForCurrentOrigin() {
|
|
59
|
-
if (typeof window === 'undefined' || !window.location || !window.sessionStorage) {
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
try {
|
|
63
|
-
return window.sessionStorage.getItem((0, ssoBounce_1.ssoStateKey)(window.location.origin));
|
|
64
|
-
}
|
|
65
|
-
catch {
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
function OxyServicesSsoMixin(Base) {
|
|
70
|
-
return class extends Base {
|
|
71
|
-
constructor(...args) {
|
|
72
|
-
super(...args);
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Generate cryptographically secure state for the SSO bounce (CSRF
|
|
76
|
-
* protection). Delegates to the module-level {@link generateSsoState}
|
|
77
|
-
* helper, which uses `crypto.randomUUID` when available and falls back to
|
|
78
|
-
* `crypto.getRandomValues`.
|
|
79
|
-
*/
|
|
80
|
-
generateSsoState() {
|
|
81
|
-
return generateSsoState();
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Exchange an opaque single-use SSO code for the real Oxy session.
|
|
85
|
-
*
|
|
86
|
-
* POSTs `{ code }` to `${getSessionBaseUrl()}/sso/exchange` as a CORS
|
|
87
|
-
* request with NO credentials/cookies. On success the returned access token
|
|
88
|
-
* is planted via `httpService.setTokens(...)` (matching
|
|
89
|
-
* `exchangeIdTokenForSession` / `verifyChallenge`), so callers do not need
|
|
90
|
-
* to plant tokens manually.
|
|
91
|
-
*
|
|
92
|
-
* @param code - The opaque single-use code delivered in the SSO return
|
|
93
|
-
* fragment (see {@link parseSsoReturnFragment}). The central store burns
|
|
94
|
-
* it atomically on exchange.
|
|
95
|
-
* @param state - The state value returned alongside the code. In browsers,
|
|
96
|
-
* when an SSO bounce state is still stored for the current origin, this
|
|
97
|
-
* must match before any token-committing exchange is attempted.
|
|
98
|
-
* @returns The resolved {@link SessionLoginResponse}.
|
|
99
|
-
*/
|
|
100
|
-
async exchangeSsoCode(code, state) {
|
|
101
|
-
if (typeof code !== 'string' || code.length === 0) {
|
|
102
|
-
throw this.handleError(new Error('exchangeSsoCode requires a non-empty code'));
|
|
103
|
-
}
|
|
104
|
-
const expectedState = getStoredSsoStateForCurrentOrigin();
|
|
105
|
-
if (expectedState !== null && (typeof state !== 'string' || state.length === 0 || state !== expectedState)) {
|
|
106
|
-
throw this.handleError(new Error('SSO exchange state mismatch'));
|
|
107
|
-
}
|
|
108
|
-
const url = `${this.getSessionBaseUrl().replace(/\/$/, '')}/sso/exchange`;
|
|
109
|
-
debug.log('Exchanging SSO code for session...');
|
|
110
|
-
let response;
|
|
111
|
-
try {
|
|
112
|
-
response = await fetch(url, {
|
|
113
|
-
method: 'POST',
|
|
114
|
-
// No cookies: the opaque code is the sole bearer of authority and the
|
|
115
|
-
// server validates by Origin against the code's bound clientOrigin.
|
|
116
|
-
credentials: 'omit',
|
|
117
|
-
headers: {
|
|
118
|
-
'Content-Type': 'application/json',
|
|
119
|
-
Accept: 'application/json',
|
|
120
|
-
},
|
|
121
|
-
body: JSON.stringify({ code }),
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
catch (error) {
|
|
125
|
-
debug.error('SSO exchange request failed:', error instanceof Error ? error.message : String(error));
|
|
126
|
-
throw this.handleError(error);
|
|
127
|
-
}
|
|
128
|
-
if (!response.ok) {
|
|
129
|
-
throw this.handleError(new Error(`SSO exchange failed with HTTP ${response.status}`));
|
|
130
|
-
}
|
|
131
|
-
let payload;
|
|
132
|
-
try {
|
|
133
|
-
payload = (await response.json());
|
|
134
|
-
}
|
|
135
|
-
catch (error) {
|
|
136
|
-
throw this.handleError(error);
|
|
137
|
-
}
|
|
138
|
-
if (!payload || typeof payload.accessToken !== 'string' || payload.accessToken.length === 0) {
|
|
139
|
-
throw this.handleError(new Error('SSO exchange returned no access token'));
|
|
140
|
-
}
|
|
141
|
-
if (typeof payload.sessionId !== 'string' || payload.sessionId.length === 0) {
|
|
142
|
-
throw this.handleError(new Error('SSO exchange returned no sessionId'));
|
|
143
|
-
}
|
|
144
|
-
const userId = payload.user?.id ?? payload.user?._id;
|
|
145
|
-
if (!userId || typeof payload.user?.username !== 'string') {
|
|
146
|
-
throw this.handleError(new Error('SSO exchange returned an invalid user'));
|
|
147
|
-
}
|
|
148
|
-
const user = {
|
|
149
|
-
id: userId,
|
|
150
|
-
username: payload.user.username,
|
|
151
|
-
// `name.displayName` is optional on the contract. A no-name user is
|
|
152
|
-
// valid; carry whatever structured name the server sent (possibly an
|
|
153
|
-
// empty object) and let consumers fall back to a handle.
|
|
154
|
-
name: payload.user.name ?? {},
|
|
155
|
-
avatar: payload.user.avatar,
|
|
156
|
-
};
|
|
157
|
-
// Plant the access token exactly like exchangeIdTokenForSession does.
|
|
158
|
-
// The SSO exchange does not return a refresh token (the central store
|
|
159
|
-
// holds the refresh credential), so default it to an empty string.
|
|
160
|
-
this.httpService.setTokens(payload.accessToken);
|
|
161
|
-
debug.log('SSO exchange complete:', { hasSession: !!payload.sessionId });
|
|
162
|
-
const session = {
|
|
163
|
-
sessionId: payload.sessionId,
|
|
164
|
-
deviceId: '',
|
|
165
|
-
expiresAt: payload.expiresAt ?? '',
|
|
166
|
-
user,
|
|
167
|
-
accessToken: payload.accessToken,
|
|
168
|
-
};
|
|
169
|
-
return session;
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Mint a server-formed `/sso/establish` URL for the caller's OWN session,
|
|
173
|
-
* bound to an approved RP `origin`.
|
|
174
|
-
*
|
|
175
|
-
* Bearer-authenticated (the session id is taken from the caller's own
|
|
176
|
-
* bearer, server-side — never from any argument). The server validates that
|
|
177
|
-
* `origin` is an approved client origin (and matches the request `Origin`),
|
|
178
|
-
* derives the per-apex IdP host (`auth.<apex>`), mints a short-lived HS256
|
|
179
|
-
* establish-token, and returns a fully-formed
|
|
180
|
-
* `https://<auth-host>/sso/establish?et=…&return_to=<origin>/__oxy/sso-callback&state=<state>`.
|
|
181
|
-
*
|
|
182
|
-
* Used AFTER a web device-flow claim to plant the durable first-party
|
|
183
|
-
* `fedcm_session` cookie so a reload can re-mint a token (see
|
|
184
|
-
* {@link establishIdpSessionAfterClaim}). Cache-free (a POST is never
|
|
185
|
-
* cached, but `cache: false` is explicit).
|
|
186
|
-
*
|
|
187
|
-
* @param origin - The RP origin (`window.location.origin`) to establish for.
|
|
188
|
-
* @param state - The CSRF state echoed back in the callback fragment; the
|
|
189
|
-
* caller persists the SAME value under `ssoStateKey(origin)` so the
|
|
190
|
-
* post-bounce `sso-return` step validates it.
|
|
191
|
-
*/
|
|
192
|
-
async requestSsoEstablishUrl(origin, state) {
|
|
193
|
-
if (typeof origin !== 'string' || origin.length === 0) {
|
|
194
|
-
throw this.handleError(new Error('requestSsoEstablishUrl requires a non-empty origin'));
|
|
195
|
-
}
|
|
196
|
-
if (typeof state !== 'string' || state.length === 0) {
|
|
197
|
-
throw this.handleError(new Error('requestSsoEstablishUrl requires a non-empty state'));
|
|
198
|
-
}
|
|
199
|
-
const response = await this.makeRequest('POST', '/sso/establish-token', { origin, state }, { cache: false });
|
|
200
|
-
if (!response ||
|
|
201
|
-
typeof response.establishUrl !== 'string' ||
|
|
202
|
-
response.establishUrl.length === 0) {
|
|
203
|
-
throw this.handleError(new Error('SSO establish-token returned no establishUrl'));
|
|
204
|
-
}
|
|
205
|
-
return { establishUrl: response.establishUrl };
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Post-claim durable-session establish hop (web device-flow / "Sign in with
|
|
4
|
-
* Oxy" QR).
|
|
5
|
-
*
|
|
6
|
-
* A WEB device-flow claim (`claimSessionByToken`) plants only IN-MEMORY tokens:
|
|
7
|
-
* unlike a redirect/FedCM/silent sign-in, it never causes the IdP to plant a
|
|
8
|
-
* `fedcm_session` cookie. So a reload has nothing to restore from — the
|
|
9
|
-
* silent-iframe and `/sso` paths find no IdP session and the session is lost.
|
|
10
|
-
*
|
|
11
|
-
* This primitive closes that gap. AFTER the claim has committed and the session
|
|
12
|
-
* has been durably persisted, it performs ONE top-level establish hop through
|
|
13
|
-
* the RP's own per-apex IdP host (`auth.<rp-apex>`), reusing the EXISTING
|
|
14
|
-
* `/sso/establish` endpoint: the server mints a short-lived, host+audience-bound
|
|
15
|
-
* establish-token and returns a fully-formed establish URL; navigating to it
|
|
16
|
-
* plants the durable first-party `fedcm_session` cookie and bounces back to the
|
|
17
|
-
* RP callback with an opaque code the standard `sso-return` cold-boot step
|
|
18
|
-
* exchanges.
|
|
19
|
-
*
|
|
20
|
-
* It reuses the SAME per-origin `sessionStorage` bounce contract
|
|
21
|
-
* (`ssoStateKey` / `ssoGuardKey` / `ssoDestKey`) that {@link buildSsoBounceUrl}
|
|
22
|
-
* primes for the terminal `/sso` bounce, so the post-bounce `sso-return` step
|
|
23
|
-
* (`consumeSsoReturn`) validates the CSRF `state`, exchanges the code, and
|
|
24
|
-
* restores the user's real destination with no extra wiring.
|
|
25
|
-
*
|
|
26
|
-
* Contract:
|
|
27
|
-
* - WEB only — off-web / native it is a no-op returning `false`.
|
|
28
|
-
* - NEVER fires while sitting on the central IdP origin (that would loop the
|
|
29
|
-
* IdP against itself).
|
|
30
|
-
* - Bounce state is persisted ONLY after the establish-URL request succeeds, so
|
|
31
|
-
* a failed request leaves no stale state behind.
|
|
32
|
-
* - SINGLE attempt: the caller invokes this exactly once per successful claim.
|
|
33
|
-
* On ANY failure it does NOT navigate and returns `false`, leaving the
|
|
34
|
-
* committed in-memory session exactly as-is (the user is no worse off than
|
|
35
|
-
* before this hop existed).
|
|
36
|
-
* - Total: never throws. Failures are reported via {@link deps.onError} only.
|
|
37
|
-
*/
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.establishIdpSessionAfterClaim = establishIdpSessionAfterClaim;
|
|
40
|
-
const ssoBounce_1 = require("./ssoBounce");
|
|
41
|
-
const OxyServices_sso_1 = require("../mixins/OxyServices.sso");
|
|
42
|
-
/**
|
|
43
|
-
* Perform the post-claim establish hop. Returns `true` when a navigation to the
|
|
44
|
-
* establish URL was initiated (the document is being torn down and replaced by
|
|
45
|
-
* the IdP), `false` on every no-op / failure path.
|
|
46
|
-
*
|
|
47
|
-
* @param client - The exchange surface (`oxyServices.requestSsoEstablishUrl`).
|
|
48
|
-
* @param deps - Injectable web seams; see {@link EstablishAfterClaimDeps}.
|
|
49
|
-
*/
|
|
50
|
-
async function establishIdpSessionAfterClaim(client, deps = {}) {
|
|
51
|
-
const isWeb = deps.isWeb ??
|
|
52
|
-
(() => typeof window !== 'undefined' &&
|
|
53
|
-
typeof window.sessionStorage !== 'undefined');
|
|
54
|
-
if (!isWeb()) {
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
const storage = deps.storage ?? window.sessionStorage;
|
|
58
|
-
const location = deps.location ?? window.location;
|
|
59
|
-
const navigate = deps.navigate ?? ssoBounce_1.ssoNavigate;
|
|
60
|
-
const generateState = deps.generateState ?? OxyServices_sso_1.generateSsoState;
|
|
61
|
-
const now = deps.now ?? (() => Date.now());
|
|
62
|
-
const origin = location.origin;
|
|
63
|
-
// Never establish while sitting on the central IdP itself — that would bounce
|
|
64
|
-
// the IdP against itself. (The device-flow claim can only happen on an RP.)
|
|
65
|
-
if ((0, ssoBounce_1.isCentralIdPOrigin)(origin)) {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
const state = generateState();
|
|
69
|
-
let establishUrl;
|
|
70
|
-
try {
|
|
71
|
-
const result = await client.requestSsoEstablishUrl(origin, state);
|
|
72
|
-
if (!result ||
|
|
73
|
-
typeof result.establishUrl !== 'string' ||
|
|
74
|
-
result.establishUrl.length === 0) {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
establishUrl = result.establishUrl;
|
|
78
|
-
// Defense-in-depth before a TOP-LEVEL navigation: the establish URL is
|
|
79
|
-
// server-formed, but never follow anything that is not a well-formed https
|
|
80
|
-
// `/sso/establish` on an `auth.` host. A malformed or unexpected URL aborts
|
|
81
|
-
// silently (no navigation, no state persisted) — same total/no-throw
|
|
82
|
-
// contract — rather than navigating the document somewhere unintended.
|
|
83
|
-
let parsedEstablishUrl;
|
|
84
|
-
try {
|
|
85
|
-
parsedEstablishUrl = new URL(establishUrl);
|
|
86
|
-
}
|
|
87
|
-
catch {
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
if (parsedEstablishUrl.protocol !== 'https:' ||
|
|
91
|
-
parsedEstablishUrl.pathname !== '/sso/establish' ||
|
|
92
|
-
!parsedEstablishUrl.hostname.toLowerCase().startsWith('auth.')) {
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
// Persist the bounce state ONLY now that the request has succeeded and the
|
|
96
|
-
// URL is validated — so a failed/rejected request never leaves stale state
|
|
97
|
-
// behind. This is the exact contract the terminal `/sso` bounce primes via
|
|
98
|
-
// `buildSsoBounceUrl`, so the post-bounce `sso-return` step (`consumeSsoReturn`)
|
|
99
|
-
// validates `state`, exchanges the returned code, and restores the dest.
|
|
100
|
-
storage.setItem((0, ssoBounce_1.ssoStateKey)(origin), state);
|
|
101
|
-
storage.setItem((0, ssoBounce_1.ssoGuardKey)(origin), String(now()));
|
|
102
|
-
storage.setItem((0, ssoBounce_1.ssoDestKey)(origin), location.href);
|
|
103
|
-
}
|
|
104
|
-
catch (error) {
|
|
105
|
-
deps.onError?.(error);
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
108
|
-
navigate(establishUrl);
|
|
109
|
-
return true;
|
|
110
|
-
}
|