@axa-fr/oidc-client 7.29.8 → 7.30.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 +187 -0
- package/dist/events.d.ts +3 -0
- package/dist/events.d.ts.map +1 -1
- package/dist/fetch.d.ts +2 -2
- package/dist/fetch.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1339 -871
- package/dist/index.umd.cjs +2 -2
- package/dist/initSession.d.ts +2 -0
- package/dist/initSession.d.ts.map +1 -1
- package/dist/initWorker.d.ts +1 -25
- package/dist/initWorker.d.ts.map +1 -1
- package/dist/jwt.d.ts.map +1 -1
- package/dist/keepSession.d.ts.map +1 -1
- package/dist/keepSession.spec.d.ts +2 -0
- package/dist/keepSession.spec.d.ts.map +1 -0
- package/dist/legacyCompatibility.spec.d.ts +2 -0
- package/dist/legacyCompatibility.spec.d.ts.map +1 -0
- package/dist/login.d.ts +2 -1
- package/dist/login.d.ts.map +1 -1
- package/dist/logout.d.ts.map +1 -1
- package/dist/node_modules/@axa-fr/oidc-client-service-worker/dist/OidcServiceWorker.js +1049 -0
- package/dist/node_modules/@axa-fr/oidc-client-service-worker/dist/OidcTrustedDomains.js +31 -0
- package/dist/oidc.d.ts +6 -1
- package/dist/oidc.d.ts.map +1 -1
- package/dist/oidcClient.d.ts +13 -2
- package/dist/oidcClient.d.ts.map +1 -1
- package/dist/oidcError.d.ts +5 -0
- package/dist/oidcError.d.ts.map +1 -1
- package/dist/parseTokens.d.ts +10 -0
- package/dist/parseTokens.d.ts.map +1 -1
- package/dist/protocol.d.ts +7 -1
- package/dist/protocol.d.ts.map +1 -1
- package/dist/renewTokens.d.ts +0 -6
- package/dist/renewTokens.d.ts.map +1 -1
- package/dist/requests.d.ts +3 -3
- package/dist/requests.d.ts.map +1 -1
- package/dist/resourceParameters.d.ts +9 -0
- package/dist/resourceParameters.d.ts.map +1 -0
- package/dist/resourceTokens.d.ts +34 -0
- package/dist/resourceTokens.d.ts.map +1 -0
- package/dist/resourceTokens.spec.d.ts +2 -0
- package/dist/resourceTokens.spec.d.ts.map +1 -0
- package/dist/silentLogin.d.ts +2 -1
- package/dist/silentLogin.d.ts.map +1 -1
- package/dist/types.d.ts +28 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +3 -3
- package/src/events.ts +3 -0
- package/src/fetch.ts +115 -15
- package/src/index.ts +4 -0
- package/src/initSession.ts +9 -0
- package/src/initWorker.ts +65 -13
- package/src/jwt.spec.ts +17 -0
- package/src/jwt.ts +4 -1
- package/src/keepSession.spec.ts +254 -0
- package/src/keepSession.ts +10 -4
- package/src/legacyCompatibility.spec.ts +142 -0
- package/src/login.ts +91 -29
- package/src/logout.ts +36 -0
- package/src/oidc.ts +71 -20
- package/src/oidcClient.ts +48 -3
- package/src/oidcError.ts +7 -0
- package/src/parseTokens.ts +14 -1
- package/src/protocol.ts +16 -1
- package/src/renewTokens.ts +19 -8
- package/src/requests.ts +13 -11
- package/src/resourceParameters.ts +85 -0
- package/src/resourceTokens.spec.ts +1271 -0
- package/src/resourceTokens.ts +708 -0
- package/src/silentLogin.spec.ts +87 -1
- package/src/silentLogin.ts +24 -22
- package/src/types.ts +34 -0
- package/src/version.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,87 @@
|
|
|
1
|
-
//#region src/
|
|
1
|
+
//#region src/oidcError.ts
|
|
2
2
|
var e = {
|
|
3
|
+
INVALID_RESOURCE: "INVALID_RESOURCE",
|
|
4
|
+
INVALID_TARGET: "INVALID_TARGET",
|
|
5
|
+
RESOURCE_TOKEN_UNAVAILABLE: "RESOURCE_TOKEN_UNAVAILABLE",
|
|
6
|
+
RESOURCE_CONTEXT_MISMATCH: "RESOURCE_CONTEXT_MISMATCH",
|
|
7
|
+
RESOURCE_WORKER_UNSUPPORTED: "RESOURCE_WORKER_UNSUPPORTED",
|
|
8
|
+
LOGIN_REQUIRED: "LOGIN_REQUIRED",
|
|
9
|
+
CONSENT_REQUIRED: "CONSENT_REQUIRED",
|
|
10
|
+
INTERACTION_REQUIRED: "INTERACTION_REQUIRED",
|
|
11
|
+
OAUTH_ERROR: "OAUTH_ERROR",
|
|
12
|
+
TOKEN_REQUEST_FAILED: "TOKEN_REQUEST_FAILED",
|
|
13
|
+
SILENT_LOGIN_TIMEOUT: "SILENT_LOGIN_TIMEOUT",
|
|
14
|
+
INVALID_STATE: "INVALID_STATE",
|
|
15
|
+
INVALID_NONCE: "INVALID_NONCE",
|
|
16
|
+
DPOP_NONCE_REQUIRED: "DPOP_NONCE_REQUIRED",
|
|
17
|
+
NETWORK_ERROR: "NETWORK_ERROR",
|
|
18
|
+
STATE_MISSING: "STATE_MISSING",
|
|
19
|
+
STATE_MISMATCH: "STATE_MISMATCH",
|
|
20
|
+
NONCE_MISSING: "NONCE_MISSING",
|
|
21
|
+
ENDPOINT_UNAVAILABLE: "ENDPOINT_UNAVAILABLE",
|
|
22
|
+
REQUEST_FAILED: "REQUEST_FAILED",
|
|
23
|
+
INVALID_RESPONSE: "INVALID_RESPONSE"
|
|
24
|
+
}, t = new Set(Object.values(e)), n = /* @__PURE__ */ new Set([
|
|
25
|
+
"login",
|
|
26
|
+
"callback",
|
|
27
|
+
"refresh",
|
|
28
|
+
"logout",
|
|
29
|
+
"userinfo",
|
|
30
|
+
"api_request"
|
|
31
|
+
]), r = class extends Error {
|
|
32
|
+
constructor(e, t, n) {
|
|
33
|
+
super(t), this.name = "OidcError", this.code = e, this.phase = n.phase, this.oauthError = n.oauthError, this.oauthErrorDescription = n.oauthErrorDescription, this.retryable = n.retryable, this.status = n.status, this.cause = n.cause, Object.setPrototypeOf(this, new.target.prototype);
|
|
34
|
+
}
|
|
35
|
+
}, i = (e) => e instanceof r, a = (e) => e === 408 || e === 429 || e !== void 0 && e >= 500, o = (t) => {
|
|
36
|
+
switch (t) {
|
|
37
|
+
case "invalid_target": return e.INVALID_TARGET;
|
|
38
|
+
case "login_required": return e.LOGIN_REQUIRED;
|
|
39
|
+
case "consent_required": return e.CONSENT_REQUIRED;
|
|
40
|
+
case "interaction_required": return e.INTERACTION_REQUIRED;
|
|
41
|
+
case "use_dpop_nonce": return e.DPOP_NONCE_REQUIRED;
|
|
42
|
+
default: return e.OAUTH_ERROR;
|
|
43
|
+
}
|
|
44
|
+
}, s = (t, n, i, s, c) => {
|
|
45
|
+
let l = o(t);
|
|
46
|
+
return new r(l, i, {
|
|
47
|
+
phase: s,
|
|
48
|
+
retryable: l !== e.LOGIN_REQUIRED && l !== e.CONSENT_REQUIRED && l !== e.INTERACTION_REQUIRED && (l === e.DPOP_NONCE_REQUIRED || t === "server_error" || t === "temporarily_unavailable" || a(c)),
|
|
49
|
+
oauthError: t,
|
|
50
|
+
oauthErrorDescription: n,
|
|
51
|
+
status: c
|
|
52
|
+
});
|
|
53
|
+
}, c = (t, n, i = "Network request failed") => {
|
|
54
|
+
let a = t instanceof Error && typeof t.message == "string" && t.message ? t.message : i;
|
|
55
|
+
return new r(e.NETWORK_ERROR, a, {
|
|
56
|
+
phase: n,
|
|
57
|
+
retryable: !0,
|
|
58
|
+
cause: t
|
|
59
|
+
});
|
|
60
|
+
}, l = (e) => e instanceof Error ? e.name === "AbortError" || e.name === "NetworkError" || e.message === "Network request failed" || e.message === "Failed to fetch" || e.message === "fetch failed" : !1, u = (e) => ({
|
|
61
|
+
name: e.name,
|
|
62
|
+
message: e.message,
|
|
63
|
+
code: e.code,
|
|
64
|
+
phase: e.phase,
|
|
65
|
+
retryable: e.retryable,
|
|
66
|
+
oauthError: e.oauthError,
|
|
67
|
+
oauthErrorDescription: e.oauthErrorDescription,
|
|
68
|
+
status: e.status
|
|
69
|
+
}), d = (e) => {
|
|
70
|
+
if (!e || typeof e != "object") return null;
|
|
71
|
+
let i = e;
|
|
72
|
+
if (typeof i.message != "string" || typeof i.code != "string" || !t.has(i.code) || typeof i.phase != "string" || !n.has(i.phase) || typeof i.retryable != "boolean") return null;
|
|
73
|
+
let a = new r(i.code, i.message, {
|
|
74
|
+
phase: i.phase,
|
|
75
|
+
retryable: i.retryable,
|
|
76
|
+
oauthError: typeof i.oauthError == "string" ? i.oauthError : void 0,
|
|
77
|
+
oauthErrorDescription: typeof i.oauthErrorDescription == "string" ? i.oauthErrorDescription : void 0,
|
|
78
|
+
status: typeof i.status == "number" ? i.status : void 0
|
|
79
|
+
});
|
|
80
|
+
return typeof i.name == "string" && i.name && (a.name = i.name), a;
|
|
81
|
+
}, f = {
|
|
82
|
+
resource_token_acquired: "resource_token_acquired",
|
|
83
|
+
resource_token_cleared: "resource_token_cleared",
|
|
84
|
+
resource_token_error: "resource_token_error",
|
|
3
85
|
service_worker_not_supported_by_browser: "service_worker_not_supported_by_browser",
|
|
4
86
|
token_acquired: "token_acquired",
|
|
5
87
|
logout_from_another_tab: "logout_from_another_tab",
|
|
@@ -34,82 +116,86 @@ var e = {
|
|
|
34
116
|
syncTokensAsync_error: "syncTokensAsync_error",
|
|
35
117
|
tokensInvalidAndWaitingActionsToRefresh: "tokensInvalidAndWaitingActionsToRefresh",
|
|
36
118
|
loadingTimeout_error: "loadingTimeout_error"
|
|
37
|
-
},
|
|
119
|
+
}, p = (e, t, n) => {
|
|
38
120
|
n == null ? delete e[t] : e[t] = JSON.stringify(n);
|
|
39
|
-
},
|
|
121
|
+
}, m = (e, t, n) => {
|
|
40
122
|
n == null ? delete e[t] : e[t] = n;
|
|
41
|
-
},
|
|
123
|
+
}, h = (e) => {
|
|
42
124
|
if (typeof e != "string" || e === "undefined" || e === "null" || e === "") return null;
|
|
43
125
|
try {
|
|
44
126
|
return JSON.parse(e);
|
|
45
127
|
} catch {
|
|
46
128
|
return null;
|
|
47
129
|
}
|
|
48
|
-
},
|
|
49
|
-
let
|
|
130
|
+
}, g = (e, t = sessionStorage, n) => {
|
|
131
|
+
let r = n ?? t, i = (i) => (p(t, `oidc.${e}`, {
|
|
50
132
|
tokens: null,
|
|
51
|
-
status:
|
|
52
|
-
}), delete
|
|
53
|
-
let n =
|
|
133
|
+
status: i
|
|
134
|
+
}), delete t[`oidc.${e}.userInfo`], n && n !== t && (delete r[`oidc.login.${e}`], delete r[`oidc.state.${e}`], delete r[`oidc.code_verifier.${e}`], delete r[`oidc.nonce.${e}`]), Promise.resolve()), a = async () => {
|
|
135
|
+
let n = h(t[`oidc.${e}`]);
|
|
54
136
|
return n ? Promise.resolve({
|
|
55
137
|
tokens: n.tokens,
|
|
56
138
|
status: n.status
|
|
57
|
-
}) : (t
|
|
139
|
+
}) : (p(t, `oidc.${e}`, {
|
|
58
140
|
tokens: null,
|
|
59
141
|
status: null
|
|
60
142
|
}), {
|
|
61
143
|
tokens: null,
|
|
62
144
|
status: null
|
|
63
145
|
});
|
|
64
|
-
},
|
|
65
|
-
t
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
},
|
|
71
|
-
t
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
}, _ = () =>
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
146
|
+
}, o = (n) => {
|
|
147
|
+
p(t, `oidc.${e}`, { tokens: n });
|
|
148
|
+
}, s = async (n) => {
|
|
149
|
+
m(t, `oidc.session_state.${e}`, n);
|
|
150
|
+
}, c = async () => t[`oidc.session_state.${e}`], l = (t) => {
|
|
151
|
+
m(r, `oidc.nonce.${e}`, t?.nonce);
|
|
152
|
+
}, u = (n) => {
|
|
153
|
+
p(t, `oidc.jwk.${e}`, n);
|
|
154
|
+
}, d = () => h(t[`oidc.jwk.${e}`]), f = async () => ({ nonce: r[`oidc.nonce.${e}`] }), g = async (n) => {
|
|
155
|
+
m(t, `oidc.dpop_nonce.${e}`, n);
|
|
156
|
+
}, _ = () => t[`oidc.dpop_nonce.${e}`], v = async (n) => {
|
|
157
|
+
m(t, `oidc.dpop_api_nonce.${e}`, n);
|
|
158
|
+
}, y = () => t[`oidc.dpop_api_nonce.${e}`], b = () => {
|
|
159
|
+
let n = h(t[`oidc.${e}`]);
|
|
160
|
+
return n ? JSON.stringify({ tokens: n.tokens }) : null;
|
|
161
|
+
}, x = {};
|
|
78
162
|
return {
|
|
79
|
-
clearAsync:
|
|
80
|
-
initAsync:
|
|
81
|
-
setTokens:
|
|
82
|
-
getTokens:
|
|
83
|
-
setSessionStateAsync:
|
|
84
|
-
getSessionStateAsync:
|
|
85
|
-
setNonceAsync:
|
|
86
|
-
getNonceAsync:
|
|
87
|
-
setLoginParams: (
|
|
88
|
-
|
|
163
|
+
clearAsync: i,
|
|
164
|
+
initAsync: a,
|
|
165
|
+
setTokens: o,
|
|
166
|
+
getTokens: b,
|
|
167
|
+
setSessionStateAsync: s,
|
|
168
|
+
getSessionStateAsync: c,
|
|
169
|
+
setNonceAsync: l,
|
|
170
|
+
getNonceAsync: f,
|
|
171
|
+
setLoginParams: (t) => {
|
|
172
|
+
t == null ? (delete x[e], delete r[`oidc.login.${e}`]) : (x[e] = t, p(r, `oidc.login.${e}`, t));
|
|
89
173
|
},
|
|
90
174
|
getLoginParams: () => {
|
|
91
|
-
if (
|
|
92
|
-
let t = r
|
|
93
|
-
return t === null ? (console.warn(`storage[oidc.login.${e}] is empty, you should have an bad OIDC or code configuration somewhere.`), null) : (
|
|
175
|
+
if (x[e]) return x[e];
|
|
176
|
+
let t = h(r[`oidc.login.${e}`]);
|
|
177
|
+
return t === null ? (console.warn(`storage[oidc.login.${e}] is empty, you should have an bad OIDC or code configuration somewhere.`), null) : (x[e] = t, t);
|
|
94
178
|
},
|
|
95
|
-
getStateAsync: async () =>
|
|
179
|
+
getStateAsync: async () => r[`oidc.state.${e}`],
|
|
96
180
|
setStateAsync: async (t) => {
|
|
97
|
-
|
|
181
|
+
m(r, `oidc.state.${e}`, t);
|
|
98
182
|
},
|
|
99
|
-
getCodeVerifierAsync: async () =>
|
|
183
|
+
getCodeVerifierAsync: async () => r[`oidc.code_verifier.${e}`],
|
|
100
184
|
setCodeVerifierAsync: async (t) => {
|
|
101
|
-
|
|
185
|
+
m(r, `oidc.code_verifier.${e}`, t);
|
|
102
186
|
},
|
|
103
187
|
setDemonstratingProofOfPossessionNonce: g,
|
|
104
188
|
getDemonstratingProofOfPossessionNonce: _,
|
|
105
|
-
|
|
106
|
-
|
|
189
|
+
setDemonstratingProofOfPossessionApiNonce: v,
|
|
190
|
+
getDemonstratingProofOfPossessionApiNonce: y,
|
|
191
|
+
setDemonstratingProofOfPossessionJwkAsync: u,
|
|
192
|
+
getDemonstratingProofOfPossessionJwkAsync: d
|
|
107
193
|
};
|
|
108
|
-
},
|
|
109
|
-
constructor(e, t, n, r =
|
|
110
|
-
this._callback = e, this._client_id = t, this._url = n, this._interval = r ||
|
|
111
|
-
let
|
|
112
|
-
this._frame_origin = n.substring(0,
|
|
194
|
+
}, _ = 2e3, v = console, y = class {
|
|
195
|
+
constructor(e, t, n, r = _, i = !0) {
|
|
196
|
+
this._callback = e, this._client_id = t, this._url = n, this._interval = r || _, this._stopOnError = i;
|
|
197
|
+
let a = n.indexOf("/", n.indexOf("//") + 2);
|
|
198
|
+
this._frame_origin = n.substring(0, a), this._frame = window.document.createElement("iframe"), this._frame.style.visibility = "hidden", this._frame.style.position = "absolute", this._frame.style.display = "none", this._frame.width = 0, this._frame.height = 0, this._frame.src = n;
|
|
113
199
|
}
|
|
114
200
|
load() {
|
|
115
201
|
return new Promise((e) => {
|
|
@@ -119,91 +205,18 @@ var e = {
|
|
|
119
205
|
});
|
|
120
206
|
}
|
|
121
207
|
_message(e) {
|
|
122
|
-
e.origin === this._frame_origin && e.source === this._frame.contentWindow && (e.data === "error" ? (
|
|
208
|
+
e.origin === this._frame_origin && e.source === this._frame.contentWindow && (e.data === "error" ? (v.error("CheckSessionIFrame: error message from check session op iframe"), this._stopOnError && this.stop()) : e.data === "changed" ? (v.debug(e), v.debug("CheckSessionIFrame: changed message from check session op iframe"), this.stop(), this._callback()) : v.debug("CheckSessionIFrame: " + e.data + " message from check session op iframe"));
|
|
123
209
|
}
|
|
124
210
|
start(e) {
|
|
125
|
-
|
|
211
|
+
v.debug("CheckSessionIFrame.start :" + e), this.stop();
|
|
126
212
|
let t = () => {
|
|
127
213
|
this._frame.contentWindow.postMessage(this._client_id + " " + e, this._frame_origin);
|
|
128
214
|
};
|
|
129
215
|
t(), this._timer = window.setInterval(t, this._interval);
|
|
130
216
|
}
|
|
131
217
|
stop() {
|
|
132
|
-
this._timer &&= (
|
|
133
|
-
}
|
|
134
|
-
}, c = {
|
|
135
|
-
LOGIN_REQUIRED: "LOGIN_REQUIRED",
|
|
136
|
-
CONSENT_REQUIRED: "CONSENT_REQUIRED",
|
|
137
|
-
INTERACTION_REQUIRED: "INTERACTION_REQUIRED",
|
|
138
|
-
OAUTH_ERROR: "OAUTH_ERROR",
|
|
139
|
-
TOKEN_REQUEST_FAILED: "TOKEN_REQUEST_FAILED",
|
|
140
|
-
SILENT_LOGIN_TIMEOUT: "SILENT_LOGIN_TIMEOUT",
|
|
141
|
-
INVALID_STATE: "INVALID_STATE",
|
|
142
|
-
INVALID_NONCE: "INVALID_NONCE",
|
|
143
|
-
DPOP_NONCE_REQUIRED: "DPOP_NONCE_REQUIRED",
|
|
144
|
-
NETWORK_ERROR: "NETWORK_ERROR",
|
|
145
|
-
STATE_MISSING: "STATE_MISSING",
|
|
146
|
-
STATE_MISMATCH: "STATE_MISMATCH",
|
|
147
|
-
NONCE_MISSING: "NONCE_MISSING",
|
|
148
|
-
ENDPOINT_UNAVAILABLE: "ENDPOINT_UNAVAILABLE",
|
|
149
|
-
REQUEST_FAILED: "REQUEST_FAILED",
|
|
150
|
-
INVALID_RESPONSE: "INVALID_RESPONSE"
|
|
151
|
-
}, l = new Set(Object.values(c)), u = /* @__PURE__ */ new Set([
|
|
152
|
-
"login",
|
|
153
|
-
"callback",
|
|
154
|
-
"refresh",
|
|
155
|
-
"logout",
|
|
156
|
-
"userinfo",
|
|
157
|
-
"api_request"
|
|
158
|
-
]), d = class extends Error {
|
|
159
|
-
constructor(e, t, n) {
|
|
160
|
-
super(t), this.name = "OidcError", this.code = e, this.phase = n.phase, this.oauthError = n.oauthError, this.oauthErrorDescription = n.oauthErrorDescription, this.retryable = n.retryable, this.status = n.status, this.cause = n.cause, Object.setPrototypeOf(this, new.target.prototype);
|
|
218
|
+
this._timer &&= (v.debug("CheckSessionIFrame.stop"), window.clearInterval(this._timer), null);
|
|
161
219
|
}
|
|
162
|
-
}, f = (e) => e instanceof d, p = (e) => e === 408 || e === 429 || e !== void 0 && e >= 500, m = (e) => {
|
|
163
|
-
switch (e) {
|
|
164
|
-
case "login_required": return c.LOGIN_REQUIRED;
|
|
165
|
-
case "consent_required": return c.CONSENT_REQUIRED;
|
|
166
|
-
case "interaction_required": return c.INTERACTION_REQUIRED;
|
|
167
|
-
case "use_dpop_nonce": return c.DPOP_NONCE_REQUIRED;
|
|
168
|
-
default: return c.OAUTH_ERROR;
|
|
169
|
-
}
|
|
170
|
-
}, h = (e, t, n, r, i) => {
|
|
171
|
-
let a = m(e);
|
|
172
|
-
return new d(a, n, {
|
|
173
|
-
phase: r,
|
|
174
|
-
retryable: a !== c.LOGIN_REQUIRED && a !== c.CONSENT_REQUIRED && a !== c.INTERACTION_REQUIRED && (a === c.DPOP_NONCE_REQUIRED || e === "server_error" || e === "temporarily_unavailable" || p(i)),
|
|
175
|
-
oauthError: e,
|
|
176
|
-
oauthErrorDescription: t,
|
|
177
|
-
status: i
|
|
178
|
-
});
|
|
179
|
-
}, g = (e, t, n = "Network request failed") => {
|
|
180
|
-
let r = e instanceof Error && typeof e.message == "string" && e.message ? e.message : n;
|
|
181
|
-
return new d(c.NETWORK_ERROR, r, {
|
|
182
|
-
phase: t,
|
|
183
|
-
retryable: !0,
|
|
184
|
-
cause: e
|
|
185
|
-
});
|
|
186
|
-
}, _ = (e) => e instanceof Error ? e.name === "AbortError" || e.name === "NetworkError" || e.message === "Network request failed" || e.message === "Failed to fetch" || e.message === "fetch failed" : !1, v = (e) => ({
|
|
187
|
-
name: e.name,
|
|
188
|
-
message: e.message,
|
|
189
|
-
code: e.code,
|
|
190
|
-
phase: e.phase,
|
|
191
|
-
retryable: e.retryable,
|
|
192
|
-
oauthError: e.oauthError,
|
|
193
|
-
oauthErrorDescription: e.oauthErrorDescription,
|
|
194
|
-
status: e.status
|
|
195
|
-
}), y = (e) => {
|
|
196
|
-
if (!e || typeof e != "object") return null;
|
|
197
|
-
let t = e;
|
|
198
|
-
if (typeof t.message != "string" || typeof t.code != "string" || !l.has(t.code) || typeof t.phase != "string" || !u.has(t.phase) || typeof t.retryable != "boolean") return null;
|
|
199
|
-
let n = new d(t.code, t.message, {
|
|
200
|
-
phase: t.phase,
|
|
201
|
-
retryable: t.retryable,
|
|
202
|
-
oauthError: typeof t.oauthError == "string" ? t.oauthError : void 0,
|
|
203
|
-
oauthErrorDescription: typeof t.oauthErrorDescription == "string" ? t.oauthErrorDescription : void 0,
|
|
204
|
-
status: typeof t.status == "number" ? t.status : void 0
|
|
205
|
-
});
|
|
206
|
-
return typeof t.name == "string" && t.name && (n.name = t.name), n;
|
|
207
220
|
}, b = (function() {
|
|
208
221
|
let e = typeof window > "u" ? global : window;
|
|
209
222
|
return {
|
|
@@ -212,87 +225,89 @@ var e = {
|
|
|
212
225
|
setInterval: setInterval.bind(e),
|
|
213
226
|
clearInterval: clearInterval.bind(e)
|
|
214
227
|
};
|
|
215
|
-
})(), x = (t, n,
|
|
228
|
+
})(), x = (t, n, i, a = "login") => (o = null, c = null, l = null) => {
|
|
216
229
|
if (!n.silent_redirect_uri || !n.silent_login_uri) return Promise.resolve(null);
|
|
217
230
|
try {
|
|
218
|
-
|
|
219
|
-
let
|
|
220
|
-
if (
|
|
221
|
-
let
|
|
222
|
-
return
|
|
223
|
-
let
|
|
224
|
-
window.removeEventListener("message",
|
|
225
|
-
},
|
|
226
|
-
if (
|
|
227
|
-
let
|
|
228
|
-
if (
|
|
229
|
-
if (
|
|
230
|
-
let t = JSON.parse(
|
|
231
|
-
|
|
232
|
-
} else if (
|
|
233
|
-
let t = JSON.parse(
|
|
234
|
-
|
|
231
|
+
i(f.silentLoginAsync_begin, {});
|
|
232
|
+
let u = "";
|
|
233
|
+
if (c && (o ??= {}, o.state = c), l != null && (o ??= {}, o.scope = l), o != null) for (let [e, t] of Object.entries(o)) t != null && (u === "" ? u = `?${encodeURIComponent(e)}=${encodeURIComponent(t)}` : u += `&${encodeURIComponent(e)}=${encodeURIComponent(t)}`);
|
|
234
|
+
let p = n.silent_login_uri + u, m = p.indexOf("/", p.indexOf("//") + 2), h = p.substring(0, m), g = document.createElement("iframe");
|
|
235
|
+
return g.width = "0px", g.height = "0px", g.id = `${t}_oidc_iframe`, g.setAttribute("src", p), g.style.display = "none", document.body.appendChild(g), new Promise((o, c) => {
|
|
236
|
+
let l = !1, u = () => {
|
|
237
|
+
window.removeEventListener("message", p), g.remove(), l = !0;
|
|
238
|
+
}, p = (e) => {
|
|
239
|
+
if (e.origin === h && e.source === g.contentWindow) {
|
|
240
|
+
let n = `${t}_oidc_tokens:`, r = `${t}_oidc_error:`, p = `${t}_oidc_exception:`, m = e.data;
|
|
241
|
+
if (m && typeof m == "string" && !l) {
|
|
242
|
+
if (m.startsWith(n)) {
|
|
243
|
+
let t = JSON.parse(e.data.replace(n, ""));
|
|
244
|
+
i(f.silentLoginAsync_end, {}), o(t), u();
|
|
245
|
+
} else if (m.startsWith(r)) {
|
|
246
|
+
let t = JSON.parse(e.data.replace(r, "")), n = d(t.oidcError) ?? s(t.error, t.error_description, `Error from OIDC server: ${t.error} - ${t.error_description}`, a);
|
|
247
|
+
i(f.silentLoginAsync_error, n), o({
|
|
235
248
|
error: "oidc_" + t.error,
|
|
236
249
|
tokens: null,
|
|
237
250
|
sessionState: null,
|
|
238
|
-
oidcError:
|
|
239
|
-
}),
|
|
240
|
-
} else if (
|
|
241
|
-
let t = JSON.parse(
|
|
242
|
-
|
|
251
|
+
oidcError: n
|
|
252
|
+
}), u();
|
|
253
|
+
} else if (m.startsWith(p)) {
|
|
254
|
+
let t = JSON.parse(e.data.replace(p, "")), n = d(t.oidcError) ?? Error(t.error);
|
|
255
|
+
i(f.silentLoginAsync_error, n), c(n), u();
|
|
243
256
|
}
|
|
244
257
|
}
|
|
245
258
|
}
|
|
246
259
|
};
|
|
247
260
|
try {
|
|
248
|
-
window.addEventListener("message",
|
|
261
|
+
window.addEventListener("message", p);
|
|
249
262
|
let t = n.silent_login_timeout;
|
|
250
263
|
setTimeout(() => {
|
|
251
|
-
if (!
|
|
252
|
-
|
|
253
|
-
let t = new
|
|
254
|
-
phase:
|
|
264
|
+
if (!l) {
|
|
265
|
+
u();
|
|
266
|
+
let t = new r(e.SILENT_LOGIN_TIMEOUT, "timeout", {
|
|
267
|
+
phase: a,
|
|
255
268
|
retryable: !0
|
|
256
269
|
});
|
|
257
|
-
|
|
270
|
+
i(f.silentLoginAsync_error, t), c(t);
|
|
258
271
|
}
|
|
259
272
|
}, t);
|
|
260
|
-
} catch (
|
|
261
|
-
|
|
273
|
+
} catch (e) {
|
|
274
|
+
u(), i(f.silentLoginAsync_error, e), c(e);
|
|
262
275
|
}
|
|
263
276
|
});
|
|
264
|
-
} catch (
|
|
265
|
-
throw
|
|
277
|
+
} catch (e) {
|
|
278
|
+
throw i(f.silentLoginAsync_error, e), e;
|
|
266
279
|
}
|
|
267
|
-
}, S = (t, n,
|
|
280
|
+
}, S = (t, n, i, a, o) => (t = null, s = void 0) => {
|
|
268
281
|
t = { ...t };
|
|
269
|
-
let
|
|
282
|
+
let c = (e, t, r) => x(n, i, a.bind(o))(e, t, r);
|
|
270
283
|
return (async () => {
|
|
271
|
-
a.timeoutId && b.clearTimeout(a.timeoutId);
|
|
272
284
|
let n;
|
|
273
285
|
t && "state" in t && (n = t.state, delete t.state);
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
if (
|
|
283
|
-
|
|
284
|
-
|
|
286
|
+
let l = i.extras ? {
|
|
287
|
+
...i.extras,
|
|
288
|
+
...t
|
|
289
|
+
} : t, u = await c({
|
|
290
|
+
...l,
|
|
291
|
+
prompt: "none"
|
|
292
|
+
}, n, s);
|
|
293
|
+
if (u) {
|
|
294
|
+
if (u.oidcError) throw u.oidcError;
|
|
295
|
+
if (!u.tokens) throw new r(e.TOKEN_REQUEST_FAILED, "Silent login returned no tokens.", {
|
|
296
|
+
phase: "login",
|
|
297
|
+
retryable: !1
|
|
298
|
+
});
|
|
299
|
+
return o.timeoutId && b.clearTimeout(o.timeoutId), o.tokens = u.tokens, a(f.token_acquired, {}), o.timeoutId = q(o, o.tokens.expiresAt, t, s), {};
|
|
285
300
|
}
|
|
286
|
-
})();
|
|
301
|
+
})().catch((e) => e);
|
|
287
302
|
}, C = (e, t, n) => (r, i, a, o = !1) => {
|
|
288
|
-
let
|
|
289
|
-
return new Promise((
|
|
290
|
-
n.silent_login_uri && n.silent_redirect_uri && n.monitor_session && r && a && !o ? (e.checkSessionIFrame = new
|
|
303
|
+
let s = (t, r = void 0, i = void 0) => x(e.configurationName, n, e.publishEvent.bind(e))(t, r, i);
|
|
304
|
+
return new Promise((c, l) => {
|
|
305
|
+
n.silent_login_uri && n.silent_redirect_uri && n.monitor_session && r && a && !o ? (e.checkSessionIFrame = new y(() => {
|
|
291
306
|
e.checkSessionIFrame.stop();
|
|
292
307
|
let r = e.tokens;
|
|
293
308
|
if (r === null) return;
|
|
294
309
|
let i = r.idToken, a = r.idTokenPayload;
|
|
295
|
-
return
|
|
310
|
+
return s({
|
|
296
311
|
prompt: "none",
|
|
297
312
|
id_token_hint: i,
|
|
298
313
|
scope: n.scope || "openid"
|
|
@@ -308,10 +323,10 @@ var e = {
|
|
|
308
323
|
for (let [, e] of Object.entries(t)) await e.logoutOtherTabAsync(n.client_id, a.sub);
|
|
309
324
|
});
|
|
310
325
|
}, i, r), e.checkSessionIFrame.load().then(() => {
|
|
311
|
-
e.checkSessionIFrame.start(a),
|
|
326
|
+
e.checkSessionIFrame.start(a), c(e.checkSessionIFrame);
|
|
312
327
|
}).catch((e) => {
|
|
313
|
-
|
|
314
|
-
})) :
|
|
328
|
+
l(e);
|
|
329
|
+
})) : c(null);
|
|
315
330
|
});
|
|
316
331
|
};
|
|
317
332
|
//#endregion
|
|
@@ -333,10 +348,10 @@ var D = (e) => {
|
|
|
333
348
|
t += String.fromCharCode(e);
|
|
334
349
|
}), T(t);
|
|
335
350
|
};
|
|
336
|
-
function
|
|
351
|
+
function ee(e) {
|
|
337
352
|
return T(E(e));
|
|
338
353
|
}
|
|
339
|
-
var
|
|
354
|
+
var O = {
|
|
340
355
|
importKeyAlgorithm: {
|
|
341
356
|
name: "ECDSA",
|
|
342
357
|
namedCurve: "P-256",
|
|
@@ -352,7 +367,7 @@ var k = {
|
|
|
352
367
|
},
|
|
353
368
|
digestAlgorithm: { name: "SHA-256" },
|
|
354
369
|
jwtHeaderAlgorithm: "ES256"
|
|
355
|
-
},
|
|
370
|
+
}, k = { sign: (e) => async (t, n, r, i, a = "dpop+jwt") => {
|
|
356
371
|
switch (t = Object.assign({}, t), n.typ = a, n.alg = i.jwtHeaderAlgorithm, n.alg) {
|
|
357
372
|
case "ES256":
|
|
358
373
|
n.jwk = {
|
|
@@ -373,11 +388,11 @@ var k = {
|
|
|
373
388
|
default: throw Error("Unknown or not implemented JWS algorithm");
|
|
374
389
|
}
|
|
375
390
|
let o = {
|
|
376
|
-
protected:
|
|
377
|
-
payload:
|
|
391
|
+
protected: ee(JSON.stringify(n)),
|
|
392
|
+
payload: ee(JSON.stringify(r))
|
|
378
393
|
}, s = i.importKeyAlgorithm, c = await e.crypto.subtle.importKey("jwk", t, s, !0, ["sign"]), l = w(`${o.protected}.${o.payload}`), u = i.signAlgorithm, d = await e.crypto.subtle.sign(u, c, l);
|
|
379
394
|
return o.signature = D(new Uint8Array(d)), `${o.protected}.${o.payload}.${o.signature}`;
|
|
380
|
-
} },
|
|
395
|
+
} }, A = {
|
|
381
396
|
generate: (e) => async (t) => {
|
|
382
397
|
let n = t, r = await e.crypto.subtle.generateKey(n, !0, ["sign", "verify"]);
|
|
383
398
|
return await e.crypto.subtle.exportKey("jwk", r.privateKey);
|
|
@@ -386,7 +401,7 @@ var k = {
|
|
|
386
401
|
let t = Object.assign({}, e);
|
|
387
402
|
return delete t.d, t.key_ops = ["verify"], t;
|
|
388
403
|
}
|
|
389
|
-
},
|
|
404
|
+
}, j = { thumbprint: (e) => async (t, n) => {
|
|
390
405
|
let r;
|
|
391
406
|
switch (t.kty) {
|
|
392
407
|
case "EC":
|
|
@@ -399,48 +414,50 @@ var k = {
|
|
|
399
414
|
}
|
|
400
415
|
let i = await e.crypto.subtle.digest(n, w(r));
|
|
401
416
|
return D(new Uint8Array(i));
|
|
402
|
-
} },
|
|
403
|
-
let o =
|
|
417
|
+
} }, te = (e) => async (t) => await A.generate(e)(t), ne = (e) => (t) => async (n, r = "POST", i, a = {}) => {
|
|
418
|
+
let o = new URL(i, e.location?.href);
|
|
419
|
+
o.search = "", o.hash = "";
|
|
420
|
+
let s = {
|
|
404
421
|
jti: btoa(e.crypto.randomUUID()),
|
|
405
422
|
htm: r,
|
|
406
|
-
htu:
|
|
423
|
+
htu: o.href,
|
|
407
424
|
iat: Math.round(Date.now() / 1e3),
|
|
408
425
|
...a
|
|
409
|
-
},
|
|
410
|
-
return await
|
|
411
|
-
},
|
|
412
|
-
let e =
|
|
426
|
+
}, c = await j.thumbprint(e)(n, t.digestAlgorithm);
|
|
427
|
+
return await k.sign(e)(n, { kid: c }, s, t);
|
|
428
|
+
}, re = () => typeof globalThis < "u" ? globalThis.crypto : void 0, ie = () => {
|
|
429
|
+
let e = re();
|
|
413
430
|
return {
|
|
414
431
|
hasCrypto: !!e,
|
|
415
432
|
hasSubtleCrypto: !!e?.subtle
|
|
416
433
|
};
|
|
417
|
-
},
|
|
434
|
+
}, ae = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", oe = (e) => {
|
|
418
435
|
let t = [];
|
|
419
436
|
for (let n = 0; n < e.byteLength; n += 1) {
|
|
420
437
|
let r = e[n] % 62;
|
|
421
|
-
t.push(
|
|
438
|
+
t.push(ae[r]);
|
|
422
439
|
}
|
|
423
440
|
return t.join("");
|
|
424
|
-
},
|
|
425
|
-
let t = new Uint8Array(e), n =
|
|
441
|
+
}, se = (e) => {
|
|
442
|
+
let t = new Uint8Array(e), n = re();
|
|
426
443
|
if (!n?.getRandomValues) throw Error("Web Crypto API is unavailable; secure random values cannot be generated.");
|
|
427
|
-
return n.getRandomValues(t),
|
|
444
|
+
return n.getRandomValues(t), oe(t);
|
|
428
445
|
};
|
|
429
|
-
function
|
|
446
|
+
function ce(e) {
|
|
430
447
|
let t = new ArrayBuffer(e.length), n = new Uint8Array(t);
|
|
431
448
|
for (let t = 0; t < e.length; t++) n[t] = e.charCodeAt(t);
|
|
432
449
|
return n;
|
|
433
450
|
}
|
|
434
|
-
function
|
|
451
|
+
function le(e) {
|
|
435
452
|
return new Promise((t, n) => {
|
|
436
|
-
crypto.subtle.digest("SHA-256",
|
|
453
|
+
crypto.subtle.digest("SHA-256", ce(e)).then((e) => t(D(new Uint8Array(e))), (e) => n(e));
|
|
437
454
|
});
|
|
438
455
|
}
|
|
439
|
-
var
|
|
456
|
+
var ue = (e) => {
|
|
440
457
|
if (e.length < 43 || e.length > 128) return Promise.reject(/* @__PURE__ */ Error("Invalid code length."));
|
|
441
|
-
let { hasSubtleCrypto: t } =
|
|
442
|
-
return t ?
|
|
443
|
-
},
|
|
458
|
+
let { hasSubtleCrypto: t } = ie();
|
|
459
|
+
return t ? le(e) : Promise.reject(/* @__PURE__ */ Error("window.crypto.subtle is unavailable."));
|
|
460
|
+
}, de = (e) => !!(e.os === "iOS" && e.osVersion.startsWith("12") || e.os === "Mac OS X" && e.osVersion.startsWith("10_15_6")), fe = (e) => {
|
|
444
461
|
let t = e.appVersion, n = e.userAgent, r = "-", i = [
|
|
445
462
|
{
|
|
446
463
|
s: "Windows 10",
|
|
@@ -576,7 +593,7 @@ var de = (e) => {
|
|
|
576
593
|
osVersion: a
|
|
577
594
|
};
|
|
578
595
|
};
|
|
579
|
-
function
|
|
596
|
+
function pe() {
|
|
580
597
|
let e = navigator.userAgent, t, n = e.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
|
|
581
598
|
if (/trident/i.test(n[1])) return t = /\brv[ :]+(\d+)/g.exec(e) || [], {
|
|
582
599
|
name: "ie",
|
|
@@ -602,53 +619,53 @@ function me() {
|
|
|
602
619
|
version: n[1]
|
|
603
620
|
};
|
|
604
621
|
}
|
|
605
|
-
var
|
|
606
|
-
let { name: e, version: t } =
|
|
607
|
-
return e === "chrome" && parseInt(t) <= 70 || e === "opera" && (!t || parseInt(t.split(".")[0]) < 80) || e === "ie" ? !1 : !fe(
|
|
608
|
-
},
|
|
609
|
-
let
|
|
610
|
-
if (
|
|
611
|
-
|
|
622
|
+
var me = () => {
|
|
623
|
+
let { name: e, version: t } = pe();
|
|
624
|
+
return e === "chrome" && parseInt(t) <= 70 || e === "opera" && (!t || parseInt(t.split(".")[0]) < 80) || e === "ie" ? !1 : !de(fe(navigator));
|
|
625
|
+
}, he = async (e) => {
|
|
626
|
+
let t;
|
|
627
|
+
if (e.tokens != null) return !1;
|
|
628
|
+
e.publishEvent(f.tryKeepExistingSessionAsync_begin, {});
|
|
612
629
|
try {
|
|
613
|
-
let
|
|
614
|
-
if (
|
|
615
|
-
let { tokens: i } = await
|
|
630
|
+
let n = e.configuration, r = await e.initAsync(n.authority, n.authority_configuration);
|
|
631
|
+
if (t = await $(n, e.configurationName), t) {
|
|
632
|
+
let { tokens: i } = await t.initAsync(r, "tryKeepExistingSessionAsync", n);
|
|
616
633
|
if (i) {
|
|
617
|
-
|
|
618
|
-
let
|
|
619
|
-
|
|
620
|
-
let
|
|
621
|
-
return await
|
|
634
|
+
t.startKeepAliveServiceWorker(), e.tokens = i;
|
|
635
|
+
let a = t.getLoginParams(e.configurationName);
|
|
636
|
+
e.timeoutId = q(e, e.tokens.expiresAt, a?.extras, a?.scope);
|
|
637
|
+
let o = await t.getSessionStateAsync();
|
|
638
|
+
return await e.startCheckSessionAsync(r.checkSessionIframe, n.client_id, o), n.preload_user_info && await e.userInfoAsync(), e.publishEvent(f.tryKeepExistingSessionAsync_end, {
|
|
622
639
|
success: !0,
|
|
623
640
|
message: "tokens inside ServiceWorker are valid"
|
|
624
641
|
}), !0;
|
|
625
642
|
}
|
|
626
|
-
|
|
643
|
+
e.publishEvent(f.tryKeepExistingSessionAsync_end, {
|
|
627
644
|
success: !1,
|
|
628
645
|
message: "no exiting session found"
|
|
629
646
|
});
|
|
630
647
|
} else {
|
|
631
|
-
|
|
632
|
-
let
|
|
633
|
-
if (
|
|
634
|
-
|
|
635
|
-
let
|
|
636
|
-
|
|
637
|
-
let
|
|
638
|
-
return await
|
|
648
|
+
n.service_worker_relative_url && e.publishEvent(f.service_worker_not_supported_by_browser, { message: "service worker is not supported by this browser" });
|
|
649
|
+
let t = g(e.configurationName, n.storage ?? sessionStorage, n.login_state_storage ?? n.storage ?? sessionStorage), { tokens: i } = await t.initAsync();
|
|
650
|
+
if (i) {
|
|
651
|
+
e.tokens = Mt(i, null, n.token_renew_mode);
|
|
652
|
+
let a = t.getLoginParams();
|
|
653
|
+
e.timeoutId = q(e, e.tokens.expiresAt, a?.extras, a?.scope);
|
|
654
|
+
let o = await t.getSessionStateAsync();
|
|
655
|
+
return await e.startCheckSessionAsync(r.checkSessionIframe, n.client_id, o), n.preload_user_info && await e.userInfoAsync(), e.publishEvent(f.tryKeepExistingSessionAsync_end, {
|
|
639
656
|
success: !0,
|
|
640
657
|
message: "tokens inside storage are valid"
|
|
641
658
|
}), !0;
|
|
642
659
|
}
|
|
643
660
|
}
|
|
644
|
-
return
|
|
661
|
+
return e.publishEvent(f.tryKeepExistingSessionAsync_end, {
|
|
645
662
|
success: !1,
|
|
646
|
-
message:
|
|
663
|
+
message: t ? "service worker sessions not retrieved" : "session storage sessions not retrieved"
|
|
647
664
|
}), !1;
|
|
648
|
-
} catch (
|
|
649
|
-
return console.error(
|
|
665
|
+
} catch (n) {
|
|
666
|
+
return e.tokens = null, e.userInfo = null, b.clearTimeout(e.timeoutId), e.timeoutId = null, e.checkSessionIFrame?.stop(), console.error(n), t && await t.clearAsync(), e.publishEvent(f.tryKeepExistingSessionAsync_error, "tokens inside ServiceWorker are invalid"), !1;
|
|
650
667
|
}
|
|
651
|
-
},
|
|
668
|
+
}, M = class {
|
|
652
669
|
open(e) {
|
|
653
670
|
window.location.href = e;
|
|
654
671
|
}
|
|
@@ -665,52 +682,52 @@ var he = () => {
|
|
|
665
682
|
getOrigin() {
|
|
666
683
|
return window.origin;
|
|
667
684
|
}
|
|
668
|
-
},
|
|
685
|
+
}, N = {
|
|
669
686
|
STATE_MISSING: "STATE_MISSING",
|
|
670
687
|
STATE_MISMATCH: "STATE_MISMATCH",
|
|
671
688
|
NONCE_MISSING: "NONCE_MISSING"
|
|
672
|
-
},
|
|
689
|
+
}, ge = new Set(Object.values(N)), _e = (e) => typeof e == "string" && ge.has(e), P = class e extends r {
|
|
673
690
|
constructor(t, n, r = "callback") {
|
|
674
691
|
super(t, n, {
|
|
675
692
|
phase: r,
|
|
676
693
|
retryable: !1
|
|
677
694
|
}), this.name = "OidcStateError", Object.setPrototypeOf(this, e.prototype);
|
|
678
695
|
}
|
|
679
|
-
},
|
|
696
|
+
}, ve = (e) => e instanceof P || i(e) && _e(e.code), F = {
|
|
680
697
|
ENDPOINT_UNAVAILABLE: "ENDPOINT_UNAVAILABLE",
|
|
681
698
|
REQUEST_FAILED: "REQUEST_FAILED",
|
|
682
699
|
INVALID_RESPONSE: "INVALID_RESPONSE"
|
|
683
|
-
},
|
|
700
|
+
}, I = class e extends r {
|
|
684
701
|
constructor(t, n, r = {}) {
|
|
685
702
|
super(t, n, {
|
|
686
703
|
phase: "login",
|
|
687
|
-
retryable: r.cause !== void 0 ||
|
|
704
|
+
retryable: r.cause !== void 0 || a(r.status),
|
|
688
705
|
status: r.status,
|
|
689
706
|
oauthError: r.oauthError,
|
|
690
707
|
oauthErrorDescription: r.oauthErrorDescription,
|
|
691
708
|
cause: r.cause
|
|
692
709
|
}), this.name = "PushedAuthorizationRequestError", Object.setPrototypeOf(this, e.prototype);
|
|
693
710
|
}
|
|
694
|
-
},
|
|
695
|
-
if (!
|
|
711
|
+
}, ye = (e) => e instanceof I, be = {}, xe = (e, t = window.sessionStorage, n) => {
|
|
712
|
+
if (!be[e] && t) {
|
|
696
713
|
let n = t.getItem(e);
|
|
697
|
-
n && (
|
|
714
|
+
n && (be[e] = JSON.parse(n));
|
|
698
715
|
}
|
|
699
|
-
let r =
|
|
716
|
+
let r = be[e], i = 1e3 * n;
|
|
700
717
|
return r && r.timestamp + i > Date.now() ? r.result : null;
|
|
701
718
|
}, Se = (e, t, n = window.sessionStorage) => {
|
|
702
719
|
let r = {
|
|
703
720
|
result: t,
|
|
704
721
|
timestamp: Date.now()
|
|
705
722
|
};
|
|
706
|
-
|
|
723
|
+
be[e] = r, n && n.setItem(e, JSON.stringify(r));
|
|
707
724
|
}, Ce = 3600, we = (e) => async (t, n = Ce, r = window.sessionStorage, i = 1e4) => {
|
|
708
725
|
let a = `${t}/.well-known/openid-configuration`, o = `oidc.server:${t}`, s = xe(o, r, n);
|
|
709
|
-
if (s) return new
|
|
726
|
+
if (s) return new yt(s);
|
|
710
727
|
let c = await L(e)(a, {}, i);
|
|
711
728
|
if (c.status !== 200) return null;
|
|
712
729
|
let l = await c.json();
|
|
713
|
-
return Se(o, l, r), new
|
|
730
|
+
return Se(o, l, r), new yt(l);
|
|
714
731
|
}, L = (e) => async (t, n = {}, r = 1e4, i = 0) => {
|
|
715
732
|
let a;
|
|
716
733
|
try {
|
|
@@ -731,27 +748,30 @@ var he = () => {
|
|
|
731
748
|
throw console.error(a.message), a;
|
|
732
749
|
}
|
|
733
750
|
return a;
|
|
734
|
-
},
|
|
751
|
+
}, R = {
|
|
735
752
|
refresh_token: "refresh_token",
|
|
736
753
|
access_token: "access_token"
|
|
737
|
-
},
|
|
754
|
+
}, Te = (e) => {
|
|
738
755
|
let t = [];
|
|
739
|
-
for (let n in e)
|
|
756
|
+
for (let n in e) {
|
|
757
|
+
let r = e[n], i = Array.isArray(r) ? r : [String(r)];
|
|
758
|
+
for (let e of i) t.push(`${encodeURIComponent(n)}=${encodeURIComponent(e)}`);
|
|
759
|
+
}
|
|
740
760
|
return t.join("&");
|
|
741
|
-
},
|
|
761
|
+
}, Ee = (e) => async (t, n, r = R.refresh_token, i, a = {}, o = 1e4) => {
|
|
742
762
|
let s = {
|
|
743
763
|
token: n,
|
|
744
764
|
token_type_hint: r,
|
|
745
765
|
client_id: i
|
|
746
766
|
};
|
|
747
767
|
for (let [e, t] of Object.entries(a)) s[e] === void 0 && (s[e] = t);
|
|
748
|
-
let c =
|
|
768
|
+
let c = Te(s), l = await L(e)(t, {
|
|
749
769
|
method: "POST",
|
|
750
770
|
headers: { "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8" },
|
|
751
771
|
body: c
|
|
752
772
|
}, o);
|
|
753
773
|
if (l.status !== 200) {
|
|
754
|
-
let e = await
|
|
774
|
+
let e = await De(l);
|
|
755
775
|
return {
|
|
756
776
|
success: !1,
|
|
757
777
|
status: l.status,
|
|
@@ -763,15 +783,15 @@ var he = () => {
|
|
|
763
783
|
success: !0,
|
|
764
784
|
status: l.status
|
|
765
785
|
};
|
|
766
|
-
},
|
|
786
|
+
}, De = async (e) => {
|
|
767
787
|
try {
|
|
768
788
|
return await e.json();
|
|
769
789
|
} catch {
|
|
770
790
|
return null;
|
|
771
791
|
}
|
|
772
|
-
},
|
|
773
|
-
if (n.request_uri !== void 0) throw new F
|
|
774
|
-
let i =
|
|
792
|
+
}, Oe = (e) => async (t, n, r = 1e4) => {
|
|
793
|
+
if (n.request_uri !== void 0) throw new I(F.REQUEST_FAILED, "The request_uri parameter must not be included in a pushed authorization request.");
|
|
794
|
+
let i = Te(n), a;
|
|
775
795
|
try {
|
|
776
796
|
a = await L(e)(t, {
|
|
777
797
|
method: "POST",
|
|
@@ -779,25 +799,25 @@ var he = () => {
|
|
|
779
799
|
body: i
|
|
780
800
|
}, r);
|
|
781
801
|
} catch (e) {
|
|
782
|
-
throw new F
|
|
802
|
+
throw new I(F.REQUEST_FAILED, "The pushed authorization request could not be sent.", { cause: e });
|
|
783
803
|
}
|
|
784
|
-
let o = await
|
|
804
|
+
let o = await De(a);
|
|
785
805
|
if (a.status !== 201) {
|
|
786
806
|
let e = typeof o?.error == "string" ? o.error : void 0, t = typeof o?.error_description == "string" ? o.error_description : void 0, n = [e, t].filter(Boolean).join(": ");
|
|
787
|
-
throw new F
|
|
807
|
+
throw new I(F.REQUEST_FAILED, `The pushed authorization request failed with HTTP status ${a.status}${n ? ` (${n})` : ""}.`, {
|
|
788
808
|
status: a.status,
|
|
789
809
|
oauthError: e,
|
|
790
810
|
oauthErrorDescription: t
|
|
791
811
|
});
|
|
792
812
|
}
|
|
793
|
-
if (typeof o?.request_uri != "string" || o.request_uri.length === 0 || !Number.isInteger(o?.expires_in) || o.expires_in <= 0) throw new F
|
|
813
|
+
if (typeof o?.request_uri != "string" || o.request_uri.length === 0 || !Number.isInteger(o?.expires_in) || o.expires_in <= 0) throw new I(F.INVALID_RESPONSE, "The pushed authorization response must contain a non-empty request_uri and a positive integer expires_in.", { status: a.status });
|
|
794
814
|
return {
|
|
795
815
|
request_uri: o.request_uri,
|
|
796
816
|
expires_in: o.expires_in
|
|
797
817
|
};
|
|
798
|
-
},
|
|
818
|
+
}, ke = (e) => async (t, n, r, i, a = {}, o, s = 1e4) => {
|
|
799
819
|
for (let [e, t] of Object.entries(r)) n[e] === void 0 && (n[e] = t);
|
|
800
|
-
let c =
|
|
820
|
+
let c = Te(n), l = await L(e)(t, {
|
|
801
821
|
method: "POST",
|
|
802
822
|
headers: {
|
|
803
823
|
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
|
|
@@ -806,37 +826,37 @@ var he = () => {
|
|
|
806
826
|
body: c
|
|
807
827
|
}, s);
|
|
808
828
|
if (l.status !== 200) {
|
|
809
|
-
let e = await
|
|
829
|
+
let e = await De(l);
|
|
810
830
|
return {
|
|
811
831
|
success: !1,
|
|
812
832
|
status: l.status,
|
|
813
833
|
data: e,
|
|
814
834
|
oauthError: typeof e?.error == "string" ? e.error : void 0,
|
|
815
835
|
oauthErrorDescription: typeof e?.error_description == "string" ? e.error_description : void 0,
|
|
816
|
-
demonstratingProofOfPossessionNonce: l.headers?.has(
|
|
836
|
+
demonstratingProofOfPossessionNonce: l.headers?.has(z) ? l.headers.get(z) : null
|
|
817
837
|
};
|
|
818
838
|
}
|
|
819
839
|
let u = await l.json(), d = null;
|
|
820
|
-
return l.headers.has(
|
|
840
|
+
return l.headers.has(z) && (d = l.headers.get(z)), {
|
|
821
841
|
success: !0,
|
|
822
842
|
status: l.status,
|
|
823
|
-
data:
|
|
843
|
+
data: Nt(u, i, o),
|
|
824
844
|
demonstratingProofOfPossessionNonce: d
|
|
825
845
|
};
|
|
826
|
-
},
|
|
846
|
+
}, Ae = (e, t) => async (n, r, i) => {
|
|
827
847
|
r = r ? { ...r } : {};
|
|
828
|
-
let a =
|
|
848
|
+
let a = se(128), o = await ue(a);
|
|
829
849
|
if (await e.setCodeVerifierAsync(a), await e.setStateAsync(r.state), r.code_challenge = o, r.code_challenge_method = "S256", i) {
|
|
830
|
-
let e = await
|
|
831
|
-
t.open(`${n}?client_id=${encodeURIComponent(r.client_id)}&request_uri=${encodeURIComponent(e.request_uri)}`);
|
|
850
|
+
let e = await Oe(i.fetch)(i.endpoint, r, i.timeoutMs);
|
|
851
|
+
t.open(`${n}?client_id=${encodeURIComponent(String(r.client_id))}&request_uri=${encodeURIComponent(e.request_uri)}`);
|
|
832
852
|
return;
|
|
833
853
|
}
|
|
834
854
|
let s = "";
|
|
835
|
-
if (r) for (let [e, t] of Object.entries(r)) s += s === "" ? "?" : "&", s += `${e}=${encodeURIComponent(
|
|
855
|
+
if (r) for (let [e, t] of Object.entries(r)) for (let n of Array.isArray(t) ? t : [String(t)]) s += s === "" ? "?" : "&", s += `${e}=${encodeURIComponent(n)}`;
|
|
836
856
|
t.open(`${n}${s}`);
|
|
837
|
-
},
|
|
857
|
+
}, z = "DPoP-Nonce", je = (e) => async (t, n, r, i, a = 1e4, o = !1) => {
|
|
838
858
|
n = n ? { ...n } : {}, n.code_verifier = await e.getCodeVerifierAsync();
|
|
839
|
-
let s =
|
|
859
|
+
let s = Te(n), c = await L(fetch)(t, {
|
|
840
860
|
method: "POST",
|
|
841
861
|
headers: {
|
|
842
862
|
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
|
|
@@ -845,29 +865,87 @@ var he = () => {
|
|
|
845
865
|
body: s
|
|
846
866
|
}, a);
|
|
847
867
|
if (c.status !== 200) {
|
|
848
|
-
let t = await
|
|
868
|
+
let t = await De(c), n = typeof t?.error == "string" ? t.error : void 0;
|
|
849
869
|
return o && n === "use_dpop_nonce" || await Promise.all([e.setCodeVerifierAsync(null), e.setStateAsync(null)]), {
|
|
850
870
|
success: !1,
|
|
851
871
|
status: c.status,
|
|
852
872
|
data: t,
|
|
853
873
|
oauthError: n,
|
|
854
874
|
oauthErrorDescription: typeof t?.error_description == "string" ? t.error_description : void 0,
|
|
855
|
-
demonstratingProofOfPossessionNonce: c.headers?.has(
|
|
875
|
+
demonstratingProofOfPossessionNonce: c.headers?.has(z) ? c.headers.get(z) : null
|
|
856
876
|
};
|
|
857
877
|
}
|
|
858
878
|
await Promise.all([e.setCodeVerifierAsync(null), e.setStateAsync(null)]);
|
|
859
879
|
let l = null;
|
|
860
|
-
c.headers.has(
|
|
880
|
+
c.headers.has(z) && (l = c.headers.get(z));
|
|
861
881
|
let u = await c.json();
|
|
862
882
|
return {
|
|
863
883
|
success: !0,
|
|
864
884
|
data: {
|
|
865
885
|
state: n.state,
|
|
866
|
-
tokens:
|
|
886
|
+
tokens: Nt(u, null, i),
|
|
867
887
|
demonstratingProofOfPossessionNonce: l
|
|
868
888
|
}
|
|
869
889
|
};
|
|
870
|
-
}, Ne = (e) => {
|
|
890
|
+
}, Me = "x-oidc-resource", Ne = (e, t) => `${e}#resource=${encodeURIComponent(t)}`, Pe = (e) => {
|
|
891
|
+
let t = e.indexOf("#resource=");
|
|
892
|
+
return t < 0 ? void 0 : decodeURIComponent(e.slice(t + 10));
|
|
893
|
+
}, Fe = (e) => {
|
|
894
|
+
if (typeof e != "string" || !/^[a-z][a-z\d+.-]*:/i.test(e) || e.includes("#") || /\s/.test(e)) throw Error("A resource must be an absolute URI without whitespace or a fragment.");
|
|
895
|
+
new URL(e);
|
|
896
|
+
}, Ie = (e) => {
|
|
897
|
+
let t = new URL(e);
|
|
898
|
+
if (t.protocol !== "https:" && t.protocol !== "http:" || t.username || t.password || t.hash || /%2f|%5c/i.test(t.pathname)) throw Error("API destinations must be HTTP(S) URLs without credentials, fragments, or encoded separators.");
|
|
899
|
+
return t;
|
|
900
|
+
}, Le = (e) => {
|
|
901
|
+
let t = Ie(e);
|
|
902
|
+
if (t.search) throw Error("An API URL prefix must not contain a query.");
|
|
903
|
+
return t;
|
|
904
|
+
}, Re = (e, t) => {
|
|
905
|
+
let n = Ie(t).origin;
|
|
906
|
+
return e?.some((e) => e.allowedUrlPrefixes.some((e) => Le(e).origin === n)) ?? !1;
|
|
907
|
+
}, ze = (e, t) => {
|
|
908
|
+
let n = Ie(t);
|
|
909
|
+
return e.allowedUrlPrefixes.some((e) => {
|
|
910
|
+
let t = Le(e), r = t.pathname.replace(/\/+$/, "");
|
|
911
|
+
return n.origin === t.origin && (r === "" || n.pathname === r || n.pathname.startsWith(`${r}/`));
|
|
912
|
+
});
|
|
913
|
+
}, B = (e, t) => {
|
|
914
|
+
Fe(t);
|
|
915
|
+
let n = e?.filter((e) => e.resource === t) ?? [];
|
|
916
|
+
if (n.length !== 1 || n[0].allowedUrlPrefixes.length === 0) throw Error("The resource must be registered exactly once with permitted API URL prefixes.");
|
|
917
|
+
for (let e of n[0].allowedUrlPrefixes) ze(n[0], e);
|
|
918
|
+
return n[0];
|
|
919
|
+
}, Be = "1.1.0", Ve = {
|
|
920
|
+
SKIP_WAITING: "SKIP_WAITING",
|
|
921
|
+
CLAIM: "claim",
|
|
922
|
+
CLEAR: "clear",
|
|
923
|
+
INIT: "init",
|
|
924
|
+
SET_STATE: "setState",
|
|
925
|
+
GET_STATE: "getState",
|
|
926
|
+
SET_CODE_VERIFIER: "setCodeVerifier",
|
|
927
|
+
GET_CODE_VERIFIER: "getCodeVerifier",
|
|
928
|
+
SET_SESSION_STATE: "setSessionState",
|
|
929
|
+
GET_SESSION_STATE: "getSessionState",
|
|
930
|
+
SET_NONCE: "setNonce",
|
|
931
|
+
GET_NONCE: "getNonce",
|
|
932
|
+
SET_DPOP_NONCE: "setDemonstratingProofOfPossessionNonce",
|
|
933
|
+
GET_DPOP_NONCE: "getDemonstratingProofOfPossessionNonce",
|
|
934
|
+
SET_DPOP_JWK: "setDemonstratingProofOfPossessionJwk",
|
|
935
|
+
GET_DPOP_JWK: "getDemonstratingProofOfPossessionJwk"
|
|
936
|
+
}, He = {
|
|
937
|
+
ACCESS_TOKEN: "ACCESS_TOKEN_SECURED_BY_OIDC_SERVICE_WORKER",
|
|
938
|
+
REFRESH_TOKEN: "REFRESH_TOKEN_SECURED_BY_OIDC_SERVICE_WORKER",
|
|
939
|
+
NONCE_TOKEN: "NONCE_SECURED_BY_OIDC_SERVICE_WORKER",
|
|
940
|
+
CODE_VERIFIER: "CODE_VERIFIER_SECURED_BY_OIDC_SERVICE_WORKER"
|
|
941
|
+
}, Ue = "DPOP_SECURED_BY_OIDC_SERVICE_WORKER", We = {
|
|
942
|
+
TAB_ID: "oidc.tabId.",
|
|
943
|
+
STATE: "oidc.state.",
|
|
944
|
+
NONCE: "oidc.nonce.",
|
|
945
|
+
CODE_VERIFIER: "oidc.code_verifier.",
|
|
946
|
+
LOGIN_PARAMS: "oidc.login.",
|
|
947
|
+
SW_VERSION_MISMATCH_RELOAD: "oidc.sw.version_mismatch_reload."
|
|
948
|
+
}, Ge = "oidc.sw.controllerchange_reload_count", Ke = (e, t) => `${e}${t}`, qe = (e, t, n = "default") => `${e}_${t}#tabId=${n}`, Je = (e, t = "default") => `${Ue}_${e}#tabId=${t}`, Ye = (e) => typeof e == "string" && Object.values(Ve).includes(e), Xe = (e) => {
|
|
871
949
|
let t = e.match(/^([a-z][\w-]+\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/);
|
|
872
950
|
if (!t) throw Error("Invalid URL");
|
|
873
951
|
let n = t[6], r = t[7];
|
|
@@ -885,147 +963,198 @@ var he = () => {
|
|
|
885
963
|
search: n,
|
|
886
964
|
hash: r
|
|
887
965
|
};
|
|
888
|
-
},
|
|
889
|
-
let t =
|
|
966
|
+
}, Ze = (e) => {
|
|
967
|
+
let t = Xe(e), { path: n } = t;
|
|
890
968
|
n.endsWith("/") && (n = n.slice(0, -1));
|
|
891
969
|
let { hash: r } = t;
|
|
892
970
|
return (r === "#" || r === "#_=_") && (r = ""), r && (n += r), n;
|
|
893
|
-
},
|
|
894
|
-
let { search: t } =
|
|
895
|
-
return
|
|
896
|
-
},
|
|
971
|
+
}, V = (e) => {
|
|
972
|
+
let { search: t } = Xe(e);
|
|
973
|
+
return Qe(t);
|
|
974
|
+
}, Qe = (e) => {
|
|
897
975
|
let t = {};
|
|
898
976
|
for (let n of e.split("&")) {
|
|
899
977
|
let [e, r] = n.split("=");
|
|
900
978
|
t[decodeURIComponent(e)] = decodeURIComponent(r);
|
|
901
979
|
}
|
|
902
980
|
return t;
|
|
903
|
-
},
|
|
904
|
-
let
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
981
|
+
}, $e = "_oidc_resource", et = "oidc.resource_transaction.", H = (e, t) => t === void 0 ? e : Ne(e, t), tt = (t, n, i) => {
|
|
982
|
+
let a = i ?? n.resource;
|
|
983
|
+
if (a === void 0) return t;
|
|
984
|
+
let o = typeof a == "string" ? [a] : a;
|
|
985
|
+
if (o.length === 0) throw new r(e.INVALID_RESOURCE, "At least one resource is required.", {
|
|
986
|
+
phase: "login",
|
|
987
|
+
retryable: !1
|
|
988
|
+
});
|
|
989
|
+
for (let e of o) Fe(e), n.resources && B(n.resources, e);
|
|
990
|
+
let s = t.resource;
|
|
991
|
+
if (s !== void 0 && JSON.stringify(typeof s == "string" ? [s] : s) !== JSON.stringify(o)) throw new r(e.INVALID_RESOURCE, "Resource extras conflict with the selected resource.", {
|
|
992
|
+
phase: "login",
|
|
993
|
+
retryable: !1
|
|
994
|
+
});
|
|
995
|
+
return {
|
|
996
|
+
...t,
|
|
997
|
+
resource: a
|
|
998
|
+
};
|
|
999
|
+
}, nt = (e, t, n) => {
|
|
1000
|
+
sessionStorage.setItem(`${et}${e}.${t}`, n);
|
|
1001
|
+
}, rt = (e, t) => {
|
|
1002
|
+
let { state: n } = V(t);
|
|
1003
|
+
return n ? sessionStorage.getItem(`${et}${e}.${n}`) ?? void 0 : void 0;
|
|
1004
|
+
}, it = (e, t) => {
|
|
1005
|
+
let { state: n } = V(t);
|
|
1006
|
+
n && sessionStorage.removeItem(`${et}${e}.${n}`);
|
|
1007
|
+
}, at = (e, t) => {
|
|
1008
|
+
let n = `${et}${e}.`;
|
|
1009
|
+
for (let e of Object.keys(sessionStorage)) e.startsWith(n) && (t === void 0 || sessionStorage.getItem(e) === t) && sessionStorage.removeItem(e);
|
|
1010
|
+
}, ot = (e, t, n, r, i, a = () => window.fetch) => (o = void 0, s = null, u = !1, d = void 0) => {
|
|
1011
|
+
let p = s;
|
|
1012
|
+
s = { ...s };
|
|
1013
|
+
let m = s[$e];
|
|
1014
|
+
delete s[$e];
|
|
1015
|
+
let h = H(e, m);
|
|
1016
|
+
return (async () => {
|
|
1017
|
+
let _ = o || i.getPath();
|
|
1018
|
+
if ("state" in s || (s.state = se(16)), m !== void 0 && nt(e, s.state, m), n(f.loginAsync_begin, {}), s) for (let e of Object.keys(s)) e.endsWith(":token_request") && delete s[e];
|
|
908
1019
|
try {
|
|
909
|
-
let e = u ?
|
|
910
|
-
d ||=
|
|
911
|
-
let
|
|
912
|
-
...
|
|
913
|
-
...
|
|
914
|
-
} :
|
|
915
|
-
|
|
916
|
-
let
|
|
917
|
-
if (
|
|
918
|
-
callbackPath:
|
|
919
|
-
extras:
|
|
1020
|
+
let e = u ? t.silent_redirect_uri : t.redirect_uri;
|
|
1021
|
+
d ||= t.scope;
|
|
1022
|
+
let n = tt(t.extras ? {
|
|
1023
|
+
...t.extras,
|
|
1024
|
+
...s
|
|
1025
|
+
} : s, t, m);
|
|
1026
|
+
typeof n.scope == "string" && (d = n.scope), n.nonce ||= se(12);
|
|
1027
|
+
let o = { nonce: n.nonce }, c = await $(t, h), l = await r(t.authority, t.authority_configuration), f;
|
|
1028
|
+
if (c) c.setLoginParams({
|
|
1029
|
+
callbackPath: _,
|
|
1030
|
+
extras: p,
|
|
1031
|
+
scope: d,
|
|
1032
|
+
resource: m
|
|
1033
|
+
}), await c.initAsync(l, "loginAsync", {
|
|
1034
|
+
...t,
|
|
920
1035
|
scope: d
|
|
921
|
-
}), await
|
|
1036
|
+
}), await c.setNonceAsync(o), c.startKeepAliveServiceWorker(), f = c;
|
|
922
1037
|
else {
|
|
923
|
-
let e =
|
|
1038
|
+
let e = g(h, t.storage ?? sessionStorage, t.login_state_storage ?? t.storage ?? sessionStorage);
|
|
924
1039
|
e.setLoginParams({
|
|
925
|
-
callbackPath:
|
|
926
|
-
extras:
|
|
927
|
-
scope: d
|
|
928
|
-
|
|
1040
|
+
callbackPath: _,
|
|
1041
|
+
extras: p,
|
|
1042
|
+
scope: d,
|
|
1043
|
+
resource: m
|
|
1044
|
+
}), await e.setNonceAsync(o), f = e;
|
|
929
1045
|
}
|
|
930
|
-
let
|
|
931
|
-
client_id:
|
|
1046
|
+
let v = {
|
|
1047
|
+
client_id: t.client_id,
|
|
932
1048
|
redirect_uri: e,
|
|
933
1049
|
scope: d,
|
|
934
1050
|
response_type: "code",
|
|
935
|
-
...
|
|
936
|
-
},
|
|
937
|
-
if (!
|
|
938
|
-
let
|
|
939
|
-
endpoint:
|
|
940
|
-
fetch:
|
|
941
|
-
timeoutMs:
|
|
1051
|
+
...n
|
|
1052
|
+
}, y = t.par ?? "disabled", b = l.pushedAuthorizationRequestEndpoint, x = l.requirePushedAuthorizationRequests;
|
|
1053
|
+
if (!b && (y === "required" || y === "auto" && x)) throw new I(F.ENDPOINT_UNAVAILABLE, "Pushed Authorization Requests are required, but the authorization server metadata does not provide a pushed_authorization_request_endpoint.");
|
|
1054
|
+
let S = y !== "disabled" && b ? {
|
|
1055
|
+
endpoint: b,
|
|
1056
|
+
fetch: a(),
|
|
1057
|
+
timeoutMs: t.par_request_timeout
|
|
942
1058
|
} : void 0;
|
|
943
|
-
await
|
|
944
|
-
} catch (
|
|
945
|
-
let
|
|
946
|
-
throw
|
|
1059
|
+
await Ae(f, i)(l.authorizationEndpoint, v, S);
|
|
1060
|
+
} catch (e) {
|
|
1061
|
+
let t = l(e) ? c(e, "login") : e;
|
|
1062
|
+
throw n(f.loginAsync_error, t), t;
|
|
947
1063
|
}
|
|
948
1064
|
})();
|
|
949
|
-
},
|
|
1065
|
+
}, st = (t) => async (n = !1, o) => {
|
|
950
1066
|
try {
|
|
951
|
-
t.publishEvent(
|
|
952
|
-
let
|
|
953
|
-
if (
|
|
1067
|
+
t.publishEvent(f.loginCallbackAsync_begin, {});
|
|
1068
|
+
let i = t.configuration, c = H(t.configurationName, o), l = i.client_id, u = n ? i.silent_redirect_uri : i.redirect_uri, d = i.authority, p = i.token_request_timeout, m = await t.initAsync(d, i.authority_configuration), h = V(t.location.getCurrentHref()), _ = h.session_state, v = await $(i, c), y, b, x, S;
|
|
1069
|
+
if (v) await v.initAsync(m, "loginCallbackAsync", i), await v.setSessionStateAsync(_), b = await v.getNonceAsync(), x = v.getLoginParams(), S = await v.getStateAsync(), v.startKeepAliveServiceWorker(), y = v;
|
|
954
1070
|
else {
|
|
955
|
-
let e =
|
|
956
|
-
await e.setSessionStateAsync(
|
|
1071
|
+
let e = g(c, i.storage ?? sessionStorage, i.login_state_storage ?? i.storage ?? sessionStorage);
|
|
1072
|
+
await e.setSessionStateAsync(_), b = await e.getNonceAsync(), x = e.getLoginParams(), S = await e.getStateAsync(), y = e;
|
|
957
1073
|
}
|
|
958
|
-
if (
|
|
959
|
-
if (
|
|
960
|
-
if (
|
|
961
|
-
if (!
|
|
962
|
-
if (
|
|
1074
|
+
if (h.error || h.error_description) throw s(h.error, h.error_description, `Error from OIDC server: ${h.error} - ${h.error_description}`, n ? "refresh" : "callback");
|
|
1075
|
+
if (h.iss && h.iss !== m.issuer) throw console.error(), Error(`Issuer not valid (expected: ${m.issuer}, received: ${h.iss})`);
|
|
1076
|
+
if (h.state) {
|
|
1077
|
+
if (!S) throw new P(N.STATE_MISSING, "OIDC state is missing from storage. The login state may have been cleared between the authorization redirect and the callback (e.g., private browsing, storage cleared, or browser eviction).", n ? "refresh" : "callback");
|
|
1078
|
+
if (h.state !== S) throw new P(N.STATE_MISMATCH, `OIDC state does not match the stored one (expected: ${S}, received: ${h.state}).`, n ? "refresh" : "callback");
|
|
963
1079
|
}
|
|
964
|
-
if (!
|
|
965
|
-
let
|
|
966
|
-
code:
|
|
1080
|
+
if (!b || !b.nonce) throw new P(N.NONCE_MISSING, "OIDC nonce is missing from storage. The login state may have been cleared between the authorization redirect and the callback (e.g., private browsing, storage cleared, or browser eviction).", n ? "refresh" : "callback");
|
|
1081
|
+
let C = tt({
|
|
1082
|
+
code: h.code,
|
|
967
1083
|
grant_type: "authorization_code",
|
|
968
|
-
client_id:
|
|
969
|
-
redirect_uri:
|
|
970
|
-
},
|
|
971
|
-
if (
|
|
972
|
-
if (
|
|
973
|
-
let
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
1084
|
+
client_id: i.client_id,
|
|
1085
|
+
redirect_uri: u
|
|
1086
|
+
}, i, o), w = {};
|
|
1087
|
+
if (i.token_request_extras) for (let [e, t] of Object.entries(i.token_request_extras)) w[e] = t;
|
|
1088
|
+
if (x?.extras) for (let [e, t] of Object.entries(x.extras)) e.endsWith(":token_request") && (w[e.replace(":token_request", "")] = t);
|
|
1089
|
+
let T = m.tokenEndpoint, E = {}, D;
|
|
1090
|
+
if (i.demonstrating_proof_of_possession) {
|
|
1091
|
+
if (v) E.DPoP = `DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${c}`;
|
|
1092
|
+
else {
|
|
1093
|
+
if (D = o === void 0 ? await te(window)(i.demonstrating_proof_of_possession_configuration.generateKeyAlgorithm) : await g(t.configurationName, i.storage).getDemonstratingProofOfPossessionJwkAsync(), !D) throw new r(e.RESOURCE_TOKEN_UNAVAILABLE, "The original OIDC DPoP key is unavailable.", {
|
|
1094
|
+
phase: "callback",
|
|
1095
|
+
retryable: !1
|
|
1096
|
+
});
|
|
1097
|
+
await g(c, i.storage, i.login_state_storage ?? i.storage).setDemonstratingProofOfPossessionJwkAsync(D), E.DPoP = await ne(window)(i.demonstrating_proof_of_possession_configuration)(D, "POST", T);
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
let ee = tt({
|
|
1101
|
+
...C,
|
|
1102
|
+
...w
|
|
1103
|
+
}, i, o), O = await je(y)(T, ee, E, t.configuration.token_renew_mode, p, i.demonstrating_proof_of_possession);
|
|
1104
|
+
if (!O.success && O.oauthError === "use_dpop_nonce" && O.demonstratingProofOfPossessionNonce && i.demonstrating_proof_of_possession ? (await y.setDemonstratingProofOfPossessionNonce(O.demonstratingProofOfPossessionNonce), v || (E.DPoP = await ne(window)(i.demonstrating_proof_of_possession_configuration)(D, "POST", T, { nonce: O.demonstratingProofOfPossessionNonce })), O = await je(y)(T, ee, E, t.configuration.token_renew_mode, p)) : !O.success && i.demonstrating_proof_of_possession && await Promise.all([y.setCodeVerifierAsync(null), y.setStateAsync(null)]), !O.success) {
|
|
1105
|
+
let t = O.oauthError === "use_dpop_nonce" ? e.DPOP_NONCE_REQUIRED : e.TOKEN_REQUEST_FAILED;
|
|
1106
|
+
throw new r(t, "Token request failed", {
|
|
985
1107
|
phase: n ? "refresh" : "callback",
|
|
986
|
-
retryable:
|
|
987
|
-
status:
|
|
988
|
-
oauthError:
|
|
989
|
-
oauthErrorDescription:
|
|
1108
|
+
retryable: t === e.DPOP_NONCE_REQUIRED || a(O.status),
|
|
1109
|
+
status: O.status,
|
|
1110
|
+
oauthError: O.oauthError,
|
|
1111
|
+
oauthErrorDescription: O.oauthErrorDescription
|
|
990
1112
|
});
|
|
991
1113
|
}
|
|
992
|
-
let
|
|
993
|
-
|
|
1114
|
+
let k, A = O.data.tokens;
|
|
1115
|
+
i.resources?.length && (A.scope ??= x?.scope ?? i.scope);
|
|
1116
|
+
let j = O.data.demonstratingProofOfPossessionNonce;
|
|
1117
|
+
if (O.data.state !== w.state) throw new r(e.INVALID_STATE, "state is not valid", {
|
|
994
1118
|
phase: n ? "refresh" : "callback",
|
|
995
1119
|
retryable: !1
|
|
996
1120
|
});
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1121
|
+
if (o !== void 0 && A.idTokenPayload?.nonce !== b.nonce) throw new r(e.INVALID_NONCE, "Resource authorization requires the transaction nonce in a fresh ID token.", {
|
|
1122
|
+
phase: n ? "refresh" : "callback",
|
|
1123
|
+
retryable: !1
|
|
1124
|
+
});
|
|
1125
|
+
let { isValid: re, reason: ie } = It(A, b.nonce, m);
|
|
1126
|
+
if (!re) {
|
|
1127
|
+
let t = `Tokens are not OpenID valid, reason: ${ie}`;
|
|
1128
|
+
throw ie.startsWith("Nonce does not match") ? new r(e.INVALID_NONCE, t, {
|
|
1001
1129
|
phase: n ? "refresh" : "callback",
|
|
1002
1130
|
retryable: !1
|
|
1003
|
-
}) : Error(
|
|
1131
|
+
}) : Error(t);
|
|
1004
1132
|
}
|
|
1005
|
-
if (
|
|
1006
|
-
if (
|
|
1007
|
-
if (
|
|
1133
|
+
if (v) {
|
|
1134
|
+
if (A.refreshToken && !A.refreshToken.includes("SECURED_BY_OIDC_SERVICE_WORKER")) throw Error("Refresh token should be hidden by service worker");
|
|
1135
|
+
if (j && A?.accessToken.includes("SECURED_BY_OIDC_SERVICE_WORKER")) throw Error("Demonstration of proof of possession require Access token not hidden by service worker");
|
|
1008
1136
|
}
|
|
1009
|
-
if (
|
|
1137
|
+
if (v) await v.initAsync(m, "syncTokensAsync", i), k = v.getLoginParams(), j && await v.setDemonstratingProofOfPossessionNonce(j);
|
|
1010
1138
|
else {
|
|
1011
|
-
let e =
|
|
1012
|
-
|
|
1139
|
+
let e = g(c, i.storage, i.login_state_storage ?? i.storage);
|
|
1140
|
+
k = e.getLoginParams(), j && await e.setDemonstratingProofOfPossessionNonce(j);
|
|
1013
1141
|
}
|
|
1014
|
-
return await t.startCheckSessionAsync(
|
|
1015
|
-
|
|
1142
|
+
return o === void 0 && await t.startCheckSessionAsync(m.checkSessionIframe, l, _, n), t.publishEvent(f.loginCallbackAsync_end, {}), {
|
|
1143
|
+
resource: o,
|
|
1144
|
+
tokens: A,
|
|
1016
1145
|
state: "request.state",
|
|
1017
|
-
callbackPath:
|
|
1018
|
-
scope:
|
|
1019
|
-
extras:
|
|
1146
|
+
callbackPath: k.callbackPath,
|
|
1147
|
+
scope: h.scope,
|
|
1148
|
+
extras: k.extras
|
|
1020
1149
|
};
|
|
1021
|
-
} catch (
|
|
1022
|
-
let
|
|
1023
|
-
throw console.error(
|
|
1150
|
+
} catch (e) {
|
|
1151
|
+
let r = !i(e) && l(e) ? c(e, n ? "refresh" : "callback") : e;
|
|
1152
|
+
throw console.error(r), t.publishEvent(f.loginCallbackAsync_error, r), r;
|
|
1024
1153
|
}
|
|
1025
|
-
},
|
|
1154
|
+
}, ct = {
|
|
1026
1155
|
access_token: "access_token",
|
|
1027
1156
|
refresh_token: "refresh_token"
|
|
1028
|
-
},
|
|
1157
|
+
}, lt = (e, t) => {
|
|
1029
1158
|
let n = {};
|
|
1030
1159
|
if (e) {
|
|
1031
1160
|
for (let [r, i] of Object.entries(e)) if (r.endsWith(t)) {
|
|
@@ -1035,184 +1164,497 @@ var he = () => {
|
|
|
1035
1164
|
return n;
|
|
1036
1165
|
}
|
|
1037
1166
|
return n;
|
|
1038
|
-
},
|
|
1167
|
+
}, ut = (e) => {
|
|
1039
1168
|
let t = {};
|
|
1040
1169
|
if (e) {
|
|
1041
1170
|
for (let [n, r] of Object.entries(e)) n.includes(":") || (t[n] = r);
|
|
1042
1171
|
return t;
|
|
1043
1172
|
}
|
|
1044
1173
|
return t;
|
|
1045
|
-
},
|
|
1046
|
-
b.clearTimeout(e.timeoutId), e.timeoutId = null, e.checkSessionIFrame && e.checkSessionIFrame.stop();
|
|
1174
|
+
}, dt = (e) => async (t) => {
|
|
1175
|
+
e.resourceTokens && await e.resourceTokens.clearAllAsync(), b.clearTimeout(e.timeoutId), e.timeoutId = null, e.checkSessionIFrame && e.checkSessionIFrame.stop();
|
|
1047
1176
|
let n = await $(e.configuration, e.configurationName);
|
|
1048
|
-
n ? await n.clearAsync(t) : await
|
|
1049
|
-
},
|
|
1050
|
-
let
|
|
1051
|
-
await
|
|
1052
|
-
for (let [,
|
|
1053
|
-
},
|
|
1177
|
+
n ? await n.clearAsync(t) : await g(e.configurationName, e.configuration.storage, e.configuration.login_state_storage ?? e.configuration.storage).clearAsync(t), e.tokens = null, e.userInfo = null;
|
|
1178
|
+
}, ft = (e, t) => async () => {
|
|
1179
|
+
let n = e.tokens?.idTokenPayload?.sub ?? null;
|
|
1180
|
+
await e.destroyAsync("LOGGED_OUT");
|
|
1181
|
+
for (let [, r] of Object.entries(t)) r === e ? e.publishEvent(f.logout_from_same_tab, {}) : await e.logoutSameTabAsync(e.configuration.client_id, n);
|
|
1182
|
+
}, pt = (e, t, n, r) => {
|
|
1054
1183
|
"id_token_hint" in t || (t.id_token_hint = n), !("post_logout_redirect_uri" in t) && r !== null && (t.post_logout_redirect_uri = r);
|
|
1055
1184
|
let i = "";
|
|
1056
1185
|
for (let [e, n] of Object.entries(t)) n != null && (i += i === "" ? "?" : "&", i += `${e}=${encodeURIComponent(n)}`);
|
|
1057
1186
|
return `${e}${i}`;
|
|
1058
|
-
},
|
|
1059
|
-
let
|
|
1187
|
+
}, mt = (t, n, o, s, u) => async (d = void 0, p = null) => {
|
|
1188
|
+
let m = t.configuration, h;
|
|
1060
1189
|
try {
|
|
1061
|
-
|
|
1062
|
-
} catch (
|
|
1063
|
-
let
|
|
1064
|
-
throw t.publishEvent(
|
|
1190
|
+
h = await t.initAsync(m.authority, m.authority_configuration);
|
|
1191
|
+
} catch (e) {
|
|
1192
|
+
let n = l(e) ? c(e, "logout") : e;
|
|
1193
|
+
throw t.publishEvent(f.logoutAsync_error, n), n;
|
|
1065
1194
|
}
|
|
1066
|
-
|
|
1067
|
-
let
|
|
1068
|
-
|
|
1069
|
-
let v =
|
|
1195
|
+
d && typeof d != "string" && (d = void 0, s.warn("callbackPathOrUrl path is not a string"));
|
|
1196
|
+
let g = d ?? u.getPath(), _ = !1;
|
|
1197
|
+
d && (_ = d.includes("https://") || d.includes("http://"));
|
|
1198
|
+
let v = d === null ? null : _ ? d : u.getOrigin() + g, y = t.tokens ? t.tokens.idToken : "";
|
|
1070
1199
|
t.isLoggingOut = !0;
|
|
1071
1200
|
try {
|
|
1072
1201
|
try {
|
|
1073
|
-
|
|
1202
|
+
m.resources?.length && t.resourceTokens && await t.resourceTokens.withRefreshLockAsync(async () => {});
|
|
1203
|
+
let n = h.revocationEndpoint;
|
|
1074
1204
|
if (n) {
|
|
1075
|
-
let i = [],
|
|
1076
|
-
if (
|
|
1077
|
-
let e =
|
|
1205
|
+
let i = [], s = t.tokens ? t.tokens.accessToken : null;
|
|
1206
|
+
if (s && m.logout_tokens_to_invalidate.includes(ct.access_token)) {
|
|
1207
|
+
let e = lt(p, ":revoke_access_token"), t = Ee(o)(n, s, R.access_token, m.client_id, e);
|
|
1078
1208
|
i.push(t);
|
|
1079
1209
|
}
|
|
1080
|
-
let
|
|
1081
|
-
if (
|
|
1082
|
-
let e =
|
|
1210
|
+
let c = t.tokens ? t.tokens.refreshToken : null;
|
|
1211
|
+
if (c && m.logout_tokens_to_invalidate.includes(ct.refresh_token)) {
|
|
1212
|
+
let e = lt(p, ":revoke_refresh_token"), t = Ee(o)(n, c, R.refresh_token, m.client_id, e);
|
|
1083
1213
|
i.push(t);
|
|
1084
1214
|
}
|
|
1215
|
+
if (t.resourceTokens) {
|
|
1216
|
+
let e = await t.resourceTokens.getTokensToRevokeAsync(), r = new Set([s, c].filter(Boolean));
|
|
1217
|
+
for (let t of e) for (let [e, a] of [[R.access_token, t.accessToken], [R.refresh_token, t.refreshToken]]) a && !r.has(a) && m.logout_tokens_to_invalidate.includes(e) && (r.add(a), i.push(Ee(o)(n, a, e, m.client_id, lt(p, e === R.access_token ? ":revoke_access_token" : ":revoke_refresh_token"))));
|
|
1218
|
+
}
|
|
1085
1219
|
if (i.length > 0) {
|
|
1086
1220
|
let n = await Promise.all(i);
|
|
1087
|
-
for (let
|
|
1221
|
+
for (let i of n) i.success || t.publishEvent(f.logoutAsync_error, new r(e.REQUEST_FAILED, "Token revocation request failed", {
|
|
1088
1222
|
phase: "logout",
|
|
1089
|
-
retryable:
|
|
1090
|
-
status:
|
|
1091
|
-
oauthError:
|
|
1092
|
-
oauthErrorDescription:
|
|
1223
|
+
retryable: a(i.status),
|
|
1224
|
+
status: i.status,
|
|
1225
|
+
oauthError: i.oauthError,
|
|
1226
|
+
oauthErrorDescription: i.oauthErrorDescription
|
|
1093
1227
|
}));
|
|
1094
1228
|
}
|
|
1095
1229
|
}
|
|
1096
|
-
} catch (
|
|
1097
|
-
let
|
|
1098
|
-
t.publishEvent(
|
|
1230
|
+
} catch (e) {
|
|
1231
|
+
let n = !i(e) && l(e) ? c(e, "logout") : e;
|
|
1232
|
+
t.publishEvent(f.logoutAsync_error, n), s.warn("logoutAsync: error when revoking tokens, if the error persist, you ay configure property logout_tokens_to_invalidate from configuration to avoid this error"), s.warn(n);
|
|
1099
1233
|
}
|
|
1100
|
-
let
|
|
1101
|
-
if (
|
|
1102
|
-
await
|
|
1234
|
+
let d = lt(p, ":oidc");
|
|
1235
|
+
if (d && d.no_reload === "true") {
|
|
1236
|
+
await ft(t, n)(), t.isLoggingOut = !1;
|
|
1103
1237
|
return;
|
|
1104
1238
|
}
|
|
1105
|
-
let
|
|
1106
|
-
if (
|
|
1107
|
-
let e =
|
|
1108
|
-
|
|
1109
|
-
} else
|
|
1110
|
-
await
|
|
1111
|
-
} catch (
|
|
1239
|
+
let g = ut(p);
|
|
1240
|
+
if (h.endSessionEndpoint) {
|
|
1241
|
+
let e = pt(h.endSessionEndpoint, g, y, v);
|
|
1242
|
+
u.open(e);
|
|
1243
|
+
} else u.reload();
|
|
1244
|
+
await ft(t, n)();
|
|
1245
|
+
} catch (e) {
|
|
1112
1246
|
t.isLoggingOut = !1;
|
|
1113
|
-
let
|
|
1114
|
-
throw t.publishEvent(
|
|
1247
|
+
let n = !i(e) && l(e) ? c(e, "logout") : e;
|
|
1248
|
+
throw t.publishEvent(f.logoutAsync_error, n), n;
|
|
1249
|
+
}
|
|
1250
|
+
}, U = (t) => new r(e.RESOURCE_TOKEN_UNAVAILABLE, t, {
|
|
1251
|
+
phase: "refresh",
|
|
1252
|
+
retryable: !1
|
|
1253
|
+
}), ht = class {
|
|
1254
|
+
constructor(e) {
|
|
1255
|
+
this.oidc = e, this.pending = /* @__PURE__ */ new Map(), this.cached = /* @__PURE__ */ new Map(), this.generations = /* @__PURE__ */ new Map(), this.generation = 0, this.refreshQueue = Promise.resolve(), this.renewalTimers = /* @__PURE__ */ new Map();
|
|
1256
|
+
}
|
|
1257
|
+
async contextAsync(e) {
|
|
1258
|
+
let { oidc: t } = this, n = H(t.configurationName, e), r = await t.initAsync(t.configuration.authority, t.configuration.authority_configuration), i = await $(t.configuration, n), a = g(n, t.configuration.storage, t.configuration.login_state_storage ?? t.configuration.storage), o = i ? await i.initAsync(r, "resource-token", t.configuration) : await a.initAsync(), s = [];
|
|
1259
|
+
if ("resourceContexts" in o && o.resourceContexts !== void 0) {
|
|
1260
|
+
if (!Array.isArray(o.resourceContexts) || o.resourceContexts.some((e) => typeof e != "string")) throw U("The worker returned invalid resource context metadata.");
|
|
1261
|
+
s.push(...o.resourceContexts);
|
|
1262
|
+
}
|
|
1263
|
+
return {
|
|
1264
|
+
storage: i ?? a,
|
|
1265
|
+
tokens: o.tokens,
|
|
1266
|
+
server: r,
|
|
1267
|
+
isWorker: i !== null,
|
|
1268
|
+
resourceContexts: s
|
|
1269
|
+
};
|
|
1270
|
+
}
|
|
1271
|
+
validate(t, n, i, a = this.oidc.tokens?.idTokenPayload?.sub) {
|
|
1272
|
+
let { oidc: o } = this, s = B(o.configuration.resources, t), c = n.resourceContext;
|
|
1273
|
+
if (!c || c.resource !== t || c.issuer !== i || c.clientId !== o.configuration.client_id || c.configurationName !== o.configurationName || c.subject !== a) throw new r(e.RESOURCE_CONTEXT_MISMATCH, "The token does not belong to this resource and OIDC session.", {
|
|
1274
|
+
phase: "refresh",
|
|
1275
|
+
retryable: !1
|
|
1276
|
+
});
|
|
1277
|
+
let l = n.accessTokenPayload;
|
|
1278
|
+
if (l?.iss !== void 0 && l.iss !== i || l && s.audiences && !s.audiences.some((e) => (typeof l.aud == "string" ? [l.aud] : Array.isArray(l.aud) ? l.aud : []).includes(e))) throw new r(e.RESOURCE_CONTEXT_MISMATCH, "Resource token issuer or configured audience does not match.", {
|
|
1279
|
+
phase: "refresh",
|
|
1280
|
+
retryable: !1
|
|
1281
|
+
});
|
|
1282
|
+
if (typeof n.accessToken != "string" || !n.accessToken || !Number.isFinite(n.expiresAt) || !Number.isFinite(n.issuedAt) || n.refreshToken != null && (typeof n.refreshToken != "string" || !n.refreshToken)) throw U("The provider did not return a usable resource token response.");
|
|
1283
|
+
if (s.scope && !s.scope.split(/\s+/).filter(Boolean).every((e) => (n.scope ?? "").split(/\s+/).includes(e))) throw U("The provider did not grant the required resource scopes.");
|
|
1115
1284
|
}
|
|
1116
|
-
|
|
1285
|
+
publicToken(e, t) {
|
|
1286
|
+
return {
|
|
1287
|
+
resource: e,
|
|
1288
|
+
issuer: t.resourceContext.issuer,
|
|
1289
|
+
clientId: this.oidc.configuration.client_id,
|
|
1290
|
+
configurationName: this.oidc.configurationName,
|
|
1291
|
+
accessToken: t.accessToken,
|
|
1292
|
+
expiresAt: t.expiresAt,
|
|
1293
|
+
scope: t.scope,
|
|
1294
|
+
tokenType: t.tokenType
|
|
1295
|
+
};
|
|
1296
|
+
}
|
|
1297
|
+
updateSharedRefreshToken(e, t) {
|
|
1298
|
+
typeof e.refreshToken == "string" && e.refreshToken && this.oidc.tokens && (this.oidc.tokens = {
|
|
1299
|
+
...this.oidc.tokens,
|
|
1300
|
+
refreshToken: e.refreshToken
|
|
1301
|
+
}, t || g(this.oidc.configurationName, this.oidc.configuration.storage).setTokens(this.oidc.tokens));
|
|
1302
|
+
}
|
|
1303
|
+
scheduleRenewal(e, t) {
|
|
1304
|
+
let n = this.renewalTimers.get(e);
|
|
1305
|
+
if (n && b.clearTimeout(n), this.oidc.configuration.token_automatic_renew_mode === "AutomaticOnlyWhenFetchExecuted") return;
|
|
1306
|
+
let r = Math.max(1e3, Math.min(2147483647, (t.expiresAt - Date.now() / 1e3 - this.renewalMargin(t)) * 1e3)), a = b.setTimeout(async () => {
|
|
1307
|
+
this.renewalTimers.delete(e);
|
|
1308
|
+
try {
|
|
1309
|
+
await this.getAccessTokenAsync(e, { forceRenew: !0 });
|
|
1310
|
+
} catch (e) {
|
|
1311
|
+
console.error("Resource renewal failed:", i(e) ? e.code : "unexpected error");
|
|
1312
|
+
}
|
|
1313
|
+
}, r);
|
|
1314
|
+
this.renewalTimers.set(e, a);
|
|
1315
|
+
}
|
|
1316
|
+
renewalMargin(e) {
|
|
1317
|
+
return Math.min(this.oidc.configuration.refresh_time_before_tokens_expiration_in_second, Math.max(0, (e.expiresAt - e.issuedAt) / 2));
|
|
1318
|
+
}
|
|
1319
|
+
async withRefreshLockAsync(e) {
|
|
1320
|
+
let t = async () => {
|
|
1321
|
+
if (navigator.locks) {
|
|
1322
|
+
let t = this.oidc.configuration;
|
|
1323
|
+
return navigator.locks.request(`${t.client_id}_${this.oidc.configurationName}_${t.authority}`, e);
|
|
1324
|
+
}
|
|
1325
|
+
return e();
|
|
1326
|
+
}, n = this.refreshQueue.then(t, t);
|
|
1327
|
+
return this.refreshQueue = n.then(() => void 0, () => void 0), n;
|
|
1328
|
+
}
|
|
1329
|
+
async acceptAuthorizationAsync(t, n) {
|
|
1330
|
+
let i = this.generation, a = this.generations.get(t) ?? 0, o = await this.contextAsync(t), s = await this.contextAsync();
|
|
1331
|
+
if (i !== this.generation || a !== (this.generations.get(t) ?? 0)) throw U("The resource authorization was cleared.");
|
|
1332
|
+
let c = n.idTokenPayload?.sub;
|
|
1333
|
+
if (typeof c != "string" || (this.oidc.tokens?.idTokenPayload?.sub ?? s.tokens?.idTokenPayload?.sub) !== c) throw new r(e.RESOURCE_CONTEXT_MISMATCH, "Resource authorization must preserve the authenticated subject.", {
|
|
1334
|
+
phase: "callback",
|
|
1335
|
+
retryable: !1
|
|
1336
|
+
});
|
|
1337
|
+
if (n.refreshToken && n.refreshToken === s.tokens?.refreshToken) throw U("The provider reused a refresh token across separate authorization transactions; use a multi-resource authorization grant instead.");
|
|
1338
|
+
let l = {
|
|
1339
|
+
...n,
|
|
1340
|
+
scope: n.scope ?? B(this.oidc.configuration.resources, t).scope ?? this.oidc.configuration.scope,
|
|
1341
|
+
resourceContext: {
|
|
1342
|
+
resource: t,
|
|
1343
|
+
issuer: o.server.issuer,
|
|
1344
|
+
clientId: this.oidc.configuration.client_id,
|
|
1345
|
+
configurationName: this.oidc.configurationName,
|
|
1346
|
+
subject: c,
|
|
1347
|
+
grantResource: t
|
|
1348
|
+
}
|
|
1349
|
+
};
|
|
1350
|
+
this.validate(t, l, o.server.issuer, c), o.isWorker || g(H(this.oidc.configurationName, t), this.oidc.configuration.storage).setTokens(l), this.cached.set(t, l);
|
|
1351
|
+
}
|
|
1352
|
+
getAccessTokenAsync(t, n = {}) {
|
|
1353
|
+
let a = this.pending.get(t);
|
|
1354
|
+
if (a) return a;
|
|
1355
|
+
let o = this.generation, u = this.generations.get(t) ?? 0, d = this.oidc.tokens?.idTokenPayload?.sub, p = this.oidc.tokens?.idTokenPayload?.nonce, m = () => this.generation === o && (this.generations.get(t) ?? 0) === u && !this.oidc.isLoggingOut && this.oidc.tokens?.idTokenPayload?.sub === d && this.oidc.tokens?.idTokenPayload?.nonce === p, h = this.withRefreshLockAsync(async () => {
|
|
1356
|
+
let { oidc: i } = this, a = B(i.configuration.resources, t);
|
|
1357
|
+
if (!Number.isFinite(i.configuration.refresh_time_before_tokens_expiration_in_second) || i.configuration.refresh_time_before_tokens_expiration_in_second < 0) throw U("Configure a finite, non-negative renewal margin.");
|
|
1358
|
+
if (!i.tokens || typeof i.tokens.idTokenPayload?.sub != "string" || !m()) throw U("Sign in before requesting a resource token.");
|
|
1359
|
+
if (i.configuration.token_request_extras?.resource !== void 0 && i.configuration.token_request_extras.resource !== t) throw new r(e.INVALID_RESOURCE, "Token extras conflict with the selected resource.", {
|
|
1360
|
+
phase: "refresh",
|
|
1361
|
+
retryable: !1
|
|
1362
|
+
});
|
|
1363
|
+
let c = await this.contextAsync(t), l = await this.contextAsync();
|
|
1364
|
+
if (!m()) throw U("The resource transaction was cleared.");
|
|
1365
|
+
let h = l.tokens?.idTokenPayload?.nonce;
|
|
1366
|
+
if (!l.tokens || l.tokens.idTokenPayload?.sub !== d || !l.isWorker && h !== i.tokens.idTokenPayload?.nonce) throw U("The original OIDC session changed or is unavailable; restore it before requesting resource tokens.");
|
|
1367
|
+
let _ = c.tokens;
|
|
1368
|
+
if (_ && (this.validate(t, _, c.server.issuer), !n.forceRenew && Pt(_, this.renewalMargin(_)))) {
|
|
1369
|
+
let e = this.cached.get(t);
|
|
1370
|
+
return this.cached.set(t, _), this.scheduleRenewal(t, _), (e?.accessToken !== _.accessToken || e?.expiresAt !== _.expiresAt || e?.scope !== _.scope || e?.tokenType !== _.tokenType) && i.publishEvent(f.resource_token_acquired, { resource: t }), this.publicToken(t, _);
|
|
1371
|
+
}
|
|
1372
|
+
let v = typeof i.configuration.resource == "string" ? [i.configuration.resource] : i.configuration.resource ?? [], y = (l.tokens.scope ?? i.configuration.scope).split(/\s+/), b = !a.scope || a.scope.split(/\s+/).filter(Boolean).every((e) => y.includes(e)), S = _?.resourceContext ? _.resourceContext.grantResource : v.includes(t) && b ? null : t, C = S === null ? await this.contextAsync() : c, w = S === null && !b ? void 0 : C.tokens?.refreshToken, T = i.configuration.demonstrating_proof_of_possession || C.tokens?.tokenType?.toLowerCase() === "dpop";
|
|
1373
|
+
if (!m()) throw U("The resource transaction was cleared.");
|
|
1374
|
+
if (w) {
|
|
1375
|
+
let n = await C.storage.getNonceAsync(), l = c.isWorker ? { [Me]: encodeURIComponent(t) } : {};
|
|
1376
|
+
T && (l.DPoP = await this.generateProofAsync(t, {
|
|
1377
|
+
accessToken: C.tokens.accessToken,
|
|
1378
|
+
url: c.server.tokenEndpoint,
|
|
1379
|
+
method: "POST",
|
|
1380
|
+
grantResource: S
|
|
1381
|
+
}));
|
|
1382
|
+
let f = {
|
|
1383
|
+
client_id: i.configuration.client_id,
|
|
1384
|
+
grant_type: "refresh_token",
|
|
1385
|
+
refresh_token: w,
|
|
1386
|
+
resource: t,
|
|
1387
|
+
...a.scope ? { scope: a.scope } : {}
|
|
1388
|
+
}, v = () => ke(i.getFetch())(c.server.tokenEndpoint, f, i.configuration.token_request_extras ?? {}, _, l, Y.access_token_invalid, i.configuration.token_request_timeout), y = await v();
|
|
1389
|
+
if (!y.success && y.oauthError === "use_dpop_nonce" && y.demonstratingProofOfPossessionNonce && T && (await C.storage.setDemonstratingProofOfPossessionNonce(y.demonstratingProofOfPossessionNonce), l.DPoP = await this.generateProofAsync(t, {
|
|
1390
|
+
accessToken: C.tokens.accessToken,
|
|
1391
|
+
url: c.server.tokenEndpoint,
|
|
1392
|
+
method: "POST",
|
|
1393
|
+
grantResource: S
|
|
1394
|
+
}), y = await v()), y.success) {
|
|
1395
|
+
let s = await this.contextAsync();
|
|
1396
|
+
if (!s.tokens || s.tokens.idTokenPayload?.sub !== d || !s.isWorker && s.tokens.idTokenPayload?.nonce !== h) throw U("The original OIDC session changed during resource renewal.");
|
|
1397
|
+
_ = y.data;
|
|
1398
|
+
let l = this.generation === o && i.tokens?.idTokenPayload?.sub === d && i.tokens?.idTokenPayload?.nonce === p;
|
|
1399
|
+
if (l && S === null && this.updateSharedRefreshToken(_, c.isWorker), _.idTokenPayload?.sub !== void 0 && _.idTokenPayload.sub !== d) throw new r(e.RESOURCE_CONTEXT_MISMATCH, "Resource renewal changed the authenticated subject.", {
|
|
1400
|
+
phase: "refresh",
|
|
1401
|
+
retryable: !1
|
|
1402
|
+
});
|
|
1403
|
+
let f = It(_, n?.nonce, c.server);
|
|
1404
|
+
if (!f.isValid) throw U(f.reason);
|
|
1405
|
+
if (_ = {
|
|
1406
|
+
..._,
|
|
1407
|
+
scope: _.scope ?? a.scope ?? C.tokens.scope ?? i.configuration.scope,
|
|
1408
|
+
resourceContext: {
|
|
1409
|
+
resource: t,
|
|
1410
|
+
issuer: c.server.issuer,
|
|
1411
|
+
clientId: i.configuration.client_id,
|
|
1412
|
+
configurationName: i.configurationName,
|
|
1413
|
+
subject: d,
|
|
1414
|
+
grantResource: S
|
|
1415
|
+
}
|
|
1416
|
+
}, this.validate(t, _, c.server.issuer, d), !m()) throw l && i.isLoggingOut && u === (this.generations.get(t) ?? 0) && !c.isWorker && g(H(i.configurationName, t), i.configuration.storage).setTokens(_), U("The resource transaction was cleared.");
|
|
1417
|
+
y.demonstratingProofOfPossessionNonce && await C.storage.setDemonstratingProofOfPossessionNonce(y.demonstratingProofOfPossessionNonce), c.isWorker || g(H(i.configurationName, t), i.configuration.storage).setTokens(_), S === null && this.updateSharedRefreshToken(_, c.isWorker);
|
|
1418
|
+
} else if (y.oauthError !== "invalid_grant") throw s(y.oauthError, y.oauthErrorDescription, "Resource token request failed.", "refresh", y.status);
|
|
1419
|
+
else _ = null;
|
|
1420
|
+
} else _ = null;
|
|
1421
|
+
if (!_) {
|
|
1422
|
+
if (!m()) throw U("The resource transaction was cleared.");
|
|
1423
|
+
let e = a.scope ? [.../* @__PURE__ */ new Set(["openid", ...a.scope.split(" ")])].join(" ") : i.configuration.scope, n = await x(i.configurationName, i.configuration, i.publishEvent.bind(i), "refresh")({
|
|
1424
|
+
...i.configuration.extras,
|
|
1425
|
+
prompt: "none",
|
|
1426
|
+
resource: t,
|
|
1427
|
+
[$e]: t
|
|
1428
|
+
}, null, e);
|
|
1429
|
+
if (!n) throw U("Configure silent_redirect_uri and silent_login_uri for resource authorization.");
|
|
1430
|
+
if (n.error) throw n.oidcError ?? s(n.error, void 0, "Resource silent authorization failed.", "refresh");
|
|
1431
|
+
if (!m() || n.resource !== t) throw U("The resource authorization transaction is no longer current.");
|
|
1432
|
+
await this.acceptAuthorizationAsync(t, n.tokens), c = await this.contextAsync(t), _ = c.tokens ?? this.cached.get(t);
|
|
1433
|
+
}
|
|
1434
|
+
if (!m()) throw U("The resource transaction was cleared.");
|
|
1435
|
+
if (this.validate(t, _, c.server.issuer), !Pt(_)) throw U("The resource access token is expired.");
|
|
1436
|
+
return this.cached.set(t, _), this.scheduleRenewal(t, _), i.publishEvent(f.resource_token_acquired, { resource: t }), this.publicToken(t, _);
|
|
1437
|
+
}).catch((n) => {
|
|
1438
|
+
let a = i(n) ? n : l(n) ? c(n, "refresh") : new r(e.RESOURCE_TOKEN_UNAVAILABLE, n instanceof Error ? n.message : "Resource token acquisition failed.", {
|
|
1439
|
+
phase: "refresh",
|
|
1440
|
+
retryable: !1,
|
|
1441
|
+
cause: n
|
|
1442
|
+
});
|
|
1443
|
+
throw this.oidc.publishEvent(f.resource_token_error, {
|
|
1444
|
+
resource: t,
|
|
1445
|
+
error: a
|
|
1446
|
+
}), a;
|
|
1447
|
+
}).finally(() => {
|
|
1448
|
+
this.pending.get(t) === h && this.pending.delete(t);
|
|
1449
|
+
});
|
|
1450
|
+
return this.pending.set(t, h), h;
|
|
1451
|
+
}
|
|
1452
|
+
async generateProofAsync(e, t) {
|
|
1453
|
+
let n = this.cached.get(e)?.resourceContext, r = t.grantResource === void 0 ? n ? n.grantResource : e : t.grantResource, i = await this.contextAsync(r ?? void 0);
|
|
1454
|
+
if (i.isWorker) return `DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${H(this.oidc.configurationName, e)}`;
|
|
1455
|
+
let a = await i.storage.getDemonstratingProofOfPossessionJwkAsync();
|
|
1456
|
+
if (!a) throw U("The resource DPoP grant key is unavailable.");
|
|
1457
|
+
let o = t.url === i.server.tokenEndpoint ? await i.storage.getDemonstratingProofOfPossessionNonce() : g(H(this.oidc.configurationName, e), this.oidc.configuration.storage).getDemonstratingProofOfPossessionApiNonce();
|
|
1458
|
+
return ne(window)(this.oidc.configuration.demonstrating_proof_of_possession_configuration)(a, t.method, t.url, {
|
|
1459
|
+
ath: await le(t.accessToken),
|
|
1460
|
+
...o ? { nonce: o } : {}
|
|
1461
|
+
});
|
|
1462
|
+
}
|
|
1463
|
+
peek(e) {
|
|
1464
|
+
if (this.oidc.isLoggingOut) return null;
|
|
1465
|
+
let t = this.cached.get(e);
|
|
1466
|
+
return t && t.resourceContext?.subject === this.oidc.tokens?.idTokenPayload?.sub && Pt(t) ? this.publicToken(e, t) : null;
|
|
1467
|
+
}
|
|
1468
|
+
createApiNonceRecorder(e) {
|
|
1469
|
+
let t = this.generation, n = this.generations.get(e) ?? 0;
|
|
1470
|
+
return async (r) => {
|
|
1471
|
+
t !== this.generation || n !== (this.generations.get(e) ?? 0) || !this.peek(e) ? console.warn("Ignoring a resource API nonce response after its session was cleared.") : this.oidc.configuration.service_worker_relative_url || await g(H(this.oidc.configurationName, e), this.oidc.configuration.storage).setDemonstratingProofOfPossessionApiNonce(r);
|
|
1472
|
+
};
|
|
1473
|
+
}
|
|
1474
|
+
async getTokensToRevokeAsync() {
|
|
1475
|
+
if (!this.oidc.configuration.resources?.length) return [];
|
|
1476
|
+
let e = await this.contextAsync(), t = e.isWorker ? e.resourceContexts.map(Pe).filter((e) => e !== void 0) : this.oidc.configuration.resources.map((e) => e.resource), n = [];
|
|
1477
|
+
for (let e of t) {
|
|
1478
|
+
let t = await this.contextAsync(e);
|
|
1479
|
+
t.tokens && (this.validate(e, t.tokens, t.server.issuer), n.push(t.tokens));
|
|
1480
|
+
}
|
|
1481
|
+
return n;
|
|
1482
|
+
}
|
|
1483
|
+
async clearAsync(e) {
|
|
1484
|
+
B(this.oidc.configuration.resources, e), this.generations.set(e, (this.generations.get(e) ?? 0) + 1), at(this.oidc.configurationName, e), this.pending.delete(e), this.cached.delete(e);
|
|
1485
|
+
let t = this.renewalTimers.get(e);
|
|
1486
|
+
t && b.clearTimeout(t), this.renewalTimers.delete(e);
|
|
1487
|
+
let n = await this.contextAsync(e);
|
|
1488
|
+
await n.storage.clearAsync("LOGGED_OUT"), n.storage.setLoginParams(null), n.isWorker || (await g(H(this.oidc.configurationName, e), this.oidc.configuration.storage).setDemonstratingProofOfPossessionApiNonce(null), await Promise.all([
|
|
1489
|
+
n.storage.setStateAsync(null),
|
|
1490
|
+
n.storage.setCodeVerifierAsync(null),
|
|
1491
|
+
n.storage.setNonceAsync(null),
|
|
1492
|
+
n.storage.setDemonstratingProofOfPossessionJwkAsync(null),
|
|
1493
|
+
n.storage.setDemonstratingProofOfPossessionNonce(null)
|
|
1494
|
+
])), this.oidc.publishEvent(f.resource_token_cleared, { resource: e });
|
|
1495
|
+
}
|
|
1496
|
+
async clearAllAsync() {
|
|
1497
|
+
if (this.oidc.configuration.resources?.length) {
|
|
1498
|
+
this.generation++, at(this.oidc.configurationName), this.pending.clear(), this.cached.clear();
|
|
1499
|
+
for (let e of this.renewalTimers.values()) b.clearTimeout(e);
|
|
1500
|
+
if (this.renewalTimers.clear(), !this.oidc.configuration.service_worker_relative_url) for (let e of this.oidc.configuration.resources ?? []) {
|
|
1501
|
+
let t = g(H(this.oidc.configurationName, e.resource), this.oidc.configuration.storage, this.oidc.configuration.login_state_storage ?? this.oidc.configuration.storage);
|
|
1502
|
+
await t.clearAsync("LOGGED_OUT"), t.setLoginParams(null), await Promise.all([
|
|
1503
|
+
t.setStateAsync(null),
|
|
1504
|
+
t.setCodeVerifierAsync(null),
|
|
1505
|
+
t.setNonceAsync(null),
|
|
1506
|
+
t.setDemonstratingProofOfPossessionJwkAsync(null),
|
|
1507
|
+
t.setDemonstratingProofOfPossessionNonce(null),
|
|
1508
|
+
t.setDemonstratingProofOfPossessionApiNonce(null)
|
|
1509
|
+
]);
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
}, W = /* @__PURE__ */ function(e) {
|
|
1117
1514
|
return e.AutomaticBeforeTokenExpiration = "AutomaticBeforeTokensExpiration", e.AutomaticOnlyWhenFetchExecuted = "AutomaticOnlyWhenFetchExecuted", e;
|
|
1118
|
-
}({}),
|
|
1119
|
-
let [
|
|
1120
|
-
|
|
1121
|
-
|
|
1515
|
+
}({}), gt = (t, n, i = !1, a = "api_request") => async (...o) => {
|
|
1516
|
+
let [s, l, ...u] = o, d = typeof a == "string" ? a : "api_request", p = typeof a == "string" ? void 0 : a.resource, m;
|
|
1517
|
+
if (p === void 0 && d === "api_request" && n.configuration.resources?.length) try {
|
|
1518
|
+
let e = new URL(s instanceof Request ? s.url : s.toString(), window.location.href).toString();
|
|
1519
|
+
if (Re(n.configuration.resources, e)) throw Error("Select a resource explicitly when fetching a resource-managed API.");
|
|
1520
|
+
} catch (t) {
|
|
1521
|
+
let i = new r(e.INVALID_RESOURCE, t instanceof Error ? t.message : "Invalid resource destination.", {
|
|
1522
|
+
phase: d,
|
|
1523
|
+
retryable: !1,
|
|
1524
|
+
cause: t
|
|
1525
|
+
});
|
|
1526
|
+
throw n.publishEvent(f.apiRequest_error, i), i;
|
|
1527
|
+
}
|
|
1528
|
+
if (typeof a != "string" && Object.prototype.hasOwnProperty.call(a, "resource")) try {
|
|
1529
|
+
if (typeof p != "string") throw Error("An explicit resource identifier is required.");
|
|
1530
|
+
if (m = new URL(s instanceof Request ? s.url : s.toString(), window.location.href).toString(), !ze(B(n.configuration.resources, p), m)) throw Error("The destination does not belong to the selected resource.");
|
|
1531
|
+
if (l?.redirect === "follow") throw Error("Resource fetch cannot automatically follow redirects.");
|
|
1532
|
+
} catch (t) {
|
|
1533
|
+
let i = new r(e.INVALID_RESOURCE, t instanceof Error ? t.message : "Invalid resource destination.", {
|
|
1534
|
+
phase: d,
|
|
1535
|
+
retryable: !1,
|
|
1536
|
+
cause: t
|
|
1537
|
+
});
|
|
1538
|
+
throw n.publishEvent(f.apiRequest_error, i), i;
|
|
1539
|
+
}
|
|
1540
|
+
let h = p === void 0 ? l ? { ...l } : { method: "GET" } : {
|
|
1541
|
+
...s instanceof Request ? {
|
|
1542
|
+
method: s.method,
|
|
1543
|
+
headers: s.headers,
|
|
1544
|
+
credentials: s.credentials
|
|
1545
|
+
} : { method: "GET" },
|
|
1546
|
+
...l,
|
|
1547
|
+
redirect: l?.redirect ?? "error"
|
|
1548
|
+
}, g = new Headers();
|
|
1549
|
+
h.headers && (g = p === void 0 && h.headers instanceof Headers ? h.headers : new Headers(h.headers));
|
|
1550
|
+
let _ = {
|
|
1122
1551
|
getTokens: () => n.tokens,
|
|
1123
1552
|
configuration: {
|
|
1124
1553
|
token_automatic_renew_mode: n.configuration.token_automatic_renew_mode,
|
|
1125
1554
|
refresh_time_before_tokens_expiration_in_second: n.configuration.refresh_time_before_tokens_expiration_in_second
|
|
1126
1555
|
},
|
|
1127
1556
|
syncTokensInfoAsync: async () => {
|
|
1128
|
-
let { status: e } = await
|
|
1557
|
+
let { status: e } = await Et(n)(n.configuration, n.configurationName, n.tokens, !1);
|
|
1129
1558
|
return e;
|
|
1130
1559
|
},
|
|
1131
1560
|
renewTokensAsync: n.renewTokensAsync.bind(n)
|
|
1132
|
-
}))?.tokens?.accessToken;
|
|
1133
|
-
if (
|
|
1134
|
-
if (n.configuration.demonstrating_proof_of_possession &&
|
|
1135
|
-
let e = await n.generateDemonstrationOfProofOfPossessionAsync(
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
}
|
|
1561
|
+
}, v = p === void 0 ? void 0 : await n.resourceTokens.getAccessTokenAsync(p), y = p === void 0 ? await Ft(_) : void 0, b = v?.accessToken ?? y?.tokens?.accessToken;
|
|
1562
|
+
if (g.has("Accept") || g.set("Accept", "application/json"), b) {
|
|
1563
|
+
if (n.configuration.demonstrating_proof_of_possession && i || v?.tokenType?.toLowerCase() === "dpop") {
|
|
1564
|
+
let e = p === void 0 ? await n.generateDemonstrationOfProofOfPossessionAsync(b, s.toString(), h.method) : await n.resourceTokens.generateProofAsync(p, {
|
|
1565
|
+
accessToken: b,
|
|
1566
|
+
url: m,
|
|
1567
|
+
method: h.method ?? "GET"
|
|
1568
|
+
});
|
|
1569
|
+
g.set("Authorization", `DPoP ${b}`), g.set("DPoP", e);
|
|
1570
|
+
} else g.set("Authorization", `Bearer ${b}`);
|
|
1571
|
+
h.credentials ||= "same-origin";
|
|
1572
|
+
}
|
|
1573
|
+
let x = {
|
|
1574
|
+
...h,
|
|
1575
|
+
headers: g
|
|
1576
|
+
}, S = v && g.has("DPoP") ? n.resourceTokens.createApiNonceRecorder(p) : void 0;
|
|
1577
|
+
if (v && n.resourceTokens.peek(p)?.accessToken !== v.accessToken) {
|
|
1578
|
+
let t = new r(e.RESOURCE_TOKEN_UNAVAILABLE, "The selected resource token was cleared or changed before dispatch.", {
|
|
1579
|
+
phase: d,
|
|
1580
|
+
retryable: !1
|
|
1581
|
+
});
|
|
1582
|
+
throw n.publishEvent(f.apiRequest_error, t), t;
|
|
1583
|
+
}
|
|
1584
|
+
let C;
|
|
1144
1585
|
try {
|
|
1145
|
-
|
|
1146
|
-
} catch (
|
|
1147
|
-
let
|
|
1148
|
-
throw
|
|
1586
|
+
C = await t(s, x, ...u);
|
|
1587
|
+
} catch (e) {
|
|
1588
|
+
let t = c(e, d);
|
|
1589
|
+
throw d === "api_request" && n.publishEvent(f.apiRequest_error, t), t;
|
|
1149
1590
|
}
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1591
|
+
let w = C.headers?.get("DPoP-Nonce");
|
|
1592
|
+
if (S && w && await S(w), !C.ok && C.headers?.has("DPoP-Nonce") && (C.status === 400 || C.status === 401 || C.headers.get("WWW-Authenticate")?.includes("use_dpop_nonce"))) {
|
|
1593
|
+
let t = new r(e.DPOP_NONCE_REQUIRED, "DPoP nonce required", {
|
|
1594
|
+
phase: d,
|
|
1153
1595
|
retryable: !0,
|
|
1154
|
-
status:
|
|
1596
|
+
status: C.status,
|
|
1155
1597
|
oauthError: "use_dpop_nonce"
|
|
1156
1598
|
});
|
|
1157
|
-
|
|
1599
|
+
d === "api_request" && n.publishEvent(f.apiRequest_error, t);
|
|
1158
1600
|
}
|
|
1159
|
-
return
|
|
1160
|
-
},
|
|
1601
|
+
return C;
|
|
1602
|
+
}, _t = (t) => async (n = !1, o = !1) => {
|
|
1161
1603
|
try {
|
|
1162
1604
|
if (t.userInfo != null && !n) return t.userInfo;
|
|
1163
1605
|
let i = !n && t.configuration.storage?.getItem(`oidc.${t.configurationName}.userInfo`);
|
|
1164
1606
|
if (i) return t.userInfo = JSON.parse(i), t.userInfo;
|
|
1165
|
-
let
|
|
1166
|
-
let n = await
|
|
1607
|
+
let s = t.configuration, c = (await t.initAsync(s.authority, s.authority_configuration)).userInfoEndpoint, l = await (async () => {
|
|
1608
|
+
let n = await gt(fetch, t, o, "userinfo")(c);
|
|
1167
1609
|
if (n.status !== 200) {
|
|
1168
|
-
let
|
|
1610
|
+
let i = n.headers?.has("DPoP-Nonce") && (n.status === 400 || n.status === 401 || n.headers.get("WWW-Authenticate")?.includes("use_dpop_nonce")), o = new r(i ? e.DPOP_NONCE_REQUIRED : e.REQUEST_FAILED, "UserInfo request failed", {
|
|
1169
1611
|
phase: "userinfo",
|
|
1170
|
-
retryable:
|
|
1612
|
+
retryable: i || a(n.status),
|
|
1171
1613
|
status: n.status,
|
|
1172
|
-
oauthError:
|
|
1614
|
+
oauthError: i ? "use_dpop_nonce" : void 0
|
|
1173
1615
|
});
|
|
1174
|
-
return t.publishEvent(
|
|
1616
|
+
return t.publishEvent(f.userInfoAsync_error, o), null;
|
|
1175
1617
|
}
|
|
1176
1618
|
return n.json();
|
|
1177
1619
|
})();
|
|
1178
|
-
return t.userInfo =
|
|
1179
|
-
} catch (
|
|
1180
|
-
let
|
|
1181
|
-
throw t.publishEvent(
|
|
1620
|
+
return t.userInfo = l, l && t.configuration.storage?.setItem(`oidc.${t.configurationName}.userInfo`, JSON.stringify(l)), l;
|
|
1621
|
+
} catch (e) {
|
|
1622
|
+
let n = i(e) ? e : l(e) ? c(e, "userinfo") : e;
|
|
1623
|
+
throw t.publishEvent(f.userInfoAsync_error, n), n;
|
|
1182
1624
|
}
|
|
1183
|
-
},
|
|
1625
|
+
}, vt = () => fetch, yt = class {
|
|
1184
1626
|
constructor(e) {
|
|
1185
1627
|
this.authorizationEndpoint = e.authorization_endpoint, this.tokenEndpoint = e.token_endpoint, this.revocationEndpoint = e.revocation_endpoint, this.userInfoEndpoint = e.userinfo_endpoint, this.checkSessionIframe = e.check_session_iframe, this.issuer = e.issuer, this.endSessionEndpoint = e.end_session_endpoint, this.pushedAuthorizationRequestEndpoint = e.pushed_authorization_request_endpoint, this.requirePushedAuthorizationRequests = e.require_pushed_authorization_requests ?? !1;
|
|
1186
1628
|
}
|
|
1187
|
-
},
|
|
1629
|
+
}, G = {}, bt = (e, t = new M()) => (n, r = "default") => (G[r] || (G[r] = new K(n, r, e, t)), G[r]), xt = async (e) => {
|
|
1188
1630
|
let { parsedTokens: t, callbackPath: n, extras: r, scope: i } = await e.loginCallbackAsync();
|
|
1189
|
-
return e.timeoutId =
|
|
1190
|
-
},
|
|
1191
|
-
constructor(e, t = "default", n, r = new
|
|
1631
|
+
return e.timeoutId = q(e, t.expiresAt, r, i), { callbackPath: n };
|
|
1632
|
+
}, K = class t {
|
|
1633
|
+
constructor(e, t = "default", n, r = new M()) {
|
|
1192
1634
|
this.isLoggingOut = !1, this.initPromise = null, this.tryKeepExistingSessionPromise = null, this.loginPromise = null, this.loginCallbackPromise = null, this.loginCallbackWithAutoTokensRenewPromise = null, this.userInfoPromise = null, this.renewTokensPromise = null, this.clearSessionPromise = null, this.logoutPromise = null;
|
|
1193
1635
|
let i = e.silent_login_uri;
|
|
1194
1636
|
e.silent_redirect_uri && !e.silent_login_uri && (i = `${e.silent_redirect_uri.replace("-callback", "").replace("callback", "")}-login`);
|
|
1195
1637
|
let a = e.refresh_time_before_tokens_expiration_in_second ?? 120;
|
|
1196
|
-
a > 60 && (a -= Math.floor(Math.random() * 40)), this.location = r ?? new
|
|
1638
|
+
a > 60 && (a -= Math.floor(Math.random() * 40)), this.location = r ?? new M(), this.configuration = {
|
|
1197
1639
|
...e,
|
|
1198
1640
|
silent_login_uri: i,
|
|
1199
|
-
token_automatic_renew_mode: e.token_automatic_renew_mode ??
|
|
1641
|
+
token_automatic_renew_mode: e.token_automatic_renew_mode ?? W.AutomaticBeforeTokenExpiration,
|
|
1200
1642
|
monitor_session: e.monitor_session ?? !1,
|
|
1201
1643
|
refresh_time_before_tokens_expiration_in_second: a,
|
|
1202
1644
|
silent_login_timeout: e.silent_login_timeout ?? 12e3,
|
|
1203
|
-
token_renew_mode: e.token_renew_mode ??
|
|
1645
|
+
token_renew_mode: e.token_renew_mode ?? Y.access_token_or_id_token_invalid,
|
|
1204
1646
|
demonstrating_proof_of_possession: e.demonstrating_proof_of_possession ?? !1,
|
|
1205
1647
|
authority_timeout_wellknowurl_in_millisecond: e.authority_timeout_wellknowurl_in_millisecond ?? 1e4,
|
|
1206
1648
|
logout_tokens_to_invalidate: e.logout_tokens_to_invalidate ?? ["access_token", "refresh_token"],
|
|
1207
|
-
service_worker_activate: e.service_worker_activate ??
|
|
1208
|
-
demonstrating_proof_of_possession_configuration: e.demonstrating_proof_of_possession_configuration ??
|
|
1649
|
+
service_worker_activate: e.service_worker_activate ?? me,
|
|
1650
|
+
demonstrating_proof_of_possession_configuration: e.demonstrating_proof_of_possession_configuration ?? O,
|
|
1209
1651
|
preload_user_info: e.preload_user_info ?? !1,
|
|
1210
1652
|
par: e.par ?? "disabled",
|
|
1211
1653
|
par_request_timeout: e.par_request_timeout ?? 1e4
|
|
1212
|
-
}, this.getFetch = n ??
|
|
1654
|
+
}, this.getFetch = n ?? vt, this.configurationName = t, this.tokens = null, this.userInfo = null, this.events = [], this.timeoutId = null, this.resourceTokens = new ht(this), this.loginCallbackWithAutoTokensRenewAsync.bind(this), this.initAsync.bind(this), this.loginCallbackAsync.bind(this), this.subscribeEvents.bind(this), this.removeEventSubscription.bind(this), this.publishEvent.bind(this), this.destroyAsync.bind(this), this.logoutAsync.bind(this), this.renewTokensAsync.bind(this), this.renewTokensOrThrowAsync.bind(this), this.initAsync(this.configuration.authority, this.configuration.authority_configuration);
|
|
1213
1655
|
}
|
|
1214
1656
|
subscribeEvents(e) {
|
|
1215
|
-
let t =
|
|
1657
|
+
let t = se(16);
|
|
1216
1658
|
return this.events.push({
|
|
1217
1659
|
id: t,
|
|
1218
1660
|
func: e
|
|
@@ -1228,10 +1670,10 @@ var he = () => {
|
|
|
1228
1670
|
});
|
|
1229
1671
|
}
|
|
1230
1672
|
static {
|
|
1231
|
-
this.getOrCreate = (e, t) => (n, r = "default") =>
|
|
1673
|
+
this.getOrCreate = (e, t) => (n, r = "default") => bt(e, t)(n, r);
|
|
1232
1674
|
}
|
|
1233
1675
|
static get(e = "default") {
|
|
1234
|
-
return Object.prototype.hasOwnProperty.call(
|
|
1676
|
+
return Object.prototype.hasOwnProperty.call(G, e) ? G[e] : null;
|
|
1235
1677
|
}
|
|
1236
1678
|
static getOrThrow(e = "default") {
|
|
1237
1679
|
let n = t.get(e);
|
|
@@ -1240,36 +1682,38 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1240
1682
|
return n;
|
|
1241
1683
|
}
|
|
1242
1684
|
static {
|
|
1243
|
-
this.eventNames =
|
|
1685
|
+
this.eventNames = f;
|
|
1244
1686
|
}
|
|
1245
|
-
_silentLoginCallbackFromIFrame() {
|
|
1687
|
+
_silentLoginCallbackFromIFrame(e = this.tokens, t) {
|
|
1246
1688
|
if (this.configuration.silent_redirect_uri && this.configuration.silent_login_uri) {
|
|
1247
|
-
let
|
|
1689
|
+
let n = this.location, r = V(n.getCurrentHref());
|
|
1248
1690
|
window.parent.postMessage(`${this.configurationName}_oidc_tokens:${JSON.stringify({
|
|
1249
|
-
tokens:
|
|
1250
|
-
|
|
1251
|
-
|
|
1691
|
+
tokens: e,
|
|
1692
|
+
resource: t,
|
|
1693
|
+
sessionState: r.session_state
|
|
1694
|
+
})}`, n.getOrigin());
|
|
1252
1695
|
}
|
|
1253
1696
|
}
|
|
1254
1697
|
_silentLoginErrorCallbackFromIFrame(e = null) {
|
|
1255
1698
|
if (this.configuration.silent_redirect_uri && this.configuration.silent_login_uri) {
|
|
1256
|
-
let t = this.location, n =
|
|
1699
|
+
let t = this.location, n = V(t.getCurrentHref());
|
|
1257
1700
|
if (n.error) {
|
|
1258
|
-
let e =
|
|
1701
|
+
let e = s(n.error, n.error_description, `Error from OIDC server: ${n.error} - ${n.error_description}`, "refresh");
|
|
1259
1702
|
window.parent.postMessage(`${this.configurationName}_oidc_error:${JSON.stringify({
|
|
1260
1703
|
error: n.error,
|
|
1261
1704
|
error_description: n.error_description,
|
|
1262
|
-
oidcError:
|
|
1705
|
+
oidcError: u(e)
|
|
1263
1706
|
})}`, t.getOrigin());
|
|
1264
1707
|
} else window.parent.postMessage(`${this.configurationName}_oidc_exception:${JSON.stringify({
|
|
1265
1708
|
error: e == null ? "" : e.toString(),
|
|
1266
|
-
oidcError:
|
|
1709
|
+
oidcError: i(e) ? u(e) : void 0
|
|
1267
1710
|
})}`, t.getOrigin());
|
|
1268
1711
|
}
|
|
1269
1712
|
}
|
|
1270
1713
|
async silentLoginCallbackAsync() {
|
|
1271
1714
|
try {
|
|
1272
|
-
|
|
1715
|
+
let e = this.configuration.resources?.length ? rt(this.configurationName, this.location.getCurrentHref()) : void 0, t = await this.loginCallbackAsync(!0);
|
|
1716
|
+
this._silentLoginCallbackFromIFrame(t.parsedTokens, e);
|
|
1273
1717
|
} catch (e) {
|
|
1274
1718
|
console.error(e), this._silentLoginErrorCallbackFromIFrame(e);
|
|
1275
1719
|
}
|
|
@@ -1277,7 +1721,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1277
1721
|
async initAsync(e, t) {
|
|
1278
1722
|
if (this.initPromise !== null) return this.initPromise;
|
|
1279
1723
|
let n = async () => {
|
|
1280
|
-
if (t != null) return new
|
|
1724
|
+
if (t != null) return new yt({
|
|
1281
1725
|
authorization_endpoint: t.authorization_endpoint,
|
|
1282
1726
|
end_session_endpoint: t.end_session_endpoint,
|
|
1283
1727
|
revocation_endpoint: t.revocation_endpoint,
|
|
@@ -1296,50 +1740,65 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1296
1740
|
});
|
|
1297
1741
|
}
|
|
1298
1742
|
async tryKeepExistingSessionAsync() {
|
|
1299
|
-
return this.tryKeepExistingSessionPromise === null ? (this.tryKeepExistingSessionPromise =
|
|
1743
|
+
return this.tryKeepExistingSessionPromise === null ? (this.tryKeepExistingSessionPromise = he(this), this.tryKeepExistingSessionPromise.finally(() => {
|
|
1300
1744
|
this.tryKeepExistingSessionPromise = null;
|
|
1301
1745
|
})) : this.tryKeepExistingSessionPromise;
|
|
1302
1746
|
}
|
|
1303
1747
|
async startCheckSessionAsync(e, t, n, r = !1) {
|
|
1304
|
-
await C(this,
|
|
1748
|
+
await C(this, G, this.configuration)(e, t, n, r);
|
|
1305
1749
|
}
|
|
1306
1750
|
async loginAsync(e = void 0, t = null, n = !1, r = void 0, i = !1) {
|
|
1307
|
-
return this.logoutPromise && await this.logoutPromise, this.loginPromise === null ? (this.loginPromise = i ? S(window, this.configurationName, this.configuration, this.publishEvent.bind(this), this)(t, r) :
|
|
1751
|
+
return this.logoutPromise && await this.logoutPromise, this.loginPromise === null ? (this.loginPromise = (async () => (t?._oidc_resource === void 0 && this.configuration.resources?.length && await this.resourceTokens.clearAllAsync(), i ? S(window, this.configurationName, this.configuration, this.publishEvent.bind(this), this)(t, r) : ot(this.configurationName, this.configuration, this.publishEvent.bind(this), this.initAsync.bind(this), this.location, this.getFetch)(e, t, n, r)))(), this.loginPromise.catch((e) => {
|
|
1752
|
+
throw n && this._silentLoginErrorCallbackFromIFrame(e), e;
|
|
1753
|
+
}).finally(() => {
|
|
1308
1754
|
this.loginPromise = null;
|
|
1309
1755
|
})) : this.loginPromise;
|
|
1310
1756
|
}
|
|
1311
|
-
async loginCallbackAsync(
|
|
1757
|
+
async loginCallbackAsync(n = !1) {
|
|
1312
1758
|
if (this.loginCallbackPromise !== null) return this.loginCallbackPromise;
|
|
1313
|
-
let
|
|
1314
|
-
let
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1759
|
+
let i = async () => {
|
|
1760
|
+
let i = this.configuration.resources?.length ? rt(this.configurationName, this.location.getCurrentHref()) : void 0, a = await st(this)(n, i), o = a.tokens;
|
|
1761
|
+
if (i !== void 0) {
|
|
1762
|
+
if (rt(this.configurationName, this.location.getCurrentHref()) !== i) throw new r(e.RESOURCE_TOKEN_UNAVAILABLE, "The resource authorization was cleared.", {
|
|
1763
|
+
phase: "callback",
|
|
1764
|
+
retryable: !1
|
|
1765
|
+
});
|
|
1766
|
+
return await this.resourceTokens.acceptAuthorizationAsync(i, o), it(this.configurationName, this.location.getCurrentHref()), {
|
|
1767
|
+
parsedTokens: o,
|
|
1768
|
+
state: a.state,
|
|
1769
|
+
callbackPath: a.callbackPath,
|
|
1770
|
+
scope: a.scope,
|
|
1771
|
+
extras: a.extras
|
|
1772
|
+
};
|
|
1773
|
+
}
|
|
1774
|
+
return await this.resourceTokens.clearAllAsync(), this.tokens = o, await $(this.configuration, H(this.configurationName, i)) || g(this.configurationName, this.configuration.storage, this.configuration.login_state_storage ?? this.configuration.storage).setTokens(o), this.publishEvent(t.eventNames.token_acquired, o), this.configuration.preload_user_info && await this.userInfoAsync(), {
|
|
1775
|
+
parsedTokens: o,
|
|
1776
|
+
state: a.state,
|
|
1777
|
+
callbackPath: a.callbackPath,
|
|
1778
|
+
scope: a.scope,
|
|
1779
|
+
extras: a.extras
|
|
1321
1780
|
};
|
|
1322
1781
|
};
|
|
1323
|
-
return this.loginCallbackPromise =
|
|
1782
|
+
return this.loginCallbackPromise = i(), this.loginCallbackPromise.finally(() => {
|
|
1324
1783
|
this.loginCallbackPromise = null;
|
|
1325
1784
|
});
|
|
1326
1785
|
}
|
|
1327
1786
|
async generateDemonstrationOfProofOfPossessionAsync(e, t, n, r = {}) {
|
|
1328
|
-
let
|
|
1329
|
-
ath: await
|
|
1787
|
+
let i = this.configuration, a = {
|
|
1788
|
+
ath: await le(e),
|
|
1330
1789
|
...r
|
|
1331
1790
|
};
|
|
1332
|
-
if (await $(
|
|
1333
|
-
let
|
|
1334
|
-
return
|
|
1791
|
+
if (await $(i, this.configurationName)) return `DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${this.configurationName}#tabId=${Ut(this.configurationName)}`;
|
|
1792
|
+
let o = g(this.configurationName, i.storage, i.login_state_storage ?? i.storage), s = await o.getDemonstratingProofOfPossessionJwkAsync(), c = o.getDemonstratingProofOfPossessionNonce();
|
|
1793
|
+
return c && (a.nonce = c), await ne(window)(i.demonstrating_proof_of_possession_configuration)(s, n, t, a);
|
|
1335
1794
|
}
|
|
1336
1795
|
loginCallbackWithAutoTokensRenewAsync() {
|
|
1337
|
-
return this.loginCallbackWithAutoTokensRenewPromise === null ? (this.loginCallbackWithAutoTokensRenewPromise =
|
|
1796
|
+
return this.loginCallbackWithAutoTokensRenewPromise === null ? (this.loginCallbackWithAutoTokensRenewPromise = xt(this), this.loginCallbackWithAutoTokensRenewPromise.finally(() => {
|
|
1338
1797
|
this.loginCallbackWithAutoTokensRenewPromise = null;
|
|
1339
1798
|
})) : this.loginCallbackWithAutoTokensRenewPromise;
|
|
1340
1799
|
}
|
|
1341
1800
|
userInfoAsync(e = !1, t = !1) {
|
|
1342
|
-
return this.userInfoPromise === null ? (this.userInfoPromise =
|
|
1801
|
+
return this.userInfoPromise === null ? (this.userInfoPromise = _t(this)(e, t), this.userInfoPromise.finally(() => {
|
|
1343
1802
|
this.userInfoPromise = null;
|
|
1344
1803
|
})) : this.userInfoPromise;
|
|
1345
1804
|
}
|
|
@@ -1347,7 +1806,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1347
1806
|
if (this.renewTokensPromise !== null) return this.renewTokensPromise;
|
|
1348
1807
|
if (!this.timeoutId) return null;
|
|
1349
1808
|
b.clearTimeout(this.timeoutId);
|
|
1350
|
-
let n =
|
|
1809
|
+
let n = wt(this, !0, e, t);
|
|
1351
1810
|
return this.renewTokensPromise = n, n.finally(() => {
|
|
1352
1811
|
this.renewTokensPromise === n && (this.renewTokensPromise = null);
|
|
1353
1812
|
});
|
|
@@ -1355,67 +1814,67 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1355
1814
|
async renewTokensAsync(e = null, t = null) {
|
|
1356
1815
|
return (await this.renewTokensResultAsync(e, t))?.tokens;
|
|
1357
1816
|
}
|
|
1358
|
-
async renewTokensOrThrowAsync(
|
|
1359
|
-
let
|
|
1360
|
-
if (
|
|
1361
|
-
if (!
|
|
1817
|
+
async renewTokensOrThrowAsync(t = null, n = null) {
|
|
1818
|
+
let i = await this.renewTokensResultAsync(t, n);
|
|
1819
|
+
if (i?.error) throw i.error;
|
|
1820
|
+
if (!i?.tokens) throw new r(e.TOKEN_REQUEST_FAILED, "Token renewal failed", {
|
|
1362
1821
|
phase: "refresh",
|
|
1363
1822
|
retryable: !1
|
|
1364
1823
|
});
|
|
1365
|
-
return
|
|
1824
|
+
return i.tokens;
|
|
1366
1825
|
}
|
|
1367
1826
|
async destroyAsync(e) {
|
|
1368
|
-
return await
|
|
1827
|
+
return await dt(this)(e);
|
|
1369
1828
|
}
|
|
1370
1829
|
async clearSessionAsync() {
|
|
1371
|
-
return this.clearSessionPromise ? this.clearSessionPromise : (this.clearSessionPromise =
|
|
1830
|
+
return this.clearSessionPromise ? this.clearSessionPromise : (this.clearSessionPromise = ft(this, G)(), this.clearSessionPromise.finally(() => {
|
|
1372
1831
|
this.clearSessionPromise = null;
|
|
1373
1832
|
}));
|
|
1374
1833
|
}
|
|
1375
|
-
async logoutSameTabAsync(
|
|
1376
|
-
this.configuration.monitor_session && this.configuration.client_id ===
|
|
1834
|
+
async logoutSameTabAsync(e, t) {
|
|
1835
|
+
this.configuration.monitor_session && this.configuration.client_id === e && t && this.tokens && this.tokens.idTokenPayload && this.tokens.idTokenPayload.sub === t && (await this.destroyAsync("LOGGED_OUT"), this.publishEvent(f.logout_from_same_tab, {
|
|
1377
1836
|
mmessage: "SessionMonitor",
|
|
1378
|
-
sub:
|
|
1837
|
+
sub: t
|
|
1379
1838
|
}));
|
|
1380
1839
|
}
|
|
1381
|
-
async logoutOtherTabAsync(
|
|
1382
|
-
this.configuration.monitor_session && this.configuration.client_id ===
|
|
1840
|
+
async logoutOtherTabAsync(e, t) {
|
|
1841
|
+
this.configuration.monitor_session && this.configuration.client_id === e && t && this.tokens && this.tokens.idTokenPayload && this.tokens.idTokenPayload.sub === t && (await this.destroyAsync("LOGGED_OUT"), this.publishEvent(f.logout_from_another_tab, {
|
|
1383
1842
|
message: "SessionMonitor",
|
|
1384
|
-
sub:
|
|
1843
|
+
sub: t
|
|
1385
1844
|
}));
|
|
1386
1845
|
}
|
|
1387
1846
|
async logoutAsync(e = void 0, t = null) {
|
|
1388
|
-
return this.logoutPromise ? this.logoutPromise : (this.logoutPromise =
|
|
1847
|
+
return this.logoutPromise ? this.logoutPromise : (this.logoutPromise = mt(this, G, this.getFetch(), console, this.location)(e, t), this.logoutPromise.finally(() => {
|
|
1389
1848
|
this.logoutPromise = null;
|
|
1390
1849
|
}));
|
|
1391
1850
|
}
|
|
1392
|
-
},
|
|
1393
|
-
let
|
|
1394
|
-
return new
|
|
1851
|
+
}, St = (t, n) => {
|
|
1852
|
+
let i = n?.oauthError === "use_dpop_nonce" ? e.DPOP_NONCE_REQUIRED : e.TOKEN_REQUEST_FAILED;
|
|
1853
|
+
return new r(i, t, {
|
|
1395
1854
|
phase: "refresh",
|
|
1396
|
-
retryable:
|
|
1397
|
-
status:
|
|
1398
|
-
oauthError:
|
|
1399
|
-
oauthErrorDescription:
|
|
1855
|
+
retryable: i === e.DPOP_NONCE_REQUIRED || a(n?.status),
|
|
1856
|
+
status: n?.status,
|
|
1857
|
+
oauthError: n?.oauthError,
|
|
1858
|
+
oauthErrorDescription: n?.oauthErrorDescription
|
|
1400
1859
|
});
|
|
1401
1860
|
};
|
|
1402
|
-
async function
|
|
1861
|
+
async function Ct(e, t, n, r = null) {
|
|
1403
1862
|
let a = (t) => {
|
|
1404
1863
|
e.tokens = t;
|
|
1405
1864
|
};
|
|
1406
|
-
e.publishEvent(
|
|
1865
|
+
e.publishEvent(K.eventNames.syncTokensAsync_begin, {});
|
|
1407
1866
|
let o;
|
|
1408
1867
|
try {
|
|
1409
|
-
o = await
|
|
1868
|
+
o = await Dt(e)(a, 0, 0, t, n, r);
|
|
1410
1869
|
} catch (t) {
|
|
1411
|
-
throw e.publishEvent(
|
|
1870
|
+
throw e.publishEvent(K.eventNames.syncTokensAsync_error, {
|
|
1412
1871
|
message: "sync tokens error",
|
|
1413
|
-
error:
|
|
1872
|
+
error: i(t) ? t : void 0,
|
|
1414
1873
|
exception: t
|
|
1415
1874
|
}), t;
|
|
1416
1875
|
}
|
|
1417
1876
|
let { tokens: s, status: c } = o;
|
|
1418
|
-
return e.publishEvent(
|
|
1877
|
+
return e.publishEvent(K.eventNames.syncTokensAsync_end, { status: c }), await $(e.configuration, e.configurationName) || g(e.configurationName, e.configuration.storage, e.configuration.login_state_storage ?? e.configuration.storage).setTokens(e.tokens), e.tokens ? {
|
|
1419
1878
|
...o,
|
|
1420
1879
|
tokens: s
|
|
1421
1880
|
} : (await e.destroyAsync(c), {
|
|
@@ -1423,29 +1882,30 @@ async function Ze(e, t, n, r = null) {
|
|
|
1423
1882
|
tokens: null
|
|
1424
1883
|
});
|
|
1425
1884
|
}
|
|
1426
|
-
async function
|
|
1885
|
+
async function wt(e, t = !1, n = null, r = null) {
|
|
1427
1886
|
let i = e.configuration, a = `${i.client_id}_${e.configurationName}_${i.authority}`, o, s = await $(e.configuration, e.configurationName);
|
|
1428
|
-
if (i?.
|
|
1887
|
+
if (i.resources?.length && e.resourceTokens) o = await e.resourceTokens.withRefreshLockAsync(() => Ct(e, t, n, r));
|
|
1888
|
+
else if (i?.storage === window?.sessionStorage && !s || !navigator.locks) o = await Ct(e, t, n, r);
|
|
1429
1889
|
else {
|
|
1430
1890
|
let i = "retry";
|
|
1431
|
-
for (; i === "retry";) i = await navigator.locks.request(a, { ifAvailable: !0 }, async (i) => i ? await
|
|
1891
|
+
for (; i === "retry";) i = await navigator.locks.request(a, { ifAvailable: !0 }, async (i) => i ? await Ct(e, t, n, r) : (e.publishEvent(K.eventNames.syncTokensAsync_lock_not_available, { lock: "lock not available" }), "retry"));
|
|
1432
1892
|
o = i;
|
|
1433
1893
|
}
|
|
1434
|
-
return o.tokens ? (e.timeoutId &&=
|
|
1894
|
+
return o.tokens ? (e.timeoutId &&= q(e, e.tokens.expiresAt, n, r), {
|
|
1435
1895
|
...o,
|
|
1436
1896
|
tokens: e.tokens
|
|
1437
1897
|
}) : o;
|
|
1438
1898
|
}
|
|
1439
|
-
async function
|
|
1440
|
-
return (await
|
|
1899
|
+
async function Tt(e, t = !1, n = null, r = null) {
|
|
1900
|
+
return (await wt(e, t, n, r)).tokens;
|
|
1441
1901
|
}
|
|
1442
|
-
var
|
|
1902
|
+
var q = (e, t, n = null, r = null) => {
|
|
1443
1903
|
let i = e.configuration.refresh_time_before_tokens_expiration_in_second;
|
|
1444
1904
|
return e.timeoutId && b.clearTimeout(e.timeoutId), b.setTimeout(async () => {
|
|
1445
|
-
let a = { timeLeft:
|
|
1446
|
-
e.publishEvent(
|
|
1905
|
+
let a = { timeLeft: X(i, t) };
|
|
1906
|
+
e.publishEvent(K.eventNames.token_timer, a), await Tt(e, !1, n, r);
|
|
1447
1907
|
}, 1e3);
|
|
1448
|
-
},
|
|
1908
|
+
}, J = {
|
|
1449
1909
|
FORCE_REFRESH: "FORCE_REFRESH",
|
|
1450
1910
|
SESSION_LOST: "SESSION_LOST",
|
|
1451
1911
|
NOT_CONNECTED: "NOT_CONNECTED",
|
|
@@ -1455,297 +1915,297 @@ var W = (e, t, n = null, r = null) => {
|
|
|
1455
1915
|
LOGOUT_FROM_ANOTHER_TAB: "LOGOUT_FROM_ANOTHER_TAB",
|
|
1456
1916
|
REQUIRE_SYNC_TOKENS: "REQUIRE_SYNC_TOKENS",
|
|
1457
1917
|
TOKENS_INVALID: "TOKENS_INVALID"
|
|
1458
|
-
},
|
|
1459
|
-
let
|
|
1918
|
+
}, Et = (e) => async (t, n, r, i = !1) => {
|
|
1919
|
+
let a = { nonce: null };
|
|
1460
1920
|
if (!r) return {
|
|
1461
1921
|
tokens: null,
|
|
1462
|
-
status:
|
|
1463
|
-
nonce:
|
|
1922
|
+
status: J.NOT_CONNECTED,
|
|
1923
|
+
nonce: a
|
|
1464
1924
|
};
|
|
1465
|
-
let
|
|
1466
|
-
if (
|
|
1467
|
-
let { status: e, tokens: n } = await
|
|
1925
|
+
let o, s = await e.initAsync(t.authority, t.authority_configuration), c = await $(t, n);
|
|
1926
|
+
if (c) {
|
|
1927
|
+
let { status: e, tokens: n } = await c.initAsync(s, "syncTokensAsync", t);
|
|
1468
1928
|
if (e === "LOGGED_OUT") return {
|
|
1469
1929
|
tokens: null,
|
|
1470
|
-
status:
|
|
1471
|
-
nonce:
|
|
1930
|
+
status: J.LOGOUT_FROM_ANOTHER_TAB,
|
|
1931
|
+
nonce: a
|
|
1472
1932
|
};
|
|
1473
1933
|
if (e === "SESSIONS_LOST") return {
|
|
1474
1934
|
tokens: null,
|
|
1475
|
-
status:
|
|
1476
|
-
nonce:
|
|
1935
|
+
status: J.SESSION_LOST,
|
|
1936
|
+
nonce: a
|
|
1477
1937
|
};
|
|
1478
1938
|
if (!e || !n) return {
|
|
1479
1939
|
tokens: null,
|
|
1480
|
-
status:
|
|
1481
|
-
nonce:
|
|
1940
|
+
status: J.REQUIRE_SYNC_TOKENS,
|
|
1941
|
+
nonce: a
|
|
1482
1942
|
};
|
|
1483
1943
|
if (n.issuedAt !== r.issuedAt) return {
|
|
1484
1944
|
tokens: n,
|
|
1485
|
-
status:
|
|
1486
|
-
nonce: await
|
|
1945
|
+
status: X(t.refresh_time_before_tokens_expiration_in_second, n.expiresAt) > 0 ? J.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID : J.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID,
|
|
1946
|
+
nonce: await c.getNonceAsync()
|
|
1487
1947
|
};
|
|
1488
|
-
|
|
1948
|
+
o = await c.getNonceAsync();
|
|
1489
1949
|
} else {
|
|
1490
|
-
let
|
|
1491
|
-
if (
|
|
1950
|
+
let i = g(n, t.storage ?? sessionStorage, t.login_state_storage ?? t.storage ?? sessionStorage), s = await i.initAsync(), { tokens: c } = s, { status: l } = s;
|
|
1951
|
+
if (c &&= Mt(c, e.tokens, t.token_renew_mode), !c) return {
|
|
1492
1952
|
tokens: null,
|
|
1493
|
-
status:
|
|
1494
|
-
nonce:
|
|
1953
|
+
status: J.LOGOUT_FROM_ANOTHER_TAB,
|
|
1954
|
+
nonce: a
|
|
1495
1955
|
};
|
|
1496
|
-
if (
|
|
1956
|
+
if (l === "SESSIONS_LOST") return {
|
|
1497
1957
|
tokens: null,
|
|
1498
|
-
status:
|
|
1499
|
-
nonce:
|
|
1958
|
+
status: J.SESSION_LOST,
|
|
1959
|
+
nonce: a
|
|
1500
1960
|
};
|
|
1501
|
-
if (
|
|
1502
|
-
let e =
|
|
1961
|
+
if (c.issuedAt !== r.issuedAt) {
|
|
1962
|
+
let e = X(t.refresh_time_before_tokens_expiration_in_second, c.expiresAt) > 0 ? J.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID : J.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID, n = await i.getNonceAsync();
|
|
1503
1963
|
return {
|
|
1504
|
-
tokens:
|
|
1964
|
+
tokens: c,
|
|
1505
1965
|
status: e,
|
|
1506
1966
|
nonce: n
|
|
1507
1967
|
};
|
|
1508
1968
|
}
|
|
1509
|
-
|
|
1969
|
+
o = await i.getNonceAsync();
|
|
1510
1970
|
}
|
|
1511
|
-
let
|
|
1512
|
-
return
|
|
1971
|
+
let l = X(t.refresh_time_before_tokens_expiration_in_second, r.expiresAt) > 0 ? "TOKENS_VALID" : "TOKENS_INVALID";
|
|
1972
|
+
return i ? {
|
|
1513
1973
|
tokens: r,
|
|
1514
1974
|
status: "FORCE_REFRESH",
|
|
1515
|
-
nonce:
|
|
1975
|
+
nonce: o
|
|
1516
1976
|
} : {
|
|
1517
1977
|
tokens: r,
|
|
1518
|
-
status:
|
|
1519
|
-
nonce:
|
|
1978
|
+
status: l,
|
|
1979
|
+
nonce: o
|
|
1520
1980
|
};
|
|
1521
|
-
},
|
|
1981
|
+
}, Dt = (t) => async (n, a = 0, o = 0, s = !1, u = null, d = null, p = null) => {
|
|
1522
1982
|
if (!navigator.onLine && document.hidden) return {
|
|
1523
1983
|
tokens: t.tokens,
|
|
1524
1984
|
status: "GIVE_UP"
|
|
1525
1985
|
};
|
|
1526
|
-
let
|
|
1527
|
-
for (; !navigator.onLine &&
|
|
1528
|
-
let
|
|
1529
|
-
if (
|
|
1986
|
+
let m = 6, h = s ? 2 : 5;
|
|
1987
|
+
for (; !navigator.onLine && m > 0;) await Bt({ milliseconds: 1e3 }), m--, t.publishEvent(f.refreshTokensAsync, { message: `wait because navigator is offline try ${m}` });
|
|
1988
|
+
let _ = document.hidden, v = _ ? a : a + 1, y = _ ? o + 1 : o;
|
|
1989
|
+
if (a >= h || o >= 5) {
|
|
1530
1990
|
n(null);
|
|
1531
|
-
let
|
|
1532
|
-
return t.publishEvent(
|
|
1991
|
+
let e = p ?? St("refresh token");
|
|
1992
|
+
return t.publishEvent(f.refreshTokensAsync_error, {
|
|
1533
1993
|
message: "refresh token",
|
|
1534
|
-
error:
|
|
1994
|
+
error: e
|
|
1535
1995
|
}), {
|
|
1536
1996
|
tokens: null,
|
|
1537
1997
|
status: "SESSION_LOST",
|
|
1538
|
-
error:
|
|
1998
|
+
error: e
|
|
1539
1999
|
};
|
|
1540
2000
|
}
|
|
1541
|
-
|
|
2001
|
+
u ||= {};
|
|
1542
2002
|
let b = t.configuration, S = (e, n = null, r = null) => x(t.configurationName, t.configuration, t.publishEvent.bind(t), "refresh")(e, n, r), C = async () => {
|
|
1543
2003
|
try {
|
|
1544
|
-
let
|
|
1545
|
-
|
|
2004
|
+
let i, a = await $(b, t.configurationName);
|
|
2005
|
+
i = a ? a.getLoginParams() : g(t.configurationName, b.storage, b.login_state_storage ?? b.storage).getLoginParams();
|
|
1546
2006
|
let o = {};
|
|
1547
|
-
if (
|
|
1548
|
-
if (
|
|
1549
|
-
o.prompt = "none",
|
|
1550
|
-
let
|
|
1551
|
-
if (!
|
|
2007
|
+
if (i && i.extras) for (let [e, t] of Object.entries(i.extras)) t != null && (o[e] = t);
|
|
2008
|
+
if (u) for (let [e, t] of Object.entries(u)) t != null && (o[e] = t);
|
|
2009
|
+
o.prompt = "none", d && (o.scope = d);
|
|
2010
|
+
let s = await S(o);
|
|
2011
|
+
if (!s) {
|
|
1552
2012
|
n(null);
|
|
1553
|
-
let
|
|
1554
|
-
return t.publishEvent(
|
|
2013
|
+
let e = St("refresh token silent not active");
|
|
2014
|
+
return t.publishEvent(f.refreshTokensAsync_error, {
|
|
1555
2015
|
message: "refresh token silent not active",
|
|
1556
|
-
error:
|
|
2016
|
+
error: e
|
|
1557
2017
|
}), {
|
|
1558
2018
|
tokens: null,
|
|
1559
2019
|
status: "SESSION_LOST",
|
|
1560
|
-
error:
|
|
2020
|
+
error: e
|
|
1561
2021
|
};
|
|
1562
2022
|
}
|
|
1563
|
-
if (
|
|
2023
|
+
if (s.error) {
|
|
1564
2024
|
n(null);
|
|
1565
|
-
let
|
|
2025
|
+
let i = s.oidcError ?? new r(e.OAUTH_ERROR, "refresh token silent", {
|
|
1566
2026
|
phase: "refresh",
|
|
1567
2027
|
retryable: !1,
|
|
1568
|
-
oauthError:
|
|
2028
|
+
oauthError: s.error
|
|
1569
2029
|
});
|
|
1570
|
-
return t.publishEvent(
|
|
2030
|
+
return t.publishEvent(f.refreshTokensAsync_error, {
|
|
1571
2031
|
message: "refresh token silent",
|
|
1572
|
-
error:
|
|
2032
|
+
error: i
|
|
1573
2033
|
}), {
|
|
1574
2034
|
tokens: null,
|
|
1575
2035
|
status: "SESSION_LOST",
|
|
1576
|
-
error:
|
|
2036
|
+
error: i
|
|
1577
2037
|
};
|
|
1578
2038
|
}
|
|
1579
|
-
return n(
|
|
1580
|
-
tokens:
|
|
2039
|
+
return n(s.tokens), t.publishEvent(K.eventNames.token_renewed, {}), {
|
|
2040
|
+
tokens: s.tokens,
|
|
1581
2041
|
status: "LOGGED"
|
|
1582
2042
|
};
|
|
1583
|
-
} catch (
|
|
1584
|
-
let
|
|
1585
|
-
return console.error(
|
|
2043
|
+
} catch (e) {
|
|
2044
|
+
let r = i(e) || !l(e) ? e : c(e, "refresh");
|
|
2045
|
+
return console.error(r), t.publishEvent(f.refreshTokensAsync_silent_error, {
|
|
1586
2046
|
message: "exceptionSilent",
|
|
1587
|
-
exception:
|
|
1588
|
-
error:
|
|
1589
|
-
}), await
|
|
2047
|
+
exception: r.message,
|
|
2048
|
+
error: i(r) ? r : void 0
|
|
2049
|
+
}), await Dt(t)(n, v, y, s, u, d, i(r) ? r : p);
|
|
1590
2050
|
}
|
|
1591
2051
|
};
|
|
1592
2052
|
try {
|
|
1593
|
-
let { status:
|
|
1594
|
-
switch (
|
|
1595
|
-
case
|
|
2053
|
+
let { status: i, tokens: c, nonce: l } = await Et(t)(b, t.configurationName, t.tokens, s);
|
|
2054
|
+
switch (i) {
|
|
2055
|
+
case J.SESSION_LOST:
|
|
1596
2056
|
n(null);
|
|
1597
2057
|
{
|
|
1598
|
-
let
|
|
1599
|
-
return t.publishEvent(
|
|
2058
|
+
let e = p ?? St("refresh token session lost");
|
|
2059
|
+
return t.publishEvent(f.refreshTokensAsync_error, {
|
|
1600
2060
|
message: "refresh token session lost",
|
|
1601
|
-
error:
|
|
2061
|
+
error: e
|
|
1602
2062
|
}), {
|
|
1603
2063
|
tokens: null,
|
|
1604
2064
|
status: "SESSION_LOST",
|
|
1605
|
-
error:
|
|
2065
|
+
error: e
|
|
1606
2066
|
};
|
|
1607
2067
|
}
|
|
1608
|
-
case
|
|
2068
|
+
case J.NOT_CONNECTED: return n(null), {
|
|
1609
2069
|
tokens: null,
|
|
1610
2070
|
status: null
|
|
1611
2071
|
};
|
|
1612
|
-
case
|
|
1613
|
-
tokens:
|
|
2072
|
+
case J.TOKENS_VALID: return n(c), {
|
|
2073
|
+
tokens: c,
|
|
1614
2074
|
status: "LOGGED_IN"
|
|
1615
2075
|
};
|
|
1616
|
-
case
|
|
1617
|
-
tokens:
|
|
2076
|
+
case J.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID: return n(c), t.publishEvent(K.eventNames.token_renewed, { reason: "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID" }), {
|
|
2077
|
+
tokens: c,
|
|
1618
2078
|
status: "LOGGED_IN"
|
|
1619
2079
|
};
|
|
1620
|
-
case
|
|
2080
|
+
case J.LOGOUT_FROM_ANOTHER_TAB: return n(null), t.publishEvent(f.logout_from_another_tab, { status: "session syncTokensAsync" }), {
|
|
1621
2081
|
tokens: null,
|
|
1622
2082
|
status: "LOGGED_OUT"
|
|
1623
2083
|
};
|
|
1624
|
-
case
|
|
2084
|
+
case J.REQUIRE_SYNC_TOKENS: return b.token_automatic_renew_mode == W.AutomaticOnlyWhenFetchExecuted && !s ? (t.publishEvent(f.tokensInvalidAndWaitingActionsToRefresh, {}), {
|
|
1625
2085
|
tokens: t.tokens,
|
|
1626
2086
|
status: "GIVE_UP"
|
|
1627
|
-
}) : (t.publishEvent(
|
|
2087
|
+
}) : (t.publishEvent(f.refreshTokensAsync_begin, { tryNumber: a }), await C());
|
|
1628
2088
|
default: {
|
|
1629
|
-
if (b.token_automatic_renew_mode ==
|
|
2089
|
+
if (b.token_automatic_renew_mode == W.AutomaticOnlyWhenFetchExecuted && J.FORCE_REFRESH !== i) return t.publishEvent(f.tokensInvalidAndWaitingActionsToRefresh, {}), {
|
|
1630
2090
|
tokens: t.tokens,
|
|
1631
2091
|
status: "GIVE_UP"
|
|
1632
2092
|
};
|
|
1633
|
-
if (t.publishEvent(
|
|
1634
|
-
refreshToken:
|
|
1635
|
-
status:
|
|
1636
|
-
tryNumber:
|
|
1637
|
-
backgroundTry:
|
|
1638
|
-
}), !
|
|
1639
|
-
let
|
|
1640
|
-
for (let [e, t] of Object.entries(
|
|
2093
|
+
if (t.publishEvent(f.refreshTokensAsync_begin, {
|
|
2094
|
+
refreshToken: c.refreshToken,
|
|
2095
|
+
status: i,
|
|
2096
|
+
tryNumber: a,
|
|
2097
|
+
backgroundTry: o
|
|
2098
|
+
}), !c.refreshToken) return await C();
|
|
2099
|
+
let p = b.client_id, m = b.redirect_uri, h = b.authority, _ = { ...b.token_request_extras ? b.token_request_extras : {} };
|
|
2100
|
+
for (let [e, t] of Object.entries(u)) e.endsWith(":token_request") && (_[e.replace(":token_request", "")] = t);
|
|
1641
2101
|
return await (async () => {
|
|
1642
|
-
let
|
|
1643
|
-
client_id:
|
|
1644
|
-
redirect_uri:
|
|
2102
|
+
let i = tt({
|
|
2103
|
+
client_id: p,
|
|
2104
|
+
redirect_uri: m,
|
|
1645
2105
|
grant_type: "refresh_token",
|
|
1646
|
-
refresh_token:
|
|
1647
|
-
}, a = await t.initAsync(
|
|
1648
|
-
b.demonstrating_proof_of_possession && (S.DPoP = await t.generateDemonstrationOfProofOfPossessionAsync(
|
|
1649
|
-
let C = await
|
|
2106
|
+
refresh_token: c.refreshToken
|
|
2107
|
+
}, b), a = await t.initAsync(h, b.authority_configuration), o = document.hidden ? 1e4 : 3e5, x = a.tokenEndpoint, S = {};
|
|
2108
|
+
b.demonstrating_proof_of_possession && (S.DPoP = await t.generateDemonstrationOfProofOfPossessionAsync(c.accessToken, x, "POST"));
|
|
2109
|
+
let C = await ke(t.getFetch())(x, i, tt(_, b), c, S, b.token_renew_mode, o);
|
|
1650
2110
|
if (!C.success && C.oauthError === "use_dpop_nonce" && C.demonstratingProofOfPossessionNonce && b.demonstrating_proof_of_possession) {
|
|
1651
2111
|
let e = await $(b, t.configurationName);
|
|
1652
|
-
e ? await e.setDemonstratingProofOfPossessionNonce(C.demonstratingProofOfPossessionNonce) : await
|
|
2112
|
+
e ? await e.setDemonstratingProofOfPossessionNonce(C.demonstratingProofOfPossessionNonce) : await g(t.configurationName, b.storage, b.login_state_storage ?? b.storage).setDemonstratingProofOfPossessionNonce(C.demonstratingProofOfPossessionNonce), S.DPoP = await t.generateDemonstrationOfProofOfPossessionAsync(c.accessToken, x, "POST"), C = await ke(t.getFetch())(x, i, _, c, S, b.token_renew_mode, o);
|
|
1653
2113
|
}
|
|
1654
2114
|
if (C.success) {
|
|
1655
|
-
if (!
|
|
2115
|
+
if (!l || !l.nonce) {
|
|
1656
2116
|
n(null);
|
|
1657
|
-
let
|
|
1658
|
-
return t.publishEvent(
|
|
2117
|
+
let e = new P(N.NONCE_MISSING, "refresh token: nonce missing from storage", "refresh");
|
|
2118
|
+
return t.publishEvent(f.refreshTokensAsync_error, {
|
|
1659
2119
|
message: "refresh token: nonce missing from storage",
|
|
1660
|
-
error:
|
|
2120
|
+
error: e
|
|
1661
2121
|
}), {
|
|
1662
2122
|
tokens: null,
|
|
1663
2123
|
status: "SESSION_LOST",
|
|
1664
|
-
error:
|
|
2124
|
+
error: e
|
|
1665
2125
|
};
|
|
1666
2126
|
}
|
|
1667
|
-
let { isValid:
|
|
1668
|
-
if (!
|
|
2127
|
+
let { isValid: i, reason: o } = It(C.data, l.nonce, a);
|
|
2128
|
+
if (!i) {
|
|
1669
2129
|
n(null);
|
|
1670
|
-
let
|
|
2130
|
+
let i = new r(o.startsWith("Nonce does not match") ? e.INVALID_NONCE : e.TOKEN_REQUEST_FAILED, `refresh token return not valid tokens, reason: ${o}`, {
|
|
1671
2131
|
phase: "refresh",
|
|
1672
2132
|
retryable: !1
|
|
1673
2133
|
});
|
|
1674
|
-
return t.publishEvent(
|
|
2134
|
+
return t.publishEvent(f.refreshTokensAsync_error, {
|
|
1675
2135
|
message: `refresh token return not valid tokens, reason: ${o}`,
|
|
1676
|
-
error:
|
|
2136
|
+
error: i
|
|
1677
2137
|
}), {
|
|
1678
2138
|
tokens: null,
|
|
1679
2139
|
status: "SESSION_LOST",
|
|
1680
|
-
error:
|
|
2140
|
+
error: i
|
|
1681
2141
|
};
|
|
1682
2142
|
}
|
|
1683
2143
|
if (n(C.data), C.demonstratingProofOfPossessionNonce) {
|
|
1684
2144
|
let e = await $(b, t.configurationName);
|
|
1685
|
-
e ? await e.setDemonstratingProofOfPossessionNonce(C.demonstratingProofOfPossessionNonce) : await
|
|
2145
|
+
e ? await e.setDemonstratingProofOfPossessionNonce(C.demonstratingProofOfPossessionNonce) : await g(t.configurationName, b.storage, b.login_state_storage ?? b.storage).setDemonstratingProofOfPossessionNonce(C.demonstratingProofOfPossessionNonce);
|
|
1686
2146
|
}
|
|
1687
|
-
return t.publishEvent(
|
|
2147
|
+
return t.publishEvent(f.refreshTokensAsync_end, { success: C.success }), t.publishEvent(K.eventNames.token_renewed, { reason: "REFRESH_TOKEN" }), {
|
|
1688
2148
|
tokens: C.data,
|
|
1689
2149
|
status: "LOGGED_IN"
|
|
1690
2150
|
};
|
|
1691
2151
|
}
|
|
1692
2152
|
{
|
|
1693
|
-
let
|
|
1694
|
-
return t.publishEvent(
|
|
2153
|
+
let e = St("Token request failed", C);
|
|
2154
|
+
return t.publishEvent(f.refreshTokensAsync_silent_error, {
|
|
1695
2155
|
message: "bad request",
|
|
1696
2156
|
tokenResponse: C,
|
|
1697
|
-
error:
|
|
1698
|
-
}), C.status >= 400 && C.status < 500 ? (n(null), t.publishEvent(
|
|
2157
|
+
error: e
|
|
2158
|
+
}), C.status >= 400 && C.status < 500 ? (n(null), t.publishEvent(f.refreshTokensAsync_error, {
|
|
1699
2159
|
message: `session lost: ${C.status}`,
|
|
1700
|
-
error:
|
|
2160
|
+
error: e
|
|
1701
2161
|
}), {
|
|
1702
2162
|
tokens: null,
|
|
1703
2163
|
status: "SESSION_LOST",
|
|
1704
|
-
error:
|
|
1705
|
-
}) : await
|
|
2164
|
+
error: e
|
|
2165
|
+
}) : await Dt(t)(n, v, y, s, u, d, e);
|
|
1706
2166
|
}
|
|
1707
2167
|
})();
|
|
1708
2168
|
}
|
|
1709
2169
|
}
|
|
1710
|
-
} catch (
|
|
1711
|
-
let
|
|
1712
|
-
return console.error(
|
|
2170
|
+
} catch (e) {
|
|
2171
|
+
let r = i(e) || !l(e) ? e : c(e, "refresh");
|
|
2172
|
+
return console.error(r), t.publishEvent(f.refreshTokensAsync_silent_error, {
|
|
1713
2173
|
message: "exception",
|
|
1714
|
-
exception:
|
|
1715
|
-
error:
|
|
1716
|
-
}), new Promise((e,
|
|
2174
|
+
exception: r.message,
|
|
2175
|
+
error: i(r) ? r : void 0
|
|
2176
|
+
}), new Promise((e, a) => {
|
|
1717
2177
|
setTimeout(() => {
|
|
1718
|
-
|
|
2178
|
+
Dt(t)(n, v, y, s, u, d, i(r) ? r : p).then(e).catch(a);
|
|
1719
2179
|
}, 1e3);
|
|
1720
2180
|
});
|
|
1721
2181
|
}
|
|
1722
|
-
},
|
|
2182
|
+
}, Ot = (e) => decodeURIComponent(Array.prototype.map.call(atob(e), (e) => "%" + ("00" + e.charCodeAt(0).toString(16)).slice(-2)).join("")), kt = (e) => JSON.parse(Ot(e.replaceAll(/-/g, "+").replaceAll(/_/g, "/"))), At = (e) => {
|
|
1723
2183
|
try {
|
|
1724
2184
|
if (!e) return null;
|
|
1725
2185
|
let t = e.split(".");
|
|
1726
|
-
return t.length === 3 ?
|
|
2186
|
+
return t.length === 3 ? kt(t[1]) : null;
|
|
1727
2187
|
} catch (e) {
|
|
1728
2188
|
console.warn(e);
|
|
1729
2189
|
}
|
|
1730
2190
|
return null;
|
|
1731
|
-
},
|
|
2191
|
+
}, Y = {
|
|
1732
2192
|
access_token_or_id_token_invalid: "access_token_or_id_token_invalid",
|
|
1733
2193
|
access_token_invalid: "access_token_invalid",
|
|
1734
2194
|
id_token_invalid: "id_token_invalid"
|
|
1735
2195
|
};
|
|
1736
|
-
function
|
|
2196
|
+
function jt(e, t, n) {
|
|
1737
2197
|
return e.issuedAt ? typeof e.issuedAt == "string" ? parseInt(e.issuedAt, 10) : e.issuedAt : t && t.iat ? t.iat : n && n.iat ? n.iat : (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
1738
2198
|
}
|
|
1739
|
-
var
|
|
2199
|
+
var Mt = (e, t = null, n) => {
|
|
1740
2200
|
if (!e) return null;
|
|
1741
2201
|
let r, i = typeof e.expiresIn == "string" ? parseInt(e.expiresIn, 10) : e.expiresIn;
|
|
1742
|
-
r = e.accessTokenPayload === void 0 ?
|
|
2202
|
+
r = e.accessTokenPayload === void 0 ? At(e.accessToken) : e.accessTokenPayload;
|
|
1743
2203
|
let a;
|
|
1744
2204
|
a = t != null && "idToken" in t && !("idToken" in e) ? t.idToken : e.idToken;
|
|
1745
|
-
let o = e.idTokenPayload ? e.idTokenPayload :
|
|
1746
|
-
e.issuedAt =
|
|
2205
|
+
let o = e.idTokenPayload ? e.idTokenPayload : At(a), s = o && o.exp ? o.exp : Number.MAX_VALUE, c = r && r.exp ? r.exp : e.issuedAt + i;
|
|
2206
|
+
e.issuedAt = jt(e, r, o);
|
|
1747
2207
|
let l;
|
|
1748
|
-
l = e.expiresAt ? e.expiresAt : n ===
|
|
2208
|
+
l = e.expiresAt ? e.expiresAt : n === Y.access_token_invalid ? c : n === Y.id_token_invalid || s < c ? s : c;
|
|
1749
2209
|
let u = {
|
|
1750
2210
|
...e,
|
|
1751
2211
|
idTokenPayload: o,
|
|
@@ -1761,40 +2221,40 @@ var at = (e, t = null, n) => {
|
|
|
1761
2221
|
};
|
|
1762
2222
|
}
|
|
1763
2223
|
return u;
|
|
1764
|
-
},
|
|
2224
|
+
}, Nt = (e, t, n) => {
|
|
1765
2225
|
if (!e) return null;
|
|
1766
2226
|
e.issued_at ||= (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
1767
2227
|
let r = {
|
|
1768
2228
|
accessToken: e.access_token,
|
|
1769
2229
|
expiresIn: e.expires_in,
|
|
1770
2230
|
idToken: e.id_token,
|
|
1771
|
-
scope: e.scope,
|
|
2231
|
+
scope: e.scope ?? t?.scope,
|
|
1772
2232
|
tokenType: e.token_type,
|
|
1773
2233
|
issuedAt: e.issued_at
|
|
1774
2234
|
};
|
|
1775
|
-
return "refresh_token" in e && (r.refreshToken = e.refresh_token), e.accessTokenPayload !== void 0 && (r.accessTokenPayload = e.accessTokenPayload), e.idTokenPayload !== void 0 && (r.idTokenPayload = e.idTokenPayload),
|
|
1776
|
-
},
|
|
2235
|
+
return e.resourceContext !== void 0 && Object.assign(r, { resourceContext: e.resourceContext }), "refresh_token" in e && (r.refreshToken = e.refresh_token), e.accessTokenPayload !== void 0 && (r.accessTokenPayload = e.accessTokenPayload), e.idTokenPayload !== void 0 && (r.idTokenPayload = e.idTokenPayload), Mt(r, t, n);
|
|
2236
|
+
}, X = (e, t) => {
|
|
1777
2237
|
let n = t - (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
1778
2238
|
return Math.round(n - e);
|
|
1779
|
-
},
|
|
2239
|
+
}, Pt = (e, t = 0) => e ? X(t, e.expiresAt) > 0 : !1, Ft = async (e, t = 200, n = 50) => {
|
|
1780
2240
|
let r = n, i = await e.syncTokensInfoAsync();
|
|
1781
2241
|
for (; [
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
2242
|
+
J.REQUIRE_SYNC_TOKENS,
|
|
2243
|
+
J.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID,
|
|
2244
|
+
J.TOKENS_INVALID
|
|
1785
2245
|
].includes(i) && r > 0;) {
|
|
1786
|
-
if (e.configuration.token_automatic_renew_mode ==
|
|
2246
|
+
if (e.configuration.token_automatic_renew_mode == W.AutomaticOnlyWhenFetchExecuted) {
|
|
1787
2247
|
await e.renewTokensAsync({});
|
|
1788
2248
|
break;
|
|
1789
2249
|
}
|
|
1790
|
-
await
|
|
2250
|
+
await Bt({ milliseconds: t }), --r, i = await e.syncTokensInfoAsync();
|
|
1791
2251
|
}
|
|
1792
2252
|
return {
|
|
1793
|
-
isTokensValid:
|
|
2253
|
+
isTokensValid: Pt(e.getTokens()),
|
|
1794
2254
|
tokens: e.getTokens(),
|
|
1795
2255
|
numberWaited: r - n
|
|
1796
2256
|
};
|
|
1797
|
-
},
|
|
2257
|
+
}, It = (e, t, n) => {
|
|
1798
2258
|
if (e.idTokenPayload) {
|
|
1799
2259
|
let r = e.idTokenPayload;
|
|
1800
2260
|
if (n.issuer !== r.iss) return {
|
|
@@ -1820,25 +2280,26 @@ var at = (e, t = null, n) => {
|
|
|
1820
2280
|
isValid: !0,
|
|
1821
2281
|
reason: ""
|
|
1822
2282
|
};
|
|
1823
|
-
},
|
|
2283
|
+
}, Lt = "7.30.1", Rt = null, zt, Bt = ({ milliseconds: e }) => new Promise((t) => b.setTimeout(t, e)), Vt = (e = "/") => {
|
|
1824
2284
|
try {
|
|
1825
|
-
|
|
2285
|
+
zt = new AbortController(), fetch(`${e}OidcKeepAliveServiceWorker.json?minSleepSeconds=150`, { signal: zt.signal }).catch((e) => {
|
|
1826
2286
|
console.log(e);
|
|
1827
|
-
}),
|
|
2287
|
+
}), Bt({ milliseconds: 15e4 }).then(() => Vt(e));
|
|
1828
2288
|
} catch (e) {
|
|
1829
2289
|
console.log(e);
|
|
1830
2290
|
}
|
|
1831
|
-
},
|
|
1832
|
-
|
|
1833
|
-
},
|
|
2291
|
+
}, Ht = () => {
|
|
2292
|
+
zt && zt.abort();
|
|
2293
|
+
}, Ut = (e) => {
|
|
2294
|
+
Pe(e) !== void 0 && (e = e.split("#resource=")[0]);
|
|
1834
2295
|
let t = `oidc.tabId.${e}`, n = sessionStorage.getItem(t);
|
|
1835
2296
|
if (n) return n;
|
|
1836
2297
|
let r = globalThis.crypto.randomUUID();
|
|
1837
2298
|
return sessionStorage.setItem(t, r), r;
|
|
1838
|
-
},
|
|
2299
|
+
}, Wt = (e) => navigator.serviceWorker.controller ?? e.active ?? e.waiting ?? e.installing ?? null, Z = (e, t) => (n) => {
|
|
1839
2300
|
let r = t?.timeoutMs ?? 5e3;
|
|
1840
2301
|
return new Promise((t, i) => {
|
|
1841
|
-
let a =
|
|
2302
|
+
let a = Wt(e);
|
|
1842
2303
|
if (!a) {
|
|
1843
2304
|
i(/* @__PURE__ */ Error("Service worker target not available (controller/active/waiting/installing missing)"));
|
|
1844
2305
|
return;
|
|
@@ -1859,51 +2320,57 @@ var at = (e, t = null, n) => {
|
|
|
1859
2320
|
let e = n?.configurationName;
|
|
1860
2321
|
a.postMessage({
|
|
1861
2322
|
...n,
|
|
1862
|
-
tabId:
|
|
2323
|
+
tabId: Ut(e ?? "default")
|
|
1863
2324
|
}, [o.port2]);
|
|
1864
2325
|
} catch (e) {
|
|
1865
2326
|
c(), i(e);
|
|
1866
2327
|
}
|
|
1867
2328
|
});
|
|
1868
|
-
},
|
|
2329
|
+
}, Gt = async (e) => navigator.serviceWorker.controller ? navigator.serviceWorker.controller : new Promise((t) => {
|
|
1869
2330
|
let n = !1, r = () => {
|
|
1870
2331
|
n || (n = !0, navigator.serviceWorker.removeEventListener("controllerchange", r), t(navigator.serviceWorker.controller ?? null));
|
|
1871
2332
|
};
|
|
1872
2333
|
navigator.serviceWorker.addEventListener("controllerchange", r), b.setTimeout(() => {
|
|
1873
2334
|
n || (n = !0, navigator.serviceWorker.removeEventListener("controllerchange", r), t(navigator.serviceWorker.controller ?? null));
|
|
1874
2335
|
}, e);
|
|
1875
|
-
}),
|
|
2336
|
+
}), Kt = !1, Q = !1, qt = /* @__PURE__ */ new Map(), Jt = (e) => e instanceof DOMException ? e.name === "AbortError" : e?.name === "AbortError", Yt = "oidc.sw.controllerchange_reload_count", Xt = 3, Zt = () => {
|
|
1876
2337
|
try {
|
|
1877
|
-
return parseInt(sessionStorage.getItem(
|
|
2338
|
+
return parseInt(sessionStorage.getItem(Yt) ?? "0", 10);
|
|
1878
2339
|
} catch {
|
|
1879
2340
|
return 0;
|
|
1880
2341
|
}
|
|
1881
|
-
},
|
|
1882
|
-
let e =
|
|
2342
|
+
}, Qt = () => {
|
|
2343
|
+
let e = Zt() + 1;
|
|
1883
2344
|
try {
|
|
1884
|
-
sessionStorage.setItem(
|
|
2345
|
+
sessionStorage.setItem(Yt, String(e));
|
|
1885
2346
|
} catch {}
|
|
1886
2347
|
return e;
|
|
1887
|
-
},
|
|
2348
|
+
}, $t = () => {
|
|
1888
2349
|
try {
|
|
1889
|
-
sessionStorage.removeItem(
|
|
2350
|
+
sessionStorage.removeItem(Yt);
|
|
1890
2351
|
} catch {}
|
|
1891
|
-
}, $ = async (
|
|
1892
|
-
let n =
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
2352
|
+
}, $ = async (t, n) => {
|
|
2353
|
+
let i = t.service_worker_relative_url, a = Pe(n), o = n.split("#resource=")[0], s = () => {
|
|
2354
|
+
if (a !== void 0 && i) throw new r(e.RESOURCE_WORKER_UNSUPPORTED, "Resource token isolation requires an available, compatible Service Worker.", {
|
|
2355
|
+
phase: "refresh",
|
|
2356
|
+
retryable: !1
|
|
2357
|
+
});
|
|
2358
|
+
return null;
|
|
2359
|
+
};
|
|
2360
|
+
if (typeof window > "u" || typeof navigator > "u" || !navigator.serviceWorker || !i || t.service_worker_activate() === !1) return s();
|
|
2361
|
+
let c = `${i}${i.includes("?") ? "&" : "?"}v=${Lt}`, l = t.service_worker_register ? i : c;
|
|
2362
|
+
qt.has(l) || qt.set(l, t.service_worker_register ? t.service_worker_register(i) : navigator.serviceWorker.register(c, { updateViaCache: "none" }));
|
|
2363
|
+
let u = null;
|
|
1897
2364
|
try {
|
|
1898
|
-
|
|
2365
|
+
u = await qt.get(l);
|
|
1899
2366
|
} catch (e) {
|
|
1900
|
-
if (
|
|
2367
|
+
if (Jt(e)) return qt.delete(l), console.warn("oidc-client: service worker registration was aborted (likely tab shutdown or backgrounding); falling back to non–service-worker mode.", e), s();
|
|
1901
2368
|
throw e;
|
|
1902
2369
|
}
|
|
1903
|
-
let
|
|
1904
|
-
|
|
2370
|
+
let d = `oidc.sw.version_mismatch_reload.${n}`, f = async (e) => {
|
|
2371
|
+
Ht(), console.log("New SW waiting – SKIP_WAITING");
|
|
1905
2372
|
try {
|
|
1906
|
-
await new Promise((
|
|
2373
|
+
await new Promise((t, r) => {
|
|
1907
2374
|
let i = new MessageChannel(), a = null, o = () => {
|
|
1908
2375
|
try {
|
|
1909
2376
|
a != null && (b.clearTimeout(a), a = null), i.port1.onmessage = null, i.port1.close(), i.port2.close();
|
|
@@ -1914,14 +2381,14 @@ var at = (e, t = null, n) => {
|
|
|
1914
2381
|
a = b.setTimeout(() => {
|
|
1915
2382
|
o(), r(/* @__PURE__ */ Error("SKIP_WAITING did not respond within 8000ms"));
|
|
1916
2383
|
}, 8e3), i.port1.onmessage = (e) => {
|
|
1917
|
-
o(), e?.data?.error ? r(e.data.error) :
|
|
2384
|
+
o(), e?.data?.error ? r(e.data.error) : t();
|
|
1918
2385
|
};
|
|
1919
2386
|
try {
|
|
1920
2387
|
e.postMessage({
|
|
1921
2388
|
type: "SKIP_WAITING",
|
|
1922
|
-
configurationName:
|
|
2389
|
+
configurationName: n,
|
|
1923
2390
|
data: null,
|
|
1924
|
-
tabId:
|
|
2391
|
+
tabId: Ut(n ?? "default")
|
|
1925
2392
|
}, [i.port2]);
|
|
1926
2393
|
} catch (e) {
|
|
1927
2394
|
o(), r(e);
|
|
@@ -1930,187 +2397,205 @@ var at = (e, t = null, n) => {
|
|
|
1930
2397
|
} catch (e) {
|
|
1931
2398
|
console.warn("SKIP_WAITING failed", e);
|
|
1932
2399
|
}
|
|
1933
|
-
},
|
|
1934
|
-
let e =
|
|
1935
|
-
e ? await
|
|
1936
|
-
},
|
|
1937
|
-
|
|
2400
|
+
}, p = async () => {
|
|
2401
|
+
let e = u.waiting;
|
|
2402
|
+
e ? await f(e) : console.warn("sendSkipWaiting called but no waiting service worker found");
|
|
2403
|
+
}, m = (e) => {
|
|
2404
|
+
Ht(), e.addEventListener("statechange", async () => {
|
|
1938
2405
|
if (e.state === "installed" && navigator.serviceWorker.controller) {
|
|
1939
|
-
if (
|
|
2406
|
+
if (Zt() >= Xt) {
|
|
1940
2407
|
console.warn("SW trackInstallingWorker: skipping SKIP_WAITING because the reload budget is exhausted");
|
|
1941
2408
|
return;
|
|
1942
2409
|
}
|
|
1943
|
-
await
|
|
2410
|
+
await f(e);
|
|
1944
2411
|
}
|
|
1945
2412
|
});
|
|
1946
2413
|
};
|
|
1947
|
-
|
|
1948
|
-
let e =
|
|
1949
|
-
e &&
|
|
1950
|
-
}),
|
|
2414
|
+
u.addEventListener("updatefound", () => {
|
|
2415
|
+
let e = u.installing;
|
|
2416
|
+
e && m(e);
|
|
2417
|
+
}), u.installing ? m(u.installing) : u.waiting && navigator.serviceWorker.controller && (Zt() < Xt ? p() : console.warn("SW: a waiting worker exists but reload budget is exhausted – skipping activation")), u.update().catch((e) => {
|
|
1951
2418
|
console.error(e);
|
|
1952
2419
|
});
|
|
1953
2420
|
try {
|
|
1954
|
-
await navigator.serviceWorker.ready, navigator.serviceWorker.controller || (await Z(
|
|
2421
|
+
await navigator.serviceWorker.ready, navigator.serviceWorker.controller || (await Z(u, { timeoutMs: 8e3 })({
|
|
1955
2422
|
type: "claim",
|
|
1956
|
-
configurationName:
|
|
2423
|
+
configurationName: n,
|
|
1957
2424
|
data: null
|
|
1958
|
-
}), await
|
|
2425
|
+
}), await Gt(2e3));
|
|
1959
2426
|
} catch (e) {
|
|
1960
|
-
return console.warn(`Failed init ServiceWorker ${e?.toString?.() ?? String(e)}`),
|
|
2427
|
+
return console.warn(`Failed init ServiceWorker ${e?.toString?.() ?? String(e)}`), s();
|
|
1961
2428
|
}
|
|
1962
|
-
|
|
2429
|
+
Kt || (Kt = !0, navigator.serviceWorker.addEventListener("controllerchange", () => {
|
|
1963
2430
|
if (Q) return;
|
|
1964
|
-
let e =
|
|
1965
|
-
e >
|
|
2431
|
+
let e = Qt();
|
|
2432
|
+
e > Xt ? console.warn(`SW controllerchange: reload budget exhausted (${e - 1} reloads). Skipping reload to avoid infinite loop.`) : (Q = !0, console.log("SW controller changed – reloading page"), Ht(), window.location.reload());
|
|
1966
2433
|
}));
|
|
1967
|
-
let
|
|
2434
|
+
let h = async (e) => Z(u)({
|
|
1968
2435
|
type: "clear",
|
|
1969
2436
|
data: { status: e },
|
|
1970
|
-
configurationName:
|
|
1971
|
-
}),
|
|
1972
|
-
let
|
|
2437
|
+
configurationName: n
|
|
2438
|
+
}), g = async (t, i, s) => {
|
|
2439
|
+
let c = {
|
|
2440
|
+
token_renew_mode: s.token_renew_mode,
|
|
2441
|
+
client_id: s.client_id,
|
|
2442
|
+
scope: s.scope,
|
|
2443
|
+
resource: s.resource,
|
|
2444
|
+
resources: s.resources,
|
|
2445
|
+
service_worker_convert_all_requests_to_cors: s.service_worker_convert_all_requests_to_cors
|
|
2446
|
+
};
|
|
2447
|
+
if (a !== void 0 && (await Z(u)({
|
|
1973
2448
|
type: "init",
|
|
2449
|
+
configurationName: o,
|
|
1974
2450
|
data: {
|
|
1975
|
-
oidcServerConfiguration:
|
|
1976
|
-
where:
|
|
1977
|
-
oidcConfiguration:
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
2451
|
+
oidcServerConfiguration: t,
|
|
2452
|
+
where: "resource-capability",
|
|
2453
|
+
oidcConfiguration: c
|
|
2454
|
+
}
|
|
2455
|
+
})).resourceTokenManagement !== !0) throw new r(e.RESOURCE_WORKER_UNSUPPORTED, "Update OidcServiceWorker.js before using resource tokens.", {
|
|
2456
|
+
phase: "refresh",
|
|
2457
|
+
retryable: !1
|
|
2458
|
+
});
|
|
2459
|
+
let l = await Z(u)({
|
|
2460
|
+
type: "init",
|
|
2461
|
+
data: {
|
|
2462
|
+
oidcServerConfiguration: t,
|
|
2463
|
+
where: i,
|
|
2464
|
+
oidcConfiguration: c
|
|
1981
2465
|
},
|
|
1982
|
-
configurationName:
|
|
1983
|
-
}),
|
|
1984
|
-
if (
|
|
1985
|
-
console.warn(`Service worker ${
|
|
1986
|
-
let e = parseInt(sessionStorage.getItem(
|
|
2466
|
+
configurationName: n
|
|
2467
|
+
}), f = l.version;
|
|
2468
|
+
if (f !== "7.30.1") {
|
|
2469
|
+
console.warn(`Service worker ${f} version mismatch with js client version ${Lt}, unregistering and reloading`);
|
|
2470
|
+
let e = parseInt(sessionStorage.getItem(d) ?? "0", 10);
|
|
1987
2471
|
if (e < 3) {
|
|
1988
|
-
if (sessionStorage.setItem(
|
|
2472
|
+
if (sessionStorage.setItem(d, String(e + 1)), u.waiting) return await p(), await Bt({ milliseconds: 500 }), Q || (Q = !0, window.location.reload()), new Promise(() => {});
|
|
1989
2473
|
{
|
|
1990
|
-
|
|
2474
|
+
Ht();
|
|
1991
2475
|
try {
|
|
1992
|
-
await
|
|
2476
|
+
await u.update();
|
|
1993
2477
|
} catch (e) {
|
|
1994
2478
|
console.error(e);
|
|
1995
2479
|
}
|
|
1996
|
-
let e = await
|
|
1997
|
-
return console.log(`Service worker unregistering ${e}`), await
|
|
2480
|
+
let e = await u.unregister();
|
|
2481
|
+
return console.log(`Service worker unregistering ${e}`), await Bt({ milliseconds: 500 }), Q || (Q = !0, window.location.reload()), new Promise(() => {});
|
|
1998
2482
|
}
|
|
1999
2483
|
}
|
|
2000
2484
|
console.error(`Service worker version mismatch persists after ${e} attempt(s). Continuing with mismatched version.`);
|
|
2001
|
-
} else sessionStorage.removeItem(
|
|
2485
|
+
} else sessionStorage.removeItem(d), $t();
|
|
2002
2486
|
return {
|
|
2003
|
-
tokens:
|
|
2004
|
-
status:
|
|
2487
|
+
tokens: Nt(l.tokens, null, s.token_renew_mode),
|
|
2488
|
+
status: l.status,
|
|
2489
|
+
resourceContexts: l.resourceContexts
|
|
2005
2490
|
};
|
|
2006
|
-
},
|
|
2007
|
-
|
|
2008
|
-
},
|
|
2491
|
+
}, _ = (e = "/") => {
|
|
2492
|
+
Rt ?? (Rt = "not_null", Vt(e));
|
|
2493
|
+
}, v = (e) => Z(u)({
|
|
2009
2494
|
type: "setSessionState",
|
|
2010
2495
|
data: { sessionState: e },
|
|
2011
|
-
configurationName:
|
|
2012
|
-
}),
|
|
2496
|
+
configurationName: n
|
|
2497
|
+
}), y = async () => (await Z(u)({
|
|
2013
2498
|
type: "getSessionState",
|
|
2014
2499
|
data: null,
|
|
2015
|
-
configurationName:
|
|
2016
|
-
})).sessionState,
|
|
2500
|
+
configurationName: n
|
|
2501
|
+
})).sessionState, x = (e) => (a === void 0 && (sessionStorage[`oidc.nonce.${n}`] = e.nonce), Z(u)({
|
|
2017
2502
|
type: "setNonce",
|
|
2018
2503
|
data: { nonce: e },
|
|
2019
|
-
configurationName:
|
|
2020
|
-
})),
|
|
2021
|
-
let
|
|
2504
|
+
configurationName: n
|
|
2505
|
+
})), S = async (e = !0) => {
|
|
2506
|
+
let t = (await Z(u)({
|
|
2022
2507
|
type: "getNonce",
|
|
2023
2508
|
data: null,
|
|
2024
|
-
configurationName:
|
|
2509
|
+
configurationName: n
|
|
2025
2510
|
})).nonce;
|
|
2026
|
-
return
|
|
2027
|
-
},
|
|
2028
|
-
e == null ? (delete
|
|
2029
|
-
},
|
|
2030
|
-
if (
|
|
2031
|
-
let e = localStorage[`oidc.login.${
|
|
2511
|
+
return a === void 0 && (t || (t = sessionStorage[`oidc.nonce.${n}`], console.warn("nonce not found in service worker, using sessionStorage"), e && (await x(t), t = (await S(!1)).nonce))), { nonce: t };
|
|
2512
|
+
}, C = {}, w = (e) => {
|
|
2513
|
+
e == null ? (delete C[n], delete localStorage[`oidc.login.${n}`]) : (C[n] = e, localStorage[`oidc.login.${n}`] = JSON.stringify(e));
|
|
2514
|
+
}, T = () => {
|
|
2515
|
+
if (C[n]) return C[n];
|
|
2516
|
+
let e = localStorage[`oidc.login.${n}`];
|
|
2032
2517
|
if (typeof e != "string" || e === "" || e === "undefined" || e === "null") return null;
|
|
2033
2518
|
try {
|
|
2034
|
-
|
|
2519
|
+
C[n] = JSON.parse(e);
|
|
2035
2520
|
} catch {
|
|
2036
2521
|
return null;
|
|
2037
2522
|
}
|
|
2038
|
-
return
|
|
2039
|
-
},
|
|
2040
|
-
await Z(
|
|
2523
|
+
return C[n];
|
|
2524
|
+
}, E = async (e) => {
|
|
2525
|
+
await Z(u)({
|
|
2041
2526
|
type: "setDemonstratingProofOfPossessionNonce",
|
|
2042
2527
|
data: { demonstratingProofOfPossessionNonce: e },
|
|
2043
|
-
configurationName:
|
|
2528
|
+
configurationName: n
|
|
2044
2529
|
});
|
|
2045
|
-
},
|
|
2530
|
+
}, D = async () => (await Z(u)({
|
|
2046
2531
|
type: "getDemonstratingProofOfPossessionNonce",
|
|
2047
2532
|
data: null,
|
|
2048
|
-
configurationName:
|
|
2049
|
-
})).demonstratingProofOfPossessionNonce,
|
|
2050
|
-
let
|
|
2051
|
-
await Z(
|
|
2533
|
+
configurationName: n
|
|
2534
|
+
})).demonstratingProofOfPossessionNonce, ee = async (e) => {
|
|
2535
|
+
let t = JSON.stringify(e);
|
|
2536
|
+
await Z(u)({
|
|
2052
2537
|
type: "setDemonstratingProofOfPossessionJwk",
|
|
2053
|
-
data: { demonstratingProofOfPossessionJwkJson:
|
|
2054
|
-
configurationName:
|
|
2538
|
+
data: { demonstratingProofOfPossessionJwkJson: t },
|
|
2539
|
+
configurationName: n
|
|
2055
2540
|
});
|
|
2056
|
-
},
|
|
2057
|
-
let e = await Z(
|
|
2541
|
+
}, O = async () => {
|
|
2542
|
+
let e = await Z(u)({
|
|
2058
2543
|
type: "getDemonstratingProofOfPossessionJwk",
|
|
2059
2544
|
data: null,
|
|
2060
|
-
configurationName:
|
|
2545
|
+
configurationName: n
|
|
2061
2546
|
});
|
|
2062
2547
|
return e.demonstratingProofOfPossessionJwkJson ? JSON.parse(e.demonstratingProofOfPossessionJwkJson) : null;
|
|
2063
|
-
},
|
|
2064
|
-
let
|
|
2548
|
+
}, k = async (e = !0) => {
|
|
2549
|
+
let t = (await Z(u)({
|
|
2065
2550
|
type: "getState",
|
|
2066
2551
|
data: null,
|
|
2067
|
-
configurationName:
|
|
2552
|
+
configurationName: n
|
|
2068
2553
|
})).state;
|
|
2069
|
-
return
|
|
2070
|
-
},
|
|
2554
|
+
return a === void 0 && (t || (t = sessionStorage[`oidc.state.${n}`], console.warn("state not found in service worker, using sessionStorage"), e && (await A(t), t = await k(!1)))), t;
|
|
2555
|
+
}, A = async (e) => (a === void 0 && (sessionStorage[`oidc.state.${n}`] = e), Z(u)({
|
|
2071
2556
|
type: "setState",
|
|
2072
2557
|
data: { state: e },
|
|
2073
|
-
configurationName:
|
|
2074
|
-
})),
|
|
2075
|
-
let
|
|
2558
|
+
configurationName: n
|
|
2559
|
+
})), j = async (e = !0) => {
|
|
2560
|
+
let t = (await Z(u)({
|
|
2076
2561
|
type: "getCodeVerifier",
|
|
2077
2562
|
data: null,
|
|
2078
|
-
configurationName:
|
|
2563
|
+
configurationName: n
|
|
2079
2564
|
})).codeVerifier;
|
|
2080
|
-
return
|
|
2081
|
-
},
|
|
2565
|
+
return a === void 0 && (t || (t = sessionStorage[`oidc.code_verifier.${n}`], console.warn("codeVerifier not found in service worker, using sessionStorage"), e && (await te(t), t = await j(!1)))), t;
|
|
2566
|
+
}, te = async (e) => (a === void 0 && (sessionStorage[`oidc.code_verifier.${n}`] = e), Z(u)({
|
|
2082
2567
|
type: "setCodeVerifier",
|
|
2083
2568
|
data: { codeVerifier: e },
|
|
2084
|
-
configurationName:
|
|
2569
|
+
configurationName: n
|
|
2085
2570
|
}));
|
|
2086
2571
|
return {
|
|
2087
|
-
clearAsync:
|
|
2088
|
-
initAsync:
|
|
2089
|
-
startKeepAliveServiceWorker: () =>
|
|
2090
|
-
setSessionStateAsync:
|
|
2091
|
-
getSessionStateAsync:
|
|
2092
|
-
setNonceAsync:
|
|
2093
|
-
getNonceAsync:
|
|
2094
|
-
setLoginParams:
|
|
2095
|
-
getLoginParams:
|
|
2096
|
-
getStateAsync:
|
|
2097
|
-
setStateAsync:
|
|
2098
|
-
getCodeVerifierAsync:
|
|
2099
|
-
setCodeVerifierAsync:
|
|
2100
|
-
setDemonstratingProofOfPossessionNonce:
|
|
2101
|
-
getDemonstratingProofOfPossessionNonce:
|
|
2102
|
-
setDemonstratingProofOfPossessionJwkAsync:
|
|
2103
|
-
getDemonstratingProofOfPossessionJwkAsync:
|
|
2104
|
-
signalAsync: (e,
|
|
2572
|
+
clearAsync: h,
|
|
2573
|
+
initAsync: g,
|
|
2574
|
+
startKeepAliveServiceWorker: () => _(t.service_worker_keep_alive_path),
|
|
2575
|
+
setSessionStateAsync: v,
|
|
2576
|
+
getSessionStateAsync: y,
|
|
2577
|
+
setNonceAsync: x,
|
|
2578
|
+
getNonceAsync: S,
|
|
2579
|
+
setLoginParams: w,
|
|
2580
|
+
getLoginParams: T,
|
|
2581
|
+
getStateAsync: k,
|
|
2582
|
+
setStateAsync: A,
|
|
2583
|
+
getCodeVerifierAsync: j,
|
|
2584
|
+
setCodeVerifierAsync: te,
|
|
2585
|
+
setDemonstratingProofOfPossessionNonce: E,
|
|
2586
|
+
getDemonstratingProofOfPossessionNonce: D,
|
|
2587
|
+
setDemonstratingProofOfPossessionJwkAsync: ee,
|
|
2588
|
+
getDemonstratingProofOfPossessionJwkAsync: O,
|
|
2589
|
+
signalAsync: (e, t) => Z(u, t)({
|
|
2105
2590
|
...e,
|
|
2106
|
-
configurationName: e.configurationName ??
|
|
2591
|
+
configurationName: e.configurationName ?? n
|
|
2107
2592
|
})
|
|
2108
2593
|
};
|
|
2109
|
-
},
|
|
2594
|
+
}, en = async (e, t, n, r) => {
|
|
2110
2595
|
let i = await $(e, t);
|
|
2111
2596
|
if (!i) throw Error(`signalServiceWorkerAsync: no service worker registered for configuration "${t}"`);
|
|
2112
2597
|
return i.signalAsync(n, r);
|
|
2113
|
-
},
|
|
2598
|
+
}, tn = class e {
|
|
2114
2599
|
constructor(e) {
|
|
2115
2600
|
this._oidc = e;
|
|
2116
2601
|
}
|
|
@@ -2124,17 +2609,17 @@ var at = (e, t = null, n) => {
|
|
|
2124
2609
|
this._oidc.publishEvent(e, t);
|
|
2125
2610
|
}
|
|
2126
2611
|
static {
|
|
2127
|
-
this.getOrCreate = (t, n = new
|
|
2612
|
+
this.getOrCreate = (t, n = new M()) => (r, i = "default") => new e(K.getOrCreate(t, n)(r, i));
|
|
2128
2613
|
}
|
|
2129
2614
|
static get(t = "default") {
|
|
2130
|
-
let n =
|
|
2615
|
+
let n = K.get(t);
|
|
2131
2616
|
return n ? new e(n) : null;
|
|
2132
2617
|
}
|
|
2133
2618
|
static getOrThrow(t = "default") {
|
|
2134
|
-
return new e(
|
|
2619
|
+
return new e(K.getOrThrow(t));
|
|
2135
2620
|
}
|
|
2136
2621
|
static {
|
|
2137
|
-
this.eventNames =
|
|
2622
|
+
this.eventNames = K.eventNames;
|
|
2138
2623
|
}
|
|
2139
2624
|
tryKeepExistingSessionAsync() {
|
|
2140
2625
|
return this._oidc.tryKeepExistingSessionAsync();
|
|
@@ -2174,21 +2659,33 @@ var at = (e, t = null, n) => {
|
|
|
2174
2659
|
}
|
|
2175
2660
|
async getValidTokenAsync(e = 200, t = 50) {
|
|
2176
2661
|
let n = this._oidc;
|
|
2177
|
-
return
|
|
2662
|
+
return Ft({
|
|
2178
2663
|
getTokens: () => n.tokens,
|
|
2179
2664
|
configuration: {
|
|
2180
2665
|
token_automatic_renew_mode: n.configuration.token_automatic_renew_mode,
|
|
2181
2666
|
refresh_time_before_tokens_expiration_in_second: n.configuration.refresh_time_before_tokens_expiration_in_second
|
|
2182
2667
|
},
|
|
2183
2668
|
syncTokensInfoAsync: async () => {
|
|
2184
|
-
let { status: e } = await
|
|
2669
|
+
let { status: e } = await Et(n)(n.configuration, n.configurationName, n.tokens, !1);
|
|
2185
2670
|
return e;
|
|
2186
2671
|
},
|
|
2187
2672
|
renewTokensAsync: n.renewTokensAsync.bind(n)
|
|
2188
2673
|
}, e, t);
|
|
2189
2674
|
}
|
|
2190
|
-
|
|
2191
|
-
return
|
|
2675
|
+
getAccessTokenForResourceAsync(e, t) {
|
|
2676
|
+
return this._oidc.resourceTokens.getAccessTokenAsync(e, t);
|
|
2677
|
+
}
|
|
2678
|
+
getAccessTokenForResource(e) {
|
|
2679
|
+
return this._oidc.resourceTokens.peek(e);
|
|
2680
|
+
}
|
|
2681
|
+
clearResourceTokensAsync(e) {
|
|
2682
|
+
return this._oidc.resourceTokens.clearAsync(e);
|
|
2683
|
+
}
|
|
2684
|
+
fetchForResource(e, t = window.fetch, n = {}) {
|
|
2685
|
+
return this.fetchWithTokens(t, n.demonstratingProofOfPossession ?? !1, { resource: e });
|
|
2686
|
+
}
|
|
2687
|
+
fetchWithTokens(e, t = !1, n = {}) {
|
|
2688
|
+
return gt(e, this._oidc, n.demonstratingProofOfPossession ?? t, n);
|
|
2192
2689
|
}
|
|
2193
2690
|
async userInfoAsync(e = !1, t = !1) {
|
|
2194
2691
|
return this._oidc.userInfoAsync(e, t);
|
|
@@ -2197,37 +2694,8 @@ var at = (e, t = null, n) => {
|
|
|
2197
2694
|
return this._oidc.userInfo;
|
|
2198
2695
|
}
|
|
2199
2696
|
async signalServiceWorker(e, t) {
|
|
2200
|
-
return
|
|
2697
|
+
return en(this._oidc.configuration, this._oidc.configurationName, e, t);
|
|
2201
2698
|
}
|
|
2202
|
-
}
|
|
2203
|
-
SKIP_WAITING: "SKIP_WAITING",
|
|
2204
|
-
CLAIM: "claim",
|
|
2205
|
-
CLEAR: "clear",
|
|
2206
|
-
INIT: "init",
|
|
2207
|
-
SET_STATE: "setState",
|
|
2208
|
-
GET_STATE: "getState",
|
|
2209
|
-
SET_CODE_VERIFIER: "setCodeVerifier",
|
|
2210
|
-
GET_CODE_VERIFIER: "getCodeVerifier",
|
|
2211
|
-
SET_SESSION_STATE: "setSessionState",
|
|
2212
|
-
GET_SESSION_STATE: "getSessionState",
|
|
2213
|
-
SET_NONCE: "setNonce",
|
|
2214
|
-
GET_NONCE: "getNonce",
|
|
2215
|
-
SET_DPOP_NONCE: "setDemonstratingProofOfPossessionNonce",
|
|
2216
|
-
GET_DPOP_NONCE: "getDemonstratingProofOfPossessionNonce",
|
|
2217
|
-
SET_DPOP_JWK: "setDemonstratingProofOfPossessionJwk",
|
|
2218
|
-
GET_DPOP_JWK: "getDemonstratingProofOfPossessionJwk"
|
|
2219
|
-
}, kt = {
|
|
2220
|
-
ACCESS_TOKEN: "ACCESS_TOKEN_SECURED_BY_OIDC_SERVICE_WORKER",
|
|
2221
|
-
REFRESH_TOKEN: "REFRESH_TOKEN_SECURED_BY_OIDC_SERVICE_WORKER",
|
|
2222
|
-
NONCE_TOKEN: "NONCE_SECURED_BY_OIDC_SERVICE_WORKER",
|
|
2223
|
-
CODE_VERIFIER: "CODE_VERIFIER_SECURED_BY_OIDC_SERVICE_WORKER"
|
|
2224
|
-
}, At = "DPOP_SECURED_BY_OIDC_SERVICE_WORKER", jt = {
|
|
2225
|
-
TAB_ID: "oidc.tabId.",
|
|
2226
|
-
STATE: "oidc.state.",
|
|
2227
|
-
NONCE: "oidc.nonce.",
|
|
2228
|
-
CODE_VERIFIER: "oidc.code_verifier.",
|
|
2229
|
-
LOGIN_PARAMS: "oidc.login.",
|
|
2230
|
-
SW_VERSION_MISMATCH_RELOAD: "oidc.sw.version_mismatch_reload."
|
|
2231
|
-
}, Mt = "oidc.sw.controllerchange_reload_count", Nt = (e, t) => `${e}${t}`, Pt = (e, t, n = "default") => `${e}_${t}#tabId=${n}`, Ft = (e, t = "default") => `${At}_${e}#tabId=${t}`, It = (e) => typeof e == "string" && Object.values(Ot).includes(e);
|
|
2699
|
+
};
|
|
2232
2700
|
//#endregion
|
|
2233
|
-
export {
|
|
2701
|
+
export { Ue as DPOP_TOKEN_PLACEHOLDER_PREFIX, tn as OidcClient, r as OidcError, e as OidcErrorCode, M as OidcLocation, P as OidcStateError, N as OidcStateErrorCode, Be as PROTOCOL_VERSION, I as PushedAuthorizationRequestError, F as PushedAuthorizationRequestErrorCode, We as STORAGE_KEY_PREFIX, Ge as SW_CONTROLLER_CHANGE_RELOAD_COUNT_KEY, Ve as ServiceWorkerMessageType, He as TOKEN_PLACEHOLDERS, W as TokenAutomaticRenewMode, Y as TokenRenewMode, Je as buildDpopSecuredPlaceholder, qe as buildSecuredTokenPlaceholder, Ke as buildStorageKey, vt as getFetchDefault, V as getParseQueryStringFromLocation, Ze as getPath, i as isOidcError, ve as isOidcStateError, ye as isPushedAuthorizationRequestError, Ye as isServiceWorkerMessageType, en as signalServiceWorkerAsync };
|