@atlasauth/angular 0.2.1 → 0.3.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.
@@ -9,8 +9,13 @@ export interface AtlasOptions {
9
9
  /** The instance's publishable key (`pk_…`). Required. */
10
10
  publishableKey: string;
11
11
  /**
12
- * The instance's FAPI origin. Empty string (the default) means same-origin —
13
- * requests go to `/v1/...` on the app's own host.
12
+ * The instance's Frontend API: an absolute URL such as
13
+ * `"https://auth.example.com"`, or `"same-origin"` / a path such as `"/atlas"`
14
+ * behind a reverse proxy on the app's own origin (requests then go to
15
+ * `/v1/...` on the app's host). Required at runtime — `AtlasService` throws an
16
+ * `AtlasConfigError` (`FRONTEND_API_REQUIRED` / `FRONTEND_API_INVALID`) when
17
+ * it is missing or malformed. Optional in the type only so existing call sites
18
+ * keep compiling.
14
19
  */
15
20
  frontendApi?: string;
16
21
  /** Design tokens + per-element class overrides. See {@link Appearance}. */
@@ -1,5 +1,5 @@
1
1
  import { EventEmitter } from '@angular/core';
2
- import { type AttemptView, type FieldError } from '@atlasauth/js';
2
+ import { type AttemptView, type CaptchaController, type FieldError } from '@atlasauth/js';
3
3
  import { type ElementKey } from '../appearance';
4
4
  import * as i0 from "@angular/core";
5
5
  /**
@@ -30,6 +30,12 @@ export declare class AttemptFlowComponent {
30
30
  busy: boolean;
31
31
  errors: FieldError[];
32
32
  titleKey: string;
33
+ /**
34
+ * The sign-in captcha, drawn above the submit button on the identifier step
35
+ * (an always-on sign-in captcha) and on the challenge step the server demands
36
+ * with `needs_captcha`. Null when the flow draws none.
37
+ */
38
+ captcha: CaptchaController | null;
33
39
  /** Emits the collected field values when the form is submitted. */
34
40
  submitFlow: EventEmitter<Record<string, string>>;
35
41
  protected values: Record<string, string>;
@@ -40,9 +46,10 @@ export declare class AttemptFlowComponent {
40
46
  protected formErrors(): FieldError[];
41
47
  protected fieldErrorsFor(name: string): FieldError[];
42
48
  private step;
49
+ protected showCaptcha(): boolean;
43
50
  protected showSubmit(): boolean;
44
51
  protected fields(): StepField[];
45
52
  static ɵfac: i0.ɵɵFactoryDeclaration<AttemptFlowComponent, never>;
46
- static ɵcmp: i0.ɵɵComponentDeclaration<AttemptFlowComponent, "atlas-attempt-flow", never, { "attempt": { "alias": "attempt"; "required": false; }; "busy": { "alias": "busy"; "required": false; }; "errors": { "alias": "errors"; "required": false; }; "titleKey": { "alias": "titleKey"; "required": false; }; }, { "submitFlow": "submitFlow"; }, never, never, true, never>;
53
+ static ɵcmp: i0.ɵɵComponentDeclaration<AttemptFlowComponent, "atlas-attempt-flow", never, { "attempt": { "alias": "attempt"; "required": false; }; "busy": { "alias": "busy"; "required": false; }; "errors": { "alias": "errors"; "required": false; }; "titleKey": { "alias": "titleKey"; "required": false; }; "captcha": { "alias": "captcha"; "required": false; }; }, { "submitFlow": "submitFlow"; }, never, never, true, never>;
47
54
  }
48
55
  export {};
@@ -1,5 +1,5 @@
1
1
  import { WritableSignal } from '@angular/core';
2
- import { FapiClient, type FlowState } from '@atlasauth/js';
2
+ import { FapiClient, type CaptchaController, type FlowState, type InstanceSettings } from '@atlasauth/js';
3
3
  /**
4
4
  * The server-driven sign-in / sign-up engine, shared by `<atlas-sign-in>` and
5
5
  * `<atlas-sign-up>` — the Angular counterpart of React's `useFlow` hook.
@@ -8,16 +8,45 @@ import { FapiClient, type FlowState } from '@atlasauth/js';
8
8
  * server via `advance`, and this controller only posts whatever the current step
9
9
  * needs and re-renders the returned status. State lives in a signal so templates
10
10
  * update whether the app runs zoned or zoneless.
11
+ *
12
+ * `<atlas-sign-up>` starts the attempt with {@link create}
13
+ * (`POST /v1/client/sign_ups`); the emailed-code step then runs through the same
14
+ * {@link submit}. Both flows draw the instance's captcha (from
15
+ * {@link loadSettings}) when it is required.
11
16
  */
12
17
  export declare class AtlasFlowController {
13
18
  private readonly client;
14
19
  private readonly reload;
20
+ /** Resolves the captcha messages' catalog keys. Defaults to en-US. */
21
+ private readonly t;
15
22
  readonly state: WritableSignal<FlowState>;
23
+ /**
24
+ * The instance's public sign-in / sign-up settings (captcha, sign-up fields,
25
+ * legal consent) from `GET /v1/appearance`; null until {@link loadSettings}
26
+ * resolves, or when the server could not be reached.
27
+ */
28
+ readonly settings: WritableSignal<InstanceSettings>;
29
+ /** The sign-in captcha (identifier step / `needs_captcha` challenge). */
30
+ readonly captcha: CaptchaController;
31
+ /** The sign-up captcha (the create-account step). */
32
+ readonly signUpCaptcha: CaptchaController;
33
+ /** Whether {@link captcha} currently draws a widget (for templates). */
34
+ readonly captchaDrawn: WritableSignal<boolean>;
35
+ /** Whether {@link signUpCaptcha} currently draws a widget (for templates). */
36
+ readonly signUpCaptchaDrawn: WritableSignal<boolean>;
16
37
  private pollTimer;
38
+ private identifier;
17
39
  constructor(client: FapiClient, reload: () => Promise<void>, pending: {
18
40
  id: string;
19
41
  status: string;
20
- } | null);
42
+ } | null,
43
+ /** Resolves the captcha messages' catalog keys. Defaults to en-US. */
44
+ t?: (key: string) => string);
45
+ /** Fetch the instance's public settings and draw whatever captcha they require. */
46
+ loadSettings(): Promise<void>;
47
+ /** Keep both captchas in step with the settings and the flow's current step. */
48
+ private syncCaptcha;
49
+ private setState;
21
50
  /**
22
51
  * Advance the flow with the values the user typed. On completion, exchange the
23
52
  * one-time ticket for cookies over a same-origin request (FAPI is cross-origin
@@ -25,10 +54,18 @@ export declare class AtlasFlowController {
25
54
  * the app sees a signed-in user.
26
55
  */
27
56
  submit(values: Record<string, string>): Promise<void>;
57
+ /**
58
+ * Create an account (`POST /v1/client/sign_ups`) from a create-account form's
59
+ * values — email, password and any configured sign-up fields — carrying the
60
+ * sign-up captcha's token when the instance requires one. The emailed code is
61
+ * then posted with {@link submit}.
62
+ */
63
+ create(values: Record<string, string>, consent?: boolean): Promise<void>;
64
+ private finish;
28
65
  /** Start/stop the §5.3 magic-link poll to match the current state. */
29
66
  syncPolling(): void;
30
67
  private startPolling;
31
68
  private stopPolling;
32
- /** Release the poll timer — call from the component's `ngOnDestroy`. */
69
+ /** Release the poll timer and the captcha widgets — call from the component's `ngOnDestroy`. */
33
70
  destroy(): void;
34
71
  }
@@ -3,7 +3,9 @@ import { AtlasFlowController } from './flow-controller';
3
3
  import * as i0 from "@angular/core";
4
4
  /**
5
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/>`.
6
+ * server-side attempt status. The Angular peer of React's `<SignIn/>`. Draws the
7
+ * instance's sign-in captcha when it is required (always-on, or a
8
+ * `needs_captcha` challenge).
7
9
  *
8
10
  * ```html
9
11
  * <atlas-sign-in *atlasSignedOut afterUrl="/dashboard"></atlas-sign-in>
@@ -0,0 +1,43 @@
1
+ import { EventEmitter } from '@angular/core';
2
+ import type { CaptchaController, FieldError, InstanceSettings, PublicSignUpField } from '@atlasauth/js';
3
+ import { type ElementKey } from '../appearance';
4
+ import * as i0 from "@angular/core";
5
+ /** What the create-account form emits: the values typed plus the consent tick. */
6
+ export interface SignUpFormSubmit {
7
+ values: Record<string, string>;
8
+ consent: boolean;
9
+ }
10
+ /**
11
+ * The create-account step of `<atlas-sign-up>`: the instance's configured extra
12
+ * fields, email + password, the legal-consent row and — when the instance
13
+ * requires one on sign-up — the captcha widget. Values live on the component so
14
+ * a refused submit never clears them.
15
+ */
16
+ export declare class SignUpFormComponent {
17
+ private readonly atlas;
18
+ settings: InstanceSettings | null;
19
+ busy: boolean;
20
+ errors: FieldError[];
21
+ captcha: CaptchaController | null;
22
+ /** Emits the typed values and the consent tick when the form is submitted. */
23
+ submitSignUp: EventEmitter<SignUpFormSubmit>;
24
+ protected values: Record<string, string>;
25
+ protected agreed: boolean;
26
+ protected t(key: string, vars?: Record<string, string>): string;
27
+ protected cls(key: ElementKey, base: string): string;
28
+ protected setValue(name: string, value: string): void;
29
+ protected fields(): PublicSignUpField[];
30
+ protected label(f: PublicSignUpField): string;
31
+ protected inputType(f: PublicSignUpField): string;
32
+ /** Same encoding as React, the embed widget and the hosted page: one value,
33
+ * or a comma-joined list for multiselect. */
34
+ protected picked(key: string): string[];
35
+ protected toggle(f: PublicSignUpField, option: string, on: boolean): void;
36
+ protected showLegal(): boolean;
37
+ protected consentOk(): boolean;
38
+ protected formErrors(): FieldError[];
39
+ protected fieldErrorsFor(name: string): FieldError[];
40
+ protected onSubmit(event: Event): void;
41
+ static ɵfac: i0.ɵɵFactoryDeclaration<SignUpFormComponent, never>;
42
+ static ɵcmp: i0.ɵɵComponentDeclaration<SignUpFormComponent, "atlas-sign-up-form", never, { "settings": { "alias": "settings"; "required": false; }; "busy": { "alias": "busy"; "required": false; }; "errors": { "alias": "errors"; "required": false; }; "captcha": { "alias": "captcha"; "required": false; }; }, { "submitSignUp": "submitSignUp"; }, never, never, true, never>;
43
+ }
@@ -1,20 +1,24 @@
1
- import { OnDestroy } from '@angular/core';
1
+ import { OnDestroy, OnInit } from '@angular/core';
2
2
  import { AtlasFlowController } from './flow-controller';
3
3
  import * as i0 from "@angular/core";
4
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.
5
+ * `<atlas-sign-up>` — creates an account. The Angular peer of React's
6
+ * `<SignUp/>`. The first step is the create-account form (the instance's
7
+ * configured fields, email, password, legal consent and — when required — the
8
+ * captcha), which POSTs `/v1/client/sign_ups`; from there it shares the flow
9
+ * engine with `<atlas-sign-in>` (the emailed-code step, then the ticket
10
+ * exchange), because the sequence of steps is decided by the server.
8
11
  *
9
12
  * ```html
10
13
  * <atlas-sign-up *atlasSignedOut></atlas-sign-up>
11
14
  * ```
12
15
  */
13
- export declare class SignUpComponent implements OnDestroy {
16
+ export declare class SignUpComponent implements OnInit, OnDestroy {
14
17
  private readonly atlas;
15
18
  /** Where to send the user once the flow completes. Reserved for host routing. */
16
19
  afterUrl?: string;
17
20
  protected readonly flow: AtlasFlowController;
21
+ ngOnInit(): void;
18
22
  ngOnDestroy(): void;
19
23
  static ɵfac: i0.ɵɵFactoryDeclaration<SignUpComponent, never>;
20
24
  static ɵcmp: i0.ɵɵComponentDeclaration<SignUpComponent, "atlas-sign-up", never, { "afterUrl": { "alias": "afterUrl"; "required": false; }; }, {}, never, never, true, never>;
@@ -0,0 +1,19 @@
1
+ import { OnDestroy, OnInit } from '@angular/core';
2
+ import type { CaptchaController } from '@atlasauth/js';
3
+ import * as i0 from "@angular/core";
4
+ /**
5
+ * `[atlasCaptchaSlot]="controller"` — the element a flow's captcha widget draws
6
+ * into (see `createCaptchaController` in `@atlasauth/js`). Attaches the
7
+ * controller to the host element while it is rendered and detaches it (removing
8
+ * the widget) when it goes away.
9
+ */
10
+ export declare class AtlasCaptchaSlotDirective implements OnInit, OnDestroy {
11
+ private readonly host;
12
+ private current;
13
+ private initialized;
14
+ set controller(next: CaptchaController | null);
15
+ ngOnInit(): void;
16
+ ngOnDestroy(): void;
17
+ static ɵfac: i0.ɵɵFactoryDeclaration<AtlasCaptchaSlotDirective, never>;
18
+ static ɵdir: i0.ɵɵDirectiveDeclaration<AtlasCaptchaSlotDirective, "[atlasCaptchaSlot]", never, { "controller": { "alias": "atlasCaptchaSlot"; "required": false; }; }, {}, never, never, true, never>;
19
+ }
@@ -18,6 +18,8 @@ export { OrganizationSwitcherComponent } from './lib/components/organization-swi
18
18
  export { UserProfileComponent } from './lib/components/user-profile.component';
19
19
  export { OrganizationProfileComponent } from './lib/components/organization-profile.component';
20
20
  export { AttemptFlowComponent } from './lib/components/attempt-flow.component';
21
+ export { SignUpFormComponent, type SignUpFormSubmit, } from './lib/components/sign-up-form.component';
22
+ export { AtlasCaptchaSlotDirective } from './lib/directives/captcha-slot.directive';
21
23
  export { AtlasFlowController } from './lib/components/flow-controller';
22
24
  export { ATLAS_UI } from './lib/atlas.ui';
23
25
  export { atlasGuard, atlasChildGuard, type AtlasGuardOptions, } from './lib/guards/atlas.guard';
@@ -26,3 +28,4 @@ export * from './lib/i18n';
26
28
  export * from './lib/protect';
27
29
  export * from './lib/types';
28
30
  export * from './lib/fapi';
31
+ export type { InstanceSettings, PublicSignUpField, CaptchaController, CaptchaFlowKey, CaptchaWidgetMode, FlowCaptcha, } from '@atlasauth/js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlasauth/angular",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "Official Angular SDK for Atlas — the Angular peer of @atlasauth/react.",
5
5
  "license": "MIT",
6
6
  "module": "./dist/fesm2022/atlas-angular.mjs",
@@ -20,8 +20,8 @@
20
20
  "dependencies": {
21
21
  "tslib": "^2.6.3",
22
22
  "@atlasauth/design": "0.1.0",
23
- "@atlasauth/js": "0.5.0",
24
- "@atlasauth/authz": "0.1.1"
23
+ "@atlasauth/authz": "0.1.1",
24
+ "@atlasauth/js": "0.6.0"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "@angular/core": ">=17",
@@ -50,7 +50,8 @@
50
50
  },
51
51
  "files": [
52
52
  "dist",
53
- "README.md"
53
+ "README.md",
54
+ "CHANGELOG.md"
54
55
  ],
55
56
  "repository": {
56
57
  "type": "git",