@mintplayer/ng-spark-auth 22.2.1 → 22.6.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 +3 -3
- package/fesm2022/mintplayer-ng-spark-auth-core.mjs +6 -6
- package/fesm2022/mintplayer-ng-spark-auth-forgot-password.mjs +3 -3
- package/fesm2022/mintplayer-ng-spark-auth-login.mjs +4 -4
- package/fesm2022/mintplayer-ng-spark-auth-login.mjs.map +1 -1
- package/fesm2022/mintplayer-ng-spark-auth-models.mjs +2 -1
- package/fesm2022/mintplayer-ng-spark-auth-models.mjs.map +1 -1
- package/fesm2022/mintplayer-ng-spark-auth-pipes.mjs +3 -3
- package/fesm2022/mintplayer-ng-spark-auth-register.mjs +9 -5
- package/fesm2022/mintplayer-ng-spark-auth-register.mjs.map +1 -1
- package/fesm2022/mintplayer-ng-spark-auth-reset-password.mjs +3 -3
- package/fesm2022/mintplayer-ng-spark-auth-routes.mjs +122 -34
- package/fesm2022/mintplayer-ng-spark-auth-routes.mjs.map +1 -1
- package/fesm2022/mintplayer-ng-spark-auth-sign-in.mjs +82 -17
- package/fesm2022/mintplayer-ng-spark-auth-sign-in.mjs.map +1 -1
- package/fesm2022/mintplayer-ng-spark-auth-two-factor.mjs +3 -3
- package/fesm2022/mintplayer-ng-spark-auth.mjs +11 -3
- package/fesm2022/mintplayer-ng-spark-auth.mjs.map +1 -1
- package/package.json +2 -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 +32 -27
- 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 +82 -12
- package/types/mintplayer-ng-spark-auth-sign-in.d.ts +58 -7
- package/types/mintplayer-ng-spark-auth-two-factor.d.ts +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SPARK_AUTH_ROUTE_PATHS } from '@mintplayer/ng-spark-auth/models';
|
|
1
|
+
import { SPARK_AUTH_ROUTE_PATHS, SPARK_EXTERNAL_PROVIDERS } from '@mintplayer/ng-spark-auth/models';
|
|
2
2
|
|
|
3
3
|
/** The routed path for an entry, independent of how its component is loaded. */
|
|
4
4
|
function entryPath(entry, defaultPath) {
|
|
@@ -14,57 +14,145 @@ function child(entry, path, defaultLoader) {
|
|
|
14
14
|
/**
|
|
15
15
|
* The routes for Spark's authentication pages.
|
|
16
16
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* **Nothing is mounted unless a feature asks for it.** Passing no features emits no pages at all —
|
|
18
|
+
* opt-in enforced by construction rather than by a flag, matching `provideHttpClient(withFetch())`
|
|
19
|
+
* and `provideRouter(withComponentInputBinding())`. Before this the pages mounted by default and an
|
|
20
|
+
* application had to opt *out*, so every app shipped a registration form whether or not it wanted
|
|
21
|
+
* one.
|
|
20
22
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* sparkAuthRoutes(
|
|
25
|
+
* withLocalLogin(),
|
|
26
|
+
* withRegistration(),
|
|
27
|
+
* withExternalLogin(githubProvider(), facebookProvider()),
|
|
28
|
+
* )
|
|
29
|
+
* ```
|
|
25
30
|
*
|
|
26
|
-
* `
|
|
27
|
-
*
|
|
31
|
+
* The `import()` expressions live *inside* each feature. That placement is the point: a bundler
|
|
32
|
+
* decides whether to emit a lazy chunk from whether the `import()` call site is reachable, not from
|
|
33
|
+
* whether the route object referencing it survives — so filtering a children array after the fact
|
|
34
|
+
* would still ship every page. A page nobody opted into has no reachable `import()` at all.
|
|
28
35
|
*/
|
|
29
|
-
function sparkAuthRoutes(
|
|
30
|
-
const mode = config?.localCredentials ?? 'full';
|
|
31
|
-
const paths = {
|
|
32
|
-
signIn: '/' + entryPath(config?.signIn, 'sign-in'),
|
|
33
|
-
login: '/' + entryPath(config?.login, 'login'),
|
|
34
|
-
twoFactor: '/' + entryPath(config?.twoFactor, 'login/two-factor'),
|
|
35
|
-
register: '/' + entryPath(config?.register, 'register'),
|
|
36
|
-
forgotPassword: '/' + entryPath(config?.forgotPassword, 'forgot-password'),
|
|
37
|
-
resetPassword: '/' + entryPath(config?.resetPassword, 'reset-password'),
|
|
38
|
-
};
|
|
36
|
+
function sparkAuthRoutes(...features) {
|
|
39
37
|
const children = [];
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
children.push(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
// Reachable only from the login page's RequiresTwoFactor branch, and it posts to the same
|
|
48
|
-
// /login endpoint — so it belongs to password sign-in, not to authentication in general.
|
|
49
|
-
child(config?.twoFactor, entryPath(config?.twoFactor, 'login/two-factor'), () => import('@mintplayer/ng-spark-auth/two-factor').then(m => m.SparkTwoFactorComponent)), child(config?.forgotPassword, entryPath(config?.forgotPassword, 'forgot-password'), () => import('@mintplayer/ng-spark-auth/forgot-password').then(m => m.SparkForgotPasswordComponent)), child(config?.resetPassword, entryPath(config?.resetPassword, 'reset-password'), () => import('@mintplayer/ng-spark-auth/reset-password').then(m => m.SparkResetPasswordComponent)));
|
|
50
|
-
}
|
|
51
|
-
if (mode === 'full') {
|
|
52
|
-
children.push(child(config?.register, entryPath(config?.register, 'register'), () => import('@mintplayer/ng-spark-auth/register').then(m => m.SparkRegisterComponent)));
|
|
38
|
+
const paths = {};
|
|
39
|
+
const externalProviders = [];
|
|
40
|
+
for (const feature of features) {
|
|
41
|
+
children.push(...feature.children);
|
|
42
|
+
Object.assign(paths, feature.paths);
|
|
43
|
+
if (feature.providers)
|
|
44
|
+
externalProviders.push(...feature.providers);
|
|
53
45
|
}
|
|
54
46
|
return [
|
|
55
47
|
{
|
|
56
48
|
path: '',
|
|
57
49
|
providers: [
|
|
58
50
|
{ provide: SPARK_AUTH_ROUTE_PATHS, useValue: paths },
|
|
51
|
+
{ provide: SPARK_EXTERNAL_PROVIDERS, useValue: externalProviders },
|
|
59
52
|
],
|
|
60
53
|
children,
|
|
61
54
|
},
|
|
62
55
|
];
|
|
63
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Mounts the email/password family: login, two-factor, forgot-password, reset-password.
|
|
59
|
+
*
|
|
60
|
+
* These four are one feature rather than four because they form a star centred on the login page and
|
|
61
|
+
* every template dereferences its siblings unconditionally — removing any proper subset leaves a
|
|
62
|
+
* dangling link. Registration is genuinely separable, and is its own feature.
|
|
63
|
+
*
|
|
64
|
+
* Two-factor belongs here because it is reachable only from the login page's `RequiresTwoFactor`
|
|
65
|
+
* branch and posts to the same `/login` endpoint: it is part of password sign-in, not of
|
|
66
|
+
* authentication in general.
|
|
67
|
+
*/
|
|
68
|
+
function withLocalLogin(entries) {
|
|
69
|
+
const login = entryPath(entries?.login, 'login');
|
|
70
|
+
const twoFactor = entryPath(entries?.twoFactor, 'login/two-factor');
|
|
71
|
+
const forgotPassword = entryPath(entries?.forgotPassword, 'forgot-password');
|
|
72
|
+
const resetPassword = entryPath(entries?.resetPassword, 'reset-password');
|
|
73
|
+
return {
|
|
74
|
+
paths: {
|
|
75
|
+
login: '/' + login,
|
|
76
|
+
twoFactor: '/' + twoFactor,
|
|
77
|
+
forgotPassword: '/' + forgotPassword,
|
|
78
|
+
resetPassword: '/' + resetPassword,
|
|
79
|
+
},
|
|
80
|
+
children: [
|
|
81
|
+
child(entries?.login, login, () => import('@mintplayer/ng-spark-auth/login').then(m => m.SparkLoginComponent)),
|
|
82
|
+
child(entries?.twoFactor, twoFactor, () => import('@mintplayer/ng-spark-auth/two-factor').then(m => m.SparkTwoFactorComponent)),
|
|
83
|
+
child(entries?.forgotPassword, forgotPassword, () => import('@mintplayer/ng-spark-auth/forgot-password').then(m => m.SparkForgotPasswordComponent)),
|
|
84
|
+
child(entries?.resetPassword, resetPassword, () => import('@mintplayer/ng-spark-auth/reset-password').then(m => m.SparkResetPasswordComponent)),
|
|
85
|
+
],
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Mounts the self-service registration page.
|
|
90
|
+
*
|
|
91
|
+
* Separate from {@link withLocalLogin} because the two decisions genuinely are separate: an
|
|
92
|
+
* application whose accounts are provisioned by an administrator still needs password sign-in and
|
|
93
|
+
* password reset. Mount it only alongside a server whose `SparkLocalCredentials` is `Full` — with
|
|
94
|
+
* `SignInOnly` the endpoint it posts to is not mapped.
|
|
95
|
+
*/
|
|
96
|
+
function withRegistration(entry) {
|
|
97
|
+
const register = entryPath(entry, 'register');
|
|
98
|
+
return {
|
|
99
|
+
paths: { register: '/' + register },
|
|
100
|
+
children: [
|
|
101
|
+
child(entry, register, () => import('@mintplayer/ng-spark-auth/register').then(m => m.SparkRegisterComponent)),
|
|
102
|
+
],
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Mounts the sign-in landing page — a button per external provider the *server* reports.
|
|
107
|
+
*
|
|
108
|
+
* Accepts provider declarations and, in any position, one options object for the page's own path;
|
|
109
|
+
* the two shapes are disjoint, so `withExternalLogin(githubProvider(), facebookProvider())` and
|
|
110
|
+
* `withExternalLogin({ signIn: 'landing' }, githubProvider())` both read naturally.
|
|
111
|
+
*
|
|
112
|
+
* Declaring no providers is valid and useful: the page still renders whatever
|
|
113
|
+
* `GET /spark/auth/capabilities` reports, using default buttons.
|
|
114
|
+
*/
|
|
115
|
+
function withExternalLogin(...providersOrOptions) {
|
|
116
|
+
const providers = providersOrOptions.filter(isProvider);
|
|
117
|
+
const options = providersOrOptions.find((p) => !isProvider(p));
|
|
118
|
+
const signIn = entryPath(options?.signIn, 'sign-in');
|
|
119
|
+
return {
|
|
120
|
+
paths: { signIn: '/' + signIn },
|
|
121
|
+
providers,
|
|
122
|
+
children: [
|
|
123
|
+
child(options?.signIn, signIn, () => import('@mintplayer/ng-spark-auth/sign-in').then(m => m.SparkSignInComponent)),
|
|
124
|
+
],
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function isProvider(value) {
|
|
128
|
+
return typeof value.scheme === 'string';
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Presentation for one provider's button, keyed by the scheme the server reports.
|
|
132
|
+
*
|
|
133
|
+
* The generic form. `githubProvider()` and friends are this with a scheme and an icon filled in —
|
|
134
|
+
* they exist so the common case does not require knowing the scheme string, not because the library
|
|
135
|
+
* has an opinion about which providers exist.
|
|
136
|
+
*/
|
|
137
|
+
function externalProvider(scheme, presentation) {
|
|
138
|
+
return { scheme, ...presentation };
|
|
139
|
+
}
|
|
140
|
+
function githubProvider(presentation) {
|
|
141
|
+
return externalProvider('GitHub', { iconClass: 'bi bi-github', ...presentation });
|
|
142
|
+
}
|
|
143
|
+
function googleProvider(presentation) {
|
|
144
|
+
return externalProvider('Google', { iconClass: 'bi bi-google', ...presentation });
|
|
145
|
+
}
|
|
146
|
+
function facebookProvider(presentation) {
|
|
147
|
+
return externalProvider('Facebook', { iconClass: 'bi bi-facebook', ...presentation });
|
|
148
|
+
}
|
|
149
|
+
function microsoftProvider(presentation) {
|
|
150
|
+
return externalProvider('Microsoft', { iconClass: 'bi bi-microsoft', ...presentation });
|
|
151
|
+
}
|
|
64
152
|
|
|
65
153
|
/**
|
|
66
154
|
* Generated bundle index. Do not edit.
|
|
67
155
|
*/
|
|
68
156
|
|
|
69
|
-
export { sparkAuthRoutes };
|
|
157
|
+
export { externalProvider, facebookProvider, githubProvider, googleProvider, microsoftProvider, sparkAuthRoutes, withExternalLogin, withLocalLogin, withRegistration };
|
|
70
158
|
//# sourceMappingURL=mintplayer-ng-spark-auth-routes.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mintplayer-ng-spark-auth-routes.mjs","sources":["../../routes/src/spark-auth-routes.ts","../../routes/mintplayer-ng-spark-auth-routes.ts"],"sourcesContent":["import { SPARK_AUTH_ROUTE_PATHS, SparkAuthRouteConfig, SparkAuthRouteEntry, SparkAuthRoutePaths } from '@mintplayer/ng-spark-auth/models';\n\ntype Loader = () => Promise<any>;\n\ninterface Child {\n path: string;\n loadComponent: Loader;\n}\n\n/** The routed path for an entry, independent of how its component is loaded. */\nfunction entryPath(entry: SparkAuthRouteEntry | undefined, defaultPath: string): string {\n if (entry === undefined) return defaultPath;\n return typeof entry === 'string' ? entry : entry.path;\n}\n\n/** An explicitly supplied component wins over the library's lazy import. */\nfunction child(entry: SparkAuthRouteEntry | undefined, path: string, defaultLoader: Loader): Child {\n const component = typeof entry === 'object' && entry.component ? entry.component : undefined;\n return { path, loadComponent: component ? () => Promise.resolve(component) : defaultLoader };\n}\n\n/**\n * The routes for Spark's authentication pages.\n *\n * `config.localCredentials` chooses how much of the email/password family to route, mirroring the\n * server's `SparkLocalCredentials`. `GET /spark/auth/capabilities` reports what the server is\n * actually running, so the two can be checked against each other.\n *\n * The `import()` expressions live *inside* the branches that need them. That placement is the point:\n * a bundler decides whether to emit a lazy chunk from whether the `import()` call site is reachable,\n * not from whether the route object referencing it survives — so filtering the children array after\n * the fact would still ship every page. Excluded pages must have no reachable `import()` at all.\n *\n * `SPARK_AUTH_ROUTE_PATHS` is still provided in full. The excluded pages are excluded together, so\n * nothing that survives can link to something that does not, and the token stays `Required`.\n */\nexport function sparkAuthRoutes(config?: SparkAuthRouteConfig): any[] {\n const mode = config?.localCredentials ?? 'full';\n\n const paths: SparkAuthRoutePaths = {\n signIn: '/' + entryPath(config?.signIn, 'sign-in'),\n login: '/' + entryPath(config?.login, 'login'),\n twoFactor: '/' + entryPath(config?.twoFactor, 'login/two-factor'),\n register: '/' + entryPath(config?.register, 'register'),\n forgotPassword: '/' + entryPath(config?.forgotPassword, 'forgot-password'),\n resetPassword: '/' + entryPath(config?.resetPassword, 'reset-password'),\n };\n\n const children: Child[] = [];\n\n // Only when local credentials are limited. In 'full' mode the login page is already the landing\n // page, and emitting a second one would change the routes of every app that never opted in.\n if (mode !== 'full') {\n children.push(\n child(config?.signIn, entryPath(config?.signIn, 'sign-in'),\n () => import('@mintplayer/ng-spark-auth/sign-in').then(m => m.SparkSignInComponent)),\n );\n }\n\n if (mode !== 'disabled') {\n children.push(\n child(config?.login, entryPath(config?.login, 'login'),\n () => import('@mintplayer/ng-spark-auth/login').then(m => m.SparkLoginComponent)),\n // Reachable only from the login page's RequiresTwoFactor branch, and it posts to the same\n // /login endpoint — so it belongs to password sign-in, not to authentication in general.\n child(config?.twoFactor, entryPath(config?.twoFactor, 'login/two-factor'),\n () => import('@mintplayer/ng-spark-auth/two-factor').then(m => m.SparkTwoFactorComponent)),\n child(config?.forgotPassword, entryPath(config?.forgotPassword, 'forgot-password'),\n () => import('@mintplayer/ng-spark-auth/forgot-password').then(m => m.SparkForgotPasswordComponent)),\n child(config?.resetPassword, entryPath(config?.resetPassword, 'reset-password'),\n () => import('@mintplayer/ng-spark-auth/reset-password').then(m => m.SparkResetPasswordComponent)),\n );\n }\n\n if (mode === 'full') {\n children.push(\n child(config?.register, entryPath(config?.register, 'register'),\n () => import('@mintplayer/ng-spark-auth/register').then(m => m.SparkRegisterComponent)),\n );\n }\n\n return [\n {\n path: '',\n providers: [\n { provide: SPARK_AUTH_ROUTE_PATHS, useValue: paths },\n ],\n children,\n },\n ];\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AASA;AACA,SAAS,SAAS,CAAC,KAAsC,EAAE,WAAmB,EAAA;IAC5E,IAAI,KAAK,KAAK,SAAS;AAAE,QAAA,OAAO,WAAW;AAC3C,IAAA,OAAO,OAAO,KAAK,KAAK,QAAQ,GAAG,KAAK,GAAG,KAAK,CAAC,IAAI;AACvD;AAEA;AACA,SAAS,KAAK,CAAC,KAAsC,EAAE,IAAY,EAAE,aAAqB,EAAA;IACxF,MAAM,SAAS,GAAG,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CA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mintplayer-ng-spark-auth-routes.mjs","sources":["../../routes/src/spark-auth-routes.ts","../../routes/mintplayer-ng-spark-auth-routes.ts"],"sourcesContent":["import {\n SPARK_AUTH_ROUTE_PATHS,\n SPARK_EXTERNAL_PROVIDERS,\n SparkAuthRouteEntries,\n SparkAuthRouteEntry,\n SparkAuthRoutePaths,\n SparkExternalProviderPresentation,\n} from '@mintplayer/ng-spark-auth/models';\n\ntype Loader = () => Promise<any>;\n\ninterface Child {\n path: string;\n loadComponent: Loader;\n}\n\n/** The routed path for an entry, independent of how its component is loaded. */\nfunction entryPath(entry: SparkAuthRouteEntry | undefined, defaultPath: string): string {\n if (entry === undefined) return defaultPath;\n return typeof entry === 'string' ? entry : entry.path;\n}\n\n/** An explicitly supplied component wins over the library's lazy import. */\nfunction child(entry: SparkAuthRouteEntry | undefined, path: string, defaultLoader: Loader): Child {\n const component = typeof entry === 'object' && entry.component ? entry.component : undefined;\n return { path, loadComponent: component ? () => Promise.resolve(component) : defaultLoader };\n}\n\n/**\n * One opt-in group of authentication pages. Produced by `withLocalLogin()`, `withRegistration()` and\n * `withExternalLogin()`; not constructible by consumers, which is what keeps the set of mountable\n * pages a decision this library makes rather than a shape an application can invent.\n */\nexport interface SparkAuthRoutesFeature {\n readonly children: Child[];\n readonly paths: SparkAuthRoutePaths;\n readonly providers?: SparkExternalProviderPresentation[];\n}\n\n/** Path override for the sign-in landing page. Named to stay clear of the core package's\n * `SparkExternalLoginOptions`, which is about the sign-in *call* rather than the route. */\nexport type SparkExternalLoginRouteOptions = Pick<SparkAuthRouteEntries, 'signIn'>;\n\n/**\n * The routes for Spark's authentication pages.\n *\n * **Nothing is mounted unless a feature asks for it.** Passing no features emits no pages at all —\n * opt-in enforced by construction rather than by a flag, matching `provideHttpClient(withFetch())`\n * and `provideRouter(withComponentInputBinding())`. Before this the pages mounted by default and an\n * application had to opt *out*, so every app shipped a registration form whether or not it wanted\n * one.\n *\n * ```ts\n * sparkAuthRoutes(\n * withLocalLogin(),\n * withRegistration(),\n * withExternalLogin(githubProvider(), facebookProvider()),\n * )\n * ```\n *\n * The `import()` expressions live *inside* each feature. That placement is the point: a bundler\n * decides whether to emit a lazy chunk from whether the `import()` call site is reachable, not from\n * whether the route object referencing it survives — so filtering a children array after the fact\n * would still ship every page. A page nobody opted into has no reachable `import()` at all.\n */\nexport function sparkAuthRoutes(...features: SparkAuthRoutesFeature[]): any[] {\n const children: Child[] = [];\n const paths: SparkAuthRoutePaths = {};\n const externalProviders: SparkExternalProviderPresentation[] = [];\n\n for (const feature of features) {\n children.push(...feature.children);\n Object.assign(paths, feature.paths);\n if (feature.providers) externalProviders.push(...feature.providers);\n }\n\n return [\n {\n path: '',\n providers: [\n { provide: SPARK_AUTH_ROUTE_PATHS, useValue: paths },\n { provide: SPARK_EXTERNAL_PROVIDERS, useValue: externalProviders },\n ],\n children,\n },\n ];\n}\n\n/**\n * Mounts the email/password family: login, two-factor, forgot-password, reset-password.\n *\n * These four are one feature rather than four because they form a star centred on the login page and\n * every template dereferences its siblings unconditionally — removing any proper subset leaves a\n * dangling link. Registration is genuinely separable, and is its own feature.\n *\n * Two-factor belongs here because it is reachable only from the login page's `RequiresTwoFactor`\n * branch and posts to the same `/login` endpoint: it is part of password sign-in, not of\n * authentication in general.\n */\nexport function withLocalLogin(\n entries?: Pick<SparkAuthRouteEntries, 'login' | 'twoFactor' | 'forgotPassword' | 'resetPassword'>,\n): SparkAuthRoutesFeature {\n const login = entryPath(entries?.login, 'login');\n const twoFactor = entryPath(entries?.twoFactor, 'login/two-factor');\n const forgotPassword = entryPath(entries?.forgotPassword, 'forgot-password');\n const resetPassword = entryPath(entries?.resetPassword, 'reset-password');\n\n return {\n paths: {\n login: '/' + login,\n twoFactor: '/' + twoFactor,\n forgotPassword: '/' + forgotPassword,\n resetPassword: '/' + resetPassword,\n },\n children: [\n child(entries?.login, login,\n () => import('@mintplayer/ng-spark-auth/login').then(m => m.SparkLoginComponent)),\n child(entries?.twoFactor, twoFactor,\n () => import('@mintplayer/ng-spark-auth/two-factor').then(m => m.SparkTwoFactorComponent)),\n child(entries?.forgotPassword, forgotPassword,\n () => import('@mintplayer/ng-spark-auth/forgot-password').then(m => m.SparkForgotPasswordComponent)),\n child(entries?.resetPassword, resetPassword,\n () => import('@mintplayer/ng-spark-auth/reset-password').then(m => m.SparkResetPasswordComponent)),\n ],\n };\n}\n\n/**\n * Mounts the self-service registration page.\n *\n * Separate from {@link withLocalLogin} because the two decisions genuinely are separate: an\n * application whose accounts are provisioned by an administrator still needs password sign-in and\n * password reset. Mount it only alongside a server whose `SparkLocalCredentials` is `Full` — with\n * `SignInOnly` the endpoint it posts to is not mapped.\n */\nexport function withRegistration(entry?: SparkAuthRouteEntry): SparkAuthRoutesFeature {\n const register = entryPath(entry, 'register');\n\n return {\n paths: { register: '/' + register },\n children: [\n child(entry, register,\n () => import('@mintplayer/ng-spark-auth/register').then(m => m.SparkRegisterComponent)),\n ],\n };\n}\n\n/**\n * Mounts the sign-in landing page — a button per external provider the *server* reports.\n *\n * Accepts provider declarations and, in any position, one options object for the page's own path;\n * the two shapes are disjoint, so `withExternalLogin(githubProvider(), facebookProvider())` and\n * `withExternalLogin({ signIn: 'landing' }, githubProvider())` both read naturally.\n *\n * Declaring no providers is valid and useful: the page still renders whatever\n * `GET /spark/auth/capabilities` reports, using default buttons.\n */\nexport function withExternalLogin(\n ...providersOrOptions: (SparkExternalProviderPresentation | SparkExternalLoginRouteOptions)[]\n): SparkAuthRoutesFeature {\n const providers = providersOrOptions.filter(isProvider);\n const options = providersOrOptions.find((p): p is SparkExternalLoginRouteOptions => !isProvider(p));\n const signIn = entryPath(options?.signIn, 'sign-in');\n\n return {\n paths: { signIn: '/' + signIn },\n providers,\n children: [\n child(options?.signIn, signIn,\n () => import('@mintplayer/ng-spark-auth/sign-in').then(m => m.SparkSignInComponent)),\n ],\n };\n}\n\nfunction isProvider(\n value: SparkExternalProviderPresentation | SparkExternalLoginRouteOptions,\n): value is SparkExternalProviderPresentation {\n return typeof (value as SparkExternalProviderPresentation).scheme === 'string';\n}\n\n/**\n * Presentation for one provider's button, keyed by the scheme the server reports.\n *\n * The generic form. `githubProvider()` and friends are this with a scheme and an icon filled in —\n * they exist so the common case does not require knowing the scheme string, not because the library\n * has an opinion about which providers exist.\n */\nexport function externalProvider(\n scheme: string,\n presentation?: Omit<SparkExternalProviderPresentation, 'scheme'>,\n): SparkExternalProviderPresentation {\n return { scheme, ...presentation };\n}\n\nexport function githubProvider(\n presentation?: Omit<SparkExternalProviderPresentation, 'scheme'>,\n): SparkExternalProviderPresentation {\n return externalProvider('GitHub', { iconClass: 'bi bi-github', ...presentation });\n}\n\nexport function googleProvider(\n presentation?: Omit<SparkExternalProviderPresentation, 'scheme'>,\n): SparkExternalProviderPresentation {\n return externalProvider('Google', { iconClass: 'bi bi-google', ...presentation });\n}\n\nexport function facebookProvider(\n presentation?: Omit<SparkExternalProviderPresentation, 'scheme'>,\n): SparkExternalProviderPresentation {\n return externalProvider('Facebook', { iconClass: 'bi bi-facebook', ...presentation });\n}\n\nexport function microsoftProvider(\n presentation?: Omit<SparkExternalProviderPresentation, 'scheme'>,\n): SparkExternalProviderPresentation {\n return externalProvider('Microsoft', { iconClass: 'bi bi-microsoft', ...presentation });\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAgBA;AACA,SAAS,SAAS,CAAC,KAAsC,EAAE,WAAmB,EAAA;IAC5E,IAAI,KAAK,KAAK,SAAS;AAAE,QAAA,OAAO,WAAW;AAC3C,IAAA,OAAO,OAAO,KAAK,KAAK,QAAQ,GAAG,KAAK,GAAG,KAAK,CAAC,IAAI;AACvD;AAEA;AACA,SAAS,KAAK,CAAC,KAAsC,EAAE,IAAY,EAAE,aAAqB,EAAA;IACxF,MAAM,SAAS,GAAG,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,GAAG,SAAS;IAC5F,OAAO,EAAE,IAA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O,gBAAgB,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,iBAAiB,EAAE,GAAG,YAAY,EAAE,CAAC;AACzF;;ACxNA;;AAEG;;;;"}
|
|
@@ -1,42 +1,100 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, signal, isDevMode, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
-
import {
|
|
2
|
+
import { inject, input, signal, computed, isDevMode, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
4
|
+
import { ActivatedRoute, RouterLink } from '@angular/router';
|
|
4
5
|
import { Color } from '@mintplayer/ng-bootstrap';
|
|
5
6
|
import { BsAlertComponent } from '@mintplayer/ng-bootstrap/alert';
|
|
6
7
|
import { BsCardComponent, BsCardHeaderComponent } from '@mintplayer/ng-bootstrap/card';
|
|
7
8
|
import { BsSpinnerComponent } from '@mintplayer/ng-bootstrap/spinner';
|
|
8
|
-
import { SPARK_AUTH_ROUTE_PATHS } from '@mintplayer/ng-spark-auth/models';
|
|
9
|
+
import { SPARK_EXTERNAL_PROVIDERS, SPARK_AUTH_ROUTE_PATHS, isSafeReturnUrl } from '@mintplayer/ng-spark-auth/models';
|
|
9
10
|
import { SparkAuthService } from '@mintplayer/ng-spark-auth/core';
|
|
10
11
|
import { TranslateKeyPipe } from '@mintplayer/ng-spark-auth/pipes';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
|
-
* The sign-in landing page
|
|
14
|
-
*
|
|
14
|
+
* The sign-in landing page: a button per external provider, and a link to the password form when the
|
|
15
|
+
* application mounted one.
|
|
15
16
|
*
|
|
16
17
|
* The providers come from `GET /spark/auth/capabilities` rather than from a list the application
|
|
17
18
|
* hard-codes. That is the point of the component: every consumer that hand-rolled this before wrote
|
|
18
19
|
* the scheme name as a string literal, which is a silent mismatch waiting to happen the moment the
|
|
19
|
-
* server's provider registration changes.
|
|
20
|
+
* server's provider registration changes. A `withExternalLogin(githubProvider())` declaration only
|
|
21
|
+
* *decorates* what the server reports — it cannot conjure a provider the server does not have.
|
|
20
22
|
*/
|
|
21
23
|
class SparkSignInComponent {
|
|
22
24
|
authService = inject(SparkAuthService);
|
|
25
|
+
declaredProviders = inject(SPARK_EXTERNAL_PROVIDERS, { optional: true }) ?? [];
|
|
26
|
+
route = inject(ActivatedRoute, { optional: true });
|
|
23
27
|
routePaths = inject(SPARK_AUTH_ROUTE_PATHS);
|
|
24
28
|
colors = Color;
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Where to land after a successful external sign-in.
|
|
31
|
+
*
|
|
32
|
+
* Falls back to a `?returnUrl=` query parameter, matching what the login page already does — so a
|
|
33
|
+
* plain `<a routerLink="/sign-in" [queryParams]="{ returnUrl: '/somewhere' }">` works with no
|
|
34
|
+
* wiring, which is what a routed page needs since the router passes it no inputs. The query value
|
|
35
|
+
* is validated as a local path before use; an off-site one is dropped rather than followed.
|
|
36
|
+
*/
|
|
37
|
+
returnUrl = input(undefined, /* @ts-ignore */
|
|
38
|
+
...(ngDevMode ? [{ debugName: "returnUrl" }] : /* istanbul ignore next */ []));
|
|
39
|
+
effectiveReturnUrl() {
|
|
40
|
+
const explicit = this.returnUrl();
|
|
41
|
+
if (explicit)
|
|
42
|
+
return explicit;
|
|
43
|
+
const fromQuery = this.route?.snapshot.queryParamMap.get('returnUrl');
|
|
44
|
+
return isSafeReturnUrl(fromQuery) ? fromQuery : undefined;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Replaces the default provider button. Rendered once per provider with a
|
|
48
|
+
* {@link SparkProviderButtonContext}.
|
|
49
|
+
*
|
|
50
|
+
* Reachable only when the consumer *hosts* this component — the router instantiates it with no
|
|
51
|
+
* projected content, so on a default `withExternalLogin()` route there is nothing to project into.
|
|
52
|
+
* Host it via `withExternalLogin({ signIn: { path: 'sign-in', component: MySignIn } })` and pass
|
|
53
|
+
* the template from there.
|
|
54
|
+
*/
|
|
55
|
+
providerTemplate = input(null, /* @ts-ignore */
|
|
56
|
+
...(ngDevMode ? [{ debugName: "providerTemplate" }] : /* istanbul ignore next */ []));
|
|
57
|
+
reported = signal([], /* @ts-ignore */
|
|
58
|
+
...(ngDevMode ? [{ debugName: "reported" }] : /* istanbul ignore next */ []));
|
|
27
59
|
localCredentialsAvailable = signal(false, /* @ts-ignore */
|
|
28
60
|
...(ngDevMode ? [{ debugName: "localCredentialsAvailable" }] : /* istanbul ignore next */ []));
|
|
29
61
|
loading = signal(true, /* @ts-ignore */
|
|
30
62
|
...(ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []));
|
|
31
63
|
failed = signal(false, /* @ts-ignore */
|
|
32
64
|
...(ngDevMode ? [{ debugName: "failed" }] : /* istanbul ignore next */ []));
|
|
65
|
+
/**
|
|
66
|
+
* The server's list, decorated and ordered by whatever the application declared. Declared-but-not-
|
|
67
|
+
* reported schemes are dropped and reported-but-not-declared ones keep a default button, so
|
|
68
|
+
* neither side can produce a provider the other does not have.
|
|
69
|
+
*/
|
|
70
|
+
providers = computed(() => {
|
|
71
|
+
const declarations = new Map(this.declaredProviders.map(p => [p.scheme.toLowerCase(), p]));
|
|
72
|
+
return this.reported()
|
|
73
|
+
.map((provider, index) => {
|
|
74
|
+
const declared = declarations.get(provider.scheme.toLowerCase());
|
|
75
|
+
return {
|
|
76
|
+
provider: {
|
|
77
|
+
...provider,
|
|
78
|
+
displayName: declared?.displayName ?? provider.displayName,
|
|
79
|
+
iconClass: declared?.iconClass,
|
|
80
|
+
},
|
|
81
|
+
// Undeclared providers sort after declared ones, keeping the server's relative order among
|
|
82
|
+
// themselves — so adding a provider server-side appends a button rather than reshuffling.
|
|
83
|
+
order: declared?.order ?? Number.MAX_SAFE_INTEGER,
|
|
84
|
+
index,
|
|
85
|
+
};
|
|
86
|
+
})
|
|
87
|
+
.sort((a, b) => a.order - b.order || a.index - b.index)
|
|
88
|
+
.map(entry => entry.provider);
|
|
89
|
+
}, /* @ts-ignore */
|
|
90
|
+
...(ngDevMode ? [{ debugName: "providers" }] : /* istanbul ignore next */ []));
|
|
33
91
|
constructor() {
|
|
34
92
|
void this.load();
|
|
35
93
|
}
|
|
36
94
|
async load() {
|
|
37
95
|
try {
|
|
38
96
|
const capabilities = await this.authService.capabilities();
|
|
39
|
-
this.
|
|
97
|
+
this.reported.set(capabilities.externalProviders);
|
|
40
98
|
this.localCredentialsAvailable.set(capabilities.localCredentials !== 'Disabled');
|
|
41
99
|
this.warnOnMismatch(capabilities);
|
|
42
100
|
}
|
|
@@ -57,20 +115,27 @@ class SparkSignInComponent {
|
|
|
57
115
|
warnOnMismatch(capabilities) {
|
|
58
116
|
if (isDevMode() && capabilities.localCredentials === 'Full') {
|
|
59
117
|
console.warn('[ng-spark-auth] This app routes the sign-in landing page, but the server reports '
|
|
60
|
-
+ 'localCredentials = Full. The two are configured independently — check that '
|
|
61
|
-
+ "sparkAuthRoutes(
|
|
118
|
+
+ 'localCredentials = Full. The two are configured independently — check that the features '
|
|
119
|
+
+ "passed to sparkAuthRoutes() match AddAuthentication's LocalCredentials mode.");
|
|
62
120
|
}
|
|
63
121
|
}
|
|
122
|
+
/** The closure handed to a projected template, so a consumer never names a scheme itself. */
|
|
123
|
+
contextFor(provider) {
|
|
124
|
+
return { $implicit: provider, signIn: () => this.signInWith(provider) };
|
|
125
|
+
}
|
|
64
126
|
signInWith(provider) {
|
|
65
|
-
void this.authService.loginWithProvider(provider.scheme);
|
|
127
|
+
void this.authService.loginWithProvider(provider.scheme, { returnUrl: this.effectiveReturnUrl() });
|
|
66
128
|
}
|
|
67
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
68
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.
|
|
129
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: SparkSignInComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
130
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: SparkSignInComponent, isStandalone: true, selector: "spark-sign-in", inputs: { returnUrl: { classPropertyName: "returnUrl", publicName: "returnUrl", isSignal: true, isRequired: false, transformFunction: null }, providerTemplate: { classPropertyName: "providerTemplate", publicName: "providerTemplate", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<div class=\"d-flex justify-content-center\">\n <bs-card style=\"width: 100%; max-width: 400px;\">\n <bs-card-header>\n <h3 class=\"mb-0 text-center\">{{ 'auth.login' | t }}</h3>\n </bs-card-header>\n <div class=\"p-4\">\n @if (loading()) {\n <div class=\"text-center\"><bs-spinner /></div>\n } @else if (failed()) {\n <bs-alert [type]=\"colors.danger\" class=\"mb-0\">{{ 'auth.signInUnavailable' | t }}</bs-alert>\n } @else {\n @for (provider of providers(); track provider.scheme) {\n @if (providerTemplate(); as tpl) {\n <ng-container *ngTemplateOutlet=\"tpl; context: contextFor(provider)\" />\n } @else {\n <button type=\"button\" class=\"btn btn-outline-primary w-100 mb-2\" (click)=\"signInWith(provider)\">\n @if (provider.iconClass) {\n <i [class]=\"provider.iconClass\" class=\"me-2\"></i>\n }\n {{ provider.displayName }}\n </button>\n }\n } @empty {\n <bs-alert [type]=\"colors.warning\" class=\"mb-0\">{{ 'auth.noSignInMethods' | t }}</bs-alert>\n }\n\n <!-- Two conditions, not one. The server may still accept passwords while this app chose not\n to mount the page \u2014 sparkAuthRoutes is opt-in per feature now \u2014 and a [routerLink] bound\n to undefined silently navigates to the current route rather than failing. -->\n @if (localCredentialsAvailable() && routePaths.login) {\n <div class=\"text-center mt-3\">\n <a [routerLink]=\"routePaths.login\">{{ 'auth.login' | t }}</a>\n </div>\n }\n }\n </div>\n </bs-card>\n</div>\n", dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "browserUrl", "routerLink"] }, { kind: "component", type: BsAlertComponent, selector: "bs-alert", inputs: ["type", "announce", "isVisible"], outputs: ["isVisibleChange", "afterOpenedOrClosed"] }, { kind: "component", type: BsCardComponent, selector: "bs-card", inputs: ["color", "outline"] }, { kind: "component", type: BsCardHeaderComponent, selector: "bs-card-header", inputs: ["color", "navStyle"] }, { kind: "component", type: BsSpinnerComponent, selector: "bs-spinner", inputs: ["type", "color"] }, { kind: "pipe", type: TranslateKeyPipe, name: "t" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
69
131
|
}
|
|
70
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
132
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: SparkSignInComponent, decorators: [{
|
|
71
133
|
type: Component,
|
|
72
|
-
args: [{ selector: 'spark-sign-in', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [
|
|
73
|
-
|
|
134
|
+
args: [{ selector: 'spark-sign-in', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [
|
|
135
|
+
NgTemplateOutlet, RouterLink, BsAlertComponent, BsCardComponent, BsCardHeaderComponent,
|
|
136
|
+
BsSpinnerComponent, TranslateKeyPipe,
|
|
137
|
+
], template: "<div class=\"d-flex justify-content-center\">\n <bs-card style=\"width: 100%; max-width: 400px;\">\n <bs-card-header>\n <h3 class=\"mb-0 text-center\">{{ 'auth.login' | t }}</h3>\n </bs-card-header>\n <div class=\"p-4\">\n @if (loading()) {\n <div class=\"text-center\"><bs-spinner /></div>\n } @else if (failed()) {\n <bs-alert [type]=\"colors.danger\" class=\"mb-0\">{{ 'auth.signInUnavailable' | t }}</bs-alert>\n } @else {\n @for (provider of providers(); track provider.scheme) {\n @if (providerTemplate(); as tpl) {\n <ng-container *ngTemplateOutlet=\"tpl; context: contextFor(provider)\" />\n } @else {\n <button type=\"button\" class=\"btn btn-outline-primary w-100 mb-2\" (click)=\"signInWith(provider)\">\n @if (provider.iconClass) {\n <i [class]=\"provider.iconClass\" class=\"me-2\"></i>\n }\n {{ provider.displayName }}\n </button>\n }\n } @empty {\n <bs-alert [type]=\"colors.warning\" class=\"mb-0\">{{ 'auth.noSignInMethods' | t }}</bs-alert>\n }\n\n <!-- Two conditions, not one. The server may still accept passwords while this app chose not\n to mount the page \u2014 sparkAuthRoutes is opt-in per feature now \u2014 and a [routerLink] bound\n to undefined silently navigates to the current route rather than failing. -->\n @if (localCredentialsAvailable() && routePaths.login) {\n <div class=\"text-center mt-3\">\n <a [routerLink]=\"routePaths.login\">{{ 'auth.login' | t }}</a>\n </div>\n }\n }\n </div>\n </bs-card>\n</div>\n" }]
|
|
138
|
+
}], ctorParameters: () => [], propDecorators: { returnUrl: [{ type: i0.Input, args: [{ isSignal: true, alias: "returnUrl", required: false }] }], providerTemplate: [{ type: i0.Input, args: [{ isSignal: true, alias: "providerTemplate", required: false }] }] } });
|
|
74
139
|
|
|
75
140
|
/**
|
|
76
141
|
* Generated bundle index. Do not edit.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mintplayer-ng-spark-auth-sign-in.mjs","sources":["../../sign-in/src/spark-sign-in.component.ts","../../sign-in/src/spark-sign-in.component.html","../../sign-in/mintplayer-ng-spark-auth-sign-in.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, inject, isDevMode, signal } from '@angular/core';\nimport { RouterLink } from '@angular/router';\nimport { Color } from '@mintplayer/ng-bootstrap';\nimport { BsAlertComponent } from '@mintplayer/ng-bootstrap/alert';\nimport { BsCardComponent, BsCardHeaderComponent } from '@mintplayer/ng-bootstrap/card';\nimport { BsSpinnerComponent } from '@mintplayer/ng-bootstrap/spinner';\nimport { SPARK_AUTH_ROUTE_PATHS, SparkAuthCapabilities, SparkExternalProvider } from '@mintplayer/ng-spark-auth/models';\nimport { SparkAuthService } from '@mintplayer/ng-spark-auth/core';\nimport { TranslateKeyPipe } from '@mintplayer/ng-spark-auth/pipes';\n\n/**\n * The sign-in landing page for an application whose local credentials are turned off — a button per\n * external provider, and a link to the password form when there still is one.\n *\n * The providers come from `GET /spark/auth/capabilities` rather than from a list the application\n * hard-codes. That is the point of the component: every consumer that hand-rolled this before wrote\n * the scheme name as a string literal, which is a silent mismatch waiting to happen the moment the\n * server's provider registration changes.\n */\n@Component({\n selector: 'spark-sign-in',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [RouterLink, BsAlertComponent, BsCardComponent, BsCardHeaderComponent, BsSpinnerComponent, TranslateKeyPipe],\n templateUrl: './spark-sign-in.component.html',\n})\nexport class SparkSignInComponent {\n private readonly authService = inject(SparkAuthService);\n readonly routePaths = inject(SPARK_AUTH_ROUTE_PATHS);\n readonly colors = Color;\n\n readonly providers = signal<SparkExternalProvider[]>([]);\n readonly localCredentialsAvailable = signal(false);\n readonly loading = signal(true);\n readonly failed = signal(false);\n\n constructor() {\n void this.load();\n }\n\n private async load(): Promise<void> {\n try {\n const capabilities = await this.authService.capabilities();\n this.providers.set(capabilities.externalProviders);\n this.localCredentialsAvailable.set(capabilities.localCredentials !== 'Disabled');\n this.warnOnMismatch(capabilities);\n } catch {\n // A sign-in page that renders nothing looks identical to one whose providers all failed to\n // load, so say which happened rather than showing an empty page.\n this.failed.set(true);\n } finally {\n this.loading.set(false);\n }\n }\n\n /**\n * The routes are a build-time decision and the server's mode a deployment-time one, so they can\n * disagree without anything failing loudly. Reaching this page at all means the app routed it,\n * which it only does when local credentials are meant to be limited.\n */\n private warnOnMismatch(capabilities: SparkAuthCapabilities): void {\n if (isDevMode() && capabilities.localCredentials === 'Full') {\n console.warn(\n '[ng-spark-auth] This app routes the sign-in landing page, but the server reports '\n + 'localCredentials = Full. The two are configured independently — check that '\n + \"sparkAuthRoutes({ localCredentials: … }) matches AddAuthentication's LocalCredentials mode.\",\n );\n }\n }\n\n signInWith(provider: SparkExternalProvider): void {\n void this.authService.loginWithProvider(provider.scheme);\n }\n}\n\nexport default SparkSignInComponent;\n","<div class=\"d-flex justify-content-center\">\n <bs-card style=\"width: 100%; max-width: 400px;\">\n <bs-card-header>\n <h3 class=\"mb-0 text-center\">{{ 'auth.login' | t }}</h3>\n </bs-card-header>\n <div class=\"p-4\">\n @if (loading()) {\n <div class=\"text-center\"><bs-spinner /></div>\n } @else if (failed()) {\n <bs-alert [type]=\"colors.danger\" class=\"mb-0\">{{ 'auth.signInUnavailable' | t }}</bs-alert>\n } @else {\n @for (provider of providers(); track provider.scheme) {\n <button type=\"button\" class=\"btn btn-outline-primary w-100 mb-2\" (click)=\"signInWith(provider)\">\n {{ provider.displayName }}\n </button>\n } @empty {\n <bs-alert [type]=\"colors.warning\" class=\"mb-0\">{{ 'auth.noSignInMethods' | t }}</bs-alert>\n }\n\n @if (localCredentialsAvailable()) {\n <div class=\"text-center mt-3\">\n <a [routerLink]=\"routePaths.login\">{{ 'auth.login' | t }}</a>\n </div>\n }\n }\n </div>\n </bs-card>\n</div>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;AAUA;;;;;;;;AAQG;MAQU,oBAAoB,CAAA;AACd,IAAA,WAAW,GAAG,MAAM,CAAC,gBAAgB,CAAC;AAC9C,IAAA,UAAU,GAAG,MAAM,CAAC,sBAAsB,CAAC;IAC3C,MAAM,GAAG,KAAK;IAEd,SAAS,GAAG,MAAM,CAA0B,EAAE;kFAAC;IAC/C,yBAAyB,GAAG,MAAM,CAAC,KAAK;kGAAC;IACzC,OAAO,GAAG,MAAM,CAAC,IAAI;gFAAC;IACtB,MAAM,GAAG,MAAM,CAAC,KAAK;+EAAC;AAE/B,IAAA,WAAA,GAAA;AACE,QAAA,KAAK,IAAI,CAAC,IAAI,EAAE;IAClB;AAEQ,IAAA,M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spark-auth-sign-in.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, TemplateRef, computed, inject, input, isDevMode, signal } from '@angular/core';\nimport { NgTemplateOutlet } from '@angular/common';\nimport { ActivatedRoute, RouterLink } from '@angular/router';\nimport { Color } from '@mintplayer/ng-bootstrap';\nimport { BsAlertComponent } from '@mintplayer/ng-bootstrap/alert';\nimport { BsCardComponent, BsCardHeaderComponent } from '@mintplayer/ng-bootstrap/card';\nimport { BsSpinnerComponent } from '@mintplayer/ng-bootstrap/spinner';\nimport {\n SPARK_AUTH_ROUTE_PATHS,\n SPARK_EXTERNAL_PROVIDERS,\n SparkAuthCapabilities,\n SparkExternalProvider,\n SparkExternalProviderPresentation,\n isSafeReturnUrl,\n} from '@mintplayer/ng-spark-auth/models';\nimport { SparkAuthService } from '@mintplayer/ng-spark-auth/core';\nimport { TranslateKeyPipe } from '@mintplayer/ng-spark-auth/pipes';\n\n/**\n * One provider's button, as the template sees it: the provider itself, and the call that signs in\n * with it.\n *\n * **Passing the closure is the point.** A consumer never touches `provider.scheme`, so the failure\n * this component exists to prevent — a hard-coded scheme string that silently stops matching when\n * the server's registration changes — is unreachable by construction. It also means busy state,\n * `returnUrl` handling and popup-versus-redirect can move behind `signIn` later without a\n * consumer-facing change.\n */\nexport interface SparkProviderButtonContext {\n $implicit: SparkExternalProviderView;\n signIn: () => void;\n}\n\n/** A provider the server reported, merged with whatever presentation the app declared for it. */\nexport interface SparkExternalProviderView extends SparkExternalProvider {\n iconClass?: string;\n}\n\n/**\n * The sign-in landing page: a button per external provider, and a link to the password form when the\n * application mounted one.\n *\n * The providers come from `GET /spark/auth/capabilities` rather than from a list the application\n * hard-codes. That is the point of the component: every consumer that hand-rolled this before wrote\n * the scheme name as a string literal, which is a silent mismatch waiting to happen the moment the\n * server's provider registration changes. A `withExternalLogin(githubProvider())` declaration only\n * *decorates* what the server reports — it cannot conjure a provider the server does not have.\n */\n@Component({\n selector: 'spark-sign-in',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [\n NgTemplateOutlet, RouterLink, BsAlertComponent, BsCardComponent, BsCardHeaderComponent,\n BsSpinnerComponent, TranslateKeyPipe,\n ],\n templateUrl: './spark-sign-in.component.html',\n})\nexport class SparkSignInComponent {\n private readonly authService = inject(SparkAuthService);\n private readonly declaredProviders = inject(SPARK_EXTERNAL_PROVIDERS, { optional: true }) ?? [];\n private readonly route = inject(ActivatedRoute, { optional: true });\n readonly routePaths = inject(SPARK_AUTH_ROUTE_PATHS);\n readonly colors = Color;\n\n /**\n * Where to land after a successful external sign-in.\n *\n * Falls back to a `?returnUrl=` query parameter, matching what the login page already does — so a\n * plain `<a routerLink=\"/sign-in\" [queryParams]=\"{ returnUrl: '/somewhere' }\">` works with no\n * wiring, which is what a routed page needs since the router passes it no inputs. The query value\n * is validated as a local path before use; an off-site one is dropped rather than followed.\n */\n readonly returnUrl = input<string | undefined>(undefined);\n\n private effectiveReturnUrl(): string | undefined {\n const explicit = this.returnUrl();\n if (explicit) return explicit;\n\n const fromQuery = this.route?.snapshot.queryParamMap.get('returnUrl');\n return isSafeReturnUrl(fromQuery) ? fromQuery! : undefined;\n }\n\n /**\n * Replaces the default provider button. Rendered once per provider with a\n * {@link SparkProviderButtonContext}.\n *\n * Reachable only when the consumer *hosts* this component — the router instantiates it with no\n * projected content, so on a default `withExternalLogin()` route there is nothing to project into.\n * Host it via `withExternalLogin({ signIn: { path: 'sign-in', component: MySignIn } })` and pass\n * the template from there.\n */\n readonly providerTemplate = input<TemplateRef<SparkProviderButtonContext> | null>(null);\n\n private readonly reported = signal<SparkExternalProvider[]>([]);\n readonly localCredentialsAvailable = signal(false);\n readonly loading = signal(true);\n readonly failed = signal(false);\n\n /**\n * The server's list, decorated and ordered by whatever the application declared. Declared-but-not-\n * reported schemes are dropped and reported-but-not-declared ones keep a default button, so\n * neither side can produce a provider the other does not have.\n */\n readonly providers = computed<SparkExternalProviderView[]>(() => {\n const declarations = new Map<string, SparkExternalProviderPresentation>(\n this.declaredProviders.map(p => [p.scheme.toLowerCase(), p]),\n );\n\n return this.reported()\n .map((provider, index) => {\n const declared = declarations.get(provider.scheme.toLowerCase());\n return {\n provider: {\n ...provider,\n displayName: declared?.displayName ?? provider.displayName,\n iconClass: declared?.iconClass,\n } satisfies SparkExternalProviderView,\n // Undeclared providers sort after declared ones, keeping the server's relative order among\n // themselves — so adding a provider server-side appends a button rather than reshuffling.\n order: declared?.order ?? Number.MAX_SAFE_INTEGER,\n index,\n };\n })\n .sort((a, b) => a.order - b.order || a.index - b.index)\n .map(entry => entry.provider);\n });\n\n constructor() {\n void this.load();\n }\n\n private async load(): Promise<void> {\n try {\n const capabilities = await this.authService.capabilities();\n this.reported.set(capabilities.externalProviders);\n this.localCredentialsAvailable.set(capabilities.localCredentials !== 'Disabled');\n this.warnOnMismatch(capabilities);\n } catch {\n // A sign-in page that renders nothing looks identical to one whose providers all failed to\n // load, so say which happened rather than showing an empty page.\n this.failed.set(true);\n } finally {\n this.loading.set(false);\n }\n }\n\n /**\n * The routes are a build-time decision and the server's mode a deployment-time one, so they can\n * disagree without anything failing loudly. Reaching this page at all means the app routed it,\n * which it only does when local credentials are meant to be limited.\n */\n private warnOnMismatch(capabilities: SparkAuthCapabilities): void {\n if (isDevMode() && capabilities.localCredentials === 'Full') {\n console.warn(\n '[ng-spark-auth] This app routes the sign-in landing page, but the server reports '\n + 'localCredentials = Full. The two are configured independently — check that the features '\n + \"passed to sparkAuthRoutes() match AddAuthentication's LocalCredentials mode.\",\n );\n }\n }\n\n /** The closure handed to a projected template, so a consumer never names a scheme itself. */\n contextFor(provider: SparkExternalProviderView): SparkProviderButtonContext {\n return { $implicit: provider, signIn: () => this.signInWith(provider) };\n }\n\n signInWith(provider: SparkExternalProviderView): void {\n void this.authService.loginWithProvider(provider.scheme, { returnUrl: this.effectiveReturnUrl() });\n }\n}\n\nexport default SparkSignInComponent;\n","<div class=\"d-flex justify-content-center\">\n <bs-card style=\"width: 100%; max-width: 400px;\">\n <bs-card-header>\n <h3 class=\"mb-0 text-center\">{{ 'auth.login' | t }}</h3>\n </bs-card-header>\n <div class=\"p-4\">\n @if (loading()) {\n <div class=\"text-center\"><bs-spinner /></div>\n } @else if (failed()) {\n <bs-alert [type]=\"colors.danger\" class=\"mb-0\">{{ 'auth.signInUnavailable' | t }}</bs-alert>\n } @else {\n @for (provider of providers(); track provider.scheme) {\n @if (providerTemplate(); as tpl) {\n <ng-container *ngTemplateOutlet=\"tpl; context: contextFor(provider)\" />\n } @else {\n <button type=\"button\" class=\"btn btn-outline-primary w-100 mb-2\" (click)=\"signInWith(provider)\">\n @if (provider.iconClass) {\n <i [class]=\"provider.iconClass\" class=\"me-2\"></i>\n }\n {{ provider.displayName }}\n </button>\n }\n } @empty {\n <bs-alert [type]=\"colors.warning\" class=\"mb-0\">{{ 'auth.noSignInMethods' | t }}</bs-alert>\n }\n\n <!-- Two conditions, not one. The server may still accept passwords while this app chose not\n to mount the page — sparkAuthRoutes is opt-in per feature now — and a [routerLink] bound\n to undefined silently navigates to the current route rather than failing. -->\n @if (localCredentialsAvailable() && routePaths.login) {\n <div class=\"text-center mt-3\">\n <a [routerLink]=\"routePaths.login\">{{ 'auth.login' | t }}</a>\n </div>\n }\n }\n </div>\n </bs-card>\n</div>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;AAsCA;;;;;;;;;AASG;MAWU,oBAAoB,CAAA;AACd,IAAA,WAAW,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACtC,IAAA,iBAAiB,GAAG,MAAM,CAAC,wBAAwB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE;IAC9E,KAAK,GAAG,MAAM,CAAC,cAAc,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAC1D,IAAA,UAAU,GAAG,MAAM,CAAC,sBAAsB,CAAC;IAC3C,MAAM,GAAG,KAAK;AAEvB;;;;;;;AAOG;I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EAAA,CAAA,iBAAA,EAAA,qBAAA,CAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EAAE,eAAe,EAAA,QAAA,EAAA,SAAA,EAAA,MAAA,EAAA,CAAA,OAAA,EAAA,SAAA,CAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EAAE,qBAAqB,EAAA,QAAA,EAAA,gBAAA,EAAA,MAAA,EAAA,CAAA,OAAA,EAAA,UAAA,CAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EACtF,kBAAkB,6EAAE,gBAAgB,EAAA,IAAA,EAAA,GAAA,EAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA;;2FAI3B,oBAAoB,EAAA,UAAA,EAAA,CAAA;kBAVhC,SAAS;AACE,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,eAAe,cACb,IAAI,EAAA,eAAA,EACC,uBAAuB,CAAC,MAAM,EAAA,OAAA,EACtC;AACP,wBAAA,gBAAgB,EAAE,UAAU,EAAE,gBAAgB,EAAE,eAAe,EAAE,qBAAqB;AACtF,wBAAA,kBAAkB,EAAE,gBAAgB;AACrC,qBAAA,EAAA,QAAA,EAAA,yrDAAA,EAAA;;;AEvDH;;AAEG;;;;"}
|
|
@@ -64,10 +64,10 @@ class SparkTwoFactorComponent {
|
|
|
64
64
|
this.loading.set(false);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
68
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.
|
|
67
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: SparkTwoFactorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
68
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: SparkTwoFactorComponent, isStandalone: true, selector: "spark-two-factor", ngImport: i0, template: "<div class=\"d-flex justify-content-center\">\n <bs-card style=\"width: 100%; max-width: 400px;\">\n <bs-card-header>\n <h3 class=\"mb-0 text-center\">{{ 'auth.twoFactorTitle' | t }}</h3>\n </bs-card-header>\n <div class=\"p-4\">\n @if (errorMessage()) {\n <bs-alert [type]=\"colors.danger\" class=\"mb-3\">{{ errorMessage() }}</bs-alert>\n }\n\n <bs-form>\n <form [formGroup]=\"form\" (ngSubmit)=\"onSubmit()\">\n @if (!useRecoveryCode()) {\n <div class=\"mb-3\">\n <label for=\"code\" class=\"form-label\">{{ 'auth.code' | t }}</label>\n <input\n type=\"text\"\n id=\"code\"\n formControlName=\"code\"\n autocomplete=\"one-time-code\"\n maxlength=\"6\"\n [placeholder]=\"'auth.enterCode' | t\"\n />\n </div>\n } @else {\n <div class=\"mb-3\">\n <label for=\"recoveryCode\" class=\"form-label\">{{ 'auth.recoveryCode' | t }}</label>\n <input\n type=\"text\"\n id=\"recoveryCode\"\n formControlName=\"recoveryCode\"\n autocomplete=\"off\"\n [placeholder]=\"'auth.enterRecoveryCode' | t\"\n />\n </div>\n }\n\n <button\n type=\"submit\"\n class=\"btn btn-primary w-100\"\n [disabled]=\"loading()\"\n >\n @if (loading()) {\n <bs-spinner class=\"me-1\" />\n }\n {{ 'auth.verify' | t }}\n </button>\n </form>\n </bs-form>\n\n <div class=\"mt-3 text-center\">\n <button class=\"btn btn-link\" (click)=\"toggleRecoveryCode()\">\n @if (useRecoveryCode()) {\n {{ 'auth.useAuthCode' | t }}\n } @else {\n {{ 'auth.useRecoveryCode' | t }}\n }\n </button>\n </div>\n <div class=\"mt-2 text-center\">\n <a [routerLink]=\"routePaths.login\">{{ 'auth.backToLogin' | t }}</a>\n </div>\n </div>\n </bs-card>\n</div>\n", dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "browserUrl", "routerLink"] }, { kind: "component", type: BsAlertComponent, selector: "bs-alert", inputs: ["type", "announce", "isVisible"], outputs: ["isVisibleChange", "afterOpenedOrClosed"] }, { kind: "component", type: BsCardComponent, selector: "bs-card", inputs: ["color", "outline"] }, { kind: "component", type: BsCardHeaderComponent, selector: "bs-card-header", inputs: ["color", "navStyle"] }, { kind: "component", type: BsFormComponent, selector: "bs-form", inputs: ["action", "method"], outputs: ["submitted"] }, { kind: "directive", type: BsFormControlDirective, selector: "bs-form input:not(.no-form-control), bs-form textarea:not(.no-form-control)" }, { kind: "component", type: BsSpinnerComponent, selector: "bs-spinner", inputs: ["type", "color"] }, { kind: "pipe", type: TranslateKeyPipe, name: "t" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
69
69
|
}
|
|
70
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
70
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: SparkTwoFactorComponent, decorators: [{
|
|
71
71
|
type: Component,
|
|
72
72
|
args: [{ selector: 'spark-two-factor', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [ReactiveFormsModule, RouterLink, BsAlertComponent, BsCardComponent, BsCardHeaderComponent, BsFormComponent, BsFormControlDirective, BsSpinnerComponent, TranslateKeyPipe], template: "<div class=\"d-flex justify-content-center\">\n <bs-card style=\"width: 100%; max-width: 400px;\">\n <bs-card-header>\n <h3 class=\"mb-0 text-center\">{{ 'auth.twoFactorTitle' | t }}</h3>\n </bs-card-header>\n <div class=\"p-4\">\n @if (errorMessage()) {\n <bs-alert [type]=\"colors.danger\" class=\"mb-3\">{{ errorMessage() }}</bs-alert>\n }\n\n <bs-form>\n <form [formGroup]=\"form\" (ngSubmit)=\"onSubmit()\">\n @if (!useRecoveryCode()) {\n <div class=\"mb-3\">\n <label for=\"code\" class=\"form-label\">{{ 'auth.code' | t }}</label>\n <input\n type=\"text\"\n id=\"code\"\n formControlName=\"code\"\n autocomplete=\"one-time-code\"\n maxlength=\"6\"\n [placeholder]=\"'auth.enterCode' | t\"\n />\n </div>\n } @else {\n <div class=\"mb-3\">\n <label for=\"recoveryCode\" class=\"form-label\">{{ 'auth.recoveryCode' | t }}</label>\n <input\n type=\"text\"\n id=\"recoveryCode\"\n formControlName=\"recoveryCode\"\n autocomplete=\"off\"\n [placeholder]=\"'auth.enterRecoveryCode' | t\"\n />\n </div>\n }\n\n <button\n type=\"submit\"\n class=\"btn btn-primary w-100\"\n [disabled]=\"loading()\"\n >\n @if (loading()) {\n <bs-spinner class=\"me-1\" />\n }\n {{ 'auth.verify' | t }}\n </button>\n </form>\n </bs-form>\n\n <div class=\"mt-3 text-center\">\n <button class=\"btn btn-link\" (click)=\"toggleRecoveryCode()\">\n @if (useRecoveryCode()) {\n {{ 'auth.useAuthCode' | t }}\n } @else {\n {{ 'auth.useRecoveryCode' | t }}\n }\n </button>\n </div>\n <div class=\"mt-2 text-center\">\n <a [routerLink]=\"routePaths.login\">{{ 'auth.backToLogin' | t }}</a>\n </div>\n </div>\n </bs-card>\n</div>\n" }]
|
|
73
73
|
}] });
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { defaultSparkAuthConfig, SPARK_AUTH_CONFIG } from '@mintplayer/ng-spark-auth/models';
|
|
2
2
|
export { SPARK_AUTH_CONFIG, defaultSparkAuthConfig } from '@mintplayer/ng-spark-auth/models';
|
|
3
|
-
import { makeEnvironmentProviders } from '@angular/core';
|
|
3
|
+
import { makeEnvironmentProviders, inject } from '@angular/core';
|
|
4
4
|
import { withInterceptors, withXsrfConfiguration } from '@angular/common/http';
|
|
5
|
+
import { SPARK_AUTH_STATE } from '@mintplayer/ng-spark';
|
|
5
6
|
import { sparkAuthInterceptor } from '@mintplayer/ng-spark-auth/interceptors';
|
|
7
|
+
import { SparkAuthService } from '@mintplayer/ng-spark-auth/core';
|
|
6
8
|
|
|
7
9
|
function provideSparkAuth(config) {
|
|
8
10
|
return makeEnvironmentProviders([
|
|
@@ -10,6 +12,12 @@ function provideSparkAuth(config) {
|
|
|
10
12
|
provide: SPARK_AUTH_CONFIG,
|
|
11
13
|
useValue: { ...defaultSparkAuthConfig, ...config },
|
|
12
14
|
},
|
|
15
|
+
// Bridges sign-in/out into ng-spark (which must not depend on this package): auth-sensitive
|
|
16
|
+
// consumers there — the program-units menu — track this signal and re-fetch on change.
|
|
17
|
+
{
|
|
18
|
+
provide: SPARK_AUTH_STATE,
|
|
19
|
+
useFactory: () => inject(SparkAuthService).user,
|
|
20
|
+
},
|
|
13
21
|
]);
|
|
14
22
|
}
|
|
15
23
|
function withSparkAuth() {
|
|
@@ -26,9 +34,9 @@ function withSparkAuth() {
|
|
|
26
34
|
// @mintplayer/ng-spark-auth/guards (sparkAuthGuard)
|
|
27
35
|
// @mintplayer/ng-spark-auth/interceptors (sparkAuthInterceptor)
|
|
28
36
|
// @mintplayer/ng-spark-auth/pipes (TranslateKeyPipe)
|
|
29
|
-
// @mintplayer/ng-spark-auth/routes (sparkAuthRoutes)
|
|
37
|
+
// @mintplayer/ng-spark-auth/routes (sparkAuthRoutes + its with* features)
|
|
30
38
|
// @mintplayer/ng-spark-auth/auth-bar (SparkAuthBarComponent)
|
|
31
|
-
// @mintplayer/ng-spark-auth/{login,two-factor,register,forgot-password,reset-password}
|
|
39
|
+
// @mintplayer/ng-spark-auth/{login,two-factor,register,forgot-password,reset-password,sign-in}
|
|
32
40
|
|
|
33
41
|
/**
|
|
34
42
|
* Generated bundle index. Do not edit.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mintplayer-ng-spark-auth.mjs","sources":["../../src/lib/provide-spark-auth.ts","../../src/public-api.ts","../../src/mintplayer-ng-spark-auth.ts"],"sourcesContent":["import { EnvironmentProviders, makeEnvironmentProviders } from '@angular/core';\nimport { HttpFeature, HttpFeatureKind, withInterceptors, withXsrfConfiguration } from '@angular/common/http';\nimport {\n defaultSparkAuthConfig,\n SPARK_AUTH_CONFIG,\n SparkAuthConfig,\n} from '@mintplayer/ng-spark-auth/models';\nimport { sparkAuthInterceptor } from '@mintplayer/ng-spark-auth/interceptors';\n\nexport function provideSparkAuth(\n config?: Partial<SparkAuthConfig>,\n): EnvironmentProviders {\n return makeEnvironmentProviders([\n {\n provide: SPARK_AUTH_CONFIG,\n useValue: { ...defaultSparkAuthConfig, ...config },\n },\n ]);\n}\n\nexport function withSparkAuth(): HttpFeature<HttpFeatureKind>[] {\n return [\n withInterceptors([sparkAuthInterceptor]),\n withXsrfConfiguration({ cookieName: 'XSRF-TOKEN', headerName: 'X-XSRF-TOKEN' }),\n ];\n}\n","// Root entry point — bootstrap API only.\n// For other members import from sub-paths:\n// @mintplayer/ng-spark-auth/core (SparkAuthService, SparkAuthTranslationService)\n// @mintplayer/ng-spark-auth/models (types + SPARK_AUTH_ROUTE_PATHS)\n// @mintplayer/ng-spark-auth/guards (sparkAuthGuard)\n// @mintplayer/ng-spark-auth/interceptors (sparkAuthInterceptor)\n// @mintplayer/ng-spark-auth/pipes (TranslateKeyPipe)\n// @mintplayer/ng-spark-auth/routes (sparkAuthRoutes)\n// @mintplayer/ng-spark-auth/auth-bar (SparkAuthBarComponent)\n// @mintplayer/ng-spark-auth/{login,two-factor,register,forgot-password,reset-password}\n\nexport type { SparkAuthConfig } from '@mintplayer/ng-spark-auth/models';\nexport { SPARK_AUTH_CONFIG, defaultSparkAuthConfig } from '@mintplayer/ng-spark-auth/models';\nexport { provideSparkAuth, withSparkAuth } from './lib/provide-spark-auth';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mintplayer-ng-spark-auth.mjs","sources":["../../src/lib/provide-spark-auth.ts","../../src/public-api.ts","../../src/mintplayer-ng-spark-auth.ts"],"sourcesContent":["import { EnvironmentProviders, inject, makeEnvironmentProviders } from '@angular/core';\nimport { HttpFeature, HttpFeatureKind, withInterceptors, withXsrfConfiguration } from '@angular/common/http';\nimport { SPARK_AUTH_STATE } from '@mintplayer/ng-spark';\nimport {\n defaultSparkAuthConfig,\n SPARK_AUTH_CONFIG,\n SparkAuthConfig,\n} from '@mintplayer/ng-spark-auth/models';\nimport { sparkAuthInterceptor } from '@mintplayer/ng-spark-auth/interceptors';\nimport { SparkAuthService } from '@mintplayer/ng-spark-auth/core';\n\nexport function provideSparkAuth(\n config?: Partial<SparkAuthConfig>,\n): EnvironmentProviders {\n return makeEnvironmentProviders([\n {\n provide: SPARK_AUTH_CONFIG,\n useValue: { ...defaultSparkAuthConfig, ...config },\n },\n // Bridges sign-in/out into ng-spark (which must not depend on this package): auth-sensitive\n // consumers there — the program-units menu — track this signal and re-fetch on change.\n {\n provide: SPARK_AUTH_STATE,\n useFactory: () => inject(SparkAuthService).user,\n },\n ]);\n}\n\nexport function withSparkAuth(): HttpFeature<HttpFeatureKind>[] {\n return [\n withInterceptors([sparkAuthInterceptor]),\n withXsrfConfiguration({ cookieName: 'XSRF-TOKEN', headerName: 'X-XSRF-TOKEN' }),\n ];\n}\n","// Root entry point — bootstrap API only.\n// For other members import from sub-paths:\n// @mintplayer/ng-spark-auth/core (SparkAuthService, SparkAuthTranslationService)\n// @mintplayer/ng-spark-auth/models (types + SPARK_AUTH_ROUTE_PATHS)\n// @mintplayer/ng-spark-auth/guards (sparkAuthGuard)\n// @mintplayer/ng-spark-auth/interceptors (sparkAuthInterceptor)\n// @mintplayer/ng-spark-auth/pipes (TranslateKeyPipe)\n// @mintplayer/ng-spark-auth/routes (sparkAuthRoutes + its with* features)\n// @mintplayer/ng-spark-auth/auth-bar (SparkAuthBarComponent)\n// @mintplayer/ng-spark-auth/{login,two-factor,register,forgot-password,reset-password,sign-in}\n\nexport type { SparkAuthConfig } from '@mintplayer/ng-spark-auth/models';\nexport { SPARK_AUTH_CONFIG, defaultSparkAuthConfig } from '@mintplayer/ng-spark-auth/models';\nexport { provideSparkAuth, withSparkAuth } from './lib/provide-spark-auth';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;AAWM,SAAU,gBAAgB,CAC9B,MAAiC,EAAA;AAEjC,IAAA,OAAO,wBAAwB,CAAC;AAC9B,QAAA;AACE,YAAA,OAAO,EAAE,iBAAiB;AAC1B,YAAA,QAAQ,EAAE,EAAE,GAAG,sBAAsB,EAAE,GAAG,MAAM,EAAE;AACnD,SAAA;;;AAGD,QAAA;AACE,YAAA,OAAO,EAAE,gBAAgB;YACzB,UAAU,EAAE,MAAM,MAAM,CAAC,gBAAgB,CAAC,CAAC,IAAI;AAChD,SAAA;AACF,KAAA,CAAC;AACJ;SAEgB,aAAa,GAAA;IAC3B,OAAO;AACL,QAAA,gBAAgB,CAAC,CAAC,oBAAoB,CAAC,CAAC;QACxC,qBAAqB,CAAC,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC;KAChF;AACH;;ACjCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACTA;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mintplayer/ng-spark-auth",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "22.
|
|
4
|
+
"version": "22.6.0",
|
|
5
5
|
"description": "Angular authentication library for MintPlayer.Spark",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"@angular/router": "^22.0.0",
|
|
15
15
|
"@angular/forms": "^22.0.0",
|
|
16
16
|
"@mintplayer/ng-bootstrap": "^22.2.0",
|
|
17
|
+
"@mintplayer/ng-spark": "^22.6.0",
|
|
17
18
|
"rxjs": "~7.8.0"
|
|
18
19
|
},
|
|
19
20
|
"sideEffects": false,
|
|
@@ -7,7 +7,7 @@ declare class SparkForgotPasswordComponent {
|
|
|
7
7
|
private readonly fb;
|
|
8
8
|
private readonly authService;
|
|
9
9
|
private readonly translation;
|
|
10
|
-
readonly routePaths:
|
|
10
|
+
readonly routePaths: Partial<Record<keyof _mintplayer_ng_spark_auth_models.SparkAuthRouteEntries, string>>;
|
|
11
11
|
colors: typeof Color;
|
|
12
12
|
readonly loading: _angular_core.WritableSignal<boolean>;
|
|
13
13
|
readonly errorMessage: _angular_core.WritableSignal<string>;
|
|
@@ -10,7 +10,7 @@ declare class SparkLoginComponent {
|
|
|
10
10
|
private readonly route;
|
|
11
11
|
private readonly config;
|
|
12
12
|
private readonly translation;
|
|
13
|
-
readonly routePaths:
|
|
13
|
+
readonly routePaths: Partial<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>;
|