@atlasauth/react 0.20.0 → 0.22.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/CHANGELOG.md +15 -1
- package/dist/AtlasProvider.js +17 -1
- package/dist/AtlasProvider.js.map +1 -1
- package/dist/access.d.ts +26 -0
- package/dist/access.js +58 -0
- package/dist/access.js.map +1 -0
- package/dist/account-factors.d.ts +14 -0
- package/dist/account-factors.js +195 -0
- package/dist/account-factors.js.map +1 -0
- package/dist/account.d.ts +12 -1
- package/dist/account.js +92 -3
- package/dist/account.js.map +1 -1
- package/dist/app-launcher.d.ts +11 -0
- package/dist/app-launcher.js +28 -0
- package/dist/app-launcher.js.map +1 -0
- package/dist/billing.d.ts +25 -4
- package/dist/billing.js +40 -22
- package/dist/billing.js.map +1 -1
- package/dist/compat-amplify.d.ts +116 -0
- package/dist/compat-amplify.js +212 -0
- package/dist/compat-amplify.js.map +1 -0
- package/dist/compat-baas.d.ts +155 -0
- package/dist/compat-baas.js +401 -0
- package/dist/compat-baas.js.map +1 -0
- package/dist/compat-firebase.d.ts +67 -0
- package/dist/compat-firebase.js +166 -0
- package/dist/compat-firebase.js.map +1 -0
- package/dist/compat-msal.d.ts +84 -0
- package/dist/compat-msal.js +158 -0
- package/dist/compat-msal.js.map +1 -0
- package/dist/compat.d.ts +7 -1
- package/dist/compat.js +9 -1
- package/dist/compat.js.map +1 -1
- package/dist/components.d.ts +12 -1
- package/dist/components.js +26 -2
- package/dist/components.js.map +1 -1
- package/dist/connected-accounts.d.ts +36 -0
- package/dist/connected-accounts.js +108 -0
- package/dist/connected-accounts.js.map +1 -0
- package/dist/delegated-ui.d.ts +49 -0
- package/dist/delegated-ui.js +42 -0
- package/dist/delegated-ui.js.map +1 -0
- package/dist/flow.d.ts +37 -1
- package/dist/flow.js +111 -2
- package/dist/flow.js.map +1 -1
- package/dist/i18n.js +14 -0
- package/dist/i18n.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/marketing.d.ts +31 -0
- package/dist/marketing.js +64 -0
- package/dist/marketing.js.map +1 -0
- package/dist/mfa-steps.d.ts +9 -0
- package/dist/mfa-steps.js +51 -0
- package/dist/mfa-steps.js.map +1 -1
- package/dist/organization-admin.d.ts +38 -0
- package/dist/organization-admin.js +192 -0
- package/dist/organization-admin.js.map +1 -0
- package/dist/organization.d.ts +8 -1
- package/dist/organization.js +15 -2
- package/dist/organization.js.map +1 -1
- package/dist/profile-completion.d.ts +11 -0
- package/dist/profile-completion.js +49 -0
- package/dist/profile-completion.js.map +1 -0
- package/dist/profile-traits.d.ts +37 -0
- package/dist/profile-traits.js +143 -0
- package/dist/profile-traits.js.map +1 -0
- package/dist/sign-up.js +48 -7
- package/dist/sign-up.js.map +1 -1
- package/dist/styles.js +7 -4
- package/dist/styles.js.map +1 -1
- package/dist/types.d.ts +8 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AWS Amplify Auth (Amazon Cognito) compatibility helpers, for
|
|
3
|
+
* `atlas migrate code --from cognito`. They keep the call shapes of
|
|
4
|
+
* `aws-amplify/auth` v6 (`getCurrentUser`, `fetchAuthSession`,
|
|
5
|
+
* `fetchUserAttributes`, `signOut`, `signInWithRedirect`), `Hub.listen('auth')`,
|
|
6
|
+
* the v5 `Auth` object's session readers, and `@aws-amplify/ui-react`'s
|
|
7
|
+
* `useAuthenticator` / `withAuthenticator`, over the `<AtlasProvider>` session.
|
|
8
|
+
*
|
|
9
|
+
* Tokens: `fetchAuthSession().tokens.idToken` and `.accessToken` are both the
|
|
10
|
+
* Atlas session JWT (`{ payload, toString() }`, like Amplify's `JWT`). AWS
|
|
11
|
+
* credentials from an identity pool are not produced; `credentials` is undefined.
|
|
12
|
+
*/
|
|
13
|
+
import { type ComponentType } from 'react';
|
|
14
|
+
import type { AtlasUser } from './types';
|
|
15
|
+
/** Thrown like Amplify's `UserUnAuthenticatedException` when no one is signed in. */
|
|
16
|
+
export declare class AmplifyCompatUnauthenticatedError extends Error {
|
|
17
|
+
constructor();
|
|
18
|
+
}
|
|
19
|
+
export interface AmplifyCompatJwt {
|
|
20
|
+
payload: Record<string, unknown>;
|
|
21
|
+
toString(): string;
|
|
22
|
+
}
|
|
23
|
+
export interface AmplifyCompatCurrentUser {
|
|
24
|
+
username: string;
|
|
25
|
+
userId: string;
|
|
26
|
+
signInDetails?: {
|
|
27
|
+
loginId?: string;
|
|
28
|
+
authFlowType?: string;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/** Cognito-style attributes (all strings, as Amplify returns them). */
|
|
32
|
+
export declare function amplifyAttributesFrom(user: AtlasUser): Record<string, string>;
|
|
33
|
+
/** `getCurrentUser()`: `{ username, userId }`; throws when signed out. */
|
|
34
|
+
export declare function amplifyGetCurrentUserCompat(): Promise<AmplifyCompatCurrentUser>;
|
|
35
|
+
/** `fetchAuthSession()`: `{ tokens: { idToken, accessToken }, userSub }`, or `{}` when signed out. */
|
|
36
|
+
export declare function amplifyFetchAuthSessionCompat(_options?: {
|
|
37
|
+
forceRefresh?: boolean;
|
|
38
|
+
}): Promise<{
|
|
39
|
+
tokens?: {
|
|
40
|
+
idToken?: AmplifyCompatJwt;
|
|
41
|
+
accessToken: AmplifyCompatJwt;
|
|
42
|
+
};
|
|
43
|
+
userSub?: string;
|
|
44
|
+
credentials?: undefined;
|
|
45
|
+
identityId?: undefined;
|
|
46
|
+
}>;
|
|
47
|
+
/** `fetchUserAttributes()`. */
|
|
48
|
+
export declare function amplifyFetchUserAttributesCompat(): Promise<Record<string, string>>;
|
|
49
|
+
/** `signOut({ global })`. */
|
|
50
|
+
export declare function amplifySignOutCompat(_input?: {
|
|
51
|
+
global?: boolean;
|
|
52
|
+
}): Promise<void>;
|
|
53
|
+
/** `signInWithRedirect({ provider })`: opens your Atlas sign-in page. */
|
|
54
|
+
export declare function amplifySignInWithRedirectCompat(input?: {
|
|
55
|
+
provider?: unknown;
|
|
56
|
+
customState?: string;
|
|
57
|
+
signInUrl?: string;
|
|
58
|
+
}): Promise<void>;
|
|
59
|
+
type HubCallback = (capsule: {
|
|
60
|
+
channel: string;
|
|
61
|
+
payload: {
|
|
62
|
+
event: string;
|
|
63
|
+
data?: unknown;
|
|
64
|
+
};
|
|
65
|
+
}) => void;
|
|
66
|
+
/**
|
|
67
|
+
* `Hub.listen('auth', cb)`: `signedIn`, `signedOut` and `tokenRefresh` events
|
|
68
|
+
* as the Atlas session changes. Other channels never fire. Returns the
|
|
69
|
+
* unsubscribe, like Amplify v6.
|
|
70
|
+
*/
|
|
71
|
+
export declare function amplifyHubListenCompat(channel: string, callback: HubCallback): () => void;
|
|
72
|
+
/** The v5 `Auth` object's session readers (`Auth.currentAuthenticatedUser()` …). */
|
|
73
|
+
export declare const amplifyAuthV5Compat: {
|
|
74
|
+
currentAuthenticatedUser(_params?: unknown): Promise<{
|
|
75
|
+
username: string;
|
|
76
|
+
attributes: Record<string, string>;
|
|
77
|
+
}>;
|
|
78
|
+
currentUserInfo(): Promise<{
|
|
79
|
+
id: string;
|
|
80
|
+
username: string;
|
|
81
|
+
attributes: Record<string, string>;
|
|
82
|
+
} | null>;
|
|
83
|
+
currentSession(): Promise<{
|
|
84
|
+
getIdToken: () => {
|
|
85
|
+
getJwtToken: () => string;
|
|
86
|
+
payload: Record<string, unknown>;
|
|
87
|
+
};
|
|
88
|
+
getAccessToken: () => {
|
|
89
|
+
getJwtToken: () => string;
|
|
90
|
+
payload: Record<string, unknown>;
|
|
91
|
+
};
|
|
92
|
+
isValid: () => boolean;
|
|
93
|
+
}>;
|
|
94
|
+
signOut(_opts?: unknown): Promise<void>;
|
|
95
|
+
federatedSignIn(_opts?: unknown): Promise<void>;
|
|
96
|
+
};
|
|
97
|
+
export type AmplifyAuthStatus = 'configuring' | 'authenticated' | 'unauthenticated';
|
|
98
|
+
/** `useAuthenticator()` from @aws-amplify/ui-react: `{ user, authStatus, route, signOut }`. */
|
|
99
|
+
export declare function useAmplifyAuthenticatorCompat(_selector?: unknown): {
|
|
100
|
+
user: (AmplifyCompatCurrentUser & {
|
|
101
|
+
attributes: Record<string, string>;
|
|
102
|
+
}) | undefined;
|
|
103
|
+
authStatus: AmplifyAuthStatus;
|
|
104
|
+
route: 'idle' | 'authenticated' | 'signIn';
|
|
105
|
+
signOut: () => void;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* `withAuthenticator(Component)`: renders the component for signed-in users
|
|
109
|
+
* (with `user` and `signOut` props, as Amplify passes them) and sends everyone
|
|
110
|
+
* else to your sign-in page.
|
|
111
|
+
*/
|
|
112
|
+
export declare function withAmplifyAuthenticatorCompat<P extends object>(Component: ComponentType<P & {
|
|
113
|
+
user?: unknown;
|
|
114
|
+
signOut?: () => void;
|
|
115
|
+
}>, _options?: unknown): ComponentType<P>;
|
|
116
|
+
export {};
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.amplifyAuthV5Compat = exports.AmplifyCompatUnauthenticatedError = void 0;
|
|
5
|
+
exports.amplifyAttributesFrom = amplifyAttributesFrom;
|
|
6
|
+
exports.amplifyGetCurrentUserCompat = amplifyGetCurrentUserCompat;
|
|
7
|
+
exports.amplifyFetchAuthSessionCompat = amplifyFetchAuthSessionCompat;
|
|
8
|
+
exports.amplifyFetchUserAttributesCompat = amplifyFetchUserAttributesCompat;
|
|
9
|
+
exports.amplifySignOutCompat = amplifySignOutCompat;
|
|
10
|
+
exports.amplifySignInWithRedirectCompat = amplifySignInWithRedirectCompat;
|
|
11
|
+
exports.amplifyHubListenCompat = amplifyHubListenCompat;
|
|
12
|
+
exports.useAmplifyAuthenticatorCompat = useAmplifyAuthenticatorCompat;
|
|
13
|
+
exports.withAmplifyAuthenticatorCompat = withAmplifyAuthenticatorCompat;
|
|
14
|
+
/**
|
|
15
|
+
* AWS Amplify Auth (Amazon Cognito) compatibility helpers, for
|
|
16
|
+
* `atlas migrate code --from cognito`. They keep the call shapes of
|
|
17
|
+
* `aws-amplify/auth` v6 (`getCurrentUser`, `fetchAuthSession`,
|
|
18
|
+
* `fetchUserAttributes`, `signOut`, `signInWithRedirect`), `Hub.listen('auth')`,
|
|
19
|
+
* the v5 `Auth` object's session readers, and `@aws-amplify/ui-react`'s
|
|
20
|
+
* `useAuthenticator` / `withAuthenticator`, over the `<AtlasProvider>` session.
|
|
21
|
+
*
|
|
22
|
+
* Tokens: `fetchAuthSession().tokens.idToken` and `.accessToken` are both the
|
|
23
|
+
* Atlas session JWT (`{ payload, toString() }`, like Amplify's `JWT`). AWS
|
|
24
|
+
* credentials from an identity pool are not produced; `credentials` is undefined.
|
|
25
|
+
*/
|
|
26
|
+
const react_1 = require("react");
|
|
27
|
+
const AtlasProvider_1 = require("./AtlasProvider");
|
|
28
|
+
const components_shared_1 = require("./components-shared");
|
|
29
|
+
const compat_1 = require("./compat");
|
|
30
|
+
const active_atlas_1 = require("./active-atlas");
|
|
31
|
+
/** Thrown like Amplify's `UserUnAuthenticatedException` when no one is signed in. */
|
|
32
|
+
class AmplifyCompatUnauthenticatedError extends Error {
|
|
33
|
+
constructor() {
|
|
34
|
+
super('User needs to be authenticated to call this API.');
|
|
35
|
+
this.name = 'UserUnAuthenticatedException';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.AmplifyCompatUnauthenticatedError = AmplifyCompatUnauthenticatedError;
|
|
39
|
+
function signedIn(helper) {
|
|
40
|
+
const atlas = (0, active_atlas_1.requireActive)(helper);
|
|
41
|
+
if (atlas.status !== 'signed_in' || !atlas.user)
|
|
42
|
+
throw new AmplifyCompatUnauthenticatedError();
|
|
43
|
+
return atlas;
|
|
44
|
+
}
|
|
45
|
+
function decodePayload(token) {
|
|
46
|
+
try {
|
|
47
|
+
const part = token.split('.')[1] ?? '';
|
|
48
|
+
const json = atob(part.replace(/-/g, '+').replace(/_/g, '/').padEnd(Math.ceil(part.length / 4) * 4, '='));
|
|
49
|
+
const parsed = JSON.parse(json);
|
|
50
|
+
return parsed && typeof parsed === 'object' ? parsed : {};
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return {};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function jwt(token) {
|
|
57
|
+
return { payload: decodePayload(token), toString: () => token };
|
|
58
|
+
}
|
|
59
|
+
function currentUserOf(user) {
|
|
60
|
+
const email = (0, compat_1.primaryEmail)(user)?.address;
|
|
61
|
+
return { username: user.username ?? email ?? user.id, userId: user.id, signInDetails: email ? { loginId: email } : undefined };
|
|
62
|
+
}
|
|
63
|
+
/** Cognito-style attributes (all strings, as Amplify returns them). */
|
|
64
|
+
function amplifyAttributesFrom(user) {
|
|
65
|
+
const email = (0, compat_1.primaryEmail)(user);
|
|
66
|
+
const phone = (user.phone_numbers ?? []).find((p) => p.primary) ?? user.phone_numbers?.[0];
|
|
67
|
+
const out = { sub: user.id };
|
|
68
|
+
if (email) {
|
|
69
|
+
out.email = email.address;
|
|
70
|
+
out.email_verified = String(email.verified);
|
|
71
|
+
}
|
|
72
|
+
if (phone) {
|
|
73
|
+
out.phone_number = phone.phone_number;
|
|
74
|
+
out.phone_number_verified = String(phone.verified);
|
|
75
|
+
}
|
|
76
|
+
if (user.first_name)
|
|
77
|
+
out.given_name = user.first_name;
|
|
78
|
+
if (user.last_name)
|
|
79
|
+
out.family_name = user.last_name;
|
|
80
|
+
const name = (0, compat_1.displayName)(user);
|
|
81
|
+
if (name)
|
|
82
|
+
out.name = name;
|
|
83
|
+
if (user.username)
|
|
84
|
+
out.preferred_username = user.username;
|
|
85
|
+
if (user.image_url)
|
|
86
|
+
out.picture = user.image_url;
|
|
87
|
+
for (const [k, v] of Object.entries(user.public_metadata ?? {})) {
|
|
88
|
+
if (typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean')
|
|
89
|
+
out[`custom:${k}`] = String(v);
|
|
90
|
+
}
|
|
91
|
+
return out;
|
|
92
|
+
}
|
|
93
|
+
/** `getCurrentUser()`: `{ username, userId }`; throws when signed out. */
|
|
94
|
+
async function amplifyGetCurrentUserCompat() {
|
|
95
|
+
return currentUserOf(signedIn('amplifyGetCurrentUserCompat').user);
|
|
96
|
+
}
|
|
97
|
+
/** `fetchAuthSession()`: `{ tokens: { idToken, accessToken }, userSub }`, or `{}` when signed out. */
|
|
98
|
+
async function amplifyFetchAuthSessionCompat(_options) {
|
|
99
|
+
const atlas = (0, active_atlas_1.requireActive)('amplifyFetchAuthSessionCompat');
|
|
100
|
+
if (atlas.status !== 'signed_in' || !atlas.user)
|
|
101
|
+
return {};
|
|
102
|
+
const token = await atlas.getToken();
|
|
103
|
+
if (!token)
|
|
104
|
+
return {};
|
|
105
|
+
return { tokens: { idToken: jwt(token), accessToken: jwt(token) }, userSub: atlas.user.id };
|
|
106
|
+
}
|
|
107
|
+
/** `fetchUserAttributes()`. */
|
|
108
|
+
async function amplifyFetchUserAttributesCompat() {
|
|
109
|
+
return amplifyAttributesFrom(signedIn('amplifyFetchUserAttributesCompat').user);
|
|
110
|
+
}
|
|
111
|
+
/** `signOut({ global })`. */
|
|
112
|
+
async function amplifySignOutCompat(_input) {
|
|
113
|
+
await (0, active_atlas_1.requireActive)('amplifySignOutCompat').signOut();
|
|
114
|
+
}
|
|
115
|
+
/** `signInWithRedirect({ provider })`: opens your Atlas sign-in page. */
|
|
116
|
+
async function amplifySignInWithRedirectCompat(input = {}) {
|
|
117
|
+
const back = typeof window !== 'undefined' ? window.location.href : undefined;
|
|
118
|
+
(0, components_shared_1.navigateTo)((0, components_shared_1.withRedirect)(input.signInUrl ?? '/sign-in', back));
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* `Hub.listen('auth', cb)`: `signedIn`, `signedOut` and `tokenRefresh` events
|
|
122
|
+
* as the Atlas session changes. Other channels never fire. Returns the
|
|
123
|
+
* unsubscribe, like Amplify v6.
|
|
124
|
+
*/
|
|
125
|
+
function amplifyHubListenCompat(channel, callback) {
|
|
126
|
+
if (channel !== 'auth')
|
|
127
|
+
return () => undefined;
|
|
128
|
+
let last = { status: null, id: null, exp: null };
|
|
129
|
+
const listener = (atlas) => {
|
|
130
|
+
if (!atlas || atlas.status === 'loading')
|
|
131
|
+
return;
|
|
132
|
+
const id = atlas.status === 'signed_in' ? (atlas.user?.id ?? null) : null;
|
|
133
|
+
const exp = atlas.claims?.exp ?? null;
|
|
134
|
+
let event = null;
|
|
135
|
+
if (last.status !== null) {
|
|
136
|
+
if (id && id !== last.id)
|
|
137
|
+
event = 'signedIn';
|
|
138
|
+
else if (!id && last.id)
|
|
139
|
+
event = 'signedOut';
|
|
140
|
+
else if (id && exp !== last.exp)
|
|
141
|
+
event = 'tokenRefresh';
|
|
142
|
+
}
|
|
143
|
+
last = { status: atlas.status, id, exp };
|
|
144
|
+
if (event)
|
|
145
|
+
callback({ channel: 'auth', payload: { event, data: event === 'signedIn' && atlas.user ? currentUserOf(atlas.user) : undefined } });
|
|
146
|
+
};
|
|
147
|
+
const unsubscribe = (0, active_atlas_1.onActiveAtlasChange)(listener);
|
|
148
|
+
const current = (0, active_atlas_1.getActiveAtlas)();
|
|
149
|
+
if (current)
|
|
150
|
+
listener(current);
|
|
151
|
+
return unsubscribe;
|
|
152
|
+
}
|
|
153
|
+
/** The v5 `Auth` object's session readers (`Auth.currentAuthenticatedUser()` …). */
|
|
154
|
+
exports.amplifyAuthV5Compat = {
|
|
155
|
+
async currentAuthenticatedUser(_params) {
|
|
156
|
+
const atlas = signedIn('Auth.currentAuthenticatedUser');
|
|
157
|
+
return { username: currentUserOf(atlas.user).username, attributes: amplifyAttributesFrom(atlas.user) };
|
|
158
|
+
},
|
|
159
|
+
async currentUserInfo() {
|
|
160
|
+
const atlas = (0, active_atlas_1.getActiveAtlas)();
|
|
161
|
+
if (!atlas || atlas.status !== 'signed_in' || !atlas.user)
|
|
162
|
+
return null;
|
|
163
|
+
return { id: atlas.user.id, username: currentUserOf(atlas.user).username, attributes: amplifyAttributesFrom(atlas.user) };
|
|
164
|
+
},
|
|
165
|
+
async currentSession() {
|
|
166
|
+
const session = await amplifyFetchAuthSessionCompat();
|
|
167
|
+
if (!session.tokens)
|
|
168
|
+
throw new AmplifyCompatUnauthenticatedError();
|
|
169
|
+
const token = session.tokens.accessToken.toString();
|
|
170
|
+
const wrap = () => ({ getJwtToken: () => token, payload: session.tokens.accessToken.payload });
|
|
171
|
+
return { getIdToken: wrap, getAccessToken: wrap, isValid: () => true };
|
|
172
|
+
},
|
|
173
|
+
async signOut(_opts) {
|
|
174
|
+
await amplifySignOutCompat();
|
|
175
|
+
},
|
|
176
|
+
async federatedSignIn(_opts) {
|
|
177
|
+
await amplifySignInWithRedirectCompat();
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
/** `useAuthenticator()` from @aws-amplify/ui-react: `{ user, authStatus, route, signOut }`. */
|
|
181
|
+
function useAmplifyAuthenticatorCompat(_selector) {
|
|
182
|
+
const atlas = (0, AtlasProvider_1.useAtlas)();
|
|
183
|
+
const authStatus = atlas.status === 'loading' ? 'configuring' : atlas.status === 'signed_in' ? 'authenticated' : 'unauthenticated';
|
|
184
|
+
const user = atlas.status === 'signed_in' && atlas.user ? { ...currentUserOf(atlas.user), attributes: amplifyAttributesFrom(atlas.user) } : undefined;
|
|
185
|
+
return {
|
|
186
|
+
user,
|
|
187
|
+
authStatus,
|
|
188
|
+
route: authStatus === 'configuring' ? 'idle' : authStatus === 'authenticated' ? 'authenticated' : 'signIn',
|
|
189
|
+
signOut: () => void amplifySignOutCompat(),
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* `withAuthenticator(Component)`: renders the component for signed-in users
|
|
194
|
+
* (with `user` and `signOut` props, as Amplify passes them) and sends everyone
|
|
195
|
+
* else to your sign-in page.
|
|
196
|
+
*/
|
|
197
|
+
function withAmplifyAuthenticatorCompat(Component, _options) {
|
|
198
|
+
function Wrapped(props) {
|
|
199
|
+
const auth = useAmplifyAuthenticatorCompat();
|
|
200
|
+
(0, react_1.useEffect)(() => {
|
|
201
|
+
if (auth.authStatus === 'unauthenticated') {
|
|
202
|
+
(0, components_shared_1.navigateTo)((0, components_shared_1.withRedirect)('/sign-in', typeof window !== 'undefined' ? window.location.href : undefined));
|
|
203
|
+
}
|
|
204
|
+
}, [auth.authStatus]);
|
|
205
|
+
if (auth.authStatus !== 'authenticated')
|
|
206
|
+
return null;
|
|
207
|
+
return (0, react_1.createElement)(Component, { ...props, user: auth.user, signOut: auth.signOut });
|
|
208
|
+
}
|
|
209
|
+
Wrapped.displayName = `withAmplifyAuthenticatorCompat(${Component.displayName ?? Component.name ?? 'Component'})`;
|
|
210
|
+
return Wrapped;
|
|
211
|
+
}
|
|
212
|
+
//# sourceMappingURL=compat-amplify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compat-amplify.js","sourceRoot":"","sources":["../src/compat-amplify.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;AAmEb,sDAsBC;AAGD,kEAEC;AAGD,sEAWC;AAGD,4EAEC;AAGD,oDAEC;AAGD,0EAGC;AASD,wDAoBC;AA+BD,sEAeC;AAOD,wEAgBC;AA5ND;;;;;;;;;;;GAWG;AACH,iCAAqE;AACrE,mDAA2C;AAC3C,2DAA+D;AAC/D,qCAAqD;AAErD,iDAAsG;AAEtG,qFAAqF;AACrF,MAAa,iCAAkC,SAAQ,KAAK;IAC1D;QACE,KAAK,CAAC,kDAAkD,CAAC,CAAC;QAC1D,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAC;IAC7C,CAAC;CACF;AALD,8EAKC;AAaD,SAAS,QAAQ,CAAC,MAAc;IAC9B,MAAM,KAAK,GAAG,IAAA,4BAAa,EAAC,MAAM,CAAC,CAAC;IACpC,IAAI,KAAK,CAAC,MAAM,KAAK,WAAW,IAAI,CAAC,KAAK,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
|
|
3
|
+
export interface AppwriteCompatUser {
|
|
4
|
+
$id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
email: string;
|
|
7
|
+
emailVerification: boolean;
|
|
8
|
+
phone: string;
|
|
9
|
+
phoneVerification: boolean;
|
|
10
|
+
status: true;
|
|
11
|
+
labels: string[];
|
|
12
|
+
prefs: Record<string, unknown>;
|
|
13
|
+
mfa: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function appwriteUserFrom(user: AtlasUser): AppwriteCompatUser;
|
|
16
|
+
/** Thrown like Appwrite's `AppwriteException` (code 401, `general_unauthorized_scope`) when signed out. */
|
|
17
|
+
export declare class AppwriteCompatException extends Error {
|
|
18
|
+
readonly code = 401;
|
|
19
|
+
readonly type = "general_unauthorized_scope";
|
|
20
|
+
constructor();
|
|
21
|
+
}
|
|
22
|
+
/** `new Account(client)` from the Appwrite web SDK. The client is accepted and ignored. */
|
|
23
|
+
export declare class AppwriteAccountCompat {
|
|
24
|
+
constructor(_client?: unknown);
|
|
25
|
+
get(): Promise<AppwriteCompatUser>;
|
|
26
|
+
getPrefs(): Promise<Record<string, unknown>>;
|
|
27
|
+
/** `deleteSession('current')` signs out; other session ids are managed in <UserProfile />. */
|
|
28
|
+
deleteSession(sessionId?: string): Promise<Record<string, never>>;
|
|
29
|
+
deleteSessions(): Promise<Record<string, never>>;
|
|
30
|
+
/** `createJWT()`: `{ jwt }` is the Atlas session JWT (verify it with @atlasauth/backend). */
|
|
31
|
+
createJWT(): Promise<{
|
|
32
|
+
jwt: string;
|
|
33
|
+
}>;
|
|
34
|
+
/** `createOAuth2Session(provider, success)`: opens the Atlas sign-in page, returning to `success`. */
|
|
35
|
+
createOAuth2Session(_provider?: unknown, success?: string, _failure?: string, _scopes?: string[]): void;
|
|
36
|
+
createOAuth2Token(provider?: unknown, success?: string, failure?: string, scopes?: string[]): void;
|
|
37
|
+
create(..._args: unknown[]): Promise<never>;
|
|
38
|
+
createEmailPasswordSession(..._args: unknown[]): Promise<never>;
|
|
39
|
+
createEmailSession(..._args: unknown[]): Promise<never>;
|
|
40
|
+
createMagicURLToken(..._args: unknown[]): Promise<never>;
|
|
41
|
+
createEmailToken(..._args: unknown[]): Promise<never>;
|
|
42
|
+
createPhoneToken(..._args: unknown[]): Promise<never>;
|
|
43
|
+
createSession(..._args: unknown[]): Promise<never>;
|
|
44
|
+
createAnonymousSession(..._args: unknown[]): Promise<never>;
|
|
45
|
+
updatePassword(..._args: unknown[]): Promise<never>;
|
|
46
|
+
updateEmail(..._args: unknown[]): Promise<never>;
|
|
47
|
+
updateName(..._args: unknown[]): Promise<never>;
|
|
48
|
+
updatePrefs(..._args: unknown[]): Promise<never>;
|
|
49
|
+
createRecovery(..._args: unknown[]): Promise<never>;
|
|
50
|
+
updateRecovery(..._args: unknown[]): Promise<never>;
|
|
51
|
+
createVerification(..._args: unknown[]): Promise<never>;
|
|
52
|
+
updateVerification(..._args: unknown[]): Promise<never>;
|
|
53
|
+
}
|
|
54
|
+
/** The PocketBase auth record shape apps read off `pb.authStore.record` / `.model`. */
|
|
55
|
+
export interface PocketBaseCompatRecord {
|
|
56
|
+
id: string;
|
|
57
|
+
collectionName: 'users';
|
|
58
|
+
email: string;
|
|
59
|
+
verified: boolean;
|
|
60
|
+
username: string;
|
|
61
|
+
name: string;
|
|
62
|
+
avatar: string;
|
|
63
|
+
[field: string]: unknown;
|
|
64
|
+
}
|
|
65
|
+
export declare function pocketbaseRecordFrom(user: AtlasUser): PocketBaseCompatRecord;
|
|
66
|
+
/** `pb.authStore`, answered by the Atlas session. */
|
|
67
|
+
export declare const pocketbaseAuthStoreCompat: {
|
|
68
|
+
readonly isValid: boolean;
|
|
69
|
+
/** The last Atlas session JWT seen (empty until the first one is minted); prefer `await getToken()`. */
|
|
70
|
+
readonly token: string;
|
|
71
|
+
readonly record: PocketBaseCompatRecord | null;
|
|
72
|
+
/** Pre-0.23 name for `record`. */
|
|
73
|
+
readonly model: PocketBaseCompatRecord | null;
|
|
74
|
+
readonly isSuperuser: boolean;
|
|
75
|
+
readonly isAdmin: boolean;
|
|
76
|
+
/** The current Atlas session JWT. */
|
|
77
|
+
getToken(): Promise<string>;
|
|
78
|
+
clear(): void;
|
|
79
|
+
/** `onChange((token, record) => …, fireImmediately)`: returns the unsubscribe. */
|
|
80
|
+
onChange(callback: (token: string, record: PocketBaseCompatRecord | null) => void, fireImmediately?: boolean): () => void;
|
|
81
|
+
/** Atlas keeps its own session cookie: there is nothing to load. */
|
|
82
|
+
loadFromCookie(_cookie?: string, _key?: string): void;
|
|
83
|
+
/** Atlas keeps its own session cookie: there is nothing to export. */
|
|
84
|
+
exportToCookie(_options?: unknown, _key?: string): string;
|
|
85
|
+
save(_token?: string, _record?: unknown): void;
|
|
86
|
+
};
|
|
87
|
+
/** Nhost's `User` shape (camelCase, as `@nhost/react` returns it). */
|
|
88
|
+
export interface NhostCompatUser {
|
|
89
|
+
id: string;
|
|
90
|
+
email?: string;
|
|
91
|
+
emailVerified: boolean;
|
|
92
|
+
displayName: string;
|
|
93
|
+
avatarUrl: string;
|
|
94
|
+
phoneNumber?: string;
|
|
95
|
+
phoneNumberVerified: boolean;
|
|
96
|
+
defaultRole: string;
|
|
97
|
+
roles: string[];
|
|
98
|
+
locale: string;
|
|
99
|
+
isAnonymous: false;
|
|
100
|
+
metadata: Record<string, unknown>;
|
|
101
|
+
}
|
|
102
|
+
export declare function nhostUserFrom(user: AtlasUser): NhostCompatUser;
|
|
103
|
+
/** `nhost.auth.*` session readers. */
|
|
104
|
+
export declare const nhostAuthCompat: {
|
|
105
|
+
getUser(): NhostCompatUser | null;
|
|
106
|
+
isAuthenticated(): boolean;
|
|
107
|
+
/** Resolves once the session is known (not while the provider is still loading). */
|
|
108
|
+
isAuthenticatedAsync(): Promise<boolean>;
|
|
109
|
+
getAccessToken(): Promise<string | undefined>;
|
|
110
|
+
getSession(): Promise<{
|
|
111
|
+
accessToken: string;
|
|
112
|
+
user: NhostCompatUser;
|
|
113
|
+
} | null>;
|
|
114
|
+
signOut(_params?: {
|
|
115
|
+
all?: boolean;
|
|
116
|
+
}): Promise<{
|
|
117
|
+
error: null;
|
|
118
|
+
}>;
|
|
119
|
+
/** `onAuthStateChanged((event, session) => …)`: SIGNED_IN / SIGNED_OUT. Returns the unsubscribe. */
|
|
120
|
+
onAuthStateChanged(callback: (event: "SIGNED_IN" | "SIGNED_OUT", session: {
|
|
121
|
+
user: NhostCompatUser;
|
|
122
|
+
} | null) => void): () => void;
|
|
123
|
+
/** `onTokenChanged(cb)`: fires when the session token is refreshed. */
|
|
124
|
+
onTokenChanged(callback: (session: {
|
|
125
|
+
accessToken: string;
|
|
126
|
+
} | null) => void): () => void;
|
|
127
|
+
};
|
|
128
|
+
/** `useAuthenticationStatus()`: `{ isAuthenticated, isLoading }`. */
|
|
129
|
+
export declare function useNhostAuthenticationStatusCompat(): {
|
|
130
|
+
isAuthenticated: boolean;
|
|
131
|
+
isLoading: boolean;
|
|
132
|
+
error: null;
|
|
133
|
+
isError: false;
|
|
134
|
+
};
|
|
135
|
+
/** `useAuthenticated()`. */
|
|
136
|
+
export declare function useNhostAuthenticatedCompat(): boolean;
|
|
137
|
+
/** `useUserData()`: the user, or null. */
|
|
138
|
+
export declare function useNhostUserDataCompat(): NhostCompatUser | null;
|
|
139
|
+
/** `useUserId()`. */
|
|
140
|
+
export declare function useNhostUserIdCompat(): string | undefined;
|
|
141
|
+
/** `useUserEmail()`. */
|
|
142
|
+
export declare function useNhostUserEmailCompat(): string | undefined;
|
|
143
|
+
/** `useUserDisplayName()`. */
|
|
144
|
+
export declare function useNhostUserDisplayNameCompat(): string | undefined;
|
|
145
|
+
/** `useUserAvatarUrl()`. */
|
|
146
|
+
export declare function useNhostUserAvatarUrlCompat(): string | undefined;
|
|
147
|
+
/** `useSignOut()`: `{ signOut, isSuccess }`. */
|
|
148
|
+
export declare function useNhostSignOutCompat(): {
|
|
149
|
+
signOut: (all?: boolean) => Promise<{
|
|
150
|
+
isSuccess: boolean;
|
|
151
|
+
isError: boolean;
|
|
152
|
+
error: null;
|
|
153
|
+
}>;
|
|
154
|
+
isSuccess: boolean;
|
|
155
|
+
};
|