@ttoss/react-auth 2.6.86 → 2.6.89

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,235 @@
1
+ /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
+ var __defProp = Object.defineProperty;
3
+ var __name = (target, value) => __defProp(target, "name", {
4
+ value,
5
+ configurable: true
6
+ });
7
+
8
+ // src/Auth.tsx
9
+ import { Auth as AuthCore, useAuthScreen } from "@ttoss/react-auth-core";
10
+ import { useI18n } from "@ttoss/react-i18n";
11
+ import { useNotifications } from "@ttoss/react-notifications";
12
+ import { confirmResetPassword, confirmSignUp, resendSignUpCode, resetPassword, signIn, signUp } from "aws-amplify/auth";
13
+ import * as React from "react";
14
+ var Auth = /* @__PURE__ */__name(props => {
15
+ const {
16
+ intl
17
+ } = useI18n();
18
+ const {
19
+ screen,
20
+ setScreen
21
+ } = useAuthScreen();
22
+ const {
23
+ addNotification
24
+ } = useNotifications();
25
+ const onSignIn = React.useCallback(async ({
26
+ email,
27
+ password
28
+ }) => {
29
+ try {
30
+ const result = await signIn({
31
+ username: email,
32
+ password
33
+ });
34
+ if (result.nextStep.signInStep === "RESET_PASSWORD") {
35
+ addNotification({
36
+ type: "error",
37
+ message: `For your security, we have updated our system and you need to reset your password in 'forgot your password?' to proceed`
38
+ });
39
+ } else if (result.nextStep.signInStep === "CONFIRM_SIGN_UP") {
40
+ await resendSignUpCode({
41
+ username: email
42
+ });
43
+ setScreen({
44
+ value: "confirmSignUpWithCode",
45
+ context: {
46
+ email
47
+ }
48
+ });
49
+ } else if (result.nextStep.signInStep === "DONE") {
50
+ addNotification({
51
+ viewType: "toast",
52
+ type: "success",
53
+ message: intl.formatMessage({
54
+ id: "EO/33N",
55
+ defaultMessage: [{
56
+ "type": 0,
57
+ "value": "Signed in successfully"
58
+ }]
59
+ })
60
+ });
61
+ }
62
+ } catch (error) {
63
+ addNotification({
64
+ type: "error",
65
+ message: error.message
66
+ });
67
+ }
68
+ }, [addNotification, intl, setScreen]);
69
+ const onSignUp = React.useCallback(async ({
70
+ email,
71
+ password
72
+ }) => {
73
+ try {
74
+ await signUp({
75
+ username: email,
76
+ password,
77
+ options: {
78
+ userAttributes: {
79
+ email
80
+ }
81
+ }
82
+ });
83
+ setScreen({
84
+ value: "confirmSignUpWithCode",
85
+ context: {
86
+ email
87
+ }
88
+ });
89
+ } catch (error) {
90
+ addNotification({
91
+ type: "error",
92
+ message: error.message
93
+ });
94
+ }
95
+ }, [setScreen, addNotification]);
96
+ const onConfirmSignUpWithCode = React.useCallback(async ({
97
+ email,
98
+ code
99
+ }) => {
100
+ try {
101
+ await confirmSignUp({
102
+ confirmationCode: code,
103
+ username: email
104
+ });
105
+ setScreen({
106
+ value: "signIn"
107
+ });
108
+ } catch (error) {
109
+ addNotification({
110
+ type: "error",
111
+ message: error.message
112
+ });
113
+ }
114
+ }, [setScreen, addNotification]);
115
+ const onForgotPassword = React.useCallback(async ({
116
+ email
117
+ }) => {
118
+ try {
119
+ await resetPassword({
120
+ username: email
121
+ });
122
+ setScreen({
123
+ value: "confirmResetPassword",
124
+ context: {
125
+ email
126
+ }
127
+ });
128
+ } catch (error) {
129
+ addNotification({
130
+ type: "error",
131
+ message: error.message
132
+ });
133
+ }
134
+ }, [setScreen, addNotification]);
135
+ const onForgotPasswordResetPassword = React.useCallback(async ({
136
+ email,
137
+ code,
138
+ newPassword
139
+ }) => {
140
+ try {
141
+ await confirmResetPassword({
142
+ confirmationCode: code,
143
+ username: email,
144
+ newPassword
145
+ });
146
+ setScreen({
147
+ value: "signIn"
148
+ });
149
+ } catch (error) {
150
+ addNotification({
151
+ type: "error",
152
+ message: error.message
153
+ });
154
+ }
155
+ }, [setScreen, addNotification]);
156
+ return /* @__PURE__ */React.createElement(AuthCore, {
157
+ screen,
158
+ setScreen,
159
+ onSignIn,
160
+ onSignUp,
161
+ onConfirmSignUpWithCode,
162
+ onForgotPassword,
163
+ onForgotPasswordResetPassword,
164
+ signUpTerms: props.signUpTerms,
165
+ logo: props.logo,
166
+ layout: props.layout
167
+ });
168
+ }, "Auth");
169
+
170
+ // src/AuthProvider.tsx
171
+ import { AuthProvider as AuthProviderCore, useAuth } from "@ttoss/react-auth-core";
172
+ import { signOut } from "aws-amplify/auth";
173
+ import { Hub } from "aws-amplify/utils";
174
+ import * as React2 from "react";
175
+
176
+ // src/getAuthData.ts
177
+ import { fetchAuthSession, fetchUserAttributes, getCurrentUser } from "aws-amplify/auth";
178
+ var getAuthData = /* @__PURE__ */__name(async ({
179
+ includeTokens
180
+ } = {}) => {
181
+ const currentUser = await getCurrentUser();
182
+ const [session, user] = await Promise.all([includeTokens ? fetchAuthSession() : Promise.resolve(null), fetchUserAttributes()]);
183
+ const idToken = session?.tokens?.idToken?.toString() ?? "";
184
+ const accessToken = session?.tokens?.accessToken?.toString() ?? "";
185
+ const refreshToken = "";
186
+ return {
187
+ user: {
188
+ id: currentUser.userId,
189
+ email: user.email ?? "",
190
+ emailVerified: user.email_verified === "true"
191
+ },
192
+ tokens: {
193
+ idToken,
194
+ accessToken,
195
+ refreshToken
196
+ },
197
+ isAuthenticated: true
198
+ };
199
+ }, "getAuthData");
200
+ var checkAuth = /* @__PURE__ */__name(async () => {
201
+ try {
202
+ const currentUser = await getCurrentUser();
203
+ return !!currentUser;
204
+ } catch {
205
+ return false;
206
+ }
207
+ }, "checkAuth");
208
+
209
+ // src/AuthProvider.tsx
210
+ var AuthProvider = /* @__PURE__ */__name(props => {
211
+ const [authListenerCount, setAuthListenerCount] = React2.useState(0);
212
+ React2.useEffect(() => {
213
+ const listener = /* @__PURE__ */__name(() => {
214
+ setAuthListenerCount(count => {
215
+ return count + 1;
216
+ });
217
+ }, "listener");
218
+ const stopHubListener = Hub.listen("auth", listener);
219
+ return () => {
220
+ stopHubListener();
221
+ };
222
+ }, []);
223
+ const getAuthDataCallback = React2.useCallback(async () => {
224
+ try {
225
+ return getAuthData();
226
+ } catch {
227
+ return null;
228
+ }
229
+ }, [authListenerCount]);
230
+ return /* @__PURE__ */React2.createElement(AuthProviderCore, {
231
+ getAuthData: getAuthDataCallback,
232
+ signOut
233
+ }, props.children);
234
+ }, "AuthProvider");
235
+ export { Auth, AuthProvider, checkAuth, getAuthData, useAuth };
@@ -0,0 +1,18 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { AuthProps as AuthProps$1, AuthData } from '@ttoss/react-auth-core';
3
+ export { useAuth } from '@ttoss/react-auth-core';
4
+ import * as React from 'react';
5
+
6
+ type AuthProps = Pick<AuthProps$1, 'signUpTerms' | 'logo' | 'layout'>;
7
+ declare const Auth: (props: AuthProps) => react_jsx_runtime.JSX.Element;
8
+
9
+ declare const AuthProvider: (props: {
10
+ children: React.ReactNode;
11
+ }) => react_jsx_runtime.JSX.Element;
12
+
13
+ declare const getAuthData: ({ includeTokens, }?: {
14
+ includeTokens?: boolean;
15
+ }) => Promise<AuthData | null>;
16
+ declare const checkAuth: () => Promise<boolean>;
17
+
18
+ export { Auth, type AuthProps, AuthProvider, checkAuth, getAuthData };
@@ -0,0 +1,410 @@
1
+ {
2
+ "0+4wTp": [
3
+ {
4
+ "type": 0,
5
+ "value": ","
6
+ }
7
+ ],
8
+ "0EjvY6": [
9
+ {
10
+ "type": 0,
11
+ "value": "∞"
12
+ }
13
+ ],
14
+ "0XOzcH": [
15
+ {
16
+ "type": 0,
17
+ "value": "Required field"
18
+ }
19
+ ],
20
+ "1DbX9V": [
21
+ {
22
+ "type": 0,
23
+ "value": "Near limit"
24
+ }
25
+ ],
26
+ "38HSjr": [
27
+ {
28
+ "type": 0,
29
+ "value": "Sign In"
30
+ }
31
+ ],
32
+ "4NwCn9": [
33
+ {
34
+ "type": 0,
35
+ "value": "Reached limit"
36
+ }
37
+ ],
38
+ "5E12mO": [
39
+ {
40
+ "type": 0,
41
+ "value": "Email"
42
+ }
43
+ ],
44
+ "6PdOcy": [
45
+ {
46
+ "type": 0,
47
+ "value": "Cancel"
48
+ }
49
+ ],
50
+ "8GMUPk": [
51
+ {
52
+ "type": 0,
53
+ "value": "I'm already registered"
54
+ }
55
+ ],
56
+ "9cApwd": [
57
+ {
58
+ "type": 0,
59
+ "value": "Please, insert a valid e-mail"
60
+ }
61
+ ],
62
+ "BtK6KR": [
63
+ {
64
+ "type": 0,
65
+ "value": "Forgot password?"
66
+ }
67
+ ],
68
+ "Co3exe": [
69
+ {
70
+ "type": 0,
71
+ "value": "By signing up, you agree to the following Terms and Conditions."
72
+ }
73
+ ],
74
+ "D1C6fR": [
75
+ {
76
+ "type": 0,
77
+ "value": "Field must be at least "
78
+ },
79
+ {
80
+ "type": 1,
81
+ "value": "min"
82
+ },
83
+ {
84
+ "type": 0,
85
+ "value": " characters"
86
+ }
87
+ ],
88
+ "EO/33N": [
89
+ {
90
+ "type": 0,
91
+ "value": "Signed in successfully"
92
+ }
93
+ ],
94
+ "EZ3YF2": [
95
+ {
96
+ "type": 0,
97
+ "value": "Sign up"
98
+ }
99
+ ],
100
+ "G/yZLu": [
101
+ {
102
+ "type": 0,
103
+ "value": "Remove"
104
+ }
105
+ ],
106
+ "HT4tSM": [
107
+ {
108
+ "type": 0,
109
+ "value": "Reset Password"
110
+ }
111
+ ],
112
+ "JEsxDw": [
113
+ {
114
+ "type": 0,
115
+ "value": "Uploading..."
116
+ }
117
+ ],
118
+ "JnCaDG": [
119
+ {
120
+ "type": 0,
121
+ "value": "."
122
+ }
123
+ ],
124
+ "KY2T6J": [
125
+ {
126
+ "type": 0,
127
+ "value": "Code"
128
+ }
129
+ ],
130
+ "MfWGyg": [
131
+ {
132
+ "type": 0,
133
+ "value": "Field is required"
134
+ }
135
+ ],
136
+ "NJ57Qj": [
137
+ {
138
+ "type": 0,
139
+ "value": "Confirm password field is required"
140
+ }
141
+ ],
142
+ "OhDL0i": [
143
+ {
144
+ "type": 0,
145
+ "value": "Invalid email"
146
+ }
147
+ ],
148
+ "PylVqx": [
149
+ {
150
+ "type": 0,
151
+ "value": "Password"
152
+ }
153
+ ],
154
+ "S3pjKw": [
155
+ {
156
+ "type": 0,
157
+ "value": "Minimum "
158
+ },
159
+ {
160
+ "type": 1,
161
+ "value": "value"
162
+ },
163
+ {
164
+ "type": 0,
165
+ "value": " characters"
166
+ }
167
+ ],
168
+ "S4bbEj": [
169
+ {
170
+ "type": 0,
171
+ "value": "Recovering Password"
172
+ }
173
+ ],
174
+ "SQJto2": [
175
+ {
176
+ "type": 0,
177
+ "value": "Sign in"
178
+ }
179
+ ],
180
+ "SfWKyS": [
181
+ {
182
+ "type": 0,
183
+ "value": "Maximum "
184
+ },
185
+ {
186
+ "type": 1,
187
+ "value": "value"
188
+ },
189
+ {
190
+ "type": 0,
191
+ "value": " characters"
192
+ }
193
+ ],
194
+ "TZ4WUk": [
195
+ {
196
+ "type": 0,
197
+ "value": "Password requires "
198
+ },
199
+ {
200
+ "type": 1,
201
+ "value": "value"
202
+ },
203
+ {
204
+ "type": 0,
205
+ "value": " characters"
206
+ }
207
+ ],
208
+ "UNttd+": [
209
+ {
210
+ "type": 0,
211
+ "value": "Confirm"
212
+ }
213
+ ],
214
+ "URJDrG": [
215
+ {
216
+ "type": 0,
217
+ "value": "Sign up"
218
+ }
219
+ ],
220
+ "WU/CqP": [
221
+ {
222
+ "type": 0,
223
+ "value": "Passwords are not the same"
224
+ }
225
+ ],
226
+ "XKyo5X": [
227
+ {
228
+ "type": 0,
229
+ "value": "File Upload"
230
+ }
231
+ ],
232
+ "XreZg+": [
233
+ {
234
+ "type": 0,
235
+ "value": "Registered Email"
236
+ }
237
+ ],
238
+ "ZhaPt0": [
239
+ {
240
+ "type": 0,
241
+ "value": "Invalid Value for Field of type "
242
+ },
243
+ {
244
+ "type": 1,
245
+ "value": "type"
246
+ }
247
+ ],
248
+ "cGR2eI": [
249
+ {
250
+ "type": 0,
251
+ "value": "Confirmation"
252
+ }
253
+ ],
254
+ "d1YCuH": [
255
+ {
256
+ "type": 0,
257
+ "value": "Enter your email address"
258
+ }
259
+ ],
260
+ "e3IQoc": [
261
+ {
262
+ "type": 0,
263
+ "value": "New Password"
264
+ }
265
+ ],
266
+ "eRShvB": [
267
+ {
268
+ "type": 0,
269
+ "value": "Maximum files reached"
270
+ }
271
+ ],
272
+ "fDCMA6": [
273
+ {
274
+ "type": 0,
275
+ "value": "Select Files"
276
+ }
277
+ ],
278
+ "fOOwej": [
279
+ {
280
+ "offset": 0,
281
+ "options": {
282
+ "one": {
283
+ "value": [
284
+ {
285
+ "type": 0,
286
+ "value": "Up to "
287
+ },
288
+ {
289
+ "type": 7
290
+ },
291
+ {
292
+ "type": 0,
293
+ "value": " file"
294
+ }
295
+ ]
296
+ },
297
+ "other": {
298
+ "value": [
299
+ {
300
+ "type": 0,
301
+ "value": "Up to "
302
+ },
303
+ {
304
+ "type": 7
305
+ },
306
+ {
307
+ "type": 0,
308
+ "value": " files"
309
+ }
310
+ ]
311
+ }
312
+ },
313
+ "pluralType": "cardinal",
314
+ "type": 6,
315
+ "value": "max_files"
316
+ }
317
+ ],
318
+ "gy0Ynb": [
319
+ {
320
+ "type": 0,
321
+ "value": "Click or drag files here"
322
+ }
323
+ ],
324
+ "kdFYba": [
325
+ {
326
+ "type": 0,
327
+ "value": "Password field is required"
328
+ }
329
+ ],
330
+ "khMx/2": [
331
+ {
332
+ "type": 0,
333
+ "value": "An error occurred with your authentication. Please try again."
334
+ }
335
+ ],
336
+ "lY+cuM": [
337
+ {
338
+ "type": 0,
339
+ "value": "Confirm password"
340
+ }
341
+ ],
342
+ "lZvoYL": [
343
+ {
344
+ "type": 0,
345
+ "value": "Sign up now"
346
+ }
347
+ ],
348
+ "mZzmNV": [
349
+ {
350
+ "type": 0,
351
+ "value": "Recover Password"
352
+ }
353
+ ],
354
+ "oYpm71": [
355
+ {
356
+ "type": 0,
357
+ "value": "of "
358
+ },
359
+ {
360
+ "type": 1,
361
+ "value": "max"
362
+ }
363
+ ],
364
+ "oayEC3": [
365
+ {
366
+ "type": 0,
367
+ "value": "Sign up"
368
+ }
369
+ ],
370
+ "pwv2cR": [
371
+ {
372
+ "type": 0,
373
+ "value": "We have sent a confirmation code to your email address. Please enter the code below."
374
+ }
375
+ ],
376
+ "qTQ4hP": [
377
+ {
378
+ "type": 0,
379
+ "value": "An email has been sent to your address. Please check your inbox and follow the instructions to confirm your sign up."
380
+ }
381
+ ],
382
+ "qnQYqN": [
383
+ {
384
+ "type": 0,
385
+ "value": "You must accept the terms and conditions"
386
+ }
387
+ ],
388
+ "rskBv4": [
389
+ {
390
+ "type": 0,
391
+ "value": "Unlimited"
392
+ }
393
+ ],
394
+ "s1OmP0": [
395
+ {
396
+ "type": 0,
397
+ "value": "Confirmation code"
398
+ }
399
+ ],
400
+ "zr0OS6": [
401
+ {
402
+ "type": 1,
403
+ "value": "percentage"
404
+ },
405
+ {
406
+ "type": 0,
407
+ "value": "% used"
408
+ }
409
+ ]
410
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/react-auth",
3
- "version": "2.6.86",
3
+ "version": "2.6.89",
4
4
  "description": "ttoss authentication module for React apps.",
5
5
  "license": "MIT",
6
6
  "author": "ttoss",
@@ -26,17 +26,17 @@
26
26
  "sideEffects": false,
27
27
  "dependencies": {
28
28
  "react-error-boundary": "^6.0.0",
29
- "@ttoss/react-auth-core": "^0.2.56"
29
+ "@ttoss/react-auth-core": "^0.2.59"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "aws-amplify": "^6.0.0",
33
33
  "react": ">=16.8.0",
34
- "@ttoss/components": "^2.12.1",
35
- "@ttoss/forms": "^0.37.3",
36
- "@ttoss/logger": "^0.7.1",
34
+ "@ttoss/components": "^2.12.4",
35
+ "@ttoss/forms": "^0.38.0",
37
36
  "@ttoss/react-i18n": "^2.0.25",
38
- "@ttoss/react-notifications": "^2.5.9",
39
- "@ttoss/ui": "^6.4.0"
37
+ "@ttoss/logger": "^0.7.1",
38
+ "@ttoss/react-notifications": "^2.5.12",
39
+ "@ttoss/ui": "^6.5.0"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@jest/globals": "^29.7.0",
@@ -46,15 +46,15 @@
46
46
  "react": "^19.2.1",
47
47
  "tsup": "^8.5.1",
48
48
  "@ttoss/cloud-auth": "^0.13.11",
49
- "@ttoss/components": "^2.12.1",
49
+ "@ttoss/components": "^2.12.4",
50
50
  "@ttoss/config": "^1.35.12",
51
- "@ttoss/forms": "^0.37.3",
52
- "@ttoss/i18n-cli": "^0.7.38",
51
+ "@ttoss/forms": "^0.38.0",
53
52
  "@ttoss/logger": "^0.7.1",
53
+ "@ttoss/i18n-cli": "^0.7.38",
54
+ "@ttoss/react-notifications": "^2.5.12",
54
55
  "@ttoss/react-i18n": "^2.0.25",
55
- "@ttoss/react-notifications": "^2.5.9",
56
- "@ttoss/ui": "^6.4.0",
57
- "@ttoss/test-utils": "^4.0.2"
56
+ "@ttoss/test-utils": "^4.0.2",
57
+ "@ttoss/ui": "^6.5.0"
58
58
  },
59
59
  "keywords": [
60
60
  "React",