@sneat/auth-core 0.26.3 → 0.26.5
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/esm2022/index.js +1 -0
- package/esm2022/index.js.map +1 -1
- package/esm2022/lib/redirect-to-login.guard.js +48 -0
- package/esm2022/lib/redirect-to-login.guard.js.map +1 -0
- package/index.d.ts +1 -0
- package/lib/redirect-to-login.guard.d.ts +34 -0
- package/package.json +3 -3
- package/tsconfig.lib.prod.tsbuildinfo +1 -1
package/esm2022/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export * from './lib/login-required-service.service';
|
|
|
2
2
|
export * from './lib/private-token-store.service';
|
|
3
3
|
export * from './lib/sneat-auth.interface';
|
|
4
4
|
export * from './lib/sneat-auth-guard';
|
|
5
|
+
export * from './lib/redirect-to-login.guard';
|
|
5
6
|
export * from './lib/sneat-auth-state-service';
|
|
6
7
|
export * from './lib/telegram-auth.service';
|
|
7
8
|
export * from './lib/user';
|
package/esm2022/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/auth/core/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAC;AACrD,cAAc,mCAAmC,CAAC;AAClD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,YAAY,CAAC","sourcesContent":["export * from './lib/login-required-service.service';\nexport * from './lib/private-token-store.service';\nexport * from './lib/sneat-auth.interface';\nexport * from './lib/sneat-auth-guard';\nexport * from './lib/sneat-auth-state-service';\nexport * from './lib/telegram-auth.service';\nexport * from './lib/user';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/auth/core/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAC;AACrD,cAAc,mCAAmC,CAAC;AAClD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,YAAY,CAAC","sourcesContent":["export * from './lib/login-required-service.service';\nexport * from './lib/private-token-store.service';\nexport * from './lib/sneat-auth.interface';\nexport * from './lib/sneat-auth-guard';\nexport * from './lib/redirect-to-login.guard';\nexport * from './lib/sneat-auth-state-service';\nexport * from './lib/telegram-auth.service';\nexport * from './lib/user';\n"]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { inject } from '@angular/core';
|
|
2
|
+
import { Router } from '@angular/router';
|
|
3
|
+
import { filter, firstValueFrom } from 'rxjs';
|
|
4
|
+
import { AuthStatuses, SneatAuthStateService } from './sneat-auth-state-service';
|
|
5
|
+
/**
|
|
6
|
+
* Redirect target for an unauthenticated visitor: `/login`, or
|
|
7
|
+
* `/login#<path>` for a non-root path so the login page can send them back
|
|
8
|
+
* to it after signing in. Matches the URL shape the fleet's
|
|
9
|
+
* `@angular/fire/auth-guard`-based `redirectToLoginIfNotSignedIn` pipe (see
|
|
10
|
+
* `./sneat-auth-guard`) has always produced.
|
|
11
|
+
*/
|
|
12
|
+
export function loginRedirectPath(path) {
|
|
13
|
+
return path && path !== '/' ? `/login#${path}` : '/login';
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Functional route guard — the `@angular/fire`-free replacement for the
|
|
17
|
+
* fleet's one uniform pattern:
|
|
18
|
+
*
|
|
19
|
+
* import { AuthGuard } from '@angular/fire/auth-guard';
|
|
20
|
+
* import { redirectToLoginIfNotSignedIn } from '@sneat/auth-core';
|
|
21
|
+
* {
|
|
22
|
+
* canActivate: [AuthGuard],
|
|
23
|
+
* data: { authGuardPipe: () => redirectToLoginIfNotSignedIn },
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* becomes simply:
|
|
27
|
+
*
|
|
28
|
+
* import { sneatAuthGuard } from '@sneat/auth-core';
|
|
29
|
+
* { canActivate: [sneatAuthGuard] }
|
|
30
|
+
*
|
|
31
|
+
* Admits a signed-in visitor; redirects everyone else to `/login` (preserving
|
|
32
|
+
* the attempted path as a hash fragment). Driven entirely by Sneat's own
|
|
33
|
+
* `SneatAuthStateService` — no `@angular/fire` `Auth`/`AuthPipe` involved.
|
|
34
|
+
*
|
|
35
|
+
* Waits out the initial `'authenticating'` status (Firebase hasn't resolved
|
|
36
|
+
* the session yet) before deciding, exactly like the fleet's current
|
|
37
|
+
* `user(auth).pipe(take(1), redirectToLoginIfNotSignedIn)` composition does.
|
|
38
|
+
*/
|
|
39
|
+
export const sneatAuthGuard = async (_route, state) => {
|
|
40
|
+
const authState = inject(SneatAuthStateService);
|
|
41
|
+
const router = inject(Router);
|
|
42
|
+
const status = await firstValueFrom(authState.authStatus.pipe(filter((s) => s !== AuthStatuses.authenticating)));
|
|
43
|
+
if (status === AuthStatuses.authenticated) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
return router.parseUrl(loginRedirectPath(state.url));
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=redirect-to-login.guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redirect-to-login.guard.js","sourceRoot":"","sources":["../../../../../../libs/auth/core/src/lib/redirect-to-login.guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAiB,MAAM,EAAuB,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEjF;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,OAAO,IAAI,IAAI,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC5D,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,cAAc,GAAkB,KAAK,EAChD,MAAM,EACN,KAA0B,EAC1B,EAAE;IACF,MAAM,SAAS,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC;IAChD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IAC9B,MAAM,MAAM,GAAG,MAAM,cAAc,CACjC,SAAS,CAAC,UAAU,CAAC,IAAI,CACvB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,YAAY,CAAC,cAAc,CAAC,CACjD,CACF,CAAC;IACF,IAAI,MAAM,KAAK,YAAY,CAAC,aAAa,EAAE,CAAC;QAC1C,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AACvD,CAAC,CAAC","sourcesContent":["import { inject } from '@angular/core';\nimport { CanActivateFn, Router, RouterStateSnapshot } from '@angular/router';\nimport { filter, firstValueFrom } from 'rxjs';\nimport { AuthStatuses, SneatAuthStateService } from './sneat-auth-state-service';\n\n/**\n * Redirect target for an unauthenticated visitor: `/login`, or\n * `/login#<path>` for a non-root path so the login page can send them back\n * to it after signing in. Matches the URL shape the fleet's\n * `@angular/fire/auth-guard`-based `redirectToLoginIfNotSignedIn` pipe (see\n * `./sneat-auth-guard`) has always produced.\n */\nexport function loginRedirectPath(path: string): string {\n return path && path !== '/' ? `/login#${path}` : '/login';\n}\n\n/**\n * Functional route guard — the `@angular/fire`-free replacement for the\n * fleet's one uniform pattern:\n *\n * import { AuthGuard } from '@angular/fire/auth-guard';\n * import { redirectToLoginIfNotSignedIn } from '@sneat/auth-core';\n * {\n * canActivate: [AuthGuard],\n * data: { authGuardPipe: () => redirectToLoginIfNotSignedIn },\n * }\n *\n * becomes simply:\n *\n * import { sneatAuthGuard } from '@sneat/auth-core';\n * { canActivate: [sneatAuthGuard] }\n *\n * Admits a signed-in visitor; redirects everyone else to `/login` (preserving\n * the attempted path as a hash fragment). Driven entirely by Sneat's own\n * `SneatAuthStateService` — no `@angular/fire` `Auth`/`AuthPipe` involved.\n *\n * Waits out the initial `'authenticating'` status (Firebase hasn't resolved\n * the session yet) before deciding, exactly like the fleet's current\n * `user(auth).pipe(take(1), redirectToLoginIfNotSignedIn)` composition does.\n */\nexport const sneatAuthGuard: CanActivateFn = async (\n _route,\n state: RouterStateSnapshot,\n) => {\n const authState = inject(SneatAuthStateService);\n const router = inject(Router);\n const status = await firstValueFrom(\n authState.authStatus.pipe(\n filter((s) => s !== AuthStatuses.authenticating),\n ),\n );\n if (status === AuthStatuses.authenticated) {\n return true;\n }\n return router.parseUrl(loginRedirectPath(state.url));\n};\n"]}
|
package/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './lib/login-required-service.service';
|
|
|
2
2
|
export * from './lib/private-token-store.service';
|
|
3
3
|
export * from './lib/sneat-auth.interface';
|
|
4
4
|
export * from './lib/sneat-auth-guard';
|
|
5
|
+
export * from './lib/redirect-to-login.guard';
|
|
5
6
|
export * from './lib/sneat-auth-state-service';
|
|
6
7
|
export * from './lib/telegram-auth.service';
|
|
7
8
|
export * from './lib/user';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { CanActivateFn } from '@angular/router';
|
|
2
|
+
/**
|
|
3
|
+
* Redirect target for an unauthenticated visitor: `/login`, or
|
|
4
|
+
* `/login#<path>` for a non-root path so the login page can send them back
|
|
5
|
+
* to it after signing in. Matches the URL shape the fleet's
|
|
6
|
+
* `@angular/fire/auth-guard`-based `redirectToLoginIfNotSignedIn` pipe (see
|
|
7
|
+
* `./sneat-auth-guard`) has always produced.
|
|
8
|
+
*/
|
|
9
|
+
export declare function loginRedirectPath(path: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Functional route guard — the `@angular/fire`-free replacement for the
|
|
12
|
+
* fleet's one uniform pattern:
|
|
13
|
+
*
|
|
14
|
+
* import { AuthGuard } from '@angular/fire/auth-guard';
|
|
15
|
+
* import { redirectToLoginIfNotSignedIn } from '@sneat/auth-core';
|
|
16
|
+
* {
|
|
17
|
+
* canActivate: [AuthGuard],
|
|
18
|
+
* data: { authGuardPipe: () => redirectToLoginIfNotSignedIn },
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* becomes simply:
|
|
22
|
+
*
|
|
23
|
+
* import { sneatAuthGuard } from '@sneat/auth-core';
|
|
24
|
+
* { canActivate: [sneatAuthGuard] }
|
|
25
|
+
*
|
|
26
|
+
* Admits a signed-in visitor; redirects everyone else to `/login` (preserving
|
|
27
|
+
* the attempted path as a hash fragment). Driven entirely by Sneat's own
|
|
28
|
+
* `SneatAuthStateService` — no `@angular/fire` `Auth`/`AuthPipe` involved.
|
|
29
|
+
*
|
|
30
|
+
* Waits out the initial `'authenticating'` status (Firebase hasn't resolved
|
|
31
|
+
* the session yet) before deciding, exactly like the fleet's current
|
|
32
|
+
* `user(auth).pipe(take(1), redirectToLoginIfNotSignedIn)` composition does.
|
|
33
|
+
*/
|
|
34
|
+
export declare const sneatAuthGuard: CanActivateFn;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sneat/auth-core",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.5",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"@angular/core": ">=22.0.0 <23.0.0",
|
|
10
10
|
"@angular/router": ">=22.0.0 <23.0.0",
|
|
11
11
|
"@angular/fire": ">=20",
|
|
12
|
-
"@capacitor-firebase/authentication": ">=
|
|
13
|
-
"@capacitor/core": ">=
|
|
12
|
+
"@capacitor-firebase/authentication": ">=8.0.0 <9.0.0",
|
|
13
|
+
"@capacitor/core": ">=8.0.0 <9.0.0",
|
|
14
14
|
"@sneat/api": "^0.26.0",
|
|
15
15
|
"@sneat/auth-models": "^0.26.0",
|
|
16
16
|
"@sneat/core": "^0.26.0",
|