@keystonehq/sdk
Advanced tools
Comparing version 0.14.1-alpha.1 to 0.14.1-alpha.2
@@ -68,4 +68,5 @@ 'use strict'; | ||
SupportedResult["UR_APTOS_SIGNATURE"] = "aptos-signature"; | ||
SupportedResult["UR_COSMOS_SIGN_REQUEST"] = "cosmos-sign-request"; | ||
SupportedResult["UR_COSMOS_SIGNATURE"] = "cosmos-ignature"; | ||
SupportedResult["UR_ARWEAVE_SIGN_REQUEST"] = "arweave-sign-request"; | ||
SupportedResult["UR_ARWEAVE_SIGNATURE"] = "arweave-signature"; | ||
SupportedResult["UR_ARWEAVE_CRYPTO_ACCOUNT"] = "arweave-crypto-account"; | ||
})(exports.SupportedResult || (exports.SupportedResult = {})); | ||
@@ -72,0 +73,0 @@ |
@@ -1,2 +0,2 @@ | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("react-dom")),r=require("react"),n=e(r),a=e(require("react-modal")),l=require("events"),i=require("rxjs"),s=e(require("qrcode.react")),o=require("@ngraveio/bc-ur");const A=({size:e=200,data:t="",ecl:r="L"})=>n.createElement(s,{value:t,size:e,level:r});var c,u,m;(c=exports.ReadStatus||(exports.ReadStatus={})).canceled="canceled",c.success="success",(u=exports.PlayStatus||(exports.PlayStatus={})).canceled="canceled",u.success="success",(m=exports.SupportedResult||(exports.SupportedResult={})).UR_BYTES="bytes",m.UR_CRYPTO_HDKEY="crypto-hdkey",m.UR_CRYPTO_ACCOUNT="crypto-account",m.UR_ETH_SIGN_REQUEST="eth-sign-request",m.UR_ETH_SIGNATURE="eth-signature",m.UR_CRYPTO_MULTI_ACCOUNTS="crypto-multi-accounts",m.UR_SOL_SIGN_REQUEST="sol-sign-request",m.UR_SOL_SIGNATURE="sol-signature",m.UR_APTOS_SIGN_REQUEST="aptos-sign-request",m.UR_APTOS_SIGNATURE="aptos-signature",m.UR_COSMOS_SIGN_REQUEST="cosmos-sign-request",m.UR_COSMOS_SIGNATURE="cosmos-ignature";const d={minWidth:"16rem",height:"3rem",background:"#784FFE",borderColor:"grey",borderRadius:"8px",borderWidth:1,color:"white",outline:"none",margin:2},y=e=>{const{onClick:t,children:r}=e;return n.createElement("button",{onClick:t,style:d},r)},g=e=>n.createElement("div",{style:{width:"100%",marginTop:"1rem",display:"flex",flexDirection:"row-reverse",alignItems:"center",justifyContent:"center"}},e.children),E=new o.UR(Buffer.from("NO DATA","utf-8"));class p extends Error{constructor(e){super(e),Object.setPrototypeOf(this,p.prototype)}}const S=()=>n.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",style:{margin:"auto",display:"block",shapeRendering:"auto",animationPlayState:"running",animationDelay:"0s"},width:"200px",height:"200px",viewBox:"0 0 100 100",preserveAspectRatio:"xMidYMid"},n.createElement("circle",{cx:"50",cy:"50",fill:"none",stroke:"#9b9b9b",strokeWidth:"7",r:"35",strokeDasharray:"164.93361431346415 56.97787143782138",style:{animationPlayState:"running",animationDelay:"0s"}},n.createElement("animateTransform",{attributeName:"transform",type:"rotate",repeatCount:"indefinite",dur:"1s",values:"0 50 50;360 50 50",keyTimes:"0;1",style:{animationPlayState:"running",animationDelay:"0s"}}))),f=n.lazy(()=>new Promise((function(e){e(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach((function(r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})})),t.default=e,t}(require("react-qr-reader")))})));let h="";const R=e=>n.createElement("div",{style:{paddingLeft:"1rem"}},n.createElement("div",{style:{display:"flex",alignItems:"center",padding:0}},n.createElement("img",{style:{display:"inline-block"},src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAoCAYAAACfKfiZAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAKAAAAACc9ikyAAAD+ElEQVRYCb1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LQQaAV45iw3k5oKsAMySb9UDcVaKuduUYWiX1xDObPJI/AHDBXhBsnvwiBZCXChAuA/nWdkQLxg0bJGOf8/tDtG9fxNKqNfisX4ZKamC/Gw/Zzs9e9GiL1Q5n0ICn6A5gQJ5KY7C4Ig33s90WibdXOsr3ud7wsoshcwiaAUPfegRm76syHgBylINaIX0c1hout8FecB/i/Uy23OedvZP/4Z5cDzSeAnYAZnK54P/BcahygHAD5dNh12tilAIPoLD0OnpwCV000AAAAASUVORK5CYII=",alt:""}),n.createElement("div",{style:{fontSize:"1.25rem",fontWeight:"bold",marginLeft:"1rem"}},"Sync Keystone")),n.createElement("ul",{style:{marginTop:"2rem",listStyleType:"none",padding:0,fontSize:"1rem"}},n.createElement("li",{style:{marginBottom:"0.75rem"}},"1. Turn on your Keystone hardware device"),n.createElement("li",{style:{marginBottom:"0.75rem"}},`2. Select your "${e.walletMode}" as your Watch-only wallet(Companion App)`),n.createElement("li",{style:{marginBottom:"0.75rem"}}," ",'3. Press the "Scan Keystone" button and scan the QR Code displayed on your Keystone hardware wallet'),n.createElement("li",{style:{marginBottom:"0.75rem"}}," ","4. Select account and check your watch-only wallet")),n.createElement("div",{style:{marginBottom:"1rem"}},n.createElement("a",{style:{marginTop:"1.25rem",color:"#784FFE",textDecoration:"none"},href:e.link,target:"_blank",rel:"noreferrer"},"Click here to view detailed tutorial")),n.createElement(y,{onClick:e.onButtonClick},"Sync Keystone")),v={overlay:{zIndex:999},content:{top:"50%",left:"50%",right:"auto",bottom:"auto",borderRadius:"10px",width:"37rem",marginRight:"-50%",transform:"translate(-50%, -50%)",postion:"relative"}};var x=()=>{const[e,{read:t,play:s,cameraReady:c}]=(()=>{const e=r.useMemo(()=>new l.EventEmitter,[]),[t,s]=r.useState(!1),[c,u]=r.useState(""),[m,d]=r.useState(""),[x,w]=r.useState(null),[b,{play:C}]=(()=>{const[e,t]=r.useState(E),[a,s]=r.useState(!1),[c,u]=r.useState(100),[m,d]=r.useState(400),[p,S]=r.useState(!1),[f,h]=r.useState(null),[R,v]=r.useState(null),x=r.useMemo(()=>new o.UREncoder(e,m),[e]),[w,b]=r.useState(x.nextPart()),C=r.useMemo(()=>new l.EventEmitter,[]);return r.useEffect(()=>{x.cbor.toString("hex")!==E.cbor.toString("hex")&&s(!0)},[x]),r.useEffect(()=>{const e=i.interval(c).subscribe(()=>{b(x.nextPart())});return()=>{e.unsubscribe()}},[c,x]),[a?n.createElement("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"}},f&&n.createElement("p",{style:{fontSize:"1.25rem",fontWeight:"bold"}},f),n.createElement(A,{size:288,data:w}),R&&n.createElement("p",{style:{fontSize:"1rem",textAlign:"center"}},R),n.createElement(g,null,n.createElement(y,{onClick:()=>{C.emit("finish",!0)}},p?"Scan Keystone":"Finish"))):n.createElement("div",null),{play:(e,r)=>new Promise(n=>{t(e),r&&(r.refreshSpeed&&u(r.refreshSpeed),r.hasNext&&S(r.hasNext),r.title&&h(r.title),r.description&&v(r.description),r.maxFragmentLength&&d(r.maxFragmentLength)),C.once("finish",()=>{t(E),s(!1),u(100),n(exports.PlayStatus.success)})})}]})(),[U,{read:B,cameraReady:T}]=(()=>{const[e,t]=r.useState(!1),[a,i]=r.useState([]),[s,A]=r.useState(new o.URDecoder),[c,u]=r.useState(""),m=r.useMemo(()=>new l.EventEmitter,[]),[d,E]=r.useState(null),[R,v]=r.useState(0),[x,w]=r.useState(null),b=()=>{A(new o.URDecoder),u("")};return[n.createElement("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"}},d&&n.createElement("p",{style:{fontSize:"1.25rem",fontWeight:"bold"}},d),x&&n.createElement("p",{style:{fontSize:"1rem",textAlign:"center"}},x),n.createElement(r.Suspense,{fallback:n.createElement("div",null)},n.createElement("div",{style:{position:"relative",width:"100%"}},e?null:n.createElement("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)"}},n.createElement(S,null)),n.createElement(f,{onScan:e=>{e&&(t(!0),((e,t)=>{try{if(s.isComplete()){const e=s.resultUR();let t=!1;if(a.forEach(r=>{if(r===e.type)return t=!0,void m.emit("read",{result:e,status:"success"})}),!t)throw new p(`received ur type ${e.type}, but expected [${a.join(",")}]`)}else s.receivePart(e),v(s.getProgress())}catch(e){u(e instanceof p?t:e.message)}})(e,h))},delay:100,style:{width:"100%"},onError:e=>{u(e.message)}}))),n.createElement("p",null,(100*R).toFixed(0)," %"),c&&n.createElement("p",{style:{color:"red",fontSize:"1rem"}},c),n.createElement(g,null,n.createElement(y,{onClick:()=>{m.emit("read",{status:"canceled"})}},"Close"),c&&n.createElement(y,{onClick:()=>{b()}},"Retry"))),{read:(e,t)=>new Promise(r=>{i(e),t&&(t.title&&E(t.title),t.description&&w(t.description),h=t.URTypeErrorMessage?t.URTypeErrorMessage:""),m.once("read",e=>{b(),r(e)})}),cameraReady:e}]})(),D=()=>{w(null),d(""),u(""),s(!1)};var P;return[n.createElement(a,{isOpen:t,style:v},n.createElement("div",{onClick:()=>{e.emit("close"),D()}},n.createElement("img",{style:{position:"absolute",top:"1rem",right:"1rem"},src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAADKADAAQAAAABAAAADAAAAAATDPpdAAAAmklEQVQoFZWRwQ3DIAwAa4brJPBP80hnaD/lD5N0iYxEfRVBxBGRwsvgO2PZklJaReTrvX/eTk7O+VVKuTtgDRYVPyOeHAysAFV40jCGEB69aHN/YSRZGK4JVuKu5/DrToDoqnI9tOh4vXJ2Qlc96kSY2lTfWs0m9DCT0r3MSkUrXR9r3eBCNbuDrY/td23z7Vg3wQhGIgcD+wPGY2fPvHuWagAAAABJRU5ErkJggg=="})),n.createElement("div",{style:{width:"35rem",padding:18,flex:1,flexDirection:"column",alignItems:"center",justifyContent:"center",color:"#002237"}},"initial"===(P=x)?n.createElement(R,{walletMode:c,link:m,onButtonClick:()=>{w("read")}}):"read"===P?U:"play"===P?b:null)),{play:(t,r)=>new Promise(n=>{e.once("close",()=>{n(exports.PlayStatus.canceled)}),s(!0),w("play"),C(t,r).then(()=>{D(),n(exports.PlayStatus.success)})}),read:async(t,r)=>new Promise(n=>{e.once("close",()=>{D(),n({status:exports.ReadStatus.canceled})}),r.renderInitial?(u(r.renderInitial.walletMode),d(r.renderInitial.link),w("initial"),s(!0),B(t,r).then(e=>{D(),n(e)})):(w("read"),s(!0),B(t,r).then(e=>{D(),n(e)}))}),cameraReady:T}]})();return B(t,s,c),e};let w,b,C,U=!1;const B=(e,t,r)=>{U=!0,w=e,b=t,C=r};exports.default={bootstrap:()=>{const e=document.getElementsByTagName("body").item(0),r=document.createElement("div");r.id="kv_sdk_container",e.appendChild(r),a.setAppElement("#kv_sdk_container"),t.render(n.createElement(x),r)},getSdk:()=>{if(U)return{read:w,play:b,cameraReady:C};throw new Error("SDK is not initialized")}}; | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("react-dom")),r=require("react"),n=e(r),a=e(require("react-modal")),l=require("events"),i=require("rxjs"),s=e(require("qrcode.react")),o=require("@ngraveio/bc-ur");const A=({size:e=200,data:t="",ecl:r="L"})=>n.createElement(s,{value:t,size:e,level:r});var c,u,m;(c=exports.ReadStatus||(exports.ReadStatus={})).canceled="canceled",c.success="success",(u=exports.PlayStatus||(exports.PlayStatus={})).canceled="canceled",u.success="success",(m=exports.SupportedResult||(exports.SupportedResult={})).UR_BYTES="bytes",m.UR_CRYPTO_HDKEY="crypto-hdkey",m.UR_CRYPTO_ACCOUNT="crypto-account",m.UR_ETH_SIGN_REQUEST="eth-sign-request",m.UR_ETH_SIGNATURE="eth-signature",m.UR_CRYPTO_MULTI_ACCOUNTS="crypto-multi-accounts",m.UR_SOL_SIGN_REQUEST="sol-sign-request",m.UR_SOL_SIGNATURE="sol-signature",m.UR_APTOS_SIGN_REQUEST="aptos-sign-request",m.UR_APTOS_SIGNATURE="aptos-signature",m.UR_ARWEAVE_SIGN_REQUEST="arweave-sign-request",m.UR_ARWEAVE_SIGNATURE="arweave-signature",m.UR_ARWEAVE_CRYPTO_ACCOUNT="arweave-crypto-account";const d={minWidth:"16rem",height:"3rem",background:"#784FFE",borderColor:"grey",borderRadius:"8px",borderWidth:1,color:"white",outline:"none",margin:2},y=e=>{const{onClick:t,children:r}=e;return n.createElement("button",{onClick:t,style:d},r)},E=e=>n.createElement("div",{style:{width:"100%",marginTop:"1rem",display:"flex",flexDirection:"row-reverse",alignItems:"center",justifyContent:"center"}},e.children),g=new o.UR(Buffer.from("NO DATA","utf-8"));class p extends Error{constructor(e){super(e),Object.setPrototypeOf(this,p.prototype)}}const S=()=>n.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",style:{margin:"auto",display:"block",shapeRendering:"auto",animationPlayState:"running",animationDelay:"0s"},width:"200px",height:"200px",viewBox:"0 0 100 100",preserveAspectRatio:"xMidYMid"},n.createElement("circle",{cx:"50",cy:"50",fill:"none",stroke:"#9b9b9b",strokeWidth:"7",r:"35",strokeDasharray:"164.93361431346415 56.97787143782138",style:{animationPlayState:"running",animationDelay:"0s"}},n.createElement("animateTransform",{attributeName:"transform",type:"rotate",repeatCount:"indefinite",dur:"1s",values:"0 50 50;360 50 50",keyTimes:"0;1",style:{animationPlayState:"running",animationDelay:"0s"}}))),f=n.lazy(()=>new Promise((function(e){e(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach((function(r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})})),t.default=e,t}(require("react-qr-reader")))})));let h="";const R=e=>n.createElement("div",{style:{paddingLeft:"1rem"}},n.createElement("div",{style:{display:"flex",alignItems:"center",padding:0}},n.createElement("img",{style:{display:"inline-block"},src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACA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3KbZehXGygw6XmAQrEU0C77TETxII3ofA6zrrZR+PIAvoBrhTEnvAPIBJZAIdQLzS8r8BkxGTNqq5AxLHocQY8iYxOIKuwCu4Sxkr8B7g5bLoIiYMTjoExAtOvTqASYiORtmmJCohxRfyBv3GeqkVnDJWgLQQaAV45iw3k5oKsAMySb9UDcVaKuduUYWiX1xDObPJI/AHDBXhBsnvwiBZCXChAuA/nWdkQLxg0bJGOf8/tDtG9fxNKqNfisX4ZKamC/Gw/Zzs9e9GiL1Q5n0ICn6A5gQJ5KY7C4Ig33s90WibdXOsr3ud7wsoshcwiaAUPfegRm76syHgBylINaIX0c1hout8FecB/i/Uy23OedvZP/4Z5cDzSeAnYAZnK54P/BcahygHAD5dNh12tilAIPoLD0OnpwCV000AAAAASUVORK5CYII=",alt:""}),n.createElement("div",{style:{fontSize:"1.25rem",fontWeight:"bold",marginLeft:"1rem"}},"Sync Keystone")),n.createElement("ul",{style:{marginTop:"2rem",listStyleType:"none",padding:0,fontSize:"1rem"}},n.createElement("li",{style:{marginBottom:"0.75rem"}},"1. Turn on your Keystone hardware device"),n.createElement("li",{style:{marginBottom:"0.75rem"}},`2. Select your "${e.walletMode}" as your Watch-only wallet(Companion App)`),n.createElement("li",{style:{marginBottom:"0.75rem"}}," ",'3. Press the "Scan Keystone" button and scan the QR Code displayed on your Keystone hardware wallet'),n.createElement("li",{style:{marginBottom:"0.75rem"}}," ","4. Select account and check your watch-only wallet")),n.createElement("div",{style:{marginBottom:"1rem"}},n.createElement("a",{style:{marginTop:"1.25rem",color:"#784FFE",textDecoration:"none"},href:e.link,target:"_blank",rel:"noreferrer"},"Click here to view detailed tutorial")),n.createElement(y,{onClick:e.onButtonClick},"Sync Keystone")),v={overlay:{zIndex:999},content:{top:"50%",left:"50%",right:"auto",bottom:"auto",borderRadius:"10px",width:"37rem",marginRight:"-50%",transform:"translate(-50%, -50%)",postion:"relative"}};var x=()=>{const[e,{read:t,play:s,cameraReady:c}]=(()=>{const e=r.useMemo(()=>new l.EventEmitter,[]),[t,s]=r.useState(!1),[c,u]=r.useState(""),[m,d]=r.useState(""),[x,w]=r.useState(null),[b,{play:C}]=(()=>{const[e,t]=r.useState(g),[a,s]=r.useState(!1),[c,u]=r.useState(100),[m,d]=r.useState(400),[p,S]=r.useState(!1),[f,h]=r.useState(null),[R,v]=r.useState(null),x=r.useMemo(()=>new o.UREncoder(e,m),[e]),[w,b]=r.useState(x.nextPart()),C=r.useMemo(()=>new l.EventEmitter,[]);return r.useEffect(()=>{x.cbor.toString("hex")!==g.cbor.toString("hex")&&s(!0)},[x]),r.useEffect(()=>{const e=i.interval(c).subscribe(()=>{b(x.nextPart())});return()=>{e.unsubscribe()}},[c,x]),[a?n.createElement("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"}},f&&n.createElement("p",{style:{fontSize:"1.25rem",fontWeight:"bold"}},f),n.createElement(A,{size:288,data:w}),R&&n.createElement("p",{style:{fontSize:"1rem",textAlign:"center"}},R),n.createElement(E,null,n.createElement(y,{onClick:()=>{C.emit("finish",!0)}},p?"Scan Keystone":"Finish"))):n.createElement("div",null),{play:(e,r)=>new Promise(n=>{t(e),r&&(r.refreshSpeed&&u(r.refreshSpeed),r.hasNext&&S(r.hasNext),r.title&&h(r.title),r.description&&v(r.description),r.maxFragmentLength&&d(r.maxFragmentLength)),C.once("finish",()=>{t(g),s(!1),u(100),n(exports.PlayStatus.success)})})}]})(),[U,{read:T,cameraReady:B}]=(()=>{const[e,t]=r.useState(!1),[a,i]=r.useState([]),[s,A]=r.useState(new o.URDecoder),[c,u]=r.useState(""),m=r.useMemo(()=>new l.EventEmitter,[]),[d,g]=r.useState(null),[R,v]=r.useState(0),[x,w]=r.useState(null),b=()=>{A(new o.URDecoder),u("")};return[n.createElement("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"}},d&&n.createElement("p",{style:{fontSize:"1.25rem",fontWeight:"bold"}},d),x&&n.createElement("p",{style:{fontSize:"1rem",textAlign:"center"}},x),n.createElement(r.Suspense,{fallback:n.createElement("div",null)},n.createElement("div",{style:{position:"relative",width:"100%"}},e?null:n.createElement("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)"}},n.createElement(S,null)),n.createElement(f,{onScan:e=>{e&&(t(!0),((e,t)=>{try{if(s.isComplete()){const e=s.resultUR();let t=!1;if(a.forEach(r=>{if(r===e.type)return t=!0,void m.emit("read",{result:e,status:"success"})}),!t)throw new p(`received ur type ${e.type}, but expected [${a.join(",")}]`)}else s.receivePart(e),v(s.getProgress())}catch(e){u(e instanceof p?t:e.message)}})(e,h))},delay:100,style:{width:"100%"},onError:e=>{u(e.message)}}))),n.createElement("p",null,(100*R).toFixed(0)," %"),c&&n.createElement("p",{style:{color:"red",fontSize:"1rem"}},c),n.createElement(E,null,n.createElement(y,{onClick:()=>{m.emit("read",{status:"canceled"})}},"Close"),c&&n.createElement(y,{onClick:()=>{b()}},"Retry"))),{read:(e,t)=>new Promise(r=>{i(e),t&&(t.title&&g(t.title),t.description&&w(t.description),h=t.URTypeErrorMessage?t.URTypeErrorMessage:""),m.once("read",e=>{b(),r(e)})}),cameraReady:e}]})(),D=()=>{w(null),d(""),u(""),s(!1)};var P;return[n.createElement(a,{isOpen:t,style:v},n.createElement("div",{onClick:()=>{e.emit("close"),D()}},n.createElement("img",{style:{position:"absolute",top:"1rem",right:"1rem"},src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAADKADAAQAAAABAAAADAAAAAATDPpdAAAAmklEQVQoFZWRwQ3DIAwAa4brJPBP80hnaD/lD5N0iYxEfRVBxBGRwsvgO2PZklJaReTrvX/eTk7O+VVKuTtgDRYVPyOeHAysAFV40jCGEB69aHN/YSRZGK4JVuKu5/DrToDoqnI9tOh4vXJ2Qlc96kSY2lTfWs0m9DCT0r3MSkUrXR9r3eBCNbuDrY/td23z7Vg3wQhGIgcD+wPGY2fPvHuWagAAAABJRU5ErkJggg=="})),n.createElement("div",{style:{width:"35rem",padding:18,flex:1,flexDirection:"column",alignItems:"center",justifyContent:"center",color:"#002237"}},"initial"===(P=x)?n.createElement(R,{walletMode:c,link:m,onButtonClick:()=>{w("read")}}):"read"===P?U:"play"===P?b:null)),{play:(t,r)=>new Promise(n=>{e.once("close",()=>{n(exports.PlayStatus.canceled)}),s(!0),w("play"),C(t,r).then(()=>{D(),n(exports.PlayStatus.success)})}),read:async(t,r)=>new Promise(n=>{e.once("close",()=>{D(),n({status:exports.ReadStatus.canceled})}),r.renderInitial?(u(r.renderInitial.walletMode),d(r.renderInitial.link),w("initial"),s(!0),T(t,r).then(e=>{D(),n(e)})):(w("read"),s(!0),T(t,r).then(e=>{D(),n(e)}))}),cameraReady:B}]})();return T(t,s,c),e};let w,b,C,U=!1;const T=(e,t,r)=>{U=!0,w=e,b=t,C=r};exports.default={bootstrap:()=>{const e=document.getElementsByTagName("body").item(0),r=document.createElement("div");r.id="kv_sdk_container",e.appendChild(r),a.setAppElement("#kv_sdk_container"),t.render(n.createElement(x),r)},getSdk:()=>{if(U)return{read:w,play:b,cameraReady:C};throw new Error("SDK is not initialized")}}; | ||
//# sourceMappingURL=sdk.cjs.production.min.js.map |
@@ -48,4 +48,5 @@ import ReactDOM from 'react-dom'; | ||
SupportedResult["UR_APTOS_SIGNATURE"] = "aptos-signature"; | ||
SupportedResult["UR_COSMOS_SIGN_REQUEST"] = "cosmos-sign-request"; | ||
SupportedResult["UR_COSMOS_SIGNATURE"] = "cosmos-ignature"; | ||
SupportedResult["UR_ARWEAVE_SIGN_REQUEST"] = "arweave-sign-request"; | ||
SupportedResult["UR_ARWEAVE_SIGNATURE"] = "arweave-signature"; | ||
SupportedResult["UR_ARWEAVE_CRYPTO_ACCOUNT"] = "arweave-crypto-account"; | ||
})(SupportedResult || (SupportedResult = {})); | ||
@@ -52,0 +53,0 @@ |
@@ -45,5 +45,6 @@ import { UR } from "@ngraveio/bc-ur"; | ||
UR_APTOS_SIGNATURE = "aptos-signature", | ||
UR_COSMOS_SIGN_REQUEST = "cosmos-sign-request", | ||
UR_COSMOS_SIGNATURE = "cosmos-ignature" | ||
UR_ARWEAVE_SIGN_REQUEST = "arweave-sign-request", | ||
UR_ARWEAVE_SIGNATURE = "arweave-signature", | ||
UR_ARWEAVE_CRYPTO_ACCOUNT = "arweave-crypto-account" | ||
} | ||
export {}; |
{ | ||
"name": "@keystonehq/sdk", | ||
"version": "0.14.1-alpha.1", | ||
"version": "0.14.1-alpha.2", | ||
"description": "Keystone airgaped wallet SDK", | ||
@@ -30,7 +30,9 @@ "author": "aaronisme <aarondongchen@gmail.com>", | ||
}, | ||
"peerDependencies": { | ||
"react": "*", | ||
"react-dom": "*" | ||
}, | ||
"dependencies": { | ||
"@ngraveio/bc-ur": "^1.0.0", | ||
"qrcode.react": "^1.0.1", | ||
"react": "16.13.1", | ||
"react-dom": "16.13.1", | ||
"react-modal": "^3.12.1", | ||
@@ -47,6 +49,9 @@ "react-qr-reader": "^2.2.1", | ||
"@types/qrcode.react": "^1.0.1", | ||
"@types/react-dom": "^17.0.9", | ||
"@types/react": "^16.0.0", | ||
"@types/react-dom": "^16.0.0", | ||
"@types/react-modal": "^3.12.0", | ||
"@types/react-qr-reader": "^2.1.3", | ||
"html-webpack-plugin": "^5.3.2", | ||
"react": "^16.0.0", | ||
"react-dom": "^16.0.0", | ||
"tsdx": "^0.14.1", | ||
@@ -58,3 +63,3 @@ "typescript": "^4.6.2", | ||
}, | ||
"gitHead": "6548069af0335bca09602c5fdaa9990b75b4fee2" | ||
"gitHead": "77958e4e7cf949e869b0cbb3ccbb23c499885772" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
162920
1311
14
+ Addedreact@16.14.017.0.218.3.1(transitive)
+ Addedreact-dom@16.14.018.3.1(transitive)
+ Addedscheduler@0.23.2(transitive)
- Removedreact@16.13.1
- Removedreact-dom@16.13.1
- Removedreact@16.13.1(transitive)
- Removedreact-dom@16.13.1(transitive)