@silencelaboratories/walletprovider-sdk 0.0.0 → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,42 @@
1
+ import { AuthModule, UserAuthentication } from './authentication.ts';
2
+ import { type IWalletProviderServiceClient } from './walletProviderServiceClient.ts';
3
+ export declare enum HashAlgo {
4
+ SHA256 = "sha256",
5
+ SHA256D = "sha256d",
6
+ NO_HASH = "nohash"
7
+ }
8
+ export interface KeygenResponse {
9
+ key_id: string;
10
+ public_key: string;
11
+ }
12
+ export interface SignResponse {
13
+ sign?: string;
14
+ recid?: number;
15
+ preSignId?: string;
16
+ }
17
+ export type KeygenSetupOpts = {
18
+ t: number;
19
+ n: number;
20
+ };
21
+ export type SignSetupOpts = {
22
+ message: string;
23
+ key_id: string;
24
+ hash_algo: HashAlgo;
25
+ };
26
+ export declare function isSignSetupOpts(params: KeygenSetupOpts | SignSetupOpts): params is SignSetupOpts;
27
+ export type UserAuthenticatedRequest<T> = {
28
+ setup: T;
29
+ user_authentication: UserAuthentication;
30
+ ttl: number;
31
+ };
32
+ export declare class NetworkSigner {
33
+ authModule: AuthModule;
34
+ threshold: number;
35
+ totalNodes: number;
36
+ ttl: number;
37
+ wp_client: IWalletProviderServiceClient;
38
+ constructor(wp_client: IWalletProviderServiceClient, threshold: number, totalNodes: number, authModule: AuthModule, ttl?: number);
39
+ authenticateAndCreateKey(): Promise<KeygenResponse>;
40
+ authenticateAndSign(keyId: string, messageHex: string, hash: HashAlgo): Promise<SignResponse>;
41
+ }
42
+ //# sourceMappingURL=networkSigner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"networkSigner.d.ts","sourceRoot":"","sources":["../src/networkSigner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,KAAK,4BAA4B,EAAE,MAAM,kCAAkC,CAAC;A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,CAAC;CAoBpG"}
@@ -0,0 +1,5 @@
1
+ import { type KeygenSetupOpts, type SignSetupOpts } from './networkSigner.ts';
2
+ import { type UserAuthentication } from './authentication.ts';
3
+ import { type IWalletProviderServiceClient } from './walletProviderServiceClient.ts';
4
+ export declare function authenticateUsingEOA(setup: KeygenSetupOpts | SignSetupOpts, user_id: string, wp_client: IWalletProviderServiceClient): Promise<UserAuthentication>;
5
+ //# sourceMappingURL=sdkEOAauthentication.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdkEOAauthentication.d.ts","sourceRoot":"","sources":["../src/sdkEOAauthentication.ts"],"names":[],"mappings":"AAGA,OAAO,EAAmB,KAAK,eAAe,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC/F,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,KAAK,4BAA4B,EAAE,MAAM,kCAAkC,CAAC;AAoJrF,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,eAAe,GAAG,aAAa,EACtC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,4BAA4B,GACtC,OAAO,CAAC,kBAAkB,CAAC,CA8B7B"}
@@ -0,0 +1,12 @@
1
+ import * as viem from 'viem';
2
+ import { NetworkSigner } from './networkSigner';
3
+ /**
4
+ * Create a new viem custom account for signing transactions using
5
+ * the MPC network.
6
+ * @param clusterConfig The network cluster configuration.
7
+ * @param keyId The selected Key ID.
8
+ * @param publicKey Associated public key of the selected Key ID.
9
+ * @param threshold The threshold.
10
+ */
11
+ export declare function createViemAccount(networkSigner: NetworkSigner, keyId: string, publicKey: string): viem.LocalAccount;
12
+ //# sourceMappingURL=viemSigner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"viemSigner.d.ts","sourceRoot":"","sources":["../src/viemSigner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAI7B,OAAO,EAAY,aAAa,EAAgB,MAAM,iBAAiB,CAAC;AAExE;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC,YAAY,CAuCnH"}
@@ -0,0 +1,40 @@
1
+ import type { TypedDataDomain } from 'viem';
2
+ interface EIP6963ProviderInfo {
3
+ uuid: string;
4
+ name: string;
5
+ icon: string;
6
+ rdns: string;
7
+ }
8
+ interface RequestArguments {
9
+ readonly method: string;
10
+ readonly params?: readonly unknown[] | object;
11
+ }
12
+ interface EIP1193Provider {
13
+ isStatus?: boolean;
14
+ host?: string;
15
+ path?: string;
16
+ request: (request: RequestArguments) => Promise<unknown>;
17
+ }
18
+ interface EIP6963ProviderDetail {
19
+ info: EIP6963ProviderInfo;
20
+ provider: EIP1193Provider;
21
+ }
22
+ export declare const discoveredBrowserWallets: Map<string, EIP6963ProviderDetail>;
23
+ export declare let selectedBrowserWalletId: string;
24
+ export declare let accountsFromBrowserWallet: Array<string>;
25
+ export declare const detectBrowserWallets: () => void;
26
+ export declare function setActiveBrowserWallet(wallet: EIP6963ProviderDetail): void;
27
+ export declare function connectToBrowserWallet(): Promise<void>;
28
+ export type FieldDefinition = {
29
+ name: string;
30
+ type: string;
31
+ };
32
+ export type TypedData<T> = {
33
+ types: Record<string, Array<FieldDefinition>>;
34
+ domain: TypedDataDomain;
35
+ primaryType: string;
36
+ message: T;
37
+ };
38
+ export declare function signTypedData<T>(from: string, request: TypedData<T>): Promise<unknown>;
39
+ export {};
40
+ //# sourceMappingURL=walletEIP6963.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"walletEIP6963.d.ts","sourceRoot":"","sources":["../src/walletEIP6963.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAG5C,UAAU,mBAAmB;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM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C,OAAO,CAAC,CAK5F"}
@@ -0,0 +1,14 @@
1
+ import { KeygenResponse, KeygenSetupOpts, SignResponse, SignSetupOpts, UserAuthenticatedRequest } from './networkSigner';
2
+ import type { TypedData } from './walletEIP6963';
3
+ export type AggregatedChallenge = {
4
+ instance: string;
5
+ challenge: string;
6
+ };
7
+ export interface IWalletProviderServiceClient {
8
+ getWalletId(): string;
9
+ requestAggregatedChallenge(user_id: string): Promise<AggregatedChallenge>;
10
+ verifyUserSignature<T>(uuid: string, typedRequest: TypedData<T>, userSignature: string, authInstance: string): Promise<void>;
11
+ startKeygen(req: UserAuthenticatedRequest<KeygenSetupOpts>): Promise<KeygenResponse>;
12
+ startSigngen(authenticated_request: UserAuthenticatedRequest<SignSetupOpts>): Promise<SignResponse>;
13
+ }
14
+ //# sourceMappingURL=walletProviderServiceClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"walletProviderServiceClient.d.ts","sourceRoot":"","sources":["../src/walletProviderServiceClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,eAAe,EACf,YAAY,EACZ,aAAa,EACb,wBAAwB,EACzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,WAAW,4BAA4B;IAC3C,WAAW,IAAI,MAAM,CAAC;IACtB,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC1E,mBAAmB,CAAC,CAAC,EACnB,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,SAAS,CAAC,CAAC,CAAC,EAC1B,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjB,WAAW,CAAC,GAAG,EAAE,wBAAwB,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IACrF,YAAY,CAAC,qBAAqB,EAAE,wBAAwB,CAAC,aAAa,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CACrG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@silencelaboratories/walletprovider-sdk",
3
- "version": "0.0.0",
3
+ "version": "0.0.1",
4
4
  "description": "Frontend SDK for Wallet Providers",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -9,6 +9,7 @@
9
9
  ],
10
10
  "scripts": {
11
11
  "format": "prettier --write --cache .",
12
+ "formatcheck": "prettier --check --cache .",
12
13
  "lint": "eslint --cache ./src/**/*.ts",
13
14
  "typecheck": "tsc -p . --noEmit",
14
15
  "build": "bun run scripts/build.mjs && bun run build:declaration",
@@ -25,5 +26,9 @@
25
26
  "prettier": "^3.2.5",
26
27
  "typescript": "^5.4.5",
27
28
  "typescript-eslint": "^7.10.0"
29
+ },
30
+ "dependencies": {
31
+ "@noble/secp256k1": "^2.1.0",
32
+ "viem": "^2.11.1"
28
33
  }
29
34
  }
package/dist/hex.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export declare const decodeHex: (s: string) => Uint8Array;
2
- export declare const encodeHex: (a: Uint8Array) => string;
3
- //# sourceMappingURL=hex.d.ts.map
package/dist/hex.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"hex.d.ts","sourceRoot":"","sources":["../src/hex.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,MAAO,MAAM,KAAG,UAMrC,CAAC;AAEF,eAAO,MAAM,SAAS,MAAO,UAAU,KAAG,MAAqE,CAAC"}