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

@automata-network/pom-js-sdk

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.10 to 0.0.11

{
"name": "@automata-network/pom-js-sdk",
"version": "0.0.10",
"version": "0.0.11",
"description": "A socket clinet for automata's Proof Of Machinehood",

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

@@ -44,3 +44,3 @@ import {

export interface AttestDeviceData {
export interface AttestDeviceResult {
platform: POMPlatform;

@@ -61,3 +61,2 @@ chainId: ChainId;

status: IdentityStatus;
payload?: AttestDeviceData;
}

@@ -85,3 +84,3 @@

) => Promise<boolean>;
onRegisterIdentity: (data: AttestDeviceData) => Promise<void>;
onRegisterIdentity: (data: AttestDeviceResult) => Promise<void>;
}

@@ -101,7 +100,3 @@

export interface GetIdentityStatusOptions extends ChainIdOptions {
onGetIdentityOnChain: (
options: GetIdentityOnChainOptions,
) => Promise<boolean>;
}
export interface GetIdentityStatusOptions extends ChainIdOptions {}

@@ -198,22 +193,13 @@ export interface SignMessageOptions extends ChainIdOptions {

const identityStatus = await this.getIdentityStatus({
chainId,
onGetIdentityOnChain,
}).promise;
const identityStatus = await this.getIdentityStatus({chainId}).promise;
let identityData: AttestDeviceData | undefined;
let identityData: AttestDeviceResult | undefined;
if (identityStatus.status === IdentityStatus.None) {
if (
identityStatus.status === IdentityStatus.None ||
identityStatus.status === IdentityStatus.Generated
) {
identityData = await this.attestDevice({chainId, caller}).promise;
} else if (
identityStatus.status === IdentityStatus.Generated ||
identityStatus.status === IdentityStatus.Registered
) {
identityData = identityStatus.payload;
}
if (identityData == null) {
throw ERR_IDENTITY_IS_EMPTY;
}
if (

@@ -223,2 +209,6 @@ identityStatus.status === IdentityStatus.None ||

) {
if (identityData == null) {
throw ERR_IDENTITY_IS_EMPTY;
}
await onRegisterIdentity(identityData);

@@ -240,9 +230,6 @@

const signature = await this.signMessage({chainId, caller, message})
const signatureResult = await this.signMessage({chainId, caller, message})
.promise;
return {
signature,
...identityData,
};
return signatureResult;
}

@@ -291,3 +278,3 @@

): MessageResult<IdentityStatusResult> {
const {chainId, onGetIdentityOnChain} = options;
const {chainId} = options;
let cancel: () => void;

@@ -298,3 +285,3 @@

ChainIdOptions,
AttestDeviceData | undefined
IdentityStatusResult | undefined
>({

@@ -308,17 +295,3 @@ socket: this.pomSocket,

} else {
onGetIdentityOnChain({
chainId,
identity: data.identity,
})
.then(registered => {
resolve({
status: registered
? IdentityStatus.Registered
: IdentityStatus.Generated,
payload: data,
});
})
.catch(e => {
reject(e);
});
resolve({status: data.status});
}

@@ -333,6 +306,8 @@ },

attestDevice(options: AttestDeviceOptions): MessageResult<AttestDeviceData> {
attestDevice(
options: AttestDeviceOptions,
): MessageResult<AttestDeviceResult> {
let cancel: () => void;
const promise = new Promise<AttestDeviceData>((resolve, reject) => {
const promise = new Promise<AttestDeviceResult>((resolve, reject) => {
cancel = sendMessageAndWaitForResponse({

@@ -350,6 +325,6 @@ socket: this.pomSocket,

signMessage(options: SignMessageOptions): MessageResult<string> {
signMessage(options: SignMessageOptions): MessageResult<SignatureResult> {
let cancel: () => void;
const promise = new Promise<string>((resolve, reject) => {
const promise = new Promise<SignatureResult>((resolve, reject) => {
cancel = sendMessageAndWaitForResponse({

@@ -356,0 +331,0 @@ socket: this.pomSocket,