Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@keystonehq/sdk

Package Overview
Dependencies
Maintainers
2
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@keystonehq/sdk - npm Package Compare versions

Comparing version 0.6.1-alpha.3 to 0.6.3-alpha.0

dist/error.d.ts

1

dist/hooks/useAnimatedQRCodeReader.d.ts

@@ -11,2 +11,3 @@ /// <reference types="react" />

cameraReady: boolean;
showError: (msg: string) => void;
}];

@@ -7,2 +7,3 @@ /// <reference types="react" />

cameraReady: boolean;
showError: (msg: string) => void;
}];
import sdk from './service';
export { SupportedResult } from './types';
export { URTypeError } from './error';
export default sdk;

35

dist/sdk.cjs.development.js

@@ -162,2 +162,11 @@ 'use strict';

class URTypeError extends Error {
constructor(msg) {
super(msg); // Set the prototype explicitly.
Object.setPrototypeOf(this, URTypeError.prototype);
}
}
const QrReader = /*#__PURE__*/React__default.lazy(() => new Promise(function (resolve) { resolve(_interopNamespace(require('react-qr-reader'))); }));

@@ -211,5 +220,9 @@ const useAnimatedQRCodeReader = () => {

});
if (!foundExpected) throw new Error(`received ur type ${result.type}, but expected [${expectTypes.join(',')}]`);
if (!foundExpected) throw new URTypeError(`received ur type ${result.type}, but expected [${expectTypes.join(',')}]`);
}
} catch (e) {
if (e instanceof URTypeError) {
throw e;
}
setError(e.message);

@@ -279,2 +292,3 @@ }

},
showError: errorMessage => setError(errorMessage),
cameraReady

@@ -373,3 +387,4 @@ }];

read,
cameraReady
cameraReady,
showError
}] = useAnimatedQRCodeReader();

@@ -439,3 +454,4 @@

},
cameraReady
cameraReady,
showError
}];

@@ -448,5 +464,6 @@ };

play,
cameraReady
cameraReady,
showError
}] = useController();
setupSdk(read, play, cameraReady);
setupSdk(read, play, cameraReady, showError);
return Controller;

@@ -459,2 +476,3 @@ });

let cameraReady;
let showError;

@@ -470,3 +488,3 @@ const bootstrap = () => {

const setupSdk = (r, p, status) => {
const setupSdk = (r, p, status, setError) => {
initialized = true;

@@ -476,2 +494,3 @@ read = r;

cameraReady = status;
showError = setError;
};

@@ -485,3 +504,4 @@ const sdk = {

play,
cameraReady
cameraReady,
showError
};

@@ -501,3 +521,4 @@ } else {

exports.URTypeError = URTypeError;
exports.default = sdk;
//# sourceMappingURL=sdk.cjs.development.js.map

@@ -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")),i=require("rxjs"),A=e(require("qrcode.react")),l=require("events"),o=require("@ngraveio/bc-ur");const s=({size:e=200,data:t="",ecl:r="L"})=>n.createElement(A,{value:t,size:e,level:r}),c={minWidth:"16rem",height:"3rem",background:"#784FFE",borderColor:"grey",borderRadius:"8px",borderWidth:1,color:"white",outline:"none",margin:2},m=e=>{const{onClick:t,children:r}=e;return n.createElement("button",{onClick:t,style:c},r)},d=e=>n.createElement("div",{style:{width:"100%",marginTop:"1rem",display:"flex",flexDirection:"row-reverse",alignItems:"center",justifyContent:"center"}},e.children),u=new o.UR(Buffer.from("NO DATA","utf-8")),y=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")))}))),g=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+ElE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kVnDJWgLQQaAV45iw3k5oKsAMySb9UDcVaKuduUYWiX1xDObPJI/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},"Click here to view detailed tutorial")),n.createElement(m,{onClick:e.onButtonClick},"Sync Keystone")),E={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 f=()=>{const[e,{read:t,play:A,cameraReady:c}]=(()=>{const[e,t]=r.useState(!1),[A,c]=r.useState(!1),[f,p]=r.useState(""),[S,h]=r.useState(""),[v,w]=r.useState("play"),[b,{play:x}]=(()=>{const[e,t]=r.useState(u),[a,A]=r.useState(!1),[c,y]=r.useState(100),[g,E]=r.useState(!1),[f,p]=r.useState(null),[S,h]=r.useState(null),v=r.useMemo(()=>new o.UREncoder(e),[e]),[w,b]=r.useState(v.nextPart()),x=r.useMemo(()=>new l.EventEmitter,[]);return r.useEffect(()=>{v.cbor.toString("hex")!==u.cbor.toString("hex")&&A(!0)},[v]),r.useEffect(()=>{const e=i.interval(c).subscribe(()=>{b(v.nextPart())});return()=>{e.unsubscribe()}},[c,v]),[a?n.createElement("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"}},f&&n.createElement("p",{style:{fontSize:"1.25rem",fontWeight:"bold"}},f),n.createElement(s,{size:288,data:w}),S&&n.createElement("p",{style:{fontSize:"1rem",textAlign:"center"}},S),n.createElement(d,null,n.createElement(m,{onClick:()=>{x.emit("finish",!0)}},g?"Continue":"Finish"))):n.createElement("div",null),{play:(e,r)=>new Promise(n=>{t(e),r&&(r.refreshSpeed&&y(r.refreshSpeed),r.hasNext&&E(r.hasNext),r.title&&p(r.title),r.description&&h(r.description)),x.once("finish",()=>{t(u),A(!1),y(100),n()})})}]})(),[B,{read:C,cameraReady:R}]=(()=>{const[e,t]=r.useState(!1),[a,i]=r.useState([]),[A,s]=r.useState(new o.URDecoder),[c,u]=r.useState(""),g=r.useMemo(()=>new l.EventEmitter,[]),[E,f]=r.useState(null),[p,S]=r.useState(0),[h,v]=r.useState(null),w=()=>{s(new o.URDecoder),u("")};return[n.createElement("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"}},E&&n.createElement("p",{style:{fontSize:"1.25rem",fontWeight:"bold"}},E),h&&n.createElement("p",{style:{fontSize:"1rem",textAlign:"center"}},h),n.createElement(r.Suspense,{fallback:n.createElement("div",null)},n.createElement(y,{onScan:e=>{e&&(e=>{try{if(A.isComplete()){const e=A.resultUR();let t=!1;if(a.forEach(r=>{if(r===e.type)return t=!0,void g.emit("read",{result:e,status:"success"})}),!t)throw new Error(`received ur type ${e.type}, but expected [${a.join(",")}]`)}else A.receivePart(e),S(A.getProgress())}catch(e){u(e.message)}})(e)},onLoad:()=>{t(!0)},delay:100,style:{width:"100%"},onError:e=>{u(e.message)}})),n.createElement("p",null,(100*p).toFixed(0)," %"),c&&n.createElement("p",{style:{color:"red",fontSize:"1rem"}},c),n.createElement(d,null,n.createElement(m,{onClick:()=>{g.emit("read",{status:"canceled"})}},"Close"),c&&n.createElement(m,{onClick:()=>{w()}},"Retry"))),{read:(e,t)=>new Promise(r=>{i(e),t&&(t.title&&f(t.title),t.description&&v(t.description)),g.once("read",e=>{w(),r(e)})}),cameraReady:e}]})(),D=()=>{t(!1),w("play")};return[n.createElement(a,{isOpen:e,style:E},n.createElement("div",{onClick:()=>t(!1)},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",boxSizing:"border-box",padding:18,flex:1,flexDirection:"column",alignItems:"center",justifyContent:"center"}},A?n.createElement(g,{walletMode:f,link:S,onButtonClick:()=>{c(!1),w("read")}}):null,A||"read"!==v?b:B)),{play:async(e,r)=>{t(!0),w("play"),await x(e,r),D()},read:async(e,r)=>{if(r.renderInitial){c(!0),p(r.renderInitial.walletMode),h(r.renderInitial.link),t(!0);const n=await C(e,r);return D(),n}{w("read"),t(!0);const n=await C(e,r);return D(),n}},cameraReady:R}]})();return w(t,A,c),e};let p,S,h,v=!1;const w=(e,t,r)=>{v=!0,p=e,S=t,h=r},b={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(f),r)},getSdk:()=>{if(v)return{read:p,play:S,cameraReady:h};throw new Error("SDK is not initialized")}};var x;(x=exports.SupportedResult||(exports.SupportedResult={})).UR_BYTES="bytes",x.UR_CRYPTO_HDKEY="crypto-hdkey",x.UR_ETH_SIGN_REQUEST="eth-sign-request",x.UR_ETH_SIGNATURE="eth-signature",exports.default=b;
"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")),o=require("rxjs"),i=e(require("qrcode.react")),l=require("events"),A=require("@ngraveio/bc-ur");const s=({size:e=200,data:t="",ecl:r="L"})=>n.createElement(i,{value:t,size:e,level:r}),c={minWidth:"16rem",height:"3rem",background:"#784FFE",borderColor:"grey",borderRadius:"8px",borderWidth:1,color:"white",outline:"none",margin:2},m=e=>{const{onClick:t,children:r}=e;return n.createElement("button",{onClick:t,style:c},r)},u=e=>n.createElement("div",{style:{width:"100%",marginTop:"1rem",display:"flex",flexDirection:"row-reverse",alignItems:"center",justifyContent:"center"}},e.children),d=new A.UR(Buffer.from("NO DATA","utf-8"));class y extends Error{constructor(e){super(e),Object.setPrototypeOf(this,y.prototype)}}const E=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")))}))),g=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,iVBORw0KGgoAAAANSUhEUgAAACAA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KbZehXGygw6XmAQrEU0C77TETxII3ofA6zrrZR+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},"Click here to view detailed tutorial")),n.createElement(m,{onClick:e.onButtonClick},"Sync Keystone")),p={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 f=()=>{const[e,{read:t,play:i,cameraReady:c,showError:f}]=(()=>{const[e,t]=r.useState(!1),[i,c]=r.useState(!1),[f,h]=r.useState(""),[S,w]=r.useState(""),[v,b]=r.useState("play"),[x,{play:B}]=(()=>{const[e,t]=r.useState(d),[a,i]=r.useState(!1),[c,y]=r.useState(100),[E,g]=r.useState(!1),[p,f]=r.useState(null),[h,S]=r.useState(null),w=r.useMemo(()=>new A.UREncoder(e),[e]),[v,b]=r.useState(w.nextPart()),x=r.useMemo(()=>new l.EventEmitter,[]);return r.useEffect(()=>{w.cbor.toString("hex")!==d.cbor.toString("hex")&&i(!0)},[w]),r.useEffect(()=>{const e=o.interval(c).subscribe(()=>{b(w.nextPart())});return()=>{e.unsubscribe()}},[c,w]),[a?n.createElement("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"}},p&&n.createElement("p",{style:{fontSize:"1.25rem",fontWeight:"bold"}},p),n.createElement(s,{size:288,data:v}),h&&n.createElement("p",{style:{fontSize:"1rem",textAlign:"center"}},h),n.createElement(u,null,n.createElement(m,{onClick:()=>{x.emit("finish",!0)}},E?"Continue":"Finish"))):n.createElement("div",null),{play:(e,r)=>new Promise(n=>{t(e),r&&(r.refreshSpeed&&y(r.refreshSpeed),r.hasNext&&g(r.hasNext),r.title&&f(r.title),r.description&&S(r.description)),x.once("finish",()=>{t(d),i(!1),y(100),n()})})}]})(),[C,{read:R,cameraReady:D,showError:k}]=(()=>{const[e,t]=r.useState(!1),[a,o]=r.useState([]),[i,s]=r.useState(new A.URDecoder),[c,d]=r.useState(""),g=r.useMemo(()=>new l.EventEmitter,[]),[p,f]=r.useState(null),[h,S]=r.useState(0),[w,v]=r.useState(null),b=()=>{s(new A.URDecoder),d("")};return[n.createElement("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"}},p&&n.createElement("p",{style:{fontSize:"1.25rem",fontWeight:"bold"}},p),w&&n.createElement("p",{style:{fontSize:"1rem",textAlign:"center"}},w),n.createElement(r.Suspense,{fallback:n.createElement("div",null)},n.createElement(E,{onScan:e=>{e&&(e=>{try{if(i.isComplete()){const e=i.resultUR();let t=!1;if(a.forEach(r=>{if(r===e.type)return t=!0,void g.emit("read",{result:e,status:"success"})}),!t)throw new y(`received ur type ${e.type}, but expected [${a.join(",")}]`)}else i.receivePart(e),S(i.getProgress())}catch(e){if(e instanceof y)throw e;d(e.message)}})(e)},onLoad:()=>{t(!0)},delay:100,style:{width:"100%"},onError:e=>{d(e.message)}})),n.createElement("p",null,(100*h).toFixed(0)," %"),c&&n.createElement("p",{style:{color:"red",fontSize:"1rem"}},c),n.createElement(u,null,n.createElement(m,{onClick:()=>{g.emit("read",{status:"canceled"})}},"Close"),c&&n.createElement(m,{onClick:()=>{b()}},"Retry"))),{read:(e,t)=>new Promise(r=>{o(e),t&&(t.title&&f(t.title),t.description&&v(t.description)),g.once("read",e=>{b(),r(e)})}),showError:e=>d(e),cameraReady:e}]})(),U=()=>{t(!1),b("play")};return[n.createElement(a,{isOpen:e,style:p},n.createElement("div",{onClick:()=>t(!1)},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",boxSizing:"border-box",padding:18,flex:1,flexDirection:"column",alignItems:"center",justifyContent:"center"}},i?n.createElement(g,{walletMode:f,link:S,onButtonClick:()=>{c(!1),b("read")}}):null,i||"read"!==v?x:C)),{play:async(e,r)=>{t(!0),b("play"),await B(e,r),U()},read:async(e,r)=>{if(r.renderInitial){c(!0),h(r.renderInitial.walletMode),w(r.renderInitial.link),t(!0);const n=await R(e,r);return U(),n}{b("read"),t(!0);const n=await R(e,r);return U(),n}},cameraReady:D,showError:k}]})();return x(t,i,c,f),e};let h,S,w,v,b=!1;const x=(e,t,r,n)=>{b=!0,h=e,S=t,w=r,v=n},B={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(f),r)},getSdk:()=>{if(b)return{read:h,play:S,cameraReady:w,showError:v};throw new Error("SDK is not initialized")}};var C;(C=exports.SupportedResult||(exports.SupportedResult={})).UR_BYTES="bytes",C.UR_CRYPTO_HDKEY="crypto-hdkey",C.UR_ETH_SIGN_REQUEST="eth-sign-request",C.UR_ETH_SIGNATURE="eth-signature",exports.URTypeError=y,exports.default=B;
//# sourceMappingURL=sdk.cjs.production.min.js.map

@@ -136,2 +136,11 @@ import ReactDOM from 'react-dom';

class URTypeError extends Error {
constructor(msg) {
super(msg); // Set the prototype explicitly.
Object.setPrototypeOf(this, URTypeError.prototype);
}
}
const QrReader = /*#__PURE__*/React.lazy(() => import('react-qr-reader'));

@@ -185,5 +194,9 @@ const useAnimatedQRCodeReader = () => {

});
if (!foundExpected) throw new Error(`received ur type ${result.type}, but expected [${expectTypes.join(',')}]`);
if (!foundExpected) throw new URTypeError(`received ur type ${result.type}, but expected [${expectTypes.join(',')}]`);
}
} catch (e) {
if (e instanceof URTypeError) {
throw e;
}
setError(e.message);

@@ -253,2 +266,3 @@ }

},
showError: errorMessage => setError(errorMessage),
cameraReady

@@ -347,3 +361,4 @@ }];

read,
cameraReady
cameraReady,
showError
}] = useAnimatedQRCodeReader();

@@ -413,3 +428,4 @@

},
cameraReady
cameraReady,
showError
}];

@@ -422,5 +438,6 @@ };

play,
cameraReady
cameraReady,
showError
}] = useController();
setupSdk(read, play, cameraReady);
setupSdk(read, play, cameraReady, showError);
return Controller;

@@ -433,2 +450,3 @@ });

let cameraReady;
let showError;

@@ -444,3 +462,3 @@ const bootstrap = () => {

const setupSdk = (r, p, status) => {
const setupSdk = (r, p, status, setError) => {
initialized = true;

@@ -450,2 +468,3 @@ read = r;

cameraReady = status;
showError = setError;
};

@@ -459,3 +478,4 @@ const sdk = {

play,
cameraReady
cameraReady,
showError
};

@@ -478,3 +498,3 @@ } else {

export default sdk;
export { SupportedResult };
export { SupportedResult, URTypeError };
//# sourceMappingURL=sdk.esm.js.map
import { Play, Read } from './types';
export declare const setupSdk: (r: Read, p: Play, status: boolean) => void;
export declare const setupSdk: (r: Read, p: Play, status: boolean, setError: (msg: string) => void) => void;
declare const sdk: {

@@ -9,4 +9,5 @@ bootstrap: () => void;

cameraReady: boolean;
showError: Function;
};
};
export default sdk;
{
"name": "@keystonehq/sdk",
"version": "0.6.1-alpha.3",
"version": "0.6.3-alpha.0",
"description": "Keystone airgaped wallet SDK",

@@ -46,3 +46,3 @@ "author": "aaronisme <aarondongchen@gmail.com>",

},
"gitHead": "83f26f2a96853331db6e811f87cf804dae6b7481"
"gitHead": "d96f70ae54c9d49ac2d0be558f22f1564ed89284"
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc