@springmicro/auth 0.5.2 → 0.5.4

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--YGIRlpi.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.2",
3
+ "version": "0.5.4",
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": "431413a6efc5c939e85c79309967bdc6c88c9ee2"
57
+ "gitHead": "d806bf269ce2cbfa56b32b469d616b42e928ae46"
58
58
  }
@@ -1,149 +1,149 @@
1
- // Copyright 2021 The Casdoor Authors. All Rights Reserved.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- import React from "react";
16
- import i18next from "i18next";
17
- import * as UserBackend from "./util/user-api";
18
- import { CaptchaModal } from "./CaptchaModal";
19
- import type { Application } from "./util/provider";
20
- import { useTranslation } from "react-i18next";
21
-
22
- type ButtonClickArgsTuple = [
23
- dest: any,
24
- type: any,
25
- applicationId: any,
26
- checkUser?: string
27
- ];
28
-
29
- export type SendCodeInputProps = {
30
- value?: any;
31
- disabled: boolean;
32
- textBefore?: string;
33
- onChange: Function;
34
- onButtonClickArgs: ButtonClickArgsTuple;
35
- application: Application;
36
- method: string;
37
- countryCode: string;
38
- };
39
-
40
- export const SendCodeInput = ({
41
- value,
42
- disabled,
43
- textBefore,
44
- onChange,
45
- onButtonClickArgs,
46
- application,
47
- method,
48
- countryCode,
49
- }: SendCodeInputProps) => {
50
- const { t } = useTranslation();
51
- const [visible, setVisible] = React.useState(false);
52
- const [buttonLeftTime, setButtonLeftTime] = React.useState(0);
53
- const [buttonLoading, setButtonLoading] = React.useState(false);
54
- const dialogRef = React.useRef<HTMLElement | null>(null);
55
-
56
- const handleCountDown = (leftTime = 60) => {
57
- let leftTimeSecond = leftTime;
58
- setButtonLeftTime(leftTimeSecond);
59
- const countDown = () => {
60
- leftTimeSecond--;
61
- setButtonLeftTime(leftTimeSecond);
62
- if (leftTimeSecond === 0) {
63
- return;
64
- }
65
- setTimeout(countDown, 1000);
66
- };
67
- setTimeout(countDown, 1000);
68
- };
69
-
70
- const handleOk = (
71
- captchaType: string,
72
- captchaToken: string,
73
- clientSecret: string
74
- ) => {
75
- setVisible(false);
76
- setButtonLoading(true);
77
- UserBackend.sendCode(
78
- captchaType,
79
- captchaToken,
80
- clientSecret,
81
- method,
82
- countryCode,
83
- ...onButtonClickArgs
84
- ).then((res: any) => {
85
- setButtonLoading(false);
86
- if (res) {
87
- handleCountDown(60);
88
- }
89
- });
90
- };
91
-
92
- const handleCancel = () => {
93
- setVisible(false);
94
- };
95
-
96
- React.useEffect(() => {
97
- dialogRef.current = document.getElementById("captcha-modal");
98
- }, []);
99
-
100
- React.useEffect(() => {
101
- if (dialogRef.current) {
102
- if (visible) {
103
- // @ts-ignore
104
- dialogRef.current.showModal();
105
- } else {
106
- // @ts-ignore
107
- dialogRef.current.close();
108
- }
109
- }
110
- }, [visible]);
111
-
112
- return (
113
- <React.Fragment>
114
- <div className="flex">
115
- <input
116
- className="input"
117
- // addonBefore={textBefore}
118
- disabled={disabled}
119
- value={value}
120
- // prefix={<SafetyOutlined />}
121
- placeholder={"Enter your code"}
122
- onChange={(e: any) => onChange(e.target.value)}
123
- // onBlur={() => setVisible(true)}
124
- autoComplete="one-time-code"
125
- />
126
- <button
127
- className="btn"
128
- disabled={disabled || buttonLeftTime > 0}
129
- // loading={buttonLoading}
130
- onClick={() => setVisible(true)}
131
- >
132
- {buttonLeftTime > 0
133
- ? `${buttonLeftTime} s`
134
- : buttonLoading
135
- ? t("code.sending")
136
- : t("code.sendCode")}
137
- </button>
138
- </div>
139
- <CaptchaModal
140
- owner={application.owner}
141
- name={application.name}
142
- visible={visible}
143
- onOk={handleOk}
144
- onCancel={handleCancel}
145
- isCurrentProvider={false}
146
- />
147
- </React.Fragment>
148
- );
149
- };
1
+ // Copyright 2021 The Casdoor Authors. All Rights Reserved.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ import React from "react";
16
+ import i18next from "i18next";
17
+ import * as UserBackend from "./util/user-api";
18
+ import { CaptchaModal } from "./CaptchaModal";
19
+ import type { Application } from "./util/provider";
20
+ import { useTranslation } from "react-i18next";
21
+
22
+ type ButtonClickArgsTuple = [
23
+ dest: any,
24
+ type: any,
25
+ applicationId: any,
26
+ checkUser?: string
27
+ ];
28
+
29
+ export type SendCodeInputProps = {
30
+ value?: any;
31
+ disabled: boolean;
32
+ textBefore?: string;
33
+ onChange: Function;
34
+ onButtonClickArgs: ButtonClickArgsTuple;
35
+ application: Application;
36
+ method: string;
37
+ countryCode: string;
38
+ };
39
+
40
+ export const SendCodeInput = ({
41
+ value,
42
+ disabled,
43
+ textBefore,
44
+ onChange,
45
+ onButtonClickArgs,
46
+ application,
47
+ method,
48
+ countryCode,
49
+ }: SendCodeInputProps) => {
50
+ const { t } = useTranslation();
51
+ const [visible, setVisible] = React.useState(false);
52
+ const [buttonLeftTime, setButtonLeftTime] = React.useState(0);
53
+ const [buttonLoading, setButtonLoading] = React.useState(false);
54
+ const dialogRef = React.useRef<HTMLElement | null>(null);
55
+
56
+ const handleCountDown = (leftTime = 60) => {
57
+ let leftTimeSecond = leftTime;
58
+ setButtonLeftTime(leftTimeSecond);
59
+ const countDown = () => {
60
+ leftTimeSecond--;
61
+ setButtonLeftTime(leftTimeSecond);
62
+ if (leftTimeSecond === 0) {
63
+ return;
64
+ }
65
+ setTimeout(countDown, 1000);
66
+ };
67
+ setTimeout(countDown, 1000);
68
+ };
69
+
70
+ const handleOk = (
71
+ captchaType: string,
72
+ captchaToken: string,
73
+ clientSecret: string
74
+ ) => {
75
+ setVisible(false);
76
+ setButtonLoading(true);
77
+ UserBackend.sendCode(
78
+ captchaType,
79
+ captchaToken,
80
+ clientSecret,
81
+ method,
82
+ countryCode,
83
+ ...onButtonClickArgs
84
+ ).then((res: any) => {
85
+ setButtonLoading(false);
86
+ if (res) {
87
+ handleCountDown(60);
88
+ }
89
+ });
90
+ };
91
+
92
+ const handleCancel = () => {
93
+ setVisible(false);
94
+ };
95
+
96
+ React.useEffect(() => {
97
+ dialogRef.current = document.getElementById("captcha-modal");
98
+ }, []);
99
+
100
+ React.useEffect(() => {
101
+ if (dialogRef.current) {
102
+ if (visible) {
103
+ // @ts-ignore
104
+ dialogRef.current.showModal();
105
+ } else {
106
+ // @ts-ignore
107
+ dialogRef.current.close();
108
+ }
109
+ }
110
+ }, [visible]);
111
+
112
+ return (
113
+ <React.Fragment>
114
+ <div className="flex">
115
+ <input
116
+ className="input"
117
+ // addonBefore={textBefore}
118
+ disabled={disabled}
119
+ value={value}
120
+ // prefix={<SafetyOutlined />}
121
+ placeholder={"Enter your code"}
122
+ onChange={(e: any) => onChange(e.target.value)}
123
+ // onBlur={() => setVisible(true)}
124
+ autoComplete="one-time-code"
125
+ />
126
+ <button
127
+ className="btn"
128
+ disabled={disabled || buttonLeftTime > 0}
129
+ // loading={buttonLoading}
130
+ onClick={() => setVisible(true)}
131
+ >
132
+ {buttonLeftTime > 0
133
+ ? `${buttonLeftTime} s`
134
+ : buttonLoading
135
+ ? t("code.sending")
136
+ : t("code.sendCode")}
137
+ </button>
138
+ </div>
139
+ <CaptchaModal
140
+ owner={application.owner}
141
+ name={application.name}
142
+ visible={visible}
143
+ onOk={handleOk}
144
+ onCancel={handleCancel}
145
+ isCurrentProvider={false}
146
+ />
147
+ </React.Fragment>
148
+ );
149
+ };