@axa-fr/react-oidc 6.5.6 → 6.5.8-alpha0
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
package/dist/FetchToken.js
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -19,100 +7,47 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
19
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
8
|
});
|
|
21
9
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import Oidc from "./vanilla/oidc";
|
|
12
|
+
import { isTokensValid } from "./vanilla/parseTokens";
|
|
13
|
+
import { sleepAsync } from "./vanilla/initWorker";
|
|
14
|
+
const defaultConfigurationName = "default";
|
|
15
|
+
const fetchWithToken = (fetch, getOidcWithConfigurationName) => (url, options = { method: 'GET' }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
let headers = new Headers();
|
|
17
|
+
const optionTmp = Object.assign({}, options);
|
|
18
|
+
if (optionTmp.headers) {
|
|
19
|
+
headers = !(optionTmp.headers instanceof Headers)
|
|
20
|
+
? new Headers(optionTmp.headers)
|
|
21
|
+
: optionTmp.headers;
|
|
47
22
|
}
|
|
23
|
+
const oidc = getOidcWithConfigurationName();
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
const accessToken = oidc.tokens ? oidc.tokens.accessToken : null;
|
|
26
|
+
// We wait the synchronisation before making a request
|
|
27
|
+
while (oidc.tokens && accessToken && !isTokensValid(oidc.tokens)) {
|
|
28
|
+
yield sleepAsync(200);
|
|
29
|
+
}
|
|
30
|
+
if (!headers.has('Accept')) {
|
|
31
|
+
headers.set('Accept', 'application/json');
|
|
32
|
+
}
|
|
33
|
+
if (accessToken) {
|
|
34
|
+
headers.set('Authorization', `Bearer ${accessToken}`);
|
|
35
|
+
if (!optionTmp.credentials) {
|
|
36
|
+
optionTmp.credentials = 'same-origin';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const newOptions = Object.assign(Object.assign({}, optionTmp), { headers });
|
|
40
|
+
return yield fetch(url, newOptions);
|
|
41
|
+
});
|
|
42
|
+
export const withOidcFetch = (fetch = null, configurationName = defaultConfigurationName) => (WrappedComponent) => (props) => {
|
|
43
|
+
const { fetch: newFetch } = useOidcFetch(fetch || props.fetch, configurationName);
|
|
44
|
+
return React.createElement(WrappedComponent, Object.assign({}, props, { fetch: newFetch }));
|
|
48
45
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
var react_1 = __importDefault(require("react"));
|
|
55
|
-
var oidc_1 = __importDefault(require("./vanilla/oidc"));
|
|
56
|
-
var parseTokens_1 = require("./vanilla/parseTokens");
|
|
57
|
-
var initWorker_1 = require("./vanilla/initWorker");
|
|
58
|
-
var defaultConfigurationName = "default";
|
|
59
|
-
var fetchWithToken = function (fetch, getOidcWithConfigurationName) { return function (url, options) {
|
|
60
|
-
if (options === void 0) { options = { method: 'GET' }; }
|
|
61
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
62
|
-
var headers, optionTmp, oidc, accessToken, newOptions;
|
|
63
|
-
return __generator(this, function (_a) {
|
|
64
|
-
switch (_a.label) {
|
|
65
|
-
case 0:
|
|
66
|
-
headers = new Headers();
|
|
67
|
-
optionTmp = __assign({}, options);
|
|
68
|
-
if (optionTmp.headers) {
|
|
69
|
-
headers = !(optionTmp.headers instanceof Headers)
|
|
70
|
-
? new Headers(optionTmp.headers)
|
|
71
|
-
: optionTmp.headers;
|
|
72
|
-
}
|
|
73
|
-
oidc = getOidcWithConfigurationName();
|
|
74
|
-
accessToken = oidc.tokens ? oidc.tokens.accessToken : null;
|
|
75
|
-
_a.label = 1;
|
|
76
|
-
case 1:
|
|
77
|
-
if (!(oidc.tokens && accessToken && !(0, parseTokens_1.isTokensValid)(oidc.tokens))) return [3 /*break*/, 3];
|
|
78
|
-
return [4 /*yield*/, (0, initWorker_1.sleepAsync)(200)];
|
|
79
|
-
case 2:
|
|
80
|
-
_a.sent();
|
|
81
|
-
return [3 /*break*/, 1];
|
|
82
|
-
case 3:
|
|
83
|
-
if (!headers.has('Accept')) {
|
|
84
|
-
headers.set('Accept', 'application/json');
|
|
85
|
-
}
|
|
86
|
-
if (accessToken) {
|
|
87
|
-
headers.set('Authorization', "Bearer ".concat(accessToken));
|
|
88
|
-
if (!optionTmp.credentials) {
|
|
89
|
-
optionTmp.credentials = 'same-origin';
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
newOptions = __assign(__assign({}, optionTmp), { headers: headers });
|
|
93
|
-
return [4 /*yield*/, fetch(url, newOptions)];
|
|
94
|
-
case 4: return [2 /*return*/, _a.sent()];
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
}; };
|
|
99
|
-
var withOidcFetch = function (fetch, configurationName) {
|
|
100
|
-
if (fetch === void 0) { fetch = null; }
|
|
101
|
-
if (configurationName === void 0) { configurationName = defaultConfigurationName; }
|
|
102
|
-
return function (WrappedComponent) { return function (props) {
|
|
103
|
-
var newFetch = (0, exports.useOidcFetch)(fetch || props.fetch, configurationName).fetch;
|
|
104
|
-
return react_1.default.createElement(WrappedComponent, __assign({}, props, { fetch: newFetch }));
|
|
105
|
-
}; };
|
|
106
|
-
};
|
|
107
|
-
exports.withOidcFetch = withOidcFetch;
|
|
108
|
-
var useOidcFetch = function (fetch, configurationName) {
|
|
109
|
-
if (fetch === void 0) { fetch = null; }
|
|
110
|
-
if (configurationName === void 0) { configurationName = defaultConfigurationName; }
|
|
111
|
-
var previousFetch = fetch || window.fetch;
|
|
112
|
-
var getOidc = oidc_1.default.get;
|
|
113
|
-
var getOidcWithConfigurationName = function () { return getOidc(configurationName); };
|
|
114
|
-
var newFetch = fetchWithToken(previousFetch, getOidcWithConfigurationName);
|
|
46
|
+
export const useOidcFetch = (fetch = null, configurationName = defaultConfigurationName) => {
|
|
47
|
+
const previousFetch = fetch || window.fetch;
|
|
48
|
+
const getOidc = Oidc.get;
|
|
49
|
+
const getOidcWithConfigurationName = () => { return getOidc(configurationName); };
|
|
50
|
+
const newFetch = fetchWithToken(previousFetch, getOidcWithConfigurationName);
|
|
115
51
|
return { fetch: newFetch };
|
|
116
52
|
};
|
|
117
|
-
exports.useOidcFetch = useOidcFetch;
|
|
118
53
|
//# sourceMappingURL=FetchToken.js.map
|
package/dist/FetchToken.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FetchToken.js","sourceRoot":"","sources":["../src/oidc/FetchToken.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FetchToken.js","sourceRoot":"","sources":["../src/oidc/FetchToken.tsx"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,gBAAgB,CAAC;AAClC,OAAO,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAMhD,MAAM,wBAAwB,GAAG,SAAS,CAAC;AAE3C,MAAM,cAAc,GAAG,CAAC,KAAY,EAAE,4BAA+C,EAAE,EAAE,CAAC,CACtF,GAAgB,EAChB,UAAuB,EAAE,MAAM,EAAE,KAAK,EAAE,EAC1C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B,EAAE,CAAC,CAAC,KAAkC,EAAE,EAAE;IAC1C,MAAM,EAAC,KAAK,EAAC,QAAQ,EAAC,GAAG,YAAY,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAA;IAC9E,OAAO,oBAAC,gBAAgB,oBAAK,KAAK,IAAE,KAAK,EAAE,QAAQ,IAAI,CAAC;AAC1D,CAAC,CAAC;AAGJ,MAAM,CAAC,MAAM,YAAY,GAAE,CAAC,QAAY,IAAI,EAAE,iBAAiB,GAAC,wBAAwB,EAAE,EAAE;IAC1F,MAAM,aAAa,GAAG,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC;IAC5C,MAAM,OAAO,GAAI,IAAI,CAAC,GAAG,CAAC;IAC1B,MAAM,4BAA4B,GAAG,GAAG,EAAE,GAAG,OAAO,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;IAClF,MAAM,QAAQ,GAAG,cAAc,CAAC,aAAa,EAAE,4BAA4B,CAAC,CAAC;IAC7E,OAAO,EAAE,KAAK,EAAC,QAAQ,EAAE,CAAC;AAC5B,CAAC,CAAA"}
|
package/dist/OidcProvider.js
CHANGED
|
@@ -1,161 +1,127 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.OidcProvider = void 0;
|
|
30
|
-
var react_1 = __importStar(require("react"));
|
|
31
|
-
var oidc_1 = __importDefault(require("./vanilla/oidc"));
|
|
32
|
-
var OidcRoutes_1 = __importDefault(require("./core/routes/OidcRoutes"));
|
|
33
|
-
var index_1 = require("./core/default-component/index");
|
|
34
|
-
var ServiceWorkerNotSupported_component_1 = __importDefault(require("./core/default-component/ServiceWorkerNotSupported.component"));
|
|
35
|
-
var AuthenticateError_component_1 = __importDefault(require("./core/default-component/AuthenticateError.component"));
|
|
36
|
-
var defaultEventState = { name: "", data: null };
|
|
37
|
-
var OidcSession = function (_a) {
|
|
38
|
-
var loadingComponent = _a.loadingComponent, children = _a.children, configurationName = _a.configurationName;
|
|
39
|
-
var _b = (0, react_1.useState)(true), loading = _b[0], setLoading = _b[1];
|
|
40
|
-
var getOidc = oidc_1.default.get;
|
|
41
|
-
var oidc = getOidc(configurationName);
|
|
42
|
-
(0, react_1.useEffect)(function () {
|
|
43
|
-
var isMounted = true;
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import Oidc from './vanilla/oidc';
|
|
3
|
+
import OidcRoutes from './core/routes/OidcRoutes';
|
|
4
|
+
import { Authenticating, SessionLost, Loading, CallBackSuccess } from './core/default-component/index';
|
|
5
|
+
import ServiceWorkerNotSupported from "./core/default-component/ServiceWorkerNotSupported.component";
|
|
6
|
+
import AuthenticatingError from "./core/default-component/AuthenticateError.component";
|
|
7
|
+
const defaultEventState = { name: "", data: null };
|
|
8
|
+
const OidcSession = ({ loadingComponent, children, configurationName }) => {
|
|
9
|
+
const [loading, setLoading] = useState(true);
|
|
10
|
+
const getOidc = Oidc.get;
|
|
11
|
+
const oidc = getOidc(configurationName);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
let isMounted = true;
|
|
44
14
|
if (oidc) {
|
|
45
|
-
oidc.tryKeepExistingSessionAsync().then(
|
|
15
|
+
oidc.tryKeepExistingSessionAsync().then(() => {
|
|
46
16
|
if (isMounted) {
|
|
47
17
|
setLoading(false);
|
|
48
18
|
}
|
|
49
19
|
});
|
|
50
20
|
}
|
|
51
|
-
return
|
|
21
|
+
return () => {
|
|
52
22
|
isMounted = false;
|
|
53
23
|
};
|
|
54
24
|
}, [oidc, configurationName]);
|
|
55
|
-
|
|
56
|
-
return (
|
|
25
|
+
const LoadingComponent = loadingComponent;
|
|
26
|
+
return (React.createElement(React.Fragment, null, loading ? (React.createElement(LoadingComponent, { configurationName: configurationName })) : (React.createElement(React.Fragment, null, children))));
|
|
57
27
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
var LoadingComponent = loadingComponent;
|
|
28
|
+
const Switch = ({ isLoading, loadingComponent, children, configurationName }) => {
|
|
29
|
+
const LoadingComponent = loadingComponent;
|
|
61
30
|
if (isLoading) {
|
|
62
|
-
return
|
|
31
|
+
return React.createElement(LoadingComponent, { configurationName: configurationName }, children);
|
|
63
32
|
}
|
|
64
|
-
return
|
|
33
|
+
return React.createElement(React.Fragment, null, children);
|
|
65
34
|
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (configurationName === void 0) { configurationName = "default"; }
|
|
70
|
-
return oidc_1.default.getOrCreate(configuration, configurationName);
|
|
35
|
+
export const OidcProvider = ({ children, configuration, configurationName = "default", callbackSuccessComponent = CallBackSuccess, authenticatingComponent = Authenticating, loadingComponent = Loading, serviceWorkerNotSupportedComponent = ServiceWorkerNotSupported, authenticatingErrorComponent = AuthenticatingError, sessionLostComponent = SessionLost, onSessionLost = null, onLogoutFromAnotherTab = null, onLogoutFromSameTab = null, withCustomHistory = null, onEvent = null, }) => {
|
|
36
|
+
const getOidc = (configurationName = "default") => {
|
|
37
|
+
return Oidc.getOrCreate(configuration, configurationName);
|
|
71
38
|
};
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
39
|
+
const [loading, setLoading] = useState(true);
|
|
40
|
+
const [event, setEvent] = useState(defaultEventState);
|
|
41
|
+
const [currentConfigurationName, setConfigurationName] = useState("default");
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
const oidc = getOidc(configurationName);
|
|
44
|
+
const newSubscriptionId = oidc.subscriveEvents((name, data) => {
|
|
78
45
|
if (onEvent) {
|
|
79
46
|
onEvent(configurationName, name, data);
|
|
80
47
|
}
|
|
81
48
|
});
|
|
82
|
-
return
|
|
83
|
-
|
|
49
|
+
return () => {
|
|
50
|
+
const previousOidc = getOidc(configurationName);
|
|
84
51
|
previousOidc.removeEventSubscription(newSubscriptionId);
|
|
85
52
|
};
|
|
86
53
|
}, [configurationName, onEvent]);
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if (name ==
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
const oidc = getOidc(configurationName);
|
|
56
|
+
const newSubscriptionId = oidc.subscriveEvents((name, data) => {
|
|
57
|
+
if (name == Oidc.eventNames.refreshTokensAsync_error || name == Oidc.eventNames.syncTokensAsync_error) {
|
|
91
58
|
if (onSessionLost != null) {
|
|
92
59
|
onSessionLost();
|
|
93
60
|
return;
|
|
94
61
|
}
|
|
95
|
-
setEvent({ name
|
|
62
|
+
setEvent({ name, data });
|
|
96
63
|
}
|
|
97
|
-
else if (name ===
|
|
64
|
+
else if (name === Oidc.eventNames.logout_from_another_tab) {
|
|
98
65
|
if (onLogoutFromAnotherTab != null) {
|
|
99
66
|
onLogoutFromAnotherTab();
|
|
100
67
|
return;
|
|
101
68
|
}
|
|
102
|
-
setEvent({ name
|
|
69
|
+
setEvent({ name, data });
|
|
103
70
|
}
|
|
104
|
-
else if (name ===
|
|
71
|
+
else if (name === Oidc.eventNames.logout_from_same_tab) {
|
|
105
72
|
if (onLogoutFromSameTab != null) {
|
|
106
73
|
onLogoutFromSameTab();
|
|
107
74
|
return;
|
|
108
75
|
}
|
|
109
76
|
//setEvent({name, data});
|
|
110
77
|
}
|
|
111
|
-
else if (name ==
|
|
112
|
-
|| name ==
|
|
113
|
-
|| name ==
|
|
114
|
-
|| name ==
|
|
115
|
-
setEvent({ name
|
|
78
|
+
else if (name == Oidc.eventNames.loginAsync_begin
|
|
79
|
+
|| name == Oidc.eventNames.loginCallbackAsync_end
|
|
80
|
+
|| name == Oidc.eventNames.loginAsync_error
|
|
81
|
+
|| name == Oidc.eventNames.loginCallbackAsync_error) {
|
|
82
|
+
setEvent({ name, data });
|
|
116
83
|
}
|
|
117
|
-
else if (name ==
|
|
118
|
-
setEvent({ name
|
|
84
|
+
else if (name == Oidc.eventNames.service_worker_not_supported_by_browser && configuration.service_worker_only === true) {
|
|
85
|
+
setEvent({ name, data });
|
|
119
86
|
}
|
|
120
87
|
});
|
|
121
88
|
setConfigurationName(configurationName);
|
|
122
89
|
setLoading(false);
|
|
123
|
-
return
|
|
124
|
-
|
|
90
|
+
return () => {
|
|
91
|
+
const previousOidc = getOidc(configurationName);
|
|
125
92
|
previousOidc.removeEventSubscription(newSubscriptionId);
|
|
126
93
|
setEvent(defaultEventState);
|
|
127
94
|
};
|
|
128
95
|
}, [configuration, configurationName]);
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
96
|
+
const SessionLostComponent = sessionLostComponent;
|
|
97
|
+
const AuthenticatingComponent = authenticatingComponent;
|
|
98
|
+
const LoadingComponent = loadingComponent;
|
|
99
|
+
const ServiceWorkerNotSupportedComponent = serviceWorkerNotSupportedComponent;
|
|
100
|
+
const AuthenticatingErrorComponent = authenticatingErrorComponent;
|
|
101
|
+
const isLoading = (loading || (currentConfigurationName != configurationName));
|
|
102
|
+
const oidc = getOidc(configurationName);
|
|
103
|
+
let eventName = event.name;
|
|
137
104
|
switch (eventName) {
|
|
138
|
-
case
|
|
139
|
-
return
|
|
140
|
-
|
|
141
|
-
case
|
|
142
|
-
return
|
|
143
|
-
|
|
144
|
-
case
|
|
145
|
-
case
|
|
146
|
-
return
|
|
147
|
-
|
|
148
|
-
case
|
|
149
|
-
case
|
|
150
|
-
case
|
|
151
|
-
return
|
|
152
|
-
|
|
105
|
+
case Oidc.eventNames.service_worker_not_supported_by_browser:
|
|
106
|
+
return React.createElement(Switch, { loadingComponent: LoadingComponent, isLoading: isLoading, configurationName: configurationName },
|
|
107
|
+
React.createElement(ServiceWorkerNotSupportedComponent, { configurationName: configurationName }));
|
|
108
|
+
case Oidc.eventNames.loginAsync_begin:
|
|
109
|
+
return React.createElement(Switch, { loadingComponent: LoadingComponent, isLoading: isLoading, configurationName: configurationName },
|
|
110
|
+
React.createElement(AuthenticatingComponent, { configurationName: configurationName }));
|
|
111
|
+
case Oidc.eventNames.loginAsync_error:
|
|
112
|
+
case Oidc.eventNames.loginCallbackAsync_error:
|
|
113
|
+
return React.createElement(Switch, { loadingComponent: LoadingComponent, isLoading: isLoading, configurationName: configurationName },
|
|
114
|
+
React.createElement(AuthenticatingErrorComponent, { configurationName: configurationName }));
|
|
115
|
+
case Oidc.eventNames.refreshTokensAsync_error:
|
|
116
|
+
case Oidc.eventNames.syncTokensAsync_error:
|
|
117
|
+
case Oidc.eventNames.logout_from_another_tab:
|
|
118
|
+
return React.createElement(Switch, { loadingComponent: LoadingComponent, isLoading: isLoading, configurationName: configurationName },
|
|
119
|
+
React.createElement(SessionLostComponent, { configurationName: configurationName }));
|
|
153
120
|
default:
|
|
154
|
-
return (
|
|
155
|
-
|
|
156
|
-
|
|
121
|
+
return (React.createElement(Switch, { loadingComponent: LoadingComponent, isLoading: isLoading, configurationName: configurationName },
|
|
122
|
+
React.createElement(OidcRoutes, { redirect_uri: oidc.configuration.redirect_uri, silent_redirect_uri: oidc.configuration.silent_redirect_uri, silent_login_uri: oidc.configuration.silent_login_uri, callbackSuccessComponent: callbackSuccessComponent, callbackErrorComponent: authenticatingErrorComponent, authenticatingComponent: authenticatingComponent, configurationName: configurationName, withCustomHistory: withCustomHistory },
|
|
123
|
+
React.createElement(OidcSession, { loadingComponent: LoadingComponent, configurationName: configurationName }, children))));
|
|
157
124
|
}
|
|
158
125
|
};
|
|
159
|
-
|
|
160
|
-
exports.default = exports.OidcProvider;
|
|
126
|
+
export default OidcProvider;
|
|
161
127
|
//# sourceMappingURL=OidcProvider.js.map
|
package/dist/OidcProvider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OidcProvider.js","sourceRoot":"","sources":["../src/oidc/OidcProvider.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"OidcProvider.js","sourceRoot":"","sources":["../src/oidc/OidcProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAuC,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AACvF,OAAO,IAAyB,MAAM,gBAAgB,CAAC;AACvD,OAAO,UAAU,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAC,cAAc,EAAqB,WAAW,EAAE,OAAO,EAAE,eAAe,EAAC,MAAM,gCAAgC,CAAC;AACxH,OAAO,yBAAyB,MAAM,8DAA8D,CAAC;AACrG,OAAO,mBAAmB,MAAM,sDAAsD,CAAC;AAOvF,MAAM,iBAAiB,GAAG,EAAC,IAAI,EAAC,EAAE,EAAE,IAAI,EAAC,IAAI,EAAC,CAAC;AAyB/C,MAAM,WAAW,GAA6C,CAAC,EAAC,gBAAgB,EAAE,QAAQ,EAAE,iBAAiB,EAAC,EAAE,EAAE;IAC9G,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,OAAO,GAAI,IAAI,CAAC,GAAG,CAAC;IAC1B,MAAM,IAAI,GAAG,OAAO,CAAC,iBAAi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-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
-
}
|
|
19
|
-
Object.defineProperty(o, k2, desc);
|
|
20
|
-
}) : (function(o, m, k, k2) {
|
|
21
|
-
if (k2 === undefined) k2 = k;
|
|
22
|
-
o[k2] = m[k];
|
|
23
|
-
}));
|
|
24
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
-
}) : function(o, v) {
|
|
27
|
-
o["default"] = v;
|
|
28
|
-
});
|
|
29
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
-
if (mod && mod.__esModule) return mod;
|
|
31
|
-
var result = {};
|
|
32
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
-
__setModuleDefault(result, mod);
|
|
34
|
-
return result;
|
|
35
|
-
};
|
|
36
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
-
};
|
|
39
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
exports.withOidcSecure = exports.OidcSecure = void 0;
|
|
41
|
-
var react_1 = __importStar(require("react"));
|
|
42
|
-
var oidc_1 = __importDefault(require("./vanilla/oidc"));
|
|
43
|
-
var OidcSecure = function (_a) {
|
|
44
|
-
var children = _a.children, _b = _a.callbackPath, callbackPath = _b === void 0 ? null : _b, _c = _a.extras, extras = _c === void 0 ? null : _c, _d = _a.configurationName, configurationName = _d === void 0 ? "default" : _d;
|
|
45
|
-
var getOidc = oidc_1.default.get;
|
|
46
|
-
var oidc = getOidc(configurationName);
|
|
47
|
-
(0, react_1.useEffect)(function () {
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import Oidc from "./vanilla/oidc";
|
|
3
|
+
export const OidcSecure = ({ children, callbackPath = null, extras = null, configurationName = "default" }) => {
|
|
4
|
+
const getOidc = Oidc.get;
|
|
5
|
+
const oidc = getOidc(configurationName);
|
|
6
|
+
useEffect(() => {
|
|
48
7
|
if (!oidc.tokens) {
|
|
49
8
|
oidc.loginAsync(callbackPath, extras);
|
|
50
9
|
}
|
|
51
|
-
return
|
|
10
|
+
return () => {
|
|
52
11
|
};
|
|
53
12
|
}, [configurationName, callbackPath, extras]);
|
|
54
13
|
if (!oidc.tokens) {
|
|
55
14
|
return null;
|
|
56
15
|
}
|
|
57
|
-
return
|
|
16
|
+
return React.createElement(React.Fragment, null, children);
|
|
58
17
|
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (extras === void 0) { extras = null; }
|
|
63
|
-
if (configurationName === void 0) { configurationName = "default"; }
|
|
64
|
-
if (state === void 0) { state = undefined; }
|
|
65
|
-
return function (props) {
|
|
66
|
-
return react_1.default.createElement(exports.OidcSecure, { state: state, callbackPath: callbackPath, extras: extras, configurationName: configurationName },
|
|
67
|
-
react_1.default.createElement(WrappedComponent, __assign({}, props)));
|
|
68
|
-
};
|
|
18
|
+
export const withOidcSecure = (WrappedComponent, callbackPath = null, extras = null, configurationName = "default", state = undefined) => (props) => {
|
|
19
|
+
return React.createElement(OidcSecure, { state: state, callbackPath: callbackPath, extras: extras, configurationName: configurationName },
|
|
20
|
+
React.createElement(WrappedComponent, Object.assign({}, props)));
|
|
69
21
|
};
|
|
70
|
-
exports.withOidcSecure = withOidcSecure;
|
|
71
22
|
//# sourceMappingURL=OidcSecure.js.map
|
package/dist/OidcSecure.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OidcSecure.js","sourceRoot":"","sources":["../src/oidc/OidcSecure.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"OidcSecure.js","sourceRoot":"","sources":["../src/oidc/OidcSecure.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAC,SAAS,EAAwB,MAAM,OAAO,CAAC;AAE9D,OAAO,IAAiB,MAAM,gBAAgB,CAAC;AAS/C,MAAM,CAAC,MAAM,UAAU,GAA2C,CAAC,EAAC,QAAQ,EAAE,YAAY,GAAC,IAAI,EAAE,MAAM,GAAC,IAAI,EAAE,iBAAiB,GAAC,SAAS,EAAC,EAAE,EAAE;IAC1I,MAAM,OAAO,GAAI,IAAI,CAAC,GAAG,CAAC;IAC1B,MAAM,IAAI,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACxC,SAAS,CAAC,GAAG,EAAE;QACX,IAAG,CAAC,IAAI,CAAC,MAAM,EAAC;YACZ,IAAI,CAAC,UAAU,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;SACzC;QACD,OAAO,GAAG,EAAE;QACZ,CAAC,CAAA;IACL,CAAC,EAAE,CAAC,iBAAiB,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC,CAAA;IAE7C,IAAG,CAAC,IAAI,CAAC,MAAM,EAAC;QACd,OAAO,IAAI,CAAC;KACb;IACD,OAAO,0CAAG,QAAQ,CAAI,CAAA;AAC1B,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,gBAAwD,EACxD,YAAY,GAAC,IAAI,EACjB,MAAM,GAAC,IAAI,EACX,iBAAiB,GAAC,SAAS,EAC3B,QAAwB,SAAS,EACjC,EAAE,CAAC,CAAC,KAAK,EAAE,EAAE;IACb,OAAO,oBAAC,UAAU,IAAC,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,iBAAiB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