@mintplayer/ng-spark-auth 22.0.1 → 22.2.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/fesm2022/mintplayer-ng-spark-auth-auth-bar.mjs +5 -3
- package/fesm2022/mintplayer-ng-spark-auth-auth-bar.mjs.map +1 -1
- package/fesm2022/mintplayer-ng-spark-auth-core.mjs +73 -2
- package/fesm2022/mintplayer-ng-spark-auth-core.mjs.map +1 -1
- package/fesm2022/mintplayer-ng-spark-auth-forgot-password.mjs +1 -1
- package/fesm2022/mintplayer-ng-spark-auth-forgot-password.mjs.map +1 -1
- package/fesm2022/mintplayer-ng-spark-auth-guards.mjs +2 -2
- package/fesm2022/mintplayer-ng-spark-auth-guards.mjs.map +1 -1
- package/fesm2022/mintplayer-ng-spark-auth-interceptors.mjs +2 -2
- package/fesm2022/mintplayer-ng-spark-auth-interceptors.mjs.map +1 -1
- package/fesm2022/mintplayer-ng-spark-auth-login.mjs +1 -1
- package/fesm2022/mintplayer-ng-spark-auth-login.mjs.map +1 -1
- package/fesm2022/mintplayer-ng-spark-auth-models.mjs +41 -2
- package/fesm2022/mintplayer-ng-spark-auth-models.mjs.map +1 -1
- package/fesm2022/mintplayer-ng-spark-auth-register.mjs +1 -1
- package/fesm2022/mintplayer-ng-spark-auth-register.mjs.map +1 -1
- package/fesm2022/mintplayer-ng-spark-auth-reset-password.mjs +1 -1
- package/fesm2022/mintplayer-ng-spark-auth-reset-password.mjs.map +1 -1
- package/fesm2022/mintplayer-ng-spark-auth-routes.mjs +48 -30
- package/fesm2022/mintplayer-ng-spark-auth-routes.mjs.map +1 -1
- package/fesm2022/mintplayer-ng-spark-auth-sign-in.mjs +80 -0
- package/fesm2022/mintplayer-ng-spark-auth-sign-in.mjs.map +1 -0
- package/fesm2022/mintplayer-ng-spark-auth-two-factor.mjs +1 -1
- package/fesm2022/mintplayer-ng-spark-auth-two-factor.mjs.map +1 -1
- package/package.json +5 -1
- package/types/mintplayer-ng-spark-auth-auth-bar.d.ts +2 -0
- package/types/mintplayer-ng-spark-auth-core.d.ts +23 -1
- package/types/mintplayer-ng-spark-auth-forgot-password.d.ts +1 -1
- package/types/mintplayer-ng-spark-auth-login.d.ts +1 -1
- package/types/mintplayer-ng-spark-auth-models.d.ts +91 -5
- package/types/mintplayer-ng-spark-auth-register.d.ts +1 -1
- package/types/mintplayer-ng-spark-auth-reset-password.d.ts +1 -1
- package/types/mintplayer-ng-spark-auth-routes.d.ts +15 -0
- package/types/mintplayer-ng-spark-auth-sign-in.d.ts +36 -0
- package/types/mintplayer-ng-spark-auth-two-factor.d.ts +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { InjectionToken, Type } from '@angular/core';
|
|
2
|
+
import { Router } from '@angular/router';
|
|
2
3
|
|
|
3
4
|
interface AuthUser {
|
|
4
5
|
isAuthenticated: boolean;
|
|
@@ -15,19 +16,63 @@ interface SparkAuthConfig {
|
|
|
15
16
|
declare const SPARK_AUTH_CONFIG: InjectionToken<SparkAuthConfig>;
|
|
16
17
|
declare const defaultSparkAuthConfig: SparkAuthConfig;
|
|
17
18
|
|
|
19
|
+
/** An external provider a user can actually click, as reported by the server. */
|
|
20
|
+
interface SparkExternalProvider {
|
|
21
|
+
scheme: string;
|
|
22
|
+
displayName: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* What `GET /spark/auth/capabilities` reports: how much of the local-credential surface this
|
|
26
|
+
* application mounts, and which external providers are registered.
|
|
27
|
+
*
|
|
28
|
+
* This exists so the two tiers cannot silently disagree. The route config is a build-time choice
|
|
29
|
+
* and the server's mode is a deployment-time one; without a channel between them, a mismatch shows
|
|
30
|
+
* up as a form that posts into a 404, or a sign-in page with no way to sign in.
|
|
31
|
+
*/
|
|
32
|
+
interface SparkAuthCapabilities {
|
|
33
|
+
localCredentials: 'Full' | 'SignInOnly' | 'Disabled';
|
|
34
|
+
externalProviders: SparkExternalProvider[];
|
|
35
|
+
}
|
|
36
|
+
|
|
18
37
|
type SparkAuthRouteEntry = string | {
|
|
19
38
|
path: string;
|
|
20
39
|
component?: Type<unknown>;
|
|
21
40
|
};
|
|
22
|
-
|
|
41
|
+
/**
|
|
42
|
+
* How much of the local-credential (email + password) page family to route.
|
|
43
|
+
*
|
|
44
|
+
* Mirrors the server's `SparkLocalCredentials`, and for the same reason it is a mode rather
|
|
45
|
+
* than five independent switches: the pages form a star centred on the login page, and every
|
|
46
|
+
* template dereferences its siblings' paths unconditionally, so removing any proper subset
|
|
47
|
+
* leaves a dangling link. The family is the unit on both tiers.
|
|
48
|
+
*/
|
|
49
|
+
type SparkLocalCredentialsMode = 'full' | 'sign-in-only' | 'disabled';
|
|
50
|
+
/** The routable local-credential pages. Kept separate from {@link SparkAuthRouteConfig} so that
|
|
51
|
+
* adding non-route options below cannot widen {@link SparkAuthRoutePaths}. */
|
|
52
|
+
interface SparkAuthRouteEntries {
|
|
53
|
+
/** The provider-button landing page. Routed whenever local credentials are limited. */
|
|
54
|
+
signIn?: SparkAuthRouteEntry;
|
|
23
55
|
login?: SparkAuthRouteEntry;
|
|
24
56
|
twoFactor?: SparkAuthRouteEntry;
|
|
25
57
|
register?: SparkAuthRouteEntry;
|
|
26
58
|
forgotPassword?: SparkAuthRouteEntry;
|
|
27
59
|
resetPassword?: SparkAuthRouteEntry;
|
|
28
60
|
}
|
|
29
|
-
|
|
30
|
-
|
|
61
|
+
interface SparkAuthRouteConfig extends SparkAuthRouteEntries {
|
|
62
|
+
/**
|
|
63
|
+
* Defaults to `'full'`, which routes every page — the behaviour of every version before this
|
|
64
|
+
* option existed. Set it to match the server's `LocalCredentials` mode; `GET /spark/auth/capabilities`
|
|
65
|
+
* reports what the server is actually running.
|
|
66
|
+
*/
|
|
67
|
+
localCredentials?: SparkLocalCredentialsMode;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Every path is present regardless of mode. The pages that are dropped are dropped together, so no
|
|
71
|
+
* surviving template can dereference a missing sibling — which is what lets this stay `Required`
|
|
72
|
+
* and keeps the change additive for consumers.
|
|
73
|
+
*/
|
|
74
|
+
type SparkAuthRoutePaths = Required<Record<keyof SparkAuthRouteEntries, string>>;
|
|
75
|
+
declare const SPARK_AUTH_ROUTE_PATHS: InjectionToken<Required<Record<keyof SparkAuthRouteEntries, string>>>;
|
|
31
76
|
|
|
32
77
|
/**
|
|
33
78
|
* Shared validator for `returnUrl` query parameters consumed by the auth
|
|
@@ -47,5 +92,46 @@ declare const SPARK_AUTH_ROUTE_PATHS: InjectionToken<Required<Record<keyof Spark
|
|
|
47
92
|
declare function isSafeReturnUrl(value: string | null | undefined): boolean;
|
|
48
93
|
declare function sanitizeReturnUrl(value: string | null | undefined, defaultUrl: string): string;
|
|
49
94
|
|
|
50
|
-
|
|
51
|
-
|
|
95
|
+
/** How the user is sent to the external provider, and how the result comes back. */
|
|
96
|
+
type SparkExternalLoginMode = 'popup' | 'redirect';
|
|
97
|
+
interface SparkExternalLoginOptions {
|
|
98
|
+
/** Where to land after a successful sign-in. Server-side sanitized to an in-app path. */
|
|
99
|
+
returnUrl?: string;
|
|
100
|
+
/** Defaults to `'popup'`. */
|
|
101
|
+
mode?: SparkExternalLoginMode;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Why an external login did not sign anyone in. The three `no_login_info` /
|
|
105
|
+
* `email_not_verified` / `account_creation_failed` codes come from the server; the two
|
|
106
|
+
* `popup_*` codes are raised here, because the browser is the only place that can observe
|
|
107
|
+
* them. Deliberately coarse — never enough to tell "no such account" from anything else.
|
|
108
|
+
*/
|
|
109
|
+
type SparkExternalLoginError = 'no_login_info' | 'email_not_verified' | 'account_creation_failed' | 'popup_blocked' | 'popup_closed';
|
|
110
|
+
interface SparkExternalLoginResult {
|
|
111
|
+
success: boolean;
|
|
112
|
+
error?: SparkExternalLoginError;
|
|
113
|
+
}
|
|
114
|
+
/** The message the callback page posts back to the window that opened it. */
|
|
115
|
+
interface SparkExternalLoginMessage {
|
|
116
|
+
type: 'spark:external-login';
|
|
117
|
+
success: boolean;
|
|
118
|
+
error?: SparkExternalLoginError;
|
|
119
|
+
}
|
|
120
|
+
declare const SPARK_EXTERNAL_LOGIN_MESSAGE_TYPE = "spark:external-login";
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Where to send someone who is not signed in.
|
|
124
|
+
*
|
|
125
|
+
* `loginUrl` is the single source of truth for this, and the only thing the guard, the interceptor
|
|
126
|
+
* and the auth bar should consult — an application that turns off local credentials points it at
|
|
127
|
+
* its own sign-in landing route.
|
|
128
|
+
*
|
|
129
|
+
* The reason this is a function rather than a property read is the failure mode it closes: nothing
|
|
130
|
+
* connects `loginUrl` to the routes that actually exist, so pointing it at a route that was never
|
|
131
|
+
* registered produces a redirect into a blank page with no type error, no build failure and no
|
|
132
|
+
* runtime error. In development that now warns, once, naming the value and the fix.
|
|
133
|
+
*/
|
|
134
|
+
declare function resolveSignInUrl(config: SparkAuthConfig, router: Router): string;
|
|
135
|
+
|
|
136
|
+
export { SPARK_AUTH_CONFIG, SPARK_AUTH_ROUTE_PATHS, SPARK_EXTERNAL_LOGIN_MESSAGE_TYPE, defaultSparkAuthConfig, isSafeReturnUrl, resolveSignInUrl, sanitizeReturnUrl };
|
|
137
|
+
export type { AuthUser, SparkAuthCapabilities, SparkAuthConfig, SparkAuthRouteConfig, SparkAuthRouteEntries, SparkAuthRouteEntry, SparkAuthRoutePaths, SparkExternalLoginError, SparkExternalLoginMessage, SparkExternalLoginMode, SparkExternalLoginOptions, SparkExternalLoginResult, SparkExternalProvider, SparkLocalCredentialsMode };
|
|
@@ -8,7 +8,7 @@ declare class SparkRegisterComponent {
|
|
|
8
8
|
private readonly authService;
|
|
9
9
|
private readonly router;
|
|
10
10
|
private readonly translation;
|
|
11
|
-
readonly routePaths: Required<Record<keyof _mintplayer_ng_spark_auth_models.
|
|
11
|
+
readonly routePaths: Required<Record<keyof _mintplayer_ng_spark_auth_models.SparkAuthRouteEntries, string>>;
|
|
12
12
|
colors: typeof Color;
|
|
13
13
|
readonly loading: _angular_core.WritableSignal<boolean>;
|
|
14
14
|
readonly errorMessage: _angular_core.WritableSignal<string>;
|
|
@@ -10,7 +10,7 @@ declare class SparkResetPasswordComponent implements OnInit {
|
|
|
10
10
|
private readonly router;
|
|
11
11
|
private readonly route;
|
|
12
12
|
private readonly translation;
|
|
13
|
-
readonly routePaths: Required<Record<keyof _mintplayer_ng_spark_auth_models.
|
|
13
|
+
readonly routePaths: Required<Record<keyof _mintplayer_ng_spark_auth_models.SparkAuthRouteEntries, string>>;
|
|
14
14
|
colors: typeof Color;
|
|
15
15
|
readonly loading: _angular_core.WritableSignal<boolean>;
|
|
16
16
|
readonly errorMessage: _angular_core.WritableSignal<string>;
|
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
import { SparkAuthRouteConfig } from '@mintplayer/ng-spark-auth/models';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* The routes for Spark's authentication pages.
|
|
5
|
+
*
|
|
6
|
+
* `config.localCredentials` chooses how much of the email/password family to route, mirroring the
|
|
7
|
+
* server's `SparkLocalCredentials`. `GET /spark/auth/capabilities` reports what the server is
|
|
8
|
+
* actually running, so the two can be checked against each other.
|
|
9
|
+
*
|
|
10
|
+
* The `import()` expressions live *inside* the branches that need them. That placement is the point:
|
|
11
|
+
* a bundler decides whether to emit a lazy chunk from whether the `import()` call site is reachable,
|
|
12
|
+
* not from whether the route object referencing it survives — so filtering the children array after
|
|
13
|
+
* the fact would still ship every page. Excluded pages must have no reachable `import()` at all.
|
|
14
|
+
*
|
|
15
|
+
* `SPARK_AUTH_ROUTE_PATHS` is still provided in full. The excluded pages are excluded together, so
|
|
16
|
+
* nothing that survives can link to something that does not, and the token stays `Required`.
|
|
17
|
+
*/
|
|
3
18
|
declare function sparkAuthRoutes(config?: SparkAuthRouteConfig): any[];
|
|
4
19
|
|
|
5
20
|
export { sparkAuthRoutes };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as _angular_core from '@angular/core';
|
|
2
|
+
import * as _mintplayer_ng_spark_auth_models from '@mintplayer/ng-spark-auth/models';
|
|
3
|
+
import { SparkExternalProvider } from '@mintplayer/ng-spark-auth/models';
|
|
4
|
+
import { Color } from '@mintplayer/ng-bootstrap';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The sign-in landing page for an application whose local credentials are turned off — a button per
|
|
8
|
+
* external provider, and a link to the password form when there still is one.
|
|
9
|
+
*
|
|
10
|
+
* The providers come from `GET /spark/auth/capabilities` rather than from a list the application
|
|
11
|
+
* hard-codes. That is the point of the component: every consumer that hand-rolled this before wrote
|
|
12
|
+
* the scheme name as a string literal, which is a silent mismatch waiting to happen the moment the
|
|
13
|
+
* server's provider registration changes.
|
|
14
|
+
*/
|
|
15
|
+
declare class SparkSignInComponent {
|
|
16
|
+
private readonly authService;
|
|
17
|
+
readonly routePaths: Required<Record<keyof _mintplayer_ng_spark_auth_models.SparkAuthRouteEntries, string>>;
|
|
18
|
+
readonly colors: typeof Color;
|
|
19
|
+
readonly providers: _angular_core.WritableSignal<SparkExternalProvider[]>;
|
|
20
|
+
readonly localCredentialsAvailable: _angular_core.WritableSignal<boolean>;
|
|
21
|
+
readonly loading: _angular_core.WritableSignal<boolean>;
|
|
22
|
+
readonly failed: _angular_core.WritableSignal<boolean>;
|
|
23
|
+
constructor();
|
|
24
|
+
private load;
|
|
25
|
+
/**
|
|
26
|
+
* The routes are a build-time decision and the server's mode a deployment-time one, so they can
|
|
27
|
+
* disagree without anything failing loudly. Reaching this page at all means the app routed it,
|
|
28
|
+
* which it only does when local credentials are meant to be limited.
|
|
29
|
+
*/
|
|
30
|
+
private warnOnMismatch;
|
|
31
|
+
signInWith(provider: SparkExternalProvider): void;
|
|
32
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<SparkSignInComponent, never>;
|
|
33
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<SparkSignInComponent, "spark-sign-in", never, {}, {}, never, never, true, never>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { SparkSignInComponent };
|
|
@@ -10,7 +10,7 @@ declare class SparkTwoFactorComponent {
|
|
|
10
10
|
private readonly route;
|
|
11
11
|
private readonly config;
|
|
12
12
|
private readonly translation;
|
|
13
|
-
readonly routePaths: Required<Record<keyof _mintplayer_ng_spark_auth_models.
|
|
13
|
+
readonly routePaths: Required<Record<keyof _mintplayer_ng_spark_auth_models.SparkAuthRouteEntries, string>>;
|
|
14
14
|
colors: typeof Color;
|
|
15
15
|
readonly loading: _angular_core.WritableSignal<boolean>;
|
|
16
16
|
readonly errorMessage: _angular_core.WritableSignal<string>;
|