@oxyhq/core 1.11.21 → 1.11.22
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 +6 -2
- package/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/mixins/OxyServices.fedcm.js +0 -80
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/mixins/OxyServices.fedcm.js +0 -79
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/mixins/OxyServices.fedcm.d.ts +0 -24
- package/package.json +1 -1
- package/src/mixins/OxyServices.fedcm.ts +0 -83
- package/src/mixins/__tests__/fedcm.test.ts +0 -182
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.__resetSilentSSOMemoForTests = __resetSilentSSOMemoForTests;
|
|
4
3
|
exports.OxyServicesFedCMMixin = OxyServicesFedCMMixin;
|
|
5
4
|
exports.FedCMMixin = OxyServicesFedCMMixin;
|
|
6
5
|
const OxyServices_errors_1 = require("../OxyServices.errors");
|
|
@@ -44,44 +43,6 @@ const FEDCM_LOGIN_HINT_KEY = 'oxy_fedcm_login_hint';
|
|
|
44
43
|
let fedCMRequestInProgress = false;
|
|
45
44
|
let fedCMRequestPromise = null;
|
|
46
45
|
let currentMediationMode = null;
|
|
47
|
-
/**
|
|
48
|
-
* Page-load-persistent memo for SILENT FedCM sign-in.
|
|
49
|
-
*
|
|
50
|
-
* Silent SSO (`mediation: 'silent'`) is the one FedCM flow that runs WITHOUT a
|
|
51
|
-
* user gesture — on app startup / provider mount. Multiple consumers
|
|
52
|
-
* (`@oxyhq/auth`'s `WebOxyProvider` / `useWebSSO`, `@oxyhq/services`'
|
|
53
|
-
* `useWebSSO`) can each mount and trigger it, and a remount storm (route churn,
|
|
54
|
-
* React StrictMode double-invoke, error-boundary recovery) previously turned
|
|
55
|
-
* into a `navigator.credentials.get` storm. This memo collapses every silent
|
|
56
|
-
* attempt for a given `origin + baseURL` into AT MOST ONE browser credential
|
|
57
|
-
* request per page load:
|
|
58
|
-
*
|
|
59
|
-
* - the FIRST silent call runs the real flow and stores its in-flight promise;
|
|
60
|
-
* - concurrent silent calls share that same in-flight promise;
|
|
61
|
-
* - once it settles, the memo retains the resolved value (a session OR `null`)
|
|
62
|
-
* and every subsequent silent call returns it WITHOUT re-invoking the
|
|
63
|
-
* browser.
|
|
64
|
-
*
|
|
65
|
-
* Keyed on `origin + baseURL` (not the OxyServices instance) so it survives
|
|
66
|
-
* instance churn across remounts. Intentionally never cleared: only a fresh
|
|
67
|
-
* page load — which starts a fresh module scope — can change the IdP session
|
|
68
|
-
* state that silent mediation observes.
|
|
69
|
-
*
|
|
70
|
-
* This guard is SILENT-ONLY. Interactive flows (`signInWithFedCM`,
|
|
71
|
-
* `mediation: 'optional'|'required'`, `mode: 'active'|'passive'`) must always
|
|
72
|
-
* be able to re-prompt and are never memoized here.
|
|
73
|
-
*/
|
|
74
|
-
const silentSSOMemo = new Map();
|
|
75
|
-
/**
|
|
76
|
-
* Test-only reset of the page-load silent-SSO memo. The memo is module-scoped
|
|
77
|
-
* and never cleared at runtime (a fresh page load resets it naturally), but
|
|
78
|
-
* tests sharing one module instance need to start from a clean slate.
|
|
79
|
-
*
|
|
80
|
-
* @internal
|
|
81
|
-
*/
|
|
82
|
-
function __resetSilentSSOMemoForTests() {
|
|
83
|
-
silentSSOMemo.clear();
|
|
84
|
-
}
|
|
85
46
|
/**
|
|
86
47
|
* Federated Credential Management (FedCM) Authentication Mixin
|
|
87
48
|
*
|
|
@@ -253,47 +214,6 @@ function OxyServicesFedCMMixin(Base) {
|
|
|
253
214
|
debug.log('Silent SSO: FedCM not supported in this browser');
|
|
254
215
|
return null;
|
|
255
216
|
}
|
|
256
|
-
// Page-load run-once guard. The first silent attempt for this
|
|
257
|
-
// origin + API runs; concurrent callers share the in-flight promise; once
|
|
258
|
-
// it settles, every later caller gets the memoized result (session OR
|
|
259
|
-
// null) WITHOUT re-invoking `navigator.credentials.get`. This is the single
|
|
260
|
-
// chokepoint for silent SSO across all consumers and remounts.
|
|
261
|
-
const memoKey = this.silentSSOMemoKey();
|
|
262
|
-
const existing = silentSSOMemo.get(memoKey);
|
|
263
|
-
if (existing) {
|
|
264
|
-
debug.log('Silent SSO: Returning memoized page-load result (no re-invocation)');
|
|
265
|
-
return existing;
|
|
266
|
-
}
|
|
267
|
-
const attempt = this._performSilentSignInWithFedCM();
|
|
268
|
-
silentSSOMemo.set(memoKey, attempt);
|
|
269
|
-
return attempt;
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* Build the page-load silent-SSO memo key from the current origin and the
|
|
273
|
-
* configured API base URL. Two providers pointed at the same API from the
|
|
274
|
-
* same origin share a single silent attempt per page load.
|
|
275
|
-
*
|
|
276
|
-
* @internal
|
|
277
|
-
*/
|
|
278
|
-
silentSSOMemoKey() {
|
|
279
|
-
const origin = typeof window !== 'undefined' ? window.location.origin : 'no-origin';
|
|
280
|
-
let baseURL = '';
|
|
281
|
-
try {
|
|
282
|
-
baseURL = this.getBaseURL();
|
|
283
|
-
}
|
|
284
|
-
catch {
|
|
285
|
-
baseURL = '';
|
|
286
|
-
}
|
|
287
|
-
return `${origin}|${baseURL}`;
|
|
288
|
-
}
|
|
289
|
-
/**
|
|
290
|
-
* Perform the actual silent FedCM sign-in. Always wrapped by
|
|
291
|
-
* {@link silentSignInWithFedCM}'s page-load memo — never call this directly
|
|
292
|
-
* (doing so bypasses the run-once guard).
|
|
293
|
-
*
|
|
294
|
-
* @internal
|
|
295
|
-
*/
|
|
296
|
-
async _performSilentSignInWithFedCM() {
|
|
297
217
|
const clientId = this.getClientId();
|
|
298
218
|
debug.log('Silent SSO: Starting for', clientId);
|
|
299
219
|
// Only try silent mediation (no UI) - works if user previously consented.
|