@tachybase/plugin-auth-sms 1.3.16 → 1.3.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.
@@ -1,4 +1,4 @@
1
1
  (function(e,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("@tachybase/client"),require("@tachybase/module-auth/client"),require("react/jsx-runtime"),require("react-i18next"),require("antd"),require("react"),require("@tachybase/schema")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","@tachybase/module-auth/client","react/jsx-runtime","react-i18next","antd","react","@tachybase/schema"],t):(e=typeof globalThis!="undefined"?globalThis:e||self,t(e["@tachybase/plugin-auth-sms"]={},e["@tachybase/client"],e["@tachybase/module-auth"],e.jsxRuntime,e["react-i18next"],e.antd,e.react,e["@tachybase/schema"]))})(this,function(e,t,a,o,d,i,h,l){"use strict";var b=(e,t,a)=>new Promise((o,d)=>{var i=r=>{try{l(a.next(r))}catch(x){d(x)}},h=r=>{try{l(a.throw(r))}catch(x){d(x)}},l=r=>r.done?o(r.value):Promise.resolve(r.value).then(i,h);l((a=a.apply(e,t)).next())});const r="SMS",x="auth-sms";function A(){return d.useTranslation(x)}const M=()=>{const{t:s}=A();return o.jsx(t.SchemaComponent,{scope:{t:s},schema:{type:"object",properties:{sms:{type:"void",properties:{public:{type:"object",properties:{autoSignup:{"x-decorator":"FormItem",type:"boolean",title:'{{t("Sign up automatically when the user does not exist")}}',"x-component":"Checkbox"},agreeMust:{"x-decorator":"FormItem",type:"boolean",title:'{{t("Must agree to the agreement")}}',"x-component":"Checkbox"},agreeCode:{"x-decorator":"FormItem",type:"string",title:'{{t("Agree to the agreement text (html supported)")}}',"x-component":"Input.TextArea"}}}}}}}})};function v({targetFieldName:s="phone",actionType:u,value:p,onChange:n}){const{t:m}=d.useTranslation(),g=t.useAPIClient(),f=l.useForm(),[c,I]=h.useState(0),S=h.useRef(null);h.useEffect(()=>{c<=0&&S.current&&clearInterval(S.current)},[c]);function k(){return b(this,null,function*(){if(!(c>0))try{const{data:{data:y}}=yield g.resource("verifications").create({values:{type:u,phone:f.values[s]}});i.message.success(m("Operation succeeded")),p&&n("");const q=y.expiresAt?Math.ceil((Date.parse(y.expiresAt)-Date.now())/1e3):60;I(q),S.current=setInterval(()=>{I(P=>P-1)},1e3)}catch(y){console.error(y)}})}return o.jsxs("fieldset",{className:t.css`
2
2
  display: flex;
3
3
  gap: 0.5em;
4
- `,children:[o.jsx(i.Input,{value:p,onChange:n,placeholder:m("Verification code")}),o.jsx(i.Button,{onClick:k,disabled:c>0,children:c>0?m("Retry after {{count}} seconds",{count:c}):m("Send code")})]})}const F=({value:s,onChange:u,htmlCode:p=""})=>o.jsx(i.Checkbox,{checked:s,onChange:n=>u(n.target.checked),children:o.jsx("span",{dangerouslySetInnerHTML:{__html:p}})}),T={type:"object",name:"phoneForm","x-component":"Form",properties:{phone:{type:"string",required:!0,"x-component":"Input","x-validator":"phone","x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Phone")}}',style:{}}},code:{type:"string",required:!0,"x-component":"VerificationCode","x-component-props":{actionType:"auth:signIn",targetFieldName:"phone"},"x-decorator":"FormItem"},agree:{type:"boolean","x-component":"HtmlAgreementCheckbox","x-component-props":{htmlCode:"{{ agreeCode }}"},"x-visible":"{{ agreeMust }}"},actions:{title:'{{t("Sign in")}}',type:"void","x-component":"Action","x-component-props":{htmlType:"submit",block:!0,type:"primary",useAction:"{{ useSMSSignIn }}",style:{width:"100%"}},"x-reactions":[{dependencies:["agree"],fulfill:{state:{disabled:"{{ agreeMust && $deps[0] !== true }}"}}}]},tip:{type:"void","x-component":"div","x-content":'{{t("User will be registered automatically if not exists.", {ns: "sms-auth"})}}',"x-component-props":{style:{color:"#ccc"}},"x-visible":"{{ autoSignup }}"}}},j=s=>{const u=s.authenticator,{name:p,options:n}=u,m=!!(n!=null&&n.autoSignup),g=!!n.agreeMust,f=n.agreeCode,c=()=>a.useSignIn(p);return o.jsx(t.SchemaComponent,{schema:T,scope:{useSMSSignIn:c,autoSignup:m,agreeMust:g,agreeCode:f},components:{VerificationCode:v,HtmlAgreementCheckbox:F}})};class C extends t.Plugin{load(){return b(this,null,function*(){this.app.pm.get(a).registerType(r,{components:{SignInForm:j,AdminSettingsForm:M}})})}}e.SmsAuthPlugin=C,e.default=C,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
4
+ `,children:[o.jsx(i.Input,{value:p,onChange:n,placeholder:m("Verification code")}),o.jsx(i.Button,{onClick:k,disabled:c>0,children:c>0?m("Retry after {{count}} seconds",{count:c}):m("Send code")})]})}const F=({value:s,onChange:u,htmlCode:p=""})=>o.jsx(i.Checkbox,{checked:s,onChange:n=>u(n.target.checked),children:o.jsx("span",{dangerouslySetInnerHTML:{__html:p}})}),T={type:"object",name:"phoneForm","x-component":"Form",properties:{phone:{type:"string",required:!0,"x-component":"Input","x-validator":"phone","x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Phone")}}',style:{}}},code:{type:"string",required:!0,"x-component":"VerificationCode","x-component-props":{actionType:"auth:signIn",targetFieldName:"phone"},"x-decorator":"FormItem"},agree:{type:"boolean","x-component":"HtmlAgreementCheckbox","x-component-props":{htmlCode:"{{ agreeCode }}"},"x-visible":"{{ agreeMust }}"},actions:{title:'{{t("Sign in")}}',type:"void","x-component":"Action","x-component-props":{htmlType:"submit",block:!0,type:"primary",useAction:"{{ useSMSSignIn }}",style:{width:"100%"}},"x-reactions":[{dependencies:["agree"],fulfill:{state:{disabled:"{{ agreeMust && $deps[0] !== true }}"}}}]},tip:{type:"void","x-component":"div","x-content":'{{t("User will be registered automatically if not exists.", {ns: "auth-sms"})}}',"x-component-props":{style:{color:"#ccc"}},"x-visible":"{{ autoSignup }}"}}},j=s=>{const u=s.authenticator,{name:p,options:n}=u,m=!!(n!=null&&n.autoSignup),g=!!n.agreeMust,f=n.agreeCode,c=()=>a.useSignIn(p);return o.jsx(t.SchemaComponent,{schema:T,scope:{useSMSSignIn:c,autoSignup:m,agreeMust:g,agreeCode:f},components:{VerificationCode:v,HtmlAgreementCheckbox:F}})};class C extends t.Plugin{load(){return b(this,null,function*(){this.app.pm.get(a).registerType(r,{components:{SignInForm:j,AdminSettingsForm:M}})})}}e.SmsAuthPlugin=C,e.default=C,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,12 +1,12 @@
1
1
  module.exports = {
2
2
  "react": "18.3.1",
3
- "@tachybase/client": "1.3.16",
4
- "@tachybase/module-auth": "1.3.16",
5
- "@tachybase/schema": "1.3.16",
3
+ "@tachybase/client": "1.3.17",
4
+ "@tachybase/module-auth": "1.3.17",
5
+ "@tachybase/schema": "1.3.17",
6
6
  "antd": "5.22.5",
7
7
  "react-i18next": "15.2.0",
8
- "@tachybase/plugin-otp": "1.3.16",
9
- "@tachybase/server": "1.3.16",
10
- "@tachybase/auth": "1.3.16",
11
- "@tachybase/database": "1.3.16"
8
+ "@tachybase/plugin-otp": "1.3.17",
9
+ "@tachybase/server": "1.3.17",
10
+ "@tachybase/auth": "1.3.17",
11
+ "@tachybase/database": "1.3.17"
12
12
  };
package/dist/index.js CHANGED
@@ -26,12 +26,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var src_exports = {};
30
- __export(src_exports, {
29
+ var index_exports = {};
30
+ __export(index_exports, {
31
31
  default: () => import_server.default
32
32
  });
33
- module.exports = __toCommonJS(src_exports);
34
- __reExport(src_exports, require("./server"), module.exports);
33
+ module.exports = __toCommonJS(index_exports);
34
+ __reExport(index_exports, require("./server"), module.exports);
35
35
  var import_server = __toESM(require("./server"));
36
36
  // Annotate the CommonJS export names for ESM import in node:
37
37
  0 && (module.exports = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tachybase/plugin-auth-sms",
3
3
  "displayName": "Auth: SMS",
4
- "version": "1.3.16",
4
+ "version": "1.3.17",
5
5
  "description": "SMS authentication.",
6
6
  "keywords": [
7
7
  "Authentication"
@@ -13,17 +13,17 @@
13
13
  "antd": "5.22.5",
14
14
  "react": "~18.3.1",
15
15
  "react-i18next": "^15.2.0",
16
- "@tachybase/schema": "1.3.16"
16
+ "@tachybase/schema": "1.3.17"
17
17
  },
18
18
  "peerDependencies": {
19
- "@tachybase/actions": "1.3.16",
20
- "@tachybase/client": "1.3.16",
21
- "@tachybase/auth": "1.3.16",
22
- "@tachybase/plugin-otp": "1.3.16",
23
- "@tachybase/module-auth": "1.3.16",
24
- "@tachybase/server": "1.3.16",
25
- "@tachybase/test": "1.3.16",
26
- "@tachybase/database": "1.3.16"
19
+ "@tachybase/actions": "1.3.17",
20
+ "@tachybase/auth": "1.3.17",
21
+ "@tachybase/client": "1.3.17",
22
+ "@tachybase/module-auth": "1.3.17",
23
+ "@tachybase/database": "1.3.17",
24
+ "@tachybase/plugin-otp": "1.3.17",
25
+ "@tachybase/server": "1.3.17",
26
+ "@tachybase/test": "1.3.17"
27
27
  },
28
28
  "description.zh-CN": "通过短信验证码认证身份。",
29
29
  "displayName.zh-CN": "认证:短信",