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

@haechi-labs/face-types

Package Overview
Dependencies
Maintainers
2
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@haechi-labs/face-types - npm Package Compare versions

Comparing version 1.2.1 to 1.3.0-alpha.0

dist/auth.d.ts

17

package.json
{
"name": "@haechi-labs/face-types",
"version": "1.2.1",
"version": "1.3.0-alpha.0",
"description": "",
"author": "",
"license": "ISC",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"lib",
"dist",
"src"

@@ -15,3 +15,4 @@ ],

"build": "tsc -p . --sourceMap true",
"build:watch": "tsc -p . --sourceMap true --watch"
"build:watch": "tsc -p . --sourceMap true --watch",
"dev": "yarn run build:watch"
},

@@ -24,5 +25,7 @@ "devDependencies": {

"dependencies": {
"ethers": "^5.6.8"
"bn.js": "^5.2.1",
"ethers": "^5.6.8",
"near-api-js": "^1.1.0"
},
"gitHead": "77355be5218d5d6eb887ad4ea984ce347d12e451",
"gitHead": "12d83f8a2483eaff0e61786a70de9507e1a62b9f",
"publishConfig": {

@@ -29,0 +32,0 @@ "access": "public"

@@ -14,2 +14,6 @@ export enum Network {

SOLANA_DEVNET = 'solana_devnet',
NEAR = 'near',
NEAR_TESTNET = 'near_testnet',
BORA = 'bora',
BORA_TESTNET = 'bora_testnet',
/** @deprecated use ETHEREUM */

@@ -45,2 +49,6 @@ ETH_MAINNET = 'ethereum',

case Network.SOLANA_DEVNET:
case Network.NEAR:
case Network.NEAR_TESTNET:
case Network.BORA:
case Network.BORA_TESTNET:
return true;

@@ -64,2 +72,6 @@ default:

[Network.SOLANA_DEVNET]: 0,
[Network.NEAR]: 0,
[Network.NEAR_TESTNET]: 0,
[Network.BORA]: 77001,
[Network.BORA_TESTNET]: 99001,

@@ -75,2 +87,4 @@ 1: Network.ETHEREUM,

1001: Network.BAOBAB,
77001: Network.BORA,
99001: Network.BORA_TESTNET,
};

@@ -84,2 +98,4 @@

SOLANA = 'SOLANA',
NEAR = 'NEAR',
BORA = 'BORA',
}

@@ -92,6 +108,58 @@

Blockchain.KLAYTN,
Blockchain.BORA,
];
export function networkToBlockchain(network: Network): Blockchain {
switch (network) {
case Network.ETHEREUM:
case Network.ROPSTEN:
case Network.GOERLI:
return Blockchain.ETHEREUM;
case Network.POLYGON:
case Network.MUMBAI:
return Blockchain.POLYGON;
case Network.BNB_SMART_CHAIN:
case Network.BNB_SMART_CHAIN_TESTNET:
return Blockchain.BNB_SMART_CHAIN;
case Network.KLAYTN:
case Network.BAOBAB:
return Blockchain.KLAYTN;
case Network.SOLANA:
case Network.SOLANA_DEVNET:
return Blockchain.SOLANA;
case Network.BORA:
case Network.BORA_TESTNET:
return Blockchain.BORA;
case Network.NEAR:
case Network.NEAR_TESTNET:
return Blockchain.NEAR;
}
throw new Error(`Unsupported network: ${network}`);
}
export function isEthlikeBlockchain(blockchain: Blockchain): boolean {
return EthLikeBlockchains.indexOf(blockchain) !== -1;
}
export interface KeyPair {
privateKey: Uint8Array;
publicKey: Uint8Array;
}
export const getPlatFormCoinDecimalByBlockchain = (blockchain: Blockchain): number => {
switch (blockchain) {
case Blockchain.ETHEREUM:
case Blockchain.POLYGON:
case Blockchain.KLAYTN:
case Blockchain.BNB_SMART_CHAIN:
case Blockchain.BORA:
return 18;
case Blockchain.SOLANA:
return 9;
case Blockchain.NEAR:
return 24;
default:
throw new Error('unsupported blockchain');
}
};

@@ -23,2 +23,3 @@ import { JsonRpcError, RpcErrorCode } from './json-rpc';

CHAIN_DISCONNECTED = 4901,
SEND_TRANCTION_FAILED = 4902,

@@ -29,4 +30,4 @@ INTERNAL = 5000,

export class FaceError extends Error {
private readonly code: FaceErrorCode | RpcErrorCode | number;
public data?: Record<string, any>;
public readonly code: FaceErrorCode | RpcErrorCode | number;
public data?: any;
public origin: any;

@@ -42,3 +43,3 @@

origin?: any;
data?: Record<string, any>;
data?: any;
}) {

@@ -58,2 +59,10 @@ super();

export function sendTransactionError(err: JsonRpcError) {
return new FaceError({
message: err.message,
code: FaceErrorCode.SEND_TRANCTION_FAILED,
data: err.data,
});
}
export function jsonRpcError(err: JsonRpcError) {

@@ -67,3 +76,3 @@ return new FaceError({

export function faceServerError(message: string, origin?: any, data?: Record<string, any>) {
export function faceServerError(message: string, origin?: any, data?: any) {
return new FaceError({

@@ -77,3 +86,3 @@ message: `face server error: ${message}`,

export function nitroEnclaveError(message: string, origin?: any, data?: Record<string, any>) {
export function nitroEnclaveError(message: string, origin?: any, data?: any) {
return new FaceError({

@@ -87,3 +96,3 @@ message: `nitro enclave error: ${message}`,

export function firebaseError(message: string, origin?: any, data?: Record<string, any>) {
export function firebaseError(message: string, origin?: any, data?: any) {
return new FaceError({

@@ -97,3 +106,3 @@ message: `firebase error: ${message}`,

export function invalidEnvironmentError(data?: Record<string, any>) {
export function invalidEnvironmentError(data?: any) {
return new FaceError({

@@ -106,3 +115,3 @@ message: 'invalid environment',

export function cryptoError(message: string, origin?: any, data?: Record<string, any>) {
export function cryptoError(message: string, origin?: any, data?: any) {
return new FaceError({

@@ -116,3 +125,3 @@ message: `crypto error: ${message}`,

export function invalidFormatError(message: string, origin?: any, data?: Record<string, any>) {
export function invalidFormatError(message: string, origin?: any, data?: any) {
return new FaceError({

@@ -126,3 +135,3 @@ message: `invalid format error: ${message}`,

export function invalidParameterError(message: string, origin?: any, data?: Record<string, any>) {
export function invalidParameterError(message: string, origin?: any, data?: any) {
return new FaceError({

@@ -136,3 +145,3 @@ message: `invalid params error: ${message}`,

export function localStorageError(message: string, origin?: any, data?: Record<string, any>) {
export function localStorageError(message: string, origin?: any, data?: any) {
return new FaceError({

@@ -184,1 +193,9 @@ message: `local storage error: ${message}`,

}
export function invalidAddressWithWalletError() {
return new FaceError({
message: `invalid address compared with wallet address`,
code: FaceErrorCode.INTERNAL,
origin,
});
}
import { BigNumber, BigNumberish } from 'ethers';
export type FaceTransactionPayload = FaceEthereumTransactionPayload | FaceSolanaTransactionPayload;
export type FaceTransactionPayload =
| FaceEthereumTransactionPayload
| FaceSolanaNearTransactionPayload;

@@ -13,7 +15,29 @@ export interface FaceEthereumTransactionPayload {

export interface FaceSolanaTransactionPayload {
export interface FaceSolanaNearTransactionPayload {
serializedHex: string;
}
export function parseFaceSolanaNearTransactionPayload(arg: unknown) {
if (arg == null || typeof arg !== 'object') {
return null;
}
if ((arg as any)['serializedHex'] == null || typeof (arg as any)['serializedHex'] !== 'string') {
return null;
}
return arg as FaceSolanaNearTransactionPayload;
}
export interface FaceLoginResponse {
wallet:
| {
id?: string;
userId?: string;
keyId?: string;
path?: string;
address?: string;
ecdsaPublicKey?: string;
eddsaPublicKey?: string;
}
| undefined;
faceUserId: string;

@@ -20,0 +44,0 @@ }

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

export * from './auth';
export * from './blockchain';

@@ -2,0 +3,0 @@ export * from './crypto';

@@ -11,2 +11,3 @@ export enum JsonRpcMethod {

face_openWalletConnect = 'face_openWalletConnect',
face_socialLogin = 'face_socialLogin',

@@ -18,4 +19,6 @@ eth_sendTransaction = 'eth_sendTransaction',

eth_sign = 'eth_sign',
eth_accounts = 'eth_accounts',
personal_sign = 'personal_sign',
personal_listAccounts = 'personal_listAccounts',

@@ -25,2 +28,4 @@ wallet_switchEthereumChain = 'wallet_switchEthereumChain',

solana_sendTransaction = 'solana_sendTransaction',
near_broadcast_tx_async = 'near_broadcast_tx_async',
}

@@ -32,2 +37,3 @@

FACE_WALLET_CONNECT = 'FACE_WALLET_CONNECT',
FACE_NATIVE_SDK = 'FACE_NATIVE_SDK',
}

@@ -65,5 +71,14 @@

export interface JsonRpcResponsePayload<ResultType = any> {
jsonrpc?: string;
id?: string | number | null;
result?: ResultType | null;
error?: JsonRpcError | null;
// Originally, we were going to work with JSONRPC standard,
// and wrap ethereum rpc in one more layer.
// However, the process of handling data became complicated,
// so we decided to extend JSONRPC standard.
// Link for internal discussion:
// https://haechilabs.slack.com/archives/C03EVTP0RSB/p1666330252362169?thread_ts=1666329876.458129&cid=C03EVTP0RSB
to?: JsonRpcSource;
from?: JsonRpcSource;
}

@@ -70,0 +85,0 @@

@@ -0,1 +1,4 @@

import { BigNumberish } from 'ethers';
import { BytesLike } from 'ethers/lib/utils';
export enum TxType {

@@ -7,1 +10,14 @@ COIN = 'COIN',

}
export type EthTransactionRequest = {
to?: string;
from?: string;
path?: string;
nonce?: BigNumberish;
gasLimit?: BigNumberish;
gasPrice?: BigNumberish;
data?: BytesLike;
value?: BigNumberish;
};

@@ -6,2 +6,3 @@ import { CryptoBuffer } from './crypto';

export const FaceShare1LocalKey = 'Face-Share1';
export const FaceVersionLocalKey = 'Face-Version';
export const WalletPath = `m/44'/60'/1'/0/0`;

@@ -8,0 +9,0 @@

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