piral-oidc 1.9.0-beta.8186 → 1.9.0-beta.8196
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/lib/setup.js +9 -8
- package/lib/setup.js.map +1 -1
- package/lib/types.d.ts +3 -3
- package/package.json +4 -4
- package/piral-oidc.min.js +1 -107
- package/src/setup.test.ts +1 -1
- package/src/setup.ts +12 -8
- package/src/types.ts +3 -3
package/src/setup.test.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @vitest-environment jsdom
|
|
3
3
|
*/
|
|
4
4
|
import { describe, it, expect, vitest, beforeAll, beforeEach, afterAll } from 'vitest';
|
|
5
|
-
import { UserManager } from 'oidc-client';
|
|
5
|
+
import { UserManager } from 'oidc-client-ts';
|
|
6
6
|
import { setupOidcClient } from './setup';
|
|
7
7
|
import { OidcConfig, OidcErrorType } from './types';
|
|
8
8
|
|
package/src/setup.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Log, User, UserManager } from 'oidc-client';
|
|
1
|
+
import { Log, User, UserManager, Logger } from 'oidc-client-ts';
|
|
2
2
|
import { OidcError } from './OidcError';
|
|
3
3
|
import { AuthenticationResult, LogLevel, OidcClient, OidcConfig, OidcErrorType, OidcProfile } from './types';
|
|
4
4
|
|
|
@@ -67,11 +67,11 @@ export function setupOidcClient(config: OidcConfig): OidcClient {
|
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
if (logLevel !== undefined) {
|
|
70
|
-
Log.
|
|
71
|
-
Log.
|
|
70
|
+
Log.setLogger(console);
|
|
71
|
+
Log.setLevel(convertLogLevelToOidcClient(logLevel));
|
|
72
72
|
} else if (process.env.NODE_ENV === 'development') {
|
|
73
|
-
Log.
|
|
74
|
-
Log.
|
|
73
|
+
Log.setLogger(console);
|
|
74
|
+
Log.setLevel(Log.DEBUG);
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
if (doesWindowLocationMatch(userManager.settings.post_logout_redirect_uri)) {
|
|
@@ -126,6 +126,7 @@ export function setupOidcClient(config: OidcConfig): OidcClient {
|
|
|
126
126
|
new Promise(async (resolve, reject) => {
|
|
127
127
|
/** The user that is resolved when finishing the callback */
|
|
128
128
|
let user: User;
|
|
129
|
+
|
|
129
130
|
if (
|
|
130
131
|
(doesWindowLocationMatch(userManager.settings.silent_redirect_uri) ||
|
|
131
132
|
doesWindowLocationMatch(userManager.settings.popup_redirect_uri)) &&
|
|
@@ -137,10 +138,12 @@ export function setupOidcClient(config: OidcConfig): OidcClient {
|
|
|
137
138
|
* to update the parent. This is usually due to a timeout from a network error.
|
|
138
139
|
*/
|
|
139
140
|
try {
|
|
140
|
-
|
|
141
|
+
await userManager.signinSilentCallback();
|
|
142
|
+
user = await userManager.getUser();
|
|
141
143
|
} catch (e) {
|
|
142
144
|
return reject(new OidcError(OidcErrorType.oidcCallback, e));
|
|
143
145
|
}
|
|
146
|
+
|
|
144
147
|
return resolve({
|
|
145
148
|
shouldRender: false,
|
|
146
149
|
state: user?.state,
|
|
@@ -159,8 +162,9 @@ export function setupOidcClient(config: OidcConfig): OidcClient {
|
|
|
159
162
|
}
|
|
160
163
|
|
|
161
164
|
if (appUri) {
|
|
162
|
-
|
|
165
|
+
Logger.debug(`Redirecting to ${appUri} due to appUri being configured.`);
|
|
163
166
|
window.location.href = appUri;
|
|
167
|
+
|
|
164
168
|
return resolve({
|
|
165
169
|
shouldRender: false,
|
|
166
170
|
state: user?.state,
|
|
@@ -220,7 +224,7 @@ export function setupOidcClient(config: OidcConfig): OidcClient {
|
|
|
220
224
|
return userManager.signoutRedirect();
|
|
221
225
|
},
|
|
222
226
|
revoke() {
|
|
223
|
-
return userManager.
|
|
227
|
+
return userManager.revokeTokens();
|
|
224
228
|
},
|
|
225
229
|
handleAuthentication,
|
|
226
230
|
extendHeaders(req) {
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type {} from 'piral-core';
|
|
2
|
-
import type {
|
|
2
|
+
import type { UserProfile, StateStore } from 'oidc-client-ts';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Available configuration options for the OpenID Connect plugin.
|
|
@@ -52,7 +52,7 @@ export interface OidcConfig {
|
|
|
52
52
|
* via the responseType. By default, the responseType `code` will
|
|
53
53
|
* get `query` and responseType `token` will get `fragment`.
|
|
54
54
|
*/
|
|
55
|
-
responseMode?:
|
|
55
|
+
responseMode?: 'query' | 'fragment';
|
|
56
56
|
/**
|
|
57
57
|
* The scopes to be used. By default, `openid` is used.
|
|
58
58
|
*/
|
|
@@ -150,7 +150,7 @@ export interface PiralCustomOidcProfile {}
|
|
|
150
150
|
/**
|
|
151
151
|
* The defined OIDC profile.
|
|
152
152
|
*/
|
|
153
|
-
export type OidcProfile = PiralCustomOidcProfile &
|
|
153
|
+
export type OidcProfile = PiralCustomOidcProfile & UserProfile;
|
|
154
154
|
|
|
155
155
|
export interface OidcRequest {
|
|
156
156
|
/**
|