@axa-fr/react-oidc 6.15.8 → 6.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/{copy.js → copy.cjs} +5 -2
- package/dist/service_worker/OidcServiceWorker.d.ts +2 -0
- package/dist/service_worker/OidcServiceWorker.d.ts.map +1 -0
- package/dist/service_worker/OidcServiceWorker.js +369 -0
- package/dist/service_worker/OidcServiceWorker.js.map +1 -0
- package/dist/service_worker/constants.d.ts +18 -0
- package/dist/service_worker/constants.d.ts.map +1 -0
- package/dist/service_worker/types.d.ts +80 -0
- package/dist/service_worker/types.d.ts.map +1 -0
- package/dist/service_worker/utils/domains.d.ts +6 -0
- package/dist/service_worker/utils/domains.d.ts.map +1 -0
- package/dist/service_worker/utils/index.d.ts +6 -0
- package/dist/service_worker/utils/index.d.ts.map +1 -0
- package/dist/service_worker/utils/serializeHeaders.d.ts +3 -0
- package/dist/service_worker/utils/serializeHeaders.d.ts.map +1 -0
- package/dist/service_worker/utils/sleep.d.ts +3 -0
- package/dist/service_worker/utils/sleep.d.ts.map +1 -0
- package/dist/service_worker/utils/strings.d.ts +8 -0
- package/dist/service_worker/utils/strings.d.ts.map +1 -0
- package/dist/service_worker/utils/tokens.d.ts +12 -0
- package/dist/service_worker/utils/tokens.d.ts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/vanilla/initWorker.js +1 -1
- package/dist/vanilla/initWorker.js.map +1 -1
- package/package.json +17 -9
- package/service_worker/.eslintrc.cjs +18 -0
- package/service_worker/OidcServiceWorker.ts +387 -0
- package/service_worker/constants.ts +32 -0
- package/service_worker/dist/OidcServiceWorker.d.ts +2 -0
- package/service_worker/dist/OidcServiceWorker.d.ts.map +1 -0
- package/service_worker/dist/OidcServiceWorker.js +369 -0
- package/service_worker/dist/OidcServiceWorker.js.map +1 -0
- package/service_worker/dist/constants.d.ts +18 -0
- package/service_worker/dist/constants.d.ts.map +1 -0
- package/service_worker/dist/types.d.ts +80 -0
- package/service_worker/dist/types.d.ts.map +1 -0
- package/service_worker/dist/utils/domains.d.ts +6 -0
- package/service_worker/dist/utils/domains.d.ts.map +1 -0
- package/service_worker/dist/utils/index.d.ts +6 -0
- package/service_worker/dist/utils/index.d.ts.map +1 -0
- package/service_worker/dist/utils/serializeHeaders.d.ts +3 -0
- package/service_worker/dist/utils/serializeHeaders.d.ts.map +1 -0
- package/service_worker/dist/utils/sleep.d.ts +3 -0
- package/service_worker/dist/utils/sleep.d.ts.map +1 -0
- package/service_worker/dist/utils/strings.d.ts +8 -0
- package/service_worker/dist/utils/strings.d.ts.map +1 -0
- package/service_worker/dist/utils/tokens.d.ts +12 -0
- package/service_worker/dist/utils/tokens.d.ts.map +1 -0
- package/service_worker/tsconfig.json +26 -0
- package/service_worker/types.ts +93 -0
- package/service_worker/utils/__tests__/domains.spec.ts +63 -0
- package/service_worker/utils/__tests__/serializeHeaders.spec.ts +11 -0
- package/service_worker/utils/__tests__/strings.spec.ts +9 -0
- package/service_worker/utils/__tests__/testHelper.ts +346 -0
- package/service_worker/utils/__tests__/tokens.spec.ts +68 -0
- package/service_worker/utils/domains.ts +95 -0
- package/service_worker/utils/index.ts +5 -0
- package/service_worker/utils/serializeHeaders.ts +12 -0
- package/service_worker/utils/sleep.ts +2 -0
- package/service_worker/utils/strings.ts +9 -0
- package/service_worker/utils/tokens.ts +198 -0
- package/src/oidc/vanilla/initWorker.ts +1 -1
- package/dist/OidcServiceWorker.d.ts +0 -119
- package/dist/OidcServiceWorker.d.ts.map +0 -1
- package/dist/OidcServiceWorker.js +0 -498
- package/dist/OidcServiceWorker.js.map +0 -1
- /package/{dist → service_worker}/OidcTrustedDomains.js +0 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { TrustedDomains } from './../types';
|
|
2
|
+
import {
|
|
3
|
+
acceptAnyDomainToken,
|
|
4
|
+
openidWellknownUrlEndWith,
|
|
5
|
+
scriptFilename,
|
|
6
|
+
} from '../constants';
|
|
7
|
+
import { Database, Domain, OidcConfig } from '../types';
|
|
8
|
+
|
|
9
|
+
function checkDomain(domains: Domain[], endpoint: string) {
|
|
10
|
+
if (!endpoint) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const domain = domains.find((domain) => {
|
|
15
|
+
let testable: RegExp;
|
|
16
|
+
|
|
17
|
+
if (typeof domain === 'string') {
|
|
18
|
+
testable = new RegExp(`^${domain}`);
|
|
19
|
+
} else {
|
|
20
|
+
testable = domain;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return testable.test?.(endpoint);
|
|
24
|
+
});
|
|
25
|
+
if (!domain) {
|
|
26
|
+
throw new Error(
|
|
27
|
+
'Domain ' +
|
|
28
|
+
endpoint +
|
|
29
|
+
' is not trusted, please add domain in ' +
|
|
30
|
+
scriptFilename
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const getCurrentDatabaseDomain = (
|
|
36
|
+
database: Database,
|
|
37
|
+
url: string,
|
|
38
|
+
trustedDomains: TrustedDomains
|
|
39
|
+
) => {
|
|
40
|
+
if (url.endsWith(openidWellknownUrlEndWith)) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
for (const [key, currentDatabase] of Object.entries<OidcConfig>(database)) {
|
|
44
|
+
const oidcServerConfiguration = currentDatabase.oidcServerConfiguration;
|
|
45
|
+
|
|
46
|
+
if (!oidcServerConfiguration) {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (
|
|
51
|
+
oidcServerConfiguration.tokenEndpoint &&
|
|
52
|
+
url === oidcServerConfiguration.tokenEndpoint
|
|
53
|
+
) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (
|
|
57
|
+
oidcServerConfiguration.revocationEndpoint &&
|
|
58
|
+
url === oidcServerConfiguration.revocationEndpoint
|
|
59
|
+
) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const domainsToSendTokens = oidcServerConfiguration.userInfoEndpoint
|
|
64
|
+
? [oidcServerConfiguration.userInfoEndpoint, ...trustedDomains[key]]
|
|
65
|
+
: [...trustedDomains[key]];
|
|
66
|
+
|
|
67
|
+
let hasToSendToken = false;
|
|
68
|
+
if (domainsToSendTokens.find((f) => f === acceptAnyDomainToken)) {
|
|
69
|
+
hasToSendToken = true;
|
|
70
|
+
} else {
|
|
71
|
+
for (let i = 0; i < domainsToSendTokens.length; i++) {
|
|
72
|
+
let domain = domainsToSendTokens[i];
|
|
73
|
+
|
|
74
|
+
if (typeof domain === 'string') {
|
|
75
|
+
domain = new RegExp(`^${domain}`);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (domain.test?.(url)) {
|
|
79
|
+
hasToSendToken = true;
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (hasToSendToken) {
|
|
86
|
+
if (!currentDatabase.tokens) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
return currentDatabase;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return null;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export { checkDomain, getCurrentDatabaseDomain };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FetchHeaders } from '../types';
|
|
2
|
+
|
|
3
|
+
function serializeHeaders(headers: Headers) {
|
|
4
|
+
const headersObj: Record<string, string> = {};
|
|
5
|
+
for (const key of (headers as FetchHeaders).keys()) {
|
|
6
|
+
if (headers.has(key)) {
|
|
7
|
+
headersObj[key] = headers.get(key) as string;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
return headersObj;
|
|
11
|
+
}
|
|
12
|
+
export {serializeHeaders};
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { TOKEN, TokenRenewMode } from '../constants';
|
|
2
|
+
import { OidcConfig, OidcConfiguration, OidcServerConfiguration, Tokens } from '../types';
|
|
3
|
+
import { countLetter } from './strings';
|
|
4
|
+
|
|
5
|
+
function parseJwt(token: string) {
|
|
6
|
+
return JSON.parse(
|
|
7
|
+
b64DecodeUnicode(token.split('.')[1].replace('-', '+').replace('_', '/'))
|
|
8
|
+
);
|
|
9
|
+
}
|
|
10
|
+
function b64DecodeUnicode(str: string) {
|
|
11
|
+
return decodeURIComponent(
|
|
12
|
+
Array.prototype.map
|
|
13
|
+
.call(
|
|
14
|
+
atob(str),
|
|
15
|
+
(c) => '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)
|
|
16
|
+
)
|
|
17
|
+
.join('')
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function computeTimeLeft(
|
|
22
|
+
refreshTimeBeforeTokensExpirationInSecond: number,
|
|
23
|
+
expiresAt: number
|
|
24
|
+
) {
|
|
25
|
+
const currentTimeUnixSecond = new Date().getTime() / 1000;
|
|
26
|
+
return Math.round(
|
|
27
|
+
expiresAt -
|
|
28
|
+
refreshTimeBeforeTokensExpirationInSecond -
|
|
29
|
+
currentTimeUnixSecond
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function isTokensValid(tokens: Tokens | null) {
|
|
34
|
+
if (!tokens) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
return computeTimeLeft(0, tokens.expiresAt) > 0;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const extractTokenPayload = (token?: string) => {
|
|
41
|
+
try {
|
|
42
|
+
if (!token) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
if (countLetter(token, '.') === 2) {
|
|
46
|
+
return parseJwt(token);
|
|
47
|
+
} else {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
} catch (e) {
|
|
51
|
+
console.warn(e);
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// https://openid.net/specs/openid-connect-core-1_0.html#IDTokenValidation (excluding rules #1, #4, #5, #7, #8, #12, and #13 which did not apply).
|
|
57
|
+
// https://github.com/openid/AppAuth-JS/issues/65
|
|
58
|
+
const isTokensOidcValid = (
|
|
59
|
+
tokens: Tokens,
|
|
60
|
+
nonce: string | null,
|
|
61
|
+
oidcServerConfiguration: OidcServerConfiguration
|
|
62
|
+
): { isValid: boolean; reason: string } => {
|
|
63
|
+
if (tokens.idTokenPayload) {
|
|
64
|
+
const idTokenPayload = tokens.idTokenPayload;
|
|
65
|
+
// 2: The Issuer Identifier for the OpenID Provider (which is typically obtained during Discovery) MUST exactly match the value of the iss (issuer) Claim.
|
|
66
|
+
if (oidcServerConfiguration.issuer !== idTokenPayload.iss) {
|
|
67
|
+
return { isValid: false, reason: 'Issuer does not match' };
|
|
68
|
+
}
|
|
69
|
+
// 3: The Client MUST validate that the aud (audience) Claim contains its client_id value registered at the Issuer identified by the iss (issuer) Claim as an audience. The aud (audience) Claim MAY contain an array with more than one element. The ID Token MUST be rejected if the ID Token does not list the Client as a valid audience, or if it contains additional audiences not trusted by the Client.
|
|
70
|
+
|
|
71
|
+
// 6: If the ID Token is received via direct communication between the Client and the Token Endpoint (which it is in this flow), the TLS server validation MAY be used to validate the issuer in place of checking the token signature. The Client MUST validate the signature of all other ID Tokens according to JWS [JWS] using the algorithm specified in the JWT alg Header Parameter. The Client MUST use the keys provided by the Issuer.
|
|
72
|
+
|
|
73
|
+
// 9: The current time MUST be before the time represented by the exp Claim.
|
|
74
|
+
const currentTimeUnixSecond = new Date().getTime() / 1000;
|
|
75
|
+
if (idTokenPayload.exp && idTokenPayload.exp < currentTimeUnixSecond) {
|
|
76
|
+
return { isValid: false, reason: 'Token expired' };
|
|
77
|
+
}
|
|
78
|
+
// 10: The iat Claim can be used to reject tokens that were issued too far away from the current time, limiting the amount of time that nonces need to be stored to prevent attacks. The acceptable range is Client specific.
|
|
79
|
+
const timeInSevenDays = 60 * 60 * 24 * 7;
|
|
80
|
+
if (
|
|
81
|
+
idTokenPayload.iat &&
|
|
82
|
+
idTokenPayload.iat + timeInSevenDays < currentTimeUnixSecond
|
|
83
|
+
) {
|
|
84
|
+
return { isValid: false, reason: 'Token is used from too long time' };
|
|
85
|
+
}
|
|
86
|
+
// 11: If a nonce value was sent in the Authentication Request, a nonce Claim MUST be present and its value checked to verify that it is the same value as the one that was sent in the Authentication Request. The Client SHOULD check the nonce value for replay attacks. The precise method for detecting replay attacks is Client specific.
|
|
87
|
+
if (idTokenPayload.nonce && idTokenPayload.nonce !== nonce) {
|
|
88
|
+
return { isValid: false, reason: 'Nonce does not match' };
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return { isValid: true, reason: '' };
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
function hideTokens(currentDatabaseElement: OidcConfig) {
|
|
95
|
+
const configurationName = currentDatabaseElement.configurationName;
|
|
96
|
+
return (response: Response) => {
|
|
97
|
+
if (response.status !== 200) {
|
|
98
|
+
return response;
|
|
99
|
+
}
|
|
100
|
+
return response.json().then<Response>((tokens: Tokens) => {
|
|
101
|
+
if (!tokens.issued_at) {
|
|
102
|
+
const currentTimeUnixSecond = new Date().getTime() / 1000;
|
|
103
|
+
tokens.issued_at = currentTimeUnixSecond;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const accessTokenPayload = extractTokenPayload(tokens.access_token);
|
|
107
|
+
const secureTokens = {
|
|
108
|
+
...tokens,
|
|
109
|
+
access_token: TOKEN.ACCESS_TOKEN + '_' + configurationName,
|
|
110
|
+
accessTokenPayload,
|
|
111
|
+
};
|
|
112
|
+
tokens.accessTokenPayload = accessTokenPayload;
|
|
113
|
+
|
|
114
|
+
let _idTokenPayload = null;
|
|
115
|
+
if (tokens.id_token) {
|
|
116
|
+
_idTokenPayload = extractTokenPayload(tokens.id_token);
|
|
117
|
+
tokens.idTokenPayload = { ..._idTokenPayload };
|
|
118
|
+
if (_idTokenPayload.nonce && currentDatabaseElement.nonce != null) {
|
|
119
|
+
const keyNonce =
|
|
120
|
+
TOKEN.NONCE_TOKEN + '_' + currentDatabaseElement.configurationName;
|
|
121
|
+
_idTokenPayload.nonce = keyNonce;
|
|
122
|
+
}
|
|
123
|
+
secureTokens.idTokenPayload = _idTokenPayload;
|
|
124
|
+
}
|
|
125
|
+
if (tokens.refresh_token) {
|
|
126
|
+
secureTokens.refresh_token =
|
|
127
|
+
TOKEN.REFRESH_TOKEN + '_' + configurationName;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const idTokenExpiresAt =
|
|
131
|
+
_idTokenPayload && _idTokenPayload.exp
|
|
132
|
+
? _idTokenPayload.exp
|
|
133
|
+
: Number.MAX_VALUE;
|
|
134
|
+
const accessTokenExpiresAt =
|
|
135
|
+
accessTokenPayload && accessTokenPayload.exp
|
|
136
|
+
? accessTokenPayload.exp
|
|
137
|
+
: tokens.issued_at + tokens.expires_in;
|
|
138
|
+
|
|
139
|
+
let expiresAt: number;
|
|
140
|
+
const tokenRenewMode = (
|
|
141
|
+
currentDatabaseElement.oidcConfiguration as OidcConfiguration
|
|
142
|
+
).token_renew_mode;
|
|
143
|
+
if (tokenRenewMode === TokenRenewMode.access_token_invalid) {
|
|
144
|
+
expiresAt = accessTokenExpiresAt;
|
|
145
|
+
} else if (tokenRenewMode === TokenRenewMode.id_token_invalid) {
|
|
146
|
+
expiresAt = idTokenExpiresAt;
|
|
147
|
+
} else {
|
|
148
|
+
expiresAt =
|
|
149
|
+
idTokenExpiresAt < accessTokenExpiresAt
|
|
150
|
+
? idTokenExpiresAt
|
|
151
|
+
: accessTokenExpiresAt;
|
|
152
|
+
}
|
|
153
|
+
secureTokens.expiresAt = expiresAt;
|
|
154
|
+
|
|
155
|
+
tokens.expiresAt = expiresAt;
|
|
156
|
+
const nonce = currentDatabaseElement.nonce
|
|
157
|
+
? currentDatabaseElement.nonce.nonce
|
|
158
|
+
: null;
|
|
159
|
+
const { isValid, reason } = isTokensOidcValid(
|
|
160
|
+
tokens,
|
|
161
|
+
nonce,
|
|
162
|
+
currentDatabaseElement.oidcServerConfiguration as OidcServerConfiguration
|
|
163
|
+
); //TODO: Type assertion, could be null.
|
|
164
|
+
if (!isValid) {
|
|
165
|
+
throw Error(`Tokens are not OpenID valid, reason: ${reason}`);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// When refresh_token is not rotated we reuse ald refresh_token
|
|
169
|
+
if (
|
|
170
|
+
currentDatabaseElement.tokens != null &&
|
|
171
|
+
'refresh_token' in currentDatabaseElement.tokens &&
|
|
172
|
+
!('refresh_token' in tokens)
|
|
173
|
+
) {
|
|
174
|
+
const refreshToken = currentDatabaseElement.tokens.refresh_token;
|
|
175
|
+
|
|
176
|
+
currentDatabaseElement.tokens = {
|
|
177
|
+
...tokens,
|
|
178
|
+
refresh_token: refreshToken,
|
|
179
|
+
};
|
|
180
|
+
} else {
|
|
181
|
+
currentDatabaseElement.tokens = tokens;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
currentDatabaseElement.status = 'LOGGED_IN';
|
|
185
|
+
const body = JSON.stringify(secureTokens);
|
|
186
|
+
return new Response(body, response);
|
|
187
|
+
});
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export {
|
|
192
|
+
b64DecodeUnicode,
|
|
193
|
+
computeTimeLeft,
|
|
194
|
+
isTokensValid,
|
|
195
|
+
extractTokenPayload,
|
|
196
|
+
isTokensOidcValid,
|
|
197
|
+
hideTokens
|
|
198
|
+
};
|
|
@@ -129,7 +129,7 @@ export const excludeOs = (operatingSystem) => {
|
|
|
129
129
|
if (operatingSystem.os === 'iOS' && operatingSystem.osVersion.startsWith('12')) {
|
|
130
130
|
return true;
|
|
131
131
|
}
|
|
132
|
-
if (operatingSystem.os === 'Mac OS X' && operatingSystem.osVersion.startsWith('
|
|
132
|
+
if (operatingSystem.os === 'Mac OS X' && operatingSystem.osVersion.startsWith('10_15_6')) {
|
|
133
133
|
return true;
|
|
134
134
|
}
|
|
135
135
|
return false;
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
declare type Domain = string | RegExp;
|
|
2
|
-
declare type TrustedDomains = {
|
|
3
|
-
[key: string]: Domain[];
|
|
4
|
-
};
|
|
5
|
-
declare type OidcServerConfiguration = {
|
|
6
|
-
revocationEndpoint: string;
|
|
7
|
-
issuer: string;
|
|
8
|
-
authorizationEndpoint: string;
|
|
9
|
-
tokenEndpoint: string;
|
|
10
|
-
userInfoEndpoint: string;
|
|
11
|
-
};
|
|
12
|
-
declare type OidcConfiguration = {
|
|
13
|
-
token_renew_mode: string;
|
|
14
|
-
service_worker_convert_all_requests_to_cors: boolean;
|
|
15
|
-
};
|
|
16
|
-
interface FetchHeaders extends Headers {
|
|
17
|
-
keys(): string[];
|
|
18
|
-
}
|
|
19
|
-
declare type Status = 'LOGGED' | 'LOGGED_IN' | 'LOGGED_OUT' | 'NOT_CONNECTED' | 'LOGOUT_FROM_ANOTHER_TAB' | 'SESSION_LOST' | 'REQUIRE_SYNC_TOKENS' | 'FORCE_REFRESH' | null;
|
|
20
|
-
declare type MessageEventType = 'clear' | 'init' | 'setState' | 'getState' | 'setCodeVerifier' | 'getCodeVerifier' | 'setSessionState' | 'getSessionState' | 'setNonce';
|
|
21
|
-
declare type MessageData = {
|
|
22
|
-
status: Status;
|
|
23
|
-
oidcServerConfiguration: OidcServerConfiguration;
|
|
24
|
-
oidcConfiguration: OidcConfiguration;
|
|
25
|
-
where: string;
|
|
26
|
-
state: string;
|
|
27
|
-
codeVerifier: string;
|
|
28
|
-
sessionState: string;
|
|
29
|
-
nonce: Nonce;
|
|
30
|
-
};
|
|
31
|
-
declare type MessageEventData = {
|
|
32
|
-
configurationName: string;
|
|
33
|
-
type: MessageEventType;
|
|
34
|
-
data: MessageData;
|
|
35
|
-
};
|
|
36
|
-
declare type Nonce = {
|
|
37
|
-
nonce: string;
|
|
38
|
-
} | null;
|
|
39
|
-
declare type OidcConfig = {
|
|
40
|
-
configurationName: string;
|
|
41
|
-
tokens: Tokens | null;
|
|
42
|
-
status: Status;
|
|
43
|
-
state: string | null;
|
|
44
|
-
codeVerifier: string | null;
|
|
45
|
-
nonce: Nonce;
|
|
46
|
-
oidcServerConfiguration: OidcServerConfiguration | null;
|
|
47
|
-
oidcConfiguration?: OidcConfiguration;
|
|
48
|
-
sessionState?: string | null;
|
|
49
|
-
items?: MessageData;
|
|
50
|
-
};
|
|
51
|
-
declare type IdTokenPayload = {
|
|
52
|
-
iss: string;
|
|
53
|
-
/**
|
|
54
|
-
* (Expiration Time) Claim
|
|
55
|
-
*/
|
|
56
|
-
exp: number;
|
|
57
|
-
/**
|
|
58
|
-
* (Issued At) Claim
|
|
59
|
-
*/
|
|
60
|
-
iat: number;
|
|
61
|
-
nonce: string | null;
|
|
62
|
-
};
|
|
63
|
-
declare type AccessTokenPayload = {
|
|
64
|
-
exp: number;
|
|
65
|
-
sub: string;
|
|
66
|
-
};
|
|
67
|
-
declare type Tokens = {
|
|
68
|
-
issued_at: number;
|
|
69
|
-
access_token: string;
|
|
70
|
-
accessTokenPayload: AccessTokenPayload | null;
|
|
71
|
-
id_token: null | string;
|
|
72
|
-
idTokenPayload: IdTokenPayload;
|
|
73
|
-
refresh_token?: string;
|
|
74
|
-
expiresAt: number;
|
|
75
|
-
expires_in: number;
|
|
76
|
-
};
|
|
77
|
-
declare type Database = {
|
|
78
|
-
[key: string]: OidcConfig;
|
|
79
|
-
};
|
|
80
|
-
declare const _self: ServiceWorkerGlobalScope & typeof globalThis;
|
|
81
|
-
declare let trustedDomains: TrustedDomains;
|
|
82
|
-
declare const scriptFilename = "OidcTrustedDomains.js";
|
|
83
|
-
declare const id: string;
|
|
84
|
-
declare const acceptAnyDomainToken = "*";
|
|
85
|
-
declare const keepAliveJsonFilename = "OidcKeepAliveServiceWorker.json";
|
|
86
|
-
declare const handleInstall: (event: ExtendableEvent) => void;
|
|
87
|
-
declare const handleActivate: (event: ExtendableEvent) => void;
|
|
88
|
-
declare let currentLoginCallbackConfigurationName: string | null;
|
|
89
|
-
declare const database: Database;
|
|
90
|
-
declare const countLetter: (str: string, find: string) => number;
|
|
91
|
-
declare const b64DecodeUnicode: (str: string) => string;
|
|
92
|
-
declare const parseJwt: (token: string) => any;
|
|
93
|
-
declare const extractTokenPayload: (token: string) => any;
|
|
94
|
-
declare const computeTimeLeft: (refreshTimeBeforeTokensExpirationInSecond: number, expiresAt: number) => number;
|
|
95
|
-
declare const isTokensValid: (tokens: Tokens | null) => boolean;
|
|
96
|
-
declare const isTokensOidcValid: (tokens: Tokens, nonce: string | null, oidcServerConfiguration: OidcServerConfiguration) => {
|
|
97
|
-
isValid: boolean;
|
|
98
|
-
reason: string;
|
|
99
|
-
};
|
|
100
|
-
declare const TokenRenewMode: {
|
|
101
|
-
access_token_or_id_token_invalid: string;
|
|
102
|
-
access_token_invalid: string;
|
|
103
|
-
id_token_invalid: string;
|
|
104
|
-
};
|
|
105
|
-
declare function hideTokens(currentDatabaseElement: OidcConfig): (response: Response) => Response | Promise<Response>;
|
|
106
|
-
declare const getCurrentDatabasesTokenEndpoint: (database: Database, url: string) => OidcConfig[];
|
|
107
|
-
declare const openidWellknownUrlEndWith = "/.well-known/openid-configuration";
|
|
108
|
-
declare const getCurrentDatabaseDomain: (database: Database, url: string) => OidcConfig | null;
|
|
109
|
-
declare const serializeHeaders: (headers: Headers) => Record<string, string>;
|
|
110
|
-
declare const REFRESH_TOKEN = "REFRESH_TOKEN_SECURED_BY_OIDC_SERVICE_WORKER";
|
|
111
|
-
declare const ACCESS_TOKEN = "ACCESS_TOKEN_SECURED_BY_OIDC_SERVICE_WORKER";
|
|
112
|
-
declare const NONCE_TOKEN = "NONCE_SECURED_BY_OIDC_SERVICE_WORKER";
|
|
113
|
-
declare const CODE_VERIFIER = "CODE_VERIFIER_SECURED_BY_OIDC_SERVICE_WORKER";
|
|
114
|
-
declare const sleep: (ms: number) => Promise<unknown>;
|
|
115
|
-
declare const keepAliveAsync: (event: FetchEvent) => Promise<Response>;
|
|
116
|
-
declare const handleFetch: (event: FetchEvent) => Promise<void>;
|
|
117
|
-
declare const handleMessage: (event: ExtendableMessageEvent) => void;
|
|
118
|
-
declare const checkDomain: (domains: Domain[], endpoint: string) => void;
|
|
119
|
-
//# sourceMappingURL=OidcServiceWorker.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OidcServiceWorker.d.ts","sourceRoot":"","sources":["../service_worker/OidcServiceWorker.ts"],"names":[],"mappings":"AAAA,aAAK,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAE9B,aAAK,cAAc,GAAG;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CAC1B,CAAA;AACD,aAAK,uBAAuB,GAAG;IAC3B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,qBAAqB,EAAE,MAAM,CAAC;IAC9B,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;CAC5B,CAAA;AAED,aAAK,iBAAiB,GAAG;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,2CAA2C,EAAE,OAAO,CAAC;CACxD,CAAA;AAID,UAAU,YAAa,SAAQ,OAAO;IAClC,IAAI,IAAI,MAAM,EAAE,CAAC;CACpB;AAED,aAAK,MAAM,GAAG,QAAQ,GAAG,WAAW,GAAG,YAAY,GAAG,eAAe,GAAG,yBAAyB,GAAG,cAAc,GAAG,qBAAqB,GAAG,eAAe,GAAG,IAAI,CAAC;AACpK,aAAK,gBAAgB,GAAG,OAAO,GAAG,MAAM,GAAG,UAAU,GAAG,UAAU,GAAG,iBAAiB,GAAG,iBAAiB,GAAG,iBAAiB,GAAG,iBAAiB,GAAG,UAAU,CAAC;AAEhK,aAAK,WAAW,GAAG;IACf,MAAM,EAAE,MAAM,CAAC;IACf,uBAAuB,EAAE,uBAAuB,CAAC;IACjD,iBAAiB,EAAE,iBAAiB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