piral-oidc 1.0.0-pre.2036 → 1.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/esm/types.js ADDED
@@ -0,0 +1,61 @@
1
+ /**
2
+ * The available log levels.
3
+ */
4
+ export var LogLevel;
5
+ (function (LogLevel) {
6
+ /**
7
+ * Logging disabled.
8
+ */
9
+ LogLevel["none"] = "none";
10
+ /**
11
+ * Only log on error.
12
+ */
13
+ LogLevel["error"] = "error";
14
+ /**
15
+ * Start logging when its at least a warning.
16
+ */
17
+ LogLevel["warn"] = "warn";
18
+ /**
19
+ * Already start logging on info level.
20
+ */
21
+ LogLevel["info"] = "info";
22
+ /**
23
+ * Log everything - good for debugging purposes.
24
+ */
25
+ LogLevel["debug"] = "debug";
26
+ })(LogLevel || (LogLevel = {}));
27
+ /**
28
+ * The available error types.
29
+ */
30
+ export var OidcErrorType;
31
+ (function (OidcErrorType) {
32
+ /**
33
+ * This error was thrown at some point during authentication, by the browser or by oidc-client
34
+ * and we are unable to handle it.
35
+ */
36
+ OidcErrorType["unknown"] = "unknown";
37
+ /**
38
+ * This error happens when the user does not have an access token during Authentication.
39
+ * It is an expected error, and should be handled during `handleAuthentication()` calls.
40
+ * If doing manual authentication, prompt the user to `login()` when receiving it.
41
+ */
42
+ OidcErrorType["notAuthorized"] = "notAuthorized";
43
+ /**
44
+ * This error happens when silent renew fails in the background. It is not expected, and
45
+ * signifies a network error or configuration problem.
46
+ */
47
+ OidcErrorType["silentRenewFailed"] = "silentRenewFailed";
48
+ /**
49
+ * This is an unexpected error that happens when the `token()` call retrieves a User from
50
+ * the user manager, but it does not have an access_token. This signifies a configuration
51
+ * error, make sure the correct `scopes` are supplied during configuration.
52
+ */
53
+ OidcErrorType["invalidToken"] = "invalidToken";
54
+ /**
55
+ * This error happened during an Open ID callback. This signifies a network or configuration error
56
+ * which is non-recoverable. This should be logged to a logging service, and the user should be
57
+ * prompted to logout().
58
+ */
59
+ OidcErrorType["oidcCallback"] = "oidcCallback";
60
+ })(OidcErrorType || (OidcErrorType = {}));
61
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAuGA;;GAEG;AACH,MAAM,CAAN,IAAY,QAqBX;AArBD,WAAY,QAAQ;IAClB;;OAEG;IACH,yBAAa,CAAA;IACb;;OAEG;IACH,2BAAe,CAAA;IACf;;OAEG;IACH,yBAAa,CAAA;IACb;;OAEG;IACH,yBAAa,CAAA;IACb;;OAEG;IACH,2BAAe,CAAA;AACjB,CAAC,EArBW,QAAQ,KAAR,QAAQ,QAqBnB;AA8FD;;GAEG;AACH,MAAM,CAAN,IAAY,aA6BX;AA7BD,WAAY,aAAa;IACvB;;;OAGG;IACH,oCAAmB,CAAA;IACnB;;;;OAIG;IACH,gDAA+B,CAAA;IAC/B;;;OAGG;IACH,wDAAuC,CAAA;IACvC;;;;OAIG;IACH,8CAA6B,CAAA;IAC7B;;;;OAIG;IACH,8CAA6B,CAAA;AAC/B,CAAC,EA7BW,aAAa,KAAb,aAAa,QA6BxB"}
package/lib/OidcError.js CHANGED
@@ -1,16 +1,14 @@
1
1
  "use strict";
2
- var _a;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.OidcError = void 0;
5
- var tslib_1 = require("tslib");
6
- var types_1 = require("./types");
7
- var errorMessageMap = (_a = {},
8
- _a[types_1.OidcErrorType.notAuthorized] = 'Not logged in. Please call `login()` to retrieve a token.',
9
- _a[types_1.OidcErrorType.silentRenewFailed] = 'Silent renew failed to retrieve access token.',
10
- _a[types_1.OidcErrorType.invalidToken] = 'Invalid token during authentication',
11
- _a);
12
- var getErrorMessage = function (type, innerError) {
13
- var message = errorMessageMap[type];
4
+ const types_1 = require("./types");
5
+ const errorMessageMap = {
6
+ [types_1.OidcErrorType.notAuthorized]: 'Not logged in. Please call `login()` to retrieve a token.',
7
+ [types_1.OidcErrorType.silentRenewFailed]: 'Silent renew failed to retrieve access token.',
8
+ [types_1.OidcErrorType.invalidToken]: 'Invalid token during authentication',
9
+ };
10
+ const getErrorMessage = (type, innerError) => {
11
+ const message = errorMessageMap[type];
14
12
  return message || (innerError ? innerError.toString() : 'an unexpected error has occurred without a message');
15
13
  };
16
14
  /**
@@ -20,21 +18,17 @@ var getErrorMessage = function (type, innerError) {
20
18
  * An optional innerError can be supplied in order to not lose visibility on messages provided
21
19
  * by oidc-client.
22
20
  */
23
- var OidcError = /** @class */ (function (_super) {
24
- tslib_1.__extends(OidcError, _super);
25
- function OidcError(errorType, innerError) {
26
- var _this = this;
27
- var message = getErrorMessage(errorType, innerError);
28
- _this = _super.call(this, message) || this;
21
+ class OidcError extends Error {
22
+ constructor(errorType, innerError) {
23
+ const message = getErrorMessage(errorType, innerError);
24
+ super(message);
29
25
  if (Error.captureStackTrace) {
30
- Error.captureStackTrace(_this, OidcError);
26
+ Error.captureStackTrace(this, OidcError);
31
27
  }
32
- _this.name = 'OidcError';
33
- _this.type = errorType;
34
- _this.innerError = innerError;
35
- return _this;
28
+ this.name = 'OidcError';
29
+ this.type = errorType;
30
+ this.innerError = innerError;
36
31
  }
37
- return OidcError;
38
- }(Error));
32
+ }
39
33
  exports.OidcError = OidcError;
40
34
  //# sourceMappingURL=OidcError.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"OidcError.js","sourceRoot":"","sources":["../src/OidcError.ts"],"names":[],"mappings":";;;;;AAAA,iCAAwD;AAExD,IAAM,eAAe;IACnB,GAAC,qBAAa,CAAC,aAAa,IAAG,2DAA2D;IAC1F,GAAC,qBAAa,CAAC,iBAAiB,IAAG,+CAA+C;IAClF,GAAC,qBAAa,CAAC,YAAY,IAAG,qCAAqC;OACpE,CAAC;AAEF,IAAM,eAAe,GAAG,UAAC,IAAmB,EAAE,UAA2B;IACvE,IAAM,OAAO,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IACtC,OAAO,OAAO,IAAI,CAAC,UA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/D,MAAM,OAAO,GAAG,eAAe,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QACvD,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,KAAK,CAAC,iBAAiB,EAAE;YAC3B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;SAC1C;QAED,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;QACtB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF;AAhBD,8BAgBC"}
package/lib/create.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { PiralPlugin } from 'piral-core';
2
- import { PiralOidcApi, OidcClient } from './types';
2
+ import { PiletOidcApi, OidcClient } from './types';
3
3
  /**
4
4
  * Creates new Pilet API extensions for the integration of OpenID Connect.
5
5
  */
6
- export declare function createOidcApi(client: OidcClient): PiralPlugin<PiralOidcApi>;
6
+ export declare function createOidcApi(client: OidcClient): PiralPlugin<PiletOidcApi>;
package/lib/create.js CHANGED
@@ -5,13 +5,13 @@ exports.createOidcApi = void 0;
5
5
  * Creates new Pilet API extensions for the integration of OpenID Connect.
6
6
  */
7
7
  function createOidcApi(client) {
8
- return function (context) {
8
+ return (context) => {
9
9
  context.on('before-fetch', client.extendHeaders);
10
10
  return {
11
- getAccessToken: function () {
11
+ getAccessToken() {
12
12
  return client.token();
13
13
  },
14
- getProfile: function () {
14
+ getProfile() {
15
15
  return client.account();
16
16
  },
17
17
  };
package/lib/create.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":";;;AAGA;;GAEG;AACH,SAAgB,aAAa,CAAC,MAAkB;IAC9C,OAAO,UAAC,OAAO;QACb,OAAO,CAAC,EAAE,CAAC,cAAc,EAAE,MAAM,CAAC,aAAa,CAAC,CAAC;QAEjD,OAAO;YACL,cAAc;gBACZ,OAAO,MAAM,CAAC,KAAK,EAAE,CAAC;YACxB,CAAC;YAED,UAAU;gBACR,OAAO,MAAM,CAAC,OAAO,EAAE,CAAC;YAC1B,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAdD,sCAcC"}
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":";;;AAGA;;GAEG;AACH,SAAgB,aAAa,CAAC,MAAkB;IAC9C,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,OAAO,CAAC,EAAE,CAAC,cAAc,EAAE,MAAM,CAAC,aAAa,CAAC,CAAC;QAEjD,OAAO;YACL,cAAc;gBACZ,OAAO,MAAM,CAAC,KAAK,EAAE,CAAC;YACxB,CAAC;YAED,UAAU;gBACR,OAAO,MAAM,CAAC,OAAO,EAAE,CAAC;YAC1B,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAdD,sCAcC"}
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
3
+ const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./create"), exports);
5
5
  tslib_1.__exportStar(require("./setup"), exports);
6
6
  tslib_1.__exportStar(require("./types"), exports);
package/lib/setup.js CHANGED
@@ -1,18 +1,17 @@
1
1
  "use strict";
2
- var _a;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.setupOidcClient = void 0;
5
- var tslib_1 = require("tslib");
6
- var oidc_client_1 = require("oidc-client");
7
- var OidcError_1 = require("./OidcError");
8
- var types_1 = require("./types");
9
- var logLevelToOidcMap = (_a = {},
10
- _a[types_1.LogLevel.none] = 0,
11
- _a[types_1.LogLevel.error] = 1,
12
- _a[types_1.LogLevel.warn] = 2,
13
- _a[types_1.LogLevel.info] = 3,
14
- _a[types_1.LogLevel.debug] = 4,
15
- _a);
4
+ const tslib_1 = require("tslib");
5
+ const oidc_client_1 = require("oidc-client");
6
+ const OidcError_1 = require("./OidcError");
7
+ const types_1 = require("./types");
8
+ const logLevelToOidcMap = {
9
+ [types_1.LogLevel.none]: 0,
10
+ [types_1.LogLevel.error]: 1,
11
+ [types_1.LogLevel.warn]: 2,
12
+ [types_1.LogLevel.info]: 3,
13
+ [types_1.LogLevel.debug]: 4,
14
+ };
16
15
  function doesWindowLocationMatch(targetUri) {
17
16
  return window.location.pathname === new URL(targetUri).pathname;
18
17
  }
@@ -24,10 +23,9 @@ function convertLogLevelToOidcClient(level) {
24
23
  * @param config The configuration for the client.
25
24
  */
26
25
  function setupOidcClient(config) {
27
- var _this = this;
28
- var clientId = config.clientId, clientSecret = config.clientSecret, identityProviderUri = config.identityProviderUri, _a = config.redirectUri, redirectUri = _a === void 0 ? location.origin + "/auth" : _a, signInRedirectParams = config.signInRedirectParams, _b = config.postLogoutRedirectUri, postLogoutRedirectUri = _b === void 0 ? location.origin : _b, responseType = config.responseType, scopes = config.scopes, _c = config.restrict, restrict = _c === void 0 ? false : _c, parentName = config.parentName, appUri = config.appUri, logLevel = config.logLevel, userStore = config.userStore;
29
- var isMainWindow = function () { var _a; return (parentName ? parentName === ((_a = window.parent) === null || _a === void 0 ? void 0 : _a.name) : window === window.top); };
30
- var userManager = new oidc_client_1.UserManager({
26
+ const { clientId, clientSecret, identityProviderUri, redirectUri = `${location.origin}/auth`, signInRedirectParams, postLogoutRedirectUri = location.origin, responseType, responseMode, scopes, restrict = false, parentName, appUri, logLevel, userStore, extraQueryParams, uiLocales, metadata, metadataUrl, monitorSession, } = config;
27
+ const isMainWindow = () => { var _a; return (parentName ? parentName === ((_a = window.parent) === null || _a === void 0 ? void 0 : _a.name) : window === window.top); };
28
+ const userManager = new oidc_client_1.UserManager({
31
29
  authority: identityProviderUri,
32
30
  redirect_uri: redirectUri,
33
31
  silent_redirect_uri: redirectUri,
@@ -37,7 +35,13 @@ function setupOidcClient(config) {
37
35
  client_secret: clientSecret,
38
36
  response_type: responseType,
39
37
  scope: scopes === null || scopes === void 0 ? void 0 : scopes.join(' '),
40
- userStore: userStore,
38
+ userStore,
39
+ extraQueryParams,
40
+ ui_locales: uiLocales,
41
+ response_mode: responseMode,
42
+ metadata,
43
+ metadataUrl,
44
+ monitorSession,
41
45
  });
42
46
  if (logLevel !== undefined) {
43
47
  oidc_client_1.Log.logger = console;
@@ -55,11 +59,11 @@ function setupOidcClient(config) {
55
59
  userManager.signoutPopupCallback();
56
60
  }
57
61
  }
58
- var retrieveToken = function () {
59
- return new Promise(function (res, rej) {
62
+ const retrieveToken = () => {
63
+ return new Promise((res, rej) => {
60
64
  userManager
61
65
  .getUser()
62
- .then(function (user) {
66
+ .then((user) => {
63
67
  if (!user) {
64
68
  rej(new OidcError_1.OidcError(types_1.OidcErrorType.notAuthorized));
65
69
  }
@@ -67,7 +71,7 @@ function setupOidcClient(config) {
67
71
  res(user.access_token);
68
72
  }
69
73
  else {
70
- return userManager.signinSilent().then(function (user) {
74
+ return userManager.signinSilent().then((user) => {
71
75
  if (!user) {
72
76
  return rej(new OidcError_1.OidcError(types_1.OidcErrorType.silentRenewFailed));
73
77
  }
@@ -78,141 +82,119 @@ function setupOidcClient(config) {
78
82
  });
79
83
  }
80
84
  })
81
- .catch(function (err) { return rej(new OidcError_1.OidcError(types_1.OidcErrorType.unknown, err)); });
85
+ .catch((err) => rej(new OidcError_1.OidcError(types_1.OidcErrorType.unknown, err)));
82
86
  });
83
87
  };
84
- var retrieveProfile = function () {
85
- return new Promise(function (res, rej) {
86
- userManager.getUser().then(function (user) {
88
+ const retrieveProfile = () => {
89
+ return new Promise((res, rej) => {
90
+ userManager.getUser().then((user) => {
87
91
  if (!user || user.expires_in <= 0) {
88
92
  return rej(new OidcError_1.OidcError(types_1.OidcErrorType.notAuthorized));
89
93
  }
90
94
  else {
91
95
  return res(user.profile);
92
96
  }
93
- }, function (err) { return rej(new OidcError_1.OidcError(types_1.OidcErrorType.unknown, err)); });
97
+ }, (err) => rej(new OidcError_1.OidcError(types_1.OidcErrorType.unknown, err)));
94
98
  });
95
99
  };
96
- var handleAuthentication = function () {
97
- return new Promise(function (resolve, reject) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
98
- var user, e_1, e_2;
99
- var _this = this;
100
- return tslib_1.__generator(this, function (_a) {
101
- switch (_a.label) {
102
- case 0:
103
- if (!((doesWindowLocationMatch(userManager.settings.silent_redirect_uri) ||
104
- doesWindowLocationMatch(userManager.settings.popup_redirect_uri)) &&
105
- !isMainWindow())) return [3 /*break*/, 5];
106
- _a.label = 1;
107
- case 1:
108
- _a.trys.push([1, 3, , 4]);
109
- return [4 /*yield*/, userManager.signinSilentCallback()];
110
- case 2:
111
- user = _a.sent();
112
- return [3 /*break*/, 4];
113
- case 3:
114
- e_1 = _a.sent();
115
- return [2 /*return*/, reject(new OidcError_1.OidcError(types_1.OidcErrorType.oidcCallback, e_1))];
116
- case 4: return [2 /*return*/, resolve({
117
- shouldRender: false,
118
- state: user === null || user === void 0 ? void 0 : user.state,
119
- })];
120
- case 5:
121
- if (!(doesWindowLocationMatch(userManager.settings.redirect_uri) && isMainWindow())) return [3 /*break*/, 10];
122
- _a.label = 6;
123
- case 6:
124
- _a.trys.push([6, 8, , 9]);
125
- return [4 /*yield*/, userManager.signinCallback()];
126
- case 7:
127
- user = _a.sent();
128
- return [3 /*break*/, 9];
129
- case 8:
130
- e_2 = _a.sent();
131
- /*
132
- * Failing to handle a sign-in callback is non-recoverable. The user is expected to call `logout()`, after
133
- * logging this error to their internal error-handling service. Usually, this is due to a misconfigured auth server.
134
- */
135
- return [2 /*return*/, reject(new OidcError_1.OidcError(types_1.OidcErrorType.oidcCallback, e_2))];
136
- case 9:
137
- if (appUri) {
138
- oidc_client_1.Log.debug("Redirecting to " + appUri + " due to appUri being configured.");
139
- window.location.href = appUri;
140
- return [2 /*return*/, resolve({
141
- shouldRender: false,
142
- state: user === null || user === void 0 ? void 0 : user.state,
143
- })];
144
- }
145
- /* If appUri is not configured, we let the user decide what to do after getting a session. */
146
- return [2 /*return*/, resolve({
147
- shouldRender: true,
148
- state: user === null || user === void 0 ? void 0 : user.state,
149
- })];
150
- case 10:
151
- /*
152
- * The current page is a normal flow, not a callback or signout. We should retrieve the current access_token,
153
- * or log the user in if there is no current session.
154
- * This branch of code should also tell the user to render the main application.
155
- */
156
- return [2 /*return*/, retrieveToken()
157
- .then(function (token) {
158
- if (token) {
159
- return resolve({ shouldRender: true });
160
- }
161
- else {
162
- /* We should never get into this state, retrieveToken() should reject if there is no token */
163
- return reject(new OidcError_1.OidcError(types_1.OidcErrorType.invalidToken));
164
- }
165
- })
166
- .catch(function (reason) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
167
- return tslib_1.__generator(this, function (_a) {
168
- switch (_a.label) {
169
- case 0:
170
- if (!(reason.type === types_1.OidcErrorType.notAuthorized)) return [3 /*break*/, 2];
171
- /*
172
- * Expected Error during normal code flow:
173
- * This is the first time logging in since a logout (or ever), instead of asking the user
174
- * to call `login()`, just perform it ourself here.
175
- *
176
- * The resolve shouldn't matter, as `signinRedirect` will redirect the browser location
177
- * to the user's configured redirectUri.
178
- */
179
- return [4 /*yield*/, userManager.signinRedirect(signInRedirectParams)];
180
- case 1:
181
- /*
182
- * Expected Error during normal code flow:
183
- * This is the first time logging in since a logout (or ever), instead of asking the user
184
- * to call `login()`, just perform it ourself here.
185
- *
186
- * The resolve shouldn't matter, as `signinRedirect` will redirect the browser location
187
- * to the user's configured redirectUri.
188
- */
189
- _a.sent();
190
- return [2 /*return*/, resolve({ shouldRender: false })];
191
- case 2:
192
- /*
193
- * Getting here is a non-recoverable error. It is up to the user to determine what to do.
194
- * Usually this is a result of failing to reach the authentication server, or a misconfigured
195
- * authentication server, or a bad clock skew (commonly caused by docker in windows).
196
- */
197
- return [2 /*return*/, reject(reason)];
198
- }
199
- });
200
- }); })];
201
- }
100
+ const handleAuthentication = () => new Promise((resolve, reject) => tslib_1.__awaiter(this, void 0, void 0, function* () {
101
+ /** The user that is resolved when finishing the callback */
102
+ let user;
103
+ if ((doesWindowLocationMatch(userManager.settings.silent_redirect_uri) ||
104
+ doesWindowLocationMatch(userManager.settings.popup_redirect_uri)) &&
105
+ !isMainWindow()) {
106
+ /*
107
+ * This is a silent redirect frame. The correct behavior is to notify the parent of the updated user,
108
+ * and then to do nothing else. Encountering an error here means the background IFrame failed
109
+ * to update the parent. This is usually due to a timeout from a network error.
110
+ */
111
+ try {
112
+ user = yield userManager.signinSilentCallback();
113
+ }
114
+ catch (e) {
115
+ return reject(new OidcError_1.OidcError(types_1.OidcErrorType.oidcCallback, e));
116
+ }
117
+ return resolve({
118
+ shouldRender: false,
119
+ state: user === null || user === void 0 ? void 0 : user.state,
202
120
  });
203
- }); });
204
- };
121
+ }
122
+ if (doesWindowLocationMatch(userManager.settings.redirect_uri) && isMainWindow()) {
123
+ try {
124
+ user = yield userManager.signinCallback();
125
+ }
126
+ catch (e) {
127
+ /*
128
+ * Failing to handle a sign-in callback is non-recoverable. The user is expected to call `logout()`, after
129
+ * logging this error to their internal error-handling service. Usually, this is due to a misconfigured auth server.
130
+ */
131
+ return reject(new OidcError_1.OidcError(types_1.OidcErrorType.oidcCallback, e));
132
+ }
133
+ if (appUri) {
134
+ oidc_client_1.Log.debug(`Redirecting to ${appUri} due to appUri being configured.`);
135
+ window.location.href = appUri;
136
+ return resolve({
137
+ shouldRender: false,
138
+ state: user === null || user === void 0 ? void 0 : user.state,
139
+ });
140
+ }
141
+ /* If appUri is not configured, we let the user decide what to do after getting a session. */
142
+ return resolve({
143
+ shouldRender: true,
144
+ state: user === null || user === void 0 ? void 0 : user.state,
145
+ });
146
+ }
147
+ /*
148
+ * The current page is a normal flow, not a callback or signout. We should retrieve the current access_token,
149
+ * or log the user in if there is no current session.
150
+ * This branch of code should also tell the user to render the main application.
151
+ */
152
+ return retrieveToken()
153
+ .then((token) => {
154
+ if (token) {
155
+ return resolve({ shouldRender: true });
156
+ }
157
+ else {
158
+ /* We should never get into this state, retrieveToken() should reject if there is no token */
159
+ return reject(new OidcError_1.OidcError(types_1.OidcErrorType.invalidToken));
160
+ }
161
+ })
162
+ .catch((reason) => tslib_1.__awaiter(this, void 0, void 0, function* () {
163
+ if (reason.type === types_1.OidcErrorType.notAuthorized) {
164
+ /*
165
+ * Expected Error during normal code flow:
166
+ * This is the first time logging in since a logout (or ever), instead of asking the user
167
+ * to call `login()`, just perform it ourself here.
168
+ *
169
+ * The resolve shouldn't matter, as `signinRedirect` will redirect the browser location
170
+ * to the user's configured redirectUri.
171
+ */
172
+ yield userManager.signinRedirect(signInRedirectParams);
173
+ return resolve({ shouldRender: false });
174
+ }
175
+ /*
176
+ * Getting here is a non-recoverable error. It is up to the user to determine what to do.
177
+ * Usually this is a result of failing to reach the authentication server, or a misconfigured
178
+ * authentication server, or a bad clock skew (commonly caused by docker in windows).
179
+ */
180
+ return reject(reason);
181
+ }));
182
+ }));
205
183
  return {
206
- login: function () {
184
+ _: userManager,
185
+ login() {
207
186
  return userManager.signinRedirect(signInRedirectParams);
208
187
  },
209
- logout: function () {
188
+ logout() {
210
189
  return userManager.signoutRedirect();
211
190
  },
212
- handleAuthentication: handleAuthentication,
213
- extendHeaders: function (req) {
191
+ revoke() {
192
+ return userManager.revokeAccessToken();
193
+ },
194
+ handleAuthentication,
195
+ extendHeaders(req) {
214
196
  if (!restrict) {
215
- req.setHeaders(retrieveToken().then(function (token) { return token && { Authorization: "Bearer " + token }; }, function () { return undefined; }));
197
+ req.setHeaders(retrieveToken().then((token) => token && { Authorization: `Bearer ${token}` }, () => undefined));
216
198
  }
217
199
  },
218
200
  token: retrieveToken,
package/lib/setup.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"setup.js","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":";;;;;AAAA,2CAAqD;AACrD,yCAAwC;AACxC,iCAA6G;AAE7G,IAAM,iBAAiB;IACrB,GAAC,gBAAQ,CAAC,IAAI,IAAG,CAAC;IAClB,GAAC,gBAAQ,CAAC,KAAK,IAAG,C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QACzC,CAAC;QACD,oBAAoB;QACpB,aAAa,CAAC,GAAG;YACf,IAAI,CAAC,QAAQ,EAAE;gBACb,GAAG,CAAC,UAAU,CACZ,aAAa,EAAE,CAAC,IAAI,CAClB,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,aAAa,EAAE,UAAU,KAAK,EAAE,EAAE,EACxD,GAAG,EAAE,CAAC,SAAS,CAChB,CACF,CAAC;aACH;QACH,CAAC;QACD,KAAK,EAAE,aAAa;QACpB,OAAO,EAAE,eAAe;KACzB,CAAC;AACJ,CAAC;AAtND,0CAsNC"}
package/lib/types.d.ts CHANGED
@@ -45,6 +45,12 @@ export interface OidcConfig {
45
45
  * is used.
46
46
  */
47
47
  responseType?: string;
48
+ /**
49
+ * The response mode, which is usually already configured well
50
+ * via the responseType. By default, the responseType `code` will
51
+ * get `query` and responseType `token` will get `fragment`.
52
+ */
53
+ responseMode?: string;
48
54
  /**
49
55
  * The scopes to be used. By default, `openid` is used.
50
56
  */
@@ -70,6 +76,26 @@ export interface OidcConfig {
70
76
  * This defaults to oidc-client's WebStorageStateStore, using sessionStorage as the internal store
71
77
  */
72
78
  userStore?: OidcStore;
79
+ /**
80
+ * Provides some extra query parameters. These are included in the authorization request.
81
+ */
82
+ extraQueryParams?: Record<string, any>;
83
+ /**
84
+ * Sets the optiopnal ui_locales parameter to set the language of the login page.
85
+ */
86
+ uiLocales?: string;
87
+ /**
88
+ * Sets the metadata if the OIDC service does not allow querying it for whatever reason.
89
+ */
90
+ metadata?: any;
91
+ /**
92
+ * Overrides the default metadata URL if the server does not follow the standard paths.
93
+ */
94
+ metadataUrl?: string;
95
+ /**
96
+ * Determines if the OIDCS session should be automatically monitored.
97
+ */
98
+ monitorSession?: boolean;
73
99
  }
74
100
  /**
75
101
  * The available log levels.
@@ -119,7 +145,7 @@ export interface PiralCustomOidcProfile {
119
145
  /**
120
146
  * The defined OIDC profile.
121
147
  */
122
- export declare type OidcProfile = PiralCustomOidcProfile & Profile;
148
+ export type OidcProfile = PiralCustomOidcProfile & Profile;
123
149
  export interface OidcRequest {
124
150
  /**
125
151
  * Sets the headers of the request.
@@ -128,6 +154,10 @@ export interface OidcRequest {
128
154
  setHeaders(headers: any): void;
129
155
  }
130
156
  export interface OidcClient {
157
+ /**
158
+ * The underlying OIDC client.
159
+ */
160
+ _: any;
131
161
  /**
132
162
  * Performs a login. Will do nothing when called from a non-top window.
133
163
  */
@@ -136,6 +166,10 @@ export interface OidcClient {
136
166
  * Performs a logout.
137
167
  */
138
168
  logout(): Promise<void>;
169
+ /**
170
+ * Revokes the access token.
171
+ */
172
+ revoke(): Promise<void>;
139
173
  /**
140
174
  * Performs a login when the app needs a new token, handles callbacks when on
141
175
  * a callback URL, and redirects into the app route if the client was configured with an `appUri`.
@@ -161,7 +195,7 @@ export interface OidcClient {
161
195
  */
162
196
  extendHeaders(req: OidcRequest): void;
163
197
  }
164
- export interface PiralOidcApi {
198
+ export interface PiletOidcApi {
165
199
  /**
166
200
  * Gets the currently valid access token, if any.
167
201
  */
@@ -172,7 +206,7 @@ export interface PiralOidcApi {
172
206
  getProfile(): Promise<OidcProfile>;
173
207
  }
174
208
  declare module 'piral-core/lib/types/custom' {
175
- interface PiletCustomApi extends PiralOidcApi {
209
+ interface PiletCustomApi extends PiletOidcApi {
176
210
  }
177
211
  }
178
212
  /**
package/lib/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AA6EA;;GAEG;AACH,IAAY,QAqBX;AArBD,WAAY,QAAQ;IAClB;;OAEG;IACH,yBAAa,CAAA;IACb;;OAEG;IACH,2BAAe,CAAA;IACf;;OAEG;IACH,yBAAa,CAAA;IACb;;OAEG;IACH,yBAAa,CAAA;IACb;;OAEG;IACH,2BAAe,CAAA;AACjB,CAAC,EArBW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAqBnB;AAsFD;;GAEG;AACH,IAAY,aA6BX;AA7BD,WAAY,aAAa;IACvB;;;OAGG;IACH,oCAAmB,CAAA;IACnB;;;;OAIG;IACH,gDAA+B,CAAA;IAC/B;;;OAGG;IACH,wDAAuC,CAAA;IACvC;;;;OAIG;IACH,8CAA6B,CAAA;IAC7B;;;;OAIG;IACH,8CAA6B,CAAA;AAC/B,CAAC,EA7BW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QA6BxB"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAuGA;;GAEG;AACH,IAAY,QAqBX;AArBD,WAAY,QAAQ;IAClB;;OAEG;IACH,yBAAa,CAAA;IACb;;OAEG;IACH,2BAAe,CAAA;IACf;;OAEG;IACH,yBAAa,CAAA;IACb;;OAEG;IACH,yBAAa,CAAA;IACb;;OAEG;IACH,2BAAe,CAAA;AACjB,CAAC,EArBW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAqBnB;AA8FD;;GAEG;AACH,IAAY,aA6BX;AA7BD,WAAY,aAAa;IACvB;;;OAGG;IACH,oCAAmB,CAAA;IACnB;;;;OAIG;IACH,gDAA+B,CAAA;IAC/B;;;OAGG;IACH,wDAAuC,CAAA;IACvC;;;;OAIG;IACH,8CAA6B,CAAA;IAC7B;;;;OAIG;IACH,8CAA6B,CAAA;AAC/B,CAAC,EA7BW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QA6BxB"}