New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@automata-network/pom-js-sdk

Package Overview
Dependencies
Maintainers
6
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@automata-network/pom-js-sdk - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

19

dist/index.d.ts

@@ -1,2 +0,2 @@

import { POMSocket, SocketConnectionResult } from '@automata-network/pom-socket';
import { POMSocket, getSocket, SocketConnectionResult } from '@automata-network/pom-socket';

@@ -24,11 +24,12 @@ declare enum POMOperation {

}
interface IdentityData {
identity: Uint8Array;
attestation?: Uint8Array;
interface AttestDeviceData {
platform: POMPlatform;
chainId: string;
attestation: string;
identity: string;
identitySignature: string;
}
interface AttestDeviceData extends IdentityData {
interface SignatureResult {
platform: POMPlatform;
chainId: string;
}
interface SignatureResult extends AttestDeviceData {
signature: string;

@@ -62,3 +63,3 @@ }

chainId: string;
identity: Uint8Array;
identity: string;
}

@@ -78,3 +79,3 @@ interface GetIdentityStatusOptions extends ChainIdOptions {

pomSocket: POMSocket;
constructor(socketUrl: string);
constructor(...[socketUrl, options]: Parameters<typeof getSocket>);
sign(options: SignatureOptions): Promise<SignatureResult>;

@@ -81,0 +82,0 @@ connectSocket(): Promise<SocketConnectionResult>;

@@ -1,2 +0,2 @@

"use strict";var e,t,n=require("@automata-network/pom-socket"),s=require("qs"),r=require("@nuintun/qrcode"),o=require("./util.js");exports.POMPlatform=void 0,(e=exports.POMPlatform||(exports.POMPlatform={})).Android="android",e.iOS="iOS",e.macOS="macOS",exports.IdentityStatus=void 0,(t=exports.IdentityStatus||(exports.IdentityStatus={})).None="none",t.Generated="generated",t.Registered="registered";const i="pom://pomrn.ata.network/connect",a=new Error("deep link is invalid"),c=new Error("deep link parameters is invalid"),d=new Error("socket is connecting"),p=new Error("get identity status timeout"),u=new Error("identity is empty");exports.ERR_OPERATION_CANCELLED=o.ERR_OPERATION_CANCELLED,Object.defineProperty(exports,"POMOperation",{enumerable:!0,get:function(){return o.POMOperation}}),exports.ERR_GET_IDENTITY_STATUS_TIMEOUT=p,exports.ERR_IDENTITY_IS_EMPTY=u,exports.ERR_INVALID_DEEP_LINK=a,exports.ERR_INVALID_DEEP_LINK_PARAMETERS=c,exports.ERR_SOCKET_IS_CONNECTING=d,exports.POMClinet=class{pomSocket;constructor(e){this.pomSocket=n.getSocket(e)}async sign(e){const{chainId:t,message:s,qrcodeLevel:r,onRenderQrcode:i,onGetIdentityOnChain:a,onRegisterIdentity:c}=e;if(this.pomSocket.status===n.SocketStatus.Connecting)throw d;if(this.pomSocket.status===n.SocketStatus.Disconnected){const e=await this.connectSocket(),t=this.generateDeepLink(e);i({deepLink:t,imageBase64:this.generateQrcode(t,r?{level:r}:void 0)}),await this.waitForConnectedEvent(),await this.waitForKeyExchangeEvent()}const p=await this.getIdentityStatus({chainId:t,onGetIdentityOnChain:a}).promise;let E;if(p.status===exports.IdentityStatus.None?E=await this.attestDevice({chainId:t}).promise:p.status!==exports.IdentityStatus.Generated&&p.status!==exports.IdentityStatus.Registered||(E=p.payload),null==E)throw u;p.status!==exports.IdentityStatus.None&&p.status!==exports.IdentityStatus.Generated||(await c(E),await o.runWithErrorRetry((()=>{const e=a({chainId:t,identity:E.identity});if(!e)throw o.ERR_NEED_RETRY;return e})));return{signature:await this.signMessage({chainId:t,message:s}).promise,...E}}async connectSocket(){return this.pomSocket.connect()}waitForConnectedEvent(){return this.pomSocket.waitForConnectedEvent()}waitForKeyExchangeEvent(){return this.pomSocket.waitForKeyExchangeEvent()}generateDeepLink(e){const{sessionId:t,dhSharedPublicNumber:n,hkdfSalt:r}=e,o={id:t,dh:n,s:r};return`${i}?${s.stringify(o)}`}parseDeepLinkQuery(e){const[t,n]=e.split("?");if(t!==i)throw a;const r=s.parse(n);if("string"!=typeof r.id||"string"!=typeof r.dh||"string"!=typeof r.s||""===r.id||""===r.dh||""===r.s)throw c;return s.parse(n)}generateQrcode(e,t){return new r.Encoder({level:t?.level||"M"}).encode(new r.Byte(e)).toDataURL()}getIdentityStatus(e){const{chainId:t,onGetIdentityOnChain:n}=e;let s;return{promise:new Promise(((e,r)=>{s=o.sendMessageAndWaitForResponse({socket:this.pomSocket,op:o.POMOperation.GetIdentityStatus,data:{chainId:t},resolver:s=>{s?n({chainId:t,identity:s.identity}).then((t=>{e({status:t?exports.IdentityStatus.Registered:exports.IdentityStatus.Generated,payload:s})})).catch((e=>{r(e)})):e({status:exports.IdentityStatus.None})},rejecter:r})})),cancel:s}}attestDevice(e){let t;return{promise:new Promise(((n,s)=>{t=o.sendMessageAndWaitForResponse({socket:this.pomSocket,op:o.POMOperation.AttestDevice,data:e,resolver:n,rejecter:s})})),cancel:t}}signMessage(e){let t;return{promise:new Promise(((n,s)=>{t=o.sendMessageAndWaitForResponse({socket:this.pomSocket,op:o.POMOperation.SignMessage,data:e,resolver:n,rejecter:s})})),cancel:t}}};
"use strict";var e,t,n=require("@automata-network/pom-socket"),s=require("qs"),r=require("@nuintun/qrcode"),o=require("./util.js");exports.POMPlatform=void 0,(e=exports.POMPlatform||(exports.POMPlatform={})).Android="android",e.iOS="iOS",e.macOS="macOS",exports.IdentityStatus=void 0,(t=exports.IdentityStatus||(exports.IdentityStatus={})).None="none",t.Generated="generated",t.Registered="registered";const i="pom://pomrn.ata.network/connect",a=new Error("deep link is invalid"),c=new Error("deep link parameters is invalid"),d=new Error("socket is connecting"),p=new Error("get identity status timeout"),u=new Error("identity is empty");exports.ERR_OPERATION_CANCELLED=o.ERR_OPERATION_CANCELLED,Object.defineProperty(exports,"POMOperation",{enumerable:!0,get:function(){return o.POMOperation}}),exports.ERR_GET_IDENTITY_STATUS_TIMEOUT=p,exports.ERR_IDENTITY_IS_EMPTY=u,exports.ERR_INVALID_DEEP_LINK=a,exports.ERR_INVALID_DEEP_LINK_PARAMETERS=c,exports.ERR_SOCKET_IS_CONNECTING=d,exports.POMClinet=class{pomSocket;constructor(...[e,t]){this.pomSocket=n.getSocket(e,t)}async sign(e){const{chainId:t,message:s,qrcodeLevel:r,onRenderQrcode:i,onGetIdentityOnChain:a,onRegisterIdentity:c}=e;if(this.pomSocket.status===n.SocketStatus.Connecting)throw d;if(this.pomSocket.status===n.SocketStatus.Disconnected){const e=await this.connectSocket(),t=this.generateDeepLink(e);i({deepLink:t,imageBase64:this.generateQrcode(t,r?{level:r}:void 0)}),await this.waitForConnectedEvent(),await this.waitForKeyExchangeEvent()}const p=await this.getIdentityStatus({chainId:t,onGetIdentityOnChain:a}).promise;let E;if(p.status===exports.IdentityStatus.None?E=await this.attestDevice({chainId:t}).promise:p.status!==exports.IdentityStatus.Generated&&p.status!==exports.IdentityStatus.Registered||(E=p.payload),null==E)throw u;p.status!==exports.IdentityStatus.None&&p.status!==exports.IdentityStatus.Generated||(await c(E),await o.runWithErrorRetry((()=>{const e=a({chainId:t,identity:E.identity});if(!e)throw o.ERR_NEED_RETRY;return e})));return{signature:await this.signMessage({chainId:t,message:s}).promise,...E}}async connectSocket(){return this.pomSocket.connect()}waitForConnectedEvent(){return this.pomSocket.waitForConnectedEvent()}waitForKeyExchangeEvent(){return this.pomSocket.waitForKeyExchangeEvent()}generateDeepLink(e){const{sessionId:t,dhSharedPublicNumber:n,hkdfSalt:r}=e,o={id:t,dh:n,s:r};return`${i}?${s.stringify(o)}`}parseDeepLinkQuery(e){const[t,n]=e.split("?");if(t!==i)throw a;const r=s.parse(n);if("string"!=typeof r.id||"string"!=typeof r.dh||"string"!=typeof r.s||""===r.id||""===r.dh||""===r.s)throw c;return s.parse(n)}generateQrcode(e,t){return new r.Encoder({level:t?.level||"M"}).encode(new r.Byte(e)).toDataURL()}getIdentityStatus(e){const{chainId:t,onGetIdentityOnChain:n}=e;let s;return{promise:new Promise(((e,r)=>{s=o.sendMessageAndWaitForResponse({socket:this.pomSocket,op:o.POMOperation.GetIdentityStatus,data:{chainId:t},resolver:s=>{s?n({chainId:t,identity:s.identity}).then((t=>{e({status:t?exports.IdentityStatus.Registered:exports.IdentityStatus.Generated,payload:s})})).catch((e=>{r(e)})):e({status:exports.IdentityStatus.None})},rejecter:r})})),cancel:s}}attestDevice(e){let t;return{promise:new Promise(((n,s)=>{t=o.sendMessageAndWaitForResponse({socket:this.pomSocket,op:o.POMOperation.AttestDevice,data:e,resolver:n,rejecter:s})})),cancel:t}}signMessage(e){let t;return{promise:new Promise(((n,s)=>{t=o.sendMessageAndWaitForResponse({socket:this.pomSocket,op:o.POMOperation.SignMessage,data:e,resolver:n,rejecter:s})})),cancel:t}}};
//# sourceMappingURL=index.js.map
{
"name": "@automata-network/pom-js-sdk",
"version": "0.0.2",
"version": "0.0.3",
"description": "A socket clinet for automata's Proof Of Machinehood",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -112,4 +112,4 @@ import {

constructor(socketUrl: string) {
this.pomSocket = getSocket(socketUrl);
constructor(...[socketUrl, options]: Parameters<typeof getSocket>) {
this.pomSocket = getSocket(socketUrl, options);
}

@@ -116,0 +116,0 @@

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