@axa-fr/react-oidc 6.5.7 → 6.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/FetchToken.js +39 -104
- package/dist/FetchToken.js.map +1 -1
- package/dist/OidcProvider.js +76 -110
- package/dist/OidcProvider.js.map +1 -1
- package/dist/OidcSecure.js +11 -60
- package/dist/OidcSecure.js.map +1 -1
- package/dist/ReactOidc.js +56 -74
- package/dist/ReactOidc.js.map +1 -1
- package/dist/User.js +13 -32
- package/dist/User.js.map +1 -1
- package/dist/core/default-component/AuthenticateError.component.js +4 -29
- package/dist/core/default-component/AuthenticateError.component.js.map +1 -1
- package/dist/core/default-component/Authenticating.component.js +4 -29
- package/dist/core/default-component/Authenticating.component.js.map +1 -1
- package/dist/core/default-component/Callback.component.js +29 -99
- package/dist/core/default-component/Callback.component.js.map +1 -1
- package/dist/core/default-component/Loading.component.js +3 -28
- package/dist/core/default-component/Loading.component.js.map +1 -1
- package/dist/core/default-component/ServiceWorkerNotSupported.component.js +4 -29
- package/dist/core/default-component/ServiceWorkerNotSupported.component.js.map +1 -1
- package/dist/core/default-component/SessionLost.component.js +6 -13
- package/dist/core/default-component/SessionLost.component.js.map +1 -1
- package/dist/core/default-component/SilentCallback.component.js +13 -73
- package/dist/core/default-component/SilentCallback.component.js.map +1 -1
- package/dist/core/default-component/SilentLogin.component.js +13 -43
- package/dist/core/default-component/SilentLogin.component.js.map +1 -1
- package/dist/core/default-component/index.js +6 -19
- package/dist/core/default-component/index.js.map +1 -1
- package/dist/core/routes/OidcRoutes.js +20 -49
- package/dist/core/routes/OidcRoutes.js.map +1 -1
- package/dist/core/routes/index.js +1 -8
- package/dist/core/routes/index.js.map +1 -1
- package/dist/core/routes/withRouter.js +13 -20
- package/dist/core/routes/withRouter.js.map +1 -1
- package/dist/index.js +5 -18
- package/dist/index.js.map +1 -1
- package/dist/vanilla/checkSessionIFrame.js +21 -30
- package/dist/vanilla/checkSessionIFrame.js.map +1 -1
- package/dist/vanilla/index.js +1 -5
- package/dist/vanilla/index.js.map +1 -1
- package/dist/vanilla/initSession.js +41 -78
- package/dist/vanilla/initSession.js.map +1 -1
- package/dist/vanilla/initWorker.js +99 -168
- package/dist/vanilla/initWorker.js.map +1 -1
- package/dist/vanilla/memoryStorageBackend.js +11 -17
- package/dist/vanilla/memoryStorageBackend.js.map +1 -1
- package/dist/vanilla/noHashQueryStringUtils.js +15 -46
- package/dist/vanilla/noHashQueryStringUtils.js.map +1 -1
- package/dist/vanilla/oidc.js +945 -1394
- package/dist/vanilla/oidc.js.map +1 -1
- package/dist/vanilla/parseTokens.js +33 -53
- package/dist/vanilla/parseTokens.js.map +1 -1
- package/dist/vanilla/route-utils.js +17 -23
- package/dist/vanilla/route-utils.js.map +1 -1
- package/dist/vanilla/timer.js +21 -23
- package/dist/vanilla/timer.js.map +1 -1
- package/package.json +2 -3
- package/src/oidc/FetchToken.tsx +0 -61
- package/src/oidc/OidcProvider.tsx +0 -206
- package/src/oidc/OidcSecure.tsx +0 -37
- package/src/oidc/ReactOidc.tsx +0 -139
- package/src/oidc/User.ts +0 -38
- package/src/oidc/core/default-component/AuthenticateError.component.tsx +0 -13
- package/src/oidc/core/default-component/Authenticating.component.tsx +0 -13
- package/src/oidc/core/default-component/Callback.component.tsx +0 -46
- package/src/oidc/core/default-component/Loading.component.tsx +0 -10
- package/src/oidc/core/default-component/ServiceWorkerNotSupported.component.tsx +0 -13
- package/src/oidc/core/default-component/SessionLost.component.tsx +0 -14
- package/src/oidc/core/default-component/SilentCallback.component.tsx +0 -22
- package/src/oidc/core/default-component/SilentLogin.component.tsx +0 -35
- package/src/oidc/core/default-component/index.ts +0 -6
- package/src/oidc/core/routes/OidcRoutes.spec.tsx +0 -15
- package/src/oidc/core/routes/OidcRoutes.tsx +0 -69
- package/src/oidc/core/routes/__snapshots__/OidcRoutes.spec.tsx.snap +0 -7
- package/src/oidc/core/routes/index.ts +0 -2
- package/src/oidc/core/routes/withRouter.spec.tsx +0 -48
- package/src/oidc/core/routes/withRouter.tsx +0 -64
- package/src/oidc/index.ts +0 -5
- package/src/oidc/vanilla/OidcServiceWorker.js +0 -435
- package/src/oidc/vanilla/OidcTrustedDomains.js +0 -16
- package/src/oidc/vanilla/checkSessionIFrame.ts +0 -82
- package/src/oidc/vanilla/index.ts +0 -1
- package/src/oidc/vanilla/initSession.ts +0 -67
- package/src/oidc/vanilla/initWorker.ts +0 -165
- package/src/oidc/vanilla/memoryStorageBackend.ts +0 -33
- package/src/oidc/vanilla/noHashQueryStringUtils.ts +0 -33
- package/src/oidc/vanilla/oidc.ts +0 -1230
- package/src/oidc/vanilla/parseTokens.ts +0 -150
- package/src/oidc/vanilla/route-utils.spec.ts +0 -15
- package/src/oidc/vanilla/route-utils.ts +0 -76
- package/src/oidc/vanilla/timer.ts +0 -165
- package/tsconfig.json +0 -38
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
const idTokenPayload = (token) => {
|
|
2
|
-
if(!token){
|
|
3
|
-
return null;
|
|
4
|
-
}
|
|
5
|
-
const base64Url = token.split('.')[1];
|
|
6
|
-
const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
|
|
7
|
-
const jsonPayload = decodeURIComponent(atob(base64).split('').map(function (c) {
|
|
8
|
-
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
|
|
9
|
-
}).join(''));
|
|
10
|
-
|
|
11
|
-
return JSON.parse(jsonPayload);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const countLetter = (str, find)=> {
|
|
15
|
-
return (str.split(find)).length - 1;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const extractAccessTokenPayload = tokens => {
|
|
19
|
-
if(tokens.accessTokenPayload)
|
|
20
|
-
{
|
|
21
|
-
return tokens.accessTokenPayload;
|
|
22
|
-
}
|
|
23
|
-
const accessToken = tokens.accessToken;
|
|
24
|
-
try{
|
|
25
|
-
if (!accessToken || countLetter(accessToken,'.') !== 2) {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
return JSON.parse(atob(accessToken.split('.')[1]));
|
|
29
|
-
} catch (e) {
|
|
30
|
-
console.warn(e);
|
|
31
|
-
}
|
|
32
|
-
return null;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
export const setTokens = (tokens, oldTokens=null) =>{
|
|
37
|
-
|
|
38
|
-
if(!tokens){
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
let accessTokenPayload;
|
|
42
|
-
|
|
43
|
-
if(!tokens.issuedAt) {
|
|
44
|
-
const currentTimeUnixSecond = new Date().getTime() /1000;
|
|
45
|
-
tokens.issuedAt = currentTimeUnixSecond;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if(tokens.accessTokenPayload !== undefined) {
|
|
49
|
-
accessTokenPayload = tokens.accessTokenPayload;
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
accessTokenPayload = extractAccessTokenPayload(tokens);
|
|
53
|
-
}
|
|
54
|
-
const _idTokenPayload = tokens.idTokenPayload ? tokens.idTokenPayload : idTokenPayload(tokens.idToken);
|
|
55
|
-
|
|
56
|
-
const idTokenExipreAt =(_idTokenPayload && _idTokenPayload.exp) ? _idTokenPayload.exp: Number.MAX_VALUE;
|
|
57
|
-
const accessTokenExpiresAt = (accessTokenPayload && accessTokenPayload.exp)? accessTokenPayload.exp : tokens.issuedAt + tokens.expiresIn;
|
|
58
|
-
const expiresAt = idTokenExipreAt < accessTokenExpiresAt ? idTokenExipreAt : accessTokenExpiresAt;
|
|
59
|
-
|
|
60
|
-
const newTokens = {...tokens, idTokenPayload: _idTokenPayload, accessTokenPayload, expiresAt};
|
|
61
|
-
// When refresh_token is not rotated we reuse ald refresh_token
|
|
62
|
-
if(oldTokens != null && "refreshToken" in oldTokens && !("refreshToken" in tokens)){
|
|
63
|
-
const refreshToken = oldTokens.refreshToken
|
|
64
|
-
return {...newTokens, refreshToken};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return newTokens;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
export const parseOriginalTokens= (tokens, oldTokens) =>{
|
|
73
|
-
if(!tokens){
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
if(!tokens.issued_at) {
|
|
77
|
-
const currentTimeUnixSecond = new Date().getTime() /1000;
|
|
78
|
-
tokens.issued_at = currentTimeUnixSecond;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const data = {
|
|
82
|
-
accessToken: tokens.access_token,
|
|
83
|
-
expiresIn: tokens.expires_in,
|
|
84
|
-
idToken: tokens.id_token,
|
|
85
|
-
scope: tokens.scope,
|
|
86
|
-
tokenType: tokens.token_type,
|
|
87
|
-
issuedAt: tokens.issued_at
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
if("refresh_token" in tokens) {
|
|
91
|
-
// @ts-ignore
|
|
92
|
-
data.refreshToken= tokens.refresh_token;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
if(tokens.accessTokenPayload !== undefined){
|
|
97
|
-
// @ts-ignore
|
|
98
|
-
data.accessTokenPayload = tokens.accessTokenPayload;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if(tokens.idTokenPayload !== undefined){
|
|
102
|
-
// @ts-ignore
|
|
103
|
-
data.idTokenPayload = tokens.idTokenPayload;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return setTokens(data, oldTokens);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export const computeTimeLeft = (refreshTimeBeforeTokensExpirationInSecond, expiresAt)=>{
|
|
110
|
-
const currentTimeUnixSecond = new Date().getTime() /1000;
|
|
111
|
-
return Math.round(((expiresAt - refreshTimeBeforeTokensExpirationInSecond) - currentTimeUnixSecond));
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export const isTokensValid= (tokens) =>{
|
|
115
|
-
if(!tokens){
|
|
116
|
-
return false;
|
|
117
|
-
}
|
|
118
|
-
return computeTimeLeft(0, tokens.expiresAt) > 0;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// 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).
|
|
122
|
-
// https://github.com/openid/AppAuth-JS/issues/65
|
|
123
|
-
export const isTokensOidcValid =(tokens, nonce, oidcServerConfiguration) =>{
|
|
124
|
-
if(tokens.idTokenPayload) {
|
|
125
|
-
const idTokenPayload = tokens.idTokenPayload;
|
|
126
|
-
// 2: The Issuer Identifier for the OpenID Provider (which is typically obtained during Discovery) MUST exactly match the value of the iss (issuer) Claim.
|
|
127
|
-
if(oidcServerConfiguration.issuer !== idTokenPayload.iss){
|
|
128
|
-
return false;
|
|
129
|
-
}
|
|
130
|
-
// 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.
|
|
131
|
-
|
|
132
|
-
// 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.
|
|
133
|
-
|
|
134
|
-
// 9: The current time MUST be before the time represented by the exp Claim.
|
|
135
|
-
const currentTimeUnixSecond = new Date().getTime() /1000;
|
|
136
|
-
if(idTokenPayload.exp && idTokenPayload.exp < currentTimeUnixSecond) {
|
|
137
|
-
return false;
|
|
138
|
-
}
|
|
139
|
-
// 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.
|
|
140
|
-
const timeInSevenDays = 60 * 60 * 24 * 7;
|
|
141
|
-
if(idTokenPayload.iat && (idTokenPayload.iat + timeInSevenDays) < currentTimeUnixSecond) {
|
|
142
|
-
return false;
|
|
143
|
-
}
|
|
144
|
-
// 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.
|
|
145
|
-
if (idTokenPayload.nonce && idTokenPayload.nonce !== nonce) {
|
|
146
|
-
return false;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
return true;
|
|
150
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { getPath } from './route-utils';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
test.each([['http://example.com/pathname', '/pathname'],
|
|
5
|
-
['http://example.com:3000/pathname/?search=test#hash', '/pathname#hash'],
|
|
6
|
-
['http://example.com:3000/pathname/#hash?search=test', '/pathname#hash'],
|
|
7
|
-
['http://example.com:3000/pathname#hash?search=test', '/pathname#hash'],
|
|
8
|
-
['http://example.com:3000/', ''],])(
|
|
9
|
-
'getPath should return the full path of an url',
|
|
10
|
-
(uri, expected) => {
|
|
11
|
-
|
|
12
|
-
const path = getPath(uri);
|
|
13
|
-
expect(path).toBe(expected);
|
|
14
|
-
},
|
|
15
|
-
);
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
export const getLocation = (href: string) => {
|
|
2
|
-
const match = href.match(
|
|
3
|
-
// eslint-disable-next-line no-useless-escape
|
|
4
|
-
/^(https?\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/
|
|
5
|
-
);
|
|
6
|
-
|
|
7
|
-
let search = match[6];
|
|
8
|
-
let hash = match[7];
|
|
9
|
-
|
|
10
|
-
if (hash) {
|
|
11
|
-
const splits = hash.split("?");
|
|
12
|
-
if(splits.length ==2){
|
|
13
|
-
hash = splits[0];
|
|
14
|
-
search = splits[1];
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if(search){
|
|
19
|
-
search = search.slice(1);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
match && {
|
|
24
|
-
href,
|
|
25
|
-
protocol: match[1],
|
|
26
|
-
host: match[2],
|
|
27
|
-
hostname: match[3],
|
|
28
|
-
port: match[4],
|
|
29
|
-
path: match[5],
|
|
30
|
-
search,
|
|
31
|
-
hash,
|
|
32
|
-
}
|
|
33
|
-
);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export const getPath = (href: string) => {
|
|
37
|
-
const location = getLocation(href);
|
|
38
|
-
let { path } = location;
|
|
39
|
-
|
|
40
|
-
if(path.endsWith('/')){
|
|
41
|
-
path = path.slice(0, -1);
|
|
42
|
-
}
|
|
43
|
-
let { hash } = location;
|
|
44
|
-
|
|
45
|
-
if(hash === "#_=_"){
|
|
46
|
-
hash = "";
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (hash) {
|
|
50
|
-
path += hash;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return path;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export const getParseQueryStringFromLocation=(href: string) => {
|
|
57
|
-
const location = getLocation(href);
|
|
58
|
-
let { search } = location;
|
|
59
|
-
|
|
60
|
-
return parseQueryString(search);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const parseQueryString = (queryString:string) => {
|
|
64
|
-
let params:any = {}, queries, temp, i, l;
|
|
65
|
-
|
|
66
|
-
// Split into key/value pairs
|
|
67
|
-
queries = queryString.split("&");
|
|
68
|
-
|
|
69
|
-
// Convert the array of strings into an object
|
|
70
|
-
for (i = 0, l = queries.length; i < l; i++) {
|
|
71
|
-
temp = queries[i].split('=');
|
|
72
|
-
params[temp[0]] = temp[1];
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return params;
|
|
76
|
-
};
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
const timer = (function () {
|
|
2
|
-
const workerPort = (function () {
|
|
3
|
-
let worker;
|
|
4
|
-
let blobURL;
|
|
5
|
-
|
|
6
|
-
const workerCode = function () {
|
|
7
|
-
const innerIdsByOuterIds = {};
|
|
8
|
-
|
|
9
|
-
const methods = {
|
|
10
|
-
setTimeout: function (port, id, timeout) {
|
|
11
|
-
innerIdsByOuterIds[id] = setTimeout(function () {
|
|
12
|
-
port.postMessage(id);
|
|
13
|
-
innerIdsByOuterIds[id] = null;
|
|
14
|
-
}, timeout);
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
setInterval: function (port, id, timeout) {
|
|
18
|
-
innerIdsByOuterIds[id] = setInterval(function () {
|
|
19
|
-
port.postMessage(id);
|
|
20
|
-
}, timeout);
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
clearTimeout: function (port, id) {
|
|
24
|
-
clearTimeout(innerIdsByOuterIds[id]);
|
|
25
|
-
innerIdsByOuterIds[id] = null;
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
clearInterval: function (port, id) {
|
|
29
|
-
clearInterval(innerIdsByOuterIds[id]);
|
|
30
|
-
innerIdsByOuterIds[id] = null;
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
function onMessage(port, event) {
|
|
35
|
-
var method = event.data[0];
|
|
36
|
-
var id = event.data[1];
|
|
37
|
-
var option = event.data[2];
|
|
38
|
-
|
|
39
|
-
if (methods[method]) {
|
|
40
|
-
methods[method](port, id, option);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// For Dedicated Worker
|
|
45
|
-
this.onmessage = function (event) {
|
|
46
|
-
onMessage(self, event);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
// For Shared Worker
|
|
50
|
-
this.onconnect = function (event) {
|
|
51
|
-
const port = event.ports[0];
|
|
52
|
-
|
|
53
|
-
port.onmessage = function (event) {
|
|
54
|
-
onMessage(port, event);
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
}.toString();
|
|
58
|
-
|
|
59
|
-
try {
|
|
60
|
-
const blob = new Blob(['(', workerCode, ')()'], {type: 'application/javascript'});
|
|
61
|
-
blobURL = URL.createObjectURL(blob);
|
|
62
|
-
} catch (error) {
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
const insideBrowser = (typeof process === 'undefined');
|
|
66
|
-
try {
|
|
67
|
-
if (SharedWorker) {
|
|
68
|
-
worker = new SharedWorker(blobURL);
|
|
69
|
-
return worker.port;
|
|
70
|
-
}
|
|
71
|
-
} catch (error)
|
|
72
|
-
{
|
|
73
|
-
if(insideBrowser) {
|
|
74
|
-
console.warn("SharedWorker not available");
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
try {
|
|
78
|
-
if (Worker) {
|
|
79
|
-
worker = new Worker(blobURL);
|
|
80
|
-
return worker;
|
|
81
|
-
}
|
|
82
|
-
} catch (error)
|
|
83
|
-
{
|
|
84
|
-
if(insideBrowser) {
|
|
85
|
-
console.warn("Worker not available");
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return null;
|
|
90
|
-
}());
|
|
91
|
-
|
|
92
|
-
if (!workerPort) {
|
|
93
|
-
// In NextJS with SSR (Server Side Rendering) during rending in Node JS, the window object is undefined,
|
|
94
|
-
// the global object is used instead as it is the closest approximation of a browsers window object.
|
|
95
|
-
const bindContext = (typeof window === 'undefined')? global: window;
|
|
96
|
-
|
|
97
|
-
return {
|
|
98
|
-
setTimeout: setTimeout.bind(bindContext),
|
|
99
|
-
clearTimeout: clearTimeout.bind(bindContext),
|
|
100
|
-
setInterval: setInterval.bind(bindContext),
|
|
101
|
-
clearInterval: clearInterval.bind(bindContext)
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const getId = (function () {
|
|
106
|
-
let currentId = 0;
|
|
107
|
-
|
|
108
|
-
return function () {
|
|
109
|
-
currentId++;
|
|
110
|
-
return currentId;
|
|
111
|
-
};
|
|
112
|
-
}());
|
|
113
|
-
|
|
114
|
-
const timeoutCallbacksById = {};
|
|
115
|
-
const intervalCallbacksById = {};
|
|
116
|
-
|
|
117
|
-
workerPort.onmessage = function (event) {
|
|
118
|
-
const id = event.data;
|
|
119
|
-
|
|
120
|
-
const timeoutCallback = timeoutCallbacksById[id];
|
|
121
|
-
if (timeoutCallback) {
|
|
122
|
-
timeoutCallback();
|
|
123
|
-
timeoutCallbacksById[id] = null;
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const intervalCallback = intervalCallbacksById[id];
|
|
128
|
-
if (intervalCallback) {
|
|
129
|
-
intervalCallback();
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
function setTimeoutWorker(callback, timeout) {
|
|
134
|
-
const id = getId();
|
|
135
|
-
workerPort.postMessage(['setTimeout', id, timeout]);
|
|
136
|
-
timeoutCallbacksById[id] = callback;
|
|
137
|
-
return id;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
function clearTimeoutWorker(id) {
|
|
141
|
-
workerPort.postMessage(['clearTimeout', id]);
|
|
142
|
-
timeoutCallbacksById[id] = null;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function setIntervalWorker(callback, timeout) {
|
|
146
|
-
const id = getId();
|
|
147
|
-
workerPort.postMessage(['setInterval', id, timeout]);
|
|
148
|
-
intervalCallbacksById[id] = callback;
|
|
149
|
-
return id;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function clearIntervalWorker(id) {
|
|
153
|
-
workerPort.postMessage(['clearInterval', id]);
|
|
154
|
-
intervalCallbacksById[id] = null;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return {
|
|
158
|
-
setTimeout: setTimeoutWorker,
|
|
159
|
-
clearTimeout: clearTimeoutWorker,
|
|
160
|
-
setInterval: setIntervalWorker,
|
|
161
|
-
clearInterval: clearIntervalWorker
|
|
162
|
-
};
|
|
163
|
-
}());
|
|
164
|
-
|
|
165
|
-
export default timer;
|
package/tsconfig.json
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "es5",
|
|
4
|
-
"lib": ["es2015", "dom"],
|
|
5
|
-
"outDir": "dist",
|
|
6
|
-
"jsx": "react",
|
|
7
|
-
"module": "commonjs",
|
|
8
|
-
"declaration": true,
|
|
9
|
-
"declarationMap": true,
|
|
10
|
-
"sourceMap": true,
|
|
11
|
-
"strict": false,
|
|
12
|
-
"noImplicitAny": false,
|
|
13
|
-
"strictNullChecks": false,
|
|
14
|
-
"strictFunctionTypes": false,
|
|
15
|
-
"strictPropertyInitialization": false,
|
|
16
|
-
"noImplicitThis": false,
|
|
17
|
-
"alwaysStrict": false,
|
|
18
|
-
"noUnusedLocals": false,
|
|
19
|
-
"noUnusedParameters": false,
|
|
20
|
-
"noImplicitReturns": false,
|
|
21
|
-
"noFallthroughCasesInSwitch": true,
|
|
22
|
-
"moduleResolution": "node",
|
|
23
|
-
"resolveJsonModule": true,
|
|
24
|
-
"esModuleInterop": true,
|
|
25
|
-
"allowSyntheticDefaultImports": true
|
|
26
|
-
},
|
|
27
|
-
"include": ["src/oidc"],
|
|
28
|
-
"exclude": [
|
|
29
|
-
"node_modules",
|
|
30
|
-
"**/*.spec.ts",
|
|
31
|
-
"**/*.spec.tsx",
|
|
32
|
-
"**/*.test.ts",
|
|
33
|
-
"**/*.test.tsx",
|
|
34
|
-
"**/*.stories.tsx",
|
|
35
|
-
"./src/setupTests.ts"
|
|
36
|
-
],
|
|
37
|
-
"files": ["./src/oidc/index.ts"]
|
|
38
|
-
}
|