piral-oidc 1.9.0-beta.8186 → 1.9.0-beta.8209

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/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.logger = console;
71
- Log.level = convertLogLevelToOidcClient(logLevel);
70
+ Log.setLogger(console);
71
+ Log.setLevel(convertLogLevelToOidcClient(logLevel));
72
72
  } else if (process.env.NODE_ENV === 'development') {
73
- Log.logger = console;
74
- Log.level = Log.DEBUG;
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
- user = await userManager.signinSilentCallback();
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
- Log.debug(`Redirecting to ${appUri} due to appUri being configured.`);
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.revokeAccessToken();
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 { Profile, StateStore } from 'oidc-client';
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?: string;
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 & Profile;
153
+ export type OidcProfile = PiralCustomOidcProfile & UserProfile;
154
154
 
155
155
  export interface OidcRequest {
156
156
  /**