oidc-spa 8.0.5 → 8.1.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/angular.d.ts +191 -0
- package/angular.js +351 -0
- package/angular.js.map +1 -0
- package/core/createOidc.d.ts +7 -7
- package/core/createOidc.js +2 -2
- package/core/createOidc.js.map +1 -1
- package/esm/angular.d.ts +191 -0
- package/esm/angular.js +314 -0
- package/esm/angular.js.map +1 -0
- package/esm/core/createOidc.d.ts +7 -7
- package/esm/core/createOidc.js +2 -2
- package/esm/core/createOidc.js.map +1 -1
- package/esm/keycloak/keycloakUtils.js.map +1 -1
- package/esm/tools/ConcreteClass.d.ts +3 -0
- package/esm/tools/ConcreteClass.js +2 -0
- package/esm/tools/ConcreteClass.js.map +1 -0
- package/esm/tools/Deferred.d.ts +7 -0
- package/esm/tools/Deferred.js +5 -0
- package/esm/tools/Deferred.js.map +1 -1
- package/esm/tools/ReadonlyBehaviorSubject.d.ts +8 -0
- package/esm/tools/ReadonlyBehaviorSubject.js +2 -0
- package/esm/tools/ReadonlyBehaviorSubject.js.map +1 -0
- package/esm/tools/getBaseHref.d.ts +1 -0
- package/esm/tools/getBaseHref.js +8 -0
- package/esm/tools/getBaseHref.js.map +1 -0
- package/esm/vendor/frontend/tsafe.d.ts +1 -0
- package/esm/vendor/frontend/tsafe.js +1 -1
- package/keycloak/keycloakUtils.js.map +1 -1
- package/package.json +3 -3
- package/src/angular.ts +583 -0
- package/src/core/createOidc.ts +10 -10
- package/src/keycloak/keycloakUtils.ts +0 -1
- package/src/tools/ConcreteClass.ts +3 -0
- package/src/tools/Deferred.ts +10 -0
- package/src/tools/ReadonlyBehaviorSubject.ts +9 -0
- package/src/tools/getBaseHref.ts +7 -0
- package/src/vendor/frontend/tsafe.ts +1 -0
- package/tools/ConcreteClass.d.ts +3 -0
- package/tools/ConcreteClass.js +3 -0
- package/tools/ConcreteClass.js.map +1 -0
- package/tools/Deferred.d.ts +7 -0
- package/tools/Deferred.js +5 -0
- package/tools/Deferred.js.map +1 -1
- package/tools/ReadonlyBehaviorSubject.d.ts +8 -0
- package/tools/ReadonlyBehaviorSubject.js +3 -0
- package/tools/ReadonlyBehaviorSubject.js.map +1 -0
- package/tools/getBaseHref.d.ts +1 -0
- package/tools/getBaseHref.js +11 -0
- package/tools/getBaseHref.js.map +1 -0
- package/vendor/frontend/tsafe.d.ts +1 -0
- package/vendor/frontend/tsafe.js +1 -1
- package/angular/angular.d.ts +0 -72
- package/angular/angular.js +0 -254
- package/angular/angular.js.map +0 -1
- package/angular/index.d.ts +0 -1
- package/angular/index.js +0 -6
- package/angular/index.js.map +0 -1
- package/esm/angular/angular.d.ts +0 -72
- package/esm/angular/angular.js +0 -250
- package/esm/angular/angular.js.map +0 -1
- package/esm/angular/index.d.ts +0 -1
- package/esm/angular/index.js +0 -2
- package/esm/angular/index.js.map +0 -1
- package/esm/mock/angular.d.ts +0 -41
- package/esm/mock/angular.js +0 -7
- package/esm/mock/angular.js.map +0 -1
- package/mock/angular.d.ts +0 -41
- package/mock/angular.js +0 -10
- package/mock/angular.js.map +0 -1
- package/src/angular/angular.ts +0 -429
- package/src/angular/index.ts +0 -1
- package/src/mock/angular.ts +0 -11
package/angular.d.ts
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import type { Oidc, OidcInitializationError } from "./core";
|
|
2
|
+
import type { OidcMetadata } from "./core/OidcMetadata";
|
|
3
|
+
import { type Signal, type EnvironmentProviders } from "@angular/core";
|
|
4
|
+
import type { ReadonlyBehaviorSubject } from "./tools/ReadonlyBehaviorSubject";
|
|
5
|
+
import type { ValueOrAsyncGetter } from "./tools/ValueOrAsyncGetter";
|
|
6
|
+
export type ParamsOfProvide = {
|
|
7
|
+
issuerUri: string;
|
|
8
|
+
clientId: string;
|
|
9
|
+
/**
|
|
10
|
+
* The scopes being requested from the OIDC/OAuth2 provider (default: `["profile"]`
|
|
11
|
+
* (the scope "openid" is added automatically as it's mandatory)
|
|
12
|
+
**/
|
|
13
|
+
scopes?: string[];
|
|
14
|
+
/**
|
|
15
|
+
* Transform the url (authorization endpoint) before redirecting to the login pages.
|
|
16
|
+
*
|
|
17
|
+
* The isSilent parameter is true when the redirect is initiated in the background iframe for silent signin.
|
|
18
|
+
* This can be used to omit ui related query parameters (like `ui_locales`).
|
|
19
|
+
*/
|
|
20
|
+
transformUrlBeforeRedirect?: (params: {
|
|
21
|
+
authorizationUrl: string;
|
|
22
|
+
isSilent: boolean;
|
|
23
|
+
}) => string;
|
|
24
|
+
/**
|
|
25
|
+
* Extra query params to be added to the authorization endpoint url before redirecting or silent signing in.
|
|
26
|
+
* You can provide a function that returns those extra query params, it will be called
|
|
27
|
+
* when login() is called.
|
|
28
|
+
*
|
|
29
|
+
* Example: extraQueryParams: ()=> ({ ui_locales: "fr" })
|
|
30
|
+
*
|
|
31
|
+
* This parameter can also be passed to login() directly.
|
|
32
|
+
*/
|
|
33
|
+
extraQueryParams?: Record<string, string | undefined> | ((params: {
|
|
34
|
+
isSilent: boolean;
|
|
35
|
+
url: string;
|
|
36
|
+
}) => Record<string, string | undefined>);
|
|
37
|
+
/**
|
|
38
|
+
* Extra body params to be added to the /token POST request.
|
|
39
|
+
*
|
|
40
|
+
* It will be used when for the initial request, whenever the token is getting refreshed and if you call `renewTokens()`.
|
|
41
|
+
* You can also provide this parameter directly to the `renewTokens()` method.
|
|
42
|
+
*
|
|
43
|
+
* It can be either a string to string record or a function that returns a string to string record.
|
|
44
|
+
*
|
|
45
|
+
* Example: extraTokenParams: ()=> ({ selectedCustomer: "xxx" })
|
|
46
|
+
* extraTokenParams: { selectedCustomer: "xxx" }
|
|
47
|
+
*/
|
|
48
|
+
extraTokenParams?: Record<string, string | undefined> | (() => Record<string, string | undefined>);
|
|
49
|
+
/**
|
|
50
|
+
* Usage discouraged, it's here because we don't want to assume too much on your
|
|
51
|
+
* usecase but I can't think of a scenario where you would want anything
|
|
52
|
+
* other than the current page.
|
|
53
|
+
*
|
|
54
|
+
* Where to redirect after successful login.
|
|
55
|
+
* Default: window.location.href (here)
|
|
56
|
+
*
|
|
57
|
+
* It does not need to include the origin, eg: "/dashboard"
|
|
58
|
+
*
|
|
59
|
+
* This parameter can also be passed to login() directly as `redirectUrl`.
|
|
60
|
+
*/
|
|
61
|
+
postLoginRedirectUrl?: string;
|
|
62
|
+
/**
|
|
63
|
+
* This parameter defines after how many seconds of inactivity the user should be
|
|
64
|
+
* logged out automatically.
|
|
65
|
+
*
|
|
66
|
+
* WARNING: It should be configured on the identity server side
|
|
67
|
+
* as it's the authoritative source for security policies and not the client.
|
|
68
|
+
* If you don't provide this parameter it will be inferred from the refresh token expiration time.
|
|
69
|
+
* */
|
|
70
|
+
idleSessionLifetimeInSeconds?: number;
|
|
71
|
+
/**
|
|
72
|
+
* Usage discouraged, this parameter exists because we don't want to assume
|
|
73
|
+
* too much about your usecase but I can't think of a scenario where you would
|
|
74
|
+
* want anything other than the current page.
|
|
75
|
+
*
|
|
76
|
+
* Default: { redirectTo: "current page" }
|
|
77
|
+
*/
|
|
78
|
+
autoLogoutParams?: Parameters<Oidc.LoggedIn<any>["logout"]>[0];
|
|
79
|
+
autoLogin?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Default: false
|
|
82
|
+
*
|
|
83
|
+
* See: https://docs.oidc-spa.dev/v/v8/resources/iframe-related-issues
|
|
84
|
+
*/
|
|
85
|
+
noIframe?: boolean;
|
|
86
|
+
debugLogs?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* WARNING: This option exists solely as a workaround
|
|
89
|
+
* for limitations in the Google OAuth API.
|
|
90
|
+
* See: https://docs.oidc-spa.dev/providers-configuration/google-oauth
|
|
91
|
+
*
|
|
92
|
+
* Do not use this for other providers.
|
|
93
|
+
* If you think you need a client secret in a SPA, you are likely
|
|
94
|
+
* trying to use a confidential (private) client in the browser,
|
|
95
|
+
* which is insecure and not supported.
|
|
96
|
+
*/
|
|
97
|
+
__unsafe_clientSecret?: string;
|
|
98
|
+
/**
|
|
99
|
+
* WARNING: Setting this to true is a workaround for provider
|
|
100
|
+
* like Google OAuth that don't support JWT access token.
|
|
101
|
+
* Use at your own risk, this is a hack.
|
|
102
|
+
*/
|
|
103
|
+
__unsafe_useIdTokenAsAccessToken?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* This option should only be used as a last resort.
|
|
106
|
+
*
|
|
107
|
+
* If your OIDC provider is correctly configured, this should not be necessary.
|
|
108
|
+
*
|
|
109
|
+
* The metadata is normally retrieved automatically from:
|
|
110
|
+
* `${issuerUri}/.well-known/openid-configuration`
|
|
111
|
+
*
|
|
112
|
+
* Use this only if that endpoint is not accessible (e.g. due to missing CORS headers
|
|
113
|
+
* or non-standard deployments), and you cannot fix the server-side configuration.
|
|
114
|
+
*/
|
|
115
|
+
__metadata?: Partial<OidcMetadata>;
|
|
116
|
+
/**
|
|
117
|
+
* You can use oidc.$secondsLeftBeforeAutoLogout to display an overlay/update the tab title
|
|
118
|
+
* to indicate to your user that they are going to be logged out if they don't interact
|
|
119
|
+
* with the app.
|
|
120
|
+
* This value let you define how long before how long before auto logout this warning should
|
|
121
|
+
* start showing.
|
|
122
|
+
* Default is 45 seconds.
|
|
123
|
+
*/
|
|
124
|
+
autoLogoutWarningDurationSeconds?: number;
|
|
125
|
+
};
|
|
126
|
+
export type ParamsOfProvideMock = {
|
|
127
|
+
mockIssuerUri?: string;
|
|
128
|
+
mockClientId?: string;
|
|
129
|
+
mockAccessToken?: string;
|
|
130
|
+
isUserInitiallyLoggedIn?: boolean;
|
|
131
|
+
};
|
|
132
|
+
export declare abstract class AbstractOidcService<T_DecodedIdToken extends Record<string, unknown> = Oidc.Tokens.DecodedIdToken_base> {
|
|
133
|
+
#private;
|
|
134
|
+
protected autoLogin: boolean;
|
|
135
|
+
protected providerAwaitsInitialization: boolean;
|
|
136
|
+
protected decodedIdTokenSchema: {
|
|
137
|
+
parse: (decodedIdToken_original: Oidc.Tokens.DecodedIdToken_base) => T_DecodedIdToken;
|
|
138
|
+
} | undefined;
|
|
139
|
+
protected mockDecodedIdToken: (() => Promise<T_DecodedIdToken>) | T_DecodedIdToken | undefined;
|
|
140
|
+
static provide(params: ValueOrAsyncGetter<ParamsOfProvide>): EnvironmentProviders;
|
|
141
|
+
static provideMock(params?: ParamsOfProvideMock): EnvironmentProviders;
|
|
142
|
+
static enforceLoginGuard(): (route: import("@angular/router").ActivatedRouteSnapshot) => Promise<boolean>;
|
|
143
|
+
readonly prInitialized: Promise<true>;
|
|
144
|
+
get initializationError(): OidcInitializationError | undefined;
|
|
145
|
+
get issuerUri(): string;
|
|
146
|
+
get clientId(): string;
|
|
147
|
+
get isUserLoggedIn(): boolean;
|
|
148
|
+
login(params?: {
|
|
149
|
+
/**
|
|
150
|
+
* Add extra query parameters to the url before redirecting to the login pages.
|
|
151
|
+
*/
|
|
152
|
+
extraQueryParams?: Record<string, string | undefined>;
|
|
153
|
+
/**
|
|
154
|
+
* Where to redirect after successful login.
|
|
155
|
+
* Default: window.location.href (here)
|
|
156
|
+
*
|
|
157
|
+
* It does not need to include the origin, eg: "/dashboard"
|
|
158
|
+
*/
|
|
159
|
+
redirectUrl?: string;
|
|
160
|
+
/**
|
|
161
|
+
* Transform the url before redirecting to the login pages.
|
|
162
|
+
* Prefer using the extraQueryParams parameter if you're only adding query parameters.
|
|
163
|
+
*/
|
|
164
|
+
transformUrlBeforeRedirect?: (url: string) => string;
|
|
165
|
+
}): Promise<never>;
|
|
166
|
+
renewTokens(params?: {
|
|
167
|
+
extraTokenParams?: Record<string, string | undefined>;
|
|
168
|
+
}): Promise<void>;
|
|
169
|
+
logout(params: {
|
|
170
|
+
redirectTo: "home" | "current page";
|
|
171
|
+
} | {
|
|
172
|
+
redirectTo: "specific url";
|
|
173
|
+
url: string;
|
|
174
|
+
}): Promise<never>;
|
|
175
|
+
goToAuthServer(params: {
|
|
176
|
+
extraQueryParams?: Record<string, string | undefined>;
|
|
177
|
+
redirectUrl?: string;
|
|
178
|
+
transformUrlBeforeRedirect?: (url: string) => string;
|
|
179
|
+
}): Promise<never>;
|
|
180
|
+
readonly decodedIdToken$: ReadonlyBehaviorSubject<T_DecodedIdToken>;
|
|
181
|
+
readonly $decodedIdToken: Signal<T_DecodedIdToken>;
|
|
182
|
+
getAccessToken(): Promise<{
|
|
183
|
+
isUserLoggedIn: false;
|
|
184
|
+
accessToken?: never;
|
|
185
|
+
} | {
|
|
186
|
+
isUserLoggedIn: true;
|
|
187
|
+
accessToken: string;
|
|
188
|
+
}>;
|
|
189
|
+
readonly $secondsLeftBeforeAutoLogout: Signal<number | null>;
|
|
190
|
+
get isNewBrowserSession(): boolean;
|
|
191
|
+
}
|
package/angular.js
ADDED
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
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 () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
36
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
37
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
38
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
39
|
+
};
|
|
40
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
41
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
42
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
43
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
44
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
45
|
+
};
|
|
46
|
+
var _AbstractOidcService_instances, _AbstractOidcService_autoLogoutWarningDurationSeconds, _AbstractOidcService_dState, _AbstractOidcService_initialize, _AbstractOidcService_getPrInitializedNotResolvedErrorMessage, _AbstractOidcService_getState, _AbstractOidcService_getAutoLoginAndInitializationErrorAccessErrorMessage, _AbstractOidcService_getOidc;
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.AbstractOidcService = void 0;
|
|
49
|
+
const rxjs_1 = require("rxjs");
|
|
50
|
+
const Deferred_1 = require("./tools/Deferred");
|
|
51
|
+
const tsafe_1 = require("./vendor/frontend/tsafe");
|
|
52
|
+
const createObjectThatThrowsIfAccessed_1 = require("./tools/createObjectThatThrowsIfAccessed");
|
|
53
|
+
const core_1 = require("@angular/core");
|
|
54
|
+
const rxjs_interop_1 = require("@angular/core/rxjs-interop");
|
|
55
|
+
const router_1 = require("@angular/router");
|
|
56
|
+
const getBaseHref_1 = require("./tools/getBaseHref");
|
|
57
|
+
tsafe_1.assert;
|
|
58
|
+
class AbstractOidcService {
|
|
59
|
+
constructor() {
|
|
60
|
+
_AbstractOidcService_instances.add(this);
|
|
61
|
+
this.autoLogin = false;
|
|
62
|
+
this.providerAwaitsInitialization = true;
|
|
63
|
+
this.decodedIdTokenSchema = undefined;
|
|
64
|
+
this.mockDecodedIdToken = undefined;
|
|
65
|
+
_AbstractOidcService_autoLogoutWarningDurationSeconds.set(this, 45);
|
|
66
|
+
_AbstractOidcService_dState.set(this, new Deferred_1.Deferred());
|
|
67
|
+
this.prInitialized = __classPrivateFieldGet(this, _AbstractOidcService_dState, "f").pr.then(() => true);
|
|
68
|
+
this.decodedIdToken$ = (() => {
|
|
69
|
+
const decodedIdToken$ = new rxjs_1.BehaviorSubject((0, createObjectThatThrowsIfAccessed_1.createObjectThatThrowsIfAccessed)({
|
|
70
|
+
debugMessage: __classPrivateFieldGet(this, _AbstractOidcService_instances, "m", _AbstractOidcService_getPrInitializedNotResolvedErrorMessage).call(this, {
|
|
71
|
+
callerName: "decodedIdToken"
|
|
72
|
+
})
|
|
73
|
+
}));
|
|
74
|
+
(async () => {
|
|
75
|
+
const { initializationError, oidc } = await __classPrivateFieldGet(this, _AbstractOidcService_dState, "f").pr;
|
|
76
|
+
if (initializationError !== undefined) {
|
|
77
|
+
decodedIdToken$.next((0, createObjectThatThrowsIfAccessed_1.createObjectThatThrowsIfAccessed)({
|
|
78
|
+
debugMessage: __classPrivateFieldGet(this, _AbstractOidcService_instances, "m", _AbstractOidcService_getAutoLoginAndInitializationErrorAccessErrorMessage).call(this, {
|
|
79
|
+
callerName: "decodedIdToken"
|
|
80
|
+
})
|
|
81
|
+
}));
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
(0, tsafe_1.assert)(oidc !== undefined);
|
|
85
|
+
if (!oidc.isUserLoggedIn) {
|
|
86
|
+
decodedIdToken$.next((0, createObjectThatThrowsIfAccessed_1.createObjectThatThrowsIfAccessed)({
|
|
87
|
+
debugMessage: [
|
|
88
|
+
`oidc-spa: Trying to read properties of decodedIdToken, the user`,
|
|
89
|
+
`isn't currently logged in, this does not make sense.`,
|
|
90
|
+
`You are responsible for controlling the flow of your app and`,
|
|
91
|
+
`not try to read the decodedIdToken when oidc.isUserLoggedIn is false.`
|
|
92
|
+
].join(" ")
|
|
93
|
+
}));
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
decodedIdToken$.next(oidc.getDecodedIdToken());
|
|
97
|
+
oidc.subscribeToTokensChange(() => {
|
|
98
|
+
const value_new = oidc.getDecodedIdToken();
|
|
99
|
+
const value_current = decodedIdToken$.getValue();
|
|
100
|
+
if (value_new === value_current) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
decodedIdToken$.next(value_new);
|
|
104
|
+
});
|
|
105
|
+
})();
|
|
106
|
+
return decodedIdToken$;
|
|
107
|
+
})();
|
|
108
|
+
this.$decodedIdToken = (0, rxjs_interop_1.toSignal)(this.decodedIdToken$, { requireSync: true });
|
|
109
|
+
this.$secondsLeftBeforeAutoLogout = (() => {
|
|
110
|
+
const secondsLeftBeforeAutoLogout$ = new rxjs_1.BehaviorSubject(null);
|
|
111
|
+
(async () => {
|
|
112
|
+
const { oidc } = await __classPrivateFieldGet(this, _AbstractOidcService_dState, "f").pr;
|
|
113
|
+
if (oidc === undefined) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (!oidc.isUserLoggedIn) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
oidc.subscribeToAutoLogoutCountdown(({ secondsLeft }) => {
|
|
120
|
+
if (secondsLeft === undefined || secondsLeft > __classPrivateFieldGet(this, _AbstractOidcService_autoLogoutWarningDurationSeconds, "f")) {
|
|
121
|
+
if (secondsLeftBeforeAutoLogout$.getValue() !== null) {
|
|
122
|
+
secondsLeftBeforeAutoLogout$.next(null);
|
|
123
|
+
}
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
secondsLeftBeforeAutoLogout$.next(secondsLeft);
|
|
127
|
+
});
|
|
128
|
+
})();
|
|
129
|
+
return (0, rxjs_interop_1.toSignal)(secondsLeftBeforeAutoLogout$, { requireSync: true });
|
|
130
|
+
})();
|
|
131
|
+
}
|
|
132
|
+
static provide(params) {
|
|
133
|
+
const paramsOrGetParams = params;
|
|
134
|
+
(0, tsafe_1.assert)((0, tsafe_1.is)(this));
|
|
135
|
+
return (0, core_1.makeEnvironmentProviders)([
|
|
136
|
+
this,
|
|
137
|
+
(0, core_1.provideAppInitializer)(async () => {
|
|
138
|
+
const instance = (0, core_1.inject)(this);
|
|
139
|
+
__classPrivateFieldGet(instance, _AbstractOidcService_instances, "m", _AbstractOidcService_initialize).call(instance, {
|
|
140
|
+
prOidcOrInitializationError: (async () => {
|
|
141
|
+
const [{ createOidc }, { autoLogoutWarningDurationSeconds, ...params }] = await Promise.all([
|
|
142
|
+
Promise.resolve().then(() => __importStar(require("./core"))),
|
|
143
|
+
typeof paramsOrGetParams === "function"
|
|
144
|
+
? paramsOrGetParams()
|
|
145
|
+
: paramsOrGetParams
|
|
146
|
+
]);
|
|
147
|
+
if (autoLogoutWarningDurationSeconds !== undefined) {
|
|
148
|
+
__classPrivateFieldSet(instance, _AbstractOidcService_autoLogoutWarningDurationSeconds, autoLogoutWarningDurationSeconds, "f");
|
|
149
|
+
}
|
|
150
|
+
try {
|
|
151
|
+
return createOidc({
|
|
152
|
+
homeUrl: (0, getBaseHref_1.getBaseHref)(),
|
|
153
|
+
autoLogin: instance.autoLogin,
|
|
154
|
+
decodedIdTokenSchema: instance.decodedIdTokenSchema,
|
|
155
|
+
...params
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
catch (initializationError) {
|
|
159
|
+
(0, tsafe_1.assert)(initializationError instanceof Error);
|
|
160
|
+
(0, tsafe_1.assert)((0, tsafe_1.is)(initializationError));
|
|
161
|
+
return initializationError;
|
|
162
|
+
}
|
|
163
|
+
})()
|
|
164
|
+
});
|
|
165
|
+
if (instance.providerAwaitsInitialization) {
|
|
166
|
+
await instance.prInitialized;
|
|
167
|
+
}
|
|
168
|
+
})
|
|
169
|
+
]);
|
|
170
|
+
}
|
|
171
|
+
static provideMock(params = {}) {
|
|
172
|
+
(0, tsafe_1.assert)((0, tsafe_1.is)(this));
|
|
173
|
+
return (0, core_1.makeEnvironmentProviders)([
|
|
174
|
+
this,
|
|
175
|
+
(0, core_1.provideAppInitializer)(async () => {
|
|
176
|
+
const instance = (0, core_1.inject)(this);
|
|
177
|
+
__classPrivateFieldGet(instance, _AbstractOidcService_instances, "m", _AbstractOidcService_initialize).call(instance, {
|
|
178
|
+
prOidcOrInitializationError: (async () => {
|
|
179
|
+
const { createMockOidc } = await Promise.resolve().then(() => __importStar(require("./mock")));
|
|
180
|
+
return createMockOidc({
|
|
181
|
+
homeUrl: (0, getBaseHref_1.getBaseHref)(),
|
|
182
|
+
autoLogin: instance.autoLogin,
|
|
183
|
+
isUserInitiallyLoggedIn: instance.autoLogin
|
|
184
|
+
? true
|
|
185
|
+
: params.isUserInitiallyLoggedIn,
|
|
186
|
+
mockedParams: {
|
|
187
|
+
issuerUri: params.mockIssuerUri,
|
|
188
|
+
clientId: params.mockClientId
|
|
189
|
+
},
|
|
190
|
+
mockedTokens: {
|
|
191
|
+
accessToken: params.mockAccessToken,
|
|
192
|
+
decodedIdToken: await (() => {
|
|
193
|
+
if (instance.mockDecodedIdToken === undefined) {
|
|
194
|
+
return undefined;
|
|
195
|
+
}
|
|
196
|
+
if (typeof instance.mockDecodedIdToken === "function") {
|
|
197
|
+
return instance.mockDecodedIdToken();
|
|
198
|
+
}
|
|
199
|
+
})()
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
})()
|
|
203
|
+
});
|
|
204
|
+
await instance.prInitialized;
|
|
205
|
+
})
|
|
206
|
+
]);
|
|
207
|
+
}
|
|
208
|
+
static enforceLoginGuard() {
|
|
209
|
+
const canActivateFn = (async (route) => {
|
|
210
|
+
const instance = (0, core_1.inject)(this);
|
|
211
|
+
const router = (0, core_1.inject)(router_1.Router);
|
|
212
|
+
await instance.prInitialized;
|
|
213
|
+
const oidc = __classPrivateFieldGet(instance, _AbstractOidcService_instances, "m", _AbstractOidcService_getOidc).call(instance, { callerName: "enforceLoginGuard" });
|
|
214
|
+
if (!oidc.isUserLoggedIn) {
|
|
215
|
+
const redirectUrl = router.serializeUrl(router.createUrlTree(route.url.map(u => u.path), {
|
|
216
|
+
queryParams: route.queryParams,
|
|
217
|
+
fragment: route.fragment ?? undefined
|
|
218
|
+
}));
|
|
219
|
+
const doesCurrentHrefRequiresAuth = location.href.replace(/\/$/, "") === redirectUrl.replace(/\/$/, "");
|
|
220
|
+
await oidc.login({
|
|
221
|
+
doesCurrentHrefRequiresAuth,
|
|
222
|
+
redirectUrl
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
return true;
|
|
226
|
+
});
|
|
227
|
+
return canActivateFn;
|
|
228
|
+
}
|
|
229
|
+
get initializationError() {
|
|
230
|
+
const state = __classPrivateFieldGet(this, _AbstractOidcService_instances, "m", _AbstractOidcService_getState).call(this, { callerName: "initializationError" });
|
|
231
|
+
return state.initializationError;
|
|
232
|
+
}
|
|
233
|
+
get issuerUri() {
|
|
234
|
+
return __classPrivateFieldGet(this, _AbstractOidcService_instances, "m", _AbstractOidcService_getOidc).call(this, { callerName: "issuerUri" }).params.issuerUri;
|
|
235
|
+
}
|
|
236
|
+
get clientId() {
|
|
237
|
+
return __classPrivateFieldGet(this, _AbstractOidcService_instances, "m", _AbstractOidcService_getOidc).call(this, { callerName: "clientId" }).params.clientId;
|
|
238
|
+
}
|
|
239
|
+
get isUserLoggedIn() {
|
|
240
|
+
return __classPrivateFieldGet(this, _AbstractOidcService_instances, "m", _AbstractOidcService_getOidc).call(this, { callerName: "isUserLoggedIn" }).isUserLoggedIn;
|
|
241
|
+
}
|
|
242
|
+
async login(params) {
|
|
243
|
+
await this.prInitialized;
|
|
244
|
+
const oidc = __classPrivateFieldGet(this, _AbstractOidcService_instances, "m", _AbstractOidcService_getOidc).call(this, { callerName: "login" });
|
|
245
|
+
if (oidc.isUserLoggedIn) {
|
|
246
|
+
throw new Error([
|
|
247
|
+
"oidc-spa: login() called but the user is already logged in.",
|
|
248
|
+
"If you wish to send the user to the login page for some update",
|
|
249
|
+
"use oidc.goToAuthServer() instead"
|
|
250
|
+
].join(" "));
|
|
251
|
+
}
|
|
252
|
+
return oidc.login({
|
|
253
|
+
...params,
|
|
254
|
+
doesCurrentHrefRequiresAuth: false
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
async renewTokens(params) {
|
|
258
|
+
await this.prInitialized;
|
|
259
|
+
const oidc = __classPrivateFieldGet(this, _AbstractOidcService_instances, "m", _AbstractOidcService_getOidc).call(this, { callerName: "renewTokens" });
|
|
260
|
+
if (!oidc.isUserLoggedIn) {
|
|
261
|
+
throw new Error("oidc-spa: renewTokens() called but the user is not logged in.");
|
|
262
|
+
}
|
|
263
|
+
return oidc.renewTokens(params);
|
|
264
|
+
}
|
|
265
|
+
async logout(params) {
|
|
266
|
+
await this.prInitialized;
|
|
267
|
+
const oidc = __classPrivateFieldGet(this, _AbstractOidcService_instances, "m", _AbstractOidcService_getOidc).call(this, { callerName: "logout" });
|
|
268
|
+
if (!oidc.isUserLoggedIn) {
|
|
269
|
+
throw new Error("oidc-spa: logout() called but the user is not logged in.");
|
|
270
|
+
}
|
|
271
|
+
return oidc.logout(params);
|
|
272
|
+
}
|
|
273
|
+
async goToAuthServer(params) {
|
|
274
|
+
await this.prInitialized;
|
|
275
|
+
const oidc = __classPrivateFieldGet(this, _AbstractOidcService_instances, "m", _AbstractOidcService_getOidc).call(this, { callerName: "goToAuthServer" });
|
|
276
|
+
if (!oidc.isUserLoggedIn) {
|
|
277
|
+
throw new Error("oidc-spa: goToAuthServer() called but the user is not logged in.");
|
|
278
|
+
}
|
|
279
|
+
return oidc.goToAuthServer(params);
|
|
280
|
+
}
|
|
281
|
+
async getAccessToken() {
|
|
282
|
+
await this.prInitialized;
|
|
283
|
+
const oidc = __classPrivateFieldGet(this, _AbstractOidcService_instances, "m", _AbstractOidcService_getOidc).call(this, { callerName: "getAccessToken" });
|
|
284
|
+
return oidc.isUserLoggedIn
|
|
285
|
+
? { isUserLoggedIn: true, accessToken: (await oidc.getTokens()).accessToken }
|
|
286
|
+
: {
|
|
287
|
+
isUserLoggedIn: false
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
get isNewBrowserSession() {
|
|
291
|
+
const oidc = __classPrivateFieldGet(this, _AbstractOidcService_instances, "m", _AbstractOidcService_getOidc).call(this, { callerName: "isNewBrowserSession" });
|
|
292
|
+
if (!oidc.isUserLoggedIn) {
|
|
293
|
+
throw new Error("oidc-spa: isNewBrowserSession was used but the used is not logged in");
|
|
294
|
+
}
|
|
295
|
+
return oidc.isNewBrowserSession;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
exports.AbstractOidcService = AbstractOidcService;
|
|
299
|
+
_AbstractOidcService_autoLogoutWarningDurationSeconds = new WeakMap(), _AbstractOidcService_dState = new WeakMap(), _AbstractOidcService_instances = new WeakSet(), _AbstractOidcService_initialize = function _AbstractOidcService_initialize(params) {
|
|
300
|
+
const { prOidcOrInitializationError } = params;
|
|
301
|
+
prOidcOrInitializationError.then(oidcOrInitializationError => {
|
|
302
|
+
let initializationError = undefined;
|
|
303
|
+
let oidc = undefined;
|
|
304
|
+
if (oidcOrInitializationError instanceof Error) {
|
|
305
|
+
initializationError = oidcOrInitializationError;
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
oidc = oidcOrInitializationError;
|
|
309
|
+
initializationError = oidc.isUserLoggedIn ? undefined : oidc.initializationError;
|
|
310
|
+
}
|
|
311
|
+
__classPrivateFieldGet(this, _AbstractOidcService_dState, "f").resolve({
|
|
312
|
+
oidc,
|
|
313
|
+
initializationError
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
}, _AbstractOidcService_getPrInitializedNotResolvedErrorMessage = function _AbstractOidcService_getPrInitializedNotResolvedErrorMessage(params) {
|
|
317
|
+
const { callerName } = params;
|
|
318
|
+
return [
|
|
319
|
+
`oidc-spa: ${callerName} called/accessed before`,
|
|
320
|
+
"`oidc.prInitialized` resolved.",
|
|
321
|
+
"You are using `awaitInitialization: false`.",
|
|
322
|
+
"In your template you should wrap your usage of",
|
|
323
|
+
"oidc.isUserLoggedIn, oidc.$decodedIdToken() ect. into",
|
|
324
|
+
"@defer (when oidc.prInitialized | async) { } @placeholder { Loading... }"
|
|
325
|
+
].join(" ");
|
|
326
|
+
}, _AbstractOidcService_getState = function _AbstractOidcService_getState(params) {
|
|
327
|
+
const { callerName } = params;
|
|
328
|
+
const { hasResolved, value } = __classPrivateFieldGet(this, _AbstractOidcService_dState, "f").getState();
|
|
329
|
+
if (!hasResolved) {
|
|
330
|
+
throw new Error(__classPrivateFieldGet(this, _AbstractOidcService_instances, "m", _AbstractOidcService_getPrInitializedNotResolvedErrorMessage).call(this, { callerName }));
|
|
331
|
+
}
|
|
332
|
+
return value;
|
|
333
|
+
}, _AbstractOidcService_getAutoLoginAndInitializationErrorAccessErrorMessage = function _AbstractOidcService_getAutoLoginAndInitializationErrorAccessErrorMessage(params) {
|
|
334
|
+
const { callerName } = params;
|
|
335
|
+
return [
|
|
336
|
+
`oidc-spa: ${callerName} was accessed but initialization failed.`,
|
|
337
|
+
"You are using `autoLogin: true`, so there is no anonymous state.",
|
|
338
|
+
"Handle this by gating your UI:",
|
|
339
|
+
"if (oidc.initializationError) show an error/fallback."
|
|
340
|
+
].join(" ");
|
|
341
|
+
}, _AbstractOidcService_getOidc = function _AbstractOidcService_getOidc(params) {
|
|
342
|
+
const { callerName } = params;
|
|
343
|
+
const state = __classPrivateFieldGet(this, _AbstractOidcService_instances, "m", _AbstractOidcService_getState).call(this, { callerName });
|
|
344
|
+
if (state.oidc === undefined) {
|
|
345
|
+
// initialization failed
|
|
346
|
+
(0, tsafe_1.assert)(state.initializationError !== undefined);
|
|
347
|
+
throw new Error(__classPrivateFieldGet(this, _AbstractOidcService_instances, "m", _AbstractOidcService_getAutoLoginAndInitializationErrorAccessErrorMessage).call(this, { callerName }));
|
|
348
|
+
}
|
|
349
|
+
return state.oidc;
|
|
350
|
+
};
|
|
351
|
+
//# sourceMappingURL=angular.js.map
|
package/angular.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"angular.js","sourceRoot":"","sources":["./src/angular.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAAuC;AAGvC,+CAA4C;AAC5C,mDAAkE;AAClE,+FAA4F;AAC5F,wCAMuB;AACvB,6DAAsD;AAEtD,4CAA6D;AAE7D,qDAAkD;AAkIlD,cAKC,CAAC;AASF,MAAsB,mBAAmB;IAAzC;;QAGc,cAAS,GAAY,KAAK,CAAC;QAC3B,iCAA4B,GAAY,IAAI,CAAC;QAC7C,yBAAoB,GAIZ,SAAS,CAAC;QAElB,uBAAkB,GACxB,SAAS,CAAC;QAEd,gEAAoC,EAAE,EAAC;QA6HvC,sCAAU,IAAI,mBAAQ,EAGlB,EAAC;QAEI,kBAAa,GAAkB,uBAAA,IAAI,mCAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;QAwKhE,oBAAe,GAA8C,CAAC,GAAG,EAAE;YACxE,MAAM,eAAe,GAAG,IAAI,sBAAe,CACvC,IAAA,mEAAgC,EAAC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F,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC,iKAOqD,MAA8B;IAChF,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IAE9B,OAAO;QACH,aAAa,UAAU,0CAA0C;QACjE,kEAAkE;QAClE,gCAAgC;QAChC,uDAAuD;KAC1D,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAChB,CAAC,uEAEQ,MAA8B;IACnC,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IAC9B,MAAM,KAAK,GAAG,uBAAA,IAAI,qEAAU,MAAd,IAAI,EAAW,EAAE,UAAU,EAAE,CAAC,CAAC;IAC7C,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC3B,wBAAwB;QACxB,IAAA,cAAM,EAAC,KAAK,CAAC,mBAAmB,KAAK,SAAS,CAAC,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,uBAAA,IAAI,iHAAsD,MAA1D,IAAI,EAAuD,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;IAChG,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC;AACtB,CAAC"}
|
package/core/createOidc.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import type { OidcMetadata } from "./OidcMetadata";
|
|
2
2
|
import type { Oidc } from "./Oidc";
|
|
3
3
|
export type ParamsOfCreateOidc<DecodedIdToken extends Record<string, unknown> = Oidc.Tokens.DecodedIdToken_base, AutoLogin extends boolean = false> = {
|
|
4
|
+
/**
|
|
5
|
+
* What should you put in this parameter?
|
|
6
|
+
* - Vite project: `BASE_URL: import.meta.env.BASE_URL`
|
|
7
|
+
* - Create React App project: `BASE_URL: process.env.PUBLIC_URL`
|
|
8
|
+
* - Other: `BASE_URL: "/"` (Usually, or `/dashboard` if your app is not at the root of the domain)
|
|
9
|
+
*/
|
|
10
|
+
homeUrl: string;
|
|
4
11
|
issuerUri: string;
|
|
5
12
|
clientId: string;
|
|
6
13
|
/**
|
|
@@ -56,13 +63,6 @@ export type ParamsOfCreateOidc<DecodedIdToken extends Record<string, unknown> =
|
|
|
56
63
|
* This parameter can also be passed to login() directly as `redirectUrl`.
|
|
57
64
|
*/
|
|
58
65
|
postLoginRedirectUrl?: string;
|
|
59
|
-
/**
|
|
60
|
-
* What should you put in this parameter?
|
|
61
|
-
* - Vite project: `BASE_URL: import.meta.env.BASE_URL`
|
|
62
|
-
* - Create React App project: `BASE_URL: process.env.PUBLIC_URL`
|
|
63
|
-
* - Other: `BASE_URL: "/"` (Usually, or `/dashboard` if your app is not at the root of the domain)
|
|
64
|
-
*/
|
|
65
|
-
homeUrl: string;
|
|
66
66
|
decodedIdTokenSchema?: {
|
|
67
67
|
parse: (decodedIdToken_original: Oidc.Tokens.DecodedIdToken_base) => DecodedIdToken;
|
|
68
68
|
};
|
package/core/createOidc.js
CHANGED
|
@@ -63,7 +63,7 @@ const getIsOnline_1 = require("../tools/getIsOnline");
|
|
|
63
63
|
const isKeycloak_1 = require("../keycloak/isKeycloak");
|
|
64
64
|
const INFINITY_TIME_1 = require("../tools/INFINITY_TIME");
|
|
65
65
|
// NOTE: Replaced at build time
|
|
66
|
-
const VERSION = "8.0
|
|
66
|
+
const VERSION = "8.1.0";
|
|
67
67
|
const globalContext = {
|
|
68
68
|
prOidcByConfigId: new Map(),
|
|
69
69
|
hasLogoutBeenCalled: (0, tsafe_1.id)(false),
|
|
@@ -1120,7 +1120,6 @@ async function createOidc_nonMemoized(params, preProcessedParams) {
|
|
|
1120
1120
|
const { secondsLeft } = params;
|
|
1121
1121
|
Array.from(autoLogoutCountdownTickCallbacks).forEach(tickCallback => tickCallback({ secondsLeft }));
|
|
1122
1122
|
};
|
|
1123
|
-
invokeAllCallbacks({ secondsLeft });
|
|
1124
1123
|
if (secondsLeft === 0) {
|
|
1125
1124
|
cancel_if_offline: {
|
|
1126
1125
|
const { isOnline, prOnline } = (0, getIsOnline_1.getIsOnline)();
|
|
@@ -1148,6 +1147,7 @@ async function createOidc_nonMemoized(params, preProcessedParams) {
|
|
|
1148
1147
|
}
|
|
1149
1148
|
await oidc_loggedIn.logout(autoLogoutParams);
|
|
1150
1149
|
}
|
|
1150
|
+
invokeAllCallbacks({ secondsLeft });
|
|
1151
1151
|
}
|
|
1152
1152
|
});
|
|
1153
1153
|
let stopCountdown = undefined;
|