@atlasauth/vue 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.
@@ -0,0 +1,327 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OrganizationProfile = exports.UserProfile = exports.OrganizationSwitcher = exports.UserButton = exports.SignUp = exports.SignIn = exports.Protect = exports.AtlasLoaded = exports.AtlasLoading = exports.SignedOut = exports.SignedIn = void 0;
4
+ const vue_1 = require("vue");
5
+ const js_1 = require("@atlasauth/js");
6
+ const context_1 = require("./context");
7
+ const composables_1 = require("./composables");
8
+ const flow_1 = require("./flow");
9
+ const appearance_1 = require("./appearance");
10
+ const i18n_1 = require("./i18n");
11
+ const protect_1 = require("./protect");
12
+ /**
13
+ * §10.2 components — the Vue peer of React's `components.tsx`.
14
+ *
15
+ * `<SignIn/>` and `<SignUp/>` are full multi-step flows driven entirely by the
16
+ * server-side attempt status. That phrase is the design: this file contains no
17
+ * decision about what comes next. It renders whatever `status` the server
18
+ * returned, via the exhaustive mapping in `@atlasauth/js` — so adding a step to the
19
+ * flow is a server change, and a client that has not shipped yet degrades to a
20
+ * visible "needs an update" rather than a blank screen.
21
+ *
22
+ * Components are authored as render functions (not `.vue` SFCs) so the package
23
+ * builds with plain `tsc`, exactly like `@atlasauth/react` — no SFC compiler in the
24
+ * toolchain, and components render in the host DOM so Tailwind/CSS just works.
25
+ */
26
+ /** Resolve an element's class with the customer's appearance override appended. */
27
+ function useClass() {
28
+ const { appearance } = (0, context_1.useAtlas)();
29
+ return (key, base) => (0, appearance_1.classFor)(key, appearance, base);
30
+ }
31
+ /** Look up a catalog string and interpolate `{placeholders}`. */
32
+ function useText() {
33
+ const { catalog } = (0, context_1.useAtlas)();
34
+ return (key, vars) => (0, i18n_1.translate)(catalog, key, vars);
35
+ }
36
+ exports.SignedIn = (0, vue_1.defineComponent)({
37
+ name: 'SignedIn',
38
+ setup(_props, { slots }) {
39
+ const { isLoaded, isSignedIn } = (0, composables_1.useUser)();
40
+ // Renders nothing while loading rather than flashing the signed-out branch.
41
+ return () => (isLoaded.value && isSignedIn.value ? slots.default?.() : null);
42
+ },
43
+ });
44
+ exports.SignedOut = (0, vue_1.defineComponent)({
45
+ name: 'SignedOut',
46
+ setup(_props, { slots }) {
47
+ const { isLoaded, isSignedIn } = (0, composables_1.useUser)();
48
+ return () => (isLoaded.value && !isSignedIn.value ? slots.default?.() : null);
49
+ },
50
+ });
51
+ /** §10.2: render children only while the SDK is still loading. */
52
+ exports.AtlasLoading = (0, vue_1.defineComponent)({
53
+ name: 'AtlasLoading',
54
+ setup(_props, { slots }) {
55
+ const { isLoaded } = (0, composables_1.useUser)();
56
+ return () => (isLoaded.value ? null : slots.default?.());
57
+ },
58
+ });
59
+ /**
60
+ * §10.2: render children only once the SDK has finished loading — the symmetric
61
+ * partner of {@link AtlasLoading}, so a consumer can show a spinner and its
62
+ * resolved content without hand-rolling the inverse condition.
63
+ */
64
+ exports.AtlasLoaded = (0, vue_1.defineComponent)({
65
+ name: 'AtlasLoaded',
66
+ setup(_props, { slots }) {
67
+ const { isLoaded } = (0, composables_1.useUser)();
68
+ return () => (isLoaded.value ? slots.default?.() : null);
69
+ },
70
+ });
71
+ /**
72
+ * §10.2 `<Protect permission="…">`.
73
+ *
74
+ * A rendering helper, never an authorization boundary — anyone can flip the
75
+ * condition in devtools. The server checking the same permission is what
76
+ * actually stops them, and this component's job is only to avoid showing a
77
+ * button that would fail. Renders the `#fallback` slot when the condition is not
78
+ * met, mirroring React's `fallback` prop.
79
+ */
80
+ exports.Protect = (0, vue_1.defineComponent)({
81
+ name: 'Protect',
82
+ props: {
83
+ permission: { type: String, default: undefined },
84
+ role: { type: String, default: undefined },
85
+ anyPermission: { type: Array, default: undefined },
86
+ allPermissions: { type: Array, default: undefined },
87
+ },
88
+ setup(props, { slots }) {
89
+ const { claims, status } = (0, context_1.useAtlas)();
90
+ return () => {
91
+ if (status.value === 'loading')
92
+ return null;
93
+ const allowed = (0, protect_1.evaluate)(claims.value, {
94
+ permission: props.permission,
95
+ role: props.role,
96
+ anyPermission: props.anyPermission,
97
+ allPermissions: props.allPermissions,
98
+ }).allowed;
99
+ return allowed ? slots.default?.() : (slots.fallback?.() ?? null);
100
+ };
101
+ },
102
+ });
103
+ /**
104
+ * The server-driven flow shell.
105
+ *
106
+ * Every branch comes from `nextStep`, which is exhaustive — including the
107
+ * `unknown` case, which renders an honest message instead of nothing.
108
+ */
109
+ const AttemptFlow = (0, vue_1.defineComponent)({
110
+ name: 'AttemptFlow',
111
+ props: {
112
+ attempt: { type: Object, default: null },
113
+ busy: { type: Boolean, default: false },
114
+ errors: { type: Array, default: () => [] },
115
+ titleKey: { type: String, required: true },
116
+ onSubmit: { type: Function, required: true },
117
+ },
118
+ setup(props) {
119
+ const t = useText();
120
+ const cls = useClass();
121
+ const values = (0, vue_1.reactive)({});
122
+ const field = (name, labelKey, type = 'text') => (0, vue_1.h)('label', { class: 'atlas-field', key: name }, [
123
+ (0, vue_1.h)('span', t(labelKey)),
124
+ (0, vue_1.h)('input', {
125
+ class: cls('formFieldInput', 'atlas-input'),
126
+ type,
127
+ value: values[name] ?? '',
128
+ onInput: (event) => {
129
+ values[name] = event.target.value;
130
+ },
131
+ }),
132
+ ...props.errors
133
+ .filter((error) => error.param === name)
134
+ .map((error) => (0, vue_1.h)('span', { class: cls('formFieldError', 'atlas-error'), key: error.code }, error.message)),
135
+ ]);
136
+ const fields = (kind) => {
137
+ switch (kind) {
138
+ case 'collect_identifier':
139
+ return [field('identifier', 'signIn.identifierLabel', 'email')];
140
+ case 'collect_first_factor':
141
+ return [field('password', 'signIn.passwordLabel', 'password')];
142
+ case 'collect_second_factor':
143
+ return [field('code', 'mfa.codeLabel')];
144
+ case 'enroll_second_factor':
145
+ // Two codes, not one. §5.6 wants consecutive codes so a phone with a
146
+ // fast clock fails here rather than on every sign-in afterwards.
147
+ return [
148
+ field('code', 'mfa.enrollFirstCodeLabel'),
149
+ field('secondCode', 'mfa.enrollSecondCodeLabel'),
150
+ ];
151
+ case 'collect_email_code':
152
+ return [field('code', 'signIn.emailCodeLabel')];
153
+ case 'collect_new_password':
154
+ return [field('password', 'reset.newPasswordLabel', 'password')];
155
+ case 'await_oauth':
156
+ return [(0, vue_1.h)('p', { key: 'oauth' }, t('signIn.magicLinkSent'))];
157
+ case 'done':
158
+ return [(0, vue_1.h)('p', { key: 'done' }, t('signIn.checkOtherTab'))];
159
+ case 'restart':
160
+ return [(0, vue_1.h)('p', { key: 'restart' }, t('error.generic'))];
161
+ default:
162
+ // A status this SDK version does not know. Saying so beats rendering
163
+ // nothing, which is a blank login box the user cannot act on.
164
+ return [
165
+ (0, vue_1.h)('p', { key: 'unknown', class: cls('formFieldError', 'atlas-error') }, t('error.generic')),
166
+ ];
167
+ }
168
+ };
169
+ return () => {
170
+ const step = props.attempt
171
+ ? (0, js_1.nextStep)(props.attempt)
172
+ : { kind: 'collect_identifier' };
173
+ return (0, vue_1.h)('div', { class: cls('card', 'atlas-card') }, [
174
+ (0, vue_1.h)('h1', { class: cls('headerTitle', 'atlas-title') }, t(props.titleKey)),
175
+ ...props.errors
176
+ .filter((error) => !error.param)
177
+ .map((error) => (0, vue_1.h)('p', { class: cls('formFieldError', 'atlas-error'), role: 'alert', key: error.code }, error.message)),
178
+ (0, vue_1.h)('form', {
179
+ onSubmit: (event) => {
180
+ event.preventDefault();
181
+ props.onSubmit({ ...values });
182
+ },
183
+ }, [
184
+ ...fields(step.kind),
185
+ step.kind !== 'done' && step.kind !== 'await_oauth'
186
+ ? (0, vue_1.h)('button', {
187
+ class: cls('formButtonPrimary', 'atlas-button'),
188
+ disabled: props.busy,
189
+ type: 'submit',
190
+ }, t('signIn.submit'))
191
+ : null,
192
+ ]),
193
+ ]);
194
+ };
195
+ },
196
+ });
197
+ exports.SignIn = (0, vue_1.defineComponent)({
198
+ name: 'SignIn',
199
+ props: {
200
+ /** Where to send the user once the flow completes. */
201
+ afterUrl: { type: String, default: undefined },
202
+ },
203
+ setup() {
204
+ const { state, submit } = (0, flow_1.useFlow)();
205
+ return () => (0, vue_1.h)(AttemptFlow, {
206
+ attempt: state.value.attempt,
207
+ busy: state.value.busy,
208
+ errors: state.value.errors,
209
+ titleKey: 'signIn.title',
210
+ onSubmit: submit,
211
+ });
212
+ },
213
+ });
214
+ exports.SignUp = (0, vue_1.defineComponent)({
215
+ name: 'SignUp',
216
+ props: {
217
+ afterUrl: { type: String, default: undefined },
218
+ },
219
+ setup() {
220
+ const { state, submit } = (0, flow_1.useFlow)();
221
+ return () => (0, vue_1.h)(AttemptFlow, {
222
+ attempt: state.value.attempt,
223
+ busy: state.value.busy,
224
+ errors: state.value.errors,
225
+ titleKey: 'signUp.title',
226
+ onSubmit: submit,
227
+ });
228
+ },
229
+ });
230
+ exports.UserButton = (0, vue_1.defineComponent)({
231
+ name: 'UserButton',
232
+ setup() {
233
+ const { user } = (0, composables_1.useUser)();
234
+ const { signOut } = (0, composables_1.useAuth)();
235
+ const t = useText();
236
+ const cls = useClass();
237
+ const open = (0, vue_1.ref)(false);
238
+ return () => {
239
+ const u = user.value;
240
+ if (!u)
241
+ return null;
242
+ const label = [u.first_name, u.last_name].filter(Boolean).join(' ') || u.username || '';
243
+ return (0, vue_1.h)('div', { class: 'atlas-user-button' }, [
244
+ (0, vue_1.h)('button', {
245
+ class: cls('avatar', 'atlas-avatar'),
246
+ 'aria-expanded': open.value,
247
+ onClick: () => {
248
+ open.value = !open.value;
249
+ },
250
+ }, u.image_url
251
+ ? (0, vue_1.h)('img', { alt: '', src: u.image_url })
252
+ : (0, vue_1.h)('span', label.slice(0, 1))),
253
+ open.value
254
+ ? (0, vue_1.h)('div', { class: cls('menu', 'atlas-menu'), role: 'menu' }, [
255
+ (0, vue_1.h)('span', { class: cls('menuItem', 'atlas-menu-item') }, label),
256
+ (0, vue_1.h)('button', { class: cls('menuItem', 'atlas-menu-item'), onClick: () => void signOut() }, t('userButton.signOut')),
257
+ ])
258
+ : null,
259
+ ]);
260
+ };
261
+ },
262
+ });
263
+ exports.OrganizationSwitcher = (0, vue_1.defineComponent)({
264
+ name: 'OrganizationSwitcher',
265
+ setup() {
266
+ const { memberships, organization, setActive } = (0, composables_1.useOrganization)();
267
+ const t = useText();
268
+ const cls = useClass();
269
+ return () => (0, vue_1.h)('div', { class: cls('menu', 'atlas-menu') }, [
270
+ (0, vue_1.h)('button', { class: cls('menuItem', 'atlas-menu-item'), onClick: () => void setActive(null) }, t('organization.personal')),
271
+ ...memberships.value.map((membership) => (0, vue_1.h)('button', {
272
+ key: membership.organization.id,
273
+ class: cls('menuItem', 'atlas-menu-item'),
274
+ disabled: membership.organization.id === organization.value?.id,
275
+ onClick: () => void setActive(membership.organization.id),
276
+ }, membership.organization.name)),
277
+ ]);
278
+ },
279
+ });
280
+ exports.UserProfile = (0, vue_1.defineComponent)({
281
+ name: 'UserProfile',
282
+ setup() {
283
+ const { user } = (0, composables_1.useUser)();
284
+ const t = useText();
285
+ const cls = useClass();
286
+ return () => {
287
+ const u = user.value;
288
+ if (!u)
289
+ return null;
290
+ return (0, vue_1.h)('div', { class: cls('card', 'atlas-card') }, [
291
+ (0, vue_1.h)('h1', t('userProfile.title')),
292
+ (0, vue_1.h)('section', [
293
+ (0, vue_1.h)('h2', t('userProfile.emailsSection')),
294
+ (0, vue_1.h)('ul', (u.email_addresses ?? []).map((email) => (0, vue_1.h)('li', { key: email.id }, [
295
+ email.email_address,
296
+ email.verified ? null : (0, vue_1.h)('em', ` — ${t('userProfile.unverified')}`),
297
+ ]))),
298
+ ]),
299
+ (0, vue_1.h)('section', [
300
+ (0, vue_1.h)('h2', t('userProfile.securitySection')),
301
+ (0, vue_1.h)('p', u.mfa_enabled ? '2FA on' : '2FA off'),
302
+ ]),
303
+ ]);
304
+ };
305
+ },
306
+ });
307
+ exports.OrganizationProfile = (0, vue_1.defineComponent)({
308
+ name: 'OrganizationProfile',
309
+ setup() {
310
+ const { organization, membership } = (0, composables_1.useOrganization)();
311
+ const t = useText();
312
+ const cls = useClass();
313
+ return () => {
314
+ const org = organization.value;
315
+ if (!org)
316
+ return null;
317
+ return (0, vue_1.h)('div', { class: cls('card', 'atlas-card') }, [
318
+ (0, vue_1.h)('h1', org.name),
319
+ (0, vue_1.h)('p', `${t('organization.roleLabel')}: ${membership.value?.role ?? ''}`),
320
+ // Management controls are gated on the ACTIVE org role, matching the
321
+ // server's §9.2 rule rather than duplicating a looser one.
322
+ (0, vue_1.h)(exports.Protect, { permission: 'org:sys_memberships:manage' }, () => (0, vue_1.h)('button', t('organization.invite'))),
323
+ ]);
324
+ };
325
+ },
326
+ });
327
+ //# sourceMappingURL=components.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.js","sourceRoot":"","sources":["../src/components.ts"],"names":[],"mappings":";;;AAAA,6BAAmF;AACnF,sCAA4E;AAC5E,uCAAqC;AACrC,+CAAkE;AAClE,iCAAiC;AACjC,6CAAyD;AACzD,iCAAmC;AACnC,uCAAqC;AAErC;;;;;;;;;;;;;GAaG;AAEH,mFAAmF;AACnF,SAAS,QAAQ;IACf,MAAM,EAAE,UAAU,EAAE,GAAG,IAAA,kBAAQ,GAAE,CAAC;IAClC,OAAO,CAAC,GAAe,EAAE,IAAY,EAAE,EAAE,CAAC,IAAA,qBAAQ,EAAC,GAAG,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;AAC5E,CAAC;AAED,iEAAiE;AACjE,SAAS,OAAO;IACd,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,kBAAQ,GAAE,CAAC;IAC/B,OAAO,CAAC,GAAW,EAAE,IAA6B,EAAE,EAAE,CAAC,IAAA,gBAAS,EAAC,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;AACvF,CAAC;AAEY,QAAA,QAAQ,GAAG,IAAA,qBAAe,EAAC;IACtC,IAAI,EAAE,UAAU;IAChB,KAAK,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE;QACrB,MAAM,EAAE,QAAQ,EAAE,U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A,6BAAe,GAAE,CAAC;QACvD,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;QACpB,MAAM,GAAG,GAAG,QAAQ,EAAE,CAAC;QAEvB,OAAO,GAAG,EAAE;YACV,MAAM,GAAG,GAAG,YAAY,CAAC,KAAK,CAAC;YAC/B,IAAI,CAAC,GAAG;gBAAE,OAAO,IAAI,CAAC;YAEtB,OAAO,IAAA,OAAC,EAAC,KAAK,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,EAAE,EAAE;gBACpD,IAAA,OAAC,EAAC,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC;gBACjB,IAAA,OAAC,EAAC,GAAG,EAAE,GAAG,CAAC,CAAC,wBAAwB,CAAC,KAAK,UAAU,CAAC,KAAK,EAAE,IAAI,IAAI,EAAE,EAAE,CAAC;gBACzE,qEAAqE;gBACrE,2DAA2D;gBAC3D,IAAA,OAAC,EAAC,eAAO,EAAE,EAAE,UAAU,EAAE,4BAA4B,EAAE,EAAE,GAAG,EAAE,CAC5D,IAAA,OAAC,EAAC,QAAQ,EAAE,CAAC,CAAC,qBAAqB,CAAC,CAAC,CACtC;aACF,CAAC,CAAC;QACL,CAAC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,49 @@
1
+ import { type ComputedRef, type ShallowRef } from 'vue';
2
+ import type { ProviderToken } from '@atlasauth/js';
3
+ import { type ProtectCondition } from './protect';
4
+ import type { AtlasOrganizationMembership, AtlasSession, AtlasUser } from './types';
5
+ /**
6
+ * §10.1 composables — the Vue peer of React's hooks.
7
+ *
8
+ * Every one returns `isLoaded` alongside its data, and that is not ceremony.
9
+ * Without it a component cannot tell "still booting" from "signed out", so it
10
+ * renders a sign-in form for a fraction of a second on every page load — the
11
+ * flash of unauthenticated content that makes an app feel broken. The React SDK
12
+ * returns plain values recomputed each render; the Vue SDK returns `computed`
13
+ * refs off the reactive client, which stay live without a re-render.
14
+ */
15
+ export declare function useUser(): {
16
+ isLoaded: ComputedRef<boolean>;
17
+ isSignedIn: ComputedRef<boolean>;
18
+ user: ShallowRef<AtlasUser | null>;
19
+ /**
20
+ * §6.6 the signed-in user's own live token at a connected provider — the
21
+ * `user.getToken({ provider })` equivalent. Always the caller's own token
22
+ * (the server keys off the session), refreshed on read if stale, and never
23
+ * the refresh token.
24
+ */
25
+ getProviderToken(provider: string): Promise<ProviderToken | null>;
26
+ };
27
+ export declare function useSession(): {
28
+ isLoaded: ComputedRef<boolean>;
29
+ session: ShallowRef<AtlasSession | null>;
30
+ };
31
+ export declare function useAuth(): {
32
+ isLoaded: ComputedRef<boolean>;
33
+ isSignedIn: ComputedRef<boolean>;
34
+ userId: ComputedRef<string | null>;
35
+ sessionId: ComputedRef<string | null>;
36
+ orgId: ComputedRef<string | null>;
37
+ orgRole: ComputedRef<string | null>;
38
+ getToken(): Promise<string | null>;
39
+ getProviderToken(provider: string): Promise<ProviderToken | null>;
40
+ signOut(): Promise<void>;
41
+ has(condition: ProtectCondition): boolean;
42
+ };
43
+ export declare function useOrganization(): {
44
+ isLoaded: ComputedRef<boolean>;
45
+ organization: ComputedRef<AtlasOrganizationMembership['organization'] | null>;
46
+ membership: ComputedRef<AtlasOrganizationMembership | null>;
47
+ memberships: ShallowRef<AtlasOrganizationMembership[]>;
48
+ setActive(organizationId: string | null): Promise<void>;
49
+ };
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useUser = useUser;
4
+ exports.useSession = useSession;
5
+ exports.useAuth = useAuth;
6
+ exports.useOrganization = useOrganization;
7
+ const vue_1 = require("vue");
8
+ const context_1 = require("./context");
9
+ const protect_1 = require("./protect");
10
+ /**
11
+ * §10.1 composables — the Vue peer of React's hooks.
12
+ *
13
+ * Every one returns `isLoaded` alongside its data, and that is not ceremony.
14
+ * Without it a component cannot tell "still booting" from "signed out", so it
15
+ * renders a sign-in form for a fraction of a second on every page load — the
16
+ * flash of unauthenticated content that makes an app feel broken. The React SDK
17
+ * returns plain values recomputed each render; the Vue SDK returns `computed`
18
+ * refs off the reactive client, which stay live without a re-render.
19
+ */
20
+ function useUser() {
21
+ const { status, user, getProviderToken } = (0, context_1.useAtlas)();
22
+ return {
23
+ isLoaded: (0, vue_1.computed)(() => status.value !== 'loading'),
24
+ isSignedIn: (0, vue_1.computed)(() => status.value === 'signed_in'),
25
+ user,
26
+ getProviderToken,
27
+ };
28
+ }
29
+ function useSession() {
30
+ const { status, session } = (0, context_1.useAtlas)();
31
+ return {
32
+ isLoaded: (0, vue_1.computed)(() => status.value !== 'loading'),
33
+ session,
34
+ };
35
+ }
36
+ function useAuth() {
37
+ const { status, claims, getToken, getProviderToken, signOut } = (0, context_1.useAtlas)();
38
+ return {
39
+ isLoaded: (0, vue_1.computed)(() => status.value !== 'loading'),
40
+ isSignedIn: (0, vue_1.computed)(() => status.value === 'signed_in'),
41
+ userId: (0, vue_1.computed)(() => claims.value?.sub ?? null),
42
+ sessionId: (0, vue_1.computed)(() => claims.value?.sid ?? null),
43
+ orgId: (0, vue_1.computed)(() => claims.value?.org_id ?? null),
44
+ orgRole: (0, vue_1.computed)(() => claims.value?.org_role ?? null),
45
+ /** Always fresh: refreshes first if the cached token is close to expiry. */
46
+ getToken,
47
+ /** §6.6 the user's own live access token at a connected social provider. */
48
+ getProviderToken,
49
+ signOut,
50
+ /** Mirrors <Protect>, for logic that is not a render decision. */
51
+ has: (condition) => (0, protect_1.evaluate)(claims.value, condition).allowed,
52
+ };
53
+ }
54
+ function useOrganization() {
55
+ const { status, claims, memberships, setActiveOrganization } = (0, context_1.useAtlas)();
56
+ const active = (0, vue_1.computed)(() => memberships.value.find((m) => m.organization.id === claims.value?.org_id) ?? null);
57
+ return {
58
+ isLoaded: (0, vue_1.computed)(() => status.value !== 'loading'),
59
+ organization: (0, vue_1.computed)(() => active.value?.organization ?? null),
60
+ membership: active,
61
+ memberships,
62
+ setActive: setActiveOrganization,
63
+ };
64
+ }
65
+ //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';
2
+ import type { AtlasClient } from './plugin';
3
+ /**
4
+ * §10.1 the injected Atlas client.
5
+ *
6
+ * The Vue peer of React's `AtlasContext`. `createAtlas()` provides exactly one
7
+ * `AtlasClient` on the app; every composable and component reaches it through
8
+ * `inject`, so there is a single reactive source of auth truth per app instance
9
+ * — never a module-level singleton that would leak state between two apps (or
10
+ * two SSR requests) sharing a process.
11
+ */
12
+ export declare const ATLAS_INJECTION_KEY: InjectionKey<AtlasClient>;
13
+ /**
14
+ * The Vue peer of React's `useAtlas()`.
15
+ *
16
+ * Throws rather than returning a null-ish default. A composable handing back
17
+ * `{ user: null }` outside the plugin is indistinguishable from a signed-out
18
+ * user, and the developer spends an afternoon on it.
19
+ */
20
+ export declare function useAtlas(): AtlasClient;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ATLAS_INJECTION_KEY = void 0;
4
+ exports.useAtlas = useAtlas;
5
+ const vue_1 = require("vue");
6
+ /**
7
+ * §10.1 the injected Atlas client.
8
+ *
9
+ * The Vue peer of React's `AtlasContext`. `createAtlas()` provides exactly one
10
+ * `AtlasClient` on the app; every composable and component reaches it through
11
+ * `inject`, so there is a single reactive source of auth truth per app instance
12
+ * — never a module-level singleton that would leak state between two apps (or
13
+ * two SSR requests) sharing a process.
14
+ */
15
+ exports.ATLAS_INJECTION_KEY = Symbol('atlas');
16
+ /**
17
+ * The Vue peer of React's `useAtlas()`.
18
+ *
19
+ * Throws rather than returning a null-ish default. A composable handing back
20
+ * `{ user: null }` outside the plugin is indistinguishable from a signed-out
21
+ * user, and the developer spends an afternoon on it.
22
+ */
23
+ function useAtlas() {
24
+ const client = (0, vue_1.inject)(exports.ATLAS_INJECTION_KEY, null);
25
+ if (!client) {
26
+ throw new Error('Atlas composables must be used after app.use(createAtlas({ publishableKey })).');
27
+ }
28
+ return client;
29
+ }
30
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":";;;AAqBA,4BAMC;AA3BD,6BAAgD;AAGhD;;;;;;;;GAQG;AACU,QAAA,mBAAmB,GAA8B,MAAM,CAAC,OAAO,CAAC,CAAC;AAE9E;;;;;;GAMG;AACH,SAAgB,QAAQ;IACtB,MAAM,MAAM,GAAG,IAAA,YAAM,EAAC,2BAAmB,EAAE,IAAI,CAAC,CAAC;IACjD,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,gFAAgF,CAAC,CAAC;IACpG,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/dist/fapi.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The FAPI client and sign-in flow driver now live in `@atlasauth/js` — the pure,
3
+ * framework-agnostic browser FAPI flow — so the React `<SignIn/>` and the
4
+ * framework-agnostic `@atlasauth/embed` widget drive the exact same endpoints
5
+ * through one implementation and cannot diverge in what the server sees.
6
+ *
7
+ * This module is kept as a thin re-export so every existing importer inside the
8
+ * React SDK (`./components`, the public barrel, the tests) keeps resolving the
9
+ * driver from `./fapi` unchanged.
10
+ */
11
+ export { FapiClient, advance, prepareFactor, pollAttempt, shouldKeepPolling, requestForStep, flowFromPending, initialFlow, getProviderToken, type FapiClientOptions, type FapiResponse, type FlowState, type ProviderToken, } from '@atlasauth/js';
package/dist/fapi.js ADDED
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getProviderToken = exports.initialFlow = exports.flowFromPending = exports.requestForStep = exports.shouldKeepPolling = exports.pollAttempt = exports.prepareFactor = exports.advance = exports.FapiClient = void 0;
4
+ /**
5
+ * The FAPI client and sign-in flow driver now live in `@atlasauth/js` — the pure,
6
+ * framework-agnostic browser FAPI flow — so the React `<SignIn/>` and the
7
+ * framework-agnostic `@atlasauth/embed` widget drive the exact same endpoints
8
+ * through one implementation and cannot diverge in what the server sees.
9
+ *
10
+ * This module is kept as a thin re-export so every existing importer inside the
11
+ * React SDK (`./components`, the public barrel, the tests) keeps resolving the
12
+ * driver from `./fapi` unchanged.
13
+ */
14
+ var js_1 = require("@atlasauth/js");
15
+ Object.defineProperty(exports, "FapiClient", { enumerable: true, get: function () { return js_1.FapiClient; } });
16
+ Object.defineProperty(exports, "advance", { enumerable: true, get: function () { return js_1.advance; } });
17
+ Object.defineProperty(exports, "prepareFactor", { enumerable: true, get: function () { return js_1.prepareFactor; } });
18
+ Object.defineProperty(exports, "pollAttempt", { enumerable: true, get: function () { return js_1.pollAttempt; } });
19
+ Object.defineProperty(exports, "shouldKeepPolling", { enumerable: true, get: function () { return js_1.shouldKeepPolling; } });
20
+ Object.defineProperty(exports, "requestForStep", { enumerable: true, get: function () { return js_1.requestForStep; } });
21
+ Object.defineProperty(exports, "flowFromPending", { enumerable: true, get: function () { return js_1.flowFromPending; } });
22
+ Object.defineProperty(exports, "initialFlow", { enumerable: true, get: function () { return js_1.initialFlow; } });
23
+ Object.defineProperty(exports, "getProviderToken", { enumerable: true, get: function () { return js_1.getProviderToken; } });
24
+ //# sourceMappingURL=fapi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fapi.js","sourceRoot":"","sources":["../src/fapi.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACH,oCAcuB;AAbrB,gGAAA,UAAU,OAAA;AACV,6FAAA,OAAO,OAAA;AACP,mGAAA,aAAa,OAAA;AACb,iGAAA,WAAW,OAAA;AACX,uGAAA,iBAAiB,OAAA;AACjB,oGAAA,cAAc,OAAA;AACd,qGAAA,eAAe,OAAA;AACf,iGAAA,WAAW,OAAA;AACX,sGAAA,gBAAgB,OAAA"}
package/dist/flow.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ import { type ShallowRef } from 'vue';
2
+ import { type FlowState } from './fapi';
3
+ /**
4
+ * §10.2 the server-driven sign-in / sign-up flow, as a composable.
5
+ *
6
+ * The Vue peer of the React SDK's internal `useFlow`. It never decides what
7
+ * comes next — it drives the flow through `advance`, which owns the
8
+ * step-to-endpoint mapping in `@atlasauth/js`, and renders whatever `status` the
9
+ * server returned. `useSignIn` and `useSignUp` are the same driver; only the
10
+ * `<SignIn>` / `<SignUp>` title differs, exactly as in React.
11
+ */
12
+ export interface FlowController {
13
+ /** The current server-driven attempt state. */
14
+ state: ShallowRef<FlowState>;
15
+ /** Post the current step's fields; the server decides the next status. */
16
+ submit(values: Record<string, string>): void;
17
+ }
18
+ export declare function useFlow(): FlowController;
19
+ /** §10.2 `useSignIn()` — drive a sign-in attempt. */
20
+ export declare function useSignIn(): FlowController;
21
+ /** §10.2 `useSignUp()` — drive a sign-up attempt. */
22
+ export declare function useSignUp(): FlowController;