@ttoss/react-auth 2.6.74 → 2.6.75

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/react-auth",
3
- "version": "2.6.74",
3
+ "version": "2.6.75",
4
4
  "description": "ttoss authentication module for React apps.",
5
5
  "license": "MIT",
6
6
  "author": "ttoss",
@@ -26,35 +26,35 @@
26
26
  "sideEffects": false,
27
27
  "dependencies": {
28
28
  "react-error-boundary": "^6.0.0",
29
- "@ttoss/react-auth-core": "^0.2.44"
29
+ "@ttoss/react-auth-core": "^0.2.45"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "aws-amplify": "^6.0.0",
33
33
  "react": ">=16.8.0",
34
- "@ttoss/components": "^2.10.1",
35
- "@ttoss/react-i18n": "^2.0.24",
36
- "@ttoss/forms": "^0.35.2",
37
- "@ttoss/logger": "^0.7.0",
38
- "@ttoss/ui": "^6.0.4",
39
- "@ttoss/react-notifications": "^2.4.38"
34
+ "@ttoss/components": "^2.10.2",
35
+ "@ttoss/forms": "^0.35.3",
36
+ "@ttoss/logger": "^0.7.1",
37
+ "@ttoss/react-i18n": "^2.0.25",
38
+ "@ttoss/react-notifications": "^2.4.39",
39
+ "@ttoss/ui": "^6.1.0"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@jest/globals": "^29.7.0",
43
- "@types/react": "^19.2.6",
43
+ "@types/react": "^19.2.7",
44
44
  "aws-amplify": "^6.11.0",
45
45
  "jest": "^30.2.0",
46
- "react": "^19.2.0",
46
+ "react": "^19.2.1",
47
47
  "tsup": "^8.5.1",
48
- "@ttoss/cloud-auth": "^0.13.10",
48
+ "@ttoss/cloud-auth": "^0.13.11",
49
+ "@ttoss/components": "^2.10.2",
49
50
  "@ttoss/config": "^1.35.12",
50
- "@ttoss/forms": "^0.35.2",
51
+ "@ttoss/logger": "^0.7.1",
52
+ "@ttoss/forms": "^0.35.3",
51
53
  "@ttoss/i18n-cli": "^0.7.38",
52
- "@ttoss/logger": "^0.7.0",
53
- "@ttoss/components": "^2.10.1",
54
- "@ttoss/react-notifications": "^2.4.38",
55
- "@ttoss/react-i18n": "^2.0.24",
56
- "@ttoss/test-utils": "^4.0.1",
57
- "@ttoss/ui": "^6.0.4"
54
+ "@ttoss/react-notifications": "^2.4.39",
55
+ "@ttoss/test-utils": "^4.0.2",
56
+ "@ttoss/react-i18n": "^2.0.25",
57
+ "@ttoss/ui": "^6.1.0"
58
58
  },
59
59
  "keywords": [
60
60
  "React",
package/dist/esm/index.js DELETED
@@ -1,235 +0,0 @@
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 };
package/dist/index.d.ts DELETED
@@ -1,18 +0,0 @@
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 };