@atlasauth/svelte 0.2.0 → 0.2.1

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,5 +1,5 @@
1
1
  import { type Readable } from 'svelte/store';
2
- import { type FlowState, type ProviderToken } from '@atlasauth/js';
2
+ import { type FlowState, type ProviderToken, type SignOutOptions } from '@atlasauth/js';
3
3
  import { type AuthStatus } from './context';
4
4
  import { type ProtectCondition } from './protect';
5
5
  import type { AtlasOrganizationMembership, AtlasSession, AtlasUser } from './types';
@@ -48,7 +48,7 @@ export interface UseAuth {
48
48
  getToken(): Promise<string | null>;
49
49
  /** §6.6 the user's own live access token at a connected social provider. */
50
50
  getProviderToken(provider: string): Promise<ProviderToken | null>;
51
- signOut(): Promise<void>;
51
+ signOut(options?: SignOutOptions): Promise<void>;
52
52
  /** Mirrors `<Protect>`, for logic that is not a render decision. */
53
53
  has(condition: ProtectCondition): boolean;
54
54
  }
@@ -64,7 +64,7 @@ export declare function getOrganization(): Readable<UseOrganization>;
64
64
  /** Refresh-if-stale, then hand over the JWT. The `useAuth().getToken` shortcut. */
65
65
  export declare function getToken(): Promise<string | null>;
66
66
  /** Revoke the session and drop all in-memory state. */
67
- export declare function signOut(): Promise<void>;
67
+ export declare function signOut(options?: SignOutOptions): Promise<void>;
68
68
  /**
69
69
  * A running sign-in / sign-up attempt: a reactive `state` store plus `submit`.
70
70
  *
package/dist/accessors.js CHANGED
@@ -54,8 +54,8 @@ export function getToken() {
54
54
  return useAtlas().getToken();
55
55
  }
56
56
  /** Revoke the session and drop all in-memory state. */
57
- export function signOut() {
58
- return useAtlas().signOut();
57
+ export function signOut(options) {
58
+ return useAtlas().signOut(options);
59
59
  }
60
60
  function createFlow() {
61
61
  const atlas = useAtlas();
package/dist/context.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type Readable } from 'svelte/store';
2
- import { type ProviderToken } from '@atlasauth/js';
2
+ import { type ProviderToken, type SignOutOptions } from '@atlasauth/js';
3
3
  import { type Catalog } from './i18n';
4
4
  import { type Appearance, type InstanceDesign } from './appearance';
5
5
  import type { AtlasOrganizationMembership, AtlasSession, AtlasUser, SessionClaims } from './types';
@@ -71,7 +71,7 @@ export interface AtlasClient extends AtlasStores {
71
71
  * exposed; the server refreshes a stale token on read.
72
72
  */
73
73
  getProviderToken(provider: string): Promise<ProviderToken | null>;
74
- signOut(): Promise<void>;
74
+ signOut(options?: SignOutOptions): Promise<void>;
75
75
  setActiveOrganization(organizationId: string | null): Promise<void>;
76
76
  reload(): Promise<void>;
77
77
  /**
package/dist/context.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { getContext, setContext } from 'svelte';
2
2
  import { derived, get, writable } from 'svelte/store';
3
- import { FapiClient, TokenCache, getProviderToken as fetchProviderToken, msUntilRefresh, readExpiry, readRedirectResult, stripRedirectParams, } from '@atlasauth/js';
3
+ import { FapiClient, TokenCache, getProviderToken as fetchProviderToken, msUntilRefresh, readExpiry, readRedirectResult, stripRedirectParams, runFrontChannelLogoutFromResponse, } from '@atlasauth/js';
4
4
  import { EN_US, withFallback } from './i18n';
5
5
  import { instanceDesignFrom } from './appearance';
6
6
  /** The context key. A `Symbol` so it cannot collide with an app's own context. */
@@ -148,10 +148,16 @@ export function createAtlasClient(options) {
148
148
  function getProviderToken(provider) {
149
149
  return fetchProviderToken(fapiClient, provider);
150
150
  }
151
- async function signOut() {
151
+ async function signOut(options) {
152
152
  const current = cache.peek();
153
153
  if (current) {
154
- await call(`/v1/client/sessions/${current.sessionId}/revoke`, { method: 'POST' }).catch(() => undefined);
154
+ const revoked = await call(`/v1/client/sessions/${current.sessionId}/revoke`, {
155
+ method: 'POST',
156
+ }).catch(() => undefined);
157
+ // OIDC Front-Channel Logout: let the apps signed in through this session
158
+ // clear theirs in this browser (hidden iframes, capped at 5 s). Best-effort.
159
+ if (options?.frontchannel !== false)
160
+ await runFrontChannelLogoutFromResponse(revoked);
155
161
  }
156
162
  if (timer)
157
163
  clearTimeout(timer);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlasauth/svelte",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "svelte": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -21,10 +21,10 @@
21
21
  "./package.json": "./package.json"
22
22
  },
23
23
  "dependencies": {
24
- "@atlasauth/design": "0.1.0",
24
+ "@atlasauth/backend": "0.5.0",
25
25
  "@atlasauth/authz": "0.1.1",
26
- "@atlasauth/js": "0.4.0",
27
- "@atlasauth/backend": "0.3.0"
26
+ "@atlasauth/js": "0.5.0",
27
+ "@atlasauth/design": "0.1.0"
28
28
  },
29
29
  "peerDependencies": {
30
30
  "svelte": ">=4",