@atlasauth/angular 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +195 -0
- package/dist/LICENSE +21 -0
- package/dist/README.md +195 -0
- package/dist/esm2022/atlasauth-angular.mjs +5 -0
- package/dist/esm2022/lib/appearance.mjs +92 -0
- package/dist/esm2022/lib/atlas.config.mjs +8 -0
- package/dist/esm2022/lib/atlas.service.mjs +329 -0
- package/dist/esm2022/lib/atlas.ui.mjs +36 -0
- package/dist/esm2022/lib/components/attempt-flow.component.mjs +180 -0
- package/dist/esm2022/lib/components/flow-controller.mjs +88 -0
- package/dist/esm2022/lib/components/organization-profile.component.mjs +56 -0
- package/dist/esm2022/lib/components/organization-switcher.component.mjs +63 -0
- package/dist/esm2022/lib/components/sign-in.component.mjs +59 -0
- package/dist/esm2022/lib/components/sign-up.component.mjs +54 -0
- package/dist/esm2022/lib/components/user-button.component.mjs +94 -0
- package/dist/esm2022/lib/components/user-profile.component.mjs +81 -0
- package/dist/esm2022/lib/directives/atlas-root.directive.mjs +42 -0
- package/dist/esm2022/lib/directives/loaded.directive.mjs +23 -0
- package/dist/esm2022/lib/directives/loading.directive.mjs +23 -0
- package/dist/esm2022/lib/directives/protect.directive.mjs +82 -0
- package/dist/esm2022/lib/directives/signed-in.directive.mjs +29 -0
- package/dist/esm2022/lib/directives/signed-out.directive.mjs +29 -0
- package/dist/esm2022/lib/directives/toggle.directive.mjs +42 -0
- package/dist/esm2022/lib/fapi.mjs +9 -0
- package/dist/esm2022/lib/guards/atlas.guard.mjs +54 -0
- package/dist/esm2022/lib/i18n.mjs +78 -0
- package/dist/esm2022/lib/protect.mjs +9 -0
- package/dist/esm2022/lib/provide-atlas.mjs +85 -0
- package/dist/esm2022/lib/types.mjs +6 -0
- package/dist/esm2022/public-api.mjs +35 -0
- package/dist/fesm2022/atlasauth-angular.mjs +1557 -0
- package/dist/fesm2022/atlasauth-angular.mjs.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/lib/appearance.d.ts +85 -0
- package/dist/lib/atlas.config.d.ts +31 -0
- package/dist/lib/atlas.service.d.ts +127 -0
- package/dist/lib/atlas.ui.d.ts +22 -0
- package/dist/lib/components/attempt-flow.component.d.ts +48 -0
- package/dist/lib/components/flow-controller.d.ts +34 -0
- package/dist/lib/components/organization-profile.component.d.ts +16 -0
- package/dist/lib/components/organization-switcher.component.d.ts +15 -0
- package/dist/lib/components/sign-in.component.d.ts +21 -0
- package/dist/lib/components/sign-up.component.d.ts +21 -0
- package/dist/lib/components/user-button.component.d.ts +19 -0
- package/dist/lib/components/user-profile.component.d.ts +15 -0
- package/dist/lib/directives/atlas-root.directive.d.ts +26 -0
- package/dist/lib/directives/loaded.directive.d.ts +13 -0
- package/dist/lib/directives/loading.directive.d.ts +12 -0
- package/dist/lib/directives/protect.directive.d.ts +41 -0
- package/dist/lib/directives/signed-in.directive.d.ts +17 -0
- package/dist/lib/directives/signed-out.directive.d.ts +17 -0
- package/dist/lib/directives/toggle.directive.d.ts +25 -0
- package/dist/lib/fapi.d.ts +8 -0
- package/dist/lib/guards/atlas.guard.d.ts +43 -0
- package/dist/lib/i18n.d.ts +23 -0
- package/dist/lib/protect.d.ts +8 -0
- package/dist/lib/provide-atlas.d.ts +46 -0
- package/dist/lib/types.d.ts +48 -0
- package/dist/public-api.d.ts +28 -0
- package/package.json +58 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AtlasService } from '../atlas.service';
|
|
2
|
+
import { type ElementKey } from '../appearance';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* `<atlas-organization-switcher>` — switch the active organization (or the
|
|
6
|
+
* personal account). The Angular peer of React's `<OrganizationSwitcher/>`.
|
|
7
|
+
*/
|
|
8
|
+
export declare class OrganizationSwitcherComponent {
|
|
9
|
+
protected readonly atlas: AtlasService;
|
|
10
|
+
protected t(key: string): string;
|
|
11
|
+
protected cls(key: ElementKey, base: string): string;
|
|
12
|
+
protected setActive(organizationId: string | null): void;
|
|
13
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<OrganizationSwitcherComponent, never>;
|
|
14
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<OrganizationSwitcherComponent, "atlas-organization-switcher", never, {}, {}, never, never, true, never>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { OnDestroy, OnInit } from '@angular/core';
|
|
2
|
+
import { AtlasFlowController } from './flow-controller';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* `<atlas-sign-in>` — the full, multi-step sign-in flow driven entirely by the
|
|
6
|
+
* server-side attempt status. The Angular peer of React's `<SignIn/>`.
|
|
7
|
+
*
|
|
8
|
+
* ```html
|
|
9
|
+
* <atlas-sign-in *atlasSignedOut afterUrl="/dashboard"></atlas-sign-in>
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare class SignInComponent implements OnInit, OnDestroy {
|
|
13
|
+
private readonly atlas;
|
|
14
|
+
/** Where to send the user once the flow completes. Reserved for host routing. */
|
|
15
|
+
afterUrl?: string;
|
|
16
|
+
protected readonly flow: AtlasFlowController;
|
|
17
|
+
ngOnInit(): void;
|
|
18
|
+
ngOnDestroy(): void;
|
|
19
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SignInComponent, never>;
|
|
20
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<SignInComponent, "atlas-sign-in", never, { "afterUrl": { "alias": "afterUrl"; "required": false; }; }, {}, never, never, true, never>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { OnDestroy } from '@angular/core';
|
|
2
|
+
import { AtlasFlowController } from './flow-controller';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* `<atlas-sign-up>` — the full, server-driven sign-up flow. The Angular peer of
|
|
6
|
+
* React's `<SignUp/>`. It shares the exact flow engine with `<atlas-sign-in>`;
|
|
7
|
+
* only the title differs, because the sequence of steps is decided by the server.
|
|
8
|
+
*
|
|
9
|
+
* ```html
|
|
10
|
+
* <atlas-sign-up *atlasSignedOut></atlas-sign-up>
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare class SignUpComponent implements OnDestroy {
|
|
14
|
+
private readonly atlas;
|
|
15
|
+
/** Where to send the user once the flow completes. Reserved for host routing. */
|
|
16
|
+
afterUrl?: string;
|
|
17
|
+
protected readonly flow: AtlasFlowController;
|
|
18
|
+
ngOnDestroy(): void;
|
|
19
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SignUpComponent, never>;
|
|
20
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<SignUpComponent, "atlas-sign-up", never, { "afterUrl": { "alias": "afterUrl"; "required": false; }; }, {}, never, never, true, never>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AtlasService } from '../atlas.service';
|
|
2
|
+
import { type ElementKey } from '../appearance';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* `<atlas-user-button>` — the signed-in user's avatar with a drop-down that can
|
|
6
|
+
* sign them out. The Angular peer of React's `<UserButton/>`. Renders nothing
|
|
7
|
+
* when there is no user.
|
|
8
|
+
*/
|
|
9
|
+
export declare class UserButtonComponent {
|
|
10
|
+
protected readonly atlas: AtlasService;
|
|
11
|
+
protected readonly open: import("@angular/core").WritableSignal<boolean>;
|
|
12
|
+
protected readonly label: import("@angular/core").Signal<string>;
|
|
13
|
+
protected t(key: string): string;
|
|
14
|
+
protected cls(key: ElementKey, base: string): string;
|
|
15
|
+
protected toggle(): void;
|
|
16
|
+
protected signOut(): void;
|
|
17
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<UserButtonComponent, never>;
|
|
18
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<UserButtonComponent, "atlas-user-button", never, {}, {}, never, never, true, never>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AtlasService } from '../atlas.service';
|
|
2
|
+
import { type ElementKey } from '../appearance';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* `<atlas-user-profile>` — the signed-in user's account surface (emails,
|
|
6
|
+
* security). The Angular peer of React's `<UserProfile/>`. Renders nothing when
|
|
7
|
+
* there is no user.
|
|
8
|
+
*/
|
|
9
|
+
export declare class UserProfileComponent {
|
|
10
|
+
protected readonly atlas: AtlasService;
|
|
11
|
+
protected t(key: string): string;
|
|
12
|
+
protected cls(key: ElementKey, base: string): string;
|
|
13
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<UserProfileComponent, never>;
|
|
14
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<UserProfileComponent, "atlas-user-profile", never, {}, {}, never, never, true, never>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { OnInit } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
/**
|
|
4
|
+
* `atlasRoot` — apply the resolved appearance design tokens as `--atlas-*` CSS
|
|
5
|
+
* custom properties (and the `atlas-root` class) onto its host element, so the
|
|
6
|
+
* Atlas components rendered inside inherit them.
|
|
7
|
+
*
|
|
8
|
+
* React does this with the wrapping `<div className="atlas-root" style={…}>`
|
|
9
|
+
* inside `<AtlasProvider>`. Angular has no single wrapping element, so a
|
|
10
|
+
* consumer opts in by putting `atlasRoot` on whatever element encloses the
|
|
11
|
+
* Atlas UI (commonly the app root):
|
|
12
|
+
*
|
|
13
|
+
* ```html
|
|
14
|
+
* <div atlasRoot>
|
|
15
|
+
* <router-outlet></router-outlet>
|
|
16
|
+
* </div>
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare class AtlasRootDirective implements OnInit {
|
|
20
|
+
private readonly atlas;
|
|
21
|
+
private readonly el;
|
|
22
|
+
private readonly renderer;
|
|
23
|
+
ngOnInit(): void;
|
|
24
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AtlasRootDirective, never>;
|
|
25
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<AtlasRootDirective, "[atlasRoot]", never, {}, {}, never, never, true, never>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { AtlasToggleDirective } from './toggle.directive';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* `*atlasLoaded` — render the template only once the SDK has finished booting.
|
|
6
|
+
* The Angular peer of React's `<AtlasLoaded>`, the symmetric partner of
|
|
7
|
+
* `*atlasLoading`.
|
|
8
|
+
*/
|
|
9
|
+
export declare class AtlasLoadedDirective extends AtlasToggleDirective {
|
|
10
|
+
protected source(): Observable<boolean>;
|
|
11
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AtlasLoadedDirective, never>;
|
|
12
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<AtlasLoadedDirective, "[atlasLoaded]", never, {}, {}, never, never, true, never>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { AtlasToggleDirective } from './toggle.directive';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* `*atlasLoading` — render the template only while the SDK is still booting. The
|
|
6
|
+
* Angular peer of React's `<AtlasLoading>`; show a spinner here.
|
|
7
|
+
*/
|
|
8
|
+
export declare class AtlasLoadingDirective extends AtlasToggleDirective {
|
|
9
|
+
protected source(): Observable<boolean>;
|
|
10
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AtlasLoadingDirective, never>;
|
|
11
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<AtlasLoadingDirective, "[atlasLoading]", never, {}, {}, never, never, true, never>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { OnDestroy, OnInit, TemplateRef } from '@angular/core';
|
|
2
|
+
import { type ProtectCondition } from '@atlasauth/authz';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* `*atlasProtect` — render the template only when the active organization role
|
|
6
|
+
* satisfies a {@link ProtectCondition}. The Angular peer of React's
|
|
7
|
+
* `<Protect permission="…">`.
|
|
8
|
+
*
|
|
9
|
+
* A RENDERING helper, never an authorization boundary: anyone can flip the
|
|
10
|
+
* condition in devtools. The server checking the same permission is what
|
|
11
|
+
* actually stops them — this directive's only job is to avoid showing a control
|
|
12
|
+
* that would fail.
|
|
13
|
+
*
|
|
14
|
+
* ```html
|
|
15
|
+
* <button *atlasProtect="{ permission: 'org:sys_memberships:manage' }">Invite</button>
|
|
16
|
+
*
|
|
17
|
+
* <!-- with a fallback (identical microsyntax to *ngIf … else) -->
|
|
18
|
+
* <div *atlasProtect="{ role: 'admin' }; else denied">Admin tools</div>
|
|
19
|
+
* <ng-template #denied>You lack access.</ng-template>
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* An empty condition (`*atlasProtect`) means simply "signed in".
|
|
23
|
+
*/
|
|
24
|
+
export declare class AtlasProtectDirective implements OnInit, OnDestroy {
|
|
25
|
+
private readonly atlas;
|
|
26
|
+
private readonly templateRef;
|
|
27
|
+
private readonly viewContainer;
|
|
28
|
+
private readonly condition$;
|
|
29
|
+
private elseTemplate;
|
|
30
|
+
private sub?;
|
|
31
|
+
private rendered;
|
|
32
|
+
/** The condition to evaluate. An empty/omitted value means "signed in". */
|
|
33
|
+
set atlasProtect(condition: ProtectCondition | '' | null | undefined);
|
|
34
|
+
/** Template rendered when the condition is not met (the `else` branch). */
|
|
35
|
+
set atlasProtectElse(template: TemplateRef<unknown> | null);
|
|
36
|
+
ngOnInit(): void;
|
|
37
|
+
ngOnDestroy(): void;
|
|
38
|
+
private show;
|
|
39
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AtlasProtectDirective, never>;
|
|
40
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<AtlasProtectDirective, "[atlasProtect]", never, { "atlasProtect": { "alias": "atlasProtect"; "required": false; }; "atlasProtectElse": { "alias": "atlasProtectElse"; "required": false; }; }, {}, never, never, true, never>;
|
|
41
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { AtlasToggleDirective } from './toggle.directive';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* `*atlasSignedIn` — render the template only when the SDK has loaded AND the
|
|
6
|
+
* user is signed in. The Angular peer of React's `<SignedIn>`. Renders nothing
|
|
7
|
+
* while loading, so no signed-in UI flashes before boot completes.
|
|
8
|
+
*
|
|
9
|
+
* ```html
|
|
10
|
+
* <div *atlasSignedIn>Welcome back</div>
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare class AtlasSignedInDirective extends AtlasToggleDirective {
|
|
14
|
+
protected source(): Observable<boolean>;
|
|
15
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AtlasSignedInDirective, never>;
|
|
16
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<AtlasSignedInDirective, "[atlasSignedIn]", never, {}, {}, never, never, true, never>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { AtlasToggleDirective } from './toggle.directive';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* `*atlasSignedOut` — render the template only when the SDK has loaded AND the
|
|
6
|
+
* user is signed out. The Angular peer of React's `<SignedOut>`. Renders nothing
|
|
7
|
+
* while loading, the symmetric partner of `*atlasSignedIn`.
|
|
8
|
+
*
|
|
9
|
+
* ```html
|
|
10
|
+
* <atlas-sign-in *atlasSignedOut></atlas-sign-in>
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare class AtlasSignedOutDirective extends AtlasToggleDirective {
|
|
14
|
+
protected source(): Observable<boolean>;
|
|
15
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AtlasSignedOutDirective, never>;
|
|
16
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<AtlasSignedOutDirective, "[atlasSignedOut]", never, {}, {}, never, never, true, never>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { OnDestroy, OnInit } from '@angular/core';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { AtlasService } from '../atlas.service';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
/**
|
|
6
|
+
* Shared machinery for the boolean structural directives (`*atlasSignedIn`,
|
|
7
|
+
* `*atlasSignedOut`, `*atlasLoading`, `*atlasLoaded`). A subclass names the
|
|
8
|
+
* stream to gate on; this base mounts the embedded view exactly when that stream
|
|
9
|
+
* is true and tears it down otherwise, mirroring how the React `<SignedIn>` /
|
|
10
|
+
* `<SignedOut>` components render `children` or `null`.
|
|
11
|
+
*/
|
|
12
|
+
export declare abstract class AtlasToggleDirective implements OnInit, OnDestroy {
|
|
13
|
+
protected readonly atlas: AtlasService;
|
|
14
|
+
private readonly templateRef;
|
|
15
|
+
private readonly viewContainer;
|
|
16
|
+
private sub?;
|
|
17
|
+
private shown;
|
|
18
|
+
/** The stream whose truthiness controls whether the template renders. */
|
|
19
|
+
protected abstract source(): Observable<boolean>;
|
|
20
|
+
ngOnInit(): void;
|
|
21
|
+
ngOnDestroy(): void;
|
|
22
|
+
private render;
|
|
23
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AtlasToggleDirective, never>;
|
|
24
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<AtlasToggleDirective, never, never, {}, {}, never, never, false, never>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The FAPI client and the server-driven sign-in flow driver live in `@atlasauth/js`
|
|
3
|
+
* — the pure, framework-agnostic browser flow. This thin re-export lets the
|
|
4
|
+
* Angular components, guards and services resolve the driver from one place, so
|
|
5
|
+
* the Angular `<atlas-sign-in>` and the React `<SignIn/>` drive the exact same
|
|
6
|
+
* endpoints and cannot diverge in what the server sees.
|
|
7
|
+
*/
|
|
8
|
+
export { FapiClient, advance, prepareFactor, pollAttempt, shouldKeepPolling, requestForStep, flowFromPending, initialFlow, getProviderToken, type FapiClientOptions, type FapiResponse, type FlowState, type ProviderToken, } from '@atlasauth/js';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { CanActivateChildFn, CanActivateFn } from '@angular/router';
|
|
2
|
+
import { type ProtectCondition } from '@atlasauth/authz';
|
|
3
|
+
export interface AtlasGuardOptions extends ProtectCondition {
|
|
4
|
+
/**
|
|
5
|
+
* Where to send a user who fails the check. When set, the guard returns a
|
|
6
|
+
* `UrlTree` (a redirect); when omitted it simply returns `false` and the
|
|
7
|
+
* navigation is cancelled. A common value is your sign-in route.
|
|
8
|
+
*/
|
|
9
|
+
redirectTo?: string;
|
|
10
|
+
/**
|
|
11
|
+
* When true, append the attempted URL as a `redirect_url` query param on the
|
|
12
|
+
* `redirectTo` target, so the sign-in page can send the user back afterwards.
|
|
13
|
+
* Ignored unless `redirectTo` is set. Defaults to true.
|
|
14
|
+
*/
|
|
15
|
+
preserveReturnUrl?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Route guard factory that gates a route on session — and optionally on a
|
|
19
|
+
* permission/role. The Angular peer of using `<SignedIn>` / `<Protect>` to fence
|
|
20
|
+
* a page, expressed as a `CanActivateFn`.
|
|
21
|
+
*
|
|
22
|
+
* ```ts
|
|
23
|
+
* export const routes: Routes = [
|
|
24
|
+
* { path: 'dashboard', canActivate: [atlasGuard({ redirectTo: '/sign-in' })], ... },
|
|
25
|
+
* {
|
|
26
|
+
* path: 'admin',
|
|
27
|
+
* canActivate: [atlasGuard({ permission: 'org:admin', redirectTo: '/' })],
|
|
28
|
+
* ...
|
|
29
|
+
* },
|
|
30
|
+
* ];
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* The guard first waits for the SDK to finish booting, so a hard refresh onto a
|
|
34
|
+
* protected URL does not bounce to sign-in before the session has been read.
|
|
35
|
+
* Like the components, this is UX, not security: the server enforces the same
|
|
36
|
+
* checks on every request.
|
|
37
|
+
*/
|
|
38
|
+
export declare function atlasGuard(options?: AtlasGuardOptions): CanActivateFn;
|
|
39
|
+
/**
|
|
40
|
+
* The `CanActivateChild` form of {@link atlasGuard}, for gating a whole child
|
|
41
|
+
* route subtree with one declaration.
|
|
42
|
+
*/
|
|
43
|
+
export declare function atlasChildGuard(options?: AtlasGuardOptions): CanActivateChildFn;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* §10.3: "Every string passes through an i18n catalog; en-US ships, catalog
|
|
3
|
+
* format documented for community locales."
|
|
4
|
+
*
|
|
5
|
+
* A flat key-to-string map rather than nested objects, because nesting looks
|
|
6
|
+
* tidier and makes a missing key a runtime crash on `undefined.of.a.chain`
|
|
7
|
+
* rather than a visible fallback.
|
|
8
|
+
*
|
|
9
|
+
* A missing key renders the KEY, not an empty string. A blank button is a bug
|
|
10
|
+
* nobody can report; a button reading `signIn.submit` is one anyone can.
|
|
11
|
+
*/
|
|
12
|
+
export type Catalog = Record<string, string>;
|
|
13
|
+
export declare const EN_US: Catalog;
|
|
14
|
+
/**
|
|
15
|
+
* Look up a key and interpolate `{placeholders}`.
|
|
16
|
+
*
|
|
17
|
+
* An unknown placeholder is left visible for the same reason a missing key is:
|
|
18
|
+
* `Continue with {provider}` in the UI is a bug report waiting to be filed,
|
|
19
|
+
* whereas `Continue with ` is one nobody notices until a customer does.
|
|
20
|
+
*/
|
|
21
|
+
export declare function translate(catalog: Catalog, key: string, variables?: Record<string, string>): string;
|
|
22
|
+
/** Merge a community locale over en-US so a partial translation still renders. */
|
|
23
|
+
export declare function withFallback(locale: Catalog): Catalog;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conditional-rendering authorization primitive — re-exported unchanged from
|
|
3
|
+
* `@atlasauth/authz`, the ONE evaluator every Atlas SDK shares. `*atlasProtect` in
|
|
4
|
+
* this package and `<Protect>` in `@atlasauth/react` therefore judge a condition
|
|
5
|
+
* identically, and the server checking the same permission is what actually
|
|
6
|
+
* stops a request; these helpers only decide what a user is shown.
|
|
7
|
+
*/
|
|
8
|
+
export { type ProtectCondition, type ProtectOutcome, type ProtectReason, evaluate, hasFromClaims, } from '@atlasauth/authz';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { EnvironmentProviders, ModuleWithProviders } from '@angular/core';
|
|
2
|
+
import { type AtlasOptions } from './atlas.config';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
import * as i1 from "./directives/signed-in.directive";
|
|
5
|
+
import * as i2 from "./directives/signed-out.directive";
|
|
6
|
+
import * as i3 from "./directives/loading.directive";
|
|
7
|
+
import * as i4 from "./directives/loaded.directive";
|
|
8
|
+
import * as i5 from "./directives/protect.directive";
|
|
9
|
+
import * as i6 from "./directives/atlas-root.directive";
|
|
10
|
+
import * as i7 from "./components/sign-in.component";
|
|
11
|
+
import * as i8 from "./components/sign-up.component";
|
|
12
|
+
import * as i9 from "./components/user-button.component";
|
|
13
|
+
import * as i10 from "./components/organization-switcher.component";
|
|
14
|
+
import * as i11 from "./components/user-profile.component";
|
|
15
|
+
import * as i12 from "./components/organization-profile.component";
|
|
16
|
+
/**
|
|
17
|
+
* Standalone-provider entry point (Angular 17+). Register Atlas once at the
|
|
18
|
+
* application root — the direct analogue of wrapping the tree in React's
|
|
19
|
+
* `<AtlasProvider publishableKey>`:
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* bootstrapApplication(AppComponent, {
|
|
23
|
+
* providers: [
|
|
24
|
+
* provideAtlas({ publishableKey: 'pk_test_…' }),
|
|
25
|
+
* provideRouter(routes),
|
|
26
|
+
* ],
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* The returned providers make {@link AtlasService} injectable and eagerly
|
|
31
|
+
* construct it, so the SDK begins its first boot (redirect-completion + session
|
|
32
|
+
* read) as soon as the app starts — matching the React provider mounting on the
|
|
33
|
+
* first render.
|
|
34
|
+
*/
|
|
35
|
+
export declare function provideAtlas(options: AtlasOptions): EnvironmentProviders;
|
|
36
|
+
/**
|
|
37
|
+
* NgModule entry point for apps not yet on the standalone bootstrap. Import
|
|
38
|
+
* `AtlasModule.forRoot({ publishableKey })` once in the root module; feature
|
|
39
|
+
* modules import `AtlasModule` (no args) to use the directives/components.
|
|
40
|
+
*/
|
|
41
|
+
export declare class AtlasModule {
|
|
42
|
+
static forRoot(options: AtlasOptions): ModuleWithProviders<AtlasModule>;
|
|
43
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AtlasModule, never>;
|
|
44
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<AtlasModule, never, [typeof i1.AtlasSignedInDirective, typeof i2.AtlasSignedOutDirective, typeof i3.AtlasLoadingDirective, typeof i4.AtlasLoadedDirective, typeof i5.AtlasProtectDirective, typeof i6.AtlasRootDirective, typeof i7.SignInComponent, typeof i8.SignUpComponent, typeof i9.UserButtonComponent, typeof i10.OrganizationSwitcherComponent, typeof i11.UserProfileComponent, typeof i12.OrganizationProfileComponent], [typeof i1.AtlasSignedInDirective, typeof i2.AtlasSignedOutDirective, typeof i3.AtlasLoadingDirective, typeof i4.AtlasLoadedDirective, typeof i5.AtlasProtectDirective, typeof i6.AtlasRootDirective, typeof i7.SignInComponent, typeof i8.SignUpComponent, typeof i9.UserButtonComponent, typeof i10.OrganizationSwitcherComponent, typeof i11.UserProfileComponent, typeof i12.OrganizationProfileComponent]>;
|
|
45
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<AtlasModule>;
|
|
46
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public data shapes, mirrored 1:1 from `@atlasauth/react`'s `types.ts` so an app
|
|
3
|
+
* can move between the React and Angular SDKs without re-typing its models.
|
|
4
|
+
*/
|
|
5
|
+
export interface SessionClaims {
|
|
6
|
+
sub: string;
|
|
7
|
+
sid: string;
|
|
8
|
+
exp: number;
|
|
9
|
+
org_id?: string;
|
|
10
|
+
org_slug?: string;
|
|
11
|
+
org_role?: string;
|
|
12
|
+
org_permissions?: string[];
|
|
13
|
+
mfa?: boolean;
|
|
14
|
+
[claim: string]: unknown;
|
|
15
|
+
}
|
|
16
|
+
export interface AtlasUser {
|
|
17
|
+
id: string;
|
|
18
|
+
first_name: string | null;
|
|
19
|
+
last_name: string | null;
|
|
20
|
+
username: string | null;
|
|
21
|
+
image_url: string | null;
|
|
22
|
+
public_metadata: Record<string, unknown>;
|
|
23
|
+
unsafe_metadata: Record<string, unknown>;
|
|
24
|
+
mfa_enabled: boolean;
|
|
25
|
+
has_password: boolean;
|
|
26
|
+
email_addresses?: Array<{
|
|
27
|
+
id: string;
|
|
28
|
+
email_address: string;
|
|
29
|
+
verified: boolean;
|
|
30
|
+
primary: boolean;
|
|
31
|
+
}>;
|
|
32
|
+
}
|
|
33
|
+
export interface AtlasOrganizationMembership {
|
|
34
|
+
role: string;
|
|
35
|
+
organization: {
|
|
36
|
+
id: string;
|
|
37
|
+
name: string;
|
|
38
|
+
slug: string;
|
|
39
|
+
image_url: string | null;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export interface AtlasSession {
|
|
43
|
+
id: string;
|
|
44
|
+
status: string;
|
|
45
|
+
last_active_organization_id: string | null;
|
|
46
|
+
}
|
|
47
|
+
/** The three-state auth lifecycle, identical to the React provider's. */
|
|
48
|
+
export type AuthStatus = 'loading' | 'signed_in' | 'signed_out';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@atlasauth/angular` — the official Angular SDK for Atlas, the Angular peer of
|
|
3
|
+
* `@atlasauth/react`. Public surface.
|
|
4
|
+
*/
|
|
5
|
+
export { ATLAS_OPTIONS, type AtlasOptions } from './lib/atlas.config';
|
|
6
|
+
export { provideAtlas, AtlasModule } from './lib/provide-atlas';
|
|
7
|
+
export { AtlasService } from './lib/atlas.service';
|
|
8
|
+
export { AtlasSignedInDirective } from './lib/directives/signed-in.directive';
|
|
9
|
+
export { AtlasSignedOutDirective } from './lib/directives/signed-out.directive';
|
|
10
|
+
export { AtlasLoadingDirective } from './lib/directives/loading.directive';
|
|
11
|
+
export { AtlasLoadedDirective } from './lib/directives/loaded.directive';
|
|
12
|
+
export { AtlasProtectDirective } from './lib/directives/protect.directive';
|
|
13
|
+
export { AtlasRootDirective } from './lib/directives/atlas-root.directive';
|
|
14
|
+
export { SignInComponent } from './lib/components/sign-in.component';
|
|
15
|
+
export { SignUpComponent } from './lib/components/sign-up.component';
|
|
16
|
+
export { UserButtonComponent } from './lib/components/user-button.component';
|
|
17
|
+
export { OrganizationSwitcherComponent } from './lib/components/organization-switcher.component';
|
|
18
|
+
export { UserProfileComponent } from './lib/components/user-profile.component';
|
|
19
|
+
export { OrganizationProfileComponent } from './lib/components/organization-profile.component';
|
|
20
|
+
export { AttemptFlowComponent } from './lib/components/attempt-flow.component';
|
|
21
|
+
export { AtlasFlowController } from './lib/components/flow-controller';
|
|
22
|
+
export { ATLAS_UI } from './lib/atlas.ui';
|
|
23
|
+
export { atlasGuard, atlasChildGuard, type AtlasGuardOptions, } from './lib/guards/atlas.guard';
|
|
24
|
+
export * from './lib/appearance';
|
|
25
|
+
export * from './lib/i18n';
|
|
26
|
+
export * from './lib/protect';
|
|
27
|
+
export * from './lib/types';
|
|
28
|
+
export * from './lib/fapi';
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlasauth/angular",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Official Angular SDK for Atlas — the Angular peer of @atlasauth/react.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"module": "./dist/fesm2022/atlas-angular.mjs",
|
|
7
|
+
"typings": "./dist/index.d.ts",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
"./package.json": {
|
|
11
|
+
"default": "./package.json"
|
|
12
|
+
},
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"esm2022": "./dist/esm2022/atlas-angular.mjs",
|
|
16
|
+
"default": "./dist/fesm2022/atlas-angular.mjs"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"sideEffects": false,
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"tslib": "^2.6.3",
|
|
22
|
+
"@atlasauth/js": "0.1.0",
|
|
23
|
+
"@atlasauth/authz": "0.1.0"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"@angular/core": ">=17",
|
|
27
|
+
"@angular/common": ">=17",
|
|
28
|
+
"@angular/router": ">=17",
|
|
29
|
+
"rxjs": ">=7"
|
|
30
|
+
},
|
|
31
|
+
"peerDependenciesMeta": {
|
|
32
|
+
"@angular/router": {
|
|
33
|
+
"optional": true
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@angular/common": "^17.3.0",
|
|
38
|
+
"@angular/compiler": "^17.3.0",
|
|
39
|
+
"@angular/compiler-cli": "^17.3.0",
|
|
40
|
+
"@angular/core": "^17.3.0",
|
|
41
|
+
"@angular/router": "^17.3.0",
|
|
42
|
+
"ng-packagr": "^17.3.0",
|
|
43
|
+
"rxjs": "^7.8.1",
|
|
44
|
+
"typescript": "~5.4.5",
|
|
45
|
+
"zone.js": "^0.14.4"
|
|
46
|
+
},
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"access": "public"
|
|
49
|
+
},
|
|
50
|
+
"files": [
|
|
51
|
+
"dist",
|
|
52
|
+
"README.md"
|
|
53
|
+
],
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "ng-packagr -p ng-package.json",
|
|
56
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
57
|
+
}
|
|
58
|
+
}
|