zigap-utils 0.0.469 → 0.0.472

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.
@@ -0,0 +1 @@
1
+ export { default as useZigap } from './useZigap';
@@ -1,4 +1,5 @@
1
1
  import { LoginResultType } from 'src/components';
2
2
 
3
3
  export declare const LOGIN_RES_KEY = "loginRes";
4
- export declare const useZigap: () => LoginResultType | undefined;
4
+ declare const useZigap: () => LoginResultType | undefined;
5
+ export default useZigap;
package/dist/index.cjs.js CHANGED
@@ -52,4 +52,4 @@ React keys must be passed directly to JSX without using spread:
52
52
 
53
53
  Nonce: ${r}`,await this.sendMessage(e,t);const{publicKey:i,signature:y,address:x,network:u,nickName:o}=await this.getAccountCrypto();if(!Vf.xphereVerify(t,i,y))throw new Error("Verification failed");return{address:x,network:u,signature:y,publicKey:i,nickName:o}}else throw new Error("Verification failed")}catch(a){return Promise.reject(a)}finally{vt.leaveRoom(e)}}}const v1=new x1;class b1{generateQrCode(e,t,r,a){const i=Y0.lib.WordArray.random(16).toString(Y0.enc.Hex);let y="";return e==="login"?y=`https://zigap.io/qrCode/scan?type=login&roomId=${i}&dapp=${t}&url=${r}&network=${a}`:e==="send"?y=`zigap://send?roomId=${i}&dapp=${t}`:e==="provide"&&(y=`zigap://provide?roomId=${i}&dapp=${t}`),vt.joinRoom(i),{qrCode:y,roomId:i}}}const ti=new b1,p1="loginRes",y1=()=>{const[f,e]=H0.useState(void 0);return H0.useEffect(()=>{const t=localStorage.getItem("loginRes");t&&e(JSON.parse(t))},[]),f},sa="data:image/svg+xml,%3csvg%20width='167'%20height='166'%20viewBox='0%200%20167%20166'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M116.052%20115.296H166.355H166.36V0H51.0675V50.3042H0.759995V165.6H116.052V115.296ZM90.3366%2065.3428L40.21%20115.296H40.4307L40.2551%20115.471H101.014V150.561H15.7981V65.3428H90.3366ZM76.7327%20100.257H151.317V15.0386H66.1006V50.1536L109.424%2050.3042H126.684L126.624%2050.364L126.669%2050.3642L113.846%2063.1431L76.7327%20100.257Z'%20fill='url(%23paint0_linear_2322_66)'/%3e%3cdefs%3e%3clinearGradient%20id='paint0_linear_2322_66'%20x1='167.74'%20y1='-2.07'%20x2='-3.37985'%20y2='172.5'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%231349F8'/%3e%3cstop%20offset='1'%20stop-color='%235C13F8'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e",g1=({availableNetworks:f,dapp:e,url:t,sigMessage:r,validTime:a,onReceive:i,isShowLogo:y=!1,logoSize:x=30,...u})=>{const[o,c]=H0.useState(!0),v=Vf.generateNonce(16),{qrCode:b,roomId:B}=ti.generateQrCode("login",e,t,f);return H0.useEffect(()=>{const w=setTimeout(()=>{vt.leaveRoom(B),c(!1)},a*60*1e3);return()=>clearTimeout(w)},[B,a]),H0.useEffect(()=>{(async()=>{try{console.log("roomId",B);const R={isSuccess:!0,account:{address:"aaa",network:"bbb",nickName:"ccc"},payload:{publicKey:"ddd",message:"eee"},signature:"fff"};localStorage.setItem(p1,JSON.stringify(R));const k=await v1.qrLogin(B,r,v),z=`${r}
54
54
 
55
- Nonce: ${v}`,F={publicKey:k.publicKey,message:z},T={isSuccess:!0,account:{address:k.address,network:k.network,nickName:k.nickName},payload:F,signature:k.signature};i(T)}catch{i({isSuccess:!1})}})()},[i,r]),o?vr.jsx(ln,{value:b,...y&&{imageSettings:{src:sa,width:x,height:x,excavate:!1}},...u}):vr.jsx("div",{children:"QR loading error"})};class m1{isAccountType(e){return typeof e=="object"&&e!==null&&typeof e.address=="string"&&typeof e.network=="string"&&typeof e.nickName=="string"}getAccount(){return new Promise((e,t)=>{vt.onMessageReceived("addressProvide",r=>{this.isAccountType(r)?e(r):t(new Error("Invalid address"))})})}async qrAddressProvide(e){try{return await this.getAccount()}catch(t){return Promise.reject(t)}finally{vt.leaveRoom(e)}}}const _1=new m1,A1=({availableNetworks:f,dapp:e,url:t,validTime:r,onReceive:a,isShowLogo:i=!1,logoSize:y=30,...x})=>{const[u,o]=H0.useState(!0),{qrCode:c,roomId:v}=ti.generateQrCode("provide",e,t,f);return H0.useEffect(()=>{const b=setTimeout(()=>{vt.leaveRoom(v),o(!1)},r*60*1e3);return()=>clearTimeout(b)},[v,r]),H0.useEffect(()=>{(async()=>{try{console.log("roomId22",v);const B=await _1.qrAddressProvide(v),w={isSuccess:!0,address:B.address,network:B.network,nickName:B.nickName};a(w)}catch{a({isSuccess:!1})}})()},[a]),u?vr.jsx(ln,{value:c,...i&&{imageSettings:{src:sa,width:y,height:y,excavate:!1}},...x}):vr.jsx("div",{children:"QR loading error"})};class E1{base64url(e){return Y0.enc.Base64.stringify(Y0.enc.Utf8.parse(e)).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}createToken(e,t){const r={type:"token",alg:"XPSIG"},a=this.base64url(JSON.stringify(r)),i=this.base64url(JSON.stringify(e));return`${a}.${i}.${t}`}verifyToken(e){const[t,r,a]=e.split("."),i=JSON.parse(Y0.enc.Utf8.stringify(Y0.enc.Base64.parse(r)));if(Vf.xphereVerify(i.message,i.publicKey,a))return i;throw new Error("Invalid token")}getAddress(e){return mr.address(e)}}const w1=new E1,B1={Enc:fr,Sign:mr,Util:z0,Validation:w1},C1={Qr:ti},M1={Zigap:C1,useZigap:y1};exports.AddressProvideQR=A1;exports.LoginQR=g1;exports.Xphere=B1;exports.Zigap=M1;
55
+ Nonce: ${v}`,F={publicKey:k.publicKey,message:z},T={isSuccess:!0,account:{address:k.address,network:k.network,nickName:k.nickName},payload:F,signature:k.signature};i(T)}catch{i({isSuccess:!1})}})()},[i,r]),o?vr.jsx(ln,{value:b,...y&&{imageSettings:{src:sa,width:x,height:x,excavate:!1}},...u}):vr.jsx("div",{children:"QR loading error"})};class m1{isAccountType(e){return typeof e=="object"&&e!==null&&typeof e.address=="string"&&typeof e.network=="string"&&typeof e.nickName=="string"}getAccount(){return new Promise((e,t)=>{vt.onMessageReceived("addressProvide",r=>{this.isAccountType(r)?e(r):t(new Error("Invalid address"))})})}async qrAddressProvide(e){try{return await this.getAccount()}catch(t){return Promise.reject(t)}finally{vt.leaveRoom(e)}}}const _1=new m1,A1=({availableNetworks:f,dapp:e,url:t,validTime:r,onReceive:a,isShowLogo:i=!1,logoSize:y=30,...x})=>{const[u,o]=H0.useState(!0),{qrCode:c,roomId:v}=ti.generateQrCode("provide",e,t,f);return H0.useEffect(()=>{const b=setTimeout(()=>{vt.leaveRoom(v),o(!1)},r*60*1e3);return()=>clearTimeout(b)},[v,r]),H0.useEffect(()=>{(async()=>{try{console.log("roomId22",v);const B=await _1.qrAddressProvide(v),w={isSuccess:!0,address:B.address,network:B.network,nickName:B.nickName};a(w)}catch{a({isSuccess:!1})}})()},[a]),u?vr.jsx(ln,{value:c,...i&&{imageSettings:{src:sa,width:y,height:y,excavate:!1}},...x}):vr.jsx("div",{children:"QR loading error"})};class E1{base64url(e){return Y0.enc.Base64.stringify(Y0.enc.Utf8.parse(e)).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}createToken(e,t){const r={type:"token",alg:"XPSIG"},a=this.base64url(JSON.stringify(r)),i=this.base64url(JSON.stringify(e));return`${a}.${i}.${t}`}verifyToken(e){const[t,r,a]=e.split("."),i=JSON.parse(Y0.enc.Utf8.stringify(Y0.enc.Base64.parse(r)));if(Vf.xphereVerify(i.message,i.publicKey,a))return i;throw new Error("Invalid token")}getAddress(e){return mr.address(e)}}const w1=new E1,B1={Enc:fr,Sign:mr,Util:z0,Validation:w1},C1={Qr:ti};exports.AddressProvideQR=A1;exports.LoginQR=g1;exports.Xphere=B1;exports.Zigap=C1;exports.useZigap=y1;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './components';
2
- export { default as Xphere } from './xphere';
3
- export { default as Zigap } from './zigap';
2
+ export * from './xphere';
3
+ export * from './zigap';
4
+ export * from './hooks';
package/dist/index.es.js CHANGED
@@ -14043,13 +14043,13 @@ class y1 {
14043
14043
  };
14044
14044
  }
14045
14045
  }
14046
- const ri = new y1(), g1 = "loginRes", m1 = () => {
14046
+ const ri = new y1(), g1 = "loginRes", C1 = () => {
14047
14047
  const [f, e] = _r(void 0);
14048
14048
  return Ft(() => {
14049
14049
  const t = localStorage.getItem("loginRes");
14050
14050
  t && e(JSON.parse(t));
14051
14051
  }, []), f;
14052
- }, ca = "data:image/svg+xml,%3csvg%20width='167'%20height='166'%20viewBox='0%200%20167%20166'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M116.052%20115.296H166.355H166.36V0H51.0675V50.3042H0.759995V165.6H116.052V115.296ZM90.3366%2065.3428L40.21%20115.296H40.4307L40.2551%20115.471H101.014V150.561H15.7981V65.3428H90.3366ZM76.7327%20100.257H151.317V15.0386H66.1006V50.1536L109.424%2050.3042H126.684L126.624%2050.364L126.669%2050.3642L113.846%2063.1431L76.7327%20100.257Z'%20fill='url(%23paint0_linear_2322_66)'/%3e%3cdefs%3e%3clinearGradient%20id='paint0_linear_2322_66'%20x1='167.74'%20y1='-2.07'%20x2='-3.37985'%20y2='172.5'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%231349F8'/%3e%3cstop%20offset='1'%20stop-color='%235C13F8'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e", S1 = ({
14052
+ }, ca = "data:image/svg+xml,%3csvg%20width='167'%20height='166'%20viewBox='0%200%20167%20166'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M116.052%20115.296H166.355H166.36V0H51.0675V50.3042H0.759995V165.6H116.052V115.296ZM90.3366%2065.3428L40.21%20115.296H40.4307L40.2551%20115.471H101.014V150.561H15.7981V65.3428H90.3366ZM76.7327%20100.257H151.317V15.0386H66.1006V50.1536L109.424%2050.3042H126.684L126.624%2050.364L126.669%2050.3642L113.846%2063.1431L76.7327%20100.257Z'%20fill='url(%23paint0_linear_2322_66)'/%3e%3cdefs%3e%3clinearGradient%20id='paint0_linear_2322_66'%20x1='167.74'%20y1='-2.07'%20x2='-3.37985'%20y2='172.5'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%231349F8'/%3e%3cstop%20offset='1'%20stop-color='%235C13F8'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e", M1 = ({
14053
14053
  availableNetworks: f,
14054
14054
  dapp: e,
14055
14055
  url: t,
@@ -14118,7 +14118,7 @@ Nonce: ${v}`, F = {
14118
14118
  }
14119
14119
  ) : /* @__PURE__ */ vr.jsx("div", { children: "QR loading error" });
14120
14120
  };
14121
- class _1 {
14121
+ class m1 {
14122
14122
  // 타입 가드 함수
14123
14123
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
14124
14124
  isAccountType(e) {
@@ -14141,7 +14141,7 @@ class _1 {
14141
14141
  }
14142
14142
  }
14143
14143
  }
14144
- const A1 = new _1(), F1 = ({
14144
+ const _1 = new m1(), S1 = ({
14145
14145
  availableNetworks: f,
14146
14146
  dapp: e,
14147
14147
  url: t,
@@ -14164,7 +14164,7 @@ const A1 = new _1(), F1 = ({
14164
14164
  (async () => {
14165
14165
  try {
14166
14166
  console.log("roomId22", v);
14167
- const B = await A1.qrAddressProvide(v), w = {
14167
+ const B = await _1.qrAddressProvide(v), w = {
14168
14168
  isSuccess: !0,
14169
14169
  address: B.address,
14170
14170
  network: B.network,
@@ -14186,7 +14186,7 @@ const A1 = new _1(), F1 = ({
14186
14186
  }
14187
14187
  ) : /* @__PURE__ */ vr.jsx("div", { children: "QR loading error" });
14188
14188
  };
14189
- class E1 {
14189
+ class A1 {
14190
14190
  // Base64URL 인코딩 함수
14191
14191
  base64url(e) {
14192
14192
  return K0.enc.Base64.stringify(K0.enc.Utf8.parse(e)).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
@@ -14207,17 +14207,18 @@ class E1 {
14207
14207
  return mr.address(e);
14208
14208
  }
14209
14209
  }
14210
- const w1 = new E1(), D1 = {
14210
+ const E1 = new A1(), F1 = {
14211
14211
  Enc: rr,
14212
14212
  Sign: mr,
14213
14213
  Util: z0,
14214
- Validation: w1
14215
- }, B1 = {
14214
+ Validation: E1
14215
+ }, D1 = {
14216
14216
  Qr: ri
14217
- }, R1 = { Zigap: B1, useZigap: m1 };
14217
+ };
14218
14218
  export {
14219
- F1 as AddressProvideQR,
14220
- S1 as LoginQR,
14221
- D1 as Xphere,
14222
- R1 as Zigap
14219
+ S1 as AddressProvideQR,
14220
+ M1 as LoginQR,
14221
+ F1 as Xphere,
14222
+ D1 as Zigap,
14223
+ C1 as useZigap
14223
14224
  };
@@ -9,5 +9,5 @@ type XphereType = {
9
9
  Util: typeof Util;
10
10
  Validation: typeof Validation;
11
11
  };
12
- declare const Xphere: XphereType;
13
- export default Xphere;
12
+ export declare const Xphere: XphereType;
13
+ export {};
@@ -3,8 +3,5 @@ import { Qr } from './qr';
3
3
  type ZigapType = {
4
4
  Qr: typeof Qr;
5
5
  };
6
- declare const _default: {
7
- Zigap: ZigapType;
8
- useZigap: () => import('..').LoginResultType | undefined;
9
- };
10
- export default _default;
6
+ export declare const Zigap: ZigapType;
7
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zigap-utils",
3
- "version": "0.0.469",
3
+ "version": "0.0.472",
4
4
  "description": "",
5
5
  "main": "dist/index.es.js",
6
6
  "types": "dist/index.d.ts",