@liquid-js/lyr-auth 0.0.0-stage → 22.0.0-alpha.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.txt +23 -0
- package/README.md +61 -2
- package/components/auth-block/_auth-block.component.theme.scss +17 -0
- package/components/auth-block/auth-block.component.scss +98 -0
- package/components/auth.component.html +22 -0
- package/components/auth.component.scss +54 -0
- package/components/login/login.component.html +154 -0
- package/components/logout/logout.component.html +1 -0
- package/components/register/register.component.html +212 -0
- package/components/register/register.component.scss +5 -0
- package/components/request-password/request-password.component.html +81 -0
- package/components/reset-password/reset-password.component.html +116 -0
- package/components/reset-password/reset-password.component.scss +5 -0
- package/fesm2022/liquid-js-lyr-auth.mjs +2900 -0
- package/fesm2022/liquid-js-lyr-auth.mjs.map +1 -0
- package/package.json +59 -3
- package/styles/_globals.scss +5 -0
- package/styles/global/_components.scss +6 -0
- package/styles/prebuilt/components-custom-properties.css +1 -0
- package/styles/prebuilt/components-custom-properties.scss +10 -0
- package/styles/prebuilt/corporate-custom-properties.css +1 -0
- package/styles/prebuilt/corporate-custom-properties.scss +2 -0
- package/styles/prebuilt/corporate.css +1 -0
- package/styles/prebuilt/corporate.scss +12 -0
- package/styles/prebuilt/cosmic-custom-properties.css +1 -0
- package/styles/prebuilt/cosmic-custom-properties.scss +2 -0
- package/styles/prebuilt/cosmic.css +1 -0
- package/styles/prebuilt/cosmic.scss +12 -0
- package/styles/prebuilt/dark-custom-properties.css +1 -0
- package/styles/prebuilt/dark-custom-properties.scss +2 -0
- package/styles/prebuilt/dark.css +1 -0
- package/styles/prebuilt/dark.scss +12 -0
- package/styles/prebuilt/default-custom-properties.css +1 -0
- package/styles/prebuilt/default-custom-properties.scss +2 -0
- package/styles/prebuilt/default.css +1 -0
- package/styles/prebuilt/default.scss +12 -0
- package/types/liquid-js-lyr-auth.d.ts +1236 -0
|
@@ -0,0 +1,1236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated bundle index. Do not edit.
|
|
3
|
+
*/
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
import { ChangeDetectorRef, DestroyRef, EnvironmentProviders, InjectionToken, Injector, ModuleWithProviders, OnInit, Type } from "@angular/core";
|
|
6
|
+
import { HttpClient, HttpEvent, HttpHandler, HttpHeaders, HttpInterceptor, HttpRequest, HttpResponse } from "@angular/common/http";
|
|
7
|
+
import { BehaviorSubject, Observable, Subject, Subscription } from "rxjs";
|
|
8
|
+
import * as i1 from "@liquid-js/lyr-core";
|
|
9
|
+
import * as i2 from "@angular/router";
|
|
10
|
+
import { ActivatedRoute, Router, Routes } from "@angular/router";
|
|
11
|
+
import * as i3 from "@angular/forms";
|
|
12
|
+
import { Location } from "@angular/common";
|
|
13
|
+
export declare abstract class NbAuthToken {
|
|
14
|
+
protected payload?: unknown;
|
|
15
|
+
abstract getValue(): string;
|
|
16
|
+
abstract isValid(): boolean;
|
|
17
|
+
/** The name of the strategy that got the token, which is the one that refreshes it. */
|
|
18
|
+
abstract getOwnerStrategyName(): string;
|
|
19
|
+
abstract getCreatedAt(): Date;
|
|
20
|
+
abstract toString(): string;
|
|
21
|
+
getName(): string;
|
|
22
|
+
getPayload(): unknown;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The claims of a JWT: the registered ones (RFC 7519, 4.1) and any others the issuer adds.
|
|
26
|
+
*/
|
|
27
|
+
export interface NbAuthJWTPayload {
|
|
28
|
+
/** Expiration time, in seconds since the epoch. */
|
|
29
|
+
exp?: number;
|
|
30
|
+
/** Issued at, in seconds since the epoch. */
|
|
31
|
+
iat?: number;
|
|
32
|
+
/** Not before, in seconds since the epoch. */
|
|
33
|
+
nbf?: number;
|
|
34
|
+
sub?: string;
|
|
35
|
+
iss?: string;
|
|
36
|
+
aud?: string | string[];
|
|
37
|
+
jti?: string;
|
|
38
|
+
[claim: string]: unknown;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* An OAuth2 token response (RFC 6749, 5.1), and any other fields the server adds.
|
|
42
|
+
*/
|
|
43
|
+
export interface NbAuthOAuth2TokenData {
|
|
44
|
+
access_token?: string;
|
|
45
|
+
token_type?: string;
|
|
46
|
+
/** The lifetime of the access token, in seconds. */
|
|
47
|
+
expires_in?: number | string;
|
|
48
|
+
refresh_token?: string;
|
|
49
|
+
scope?: string;
|
|
50
|
+
[field: string]: unknown;
|
|
51
|
+
}
|
|
52
|
+
export declare class NbAuthTokenNotFoundError extends Error {
|
|
53
|
+
constructor(message: string);
|
|
54
|
+
}
|
|
55
|
+
export declare class NbAuthIllegalTokenError extends Error {
|
|
56
|
+
constructor(message: string);
|
|
57
|
+
}
|
|
58
|
+
export declare class NbAuthEmptyTokenError extends NbAuthIllegalTokenError {
|
|
59
|
+
constructor(message: string);
|
|
60
|
+
}
|
|
61
|
+
export declare class NbAuthIllegalJWTTokenError extends NbAuthIllegalTokenError {
|
|
62
|
+
constructor(message: string);
|
|
63
|
+
}
|
|
64
|
+
export interface NbAuthRefreshableToken {
|
|
65
|
+
getRefreshToken(): string;
|
|
66
|
+
setRefreshToken(refreshToken: string): void;
|
|
67
|
+
}
|
|
68
|
+
export interface NbAuthTokenClass<T = NbAuthToken> {
|
|
69
|
+
NAME: string;
|
|
70
|
+
new (raw: unknown, strategyName: string, expDate?: Date): T;
|
|
71
|
+
}
|
|
72
|
+
export declare function nbAuthCreateToken<T extends NbAuthToken>(tokenClass: NbAuthTokenClass<T>, token: unknown, ownerStrategyName: string, createdAt?: Date): T;
|
|
73
|
+
export declare function decodeJwtPayload(payload: string): NbAuthJWTPayload;
|
|
74
|
+
/** A token that is a plain string; valid while it isn't empty. */
|
|
75
|
+
export declare class NbAuthSimpleToken extends NbAuthToken {
|
|
76
|
+
protected readonly token: unknown;
|
|
77
|
+
protected readonly ownerStrategyName: string;
|
|
78
|
+
static NAME: string;
|
|
79
|
+
protected createdAt: Date;
|
|
80
|
+
constructor(token: unknown, ownerStrategyName: string, createdAt?: Date);
|
|
81
|
+
protected parsePayload(): void;
|
|
82
|
+
protected prepareCreatedAt(date?: Date): Date;
|
|
83
|
+
/** When the token was made, or when the storage says it was. */
|
|
84
|
+
getCreatedAt(): Date;
|
|
85
|
+
/** The token's text; empty when it isn't a string. */
|
|
86
|
+
getValue(): string;
|
|
87
|
+
getOwnerStrategyName(): string;
|
|
88
|
+
/** Whether the token isn't empty. */
|
|
89
|
+
isValid(): boolean;
|
|
90
|
+
/** The token as text, for the storage; empty without one. */
|
|
91
|
+
toString(): string;
|
|
92
|
+
}
|
|
93
|
+
/** A JWT: its payload is decoded, it's created at its `iat` claim, and it's valid until its `exp` claim. */
|
|
94
|
+
export declare class NbAuthJWTToken extends NbAuthSimpleToken {
|
|
95
|
+
static NAME: string;
|
|
96
|
+
protected payload?: NbAuthJWTPayload;
|
|
97
|
+
/** The `iat` claim, when there is one. */
|
|
98
|
+
protected prepareCreatedAt(date?: Date): Date;
|
|
99
|
+
/**
|
|
100
|
+
* Decodes the payload; throws `NbAuthTokenNotFoundError` without a token, and `NbAuthIllegalJWTTokenError` for one
|
|
101
|
+
* that isn't a JWT.
|
|
102
|
+
*/
|
|
103
|
+
protected parsePayload(): void;
|
|
104
|
+
/** The token's claims, or `undefined` without a token. */
|
|
105
|
+
getPayload(): NbAuthJWTPayload | undefined;
|
|
106
|
+
/** The `exp` claim as a date, or `undefined` without one. */
|
|
107
|
+
getTokenExpDate(): Date | undefined;
|
|
108
|
+
/** Whether the token isn't empty and hasn't expired. */
|
|
109
|
+
isValid(): boolean;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* An OAuth2 token response: its `access_token` is the value, and it expires `expires_in` seconds after it was created.
|
|
113
|
+
*/
|
|
114
|
+
export declare class NbAuthOAuth2Token extends NbAuthSimpleToken {
|
|
115
|
+
static NAME: string;
|
|
116
|
+
/**
|
|
117
|
+
* @param data the token response, or its JSON (as the storage gives it)
|
|
118
|
+
*/
|
|
119
|
+
constructor(data: unknown | undefined, ownerStrategyName: string, createdAt?: Date);
|
|
120
|
+
/** The token response; empty when the raw token isn't one. */
|
|
121
|
+
protected get data(): NbAuthOAuth2TokenData;
|
|
122
|
+
/** The `access_token`; empty without one. */
|
|
123
|
+
getValue(): string;
|
|
124
|
+
/** The `refresh_token`; empty without one. */
|
|
125
|
+
getRefreshToken(): string;
|
|
126
|
+
/** Sets the `refresh_token`, e.g. the previous token's after a refresh whose response has none. */
|
|
127
|
+
setRefreshToken(refreshToken: string): void;
|
|
128
|
+
/** The payload is the response itself; throws without a token, or with an empty one. */
|
|
129
|
+
protected parsePayload(): void;
|
|
130
|
+
/** The `token_type`, e.g. `Bearer`; empty without one. */
|
|
131
|
+
getType(): string;
|
|
132
|
+
/** Whether the token has an `access_token` and hasn't expired. */
|
|
133
|
+
isValid(): boolean;
|
|
134
|
+
/** When the token expires, `expires_in` seconds after it was created; `undefined` without `expires_in`. */
|
|
135
|
+
getTokenExpDate(): Date | undefined;
|
|
136
|
+
/** The response as JSON, for the storage. */
|
|
137
|
+
toString(): string;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* An OAuth2 token whose `access_token` is a JWT: its claims say when the token was created and expires, over the
|
|
141
|
+
* response's `expires_in`.
|
|
142
|
+
*/
|
|
143
|
+
export declare class NbAuthOAuth2JWTToken extends NbAuthOAuth2Token {
|
|
144
|
+
static NAME: string;
|
|
145
|
+
protected accessTokenPayload?: NbAuthJWTPayload;
|
|
146
|
+
protected parsePayload(): void;
|
|
147
|
+
protected parseAccessTokenPayload(): void;
|
|
148
|
+
/** The access token's claims; `undefined` when it has none. */
|
|
149
|
+
getAccessTokenPayload(): NbAuthJWTPayload | undefined;
|
|
150
|
+
/** The access token's `iat` claim, when there is one. */
|
|
151
|
+
protected prepareCreatedAt(date?: Date): Date;
|
|
152
|
+
/** Whether the access token has claims, and the token is valid. */
|
|
153
|
+
isValid(): boolean;
|
|
154
|
+
/** The access token's `exp` claim as a date, or the response's `expires_in` without one. */
|
|
155
|
+
getTokenExpDate(): Date | undefined;
|
|
156
|
+
}
|
|
157
|
+
/** What an `NbAuthResult` holds, for `NbAuthResult.from`. */
|
|
158
|
+
export interface NbAuthResultOptions<R = unknown> {
|
|
159
|
+
success: boolean;
|
|
160
|
+
/** What the backend answered, or the error the action failed with. */
|
|
161
|
+
response?: R;
|
|
162
|
+
/** Where to go next; `null`, as the strategies' options use for a redirect they don't want, is none. */
|
|
163
|
+
redirect?: string | null;
|
|
164
|
+
errors?: string[];
|
|
165
|
+
messages?: string[];
|
|
166
|
+
token?: NbAuthToken;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* The outcome of a strategy's action. `R` is the strategy's response: what its backend answered, or the error it failed
|
|
170
|
+
* with.
|
|
171
|
+
*/
|
|
172
|
+
export declare class NbAuthResult<R = unknown> {
|
|
173
|
+
protected success: boolean;
|
|
174
|
+
protected response?: R | undefined;
|
|
175
|
+
protected token?: NbAuthToken;
|
|
176
|
+
protected redirect?: string;
|
|
177
|
+
protected errors: string[];
|
|
178
|
+
protected messages: string[];
|
|
179
|
+
/**
|
|
180
|
+
* A result from named options, which reads better than the constructor's positional ones:
|
|
181
|
+
*
|
|
182
|
+
* ```ts
|
|
183
|
+
* NbAuthResult.from({ success: true, response, redirect: '/dashboard', messages: ['Signed in.'], token });
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
static from<R>(options: NbAuthResultOptions<R>): NbAuthResult<R>;
|
|
187
|
+
/**
|
|
188
|
+
* @param redirect where to go next; `null`, as the strategies' options use for a redirect they don't want, is none
|
|
189
|
+
*/
|
|
190
|
+
constructor(success: boolean, response?: R | undefined, redirect?: string | null, errors?: string[], messages?: string[], token?: NbAuthToken);
|
|
191
|
+
getResponse(): R | undefined;
|
|
192
|
+
getToken(): NbAuthToken | undefined;
|
|
193
|
+
getRedirect(): string | undefined;
|
|
194
|
+
getErrors(): string[];
|
|
195
|
+
getMessages(): string[];
|
|
196
|
+
isSuccess(): boolean;
|
|
197
|
+
isFailure(): boolean;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Merges the sources into the target, deep for plain objects: arrays, dates and regexps are cloned, and instances of
|
|
201
|
+
* other classes (e.g. `HttpHeaders`) are kept whole. Returns the target, or `false` when it isn't an object. To merge
|
|
202
|
+
* without changing any source, give a new object as the target: `deepExtend({}, defaults, options)`.
|
|
203
|
+
*
|
|
204
|
+
* Typed as the target and the sources together, which holds while the sources have (parts of) the target's shape.
|
|
205
|
+
*/
|
|
206
|
+
export declare function deepExtend<T extends object>(target: T): T;
|
|
207
|
+
export declare function deepExtend<T extends object, A>(target: T, a: A): T & A;
|
|
208
|
+
export declare function deepExtend<T extends object, A, B>(target: T, a: A, b: B): T & A & B;
|
|
209
|
+
export declare function deepExtend<T extends object, A, B, C>(target: T, a: A, b: B, c: C): T & A & B & C;
|
|
210
|
+
export declare function deepExtend(target: object, ...sources: unknown[]): object;
|
|
211
|
+
/** Values a dotted path doesn't go into: arrays, functions and classes. */
|
|
212
|
+
type NbPathLeaf = ReadonlyArray<unknown> | ((...args: never) => unknown) | (abstract new (...args: never) => unknown);
|
|
213
|
+
/**
|
|
214
|
+
* T with every property optional, all the way down; arrays, functions and classes are given whole.
|
|
215
|
+
*/
|
|
216
|
+
export type NbAuthDeepPartial<T> = { [K in keyof T]?: NbAuthDeepPartialValue<T[K]>; };
|
|
217
|
+
/** A value of `NbAuthDeepPartial`, each type of a union on its own. */
|
|
218
|
+
type NbAuthDeepPartialValue<V> = V extends NbPathLeaf ? V : V extends object ? NbAuthDeepPartial<V> : V;
|
|
219
|
+
/**
|
|
220
|
+
* The dotted paths `getDeepFromObject` can follow into T, such as `'login'` and `'login.redirect.success'`. Arrays,
|
|
221
|
+
* functions and classes end a path; optional and union properties are followed into their object types.
|
|
222
|
+
*/
|
|
223
|
+
export type NbPath<T> = T extends NbPathLeaf ? never : T extends object ? { [K in keyof T & string]-?: K | `${K}.${NbPath<T[K]>}`; }[keyof T & string] : never;
|
|
224
|
+
/**
|
|
225
|
+
* The value at the dotted path P into T, as `getDeepFromObject` reads it: `undefined` where a step on the way may be
|
|
226
|
+
* missing or isn't an object.
|
|
227
|
+
*/
|
|
228
|
+
export type NbPathValue<T, P extends string> = T extends NbPathLeaf ? undefined : T extends object ? P extends `${infer K}.${infer Rest}` ? K extends keyof T ? NbPathValue<T[K], Rest> : undefined : P extends keyof T ? T[P] : undefined : undefined;
|
|
229
|
+
/**
|
|
230
|
+
* Reads the value at a dotted path, from a copy of the object, or the default where there's none.
|
|
231
|
+
*
|
|
232
|
+
* getDeepFromObject({result: {data: 1}}, 'result.data', 2); // returns 1
|
|
233
|
+
*/
|
|
234
|
+
export declare function getDeepFromObject<T, P extends NbPath<T>>(object: T, name: P): NbPathValue<T, P>;
|
|
235
|
+
export declare function getDeepFromObject(object: unknown, name: string, defaultValue?: unknown): unknown;
|
|
236
|
+
/** The messages (or errors) in a value read from a response: a message, or a list of them; anything else isn't one. */
|
|
237
|
+
export declare function nbAuthMessages(value: unknown): string[];
|
|
238
|
+
export declare function urlBase64Decode(str: string): string;
|
|
239
|
+
export declare function b64decode(str: string): string;
|
|
240
|
+
export declare function b64DecodeUnicode(str: string): string;
|
|
241
|
+
export interface NbStrategyToken {
|
|
242
|
+
class?: NbAuthTokenClass;
|
|
243
|
+
[key: string]: unknown;
|
|
244
|
+
}
|
|
245
|
+
export declare class NbAuthStrategyOptions {
|
|
246
|
+
name: string;
|
|
247
|
+
token?: NbStrategyToken;
|
|
248
|
+
headers?: HttpHeaders | {
|
|
249
|
+
[header: string]: string | string[];
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* The base of the auth strategies. `O` is the strategy's options class, which types `getOption`.
|
|
254
|
+
*/
|
|
255
|
+
export declare abstract class NbAuthStrategy<O extends NbAuthStrategyOptions = NbAuthStrategyOptions> {
|
|
256
|
+
protected defaultOptions?: O;
|
|
257
|
+
/** The default messages, from `NbTextsService`. */
|
|
258
|
+
protected readonly texts: import("@angular/core").Signal<import("@liquid-js/lyr-auth").NbAuthStrategyTexts>;
|
|
259
|
+
/** The options the strategy was set up with, over its defaults and texts. */
|
|
260
|
+
protected readonly givenOptions: import("@angular/core").WritableSignal<NbAuthDeepPartial<O> | undefined>;
|
|
261
|
+
protected readonly resolvedOptions: import("@angular/core").Signal<O | undefined>;
|
|
262
|
+
/** The strategy's options: its defaults, the default messages from the texts, and the options it was given. */
|
|
263
|
+
protected get options(): O | undefined;
|
|
264
|
+
/** Sets the options the strategy works with, over its defaults; they can be partial. */
|
|
265
|
+
setOptions(options: NbAuthDeepPartial<O>): void;
|
|
266
|
+
/**
|
|
267
|
+
* The default messages of the strategy's actions, from `NbTextsService`, over the defaults of its options and under
|
|
268
|
+
* the options it's given.
|
|
269
|
+
*/
|
|
270
|
+
protected textOptions(): object;
|
|
271
|
+
/**
|
|
272
|
+
* The option at a dotted path, such as `'login.redirect.success'`, typed by the strategy's options class; `undefined`
|
|
273
|
+
* before the options are set.
|
|
274
|
+
*/
|
|
275
|
+
getOption<P extends NbPath<O>>(key: P): NbPathValue<O | undefined, P>;
|
|
276
|
+
/**
|
|
277
|
+
* Creates a token of the options' token class from a value, e.g. a response; with `failWhenInvalidToken`, an
|
|
278
|
+
* invalid one throws.
|
|
279
|
+
*/
|
|
280
|
+
createToken(value: unknown, failWhenInvalidToken?: boolean): NbAuthToken;
|
|
281
|
+
getName(): string;
|
|
282
|
+
abstract authenticate(data?: unknown): Observable<NbAuthResult>;
|
|
283
|
+
abstract register(data?: unknown): Observable<NbAuthResult>;
|
|
284
|
+
abstract requestPassword(data?: unknown): Observable<NbAuthResult>;
|
|
285
|
+
abstract resetPassword(data?: unknown): Observable<NbAuthResult>;
|
|
286
|
+
abstract logout(): Observable<NbAuthResult>;
|
|
287
|
+
abstract refreshToken(data?: unknown): Observable<NbAuthResult>;
|
|
288
|
+
protected createFailResponse(_data?: unknown): HttpResponse<unknown>;
|
|
289
|
+
protected createSuccessResponse(_data?: unknown): HttpResponse<unknown>;
|
|
290
|
+
/** The URL of an action: its `endpoint` after the options' `baseEndpoint`, or none without an endpoint. */
|
|
291
|
+
protected getActionEndpoint(action: string): string;
|
|
292
|
+
protected getHeaders(): HttpHeaders;
|
|
293
|
+
}
|
|
294
|
+
export type NbAuthStrategyClass = Type<NbAuthStrategy>;
|
|
295
|
+
export type NbAuthStrategies = Array<[NbAuthStrategyClass, NbAuthStrategyOptions]>;
|
|
296
|
+
export interface NbAuthSocialLink {
|
|
297
|
+
link?: string;
|
|
298
|
+
url?: string;
|
|
299
|
+
target?: string;
|
|
300
|
+
/** The link's text, or its accessible name when it shows an icon. */
|
|
301
|
+
title?: string;
|
|
302
|
+
/** An icon shown in place of the title. */
|
|
303
|
+
icon?: string;
|
|
304
|
+
}
|
|
305
|
+
/** Whether a form shows the messages of a successful action, and the errors of a failed one. */
|
|
306
|
+
export interface NbAuthFormMessagesOptions {
|
|
307
|
+
success: boolean;
|
|
308
|
+
error: boolean;
|
|
309
|
+
}
|
|
310
|
+
/** The options of an auth form. */
|
|
311
|
+
export interface NbAuthFormOptions {
|
|
312
|
+
/** The delay before the redirect after a successful action, while its message is shown, in milliseconds. */
|
|
313
|
+
redirectDelay: number;
|
|
314
|
+
/** The name of the strategy the form uses. */
|
|
315
|
+
strategy: string;
|
|
316
|
+
showMessages: NbAuthFormMessagesOptions;
|
|
317
|
+
/** The social links at the bottom of the form. */
|
|
318
|
+
socialLinks: NbAuthSocialLink[];
|
|
319
|
+
}
|
|
320
|
+
export interface NbAuthLoginFormOptions extends NbAuthFormOptions {
|
|
321
|
+
/** Whether to show the "remember me" checkbox. */
|
|
322
|
+
rememberMe: boolean;
|
|
323
|
+
}
|
|
324
|
+
export interface NbAuthRegisterFormOptions extends NbAuthFormOptions {
|
|
325
|
+
/** Whether the user has to agree to the terms. */
|
|
326
|
+
terms: boolean;
|
|
327
|
+
}
|
|
328
|
+
export interface NbAuthLogoutFormOptions {
|
|
329
|
+
redirectDelay: number;
|
|
330
|
+
strategy: string;
|
|
331
|
+
}
|
|
332
|
+
/** The limits of a field of the auth forms. */
|
|
333
|
+
export interface NbAuthFieldValidation {
|
|
334
|
+
required: boolean;
|
|
335
|
+
}
|
|
336
|
+
/** The limits of a field of the auth forms with a length. */
|
|
337
|
+
export interface NbAuthLengthValidation extends NbAuthFieldValidation {
|
|
338
|
+
minLength: number;
|
|
339
|
+
maxLength: number;
|
|
340
|
+
}
|
|
341
|
+
export interface NbAuthValidationOptions {
|
|
342
|
+
password: NbAuthLengthValidation;
|
|
343
|
+
email: NbAuthFieldValidation;
|
|
344
|
+
fullName: NbAuthLengthValidation;
|
|
345
|
+
}
|
|
346
|
+
/** The options of the auth forms, as the defaults give them. */
|
|
347
|
+
export interface NbAuthForms {
|
|
348
|
+
login: NbAuthLoginFormOptions;
|
|
349
|
+
register: NbAuthRegisterFormOptions;
|
|
350
|
+
requestPassword: NbAuthFormOptions;
|
|
351
|
+
resetPassword: NbAuthFormOptions;
|
|
352
|
+
logout: NbAuthLogoutFormOptions;
|
|
353
|
+
validation: NbAuthValidationOptions;
|
|
354
|
+
}
|
|
355
|
+
export interface NbAuthOptions {
|
|
356
|
+
/** The options of the forms, over the defaults. */
|
|
357
|
+
forms?: NbAuthDeepPartial<NbAuthForms>;
|
|
358
|
+
strategies?: NbAuthStrategies;
|
|
359
|
+
}
|
|
360
|
+
/** The options the auth module works with: the given ones over `defaultAuthOptions`. */
|
|
361
|
+
export interface NbAuthResolvedOptions {
|
|
362
|
+
forms: NbAuthForms;
|
|
363
|
+
strategies: NbAuthStrategies;
|
|
364
|
+
}
|
|
365
|
+
export declare const defaultAuthOptions: NbAuthResolvedOptions;
|
|
366
|
+
export declare const NB_AUTH_OPTIONS: InjectionToken<NbAuthResolvedOptions>;
|
|
367
|
+
export declare const NB_AUTH_USER_OPTIONS: InjectionToken<NbAuthOptions>;
|
|
368
|
+
export declare const NB_AUTH_STRATEGIES: InjectionToken<NbAuthStrategy<NbAuthStrategyOptions>[]>;
|
|
369
|
+
export declare const NB_AUTH_TOKENS: InjectionToken<NbAuthTokenClass<NbAuthToken>[]>;
|
|
370
|
+
export declare const NB_AUTH_INTERCEPTOR_HEADER: InjectionToken<string>;
|
|
371
|
+
export declare const NB_AUTH_TOKEN_INTERCEPTOR_FILTER: InjectionToken<(req: HttpRequest<unknown>) => boolean>;
|
|
372
|
+
/** Where a token is kept. */
|
|
373
|
+
export interface NbTokenStorageOptions {
|
|
374
|
+
/**
|
|
375
|
+
* Whether the token outlives the browser session, e.g. the login form's "remember me". Without it, a token stays
|
|
376
|
+
* where the current one is, or is remembered.
|
|
377
|
+
*/
|
|
378
|
+
remember?: boolean;
|
|
379
|
+
}
|
|
380
|
+
export declare abstract class NbTokenStorage {
|
|
381
|
+
abstract get(): NbAuthToken;
|
|
382
|
+
abstract set(token: NbAuthToken, options?: NbTokenStorageOptions): void;
|
|
383
|
+
abstract clear(): void;
|
|
384
|
+
/** Tells when the token changes from elsewhere, e.g. another tab, so the token service reads it again. */
|
|
385
|
+
readonly changes?: Observable<void>;
|
|
386
|
+
}
|
|
387
|
+
/** What tabs tell each other about a token kept for the session only. */
|
|
388
|
+
type NbTokenMessage = {
|
|
389
|
+
type: 'request';
|
|
390
|
+
} | {
|
|
391
|
+
type: 'session';
|
|
392
|
+
raw: string;
|
|
393
|
+
} | {
|
|
394
|
+
type: 'remembered';
|
|
395
|
+
} | {
|
|
396
|
+
type: 'clear';
|
|
397
|
+
};
|
|
398
|
+
/**
|
|
399
|
+
* Keeps the token in `localStorage` when it's remembered, and in `sessionStorage` when it isn't, so it's gone when the
|
|
400
|
+
* browser closes. Tabs share a session token over a `BroadcastChannel`: a new tab asks the open ones for it, and a
|
|
401
|
+
* new, refreshed or cleared token reaches them all.
|
|
402
|
+
*/
|
|
403
|
+
export declare class NbTokenLocalStorage extends NbTokenStorage {
|
|
404
|
+
private readonly parceler;
|
|
405
|
+
protected key: string;
|
|
406
|
+
/** `localStorage`; not set during server-side rendering, where the token is simply absent. */
|
|
407
|
+
protected storage?: Storage;
|
|
408
|
+
/** `sessionStorage`, for a token that isn't remembered. */
|
|
409
|
+
protected session?: Storage;
|
|
410
|
+
protected channel?: BroadcastChannel;
|
|
411
|
+
protected readonly changed: Subject<void>;
|
|
412
|
+
readonly changes: Observable<void>;
|
|
413
|
+
constructor();
|
|
414
|
+
/** The stored token, the session's over the remembered one; an empty token of the fallback class without one. */
|
|
415
|
+
get(): NbAuthToken;
|
|
416
|
+
/**
|
|
417
|
+
* Keeps the token: in `localStorage` when it's remembered, in `sessionStorage`, shared with the other tabs, when it
|
|
418
|
+
* isn't.
|
|
419
|
+
*/
|
|
420
|
+
set(token: NbAuthToken, options?: NbTokenStorageOptions): void;
|
|
421
|
+
/** Removes the token from both storages, and from the other tabs. */
|
|
422
|
+
clear(): void;
|
|
423
|
+
protected read(): string | undefined;
|
|
424
|
+
protected post(message: NbTokenMessage): void;
|
|
425
|
+
protected receive(message: NbTokenMessage): void;
|
|
426
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NbTokenLocalStorage, never>;
|
|
427
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
428
|
+
}
|
|
429
|
+
/** Gets, sets and clears the token in the `NbTokenStorage`, and tells when it changes, also from another tab. */
|
|
430
|
+
export declare class NbTokenService {
|
|
431
|
+
protected readonly tokenStorage: NbTokenStorage;
|
|
432
|
+
protected token$: BehaviorSubject<NbAuthToken | undefined>;
|
|
433
|
+
constructor();
|
|
434
|
+
/** The token, now and whenever it's set or cleared. */
|
|
435
|
+
tokenChange(): Observable<NbAuthToken>;
|
|
436
|
+
/** Stores the token, as `NbAuthService` does with the one a strategy gets. */
|
|
437
|
+
set(token: NbAuthToken, options?: NbTokenStorageOptions): Observable<void>;
|
|
438
|
+
/** The stored token. */
|
|
439
|
+
get(): Observable<NbAuthToken>;
|
|
440
|
+
/** Removes the token. */
|
|
441
|
+
clear(): Observable<void>;
|
|
442
|
+
protected publishStoredToken(): void;
|
|
443
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NbTokenService, never>;
|
|
444
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Signs in, up and out with a named strategy, and keeps the token it gets in the token storage; the auth components
|
|
448
|
+
* go through it rather than a strategy.
|
|
449
|
+
*/
|
|
450
|
+
export declare class NbAuthService {
|
|
451
|
+
protected readonly tokenService: NbTokenService;
|
|
452
|
+
protected readonly strategies: NbAuthStrategy<import("@liquid-js/lyr-auth").NbAuthStrategyOptions>[];
|
|
453
|
+
/** The stored token; an empty one of the fallback class when there's none. */
|
|
454
|
+
getToken(): Observable<NbAuthToken>;
|
|
455
|
+
/** Whether the stored token is valid. */
|
|
456
|
+
isAuthenticated(): Observable<boolean>;
|
|
457
|
+
/**
|
|
458
|
+
* Whether the stored token is valid, after refreshing it with its strategy when it has a value but isn't valid, e.g.
|
|
459
|
+
* has expired.
|
|
460
|
+
*/
|
|
461
|
+
isAuthenticatedOrRefresh(): Observable<boolean>;
|
|
462
|
+
/** The token, now and whenever it's set or cleared, also from another tab. */
|
|
463
|
+
onTokenChange(): Observable<NbAuthToken>;
|
|
464
|
+
/** Whether the token is valid, now and whenever it changes. */
|
|
465
|
+
onAuthenticationChange(): Observable<boolean>;
|
|
466
|
+
/**
|
|
467
|
+
* Signs in with the strategy, and keeps the token it gets. A `rememberMe` in `data`, as the login form sends, tells
|
|
468
|
+
* whether the token outlives the browser session; without it the token stays where the current one is, or is
|
|
469
|
+
* remembered.
|
|
470
|
+
*
|
|
471
|
+
* @param data what the strategy takes, such as the login form's `NbAuthCredentials`
|
|
472
|
+
*/
|
|
473
|
+
authenticate(strategyName: string, data?: unknown): Observable<NbAuthResult>;
|
|
474
|
+
/** Registers with the strategy, and keeps the token it gets. */
|
|
475
|
+
register(strategyName: string, data?: unknown): Observable<NbAuthResult>;
|
|
476
|
+
/** Signs out with the strategy, and clears the token when that succeeds. */
|
|
477
|
+
logout(strategyName: string): Observable<NbAuthResult>;
|
|
478
|
+
/** Asks the strategy to send the password reset instructions, e.g. to the email in `data`. */
|
|
479
|
+
requestPassword(strategyName: string, data?: unknown): Observable<NbAuthResult>;
|
|
480
|
+
/** Sets a new password with the strategy, from `data`, e.g. the reset password form's. */
|
|
481
|
+
resetPassword(strategyName: string, data?: unknown): Observable<NbAuthResult>;
|
|
482
|
+
/** Refreshes the token with the strategy, e.g. given the current token, and keeps the one it gets. */
|
|
483
|
+
refreshToken(strategyName: string, data?: unknown): Observable<NbAuthResult>;
|
|
484
|
+
/** The strategy set up under the name; throws when there's none. */
|
|
485
|
+
protected getStrategy(strategyName: string): NbAuthStrategy;
|
|
486
|
+
private processResultToken;
|
|
487
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NbAuthService, never>;
|
|
488
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
489
|
+
}
|
|
490
|
+
export declare class NbAuthComponent {
|
|
491
|
+
protected readonly texts: import("@angular/core").Signal<import("@liquid-js/lyr-auth").NbAuthTexts>;
|
|
492
|
+
protected readonly destroyRef: DestroyRef;
|
|
493
|
+
protected readonly auth: NbAuthService;
|
|
494
|
+
protected readonly location: Location;
|
|
495
|
+
subscription: Subscription;
|
|
496
|
+
authenticated: boolean;
|
|
497
|
+
token: string;
|
|
498
|
+
constructor();
|
|
499
|
+
back(): boolean;
|
|
500
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NbAuthComponent, never>;
|
|
501
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<NbAuthComponent, "nb-auth", never, {}, {}, never, never, true, never>;
|
|
502
|
+
}
|
|
503
|
+
export declare class NbAuthBlockComponent {
|
|
504
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NbAuthBlockComponent, never>;
|
|
505
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<NbAuthBlockComponent, "nb-auth-block", never, {}, {}, never, ["*"], true, never>;
|
|
506
|
+
}
|
|
507
|
+
export declare class NbUser {
|
|
508
|
+
id?: number | undefined;
|
|
509
|
+
email?: string | undefined;
|
|
510
|
+
password?: string | undefined;
|
|
511
|
+
rememberMe?: boolean | undefined;
|
|
512
|
+
terms?: boolean | undefined;
|
|
513
|
+
confirmPassword?: string | undefined;
|
|
514
|
+
fullName?: string | undefined;
|
|
515
|
+
constructor(id?: number | undefined, email?: string | undefined, password?: string | undefined, rememberMe?: boolean | undefined, terms?: boolean | undefined, confirmPassword?: string | undefined, fullName?: string | undefined);
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* What the auth forms send to their strategy, each form its own fields: the login form the email, password and
|
|
519
|
+
* "remember me", the register form all but "remember me", the request password form the email, and the reset password
|
|
520
|
+
* form the password and its confirmation.
|
|
521
|
+
*/
|
|
522
|
+
export interface NbAuthCredentials {
|
|
523
|
+
email?: string;
|
|
524
|
+
password?: string;
|
|
525
|
+
confirmPassword?: string;
|
|
526
|
+
fullName?: string;
|
|
527
|
+
rememberMe?: boolean;
|
|
528
|
+
terms?: boolean;
|
|
529
|
+
}
|
|
530
|
+
export declare class NbLoginComponent {
|
|
531
|
+
protected readonly texts: import("@angular/core").Signal<import("@liquid-js/lyr-auth").NbAuthTexts>;
|
|
532
|
+
protected readonly service: NbAuthService;
|
|
533
|
+
protected readonly options: NbAuthResolvedOptions;
|
|
534
|
+
protected readonly cd: ChangeDetectorRef;
|
|
535
|
+
protected readonly router: Router;
|
|
536
|
+
redirectDelay: number;
|
|
537
|
+
showMessages: NbAuthFormMessagesOptions;
|
|
538
|
+
strategy: string;
|
|
539
|
+
errors: string[];
|
|
540
|
+
messages: string[];
|
|
541
|
+
user: NbAuthCredentials;
|
|
542
|
+
submitted: boolean;
|
|
543
|
+
socialLinks: NbAuthSocialLink[];
|
|
544
|
+
rememberMe: boolean;
|
|
545
|
+
login(): void;
|
|
546
|
+
getConfigValue<P extends NbPath<NbAuthResolvedOptions>>(key: P): NbPathValue<NbAuthResolvedOptions, P>;
|
|
547
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NbLoginComponent, never>;
|
|
548
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<NbLoginComponent, "nb-login", never, {}, {}, never, never, true, never>;
|
|
549
|
+
}
|
|
550
|
+
export declare class NbRegisterComponent {
|
|
551
|
+
protected readonly texts: import("@angular/core").Signal<import("@liquid-js/lyr-auth").NbAuthTexts>;
|
|
552
|
+
protected readonly service: NbAuthService;
|
|
553
|
+
protected readonly options: NbAuthResolvedOptions;
|
|
554
|
+
protected readonly cd: ChangeDetectorRef;
|
|
555
|
+
protected readonly router: Router;
|
|
556
|
+
redirectDelay: number;
|
|
557
|
+
showMessages: NbAuthFormMessagesOptions;
|
|
558
|
+
strategy: string;
|
|
559
|
+
submitted: boolean;
|
|
560
|
+
errors: string[];
|
|
561
|
+
messages: string[];
|
|
562
|
+
user: NbAuthCredentials;
|
|
563
|
+
socialLinks: NbAuthSocialLink[];
|
|
564
|
+
register(): void;
|
|
565
|
+
getConfigValue<P extends NbPath<NbAuthResolvedOptions>>(key: P): NbPathValue<NbAuthResolvedOptions, P>;
|
|
566
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NbRegisterComponent, never>;
|
|
567
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<NbRegisterComponent, "nb-register", never, {}, {}, never, never, true, never>;
|
|
568
|
+
}
|
|
569
|
+
export declare class NbRequestPasswordComponent {
|
|
570
|
+
protected readonly texts: import("@angular/core").Signal<import("@liquid-js/lyr-auth").NbAuthTexts>;
|
|
571
|
+
protected readonly service: NbAuthService;
|
|
572
|
+
protected readonly options: NbAuthResolvedOptions;
|
|
573
|
+
protected readonly cd: ChangeDetectorRef;
|
|
574
|
+
protected readonly router: Router;
|
|
575
|
+
redirectDelay: number;
|
|
576
|
+
showMessages: NbAuthFormMessagesOptions;
|
|
577
|
+
strategy: string;
|
|
578
|
+
submitted: boolean;
|
|
579
|
+
errors: string[];
|
|
580
|
+
messages: string[];
|
|
581
|
+
user: NbAuthCredentials;
|
|
582
|
+
requestPass(): void;
|
|
583
|
+
getConfigValue<P extends NbPath<NbAuthResolvedOptions>>(key: P): NbPathValue<NbAuthResolvedOptions, P>;
|
|
584
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NbRequestPasswordComponent, never>;
|
|
585
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<NbRequestPasswordComponent, "nb-request-password-page", never, {}, {}, never, never, true, never>;
|
|
586
|
+
}
|
|
587
|
+
export declare class NbResetPasswordComponent {
|
|
588
|
+
protected readonly texts: import("@angular/core").Signal<import("@liquid-js/lyr-auth").NbAuthTexts>;
|
|
589
|
+
protected readonly service: NbAuthService;
|
|
590
|
+
protected readonly options: NbAuthResolvedOptions;
|
|
591
|
+
protected readonly cd: ChangeDetectorRef;
|
|
592
|
+
protected readonly router: Router;
|
|
593
|
+
redirectDelay: number;
|
|
594
|
+
showMessages: NbAuthFormMessagesOptions;
|
|
595
|
+
strategy: string;
|
|
596
|
+
submitted: boolean;
|
|
597
|
+
errors: string[];
|
|
598
|
+
messages: string[];
|
|
599
|
+
user: NbAuthCredentials;
|
|
600
|
+
resetPass(): void;
|
|
601
|
+
getConfigValue<P extends NbPath<NbAuthResolvedOptions>>(key: P): NbPathValue<NbAuthResolvedOptions, P>;
|
|
602
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NbResetPasswordComponent, never>;
|
|
603
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<NbResetPasswordComponent, "nb-reset-password-page", never, {}, {}, never, never, true, never>;
|
|
604
|
+
}
|
|
605
|
+
export declare class NbLogoutComponent implements OnInit {
|
|
606
|
+
protected readonly texts: import("@angular/core").Signal<import("@liquid-js/lyr-auth").NbAuthTexts>;
|
|
607
|
+
protected readonly service: NbAuthService;
|
|
608
|
+
protected readonly options: NbAuthResolvedOptions;
|
|
609
|
+
protected readonly router: Router;
|
|
610
|
+
redirectDelay: number;
|
|
611
|
+
strategy: string;
|
|
612
|
+
ngOnInit(): void;
|
|
613
|
+
logout(strategy: string): void;
|
|
614
|
+
getConfigValue<P extends NbPath<NbAuthResolvedOptions>>(key: P): NbPathValue<NbAuthResolvedOptions, P>;
|
|
615
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NbLogoutComponent, never>;
|
|
616
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<NbLogoutComponent, "nb-logout", never, {}, {}, never, never, true, never>;
|
|
617
|
+
}
|
|
618
|
+
export declare function nbStrategiesFactory(options: NbAuthResolvedOptions, injector: Injector): NbAuthStrategy[];
|
|
619
|
+
export declare function nbTokensFactory(strategies: NbAuthStrategy[]): NbAuthTokenClass[];
|
|
620
|
+
export declare function nbOptionsFactory(options?: NbAuthOptions): NbAuthResolvedOptions;
|
|
621
|
+
export declare function nbNoOpInterceptorFilter(_req: HttpRequest<unknown>): boolean;
|
|
622
|
+
/**
|
|
623
|
+
* Provides the auth services, strategies and tokens, in place of `NbAuthModule.forRoot()`.
|
|
624
|
+
*/
|
|
625
|
+
export declare function provideNbAuth(nbAuthOptions?: NbAuthOptions): EnvironmentProviders;
|
|
626
|
+
export declare class NbAuthModule {
|
|
627
|
+
static forRoot(nbAuthOptions?: NbAuthOptions): ModuleWithProviders<NbAuthModule>;
|
|
628
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NbAuthModule, never>;
|
|
629
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<NbAuthModule, never, [typeof i1.NbLayoutModule, typeof i1.NbCardModule, typeof i1.NbCheckboxModule, typeof i1.NbAlertModule, typeof i1.NbInputModule, typeof i1.NbButtonModule, typeof i2.RouterModule, typeof i3.FormsModule, typeof i1.NbIconModule, typeof NbAuthComponent, typeof NbAuthBlockComponent, typeof NbLoginComponent, typeof NbRegisterComponent, typeof NbRequestPasswordComponent, typeof NbResetPasswordComponent, typeof NbLogoutComponent], [typeof NbAuthComponent, typeof NbAuthBlockComponent, typeof NbLoginComponent, typeof NbRegisterComponent, typeof NbRequestPasswordComponent, typeof NbResetPasswordComponent, typeof NbLogoutComponent]>;
|
|
630
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<NbAuthModule>;
|
|
631
|
+
}
|
|
632
|
+
export declare const routes: Routes;
|
|
633
|
+
/**
|
|
634
|
+
* The texts of the authentication pages. `provideNbTexts({ auth: { ... } })` changes them, and they're translated
|
|
635
|
+
* with Angular's i18n, as `$localize` messages with ids like `@@nb.auth.loginTitle`.
|
|
636
|
+
*/
|
|
637
|
+
export interface NbAuthTexts {
|
|
638
|
+
/** Label of the link back from the authentication pages. */
|
|
639
|
+
back: string;
|
|
640
|
+
/** Shown while logging out. */
|
|
641
|
+
loggingOut: string;
|
|
642
|
+
/** Heads the errors of a request. */
|
|
643
|
+
errorTitle: string;
|
|
644
|
+
/** Heads the messages of a successful request. */
|
|
645
|
+
successTitle: string;
|
|
646
|
+
/** Names the links to sign in with other services. */
|
|
647
|
+
socialLabel: string;
|
|
648
|
+
/** Before the links to sign in with other services. */
|
|
649
|
+
socialPrompt: string;
|
|
650
|
+
emailLabel: string;
|
|
651
|
+
emailPlaceholder: string;
|
|
652
|
+
emailRequired: string;
|
|
653
|
+
emailInvalid: string;
|
|
654
|
+
passwordLabel: string;
|
|
655
|
+
passwordPlaceholder: string;
|
|
656
|
+
passwordRequired: string;
|
|
657
|
+
/** Given the shortest and the longest password. */
|
|
658
|
+
passwordLength: (min: number, max: number) => string;
|
|
659
|
+
fullNameLabel: string;
|
|
660
|
+
fullNamePlaceholder: string;
|
|
661
|
+
fullNameRequired: string;
|
|
662
|
+
/** Given the shortest and the longest name. */
|
|
663
|
+
fullNameLength: (min: number, max: number) => string;
|
|
664
|
+
confirmPasswordPlaceholder: string;
|
|
665
|
+
confirmPasswordRequired: string;
|
|
666
|
+
passwordMismatch: string;
|
|
667
|
+
loginTitle: string;
|
|
668
|
+
loginSubtitle: string;
|
|
669
|
+
forgotPassword: string;
|
|
670
|
+
rememberMe: string;
|
|
671
|
+
loginSubmit: string;
|
|
672
|
+
/** Before the link to the registration page. */
|
|
673
|
+
noAccount: string;
|
|
674
|
+
/** The link to the registration page. */
|
|
675
|
+
registerLink: string;
|
|
676
|
+
registerTitle: string;
|
|
677
|
+
/** Label of the password confirmation on the registration page. */
|
|
678
|
+
repeatPasswordLabel: string;
|
|
679
|
+
/** Before the link to the terms. */
|
|
680
|
+
agreeTo: string;
|
|
681
|
+
terms: string;
|
|
682
|
+
registerSubmit: string;
|
|
683
|
+
/** Before the link to the login page. */
|
|
684
|
+
haveAccount: string;
|
|
685
|
+
/** The link to the login page. */
|
|
686
|
+
loginLink: string;
|
|
687
|
+
/** Names the links to the login page. */
|
|
688
|
+
signInLabel: string;
|
|
689
|
+
requestPasswordTitle: string;
|
|
690
|
+
requestPasswordSubtitle: string;
|
|
691
|
+
requestPasswordEmailLabel: string;
|
|
692
|
+
requestPasswordSubmit: string;
|
|
693
|
+
/** The link back to the login page. */
|
|
694
|
+
backToLogin: string;
|
|
695
|
+
/** Names the links to the login and registration pages. */
|
|
696
|
+
signInOrUpLabel: string;
|
|
697
|
+
resetPasswordTitle: string;
|
|
698
|
+
resetPasswordSubtitle: string;
|
|
699
|
+
newPasswordLabel: string;
|
|
700
|
+
newPasswordPlaceholder: string;
|
|
701
|
+
/** Label of the password confirmation when the password is changed. */
|
|
702
|
+
confirmPasswordLabel: string;
|
|
703
|
+
resetPasswordSubmit: string;
|
|
704
|
+
}
|
|
705
|
+
/**
|
|
706
|
+
* The messages of authentication strategies, shown on the authentication pages. Options given to a strategy's
|
|
707
|
+
* `setup`, e.g. `login.defaultErrors`, are used over them.
|
|
708
|
+
*/
|
|
709
|
+
export interface NbAuthStrategyTexts {
|
|
710
|
+
/** When logging in fails. */
|
|
711
|
+
loginError: string;
|
|
712
|
+
/** When a request fails. */
|
|
713
|
+
error: string;
|
|
714
|
+
/** When a request fails and there's nothing more to tell. */
|
|
715
|
+
unknownError: string;
|
|
716
|
+
/** When a token from the backend isn't valid. */
|
|
717
|
+
invalidToken: string;
|
|
718
|
+
/** When a sign-in redirect comes back without the state this browser sent, e.g. one it didn't start. */
|
|
719
|
+
invalidState: string;
|
|
720
|
+
loginSuccess: string;
|
|
721
|
+
registerSuccess: string;
|
|
722
|
+
requestPasswordSuccess: string;
|
|
723
|
+
resetPasswordSuccess: string;
|
|
724
|
+
logoutSuccess: string;
|
|
725
|
+
refreshTokenSuccess: string;
|
|
726
|
+
authenticateSuccess: string;
|
|
727
|
+
}
|
|
728
|
+
declare module '@liquid-js/lyr-core' {
|
|
729
|
+
interface NbTexts {
|
|
730
|
+
auth: NbAuthTexts;
|
|
731
|
+
authStrategy: NbAuthStrategyTexts;
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
/** The texts of the authentication pages. @internal */
|
|
735
|
+
export declare function injectNbAuthTexts(): import("@angular/core").Signal<NbAuthTexts>;
|
|
736
|
+
/** The messages of authentication strategies. @internal */
|
|
737
|
+
export declare function injectNbAuthStrategyTexts(): import("@angular/core").Signal<NbAuthStrategyTexts>;
|
|
738
|
+
/**
|
|
739
|
+
* Sends the token as a `Bearer` authorization header, refreshing it first when it has expired. Without a valid token
|
|
740
|
+
* the request goes without one, so the app gets the 401 or 403 and can act on it, e.g. go to the login page.
|
|
741
|
+
*
|
|
742
|
+
* `NB_AUTH_TOKEN_INTERCEPTOR_FILTER` says which requests to leave alone, and the default leaves all of them alone:
|
|
743
|
+
* provide a filter that returns `false` for the requests that need the token.
|
|
744
|
+
*/
|
|
745
|
+
export declare class NbAuthJWTInterceptor implements HttpInterceptor {
|
|
746
|
+
private readonly injector;
|
|
747
|
+
protected readonly filter: (req: HttpRequest<unknown>) => boolean;
|
|
748
|
+
intercept(req: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>>;
|
|
749
|
+
protected get authService(): NbAuthService;
|
|
750
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NbAuthJWTInterceptor, never>;
|
|
751
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
752
|
+
}
|
|
753
|
+
/**
|
|
754
|
+
* Sends the token's value as it is, in the `NB_AUTH_INTERCEPTOR_HEADER` header (`Authorization` by default), with
|
|
755
|
+
* every request that goes out while there is a token.
|
|
756
|
+
*/
|
|
757
|
+
export declare class NbAuthSimpleInterceptor implements HttpInterceptor {
|
|
758
|
+
private readonly injector;
|
|
759
|
+
protected readonly headerName: string;
|
|
760
|
+
intercept(req: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>>;
|
|
761
|
+
protected get authService(): NbAuthService;
|
|
762
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NbAuthSimpleInterceptor, never>;
|
|
763
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
764
|
+
}
|
|
765
|
+
export interface NbTokenPack {
|
|
766
|
+
name: string;
|
|
767
|
+
ownerStrategyName: string;
|
|
768
|
+
createdAt: number;
|
|
769
|
+
value: string;
|
|
770
|
+
}
|
|
771
|
+
/**
|
|
772
|
+
* The class a stored token is restored as when its own isn't among `NB_AUTH_TOKENS`, and of the empty token when
|
|
773
|
+
* there's none stored; `NbAuthSimpleToken` as `provideNbAuth` sets it.
|
|
774
|
+
*/
|
|
775
|
+
export declare const NB_AUTH_FALLBACK_TOKEN: InjectionToken<NbAuthTokenClass<NbAuthToken>>;
|
|
776
|
+
/** Writes a token as JSON for the storage, with its class, strategy and creation time, and reads it back. */
|
|
777
|
+
export declare class NbAuthTokenParceler {
|
|
778
|
+
private readonly fallbackClass;
|
|
779
|
+
private readonly tokenClasses;
|
|
780
|
+
wrap(token: NbAuthToken): string;
|
|
781
|
+
/** Restores a token from its parcel; the fallback class's empty token without one, or from one it can't read. */
|
|
782
|
+
unwrap(value?: string): NbAuthToken;
|
|
783
|
+
protected getClassByName(name: string): NbAuthTokenClass | undefined;
|
|
784
|
+
protected parseTokenPack(value?: string): NbTokenPack | undefined;
|
|
785
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NbAuthTokenParceler, never>;
|
|
786
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
787
|
+
}
|
|
788
|
+
export declare class NbDummyAuthStrategyOptions extends NbAuthStrategyOptions {
|
|
789
|
+
token?: NbStrategyToken;
|
|
790
|
+
delay?: number;
|
|
791
|
+
alwaysFail?: boolean;
|
|
792
|
+
}
|
|
793
|
+
export declare const dummyStrategyOptions: NbDummyAuthStrategyOptions;
|
|
794
|
+
/**
|
|
795
|
+
* A strategy without a backend, for setting up the auth before there is one: every action succeeds after `delay`
|
|
796
|
+
* milliseconds with a simple token and a redirect to `/`, or fails when `alwaysFail` is set.
|
|
797
|
+
*
|
|
798
|
+
* Strategy settings:
|
|
799
|
+
*
|
|
800
|
+
* ```ts
|
|
801
|
+
* export class NbDummyAuthStrategyOptions extends NbAuthStrategyOptions {
|
|
802
|
+
* name = '';
|
|
803
|
+
* token?: NbStrategyToken = {
|
|
804
|
+
* class: NbAuthSimpleToken,
|
|
805
|
+
* };
|
|
806
|
+
* delay?: number = 1000;
|
|
807
|
+
* alwaysFail?: boolean = false;
|
|
808
|
+
* }
|
|
809
|
+
* ```
|
|
810
|
+
*/
|
|
811
|
+
export declare class NbDummyAuthStrategy extends NbAuthStrategy<NbDummyAuthStrategyOptions> {
|
|
812
|
+
protected defaultOptions: NbDummyAuthStrategyOptions;
|
|
813
|
+
static setup(options: NbDummyAuthStrategyOptions): [NbAuthStrategyClass, NbDummyAuthStrategyOptions];
|
|
814
|
+
authenticate(data?: unknown): Observable<NbAuthResult<HttpResponse<unknown>>>;
|
|
815
|
+
register(data?: unknown): Observable<NbAuthResult<HttpResponse<unknown>>>;
|
|
816
|
+
requestPassword(data?: unknown): Observable<NbAuthResult<HttpResponse<unknown>>>;
|
|
817
|
+
resetPassword(data?: unknown): Observable<NbAuthResult<HttpResponse<unknown>>>;
|
|
818
|
+
logout(data?: unknown): Observable<NbAuthResult<HttpResponse<unknown>>>;
|
|
819
|
+
refreshToken(data?: unknown): Observable<NbAuthResult<HttpResponse<unknown>>>;
|
|
820
|
+
protected createDummyResult(data?: unknown): NbAuthResult<HttpResponse<unknown>>;
|
|
821
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NbDummyAuthStrategy, never>;
|
|
822
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
823
|
+
}
|
|
824
|
+
/** The modules (actions) of the password strategy, as its options name them. */
|
|
825
|
+
export type NbPasswordStrategyModuleName = 'login' | 'register' | 'requestPass' | 'resetPass' | 'logout' | 'refreshToken';
|
|
826
|
+
export interface NbPasswordStrategyModule {
|
|
827
|
+
alwaysFail?: boolean;
|
|
828
|
+
endpoint?: string;
|
|
829
|
+
method?: string;
|
|
830
|
+
/** Where to go after the action; `null` turns a default redirect off, while a missing one keeps the default. */
|
|
831
|
+
redirect?: {
|
|
832
|
+
success?: string | null;
|
|
833
|
+
failure?: string | null;
|
|
834
|
+
};
|
|
835
|
+
requireValidToken?: boolean;
|
|
836
|
+
defaultErrors?: string[];
|
|
837
|
+
defaultMessages?: string[];
|
|
838
|
+
}
|
|
839
|
+
export interface NbPasswordStrategyReset extends NbPasswordStrategyModule {
|
|
840
|
+
resetPasswordTokenKey?: string;
|
|
841
|
+
}
|
|
842
|
+
export interface NbPasswordStrategyToken extends NbStrategyToken {
|
|
843
|
+
key?: string;
|
|
844
|
+
/** Reads the token value from a successful response of the given module (action). */
|
|
845
|
+
getter?(module: string, res: HttpResponse<unknown>, options: NbPasswordAuthStrategyOptions): unknown;
|
|
846
|
+
}
|
|
847
|
+
export interface NbPasswordStrategyMessage {
|
|
848
|
+
key?: string;
|
|
849
|
+
/**
|
|
850
|
+
* Reads the messages from a successful response, or the errors from a failed one, of the given module (action). The
|
|
851
|
+
* response is the strategy's own: an `HttpResponse` or `HttpErrorResponse` in the password strategy.
|
|
852
|
+
*/
|
|
853
|
+
getter?(module: string, res: unknown, options: NbAuthStrategyOptions): string[];
|
|
854
|
+
}
|
|
855
|
+
export declare class NbPasswordAuthStrategyOptions extends NbAuthStrategyOptions {
|
|
856
|
+
baseEndpoint?: string;
|
|
857
|
+
login?: boolean | NbPasswordStrategyModule;
|
|
858
|
+
register?: boolean | NbPasswordStrategyModule;
|
|
859
|
+
requestPass?: boolean | NbPasswordStrategyModule;
|
|
860
|
+
resetPass?: boolean | NbPasswordStrategyReset;
|
|
861
|
+
logout?: boolean | NbPasswordStrategyReset;
|
|
862
|
+
refreshToken?: boolean | NbPasswordStrategyModule;
|
|
863
|
+
token?: NbPasswordStrategyToken;
|
|
864
|
+
errors?: NbPasswordStrategyMessage;
|
|
865
|
+
messages?: NbPasswordStrategyMessage;
|
|
866
|
+
validation?: {
|
|
867
|
+
password?: {
|
|
868
|
+
required?: boolean;
|
|
869
|
+
minLength?: number;
|
|
870
|
+
maxLength?: number;
|
|
871
|
+
regexp?: string;
|
|
872
|
+
};
|
|
873
|
+
email?: {
|
|
874
|
+
required?: boolean;
|
|
875
|
+
regexp?: string;
|
|
876
|
+
};
|
|
877
|
+
fullName?: {
|
|
878
|
+
required?: boolean;
|
|
879
|
+
minLength?: number;
|
|
880
|
+
maxLength?: number;
|
|
881
|
+
regexp?: string;
|
|
882
|
+
};
|
|
883
|
+
};
|
|
884
|
+
}
|
|
885
|
+
export declare const passwordStrategyOptions: NbPasswordAuthStrategyOptions;
|
|
886
|
+
/**
|
|
887
|
+
* Signs in, up and out, and requests and resets the password, against an email and password backend. Each action
|
|
888
|
+
* (`login`, `register`, `requestPass`, `resetPass`, `logout`, `refreshToken`) sends its data to its `endpoint` after
|
|
889
|
+
* `baseEndpoint`, reads the token, messages and errors from the response with the `token`, `messages` and `errors`
|
|
890
|
+
* getters, and redirects as its `redirect` says; `resetPass` adds the reset token from the page's query under
|
|
891
|
+
* `resetPasswordTokenKey`. With `requireValidToken`, a response without a valid token fails the action.
|
|
892
|
+
*
|
|
893
|
+
* Strategy settings; `setup` takes the ones to change, over these defaults. `defaultErrors` and `defaultMessages` are
|
|
894
|
+
* the `authStrategy` texts (`provideNbTexts`), unless the given options set them:
|
|
895
|
+
*
|
|
896
|
+
* ```ts
|
|
897
|
+
*export class NbPasswordAuthStrategyOptions extends NbAuthStrategyOptions {
|
|
898
|
+
* name = '';
|
|
899
|
+
* baseEndpoint?: string = '/api/auth/';
|
|
900
|
+
* login?: boolean | NbPasswordStrategyModule = {
|
|
901
|
+
* alwaysFail: false,
|
|
902
|
+
* endpoint: 'login',
|
|
903
|
+
* method: 'post',
|
|
904
|
+
* requireValidToken: true,
|
|
905
|
+
* redirect: {
|
|
906
|
+
* success: '/',
|
|
907
|
+
* failure: null,
|
|
908
|
+
* },
|
|
909
|
+
* defaultErrors: ['Login/Email combination is not correct, please try again.'],
|
|
910
|
+
* defaultMessages: ['You have been successfully logged in.'],
|
|
911
|
+
* };
|
|
912
|
+
* register?: boolean | NbPasswordStrategyModule = {
|
|
913
|
+
* alwaysFail: false,
|
|
914
|
+
* endpoint: 'register',
|
|
915
|
+
* method: 'post',
|
|
916
|
+
* requireValidToken: true,
|
|
917
|
+
* redirect: {
|
|
918
|
+
* success: '/',
|
|
919
|
+
* failure: null,
|
|
920
|
+
* },
|
|
921
|
+
* defaultErrors: ['Something went wrong, please try again.'],
|
|
922
|
+
* defaultMessages: ['You have been successfully registered.'],
|
|
923
|
+
* };
|
|
924
|
+
* requestPass?: boolean | NbPasswordStrategyModule = {
|
|
925
|
+
* endpoint: 'request-pass',
|
|
926
|
+
* method: 'post',
|
|
927
|
+
* redirect: {
|
|
928
|
+
* success: '/',
|
|
929
|
+
* failure: null,
|
|
930
|
+
* },
|
|
931
|
+
* defaultErrors: ['Something went wrong, please try again.'],
|
|
932
|
+
* defaultMessages: ['Reset password instructions have been sent to your email.'],
|
|
933
|
+
* };
|
|
934
|
+
* resetPass?: boolean | NbPasswordStrategyReset = {
|
|
935
|
+
* endpoint: 'reset-pass',
|
|
936
|
+
* method: 'put',
|
|
937
|
+
* redirect: {
|
|
938
|
+
* success: '/',
|
|
939
|
+
* failure: null,
|
|
940
|
+
* },
|
|
941
|
+
* resetPasswordTokenKey: 'reset_password_token',
|
|
942
|
+
* defaultErrors: ['Something went wrong, please try again.'],
|
|
943
|
+
* defaultMessages: ['Your password has been successfully changed.'],
|
|
944
|
+
* };
|
|
945
|
+
* logout?: boolean | NbPasswordStrategyReset = {
|
|
946
|
+
* alwaysFail: false,
|
|
947
|
+
* endpoint: 'logout',
|
|
948
|
+
* method: 'delete',
|
|
949
|
+
* redirect: {
|
|
950
|
+
* success: '/',
|
|
951
|
+
* failure: null,
|
|
952
|
+
* },
|
|
953
|
+
* defaultErrors: ['Something went wrong, please try again.'],
|
|
954
|
+
* defaultMessages: ['You have been successfully logged out.'],
|
|
955
|
+
* };
|
|
956
|
+
* refreshToken?: boolean | NbPasswordStrategyModule = {
|
|
957
|
+
* endpoint: 'refresh-token',
|
|
958
|
+
* method: 'post',
|
|
959
|
+
* requireValidToken: true,
|
|
960
|
+
* redirect: {
|
|
961
|
+
* success: null,
|
|
962
|
+
* failure: null,
|
|
963
|
+
* },
|
|
964
|
+
* defaultErrors: ['Something went wrong, please try again.'],
|
|
965
|
+
* defaultMessages: ['Your token has been successfully refreshed.'],
|
|
966
|
+
* };
|
|
967
|
+
* token?: NbPasswordStrategyToken = {
|
|
968
|
+
* class: NbAuthSimpleToken,
|
|
969
|
+
* key: 'data.token',
|
|
970
|
+
* getter: (module, res, options) => getDeepFromObject(res.body, options.token.key),
|
|
971
|
+
* };
|
|
972
|
+
* errors?: NbPasswordStrategyMessage = {
|
|
973
|
+
* key: 'data.errors',
|
|
974
|
+
* getter: (module, res, options) =>
|
|
975
|
+
* nbAuthMessages(getDeepFromObject(res.error, options.errors.key, options[module].defaultErrors)),
|
|
976
|
+
* };
|
|
977
|
+
* messages?: NbPasswordStrategyMessage = {
|
|
978
|
+
* key: 'data.messages',
|
|
979
|
+
* getter: (module, res, options) =>
|
|
980
|
+
* nbAuthMessages(getDeepFromObject(res.body, options.messages.key, options[module].defaultMessages)),
|
|
981
|
+
* };
|
|
982
|
+
* validation?: {
|
|
983
|
+
* password?: {
|
|
984
|
+
* required?: boolean;
|
|
985
|
+
* minLength?: number;
|
|
986
|
+
* maxLength?: number;
|
|
987
|
+
* regexp?: string;
|
|
988
|
+
* };
|
|
989
|
+
* email?: {
|
|
990
|
+
* required?: boolean;
|
|
991
|
+
* regexp?: string;
|
|
992
|
+
* };
|
|
993
|
+
* fullName?: {
|
|
994
|
+
* required?: boolean;
|
|
995
|
+
* minLength?: number;
|
|
996
|
+
* maxLength?: number;
|
|
997
|
+
* regexp?: string;
|
|
998
|
+
* };
|
|
999
|
+
* };
|
|
1000
|
+
*}
|
|
1001
|
+
* ```
|
|
1002
|
+
*/
|
|
1003
|
+
export declare class NbPasswordAuthStrategy extends NbAuthStrategy<NbPasswordAuthStrategyOptions> {
|
|
1004
|
+
protected readonly http: HttpClient;
|
|
1005
|
+
private readonly route;
|
|
1006
|
+
protected defaultOptions: NbPasswordAuthStrategyOptions;
|
|
1007
|
+
static setup(options: NbPasswordAuthStrategyOptions): [NbAuthStrategyClass, NbPasswordAuthStrategyOptions];
|
|
1008
|
+
authenticate(data?: unknown): Observable<NbAuthResult>;
|
|
1009
|
+
register(data?: unknown): Observable<NbAuthResult>;
|
|
1010
|
+
requestPassword(data?: unknown): Observable<NbAuthResult>;
|
|
1011
|
+
/** Sends the data with the reset password token of the page's query, under the options' `resetPasswordTokenKey`. */
|
|
1012
|
+
resetPassword(data?: Record<string, unknown>): Observable<NbAuthResult>;
|
|
1013
|
+
logout(): Observable<NbAuthResult>;
|
|
1014
|
+
refreshToken(data?: unknown): Observable<NbAuthResult>;
|
|
1015
|
+
/** The messages of a module's response, as the options' messages getter reads them. */
|
|
1016
|
+
protected readMessages(module: NbPasswordStrategyModuleName, res: unknown): string[] | undefined;
|
|
1017
|
+
/** The token value of a module's response, as the options' token getter reads it. */
|
|
1018
|
+
protected readToken(module: NbPasswordStrategyModuleName, res: HttpResponse<unknown>): unknown;
|
|
1019
|
+
/** A failed module's result, with the errors of the options' errors getter for an error response. */
|
|
1020
|
+
protected handleResponseError(res: unknown, module: NbPasswordStrategyModuleName): Observable<NbAuthResult>;
|
|
1021
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NbPasswordAuthStrategy, never>;
|
|
1022
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
1023
|
+
}
|
|
1024
|
+
export declare enum NbOAuth2ResponseType {
|
|
1025
|
+
CODE = "code",
|
|
1026
|
+
TOKEN = "token"
|
|
1027
|
+
}
|
|
1028
|
+
export declare enum NbOAuth2GrantType {
|
|
1029
|
+
AUTHORIZATION_CODE = "authorization_code",
|
|
1030
|
+
PASSWORD = "password",
|
|
1031
|
+
REFRESH_TOKEN = "refresh_token"
|
|
1032
|
+
}
|
|
1033
|
+
export declare enum NbOAuth2ClientAuthMethod {
|
|
1034
|
+
NONE = "none",
|
|
1035
|
+
BASIC = "basic",
|
|
1036
|
+
REQUEST_BODY = "request-body"
|
|
1037
|
+
}
|
|
1038
|
+
export declare class NbOAuth2AuthStrategyOptions extends NbAuthStrategyOptions {
|
|
1039
|
+
baseEndpoint?: string;
|
|
1040
|
+
clientId: string;
|
|
1041
|
+
clientSecret?: string;
|
|
1042
|
+
clientAuthMethod?: string;
|
|
1043
|
+
/** Where to go after signing in; `null` turns a default redirect off, while a missing one keeps the default. */
|
|
1044
|
+
redirect?: {
|
|
1045
|
+
success?: string | null;
|
|
1046
|
+
failure?: string | null;
|
|
1047
|
+
};
|
|
1048
|
+
defaultErrors?: string[];
|
|
1049
|
+
defaultMessages?: string[];
|
|
1050
|
+
authorize?: {
|
|
1051
|
+
endpoint?: string;
|
|
1052
|
+
redirectUri?: string;
|
|
1053
|
+
responseType?: string;
|
|
1054
|
+
requireValidToken?: boolean;
|
|
1055
|
+
scope?: string;
|
|
1056
|
+
/** A state of the app's to send, and check on the way back; a random one per sign-in without it. */
|
|
1057
|
+
state?: string;
|
|
1058
|
+
/** Whether the code flow uses PKCE (RFC 7636), with an S256 challenge; on unless `false`. */
|
|
1059
|
+
pkce?: boolean;
|
|
1060
|
+
params?: {
|
|
1061
|
+
[key: string]: string;
|
|
1062
|
+
};
|
|
1063
|
+
};
|
|
1064
|
+
token?: {
|
|
1065
|
+
endpoint?: string;
|
|
1066
|
+
grantType?: string;
|
|
1067
|
+
redirectUri?: string;
|
|
1068
|
+
scope?: string;
|
|
1069
|
+
requireValidToken?: boolean;
|
|
1070
|
+
class: NbAuthTokenClass;
|
|
1071
|
+
};
|
|
1072
|
+
refresh?: {
|
|
1073
|
+
endpoint?: string;
|
|
1074
|
+
grantType?: string;
|
|
1075
|
+
scope?: string;
|
|
1076
|
+
requireValidToken?: boolean;
|
|
1077
|
+
};
|
|
1078
|
+
}
|
|
1079
|
+
export declare const auth2StrategyOptions: NbOAuth2AuthStrategyOptions;
|
|
1080
|
+
/** The state, and the PKCE verifier, of a sign-in on its way to the server and back. */
|
|
1081
|
+
interface NbOAuth2PendingAuthorization {
|
|
1082
|
+
state: string;
|
|
1083
|
+
verifier?: string;
|
|
1084
|
+
}
|
|
1085
|
+
/**
|
|
1086
|
+
* Signs in with an OAuth2 server. `authenticate` sends the browser to the `authorize` endpoint and, when it comes
|
|
1087
|
+
* back with a code (or with a token, with `responseType: 'token'`), gets the token from the `token` endpoint; with
|
|
1088
|
+
* the password grant it posts the email and password to `token` instead. `refreshToken` posts the refresh token to
|
|
1089
|
+
* `refresh`. `register`, `requestPassword` and `resetPassword` aren't supported.
|
|
1090
|
+
*
|
|
1091
|
+
* Strategy settings; `setup` takes the ones to change, over these defaults. `defaultErrors` and `defaultMessages` are
|
|
1092
|
+
* the `authStrategy` texts (`provideNbTexts`), unless the given options set them:
|
|
1093
|
+
*
|
|
1094
|
+
* ```ts
|
|
1095
|
+
* export enum NbOAuth2ResponseType {
|
|
1096
|
+
* CODE = 'code',
|
|
1097
|
+
* TOKEN = 'token',
|
|
1098
|
+
* }
|
|
1099
|
+
*
|
|
1100
|
+
* export enum NbOAuth2GrantType {
|
|
1101
|
+
* AUTHORIZATION_CODE = 'authorization_code',
|
|
1102
|
+
* PASSWORD = 'password',
|
|
1103
|
+
* REFRESH_TOKEN = 'refresh_token',
|
|
1104
|
+
* }
|
|
1105
|
+
*
|
|
1106
|
+
* export enum NbOAuth2ClientAuthMethod {
|
|
1107
|
+
* NONE = 'none',
|
|
1108
|
+
* BASIC = 'basic',
|
|
1109
|
+
* REQUEST_BODY = 'request-body',
|
|
1110
|
+
* }
|
|
1111
|
+
*
|
|
1112
|
+
* export class NbOAuth2AuthStrategyOptions extends NbAuthStrategyOptions {
|
|
1113
|
+
* name = '';
|
|
1114
|
+
* baseEndpoint?: string = '';
|
|
1115
|
+
* clientId = '';
|
|
1116
|
+
* clientSecret?: string = '';
|
|
1117
|
+
* clientAuthMethod?: string = NbOAuth2ClientAuthMethod.NONE;
|
|
1118
|
+
* redirect?: { success?: string | null; failure?: string | null } = {
|
|
1119
|
+
* success: '/',
|
|
1120
|
+
* failure: null,
|
|
1121
|
+
* };
|
|
1122
|
+
* defaultErrors?: string[] = ['Something went wrong, please try again.'];
|
|
1123
|
+
* defaultMessages?: string[] = ['You have been successfully authenticated.'];
|
|
1124
|
+
* authorize?: {
|
|
1125
|
+
* endpoint?: string;
|
|
1126
|
+
* redirectUri?: string;
|
|
1127
|
+
* responseType?: string;
|
|
1128
|
+
* requireValidToken?: boolean; // used only with NbOAuth2ResponseType.TOKEN
|
|
1129
|
+
* scope?: string;
|
|
1130
|
+
* state?: string;
|
|
1131
|
+
* pkce?: boolean;
|
|
1132
|
+
* params?: { [key: string]: string };
|
|
1133
|
+
* } = {
|
|
1134
|
+
* endpoint: 'authorize',
|
|
1135
|
+
* responseType: NbOAuth2ResponseType.CODE,
|
|
1136
|
+
* requireValidToken: true,
|
|
1137
|
+
* pkce: true,
|
|
1138
|
+
* };
|
|
1139
|
+
* token?: {
|
|
1140
|
+
* endpoint?: string;
|
|
1141
|
+
* grantType?: string;
|
|
1142
|
+
* redirectUri?: string;
|
|
1143
|
+
* scope?: string; // used only with the password grant
|
|
1144
|
+
* requireValidToken?: boolean;
|
|
1145
|
+
* class: NbAuthTokenClass;
|
|
1146
|
+
* } = {
|
|
1147
|
+
* endpoint: 'token',
|
|
1148
|
+
* grantType: NbOAuth2GrantType.AUTHORIZATION_CODE,
|
|
1149
|
+
* requireValidToken: true,
|
|
1150
|
+
* class: NbAuthOAuth2Token,
|
|
1151
|
+
* };
|
|
1152
|
+
* refresh?: {
|
|
1153
|
+
* endpoint?: string;
|
|
1154
|
+
* grantType?: string;
|
|
1155
|
+
* scope?: string;
|
|
1156
|
+
* requireValidToken?: boolean;
|
|
1157
|
+
* } = {
|
|
1158
|
+
* endpoint: 'token',
|
|
1159
|
+
* grantType: NbOAuth2GrantType.REFRESH_TOKEN,
|
|
1160
|
+
* requireValidToken: true,
|
|
1161
|
+
* };
|
|
1162
|
+
* }
|
|
1163
|
+
* ```
|
|
1164
|
+
*
|
|
1165
|
+
* With `clientAuthMethod` `basic` the client id and secret go in a Basic authorization header, with `request-body`
|
|
1166
|
+
* in the token requests' body; both need `clientId` and `clientSecret`.
|
|
1167
|
+
*
|
|
1168
|
+
* The code flow uses PKCE (RFC 7636): a random verifier per sign-in, its S256 challenge on the redirect to
|
|
1169
|
+
* `authorize`, and the verifier with the code to `token`; `authorize.pkce: false` turns it off. Every redirect sends a
|
|
1170
|
+
* state, random unless `authorize.state` sets one, and the way back is refused unless it brings the same state, so a
|
|
1171
|
+
* sign-in this browser didn't start can't complete. Both are kept in `sessionStorage` while the browser is away.
|
|
1172
|
+
*/
|
|
1173
|
+
export declare class NbOAuth2AuthStrategy extends NbAuthStrategy<NbOAuth2AuthStrategyOptions> {
|
|
1174
|
+
protected textOptions(): object;
|
|
1175
|
+
protected readonly http: HttpClient;
|
|
1176
|
+
protected readonly route: ActivatedRoute;
|
|
1177
|
+
protected readonly window: (Window & typeof globalThis) | undefined;
|
|
1178
|
+
static setup(options: NbOAuth2AuthStrategyOptions): [NbAuthStrategyClass, NbOAuth2AuthStrategyOptions];
|
|
1179
|
+
get responseType(): import("@liquid-js/lyr-auth").NbPathValue<NbOAuth2AuthStrategyOptions | undefined, "authorize.responseType">;
|
|
1180
|
+
get clientAuthMethod(): import("@liquid-js/lyr-auth").NbPathValue<NbOAuth2AuthStrategyOptions | undefined, "clientAuthMethod">;
|
|
1181
|
+
protected redirectResultHandlers: {
|
|
1182
|
+
[key: string]: () => Observable<NbAuthResult>;
|
|
1183
|
+
};
|
|
1184
|
+
protected redirectResults: {
|
|
1185
|
+
[key: string]: () => Observable<boolean>;
|
|
1186
|
+
};
|
|
1187
|
+
protected defaultOptions: NbOAuth2AuthStrategyOptions;
|
|
1188
|
+
/**
|
|
1189
|
+
* Sends the browser to sign in, or completes the sign-in it's back from; with the password grant, signs in with the
|
|
1190
|
+
* email and password.
|
|
1191
|
+
*/
|
|
1192
|
+
authenticate(data?: Pick<NbAuthCredentials, 'email' | 'password'>): Observable<NbAuthResult>;
|
|
1193
|
+
getAuthorizationResult(): Observable<NbAuthResult>;
|
|
1194
|
+
refreshToken(token: NbAuthRefreshableToken): Observable<NbAuthResult>;
|
|
1195
|
+
passwordToken(username: string, password: string): Observable<NbAuthResult>;
|
|
1196
|
+
protected authorizeRedirect(): void;
|
|
1197
|
+
/**
|
|
1198
|
+
* Starts a sign-in: makes its state and PKCE verifier, keeps them for the way back, and gives the URL to send the
|
|
1199
|
+
* browser to.
|
|
1200
|
+
*/
|
|
1201
|
+
protected startAuthorization(): Promise<string>;
|
|
1202
|
+
/** The sign-in on its way back, which can be taken once. */
|
|
1203
|
+
protected takePendingAuthorization(): NbOAuth2PendingAuthorization | undefined;
|
|
1204
|
+
protected pendingKey(): string;
|
|
1205
|
+
protected sessionStorage(): Storage | undefined;
|
|
1206
|
+
protected invalidStateResult(params: unknown): NbAuthResult<unknown>;
|
|
1207
|
+
protected isRedirectResult(): Observable<boolean>;
|
|
1208
|
+
protected requestToken(code: string, verifier?: string): Observable<NbAuthResult<unknown> | NbAuthResult<Object>>;
|
|
1209
|
+
protected buildCodeRequestData(code: string, verifier?: string): string;
|
|
1210
|
+
protected buildRefreshRequestData(token: NbAuthRefreshableToken): string;
|
|
1211
|
+
protected buildPasswordRequestData(username: string, password: string): string;
|
|
1212
|
+
protected buildAuthHeader(): HttpHeaders | undefined;
|
|
1213
|
+
protected getHeaders(): HttpHeaders;
|
|
1214
|
+
/** Removes the params without a value. */
|
|
1215
|
+
protected cleanParams(params: Record<string, unknown>): Record<string, unknown>;
|
|
1216
|
+
protected addCredentialsToParams(params: Record<string, unknown>): Record<string, unknown>;
|
|
1217
|
+
protected handleResponseError(res: unknown): Observable<NbAuthResult>;
|
|
1218
|
+
/** The URL of `authorize`, with the sign-in's state and PKCE challenge. */
|
|
1219
|
+
protected buildRedirectUrl(sign?: {
|
|
1220
|
+
state?: string;
|
|
1221
|
+
code_challenge?: string;
|
|
1222
|
+
code_challenge_method?: string;
|
|
1223
|
+
}): string;
|
|
1224
|
+
protected parseHashAsQueryParams(hash: string | null): {
|
|
1225
|
+
[key: string]: string;
|
|
1226
|
+
};
|
|
1227
|
+
protected urlEncodeParameters(params: Record<string, unknown>): string;
|
|
1228
|
+
protected createRefreshedToken(res: unknown, existingToken: NbAuthRefreshableToken, requireValidToken?: boolean): NbAuthToken;
|
|
1229
|
+
register(_data?: unknown): Observable<NbAuthResult>;
|
|
1230
|
+
requestPassword(_data?: unknown): Observable<NbAuthResult>;
|
|
1231
|
+
resetPassword(_data?: unknown): Observable<NbAuthResult>;
|
|
1232
|
+
logout(): Observable<NbAuthResult>;
|
|
1233
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NbOAuth2AuthStrategy, never>;
|
|
1234
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
1235
|
+
}
|
|
1236
|
+
export {};
|