@solidstarters/solid-core-ui 1.1.16 → 1.1.17

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.
Files changed (167) hide show
  1. package/dist/components/auth/AuthLayout.d.ts +4 -0
  2. package/dist/components/auth/AuthLayout.d.ts.map +1 -0
  3. package/dist/components/auth/AuthLayout.js +80 -0
  4. package/dist/components/auth/AuthLayout.js.map +1 -0
  5. package/dist/components/auth/ForgotPasswordThankYou.d.ts +2 -0
  6. package/dist/components/auth/ForgotPasswordThankYou.d.ts.map +1 -0
  7. package/dist/components/auth/ForgotPasswordThankYou.js +16 -0
  8. package/dist/components/auth/ForgotPasswordThankYou.js.map +1 -0
  9. package/dist/components/auth/GoogleAuthChecking.d.ts +2 -0
  10. package/dist/components/auth/GoogleAuthChecking.d.ts.map +1 -0
  11. package/dist/components/auth/GoogleAuthChecking.js +99 -0
  12. package/dist/components/auth/GoogleAuthChecking.js.map +1 -0
  13. package/dist/components/auth/SolidChangeForcePassword.d.ts.map +1 -1
  14. package/dist/components/auth/SolidChangeForcePassword.js +44 -39
  15. package/dist/components/auth/SolidChangeForcePassword.js.map +1 -1
  16. package/dist/components/auth/SolidForgotPassword.d.ts.map +1 -1
  17. package/dist/components/auth/SolidForgotPassword.js +1 -2
  18. package/dist/components/auth/SolidForgotPassword.js.map +1 -1
  19. package/dist/components/auth/SolidInitialLoginOtp.d.ts +1 -3
  20. package/dist/components/auth/SolidInitialLoginOtp.d.ts.map +1 -1
  21. package/dist/components/auth/SolidInitialLoginOtp.js +16 -12
  22. package/dist/components/auth/SolidInitialLoginOtp.js.map +1 -1
  23. package/dist/components/auth/SolidInitiateRegisterOtp.d.ts +1 -3
  24. package/dist/components/auth/SolidInitiateRegisterOtp.d.ts.map +1 -1
  25. package/dist/components/auth/SolidInitiateRegisterOtp.js +16 -12
  26. package/dist/components/auth/SolidInitiateRegisterOtp.js.map +1 -1
  27. package/dist/components/auth/SolidLogin.d.ts.map +1 -1
  28. package/dist/components/auth/SolidLogin.js +12 -8
  29. package/dist/components/auth/SolidLogin.js.map +1 -1
  30. package/dist/components/auth/SolidRegister.d.ts.map +1 -1
  31. package/dist/components/auth/SolidRegister.js +13 -9
  32. package/dist/components/auth/SolidRegister.js.map +1 -1
  33. package/dist/components/auth/SolidResetPassword.d.ts +1 -4
  34. package/dist/components/auth/SolidResetPassword.d.ts.map +1 -1
  35. package/dist/components/auth/SolidResetPassword.js +14 -10
  36. package/dist/components/auth/SolidResetPassword.js.map +1 -1
  37. package/dist/components/common/GeneralSettings.d.ts +1 -3
  38. package/dist/components/common/GeneralSettings.d.ts.map +1 -1
  39. package/dist/components/common/GeneralSettings.js +21 -18
  40. package/dist/components/common/GeneralSettings.js.map +1 -1
  41. package/dist/components/common/NotFound.d.ts +2 -0
  42. package/dist/components/common/NotFound.d.ts.map +1 -0
  43. package/dist/components/common/NotFound.js +7 -0
  44. package/dist/components/common/NotFound.js.map +1 -0
  45. package/dist/components/common/SocialMediaLogin.d.ts.map +1 -1
  46. package/dist/components/common/SocialMediaLogin.js +3 -2
  47. package/dist/components/common/SocialMediaLogin.js.map +1 -1
  48. package/dist/components/common/SolidAdmin.d.ts +2 -0
  49. package/dist/components/common/SolidAdmin.d.ts.map +1 -0
  50. package/dist/components/common/SolidAdmin.js +5 -0
  51. package/dist/components/common/SolidAdmin.js.map +1 -0
  52. package/dist/components/common/SolidFormStepper.d.ts.map +1 -1
  53. package/dist/components/common/SolidFormStepper.js +8 -1
  54. package/dist/components/common/SolidFormStepper.js.map +1 -1
  55. package/dist/components/common/SolidThemeLink.d.ts +2 -0
  56. package/dist/components/common/SolidThemeLink.d.ts.map +1 -0
  57. package/dist/components/common/SolidThemeLink.js +5 -0
  58. package/dist/components/common/SolidThemeLink.js.map +1 -0
  59. package/dist/components/common/error.d.ts +9 -0
  60. package/dist/components/common/error.d.ts.map +1 -0
  61. package/dist/components/common/error.js +7 -0
  62. package/dist/components/common/error.js.map +1 -0
  63. package/dist/components/core/common/FilterComponent.js +7 -7
  64. package/dist/components/core/common/FilterComponent.js.map +1 -1
  65. package/dist/components/core/common/SolidConfigureLayoutElement.d.ts.map +1 -1
  66. package/dist/components/core/common/SolidConfigureLayoutElement.js +4 -3
  67. package/dist/components/core/common/SolidConfigureLayoutElement.js.map +1 -1
  68. package/dist/components/core/common/SolidGlobalSearchElement.d.ts.map +1 -1
  69. package/dist/components/core/common/SolidGlobalSearchElement.js +35 -15
  70. package/dist/components/core/common/SolidGlobalSearchElement.js.map +1 -1
  71. package/dist/components/core/form/SolidFormLayouts.d.ts +3 -0
  72. package/dist/components/core/form/SolidFormLayouts.d.ts.map +1 -0
  73. package/dist/components/core/form/SolidFormLayouts.js +57 -0
  74. package/dist/components/core/form/SolidFormLayouts.js.map +1 -0
  75. package/dist/components/core/form/SolidFormView.d.ts.map +1 -1
  76. package/dist/components/core/form/SolidFormView.js +13 -1
  77. package/dist/components/core/form/SolidFormView.js.map +1 -1
  78. package/dist/components/core/form/fields/SolidMediaMultipleField.d.ts.map +1 -1
  79. package/dist/components/core/form/fields/SolidMediaMultipleField.js +11 -7
  80. package/dist/components/core/form/fields/SolidMediaMultipleField.js.map +1 -1
  81. package/dist/components/core/form/fields/SolidMediaSingleField.js +3 -2
  82. package/dist/components/core/form/fields/SolidMediaSingleField.js.map +1 -1
  83. package/dist/components/core/form/fields/relations/SolidRelationManyToManyField.d.ts.map +1 -1
  84. package/dist/components/core/form/fields/relations/SolidRelationManyToManyField.js +4 -4
  85. package/dist/components/core/form/fields/relations/SolidRelationManyToManyField.js.map +1 -1
  86. package/dist/components/core/form/fields/relations/SolidRelationManyToOneField.js +1 -1
  87. package/dist/components/core/form/fields/relations/SolidRelationManyToOneField.js.map +1 -1
  88. package/dist/components/core/kanban/SolidKanbanView.js +2 -2
  89. package/dist/components/core/kanban/SolidKanbanView.js.map +1 -1
  90. package/dist/components/core/list/SolidListView.d.ts.map +1 -1
  91. package/dist/components/core/list/SolidListView.js +6 -28
  92. package/dist/components/core/list/SolidListView.js.map +1 -1
  93. package/dist/components/core/model/CreateModel.d.ts.map +1 -1
  94. package/dist/components/core/model/CreateModel.js +12 -1
  95. package/dist/components/core/model/CreateModel.js.map +1 -1
  96. package/dist/components/core/model/FieldMetaData.d.ts.map +1 -1
  97. package/dist/components/core/model/FieldMetaData.js +2 -2
  98. package/dist/components/core/model/FieldMetaData.js.map +1 -1
  99. package/dist/components/core/model/FieldMetaDataForm.js +21 -21
  100. package/dist/components/core/model/FieldMetaDataForm.js.map +1 -1
  101. package/dist/components/core/model/ModelMetaData.js +5 -5
  102. package/dist/components/core/module/CreateModule.d.ts.map +1 -1
  103. package/dist/components/core/module/CreateModule.js +5 -2
  104. package/dist/components/core/module/CreateModule.js.map +1 -1
  105. package/dist/components/core/users/CreateUser.js +2 -2
  106. package/dist/components/layout/AdminLayout.d.ts +4 -0
  107. package/dist/components/layout/AdminLayout.d.ts.map +1 -0
  108. package/dist/components/layout/AdminLayout.js +86 -0
  109. package/dist/components/layout/AdminLayout.js.map +1 -0
  110. package/dist/components/layout/AppConfig.d.ts.map +1 -1
  111. package/dist/components/layout/AppConfig.js +4 -9
  112. package/dist/components/layout/AppConfig.js.map +1 -1
  113. package/dist/components/layout/user-profile-menu.js +1 -1
  114. package/dist/components/layout/user-profile-menu.js.map +1 -1
  115. package/dist/index.d.ts +11 -0
  116. package/dist/index.d.ts.map +1 -1
  117. package/dist/index.js +12 -0
  118. package/dist/index.js.map +1 -1
  119. package/dist/nextAuth/authProviders.d.ts +4 -0
  120. package/dist/nextAuth/authProviders.d.ts.map +1 -0
  121. package/dist/nextAuth/authProviders.js +231 -0
  122. package/dist/nextAuth/authProviders.js.map +1 -0
  123. package/dist/nextAuth/refreshAccessToken.d.ts +2 -0
  124. package/dist/nextAuth/refreshAccessToken.d.ts.map +1 -0
  125. package/dist/nextAuth/refreshAccessToken.js +76 -0
  126. package/dist/nextAuth/refreshAccessToken.js.map +1 -0
  127. package/package.json +1 -1
  128. package/src/components/auth/AuthLayout.tsx +126 -0
  129. package/src/components/auth/ForgotPasswordThankYou.tsx +45 -0
  130. package/src/components/auth/GoogleAuthChecking.tsx +60 -0
  131. package/src/components/auth/SolidChangeForcePassword.tsx +21 -32
  132. package/src/components/auth/SolidForgotPassword.tsx +3 -2
  133. package/src/components/auth/SolidInitialLoginOtp.tsx +16 -8
  134. package/src/components/auth/SolidInitiateRegisterOtp.tsx +17 -9
  135. package/src/components/auth/SolidLogin.tsx +16 -10
  136. package/src/components/auth/SolidRegister.tsx +17 -9
  137. package/src/components/auth/SolidResetPassword.tsx +13 -6
  138. package/src/components/common/GeneralSettings.tsx +7 -2
  139. package/src/components/common/NotFound.tsx +22 -0
  140. package/src/components/common/SocialMediaLogin.tsx +24 -25
  141. package/src/components/common/SolidAdmin.tsx +7 -0
  142. package/src/components/common/SolidFormStepper.tsx +55 -2
  143. package/src/components/common/SolidThemeLink.tsx +5 -0
  144. package/src/components/common/error.tsx +30 -0
  145. package/src/components/core/common/FilterComponent.tsx +70 -70
  146. package/src/components/core/common/SolidConfigureLayoutElement.tsx +6 -1
  147. package/src/components/core/common/SolidGlobalSearchElement.tsx +45 -17
  148. package/src/components/core/form/SolidFormLayouts.tsx +93 -0
  149. package/src/components/core/form/SolidFormView.tsx +64 -3
  150. package/src/components/core/form/fields/SolidMediaMultipleField.tsx +14 -9
  151. package/src/components/core/form/fields/SolidMediaSingleField.tsx +3 -3
  152. package/src/components/core/form/fields/relations/SolidRelationManyToManyField.tsx +25 -23
  153. package/src/components/core/form/fields/relations/SolidRelationManyToOneField.tsx +1 -1
  154. package/src/components/core/kanban/SolidKanbanView.tsx +4 -4
  155. package/src/components/core/list/SolidListView.tsx +4 -61
  156. package/src/components/core/model/CreateModel.tsx +58 -0
  157. package/src/components/core/model/FieldMetaData.tsx +2 -0
  158. package/src/components/core/model/FieldMetaDataForm.tsx +26 -26
  159. package/src/components/core/model/ModelMetaData.tsx +5 -5
  160. package/src/components/core/module/CreateModule.tsx +11 -3
  161. package/src/components/core/users/CreateUser.tsx +2 -2
  162. package/src/components/layout/AdminLayout.tsx +62 -0
  163. package/src/components/layout/AppConfig.tsx +4 -3
  164. package/src/components/layout/user-profile-menu.tsx +1 -1
  165. package/src/index.ts +17 -1
  166. package/src/nextAuth/authProviders.tsx +220 -0
  167. package/src/nextAuth/refreshAccessToken.tsx +27 -0
@@ -0,0 +1,220 @@
1
+ import CredentialsProvider from "next-auth/providers/credentials";
2
+ import GoogleProvider from "next-auth/providers/google";
3
+ import { NextRequest } from "next/server";
4
+ import { jwtDecode } from "jwt-decode";
5
+ import { JWT } from "next-auth/jwt";
6
+ import axios from "axios";
7
+ import { signOut } from "next-auth/react";
8
+ import { refreshAccessToken } from "./refreshAccessToken";
9
+ import { NextAuthOptions } from "next-auth";
10
+
11
+ type Credentials = {
12
+ username: string,
13
+ email: string,
14
+ password: string,
15
+ accessToken: string,
16
+ accessCode: string,
17
+ };
18
+
19
+ const authProviders: NextAuthOptions = {
20
+ session: {
21
+ strategy: "jwt",
22
+ },
23
+ providers: [
24
+ GoogleProvider({
25
+ clientId: process.env.GOOGLE_ID!,
26
+ clientSecret: process.env.GOOGLE_CLIENT_SECRET!
27
+ }),
28
+ CredentialsProvider({
29
+ // @ts-ignore
30
+ async authorize(credentials: Credentials) {
31
+ const { username, email, password, accessToken, accessCode } = credentials;
32
+
33
+ try {
34
+ if (accessCode) {
35
+ let config = {
36
+ method: 'get',
37
+ url: `${process.env.API_URL}/api/iam/google/authenticate?accessCode=${accessCode}`,
38
+ };
39
+
40
+
41
+ const loginResponse = await axios.request(config);
42
+ console.log("loginResponse", loginResponse.data);
43
+
44
+ if (loginResponse.status == 400) {
45
+ throw new Error(loginResponse.data.message);
46
+ }
47
+ if (loginResponse.status == 401) {
48
+ throw new Error(loginResponse.data.message);
49
+ }
50
+
51
+ let base64decoded = jwtDecode(loginResponse.data.data.accessToken);
52
+ let accessTokenExpires = base64decoded.exp;
53
+
54
+ return {
55
+ accessToken: loginResponse.data.data.accessToken,
56
+ refreshToken: loginResponse.data.data.refreshToken,
57
+ accessTokenExpires: accessTokenExpires,
58
+ ...loginResponse.data.data,
59
+ };
60
+
61
+ } else {
62
+ if (accessToken) {
63
+ let data = JSON.stringify({
64
+ username: email,
65
+ email: email,
66
+ password: password
67
+ });
68
+
69
+ let config = {
70
+ method: 'get',
71
+ url: `${process.env.API_URL}/api/iam/me`,
72
+ headers: {
73
+ 'accept': '*/*',
74
+ 'Content-Type': 'application/json',
75
+ 'Authorization': `Bearer ${accessToken}`
76
+ }
77
+ };
78
+
79
+
80
+ const loginResponse = await axios.request(config);
81
+
82
+ if (loginResponse.status == 400) {
83
+ throw new Error(loginResponse.data.message);
84
+ }
85
+ if (loginResponse.status == 401) {
86
+ throw new Error(loginResponse.data.message);
87
+ }
88
+
89
+ let base64decoded = jwtDecode(loginResponse.data.data.accessToken);
90
+ let accessTokenExpires = base64decoded.exp;
91
+
92
+ return {
93
+ accessToken: loginResponse.data.data.accessToken,
94
+ refreshToken: loginResponse.data.data.refreshToken,
95
+ accessTokenExpires: accessTokenExpires,
96
+ ...loginResponse.data.data,
97
+ };
98
+
99
+ } else {
100
+
101
+ let data = JSON.stringify({
102
+ username: email,
103
+ email: email,
104
+ password: password
105
+ });
106
+
107
+ let config = {
108
+ method: 'post',
109
+ maxBodyLength: Infinity,
110
+ url: `${process.env.API_URL}/api/iam/authenticate`,
111
+ headers: {
112
+ 'accept': '*/*',
113
+ 'Content-Type': 'application/json'
114
+ },
115
+ data: data
116
+ };
117
+
118
+
119
+ const loginResponse = await axios.request(config);
120
+
121
+ // const authenticateResponse = await fetch(
122
+ // `${process.env.API_URL}/api/iam/authenticate`,
123
+ // {
124
+ // method: "Post",
125
+ // headers: {
126
+ // 'accept': '*/*',
127
+ // "Content-Type": "application/json"
128
+ // },
129
+ // body: JSON.stringify({
130
+ // username: email,
131
+ // email: email,
132
+ // password: password
133
+ // })
134
+ // }
135
+ // );
136
+
137
+ // const loginResponse = await authenticateResponse.json();
138
+
139
+ // const response = await fetch(
140
+ // `${process.env.API_URL}/api/iam/me`,
141
+ // {
142
+ // method: "Get",
143
+ // headers: {
144
+ // "Content-Type": "application/json",
145
+ // "Authorization": `Bearer ${loginResponse.data.accessToken}`,
146
+ // },
147
+ // }
148
+ // );
149
+
150
+ // const responseData = await response.json();
151
+
152
+ if (loginResponse.status == 400) {
153
+ throw new Error(loginResponse.data.message);
154
+ }
155
+ if (loginResponse.status == 401) {
156
+ throw new Error(loginResponse.data.data.message);
157
+ }
158
+ let base64decoded = jwtDecode(loginResponse.data.data.accessToken);
159
+ let accessTokenExpires = base64decoded.exp;
160
+ const returnResponse = {
161
+ accessToken: loginResponse.data.data.accessToken,
162
+ refreshToken: loginResponse.data.data.refreshToken,
163
+ accessTokenExpires: accessTokenExpires,
164
+ ...loginResponse.data.data,
165
+ }
166
+ return returnResponse;
167
+ }
168
+ }
169
+ } catch (error: any) {
170
+ throw new Error(error.message ? error.message : error?.response?.data?.message);
171
+ }
172
+ },
173
+ }),
174
+ ],
175
+ callbacks: {
176
+ // @ts-ignore
177
+ jwt: async ({ token, user }) => {
178
+ if (Date.now() >= (token.accessTokenExpires as number)) {
179
+ return refreshAccessToken(token); // Call the refresh token function
180
+ }
181
+
182
+ // If there is no user (first time login or session), we return the user data
183
+ if (user) {
184
+ const base64decoded = jwtDecode(user.accessToken);
185
+ const accessTokenExpires = base64decoded.exp && base64decoded.exp * 1000; // Convert from seconds to milliseconds
186
+ return {
187
+ ...token,
188
+ accessToken: user.accessToken,
189
+ refreshToken: user.refreshToken,
190
+ accessTokenExpires: accessTokenExpires,
191
+ user: user, // Include the user data here
192
+ };
193
+ }
194
+
195
+ return token; // If no update needed, just return the existing token
196
+ },
197
+ // @ts-ignore
198
+ session: async ({ session, token }) => {
199
+ const user = token.user || {}; // Default to an empty object if user is undefined or null
200
+ session.error = token.error ? token.error : null;
201
+ // if (token.error) {
202
+ // return null
203
+ // }
204
+ session.user = {
205
+ ...user, // Include the user info from the token
206
+ accessToken: token?.accessToken, // Add the access token to session for client use
207
+ refreshToken: token?.refreshToken, // Add refresh token to session for future use
208
+ accessTokenExpires: token?.accessTokenExpires && token?.accessTokenExpires, // Store the expiry time
209
+ };
210
+ return session;
211
+
212
+ },
213
+ },
214
+ pages: {
215
+ signIn: "/auth/login",
216
+ },
217
+ secret: process.env.NEXTAUTH_SECRET,
218
+ }
219
+
220
+ export default authProviders
@@ -0,0 +1,27 @@
1
+ import axios from "axios";
2
+ import { jwtDecode } from "jwt-decode";
3
+
4
+ export async function refreshAccessToken(token: any) {
5
+ try {
6
+ const response = await axios.post(
7
+ `${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/iam/refresh-tokens`,
8
+ { refreshToken: token.refreshToken }
9
+ );
10
+
11
+ const { accessToken, refreshToken } = response.data.data;
12
+ const { exp: accessTokenExpires } = jwtDecode<{ exp: number }>(accessToken);
13
+
14
+ return {
15
+ ...token,
16
+ accessToken,
17
+ refreshToken,
18
+ accessTokenExpires: accessTokenExpires * 1000, // Convert seconds to milliseconds
19
+ };
20
+ } catch (error: any) {
21
+ console.error("Failed to refresh access token:", error.message || error.response?.data);
22
+ return {
23
+ // ...token,
24
+ error: "RefreshAccessTokenError",
25
+ };
26
+ }
27
+ }