@react-keycloak-refork/core 6.0.0 → 8.0.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/LICENSE.md +24 -24
- package/README.md +149 -150
- package/lib/context.d.ts +23 -24
- package/lib/context.js +23 -23
- package/lib/index.d.ts +3 -3
- package/lib/index.js +4 -4
- package/lib/provider.d.ts +127 -132
- package/lib/provider.js +146 -145
- package/lib/provider.js.map +1 -1
- package/lib/types.d.ts +80 -80
- package/lib/types.js +1 -1
- package/lib-commonjs/context.d.ts +23 -24
- package/lib-commonjs/context.js +26 -27
- package/lib-commonjs/context.js.map +1 -1
- package/lib-commonjs/index.d.ts +3 -3
- package/lib-commonjs/index.js +20 -20
- package/lib-commonjs/provider.d.ts +127 -132
- package/lib-commonjs/provider.js +185 -175
- package/lib-commonjs/provider.js.map +1 -1
- package/lib-commonjs/types.d.ts +80 -80
- package/lib-commonjs/types.js +2 -2
- package/package.json +11 -7
package/lib-commonjs/provider.js
CHANGED
|
@@ -1,176 +1,186 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __assign = (this && this.__assign) || function () {
|
|
18
|
-
__assign = Object.assign || function(t) {
|
|
19
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
-
s = arguments[i];
|
|
21
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
-
t[p] = s[p];
|
|
23
|
-
}
|
|
24
|
-
return t;
|
|
25
|
-
};
|
|
26
|
-
return __assign.apply(this, arguments);
|
|
27
|
-
};
|
|
28
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
29
|
-
if (k2 === undefined) k2 = k;
|
|
30
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
31
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
32
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
33
|
-
}
|
|
34
|
-
Object.defineProperty(o, k2, desc);
|
|
35
|
-
}) : (function(o, m, k, k2) {
|
|
36
|
-
if (k2 === undefined) k2 = k;
|
|
37
|
-
o[k2] = m[k];
|
|
38
|
-
}));
|
|
39
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
40
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
41
|
-
}) : function(o, v) {
|
|
42
|
-
o["default"] = v;
|
|
43
|
-
});
|
|
44
|
-
var __importStar = (this && this.__importStar) || function (
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
var
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
// Notify
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
29
|
+
if (k2 === undefined) k2 = k;
|
|
30
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
31
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
32
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
33
|
+
}
|
|
34
|
+
Object.defineProperty(o, k2, desc);
|
|
35
|
+
}) : (function(o, m, k, k2) {
|
|
36
|
+
if (k2 === undefined) k2 = k;
|
|
37
|
+
o[k2] = m[k];
|
|
38
|
+
}));
|
|
39
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
40
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
41
|
+
}) : function(o, v) {
|
|
42
|
+
o["default"] = v;
|
|
43
|
+
});
|
|
44
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
45
|
+
var ownKeys = function(o) {
|
|
46
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
47
|
+
var ar = [];
|
|
48
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
49
|
+
return ar;
|
|
50
|
+
};
|
|
51
|
+
return ownKeys(o);
|
|
52
|
+
};
|
|
53
|
+
return function (mod) {
|
|
54
|
+
if (mod && mod.__esModule) return mod;
|
|
55
|
+
var result = {};
|
|
56
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
57
|
+
__setModuleDefault(result, mod);
|
|
58
|
+
return result;
|
|
59
|
+
};
|
|
60
|
+
})();
|
|
61
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
62
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
63
|
+
};
|
|
64
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
65
|
+
exports.createAuthProvider = createAuthProvider;
|
|
66
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
67
|
+
var React = __importStar(require("react"));
|
|
68
|
+
var react_fast_compare_1 = __importDefault(require("react-fast-compare"));
|
|
69
|
+
/**
|
|
70
|
+
* Create an AuthProvider component to wrap a React app with, it will take care of common AuthClient
|
|
71
|
+
* lifecycle handling (such as initialization and token refresh).
|
|
72
|
+
*
|
|
73
|
+
* @param AuthContext the Auth context to be used by the created AuthProvider
|
|
74
|
+
*
|
|
75
|
+
* @returns the AuthProvider component
|
|
76
|
+
*/
|
|
77
|
+
function createAuthProvider(AuthContext) {
|
|
78
|
+
var defaultInitOptions = {
|
|
79
|
+
onLoad: 'check-sso',
|
|
80
|
+
};
|
|
81
|
+
var initialState = {
|
|
82
|
+
initialized: false,
|
|
83
|
+
isAuthenticated: false,
|
|
84
|
+
isLoading: true,
|
|
85
|
+
};
|
|
86
|
+
return /** @class */ (function (_super) {
|
|
87
|
+
__extends(KeycloakProvider, _super);
|
|
88
|
+
function KeycloakProvider() {
|
|
89
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
90
|
+
_this.state = __assign({}, initialState);
|
|
91
|
+
_this.onError = function (event) { return function (error) {
|
|
92
|
+
var onEvent = _this.props.onEvent;
|
|
93
|
+
// Notify Events listener
|
|
94
|
+
onEvent && onEvent(event, error);
|
|
95
|
+
}; };
|
|
96
|
+
_this.updateState = function (event) { return function () {
|
|
97
|
+
var _a = _this.props, authClient = _a.authClient, onEvent = _a.onEvent, onTokens = _a.onTokens, isLoadingCheck = _a.isLoadingCheck;
|
|
98
|
+
var _b = _this.state, prevInitialized = _b.initialized, prevAuthenticated = _b.isAuthenticated, prevLoading = _b.isLoading;
|
|
99
|
+
// Notify Events listener
|
|
100
|
+
onEvent && onEvent(event);
|
|
101
|
+
// Check Loading state
|
|
102
|
+
var isLoading = isLoadingCheck ? isLoadingCheck(authClient) : false;
|
|
103
|
+
// Check if user is authenticated
|
|
104
|
+
var isAuthenticated = isUserAuthenticated(authClient);
|
|
105
|
+
// Avoid double-refresh if state hasn't changed
|
|
106
|
+
if (!prevInitialized ||
|
|
107
|
+
isAuthenticated !== prevAuthenticated ||
|
|
108
|
+
isLoading !== prevLoading) {
|
|
109
|
+
_this.setState({
|
|
110
|
+
initialized: true,
|
|
111
|
+
isAuthenticated: isAuthenticated,
|
|
112
|
+
isLoading: isLoading,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
// Notify token listener, if any
|
|
116
|
+
var idToken = authClient.idToken, refreshToken = authClient.refreshToken, token = authClient.token;
|
|
117
|
+
onTokens &&
|
|
118
|
+
onTokens({
|
|
119
|
+
idToken: idToken,
|
|
120
|
+
refreshToken: refreshToken,
|
|
121
|
+
token: token,
|
|
122
|
+
});
|
|
123
|
+
}; };
|
|
124
|
+
_this.refreshToken = function (event) { return function () {
|
|
125
|
+
var _a = _this.props, autoRefreshToken = _a.autoRefreshToken, authClient = _a.authClient, onEvent = _a.onEvent;
|
|
126
|
+
// Notify Events listener
|
|
127
|
+
onEvent && onEvent(event);
|
|
128
|
+
if (autoRefreshToken !== false) {
|
|
129
|
+
// Refresh Keycloak token
|
|
130
|
+
authClient.updateToken(5);
|
|
131
|
+
}
|
|
132
|
+
}; };
|
|
133
|
+
return _this;
|
|
134
|
+
}
|
|
135
|
+
KeycloakProvider.prototype.componentDidMount = function () {
|
|
136
|
+
this.init();
|
|
137
|
+
};
|
|
138
|
+
KeycloakProvider.prototype.componentDidUpdate = function (_a) {
|
|
139
|
+
var prevAuthClient = _a.authClient, prevInitOptions = _a.initOptions;
|
|
140
|
+
var _b = this.props, initOptions = _b.initOptions, authClient = _b.authClient;
|
|
141
|
+
if (authClient !== prevAuthClient ||
|
|
142
|
+
!(0, react_fast_compare_1.default)(initOptions, prevInitOptions)) {
|
|
143
|
+
// De-init previous AuthClient instance
|
|
144
|
+
prevAuthClient.onReady = undefined;
|
|
145
|
+
prevAuthClient.onAuthSuccess = undefined;
|
|
146
|
+
prevAuthClient.onAuthError = undefined;
|
|
147
|
+
prevAuthClient.onAuthRefreshSuccess = undefined;
|
|
148
|
+
prevAuthClient.onAuthRefreshError = undefined;
|
|
149
|
+
prevAuthClient.onAuthLogout = undefined;
|
|
150
|
+
prevAuthClient.onTokenExpired = undefined;
|
|
151
|
+
// Reset state
|
|
152
|
+
this.setState(__assign({}, initialState));
|
|
153
|
+
// Init new AuthClient instance
|
|
154
|
+
this.init();
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
KeycloakProvider.prototype.init = function () {
|
|
158
|
+
var _a = this.props, initOptions = _a.initOptions, authClient = _a.authClient;
|
|
159
|
+
// Attach Keycloak listeners
|
|
160
|
+
authClient.onReady = this.updateState('onReady');
|
|
161
|
+
authClient.onAuthSuccess = this.updateState('onAuthSuccess');
|
|
162
|
+
authClient.onAuthError = this.onError('onAuthError');
|
|
163
|
+
authClient.onAuthRefreshSuccess = this.updateState('onAuthRefreshSuccess');
|
|
164
|
+
authClient.onAuthRefreshError = this.onError('onAuthRefreshError');
|
|
165
|
+
authClient.onAuthLogout = this.updateState('onAuthLogout');
|
|
166
|
+
authClient.onTokenExpired = this.refreshToken('onTokenExpired');
|
|
167
|
+
authClient
|
|
168
|
+
.init(__assign(__assign({}, defaultInitOptions), initOptions))
|
|
169
|
+
.catch(this.onError('onInitError'));
|
|
170
|
+
};
|
|
171
|
+
KeycloakProvider.prototype.render = function () {
|
|
172
|
+
var _a = this.props, children = _a.children, authClient = _a.authClient, LoadingComponent = _a.LoadingComponent;
|
|
173
|
+
var _b = this.state, initialized = _b.initialized, isLoading = _b.isLoading;
|
|
174
|
+
if (!!LoadingComponent && (!initialized || isLoading)) {
|
|
175
|
+
return LoadingComponent;
|
|
176
|
+
}
|
|
177
|
+
return ((0, jsx_runtime_1.jsx)(AuthContext.Provider, { value: { initialized: initialized, authClient: authClient }, children: children }));
|
|
178
|
+
};
|
|
179
|
+
return KeycloakProvider;
|
|
180
|
+
}(React.PureComponent));
|
|
181
|
+
}
|
|
182
|
+
function isUserAuthenticated(authClient) {
|
|
183
|
+
return !!authClient.idToken && !!authClient.token;
|
|
184
|
+
}
|
|
185
|
+
exports.default = createAuthProvider;
|
|
176
186
|
//# sourceMappingURL=provider.js.map
|
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
"@react-keycloak-refork\\core\\provider.tsx"
|
|
7
7
|
],
|
|
8
8
|
"names": [],
|
|
9
|
-
"mappings": "
|
|
9
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwFA,gDA2IC;;AAnOD,2CAA8B;AAE9B,0E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E7C,IAAI,CAAC,CAAC,gBAAgB,IAAI,CAAC,CAAC,WAAW,IAAI,SAAS,CAAC,EAAE,CAAC;gBACtD,OAAO,gBAAgB,CAAA;YACzB,CAAC;YAED,OAAO,CACL,uBAAC,WAAW,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,WAAW,aAAA,EAAE,UAAU,YAAA,EAAE,YACrD,QAAQ,GACY,CACxB,CAAA;QACH,CAAC;QACH,uBAAC;IAAD,CAAC,AA7HM,CAA+B,KAAK,CAAC,aAAa,GA6HxD;AACH,CAAC;AAED,SAAS,mBAAmB,CAAC,UAAsB;IACjD,OAAO,CAAC,CAAC,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC,UAAU,CAAC,KAAK,CAAA;AACnD,CAAC;AAED,kBAAe,kBAAkB,CAAA"
|
|
10
10
|
}
|
package/lib-commonjs/types.d.ts
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
export interface AuthClientError {
|
|
2
|
-
error: string;
|
|
3
|
-
error_description: string;
|
|
4
|
-
}
|
|
5
|
-
export interface AuthClientInitOptions {
|
|
6
|
-
[paramName: string]: any;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* A client for the Auth server.
|
|
10
|
-
*/
|
|
11
|
-
export interface AuthClient {
|
|
12
|
-
/**
|
|
13
|
-
* The base64 encoded token that can be sent in the Authorization header in
|
|
14
|
-
* requests to services.
|
|
15
|
-
*/
|
|
16
|
-
token?: string;
|
|
17
|
-
/**
|
|
18
|
-
* The base64 encoded refresh token that can be used to retrieve a new token.
|
|
19
|
-
*/
|
|
20
|
-
refreshToken?: string;
|
|
21
|
-
/**
|
|
22
|
-
* The base64 encoded ID token.
|
|
23
|
-
*/
|
|
24
|
-
idToken?: string;
|
|
25
|
-
/**
|
|
26
|
-
* Called when the adapter is initialized.
|
|
27
|
-
*/
|
|
28
|
-
onReady?(authenticated?: boolean): void;
|
|
29
|
-
/**
|
|
30
|
-
* Called when a user is successfully authenticated.
|
|
31
|
-
*/
|
|
32
|
-
onAuthSuccess?(): void;
|
|
33
|
-
/**
|
|
34
|
-
* Called if there was an error during authentication.
|
|
35
|
-
*/
|
|
36
|
-
onAuthError?(errorData: AuthClientError): void;
|
|
37
|
-
/**
|
|
38
|
-
* Called when the token is refreshed.
|
|
39
|
-
*/
|
|
40
|
-
onAuthRefreshSuccess?(): void;
|
|
41
|
-
/**
|
|
42
|
-
* Called if there was an error while trying to refresh the token.
|
|
43
|
-
*/
|
|
44
|
-
onAuthRefreshError?(): void;
|
|
45
|
-
/**
|
|
46
|
-
* Called if the user is logged out (will only be called if the session
|
|
47
|
-
* status iframe is enabled, or in Cordova mode).
|
|
48
|
-
*/
|
|
49
|
-
onAuthLogout?(): void;
|
|
50
|
-
/**
|
|
51
|
-
* Called when the access token is expired. If a refresh token is available
|
|
52
|
-
* the token can be refreshed with Auth#updateToken, or in cases where
|
|
53
|
-
* it's not (ie. with implicit flow) you can redirect to login screen to
|
|
54
|
-
* obtain a new access token.
|
|
55
|
-
*/
|
|
56
|
-
onTokenExpired?(): void;
|
|
57
|
-
/**
|
|
58
|
-
* Called to initialize the adapter.
|
|
59
|
-
* @param initOptions Initialization options.
|
|
60
|
-
* @returns A promise to set functions to be invoked on success or error.
|
|
61
|
-
*/
|
|
62
|
-
init(initOptions: AuthClientInitOptions): Promise<boolean>;
|
|
63
|
-
/**
|
|
64
|
-
* If the token expires within `minValidity` seconds, the token is refreshed.
|
|
65
|
-
* If the session status iframe is enabled, the session status is also
|
|
66
|
-
* checked.
|
|
67
|
-
*
|
|
68
|
-
* @returns A promise to set functions that can be invoked if the token is
|
|
69
|
-
* still valid, or if the token is no longer valid.
|
|
70
|
-
*/
|
|
71
|
-
updateToken(minValidity: number): Promise<boolean>;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Set of tokens provided by AuthClient
|
|
75
|
-
*/
|
|
76
|
-
export type AuthClientTokens = Pick<AuthClient, 'idToken' | 'refreshToken' | 'token'>;
|
|
77
|
-
/**
|
|
78
|
-
* ReactAuth event types
|
|
79
|
-
*/
|
|
80
|
-
export type AuthClientEvent = 'onReady' | 'onInitError' | 'onAuthSuccess' | 'onAuthError' | 'onAuthRefreshSuccess' | 'onAuthRefreshError' | 'onAuthLogout' | 'onTokenExpired';
|
|
1
|
+
export interface AuthClientError {
|
|
2
|
+
error: string;
|
|
3
|
+
error_description: string;
|
|
4
|
+
}
|
|
5
|
+
export interface AuthClientInitOptions {
|
|
6
|
+
[paramName: string]: any;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A client for the Auth server.
|
|
10
|
+
*/
|
|
11
|
+
export interface AuthClient {
|
|
12
|
+
/**
|
|
13
|
+
* The base64 encoded token that can be sent in the Authorization header in
|
|
14
|
+
* requests to services.
|
|
15
|
+
*/
|
|
16
|
+
token?: string;
|
|
17
|
+
/**
|
|
18
|
+
* The base64 encoded refresh token that can be used to retrieve a new token.
|
|
19
|
+
*/
|
|
20
|
+
refreshToken?: string;
|
|
21
|
+
/**
|
|
22
|
+
* The base64 encoded ID token.
|
|
23
|
+
*/
|
|
24
|
+
idToken?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Called when the adapter is initialized.
|
|
27
|
+
*/
|
|
28
|
+
onReady?(authenticated?: boolean): void;
|
|
29
|
+
/**
|
|
30
|
+
* Called when a user is successfully authenticated.
|
|
31
|
+
*/
|
|
32
|
+
onAuthSuccess?(): void;
|
|
33
|
+
/**
|
|
34
|
+
* Called if there was an error during authentication.
|
|
35
|
+
*/
|
|
36
|
+
onAuthError?(errorData: AuthClientError): void;
|
|
37
|
+
/**
|
|
38
|
+
* Called when the token is refreshed.
|
|
39
|
+
*/
|
|
40
|
+
onAuthRefreshSuccess?(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Called if there was an error while trying to refresh the token.
|
|
43
|
+
*/
|
|
44
|
+
onAuthRefreshError?(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Called if the user is logged out (will only be called if the session
|
|
47
|
+
* status iframe is enabled, or in Cordova mode).
|
|
48
|
+
*/
|
|
49
|
+
onAuthLogout?(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Called when the access token is expired. If a refresh token is available
|
|
52
|
+
* the token can be refreshed with Auth#updateToken, or in cases where
|
|
53
|
+
* it's not (ie. with implicit flow) you can redirect to login screen to
|
|
54
|
+
* obtain a new access token.
|
|
55
|
+
*/
|
|
56
|
+
onTokenExpired?(): void;
|
|
57
|
+
/**
|
|
58
|
+
* Called to initialize the adapter.
|
|
59
|
+
* @param initOptions Initialization options.
|
|
60
|
+
* @returns A promise to set functions to be invoked on success or error.
|
|
61
|
+
*/
|
|
62
|
+
init(initOptions: AuthClientInitOptions): Promise<boolean>;
|
|
63
|
+
/**
|
|
64
|
+
* If the token expires within `minValidity` seconds, the token is refreshed.
|
|
65
|
+
* If the session status iframe is enabled, the session status is also
|
|
66
|
+
* checked.
|
|
67
|
+
*
|
|
68
|
+
* @returns A promise to set functions that can be invoked if the token is
|
|
69
|
+
* still valid, or if the token is no longer valid.
|
|
70
|
+
*/
|
|
71
|
+
updateToken(minValidity: number): Promise<boolean>;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Set of tokens provided by AuthClient
|
|
75
|
+
*/
|
|
76
|
+
export type AuthClientTokens = Pick<AuthClient, 'idToken' | 'refreshToken' | 'token'>;
|
|
77
|
+
/**
|
|
78
|
+
* ReactAuth event types
|
|
79
|
+
*/
|
|
80
|
+
export type AuthClientEvent = 'onReady' | 'onInitError' | 'onAuthSuccess' | 'onAuthError' | 'onAuthRefreshSuccess' | 'onAuthRefreshError' | 'onAuthLogout' | 'onTokenExpired';
|
package/lib-commonjs/types.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
//# sourceMappingURL=types.js.map
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-keycloak-refork/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"description": "Fork of https://github.com/react-keycloak/react-keycloak.git with updated packages for Keycloak >=
|
|
5
|
+
"description": "Fork of https://github.com/react-keycloak/react-keycloak.git with updated packages for Keycloak >=19. React bindings for Keycloak javascript adapter (core)",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/leoluzh/react-keycloak-fork.git"
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
"lib-commonjs"
|
|
27
27
|
],
|
|
28
28
|
"publishConfig": {
|
|
29
|
-
"access": "public"
|
|
29
|
+
"access": "public",
|
|
30
|
+
"registry": "https://registry.npmjs.org/"
|
|
30
31
|
},
|
|
31
32
|
"scripts": {
|
|
32
33
|
"clean": "rimraf lib lib-commonjs",
|
|
@@ -42,14 +43,17 @@
|
|
|
42
43
|
"prepublishOnly": "npm run build && cp ../../README.md . && cp ../../LICENSE.md ."
|
|
43
44
|
},
|
|
44
45
|
"peerDependencies": {
|
|
45
|
-
"react": ">=
|
|
46
|
+
"react": ">=19"
|
|
46
47
|
},
|
|
47
48
|
"dependencies": {
|
|
48
|
-
"react-fast-compare": "^3.2.
|
|
49
|
+
"react-fast-compare": "^3.2.2"
|
|
49
50
|
},
|
|
50
51
|
"jest": {
|
|
51
52
|
"preset": "ts-jest",
|
|
52
|
-
"testEnvironment": "jsdom"
|
|
53
|
+
"testEnvironment": "jsdom",
|
|
54
|
+
"setupFilesAfterEnv": [
|
|
55
|
+
"<rootDir>/test/test-utils.tsx"
|
|
56
|
+
]
|
|
53
57
|
},
|
|
54
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "7c156b0d876f2fae1ab076ac53c3730f7ba59cf9"
|
|
55
59
|
}
|