@atlasauth/angular 0.5.0 → 0.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.
@@ -1,3 +1,4 @@
1
+ import type { SignOutEvent } from '@atlasauth/js';
1
2
  import { InjectionToken } from '@angular/core';
2
3
  import type { Appearance } from './appearance';
3
4
  import type { Catalog } from './i18n';
@@ -27,6 +28,13 @@ export interface AtlasOptions {
27
28
  * or tests. Defaults to `globalThis.fetch`.
28
29
  */
29
30
  fetchImpl?: typeof fetch;
31
+ /**
32
+ * Called once each time a signed-in user becomes signed out, on every path:
33
+ * `reason` is `user`, `other_tab`, `session_expired`, `revoked` (ended
34
+ * elsewhere, seen on the next refresh) or `unknown`. See also
35
+ * `AtlasService.signOut$`.
36
+ */
37
+ onSignOut?: (event: SignOutEvent) => void;
30
38
  }
31
39
  /**
32
40
  * DI token carrying the resolved {@link AtlasOptions}. Populated by
@@ -1,6 +1,6 @@
1
1
  import { OnDestroy, Signal } from '@angular/core';
2
2
  import { Observable } from 'rxjs';
3
- import { FapiClient, type ErrorLike, type ProviderToken, type SignOutOptions, type SignOutResult } from '@atlasauth/js';
3
+ import { FapiClient, type ErrorLike, type ProviderToken, type SignOutOptions, type SignOutResult, type SignOutEvent, type SignOutListener } from '@atlasauth/js';
4
4
  import { type ProtectCondition } from '@atlasauth/authz';
5
5
  import { type Appearance, type AppearanceRender, type InstanceDesign } from './appearance';
6
6
  import { type Catalog } from './i18n';
@@ -62,6 +62,15 @@ export declare class AtlasService implements OnDestroy {
62
62
  private readonly _session;
63
63
  private readonly _claims;
64
64
  private readonly _memberships;
65
+ private readonly notifier;
66
+ private readonly _signOut;
67
+ /**
68
+ * Emits once each time a signed-in user becomes signed out: `reason` is
69
+ * `user`, `other_tab`, `session_expired`, `revoked` (ended elsewhere, seen on
70
+ * the next token refresh) or `unknown`. The place to reset an embedded
71
+ * third party (a chat widget). Also dispatched as `atlas:signout` on `window`.
72
+ */
73
+ readonly signOut$: Observable<SignOutEvent>;
65
74
  /** The three-state auth lifecycle: `loading` → `signed_in` | `signed_out`. */
66
75
  readonly status$: Observable<AuthStatus>;
67
76
  readonly user$: Observable<AtlasUser | null>;
@@ -121,7 +130,10 @@ export declare class AtlasService implements OnDestroy {
121
130
  * The current session's JWT, always fresh: if the cached token is within 5s of
122
131
  * expiry it is refreshed first rather than handed over. Null when signed out.
123
132
  */
124
- getToken(): Promise<string | null>;
133
+ /** The session JWT; with `{ template }` a short-lived named-template token (e.g. `'chatly'`). */
134
+ getToken(options?: {
135
+ template?: string;
136
+ }): Promise<string | null>;
125
137
  /**
126
138
  * The signed-in user's OWN live access token at a connected provider (Google,
127
139
  * GitHub, …), so the app can call that provider's API from the browser. Null
@@ -129,6 +141,8 @@ export declare class AtlasService implements OnDestroy {
129
141
  * kept none. The server refreshes a stale token on read; the refresh token is
130
142
  * never exposed.
131
143
  */
144
+ /** Listen for sign-out on every path (see {@link signOut$}); returns the unsubscribe. */
145
+ onSignOut(listener: SignOutListener): () => void;
132
146
  getProviderToken(provider: string): Promise<ProviderToken | null>;
133
147
  /** Imperative `has()` — the same evaluation `*atlasProtect` renders on. */
134
148
  has(condition: ProtectCondition): boolean;
@@ -62,6 +62,8 @@ export declare class AttemptFlowComponent {
62
62
  /** The first factors on offer at a `needs_first_factor` step (empty on any other). */
63
63
  private offered;
64
64
  protected showEmailCodeOption(): boolean;
65
+ /** The "we sent a code to …" line on the code step. */
66
+ protected codeSentText(): string | null;
65
67
  protected showSubmit(): boolean;
66
68
  protected fields(): StepField[];
67
69
  static ɵfac: i0.ɵɵFactoryDeclaration<AttemptFlowComponent, never>;
@@ -73,6 +73,13 @@ export declare class AtlasFlowController {
73
73
  /** Keep both captchas in step with the settings and the flow's current step. */
74
74
  private syncCaptcha;
75
75
  private setState;
76
+ private autoSentFor;
77
+ /**
78
+ * With no password on offer, email the code as soon as the server asks for a
79
+ * first factor — once per attempt, so a failed send waits for the user's retry
80
+ * (the "Email me a code" button) instead of looping.
81
+ */
82
+ private autoSend;
76
83
  /**
77
84
  * Advance the flow with the values the user typed. On completion, exchange the
78
85
  * one-time ticket for cookies over a same-origin request (FAPI is cross-origin
@@ -0,0 +1,4 @@
1
+ import type { AtlasSdkInfo } from '@atlasauth/js';
2
+ /** This package's version, sent as `X-Atlas-SDK` (kept in step with package.json by a test). */
3
+ export declare const ATLAS_ANGULAR_VERSION = "0.6.0";
4
+ export declare const ATLAS_ANGULAR_SDK: AtlasSdkInfo;
@@ -30,3 +30,6 @@ export * from './lib/types';
30
30
  export * from './lib/fapi';
31
31
  export type { InstanceSettings, PublicSignUpField, CaptchaController, CaptchaFlowKey, CaptchaWidgetMode, FlowCaptcha, EmailDelivery, SignOutOptions, SignOutResult, } from '@atlasauth/js';
32
32
  export { SignOutError } from '@atlasauth/js';
33
+ export { SIGN_OUT_EVENT, onAtlasSignOut } from '@atlasauth/js';
34
+ export type { SignOutEvent, SignOutReason } from '@atlasauth/js';
35
+ export { ATLAS_ANGULAR_SDK, ATLAS_ANGULAR_VERSION } from './lib/version';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlasauth/angular",
3
- "version": "0.5.0",
3
+ "version": "0.6.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.2.0",
23
- "@atlasauth/authz": "0.1.1",
24
- "@atlasauth/js": "0.9.0"
23
+ "@atlasauth/js": "0.12.0",
24
+ "@atlasauth/authz": "0.1.1"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "@angular/core": ">=17",