@springmicro/auth 0.5.3 → 0.5.5

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.
@@ -1,4 +1,4 @@
1
- import { i as D, t as ue, q as h, B as f, o as He, s as I, y as ce, C as ze, u as je, d as P, n as w, f as $, g as U, e as te } from "./Web3Auth-R27O2eCc.js";
1
+ import { i as D, t as ue, q as h, B as f, o as He, s as I, y as ce, C as ze, u as je, d as P, n as w, f as $, g as U, e as te } from "./Web3Auth-hzrmIcT1.js";
2
2
  function A(e) {
3
3
  if (!Number.isSafeInteger(e) || e < 0)
4
4
  throw new Error(`Wrong positive integer: ${e}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@springmicro/auth",
3
- "version": "0.5.3",
3
+ "version": "0.5.5",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -54,5 +54,5 @@
54
54
  "react-social-login-buttons": "^4.1.0",
55
55
  "uuid": "^9.0.1"
56
56
  },
57
- "gitHead": "049eb0491834ffa64dd66a1d965ccd3e5751d085"
57
+ "gitHead": "9ccb87063f4e9e3a6b51bf48c27c1323b3de2858"
58
58
  }
@@ -49,8 +49,6 @@ export type SignUpFormState = {
49
49
  type SignUpFormProps = {
50
50
  application: Application | null;
51
51
  applicationName?: string;
52
- CLIENT_ID: string;
53
- CLIENT_SECRET: string;
54
52
 
55
53
  // onUpdateAccount: (account: Account) => void;
56
54
  onUpdateApplication: (application: Application | null) => void;
@@ -80,19 +78,16 @@ function SignUpForm(props: SignUpFormProps) {
80
78
  return;
81
79
  }
82
80
 
83
- ApplicationBackend.getApplication(
84
- "admin",
85
- applicationName,
86
- props.CLIENT_ID,
87
- props.CLIENT_SECRET
88
- ).then((res: any) => {
89
- if (res.status === "error") {
90
- Setting.showMessage("error", res.msg);
91
- return;
92
- }
81
+ ApplicationBackend.getApplication("admin", applicationName).then(
82
+ (res: any) => {
83
+ if (res.status === "error") {
84
+ Setting.showMessage("error", res.msg);
85
+ return;
86
+ }
93
87
 
94
- onUpdateApplication(res.data);
95
- });
88
+ onUpdateApplication(res.data);
89
+ }
90
+ );
96
91
  };
97
92
  const getApplicationLogin = (oAuthParams: any) => {
98
93
  AuthBackend.getApplicationLogin(oAuthParams).then((res) => {
@@ -181,15 +176,7 @@ function SignUpForm(props: SignUpFormProps) {
181
176
  return application.signupItems?.map((signupItem, idx) => {
182
177
  return (
183
178
  <div key={idx}>
184
- {renderFormItem(
185
- application,
186
- signupItem,
187
- state,
188
- setState,
189
- t,
190
- props.CLIENT_ID,
191
- props.CLIENT_SECRET
192
- )}
179
+ {renderFormItem(application, signupItem, state, setState, t)}
193
180
  </div>
194
181
  );
195
182
  });
@@ -203,16 +190,12 @@ type SignUpProps = {
203
190
  applicationName: string;
204
191
  casdoorApiRoot: string;
205
192
  springmicroApiRoot?: string;
206
- CLIENT_ID: string;
207
- CLIENT_SECRET: string;
208
193
  };
209
194
 
210
195
  export function SignUp({
211
196
  applicationName,
212
197
  casdoorApiRoot,
213
198
  springmicroApiRoot,
214
- CLIENT_ID,
215
- CLIENT_SECRET,
216
199
  }: SignUpProps) {
217
200
  Setting.ROOT_URLS.casdoor = casdoorApiRoot;
218
201
  if (springmicroApiRoot) {
@@ -221,22 +204,19 @@ export function SignUp({
221
204
  const [state, setState] = React.useState<SignUpState>({ application: null });
222
205
 
223
206
  const getApplication = () => {
224
- ApplicationBackend.getApplication(
225
- "admin",
226
- applicationName,
227
- CLIENT_ID,
228
- CLIENT_SECRET
229
- ).then((res: any) => {
230
- console.log(res);
231
- if (res.status === "error") {
232
- Setting.showMessage("error", res.msg);
233
- return;
234
- }
207
+ ApplicationBackend.getApplication("admin", applicationName).then(
208
+ (res: any) => {
209
+ console.log(res);
210
+ if (res.status === "error") {
211
+ Setting.showMessage("error", res.msg);
212
+ return;
213
+ }
235
214
 
236
- setState({
237
- application: res.data,
238
- });
239
- });
215
+ setState({
216
+ application: res.data,
217
+ });
218
+ }
219
+ );
240
220
  };
241
221
 
242
222
  React.useEffect(() => {
@@ -254,8 +234,6 @@ export function SignUp({
254
234
  application: application,
255
235
  });
256
236
  }}
257
- CLIENT_ID={CLIENT_ID}
258
- CLIENT_SECRET={CLIENT_SECRET}
259
237
  />
260
238
  </I18nextProvider>
261
239
  );
@@ -287,8 +265,6 @@ export function SignUpProvider({
287
265
  applicationName,
288
266
  casdoorApiRoot,
289
267
  springmicroApiRoot,
290
- CLIENT_ID,
291
- CLIENT_SECRET,
292
268
  children,
293
269
  }: React.PropsWithChildren<SignUpProps>) {
294
270
  const { t, i18n } = useTranslation();
@@ -303,22 +279,19 @@ export function SignUpProvider({
303
279
  React.useState<Record<string, boolean>>({});
304
280
 
305
281
  const getApplication = () => {
306
- ApplicationBackend.getApplication(
307
- "admin",
308
- applicationName,
309
- CLIENT_ID,
310
- CLIENT_SECRET
311
- ).then((res: any) => {
312
- console.log(res);
313
- if (res.status === "error") {
314
- Setting.showMessage("error", res.msg);
315
- return;
316
- }
282
+ ApplicationBackend.getApplication("admin", applicationName).then(
283
+ (res: any) => {
284
+ console.log(res);
285
+ if (res.status === "error") {
286
+ Setting.showMessage("error", res.msg);
287
+ return;
288
+ }
317
289
 
318
- setState({
319
- application: res.data,
320
- });
321
- });
290
+ setState({
291
+ application: res.data,
292
+ });
293
+ }
294
+ );
322
295
  };
323
296
 
324
297
  const onUpdateApplication = (application: Application) => {
@@ -21,7 +21,7 @@ import { useTranslation } from "react-i18next";
21
21
 
22
22
  type ButtonClickArgsTuple = [
23
23
  dest: any,
24
- type: any,
24
+ type: string,
25
25
  applicationId: any,
26
26
  checkUser?: string
27
27
  ];
@@ -35,8 +35,6 @@ export type SendCodeInputProps = {
35
35
  application: Application;
36
36
  method: string;
37
37
  countryCode: string;
38
- CLIENT_ID: string;
39
- CLIENT_SECRET: string;
40
38
  };
41
39
 
42
40
  export const SendCodeInput = ({
@@ -48,8 +46,6 @@ export const SendCodeInput = ({
48
46
  application,
49
47
  method,
50
48
  countryCode,
51
- CLIENT_ID,
52
- CLIENT_SECRET,
53
49
  }: SendCodeInputProps) => {
54
50
  const { t } = useTranslation();
55
51
  const [visible, setVisible] = React.useState(false);
@@ -84,9 +80,7 @@ export const SendCodeInput = ({
84
80
  clientSecret,
85
81
  method,
86
82
  countryCode,
87
- ...onButtonClickArgs,
88
- CLIENT_ID,
89
- CLIENT_SECRET
83
+ ...onButtonClickArgs
90
84
  ).then((res: any) => {
91
85
  setButtonLoading(false);
92
86
  if (res) {
@@ -157,9 +157,7 @@ export function renderFormItem(
157
157
  signupItem: any,
158
158
  state: SignUpFormState,
159
159
  setState: React.Dispatch<React.SetStateAction<SignUpFormState>>,
160
- t: TFunction<"translation", undefined>,
161
- CLIENT_ID: string,
162
- CLIENT_SECRET: string
160
+ t: TFunction<"translation", undefined>
163
161
  ) {
164
162
  if (!signupItem.visible) {
165
163
  return null;
@@ -355,8 +353,6 @@ export function renderFormItem(
355
353
  onChange={(value: string) =>
356
354
  setState({ ...state, emailCode: value })
357
355
  }
358
- CLIENT_ID={CLIENT_ID}
359
- CLIENT_SECRET={CLIENT_SECRET}
360
356
  />
361
357
  }
362
358
  setFieldValue={setFieldValue}
@@ -59,21 +59,15 @@ export function getApplicationsByOrganization(
59
59
  ).then((res) => res.json());
60
60
  }
61
61
 
62
- export function getApplication(
63
- owner: string,
64
- name: string,
65
- CLIENT_ID: string,
66
- CLIENT_SECRET: string
67
- ) {
68
- console.log("ATTEMPTING TO GET APPLICATION");
62
+ export function getApplication(owner: string, name: string) {
69
63
  return fetch(
70
64
  `${
71
65
  Setting.ROOT_URLS.casdoor
72
66
  }/api/get-application?id=${owner}/${encodeURIComponent(name)}`,
73
67
  {
74
68
  method: "GET",
69
+ credentials: "include",
75
70
  headers: {
76
- Authorization: "Basic " + btoa(`${CLIENT_ID}:${CLIENT_SECRET}`),
77
71
  "Content-Type": "application/json",
78
72
  },
79
73
  }
@@ -170,9 +170,7 @@ export function sendCode(
170
170
  dest,
171
171
  type,
172
172
  applicationId,
173
- checkUser = "",
174
- CLIENT_ID,
175
- CLIENT_SECRET
173
+ checkUser = ""
176
174
  ) {
177
175
  const formData = new FormData();
178
176
  formData.append("captchaType", captchaType);
@@ -184,14 +182,13 @@ export function sendCode(
184
182
  formData.append("type", type);
185
183
  formData.append("applicationId", "admin/" + applicationId);
186
184
  formData.append("checkUser", checkUser);
187
- console.log(Object.fromEntries(formData.entries()));
185
+
188
186
  return fetch(`${ROOT_URLS.casdoor}/api/send-verification-code`, {
189
187
  method: "POST",
190
- // credentials: ROOT_URLS.casdoor.startsWith("https") ? "include" : undefined,
188
+ credentials: "include",
191
189
  body: formData,
192
190
  headers: {
193
- Authorization: "Basic " + btoa(`${CLIENT_ID}:${CLIENT_SECRET}`),
194
- "Content-Type": "application/json",
191
+ // "Content-Type": "application/json",
195
192
  "Accept-Language": getAcceptLanguage(),
196
193
  },
197
194
  })