@silencelaboratories/walletprovider-sdk 1.6.0 → 4.0.0-hackaton
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.
- package/README.md +121 -73
- package/dist/auth/EOAauthentication.d.ts +1 -1
- package/dist/auth/authentication.d.ts +16 -27
- package/dist/auth/passkeyAuthentication.d.ts +1 -1
- package/dist/builder/signRequest.d.ts +2 -2
- package/dist/builder/userAuth.d.ts +14 -10
- package/dist/client/networkRequest.d.ts +33 -21
- package/dist/client/networkResponse.d.ts +21 -49
- package/dist/client/networkSigner.d.ts +20 -4
- package/dist/client/walletProviderServiceClient.d.ts +16 -2
- package/dist/client/walletProviderServiceClientInterface.d.ts +21 -7
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +20 -7
- package/dist/index.esm.js +1 -1
- package/dist/policy.d.ts +220 -0
- package/dist/setupMessage.d.ts +27 -12
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -8,13 +8,14 @@ export interface KeygenResponse {
|
|
|
8
8
|
*/
|
|
9
9
|
keyId: string;
|
|
10
10
|
/**
|
|
11
|
-
* Public key encoded with SEC1 format.
|
|
12
11
|
*
|
|
13
|
-
*
|
|
12
|
+
* For ECDSA: Public key encoded with SEC1 format.
|
|
14
13
|
*
|
|
14
|
+
* If point is uncompressed it's in a form of 0x04 || X || Y
|
|
15
15
|
* If point is compressed it's in a form Y || X,
|
|
16
|
-
*
|
|
17
16
|
* where Y is set to 0x02 if Y-coord is even, or 0x03 if Y-coord is odd
|
|
17
|
+
*
|
|
18
|
+
* For EdDSA: RFC 8032 32-byte compressed Edwards.
|
|
18
19
|
*/
|
|
19
20
|
publicKey: string;
|
|
20
21
|
/**
|
|
@@ -34,38 +35,37 @@ export type KeyRefreshResponse = KeygenResponse;
|
|
|
34
35
|
export interface SignResponse {
|
|
35
36
|
transactionId: string;
|
|
36
37
|
/**
|
|
37
|
-
* Hexstring of length 128 bytes, in a form: r || s
|
|
38
|
+
* For ECDSA: Hexstring of length 128 bytes, in a form: r || s. The r and s are 64 bytes long.
|
|
39
|
+
* For EdDSA: RFC 8032 64-byte signature.
|
|
38
40
|
*/
|
|
39
41
|
sign: string;
|
|
40
42
|
/**
|
|
41
|
-
* Recovery id, either 0, or 1
|
|
43
|
+
* For ECDSA: Recovery id, either 0, or 1
|
|
44
|
+
* For EdDSA: unused
|
|
42
45
|
*/
|
|
43
46
|
recid: number;
|
|
44
47
|
}
|
|
48
|
+
interface SimpleResponse {
|
|
49
|
+
/**
|
|
50
|
+
* Status of the request.
|
|
51
|
+
*/
|
|
52
|
+
status: string;
|
|
53
|
+
}
|
|
45
54
|
/**
|
|
46
55
|
* Response from the SDK for adding ephemeral key request. Receive plaintext response from network.
|
|
47
56
|
* @public
|
|
48
57
|
*/
|
|
49
|
-
export interface AddEphKeyResponse {
|
|
58
|
+
export interface AddEphKeyResponse extends SimpleResponse {
|
|
50
59
|
/**
|
|
51
60
|
* Unique ID of produced key used in subsequent API calls.
|
|
52
61
|
*/
|
|
53
62
|
keyId: string;
|
|
54
|
-
/**
|
|
55
|
-
* Status of the request.
|
|
56
|
-
*/
|
|
57
|
-
status: string;
|
|
58
63
|
}
|
|
59
64
|
/**
|
|
60
65
|
* Response from the network for revoking ephemeral key request.
|
|
61
66
|
* @public
|
|
62
67
|
*/
|
|
63
|
-
export
|
|
64
|
-
/**
|
|
65
|
-
* Status of the request.
|
|
66
|
-
*/
|
|
67
|
-
status: string;
|
|
68
|
-
}
|
|
68
|
+
export type RevokeEphKeyResponse = SimpleResponse;
|
|
69
69
|
/**
|
|
70
70
|
* Response from the network for registering passkey request.
|
|
71
71
|
* @public
|
|
@@ -78,41 +78,13 @@ export interface RegisterPasskeyResponse {
|
|
|
78
78
|
passkeyCredentialId: string;
|
|
79
79
|
}
|
|
80
80
|
/**
|
|
81
|
-
* Response from the network for
|
|
82
|
-
* @public
|
|
83
|
-
*/
|
|
84
|
-
export interface QuorumChangeResponse extends KeygenResponse {
|
|
85
|
-
/**
|
|
86
|
-
* Number of nodes of the previous version of the refreshed key.
|
|
87
|
-
*/
|
|
88
|
-
oldN: number;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
*
|
|
92
|
-
* @param keysharePlaintext Public data of keyshare in plaintext format
|
|
93
|
-
* @returns Keygen responses {@link KeygenResponse}
|
|
94
|
-
*/
|
|
95
|
-
export declare const parseKeysharePublicData: (keysharePlaintext: string) => KeygenResponse;
|
|
96
|
-
/**
|
|
97
|
-
*
|
|
98
|
-
* @param keygenResult MPC keygen result in plaintext format
|
|
99
|
-
* @param totalKey Amount of keys to generate
|
|
100
|
-
* @returns List of keygen responses {@link KeygenResponse}
|
|
101
|
-
* @public
|
|
102
|
-
*/
|
|
103
|
-
export declare const parseKeygenResult: (keygenResult: string, totalKey: number) => KeygenResponse[];
|
|
104
|
-
/**
|
|
105
|
-
*
|
|
106
|
-
* @param signResult MPC sign result in plaintext format
|
|
107
|
-
* @param signAlg MPC sign algorithm
|
|
108
|
-
* @returns List of signgen responses {@link SignResponse}
|
|
81
|
+
* Response from the network for updating passkey policy request.
|
|
109
82
|
* @public
|
|
110
83
|
*/
|
|
111
|
-
export
|
|
84
|
+
export type UpdatePolicyResponse = SimpleResponse;
|
|
112
85
|
/**
|
|
113
|
-
*
|
|
114
|
-
* @param keygenResult MPC keygen result in plaintext format
|
|
115
|
-
* @returns List of keygen responses {@link KeygenResponse}
|
|
86
|
+
* Response from the network for deleting passkey policy request.
|
|
116
87
|
* @public
|
|
117
88
|
*/
|
|
118
|
-
export
|
|
89
|
+
export type DeletePolicyResponse = SimpleResponse;
|
|
90
|
+
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { AuthModule } from '../auth/authentication';
|
|
2
2
|
import { INoAuthWpServiceClient, type IWalletProviderServiceClient } from './walletProviderServiceClientInterface';
|
|
3
|
-
import { KeygenResponse, AddEphKeyResponse, RegisterPasskeyResponse, SignResponse, RevokeEphKeyResponse, KeyRefreshResponse } from './networkResponse';
|
|
3
|
+
import { KeygenResponse, AddEphKeyResponse, RegisterPasskeyResponse, SignResponse, RevokeEphKeyResponse, KeyRefreshResponse, UpdatePolicyResponse, DeletePolicyResponse } from './networkResponse';
|
|
4
4
|
import { EphKeyClaim } from '../auth/ephemeralAuthentication';
|
|
5
|
+
import { Policy } from '../policy';
|
|
5
6
|
/**
|
|
6
7
|
* Supported signature algorithms for MPC signing.
|
|
7
8
|
* @public
|
|
@@ -32,12 +33,12 @@ export declare class NetworkSigner {
|
|
|
32
33
|
* @param totalNodes - Number of nodes that participate in keygen operation. Also known as `n`.
|
|
33
34
|
* @param signAlgs - signature algorithms for which MPC keys will be generated.
|
|
34
35
|
* @param eph_claim - optional eph key added to the generated key
|
|
35
|
-
* @param
|
|
36
|
-
* The
|
|
36
|
+
* @param policy - optional policy that will be stored in the key metadata.
|
|
37
|
+
* The policy are validated during sign requests.
|
|
37
38
|
* @returns {@link KeygenResponse} containing `keyId` and the `pubKey` public part of the key
|
|
38
39
|
* @public
|
|
39
40
|
*/
|
|
40
|
-
generateKey(threshold: number, totalNodes: number, signAlgs: string[], ephClaim?: EphKeyClaim,
|
|
41
|
+
generateKey(threshold: number, totalNodes: number, signAlgs: string[], ephClaim?: EphKeyClaim, policy?: Policy): Promise<KeygenResponse[]>;
|
|
41
42
|
/** Generate a signature by the distributed key of Silent Network.
|
|
42
43
|
* Uses `authModule` to authenticate the sign request by the User.
|
|
43
44
|
* The network chooses `t` nodes to execute the protocol.
|
|
@@ -81,4 +82,19 @@ export declare class NetworkSigner {
|
|
|
81
82
|
* @public
|
|
82
83
|
*/
|
|
83
84
|
registerPasskey(options?: string): Promise<RegisterPasskeyResponse>;
|
|
85
|
+
/** Update user's key policy on the network. This will try to update to all the available nodes on the network.
|
|
86
|
+
* Uses `authModule` to authenticate the request by the User.
|
|
87
|
+
* @param keyId - the key id returned from `keygen`
|
|
88
|
+
* @param policy - the key policy to be updated
|
|
89
|
+
* @returns {@link UpdatePolicyResponse}
|
|
90
|
+
* @public
|
|
91
|
+
*/
|
|
92
|
+
updatePolicy(keyId: string, policy: Policy): Promise<UpdatePolicyResponse>;
|
|
93
|
+
/** Delete user's key policy on the network. This will try to delete to all the available nodes on the network.
|
|
94
|
+
* Uses `authModule` to authenticate the request by the User.
|
|
95
|
+
* @param keyId - the key id returned from `keygen`
|
|
96
|
+
* @returns {@link DeletePolicyResponse}
|
|
97
|
+
* @public
|
|
98
|
+
*/
|
|
99
|
+
deletePolicy(keyId: string): Promise<DeletePolicyResponse>;
|
|
84
100
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AuthModule } from '../auth/authentication';
|
|
2
|
-
import { type KeygenResponse, type SignResponse, type AddEphKeyResponse, type RegisterPasskeyResponse, RevokeEphKeyResponse, KeyRefreshResponse } from './networkResponse';
|
|
2
|
+
import { type KeygenResponse, type SignResponse, type AddEphKeyResponse, type RegisterPasskeyResponse, RevokeEphKeyResponse, KeyRefreshResponse, UpdatePolicyResponse, DeletePolicyResponse } from './networkResponse';
|
|
3
3
|
import { KeygenSetupOpts, SignSetupOpts } from '../setupMessage';
|
|
4
4
|
import { ApiVersion, type ClientConfig, IWalletProviderServiceClient, Slug, RequestPayloadV1, RequestPayloadV2, INoAuthWpServiceClient, NoAuthSlug, NoAuthRequestPayload } from './walletProviderServiceClientInterface';
|
|
5
|
-
import { AddEphKeyRequest, KeyRefreshRequest, RegisterPasskeyRequest, RevokeEphKeyRequest } from './networkRequest';
|
|
5
|
+
import { AddEphKeyRequest, DeletePolicyRequest, KeyRefreshRequest, RegisterPasskeyRequest, RevokeEphKeyRequest, UpdatePolicyRequest } from './networkRequest';
|
|
6
6
|
declare enum ProtocolState {
|
|
7
7
|
initiated = 0,
|
|
8
8
|
waitingForSign = 1,
|
|
@@ -47,6 +47,14 @@ export declare class WalletProviderServiceClient implements IWalletProviderServi
|
|
|
47
47
|
payload: RegisterPasskeyRequest;
|
|
48
48
|
authModule: AuthModule;
|
|
49
49
|
}): Promise<RegisterPasskeyResponse>;
|
|
50
|
+
updatePolicy({ payload, authModule, }: {
|
|
51
|
+
payload: UpdatePolicyRequest;
|
|
52
|
+
authModule: AuthModule;
|
|
53
|
+
}): Promise<UpdatePolicyResponse>;
|
|
54
|
+
deletePolicy({ payload, authModule, }: {
|
|
55
|
+
payload: DeletePolicyRequest;
|
|
56
|
+
authModule: AuthModule;
|
|
57
|
+
}): Promise<DeletePolicyResponse>;
|
|
50
58
|
connect(slug: Slug, payload: RequestPayloadV1, authModule: AuthModule): Promise<string>;
|
|
51
59
|
connectV2(slug: Slug, payload: RequestPayloadV2, authModule: AuthModule): Promise<string>;
|
|
52
60
|
/**
|
|
@@ -85,6 +93,12 @@ export declare class NoAuthWalletProviderServiceClient implements INoAuthWpServi
|
|
|
85
93
|
startKeyRefresh({ payload }: {
|
|
86
94
|
payload: KeyRefreshRequest;
|
|
87
95
|
}): Promise<KeyRefreshResponse>;
|
|
96
|
+
updatePolicy({ payload }: {
|
|
97
|
+
payload: UpdatePolicyRequest;
|
|
98
|
+
}): Promise<UpdatePolicyResponse>;
|
|
99
|
+
deletePolicy({ payload }: {
|
|
100
|
+
payload: DeletePolicyRequest;
|
|
101
|
+
}): Promise<DeletePolicyResponse>;
|
|
88
102
|
connect(slug: NoAuthSlug, payload: NoAuthRequestPayload): Promise<string>;
|
|
89
103
|
}
|
|
90
104
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AuthModule, UserAuthentication } from '../auth/authentication';
|
|
2
|
-
import { KeygenResponse, SignResponse, AddEphKeyResponse, RegisterPasskeyResponse, RevokeEphKeyResponse, KeyRefreshResponse } from './networkResponse';
|
|
2
|
+
import { KeygenResponse, SignResponse, AddEphKeyResponse, RegisterPasskeyResponse, RevokeEphKeyResponse, KeyRefreshResponse, UpdatePolicyResponse, DeletePolicyResponse } from './networkResponse';
|
|
3
3
|
import { KeygenSetupOpts, SignSetupOpts, InitPresignOpts, FinishPresignOpts } from '../setupMessage';
|
|
4
|
-
import { AddEphKeyRequest,
|
|
4
|
+
import { AddEphKeyRequest, DeletePolicyRequest, KeyRefreshRequest, RegisterPasskeyRequest, RevokeEphKeyRequest, UpdatePolicyRequest } from './networkRequest';
|
|
5
5
|
/**
|
|
6
6
|
* The config used to create Wallet Provider Service backend client.
|
|
7
7
|
* Please refer to {@link https://shipyard.rs/silencelaboratories/crates/wallet-provider-service | example backend service}
|
|
@@ -54,10 +54,18 @@ export interface IWalletProviderServiceClient {
|
|
|
54
54
|
payload: RegisterPasskeyRequest;
|
|
55
55
|
authModule: AuthModule;
|
|
56
56
|
}): Promise<RegisterPasskeyResponse>;
|
|
57
|
+
updatePolicy({ payload, authModule, }: {
|
|
58
|
+
payload: UpdatePolicyRequest;
|
|
59
|
+
authModule: AuthModule;
|
|
60
|
+
}): Promise<UpdatePolicyResponse>;
|
|
61
|
+
deletePolicy({ payload, authModule, }: {
|
|
62
|
+
payload: DeletePolicyRequest;
|
|
63
|
+
authModule: AuthModule;
|
|
64
|
+
}): Promise<DeletePolicyResponse>;
|
|
57
65
|
}
|
|
58
|
-
export type Slug = 'signgen' | 'keygen' | 'keyRefresh' | 'quorumChange' | 'addEphemeralKey' | 'revokeEphemeralKey' | 'registerPasskey' | 'initPresign' | 'finishPresign';
|
|
59
|
-
export type RequestPayloadV1 = KeygenSetupOpts[] | KeyRefreshRequest |
|
|
60
|
-
export type RequestPayloadV2 = KeygenSetupOpts[] | SignSetupOpts | AddEphKeyRequest | RevokeEphKeyRequest | InitPresignOpts | FinishPresignOpts;
|
|
66
|
+
export type Slug = 'signgen' | 'keygen' | 'keyRefresh' | 'quorumChange' | 'addEphemeralKey' | 'revokeEphemeralKey' | 'registerPasskey' | 'initPresign' | 'finishPresign' | 'updatePolicy' | 'deletePolicy';
|
|
67
|
+
export type RequestPayloadV1 = KeygenSetupOpts[] | KeyRefreshRequest | SignSetupOpts | AddEphKeyRequest | RevokeEphKeyRequest | RegisterPasskeyRequest | UpdatePolicyRequest | DeletePolicyRequest | FinishPresignOpts;
|
|
68
|
+
export type RequestPayloadV2 = KeygenSetupOpts[] | SignSetupOpts | AddEphKeyRequest | RevokeEphKeyRequest | InitPresignOpts | FinishPresignOpts | UpdatePolicyRequest | DeletePolicyRequest;
|
|
61
69
|
export interface WpRequest {
|
|
62
70
|
payload: RequestPayloadV1 | RequestPayloadV2;
|
|
63
71
|
userSigs: Record<string, UserAuthentication> | undefined;
|
|
@@ -76,6 +84,12 @@ export interface INoAuthWpServiceClient {
|
|
|
76
84
|
startKeyRefresh({ payload }: {
|
|
77
85
|
payload: KeyRefreshRequest;
|
|
78
86
|
}): Promise<KeyRefreshResponse>;
|
|
87
|
+
updatePolicy({ payload }: {
|
|
88
|
+
payload: UpdatePolicyRequest;
|
|
89
|
+
}): Promise<UpdatePolicyResponse>;
|
|
90
|
+
deletePolicy({ payload }: {
|
|
91
|
+
payload: DeletePolicyRequest;
|
|
92
|
+
}): Promise<DeletePolicyResponse>;
|
|
79
93
|
}
|
|
80
|
-
export type NoAuthSlug = 'signgen' | 'keygen' | 'keyRefresh';
|
|
81
|
-
export type NoAuthRequestPayload = KeygenSetupOpts[] | SignSetupOpts | InitPresignOpts | FinishPresignOpts | KeyRefreshRequest;
|
|
94
|
+
export type NoAuthSlug = 'signgen' | 'keygen' | 'keyRefresh' | 'updatePolicy' | 'deletePolicy';
|
|
95
|
+
export type NoAuthRequestPayload = KeygenSetupOpts[] | SignSetupOpts | InitPresignOpts | FinishPresignOpts | KeyRefreshRequest | UpdatePolicyRequest | DeletePolicyRequest;
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var j=Object.defineProperty;var Ne=Object.getOwnPropertyDescriptor;var We=Object.getOwnPropertyNames;var De=Object.prototype.hasOwnProperty;var _e=(s,e,t)=>e in s?j(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var Be=(s,e)=>{for(var t in e)j(s,t,{get:e[t],enumerable:!0})},Le=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of We(e))!De.call(s,r)&&r!==t&&j(s,r,{get:()=>e[r],enumerable:!(n=Ne(e,r))||n.enumerable});return s};var Fe=s=>Le(j({},"__esModule",{value:!0}),s);var c=(s,e,t)=>_e(s,typeof e!="symbol"?e+"":e,t);var st={};Be(st,{EOAAuth:()=>D,EphAuth:()=>_,EphKeyClaim:()=>E,FinishPresignOpts:()=>x,HttpClient:()=>W,InitPresignOpts:()=>T,KeygenSetupOpts:()=>f,NetworkSigner:()=>N,NoAuthWalletProviderServiceClient:()=>R,PasskeyAuth:()=>B,PasskeyRegister:()=>L,SignRequestBuilder:()=>v,UserSignatures:()=>w,WalletProviderServiceClient:()=>V,computeAddress:()=>oe,default:()=>nt,flattenSignature:()=>te,generateEphPrivateKey:()=>Q,getEphPublicKey:()=>I,parseEphKeyOperationResult:()=>$,parseKeygenResult:()=>K,parseSigngenResult:()=>C});module.exports=Fe(st);var Pe=require("json-canonicalize");var d=(s,e)=>{g(typeof e!="string",`${s} must be string`),g((e==null?void 0:e.trim().length)===0,`${s} cannot be empty`)},be=(s,e)=>{if(g(!(s instanceof Uint8Array),"key must be an Uint8Array"),e==="secp256k1")g(s.length!==65,"secp256k1: key length must be 65 bytes, got "+s.length);else if(e==="ed25519")g(s.length!==32,"ed25519: key length must be 32 bytes, got "+s.length);else throw new Error("Invalid signature algorithm")},Ae=(s,e)=>{if(g(!(s instanceof Uint8Array),"key must be an Uint8Array"),e==="secp256k1")g(s.length!==32,"secp256k1: key length must be 32 bytes, got "+s.length);else if(e==="ed25519")g(s.length!==32,"ed25519: key length must be 32 bytes, got "+s.length);else throw new Error("Invalid signature algorithm")},xe=s=>{g(s!=="ed25519"&&s!=="secp256k1",'signAlg must be either "ed25519" or "secp256k"')},g=(s,e)=>{if(s)throw new Error(e)},He=(s,e)=>`Invalid payload ${JSON.stringify(s)}, cannot be authenticated by ${e.toLocaleUpperCase()} method.`,H=(s,e,t)=>{g(!e.some(n=>s instanceof n),He(s,t))};var v=class{constructor(){c(this,"signRequest",new Map)}setRequest(e,t,n){if(d("transactionId",e),d("message",t),d("requestType",n),this.signRequest.has(e))throw new Error(`Transaction ID ${e} is already set.`);return this.signRequest.set(e,{signingMessage:t,requestType:n}),this}build(){let e={};if(this.signRequest.forEach((t,n)=>{e[n]=t}),Object.keys(e).length===0)throw new Error("No sign request is set.");return(0,Pe.canonicalize)(e)}};var de=require("json-canonicalize");var Ce=require("js-base64");function Je(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function ce(s,...e){if(!Je(s))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(s.length))throw new Error("Uint8Array expected of length "+e+", got length="+s.length)}function ue(s,e=!0){if(s.destroyed)throw new Error("Hash instance has been destroyed");if(e&&s.finished)throw new Error("Hash#digest() has already been called")}function Ee(s,e){ce(s);let t=e.outputLen;if(s.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}var Y=s=>new DataView(s.buffer,s.byteOffset,s.byteLength),y=(s,e)=>s<<32-e|s>>>e;function Ge(s){if(typeof s!="string")throw new Error("utf8ToBytes expected string, got "+typeof s);return new Uint8Array(new TextEncoder().encode(s))}function pe(s){return typeof s=="string"&&(s=Ge(s)),ce(s),s}var X=class{clone(){return this._cloneInto()}};function ve(s){let e=n=>s().update(pe(n)).digest(),t=s();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>s(),e}function ze(s,e,t,n){if(typeof s.setBigUint64=="function")return s.setBigUint64(e,t,n);let r=BigInt(32),o=BigInt(4294967295),i=Number(t>>r&o),a=Number(t&o),u=n?4:0,p=n?0:4;s.setUint32(e+u,i,n),s.setUint32(e+p,a,n)}var ke=(s,e,t)=>s&e^~s&t,Ke=(s,e,t)=>s&e^s&t^e&t,Z=class extends X{constructor(e,t,n,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Y(this.buffer)}update(e){ue(this);let{view:t,buffer:n,blockLen:r}=this;e=pe(e);let o=e.length;for(let i=0;i<o;){let a=Math.min(r-this.pos,o-i);if(a===r){let u=Y(e);for(;r<=o-i;i+=r)this.process(u,i);continue}n.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){ue(this),Ee(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:o}=this,{pos:i}=this;t[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>r-i&&(this.process(n,0),i=0);for(let h=i;h<r;h++)t[h]=0;ze(n,r-8,BigInt(this.length*8),o),this.process(n,0);let a=Y(e),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let p=u/4,l=this.get();if(p>l.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<p;h++)a.setUint32(4*h,l[h],o)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:n,length:r,finished:o,destroyed:i,pos:a}=this;return e.length=r,e.pos=a,e.finished=o,e.destroyed=i,r%t&&e.buffer.set(n),e}};var Qe=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),b=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),A=new Uint32Array(64),he=class extends Z{constructor(){super(64,32,8,!1),this.A=b[0]|0,this.B=b[1]|0,this.C=b[2]|0,this.D=b[3]|0,this.E=b[4]|0,this.F=b[5]|0,this.G=b[6]|0,this.H=b[7]|0}get(){let{A:e,B:t,C:n,D:r,E:o,F:i,G:a,H:u}=this;return[e,t,n,r,o,i,a,u]}set(e,t,n,r,o,i,a,u){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=o|0,this.F=i|0,this.G=a|0,this.H=u|0}process(e,t){for(let h=0;h<16;h++,t+=4)A[h]=e.getUint32(t,!1);for(let h=16;h<64;h++){let S=A[h-15],U=A[h-2],Se=y(S,7)^y(S,18)^S>>>3,ae=y(U,17)^y(U,19)^U>>>10;A[h]=ae+A[h-7]+Se+A[h-16]|0}let{A:n,B:r,C:o,D:i,E:a,F:u,G:p,H:l}=this;for(let h=0;h<64;h++){let S=y(a,6)^y(a,11)^y(a,25),U=l+S+ke(a,u,p)+Qe[h]+A[h]|0,ae=(y(n,2)^y(n,13)^y(n,22))+Ke(n,r,o)|0;l=p,p=u,u=a,a=i+U|0,i=o,o=r,r=n,n=U+ae|0}n=n+this.A|0,r=r+this.B|0,o=o+this.C|0,i=i+this.D|0,a=a+this.E|0,u=u+this.F|0,p=p+this.G|0,l=l+this.H|0,this.set(n,r,o,i,a,u,p,l)}roundClean(){A.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var le=ve(()=>new he);var ee=require("viem"),m=s=>Ce.Base64.fromUint8Array(new Uint8Array(s),!0),ge=s=>{let e=(0,ee.stringToBytes)(s),t=le(le(e));return(0,ee.toHex)(t,{size:32}).slice(2)};var w=class{constructor(e,t){c(this,"userAuthentications");c(this,"authModule");c(this,"apiVersion");this.authModule=e,this.userAuthentications=new Map,this.apiVersion=t}async setDefaultAuth(e,t){let n=await this.authModule.authenticate({payload:e,challenge:t!=null?t:ge((0,de.canonicalize)(e))});this.userAuthentications.set("default",n)}async setKeygenUserSigs(e,t){if(this.apiVersion==="v1"&&!t)throw new Error("no challenge response for keygen");for(let n of e){let r=n.signAlg,o=t?t[r]:ge((0,de.canonicalize)(n));if(o){let i=await this.authModule.authenticate({payload:n,challenge:o});this.userAuthentications.set(r,i)}else throw new Error(`no final challenge found in response for ${r}`)}}async setSigngenUserSigs(e,t){if(this.apiVersion==="v1"&&!t)throw new Error("no challenge response for signgen v1");await this.setDefaultAuth(e,t)}async setAddEphKeyUserSigs(e,t){if(this.apiVersion==="v1"&&!t)throw new Error("no challenge response for add ephemeral key v1");await this.setDefaultAuth(e,t)}async setRevokeEphKeyUserSigs(e,t){if(this.apiVersion==="v1"&&!t)throw new Error("no challenge response for revoke ephemeral key v1");await this.setDefaultAuth(e,t)}async setRegisterPasskeyUserSigs(e,t){if(!t)throw new Error("missing challenge response for registerPasskey");await this.setDefaultAuth(e,t)}async setKeyRefreshUserSigs(e,t){if(!t)throw new Error("missing challenge response for keyRefresh");await this.setDefaultAuth(e,t)}async setQcUserSigs(e,t){if(!t)throw new Error("missing challenge response for quorumChange");await this.setDefaultAuth(e,t)}async setFinishPresignUserSigs(e,t){await this.setDefaultAuth(e,t)}async build(e,t,n){if(e==="keygen"){let r=n?JSON.parse(n):void 0;await this.setKeygenUserSigs(t,r)}else e==="signgen"?await this.setSigngenUserSigs(t,n):e==="addEphemeralKey"?await this.setAddEphKeyUserSigs(t,n):e==="revokeEphemeralKey"?await this.setRevokeEphKeyUserSigs(t,n):e==="registerPasskey"?await this.setRegisterPasskeyUserSigs(t,n):e==="keyRefresh"?await this.setKeyRefreshUserSigs(t,n):e==="quorumChange"?await this.setQcUserSigs(t,n):e==="finishPresign"&&await this.setFinishPresignUserSigs(t,n);return Object.fromEntries(this.userAuthentications)}};var te=s=>{let{sign:e,recid:t}=s,n=(27+t).toString(16);return`0x${e}${n}`};var je=[{name:"tag",type:"uint16"},{name:"value",type:"string"}],f=class{constructor({t:e,n:t,ephClaim:n,permissions:r,signAlg:o}){c(this,"t");c(this,"n");c(this,"ephClaim");c(this,"metadata");c(this,"signAlg");d("signAlg",o),this.t=e,this.n=t,this.signAlg=o,this.ephClaim=n==null?void 0:n.toJSON(),this.metadata=[],r&&this.metadata.push({tag:1,value:r})}get eoaRequestSchema(){return{Request:[{name:"setup",type:"KeygenSetupOpts"},{name:"challenge",type:"string"}],KeygenSetupOpts:this.ephClaim?[{name:"t",type:"uint32"},{name:"n",type:"uint32"},{name:"ephClaim",type:"string"},{name:"metadata",type:"TaggedValue[]"}]:[{name:"t",type:"uint32"},{name:"n",type:"uint32"},{name:"metadata",type:"TaggedValue[]"}],TaggedValue:je}}},q=class{constructor({t:e,key_id:t,signAlg:n,message:r}){c(this,"t");c(this,"key_id");c(this,"message");c(this,"signAlg");d("keyId",t),d("signAlg",n),d("message",r),this.t=e,this.key_id=t,this.message=r,this.signAlg=n}},T=class{constructor({amount:e,keyId:t,t:n,expiryInSecs:r}){c(this,"amount");c(this,"key_id");c(this,"t");c(this,"expiry");if(e<=0)throw new Error("Amount must be greater than 0");d("keyId",t),this.amount=e,this.key_id=t,this.t=n,this.expiry=r!=null?r:Math.floor(Date.now()/1e3)+7*24*3600}},x=class{constructor({presignSessionId:e,message:t}){c(this,"presignSessionId");c(this,"message");d("presignSessionId",e),d("message",t),this.presignSessionId=e,this.message=t}};var P=class{constructor(e,t){c(this,"key_id");c(this,"eph_claim");d("keyId",e),this.key_id=e,this.eph_claim=t.toJSON()}get eoaRequestSchema(){return{Request:[{name:"setup",type:"RevokeEphKeyRequest"},{name:"challenge",type:"string"}],RevokeEphKeyRequest:[{name:"key_id",type:"string"},{name:"eph_claim",type:"string"}]}}},k=class{constructor(e,t){c(this,"key_id_list");c(this,"eph_claim");for(let n of e)d("keyId",n);this.key_id_list=e,this.eph_claim=t.toJSON()}get eoaRequestSchema(){return{Request:[{name:"setup",type:"AddEphKeyRequest"},{name:"challenge",type:"string"}],AddEphKeyRequest:[{name:"key_id_list",type:"string[]"},{name:"eph_claim",type:"string"}]}}},O=class{constructor(e){c(this,"options");d("options",e),this.options=e}},ne=class{constructor({newT:e,newN:t,keyId:n,signAlg:r}){c(this,"new_t");c(this,"new_n");c(this,"key_id");c(this,"sign_alg");d("keyId",n),d("signAlg",r),this.new_t=e,this.new_n=t,this.key_id=n,this.sign_alg=r}get eoaRequestSchema(){return{Request:[{name:"setup",type:"QuorumChangeRequest"},{name:"challenge",type:"string"}],QuorumChangeRequest:[{name:"new_t",type:"uint32"},{name:"new_n",type:"uint32"},{name:"key_id",type:"string"},{name:"sign_alg",type:"string"}]}}},M=class{constructor({t:e,keyId:t,signAlg:n}){c(this,"t");c(this,"key_id");c(this,"sign_alg");d("keyId",t),d("signAlg",n),this.t=e,this.key_id=t,this.sign_alg=n}get eoaRequestSchema(){return{Request:[{name:"setup",type:"KeyRefreshRequest"},{name:"challenge",type:"string"}],KeyRefreshRequest:[{name:"t",type:"uint32"},{name:"key_id",type:"string"},{name:"sign_alg",type:"string"}]}}};var se=s=>{var o,i,a;let e=s.split(":");g(e.length!==3,"Invalid keygen response from network");let t=(o=e[0])==null?void 0:o.split("=")[1],n=(i=e[1])==null?void 0:i.split("=")[1],r=(a=e[2])==null?void 0:a.split("=")[1];return{publicKey:n,keyId:t,signAlg:r}},K=(s,e)=>{let t=s.split(";");return g(t.length!==e,"Invalid keygen response from network, not all keys were generated"),t.map(n=>se(n))},C=(s,e)=>s.split(";").map(n=>{var r,o,i,a,u;if(e==="secp256k1"){let p=n.split(":");g(p.length!==3,"Invalid signgen response from network");let l=(r=p[0])==null?void 0:r.split("=")[1],h=(o=p[1])==null?void 0:o.split("=")[1],S=(i=p[2])==null?void 0:i.split("=")[1];if(l===void 0||h===void 0||S===void 0)throw new Error("Invalid signgen response from network");return{transactionId:S,sign:l,recid:parseInt(h)}}else{let p=n.split(":");g(p.length!==2,"Invalid signgen response from network");let l=(a=p[0])==null?void 0:a.split("=")[1],h=(u=p[1])==null?void 0:u.split("=")[1];if(l===void 0||h===void 0)throw new Error("Invalid signgen response from network");return{transactionId:h,sign:l,recid:0}}}),$=s=>{let e=s.split(";"),t=[];return e.forEach(n=>{let r=n.split(":");g(r.length!==2,"Invalid eph key operation response from network");let o=r[0],i=r[1];t.push({keyId:o,status:i})}),t};var J=require("json-canonicalize");var V=class{constructor(e){c(this,"walletProviderUrl");c(this,"apiVersion","v1");this.walletProviderUrl=`${e.walletProviderUrl}/${e.apiVersion}`,this.apiVersion=e.apiVersion}getVersion(){return this.apiVersion}async startKeygen({setups:e,authModule:t}){return(this.apiVersion==="v1"?this.connect.bind(this):this.connectV2.bind(this))("keygen",e,t).then(r=>K(r,e.length))}async startKeyRefresh({payload:e,authModule:t}){if(this.apiVersion==="v2")throw new Error("Key refresh is not supported in v2 API");return this.connect.bind(this)("keyRefresh",e,t).then(r=>se(r))}async startSigngen({setup:e,authModule:t}){return(this.apiVersion==="v1"?this.connect.bind(this):this.connectV2.bind(this))("signgen",e,t).then(r=>C(r,e.signAlg))}async addEphemeralKey({payload:e,authModule:t}){return(this.apiVersion==="v1"?this.connect.bind(this):this.connectV2.bind(this))("addEphemeralKey",e,t).then(r=>$(r))}async revokeEphemeralKey({payload:e,authModule:t}){return(this.apiVersion==="v1"?this.connect.bind(this):this.connectV2.bind(this))("revokeEphemeralKey",e,t).then(r=>({status:r}))}async registerPasskey({payload:e,authModule:t}){if(this.apiVersion==="v2")throw new Error("Passkey registration is not supported in v2 API");return this.connect.bind(this)("registerPasskey",e,t).then(r=>({passkeyCredentialId:r}))}connect(e,t,n){return new Promise((r,o)=>{let i=new WebSocket(`${this.walletProviderUrl}/${e}`),a=0;return console.debug("Connecting to ",i.url),i.addEventListener("open",u=>{switch(console.debug(`Connection opened in state ${a} with event ${JSON.stringify(u,void 0," ")}`),a){case 0:{a=1;try{let p=(0,J.canonicalize)({payload:t});console.debug("Sending request:",p),i.send(p)}catch(p){this.finishWithError(i,a,p,"open event",o)}break}case 1:case 2:this.finishWithError(i,a,"Unexpected message in state waitingForResult.","open event",o);break;case 3:break}}),i.addEventListener("message",async u=>{switch(console.debug(`Connection message in state ${a} with event data ${JSON.stringify(u.data,void 0," ")}`),a){case 0:this.finishWithError(i,a,"Unexpected message in state initiated.","message event",o);break;case 1:{a=2;try{let p=u.data,l=await new w(n,this.apiVersion).build(e,t,p);i.send((0,J.canonicalize)(l))}catch(p){this.finishWithError(i,a,p,"message event",o)}break}case 2:{a=3,i.close(),r(u.data);break}case 3:break}}),i.addEventListener("error",u=>{console.debug(`Connection error in state ${a} with event ${JSON.stringify(u,void 0," ")}`),this.finishWithError(i,a,`Connection encountered an error event: ${u}`,"error event",o)}),i.addEventListener("close",u=>{let p=u.reason||"No specific reason provided.",l=u.code;console.debug(`Connection closed. State: ${a}, Code: ${l}, Reason: '${p}'`);let h=l>=4e3?`Application Error ${l}: ${p}`:l===1006?"Connection Abnormality (Code 1006): Server closed connection unexpectedly or network issue.":`WebSocket Closed Unexpectedly (Code ${l}): ${p}`;this.finishWithError(i,a,new Error(h),"close event",o)}),()=>{(i.readyState===WebSocket.OPEN||i.readyState===WebSocket.CONNECTING)&&i.close(1001,"Cleanup/Unmount")}})}connectV2(e,t,n){return new Promise((r,o)=>{let i=new WebSocket(`${this.walletProviderUrl}/${e}`),a=0;return console.debug("Connecting to ",i.url),i.addEventListener("open",async u=>{switch(console.debug(`Connection opened in state ${a} with event ${JSON.stringify(u,void 0," ")}`),a){case 0:a=2;try{let p=await new w(n,this.apiVersion).build(e,t);i.send((0,J.canonicalize)({payload:t,userSigs:p}))}catch(p){this.finishWithError(i,a,p,"open event",o)}break;case 2:a=3,this.finishWithError(i,a,"Unexpected message in state waitingForResult.","open event",o);break;case 3:break}}),i.addEventListener("message",async u=>{switch(console.debug(`Connection message in state ${a} with event ${JSON.stringify(u,void 0," ")}`),a){case 0:this.finishWithError(i,a,"Unexpected message in state initiated.","message event",o);break;case 2:{a=3,i.close(),r(u.data);break}case 3:break}}),i.addEventListener("error",u=>{console.debug(`Connection error in state ${a} with event ${JSON.stringify(u,void 0," ")}`),this.finishWithError(i,a,`Connection encountered an error event: ${u}`,"error event",o)}),i.addEventListener("close",u=>{let p=u.reason||"No specific reason provided.",l=u.code;console.debug(`Connection closed. State: ${a}, Code: ${l}, Reason: '${p}'`);let h=l>=4e3?`Application Error ${l}: ${p}`:l===1006?"Connection Abnormality (Code 1006): Server closed connection unexpectedly or network issue.":`WebSocket Closed Unexpectedly (Code ${l}): ${p}`;this.finishWithError(i,a,new Error(h),"close event",o)}),()=>{(i.readyState===WebSocket.OPEN||i.readyState===WebSocket.CONNECTING)&&i.close(1001,"Cleanup/Unmount")}})}finishWithError(e,t,n,r,o){console.error(`Error from ${r} in state ${t}:`,n),t!==3&&(t=3),e.readyState===WebSocket.OPEN&&e.close(1011,`Protocol run failed. Client attempted to close connection in state ${t}`),o(n instanceof Error?n:new Error(String(n)))}},R=class{constructor(e){c(this,"walletProviderUrl");c(this,"apiVersion","v1");this.walletProviderUrl=`${e.walletProviderUrl}/${e.apiVersion}`,this.apiVersion=e.apiVersion}getVersion(){return this.apiVersion}async startKeygen({setups:e}){return this.connect.bind(this)("keygen",e).then(n=>K(n,e.length))}async startSigngen({setup:e}){return this.connect.bind(this)("signgen",e).then(n=>C(n,e.signAlg))}async startKeyRefresh({payload:e}){if(this.apiVersion==="v2")throw new Error("Key refresh is not supported in v2 API");return this.connect.bind(this)("keyRefresh",e).then(n=>se(n))}connect(e,t){return new Promise((n,r)=>{let o=0,i=new WebSocket(`${this.walletProviderUrl}/${e}`);i.addEventListener("open",async a=>{switch(console.debug(`Connection opened in state ${o} with event ${JSON.stringify(a,void 0," ")}`),o){case 0:o=2;try{i.send((0,J.canonicalize)({payload:t}))}catch(u){r(u)}break;case 2:o=3,r("Incorrect protocol state");break;case 3:break}}),i.addEventListener("message",async a=>{switch(console.debug(`Connection message in state ${o} with event ${JSON.stringify(a,void 0," ")}`),o){case 0:o=3,r("Incorrect protocol state");break;case 2:{o=3,i.close(),n(a.data);break}case 3:break}}),i.addEventListener("error",a=>{console.debug(`Connection error in state ${o} with event ${JSON.stringify(a,void 0," ")}`),o!=3&&(o=3,r("Incorrect protocol state"))}),i.addEventListener("close",a=>{console.debug(`Connection closed in state ${o} with event ${JSON.stringify(a,void 0," ")}`),o!=3&&(o=3,r("Incorrect protocol state"))})})}};var N=class{constructor(e,t){c(this,"authModule");c(this,"wpClient");if(!t&&!(e instanceof R))throw new Error("missing authModule for wallet provider client in auth mode");if(t&&e instanceof R)throw new Error("authModule is required but using wallet provider client in no-auth mode");this.authModule=t,this.wpClient=e}validateQuorumSetup({threshold:e,totalNodes:t}){e&&g(e<2,`Threshold = ${e} must be at least 2`),e&&t&&g(t<e,`Total nodes = ${t} must be greater or equal to threshold = ${e}`)}async generateKey(e,t,n,r,o){this.validateQuorumSetup({threshold:e,totalNodes:t});let i=n.map(a=>new f({t:e,n:t,ephClaim:r,permissions:o,signAlg:a}));return this.authModule?await this.wpClient.startKeygen({setups:i,authModule:this.authModule}):await this.wpClient.startKeygen({setups:i})}async signMessage(e,t,n,r){this.validateQuorumSetup({threshold:e}),xe(n);let o=new q({t:e,key_id:t,signAlg:n,message:r});return this.authModule?await this.wpClient.startSigngen({setup:o,authModule:this.authModule}):await this.wpClient.startSigngen({setup:o})}async refreshKey(e,t,n){let r=new M({t:e,keyId:t,signAlg:n});return this.authModule?await this.wpClient.startKeyRefresh({payload:r,authModule:this.authModule}):await this.wpClient.startKeyRefresh({payload:r})}async addEphemeralKey(e,t){let n=new k(e,t);if(!this.authModule)throw new Error("Add ephemeral key is not supported in no auth mode");return await this.wpClient.addEphemeralKey({payload:n,authModule:this.authModule})}async revokeEphemeralKey(e,t){d("keyId",e);let n=new P(e,t);if(!this.authModule)throw new Error("Revoke ephemeral key is not supported in no auth mode");return await this.wpClient.revokeEphemeralKey({payload:n,authModule:this.authModule})}async registerPasskey(e){let t=new O(e!=null?e:"passkey options");if(!this.authModule)throw new Error("Register passkey is not supported in no auth mode");return await this.wpClient.registerPasskey({payload:t,authModule:this.authModule})}};var Ie=require("json-canonicalize");var ye=class extends Error{constructor(t,n,r){super(r||n);this.status=t;this.statusText=n;this.name="HttpError"}},W=class{constructor(e="",t={}){c(this,"baseURL");c(this,"defaultHeaders");this.baseURL=e,this.validateHeaders(t),this.defaultHeaders={"Content-Type":"application/json",...t}}validateHeaders(e){if(typeof e!="object"||e===null)throw new Error("Headers must be an object.");for(let[t,n]of Object.entries(e))if(typeof t!="string"||typeof n!="string")throw new Error(`Invalid header: ${t}. Header names and values must be strings.`)}setDefaultHeaders(e){this.defaultHeaders={...this.defaultHeaders,...e}}buildUrl(e){return`${this.baseURL}${e}`}async handleResponse(e){if(!e.ok){let n;try{n=(await e.json()).message||e.statusText}catch{n=e.statusText}throw new ye(e.status,e.statusText,n)}let t=e.headers.get("content-type");return t&&t.includes("application/json")?e.json():e.text()}async request(e,t,n,r={}){let o=this.buildUrl(t),i={...this.defaultHeaders,...r.headers},a={method:e,headers:i,...r,body:n?(0,Ie.canonicalize)(n):null},u=await fetch(o,a);return this.handleResponse(u)}async get(e,t){return this.request("GET",e,void 0,t)}async post(e,t,n){return this.request("POST",e,t,n)}async put(e,t,n){return this.request("PUT",e,t,n)}async patch(e,t,n){return this.request("PATCH",e,t,n)}async delete(e,t){return this.request("DELETE",e,void 0,t)}};var Xe={name:"SilentShard authentication",version:"0.1.0"},Ye=[{name:"name",type:"string"},{name:"version",type:"string"}];function Ze(s,e){let t={setup:s,challenge:e};return{types:{EIP712Domain:Ye,...s.eoaRequestSchema},domain:Xe,primaryType:"Request",message:t}}async function Ue({setup:s,eoa:e,challenge:t,browserWallet:n}){let r=Ze(s,t),o=await n.signTypedData(e,r);return{credentials:{credentials:"",method:"eoa",id:e},signature:o}}var fe=require("js-base64"),me=require("viem"),G=require("json-canonicalize");async function qe({user:s,challenge:e,rpConfig:t}){let n=(0,me.hexToBytes)(`0x${e}`,{size:32}),r={publicKey:{authenticatorSelection:{residentKey:"preferred",userVerification:"required"},challenge:n,excludeCredentials:[],pubKeyCredParams:[{type:"public-key",alg:-7},{type:"public-key",alg:-257}],rp:{name:t.rpName,id:t.rpId},user:{...s,id:fe.Base64.toUint8Array(s.id)}}},o=await navigator.credentials.create(r);if(o===null)throw new Error("No credential returned");let i=m(o.response.attestationObject),u={rawCredential:(0,G.canonicalize)({authenticatorAttachment:o.authenticatorAttachment,id:o.id,rawId:m(o.rawId),response:{attestationObject:i,clientDataJSON:m(o.response.clientDataJSON)},type:o.type}),origin:t.rpName,rpId:t.rpId};return{credentials:{credentials:"",method:"passkey",id:o.id},signature:(0,G.canonicalize)(u)}}async function Te({challenge:s,allowCredentialId:e,rpConfig:t}){let n=(0,me.hexToBytes)(`0x${s}`,{size:32}),r=e?[{type:"public-key",id:fe.Base64.toUint8Array(e)}]:[],o={publicKey:{userVerification:"required",challenge:n,allowCredentials:r}},i=await navigator.credentials.get(o);if(i===null)throw new Error("Failed to get navigator credentials");let a=i.response,u=a.userHandle;if(u===null)throw new Error("User handle cannot be null");let p=m(a.signature),h={rawCredential:(0,G.canonicalize)({authenticatorAttachment:i.authenticatorAttachment,id:i.id,rawId:m(i.rawId),response:{authenticatorData:m(a.authenticatorData),clientDataJSON:m(a.clientDataJSON),signature:p,userHandle:m(u)},type:i.type}),origin:t.rpName,rpId:t.rpId};return{credentials:{credentials:"",method:"passkey",id:i.id},signature:(0,G.canonicalize)(h)}}var z=require("viem"),re=require("@noble/curves/ed25519"),we=require("@noble/curves/secp256k1");var Oe=require("viem/accounts"),Re=require("json-canonicalize");var E=class s{constructor(e,t,n,r=Math.floor(Date.now()/1e3)+3600){c(this,"ephId");c(this,"ephPK");c(this,"signAlg");c(this,"expiry");this.validateInputs(e,t,n,r),this.ephId=e,this.ephPK=(0,z.toHex)(t),this.signAlg=n,this.expiry=r}validateInputs(e,t,n,r){d("ephId",e),be(t,n),g(Number.isInteger(r)===!1,"expiry must be an integer");let o=Math.floor(Date.now()/1e3),i=r-o,a=i>0&&i<=365*24*60*60;g(!a,`lifetime must be greater than 0 and less than or equal to 365 days expiry - now ${i}, expiry ${r} now secs ${o}`)}toJSON(){return(0,Re.canonicalize)({ephId:this.ephId,ephPK:this.ephPK,expiry:this.expiry,signAlg:this.signAlg})}static generateKeys(e,t){let n=Q(e),r=I(n,e),o=new s((0,z.toHex)(r),r,e,t);return{privKey:n,pubKey:r,ephClaim:o}}};async function Me({setup:s,challenge:e,ephSK:t,ephClaim:n}){let r={setup:s,challenge:e},o=new TextEncoder().encode((0,Re.canonicalize)(r)),i=await et(o,t,n.signAlg);return{credentials:{credentials:n.toJSON(),method:"ephemeral",id:n.ephId},signature:i}}async function et(s,e,t){switch(t){case"ed25519":return(0,z.toHex)(re.ed25519.sign(s,e));case"secp256k1":return await(0,Oe.signMessage)({message:{raw:s},privateKey:(0,z.toHex)(e)});default:throw new Error("Invalid signature algorithm")}}function Q(s){switch(s){case"ed25519":return re.ed25519.utils.randomPrivateKey();case"secp256k1":return we.secp256k1.utils.randomPrivateKey();default:throw new Error("Invalid signature algorithm")}}function I(s,e){switch(e){case"ed25519":return re.ed25519.getPublicKey(s);case"secp256k1":return we.secp256k1.getPublicKey(s,!1);default:throw new Error("Invalid signature algorithm")}}var $e=require("viem");var D=class{constructor(e,t){c(this,"browserWallet");c(this,"eoa");this.validateInputs(e,t),this.browserWallet=t,this.eoa=e}validateInputs(e,t){g(!(0,$e.isAddress)(e),"invalid Ethereum address format"),g(!((t==null?void 0:t.signTypedData)instanceof Function),"invalid browserWallet")}async authenticate({payload:e,challenge:t}){return H(e,[f,M,ne,k,P],"eoa"),await Ue({setup:e,eoa:this.eoa,challenge:t,browserWallet:this.browserWallet})}},_=class{constructor(e,t,n){c(this,"ephSK");c(this,"ephClaim");Ae(t,n),this.ephSK=t;let r=I(this.ephSK,n);this.ephClaim=new E(e,r,n)}async authenticate({payload:e,challenge:t}){return H(e,[q,P,x],"ephemeral"),await Me({setup:e,challenge:t,ephSK:this.ephSK,ephClaim:this.ephClaim})}},B=class{constructor(e,t){c(this,"rpConfig");c(this,"allowCredentialId");this.rpConfig=e,this.allowCredentialId=t}async authenticate({payload:e,challenge:t}){return H(e,[f,k,P],"passkey"),await Te({allowCredentialId:this.allowCredentialId,challenge:t,rpConfig:this.rpConfig})}},L=class{constructor(e,t){c(this,"rpConfig");c(this,"user");this.rpConfig=e,this.user=t}async authenticate({payload:e,challenge:t}){return H(e,[O],"passkey"),await qe({user:this.user,challenge:t,rpConfig:this.rpConfig})}};var ie=require("viem/accounts"),Ve=require("@noble/curves/secp256k1"),F=require("viem"),tt=require("js-base64");function oe(s){if(s.startsWith("0x")&&(s=s.slice(2)),s.startsWith("04"))return(0,ie.publicKeyToAddress)(`0x${s} `);if(s.startsWith("02")||s.startsWith("03")){let e=Ve.secp256k1.ProjectivePoint.fromHex(s).toHex(!1);return(0,ie.publicKeyToAddress)(`0x${e}`)}else throw new Error("Invalid public key")}var nt={KeygenSetupOpts:f,InitPresignOpts:T,FinishPresignOpts:x,UserSignatures:w,NetworkSigner:N,SignRequestBuilder:v,WalletProviderServiceClient:V,NoAuthWalletProviderServiceClient:R,HttpClient:W,EOAAuth:D,EphAuth:_,PasskeyAuth:B,PasskeyRegister:L,generateEphPrivateKey:Q,getEphPublicKey:I,EphKeyClaim:E,computeAddress:oe,flattenSignature:te,parseSigngenResult:C,parseKeygenResult:K,parseEphKeyOperationResult:$};0&&(module.exports={EOAAuth,EphAuth,EphKeyClaim,FinishPresignOpts,HttpClient,InitPresignOpts,KeygenSetupOpts,NetworkSigner,NoAuthWalletProviderServiceClient,PasskeyAuth,PasskeyRegister,SignRequestBuilder,UserSignatures,WalletProviderServiceClient,computeAddress,flattenSignature,generateEphPrivateKey,getEphPublicKey,parseEphKeyOperationResult,parseKeygenResult,parseSigngenResult});
|
|
1
|
+
"use strict";var X=Object.defineProperty;var Qe=Object.getOwnPropertyDescriptor;var Xe=Object.getOwnPropertyNames;var Ye=Object.prototype.hasOwnProperty;var Ze=(s,e,t)=>e in s?X(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var Ue=(s,e)=>{for(var t in e)X(s,t,{get:e[t],enumerable:!0})},et=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Xe(e))!Ye.call(s,n)&&n!==t&&X(s,n,{get:()=>e[n],enumerable:!(r=Qe(e,n))||r.enumerable});return s};var tt=s=>et(X({},"__esModule",{value:!0}),s);var c=(s,e,t)=>Ze(s,typeof e!="symbol"?e+"":e,t);var gt={};Ue(gt,{Action:()=>xe,ChainType:()=>Ee,DeletePolicyRequest:()=>P,EOAAuth:()=>$,EphAuth:()=>V,EphKeyClaim:()=>K,FinishPresignOpts:()=>R,HttpClient:()=>_,InitPresignOpts:()=>T,IssuerType:()=>Ae,KeygenSetupOpts:()=>S,Logic:()=>be,NetworkSigner:()=>F,NoAuthWalletProviderServiceClient:()=>E,Operator:()=>Ce,PasskeyAuth:()=>q,PasskeyRegister:()=>W,Policy:()=>ce,Rule:()=>ae,SignRequestBuilder:()=>U,SignSetupOpts:()=>m,TransactionAttribute:()=>ke,TransactionType:()=>ve,UpdatePolicyRequest:()=>w,UserSignatures:()=>x,WalletProviderServiceClient:()=>B,computeAddress:()=>ie,default:()=>dt,flattenSignature:()=>re,generateEphPrivateKey:()=>j,getEphPublicKey:()=>O});module.exports=tt(gt);var Ne=require("json-canonicalize");var h=(s,e)=>{g(typeof e!="string",`${s} must be string`),g((e==null?void 0:e.trim().length)===0,`${s} cannot be empty`)},Ie=(s,e)=>{if(g(!(s instanceof Uint8Array),"key must be an Uint8Array"),e==="secp256k1")g(s.length!==65,"secp256k1: key length must be 65 bytes, got "+s.length);else if(e==="ed25519")g(s.length!==32,"ed25519: key length must be 32 bytes, got "+s.length);else throw new Error("Invalid signature algorithm")},Me=(s,e)=>{if(g(!(s instanceof Uint8Array),"key must be an Uint8Array"),e==="secp256k1")g(s.length!==32,"secp256k1: key length must be 32 bytes, got "+s.length);else if(e==="ed25519")g(s.length!==32,"ed25519: key length must be 32 bytes, got "+s.length);else throw new Error("Invalid signature algorithm")},Oe=s=>{g(s!=="ed25519"&&s!=="secp256k1",'signAlg must be either "ed25519" or "secp256k"')},g=(s,e)=>{if(s)throw new Error(e)},rt=(s,e)=>`Invalid payload ${JSON.stringify(s)}, cannot be authenticated by ${e.toLocaleUpperCase()} method.`,H=(s,e,t)=>{g(!e.some(r=>s instanceof r),rt(s,t))};var U=class{constructor(){c(this,"signRequest",new Map)}setRequest(e,t,r){if(h("transactionId",e),h("message",t),h("requestType",r),this.signRequest.has(e))throw new Error(`Transaction ID ${e} is already set.`);return this.signRequest.set(e,{signingMessage:t,requestType:r}),this}build(){let e={};if(this.signRequest.forEach((t,r)=>{e[r]=t}),Object.keys(e).length===0)throw new Error("No sign request is set.");return(0,Ne.canonicalize)(e)}};var me=require("json-canonicalize");var We=require("js-base64");function st(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function ue(s,...e){if(!st(s))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(s.length))throw new Error("Uint8Array expected of length "+e+", got length="+s.length)}function pe(s,e=!0){if(s.destroyed)throw new Error("Hash instance has been destroyed");if(e&&s.finished)throw new Error("Hash#digest() has already been called")}function De(s,e){ue(s);let t=e.outputLen;if(s.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}var Z=s=>new DataView(s.buffer,s.byteOffset,s.byteLength),f=(s,e)=>s<<32-e|s>>>e;function nt(s){if(typeof s!="string")throw new Error("utf8ToBytes expected string, got "+typeof s);return new Uint8Array(new TextEncoder().encode(s))}function he(s){return typeof s=="string"&&(s=nt(s)),ue(s),s}var Y=class{clone(){return this._cloneInto()}};function Te(s){let e=r=>s().update(he(r)).digest(),t=s();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>s(),e}function it(s,e,t,r){if(typeof s.setBigUint64=="function")return s.setBigUint64(e,t,r);let n=BigInt(32),o=BigInt(4294967295),i=Number(t>>n&o),a=Number(t&o),l=r?4:0,u=r?0:4;s.setUint32(e+l,i,r),s.setUint32(e+u,a,r)}var $e=(s,e,t)=>s&e^~s&t,Ve=(s,e,t)=>s&e^s&t^e&t,ee=class extends Y{constructor(e,t,r,n){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Z(this.buffer)}update(e){pe(this);let{view:t,buffer:r,blockLen:n}=this;e=he(e);let o=e.length;for(let i=0;i<o;){let a=Math.min(n-this.pos,o-i);if(a===n){let l=Z(e);for(;n<=o-i;i+=n)this.process(l,i);continue}r.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===n&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){pe(this),De(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:n,isLE:o}=this,{pos:i}=this;t[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>n-i&&(this.process(r,0),i=0);for(let p=i;p<n;p++)t[p]=0;it(r,n-8,BigInt(this.length*8),o),this.process(r,0);let a=Z(e),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=l/4,d=this.get();if(u>d.length)throw new Error("_sha2: outputLen bigger than state");for(let p=0;p<u;p++)a.setUint32(4*p,d[p],o)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:r,length:n,finished:o,destroyed:i,pos:a}=this;return e.length=n,e.pos=a,e.finished=o,e.destroyed=i,n%t&&e.buffer.set(r),e}};var ot=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),v=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),k=new Uint32Array(64),de=class extends ee{constructor(){super(64,32,8,!1),this.A=v[0]|0,this.B=v[1]|0,this.C=v[2]|0,this.D=v[3]|0,this.E=v[4]|0,this.F=v[5]|0,this.G=v[6]|0,this.H=v[7]|0}get(){let{A:e,B:t,C:r,D:n,E:o,F:i,G:a,H:l}=this;return[e,t,r,n,o,i,a,l]}set(e,t,r,n,o,i,a,l){this.A=e|0,this.B=t|0,this.C=r|0,this.D=n|0,this.E=o|0,this.F=i|0,this.G=a|0,this.H=l|0}process(e,t){for(let p=0;p<16;p++,t+=4)k[p]=e.getUint32(t,!1);for(let p=16;p<64;p++){let J=k[p-15],N=k[p-2],qe=f(J,7)^f(J,18)^J>>>3,le=f(N,17)^f(N,19)^N>>>10;k[p]=le+k[p-7]+qe+k[p-16]|0}let{A:r,B:n,C:o,D:i,E:a,F:l,G:u,H:d}=this;for(let p=0;p<64;p++){let J=f(a,6)^f(a,11)^f(a,25),N=d+J+$e(a,l,u)+ot[p]+k[p]|0,le=(f(r,2)^f(r,13)^f(r,22))+Ve(r,n,o)|0;d=u,u=l,l=a,a=i+N|0,i=o,o=n,n=r,r=N+le|0}r=r+this.A|0,n=n+this.B|0,o=o+this.C|0,i=i+this.D|0,a=a+this.E|0,l=l+this.F|0,u=u+this.G|0,d=d+this.H|0,this.set(r,n,o,i,a,l,u,d)}roundClean(){k.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var ge=Te(()=>new de);var te=require("viem"),A=s=>We.Base64.fromUint8Array(new Uint8Array(s),!0),ye=s=>{let e=(0,te.stringToBytes)(s),t=ge(ge(e));return(0,te.toHex)(t,{size:32}).slice(2)};var x=class{constructor(e,t){c(this,"userAuthentications");c(this,"authModule");c(this,"apiVersion");this.authModule=e,this.userAuthentications=new Map,this.apiVersion=t}async setDefaultAuth(e){let t=await this.authModule.authenticate({payload:e.payload,challenge:e.challenge});this.userAuthentications.set("default",t)}async setKeygenUserSigs(e,t){if(this.apiVersion==="v1"&&!t)throw new Error("no challenge response for keygen");for(let r of e){let n=r.signAlg,o=t?t[n]:ye((0,me.canonicalize)(r));if(o){let i=await this.authModule.authenticate({payload:r,challenge:o});this.userAuthentications.set(n,i)}else throw new Error(`no final challenge found in response for ${n}`)}}async setSigngenUserSigs(e){await this.setDefaultAuth(e)}async setAddEphKeyUserSigs(e){await this.setDefaultAuth(e)}async setRevokeEphKeyUserSigs(e){await this.setDefaultAuth(e)}async setRegisterPasskeyUserSigs(e){await this.setDefaultAuth(e)}async setKeyRefreshUserSigs(e){await this.setDefaultAuth(e)}async setFinishPresignUserSigs(e){await this.setDefaultAuth(e)}async setUpdatePolicyUserSigs(e){await this.setDefaultAuth(e)}async setDeletePolicyUserSigs(e){await this.setDefaultAuth(e)}async build(e,t,r){if(this.apiVersion!=="v1"&&(e==="registerPasskey"||e==="keyRefresh"))throw new Error(`${e} is only supported in V1`);let{challenge:n}=r!=null?r:{};if(e==="keygen"){let o=n?JSON.parse(n):void 0;await this.setKeygenUserSigs(t,o)}else{if(this.apiVersion==="v1"&&!n)throw new Error(`missing challenge response for ${e} V1`);let o=n!=null?n:ye((0,me.canonicalize)(t));e==="signgen"?await this.setSigngenUserSigs({payload:t,challenge:o}):e==="addEphemeralKey"?await this.setAddEphKeyUserSigs({payload:t,challenge:o}):e==="revokeEphemeralKey"?await this.setRevokeEphKeyUserSigs({payload:t,challenge:o}):e==="registerPasskey"?await this.setRegisterPasskeyUserSigs({payload:t,challenge:o}):e==="keyRefresh"?await this.setKeyRefreshUserSigs({payload:t,challenge:o}):e==="finishPresign"?await this.setFinishPresignUserSigs({payload:t,challenge:o}):e==="updatePolicy"?await this.setUpdatePolicyUserSigs({payload:t,challenge:o}):e==="deletePolicy"&&await this.setDeletePolicyUserSigs({payload:t,challenge:o})}return Object.fromEntries(this.userAuthentications)}};var re=s=>{let{sign:e,recid:t}=s,r=(27+t).toString(16);return`0x${e}${r}`};var C=class{constructor(e,t){c(this,"key_id");c(this,"eph_claim");h("keyId",e),this.key_id=e,this.eph_claim=t.toJSON()}get eoaRequestSchema(){return{Request:[{name:"setup",type:"RevokeEphKeyRequest"},{name:"challenge",type:"string"}],RevokeEphKeyRequest:[{name:"key_id",type:"string"},{name:"eph_claim",type:"string"}]}}},I=class{constructor(e,t){c(this,"key_id_list");c(this,"eph_claim");for(let r of e)h("keyId",r);this.key_id_list=e,this.eph_claim=t.toJSON()}get eoaRequestSchema(){return{Request:[{name:"setup",type:"AddEphKeyRequest"},{name:"challenge",type:"string"}],AddEphKeyRequest:[{name:"key_id_list",type:"string[]"},{name:"eph_claim",type:"string"}]}}},D=class{constructor(e){c(this,"options");h("options",e),this.options=e}},M=class{constructor({t:e,keyId:t,signAlg:r}){c(this,"t");c(this,"key_id");c(this,"sign_alg");h("keyId",t),h("signAlg",r),this.t=e,this.key_id=t,this.sign_alg=r}get eoaRequestSchema(){return{Request:[{name:"setup",type:"KeyRefreshRequest"},{name:"challenge",type:"string"}],KeyRefreshRequest:[{name:"t",type:"uint32"},{name:"key_id",type:"string"},{name:"sign_alg",type:"string"}]}}},w=class{constructor({keyId:e,policy:t}){c(this,"key_id");c(this,"policy");h("keyId",e),this.key_id=e,this.policy=t.toJSON()}get eoaRequestSchema(){return{Request:[{name:"setup",type:"UpdatePolicyRequest"},{name:"challenge",type:"string"}],UpdatePolicyRequest:[{name:"key_id",type:"string"},{name:"policy",type:"string"}]}}},P=class{constructor({keyId:e}){c(this,"key_id");h("keyId",e),this.key_id=e}get eoaRequestSchema(){return{Request:[{name:"setup",type:"DeletePolicyRequest"},{name:"challenge",type:"string"}],DeletePolicyRequest:[{name:"key_id",type:"string"}]}}};var at=[{name:"tag",type:"uint16"},{name:"value",type:"string"}],S=class{constructor({t:e,n:t,ephClaim:r,policy:n,signAlg:o}){c(this,"t");c(this,"n");c(this,"ephClaim");c(this,"metadata");c(this,"signAlg");c(this,"policy");h("signAlg",o),this.t=e,this.n=t,this.signAlg=o,this.ephClaim=r==null?void 0:r.toJSON(),this.metadata=[],this.policy=n==null?void 0:n.toJSON()}get eoaRequestSchema(){let e=[{name:"t",type:"uint32"},{name:"n",type:"uint32"},{name:"metadata",type:"TaggedValue[]"}];return this.ephClaim&&e.push({name:"ephClaim",type:"string"}),this.policy&&e.push({name:"policy",type:"string"}),{Request:[{name:"setup",type:"KeygenSetupOpts"},{name:"challenge",type:"string"}],KeygenSetupOpts:e,TaggedValue:at}}},m=class{constructor({t:e,key_id:t,signAlg:r,message:n}){c(this,"t");c(this,"key_id");c(this,"message");c(this,"signAlg");h("keyId",t),h("signAlg",r),h("message",n),this.t=e,this.key_id=t,this.message=n,this.signAlg=r}get eoaRequestSchema(){return{Request:[{name:"setup",type:"SignSetupOpts"},{name:"challenge",type:"string"}],SignSetupOpts:[{name:"t",type:"uint32"},{name:"key_id",type:"string"},{name:"signAlg",type:"string"},{name:"message",type:"string"}]}}},T=class{constructor({amount:e,keyId:t,t:r,expiryInSecs:n}){c(this,"amount");c(this,"key_id");c(this,"t");c(this,"expiry");if(e<=0)throw new Error("Amount must be greater than 0");h("keyId",t),this.amount=e,this.key_id=t,this.t=r,this.expiry=n!=null?n:Math.floor(Date.now()/1e3)+7*24*3600}},R=class{constructor({presignSessionId:e,message:t}){c(this,"presignSessionId");c(this,"message");h("presignSessionId",e),h("message",t),this.presignSessionId=e,this.message=t}get eoaRequestSchema(){return{Request:[{name:"setup",type:"FinishPresignOpts"},{name:"challenge",type:"string"}],FinishPresignOpts:[{name:"presignSessionId",type:"string"},{name:"message",type:"string"}]}}};var ct={name:"SilentShard authentication",version:"0.1.0"},lt=[{name:"name",type:"string"},{name:"version",type:"string"}];function ut(s,e){let t={setup:s,challenge:e};return{types:{EIP712Domain:lt,...s.eoaRequestSchema},domain:ct,primaryType:"Request",message:t}}async function Be({setup:s,eoa:e,challenge:t,browserWallet:r}){let n=ut(s,t),o=await r.signTypedData(e,n);return new b({method:"eoa",id:e},o)}var fe=require("js-base64"),we=require("viem"),G=require("json-canonicalize");async function Fe({user:s,challenge:e,rpConfig:t}){let r=(0,we.hexToBytes)(`0x${e}`,{size:32}),n={publicKey:{authenticatorSelection:{residentKey:"preferred",userVerification:"required"},challenge:r,excludeCredentials:[],pubKeyCredParams:[{type:"public-key",alg:-7},{type:"public-key",alg:-257}],rp:{name:t.rpName,id:t.rpId},user:{...s,id:fe.Base64.toUint8Array(s.id)}}},o=await navigator.credentials.create(n);if(o===null)throw new Error("No credential returned");let i=A(o.response.attestationObject),l={rawCredential:(0,G.canonicalize)({authenticatorAttachment:o.authenticatorAttachment,id:o.id,rawId:A(o.rawId),response:{attestationObject:i,clientDataJSON:A(o.response.clientDataJSON)},type:o.type}),origin:t.rpName,rpId:t.rpId};return new b({method:"passkey",id:o.id},(0,G.canonicalize)(l))}async function _e({challenge:s,allowCredentialId:e,rpConfig:t}){let r=(0,we.hexToBytes)(`0x${s}`,{size:32}),n=e?[{type:"public-key",id:fe.Base64.toUint8Array(e)}]:[],o={publicKey:{userVerification:"required",challenge:r,allowCredentials:n}},i=await navigator.credentials.get(o);if(i===null)throw new Error("Failed to get navigator credentials");let a=i.response,l=a.userHandle;if(l===null)throw new Error("User handle cannot be null");let u=A(a.signature),p={rawCredential:(0,G.canonicalize)({authenticatorAttachment:i.authenticatorAttachment,id:i.id,rawId:A(i.rawId),response:{authenticatorData:A(a.authenticatorData),clientDataJSON:A(a.clientDataJSON),signature:u,userHandle:A(l)},type:i.type}),origin:t.rpName,rpId:t.rpId};return new b({method:"passkey",id:i.id},(0,G.canonicalize)(p))}var z=require("viem");var se=require("@noble/curves/ed25519"),Pe=require("@noble/curves/secp256k1");var Le=require("viem/accounts"),Se=require("json-canonicalize");var K=class s{constructor(e,t,r,n=Math.floor(Date.now()/1e3)+3600){c(this,"ephId");c(this,"ephPK");c(this,"signAlg");c(this,"expiry");this.validateInputs(e,t,r,n),this.ephId=e,this.ephPK=(0,z.toHex)(t),this.signAlg=r,this.expiry=n}validateInputs(e,t,r,n){h("ephId",e),Ie(t,r),g(Number.isInteger(n)===!1,"expiry must be an integer");let o=Math.floor(Date.now()/1e3),i=n-o,a=i>0&&i<=365*24*60*60;g(!a,`lifetime must be greater than 0 and less than or equal to 365 days expiry - now ${i}, expiry ${n} now secs ${o}`)}toJSON(){try{return(0,Se.canonicalize)({ephId:this.ephId,ephPK:this.ephPK,expiry:this.expiry,signAlg:this.signAlg})}catch(e){throw console.error("Error while serializing ephemeral key claim",e),new Error("Error while serializing ephemeral key claim")}}static generateKeys(e,t){let r=j(e),n=O(r,e),o=new s((0,z.toHex)(n),n,e,t);return{privKey:r,pubKey:n,ephClaim:o}}};async function Je({setup:s,challenge:e,ephSK:t,ephClaim:r}){let n={setup:s,challenge:e},o=new TextEncoder().encode((0,Se.canonicalize)(n)),i=await pt(o,t,r.signAlg);return new b({method:"ephemeral",id:r.ephId},i)}async function pt(s,e,t){switch(t){case"ed25519":return(0,z.toHex)(se.ed25519.sign(s,e));case"secp256k1":return await(0,Le.signMessage)({message:{raw:s},privateKey:(0,z.toHex)(e)});default:throw new Error("Invalid signature algorithm")}}function j(s){switch(s){case"ed25519":return se.ed25519.utils.randomPrivateKey();case"secp256k1":return Pe.secp256k1.utils.randomPrivateKey();default:throw new Error("Invalid signature algorithm")}}function O(s,e){switch(e){case"ed25519":return se.ed25519.getPublicKey(s);case"secp256k1":return Pe.secp256k1.getPublicKey(s,!1);default:throw new Error("Invalid signature algorithm")}}var He=require("viem");var b=class{constructor(e,t){this.credentials=e;this.signature=t;this.credentials=e,this.signature=t}},$=class{constructor(e,t){c(this,"browserWallet");c(this,"eoa");this.validateInputs(e,t),this.browserWallet=t,this.eoa=e}validateInputs(e,t){g(!(0,He.isAddress)(e),"invalid Ethereum address format"),g(!((t==null?void 0:t.signTypedData)instanceof Function),"invalid browserWallet")}async authenticate({payload:e,challenge:t}){return H(e,[S,M,I,C,m,R,w,P],"eoa"),await Be({setup:e,eoa:this.eoa,challenge:t,browserWallet:this.browserWallet})}},V=class{constructor(e,t,r){c(this,"ephSK");c(this,"ephClaim");Me(t,r),this.ephSK=t;let n=O(this.ephSK,r);this.ephClaim=new K(e,n,r)}async authenticate({payload:e,challenge:t}){return H(e,[m,C,R],"ephemeral"),await Je({setup:e,challenge:t,ephSK:this.ephSK,ephClaim:this.ephClaim})}},q=class{constructor(e,t){c(this,"rpConfig");c(this,"allowCredentialId");this.rpConfig=e,this.allowCredentialId=t}async authenticate({payload:e,challenge:t}){return H(e,[S,I,m,R,M,C,w,P],"passkey"),await _e({allowCredentialId:this.allowCredentialId,challenge:t,rpConfig:this.rpConfig})}},W=class{constructor(e,t){c(this,"rpConfig");c(this,"user");this.rpConfig=e,this.user=t}async authenticate({payload:e,challenge:t}){return H(e,[D],"passkey"),await Fe({user:this.user,challenge:t,rpConfig:this.rpConfig})}};var Q=require("json-canonicalize");var B=class{constructor(e){c(this,"walletProviderUrl");c(this,"apiVersion","v1");this.walletProviderUrl=`${e.walletProviderUrl}/${e.apiVersion}`,this.apiVersion=e.apiVersion}getVersion(){return this.apiVersion}async startKeygen({setups:e,authModule:t}){return(this.apiVersion==="v1"?this.connect.bind(this):this.connectV2.bind(this))("keygen",e,t).then(n=>{try{return JSON.parse(n)}catch{throw new Error(`Failed to parse keygen response: ${n}`)}})}async startKeyRefresh({payload:e,authModule:t}){if(this.apiVersion==="v2")throw new Error("Key refresh is not supported in v2 API");return this.connect.bind(this)("keyRefresh",e,t).then(n=>{try{return JSON.parse(n)}catch{throw new Error(`Failed to parse key refresh response: ${n}`)}})}async startSigngen({setup:e,authModule:t}){return(this.apiVersion==="v1"?this.connect.bind(this):this.connectV2.bind(this))("signgen",e,t).then(n=>{try{return JSON.parse(n)}catch{throw new Error(`Failed to parse signgen response: ${n}`)}})}async addEphemeralKey({payload:e,authModule:t}){return(this.apiVersion==="v1"?this.connect.bind(this):this.connectV2.bind(this))("addEphemeralKey",e,t).then(n=>{try{return JSON.parse(n)}catch{throw new Error(`Failed to parse add ephemeral key response: ${n}`)}})}async revokeEphemeralKey({payload:e,authModule:t}){return(this.apiVersion==="v1"?this.connect.bind(this):this.connectV2.bind(this))("revokeEphemeralKey",e,t).then(n=>{try{return JSON.parse(n)}catch{throw new Error(`Failed to parse revoke ephemeral key response: ${n}`)}})}async registerPasskey({payload:e,authModule:t}){if(this.apiVersion==="v2")throw new Error("Passkey registration is not supported in v2 API");return this.connect.bind(this)("registerPasskey",e,t).then(n=>({passkeyCredentialId:n}))}async updatePolicy({payload:e,authModule:t}){return(this.apiVersion==="v1"?this.connect.bind(this):this.connectV2.bind(this))("updatePolicy",e,t).then(n=>{try{return JSON.parse(n)}catch{throw new Error(`Failed to parse update policy response: ${n}`)}})}async deletePolicy({payload:e,authModule:t}){return(this.apiVersion==="v1"?this.connect.bind(this):this.connectV2.bind(this))("deletePolicy",e,t).then(n=>{try{return JSON.parse(n)}catch{throw new Error(`Failed to parse delete policy response: ${n}`)}})}connect(e,t,r){return new Promise((n,o)=>{let i=new WebSocket(`${this.walletProviderUrl}/${e}`),a=0;return console.debug("Connecting to ",i.url),i.addEventListener("open",l=>{switch(console.debug(`Connection opened in state ${a} with event ${JSON.stringify(l,void 0," ")}`),a){case 0:{a=1;try{let u=(0,Q.canonicalize)({payload:t});console.debug("Sending request:",u),i.send(u)}catch(u){this.finishWithError(i,a,u,"open event",o)}break}case 1:case 2:this.finishWithError(i,a,"Unexpected message in state waitingForResult.","open event",o);break;case 3:break}}),i.addEventListener("message",async l=>{switch(console.debug(`Connection message in state ${a} with event data ${JSON.stringify(l.data,void 0," ")}`),a){case 0:this.finishWithError(i,a,"Unexpected message in state initiated.","message event",o);break;case 1:{a=2;try{let u=l.data,d=await new x(r,this.apiVersion).build(e,t,{challenge:u});i.send((0,Q.canonicalize)(d))}catch(u){this.finishWithError(i,a,u,"message event",o)}break}case 2:{a=3,i.close(),n(l.data);break}case 3:break}}),i.addEventListener("error",l=>{this.finishWithError(i,a,`Connection encountered an error event: ${JSON.stringify(l,void 0," ")}`,"error event",o)}),i.addEventListener("close",l=>{let u=l.reason||"No specific reason provided.",d=l.code;console.debug(`Connection closed. State: ${a}, Code: ${d}, Reason: '${u}'`);let p=d>=4e3?`Application Error ${d}: ${u}`:d===1006?"Connection Abnormality (Code 1006): Server closed connection unexpectedly or network issue.":`WebSocket Closed Unexpectedly (Code ${d}): ${u}`;this.finishWithError(i,a,new Error(p),"close event",o)}),()=>{(i.readyState===WebSocket.OPEN||i.readyState===WebSocket.CONNECTING)&&i.close(1001,"Cleanup/Unmount")}})}connectV2(e,t,r){return new Promise((n,o)=>{let i=new WebSocket(`${this.walletProviderUrl}/${e}`),a=0;return console.debug("Connecting to ",i.url),i.addEventListener("open",async l=>{switch(console.debug(`Connection opened in state ${a} with event ${JSON.stringify(l,void 0," ")}`),a){case 0:a=2;try{let u=await new x(r,this.apiVersion).build(e,t);i.send((0,Q.canonicalize)({payload:t,userSigs:u}))}catch(u){this.finishWithError(i,a,u,"open event",o)}break;case 2:a=3,this.finishWithError(i,a,"Unexpected message in state waitingForResult.","open event",o);break;case 3:break}}),i.addEventListener("message",async l=>{switch(console.debug(`Connection message in state ${a} with event ${JSON.stringify(l,void 0," ")}`),a){case 0:this.finishWithError(i,a,"Unexpected message in state initiated.","message event",o);break;case 2:{a=3,i.close(),n(l.data);break}case 3:break}}),i.addEventListener("error",l=>{this.finishWithError(i,a,`Connection encountered an error event: ${JSON.stringify(l,void 0," ")}`,"error event",o)}),i.addEventListener("close",l=>{let u=l.reason||"No specific reason provided.",d=l.code;console.debug(`Connection closed. State: ${a}, Code: ${d}, Reason: '${u}'`);let p=d>=4e3?`Application Error ${d}: ${u}`:d===1006?"Connection Abnormality (Code 1006): Server closed connection unexpectedly or network issue.":`WebSocket Closed Unexpectedly (Code ${d}): ${u}`;this.finishWithError(i,a,new Error(p),"close event",o)}),()=>{(i.readyState===WebSocket.OPEN||i.readyState===WebSocket.CONNECTING)&&i.close(1001,"Cleanup/Unmount")}})}finishWithError(e,t,r,n,o){t!==3&&(console.error(`Error from ${n} in state ${t}:`,r),t=3,o(r instanceof Error?r:new Error(String(r)))),e.readyState===WebSocket.OPEN&&e.close(1e3,`Protocol run failed. Client attempted to close connection in state ${t}`)}},E=class{constructor(e){c(this,"walletProviderUrl");c(this,"apiVersion","v1");this.walletProviderUrl=`${e.walletProviderUrl}/${e.apiVersion}`,this.apiVersion=e.apiVersion}getVersion(){return this.apiVersion}async startKeygen({setups:e}){return this.connect.bind(this)("keygen",e).then(r=>{try{return JSON.parse(r)}catch{throw new Error(`Failed to parse keygen response: ${r}`)}})}async startSigngen({setup:e}){return this.connect.bind(this)("signgen",e).then(r=>{try{return JSON.parse(r)}catch{throw new Error(`Failed to parse signgen response: ${r}`)}})}async startKeyRefresh({payload:e}){if(this.apiVersion==="v2")throw new Error("Key refresh is not supported in v2 API");return this.connect.bind(this)("keyRefresh",e).then(r=>{try{return JSON.parse(r)}catch{throw new Error(`Failed to parse key refresh response: ${r}`)}})}async updatePolicy({payload:e}){return this.connect.bind(this)("updatePolicy",e).then(r=>{try{return JSON.parse(r)}catch{throw new Error(`Failed to parse update policy response: ${r}`)}})}async deletePolicy({payload:e}){return this.connect.bind(this)("deletePolicy",e).then(r=>{try{return JSON.parse(r)}catch{throw new Error(`Failed to parse delete policy response: ${r}`)}})}connect(e,t){return new Promise((r,n)=>{let o=0,i=new WebSocket(`${this.walletProviderUrl}/${e}`);i.addEventListener("open",async a=>{switch(console.debug(`Connection opened in state ${o} with event ${JSON.stringify(a,void 0," ")}`),o){case 0:o=2;try{i.send((0,Q.canonicalize)({payload:t}))}catch(l){n(l)}break;case 2:o=3,n("Incorrect protocol state");break;case 3:break}}),i.addEventListener("message",async a=>{switch(console.debug(`Connection message in state ${o} with event ${JSON.stringify(a,void 0," ")}`),o){case 0:o=3,n("Incorrect protocol state");break;case 2:{o=3,i.close(),r(a.data);break}case 3:break}}),i.addEventListener("error",a=>{console.debug(`Connection error in state ${o} with event ${JSON.stringify(a,void 0," ")}`),o!=3&&(o=3,n("Incorrect protocol state"))}),i.addEventListener("close",a=>{console.debug(`Connection closed in state ${o} with event ${JSON.stringify(a,void 0," ")}`),o!=3&&(o=3,n("Incorrect protocol state"))})})}};var F=class{constructor(e,t){c(this,"authModule");c(this,"wpClient");if(!t&&!(e instanceof E))throw new Error("missing authModule for wallet provider client in auth mode");if(t&&e instanceof E)throw new Error("authModule is required but using wallet provider client in no-auth mode");this.authModule=t,this.wpClient=e}validateQuorumSetup({threshold:e,totalNodes:t}){e&&g(e<2,`Threshold = ${e} must be at least 2`),e&&t&&g(t<e,`Total nodes = ${t} must be greater or equal to threshold = ${e}`)}async generateKey(e,t,r,n,o){this.validateQuorumSetup({threshold:e,totalNodes:t});let i=r.map(a=>new S({t:e,n:t,ephClaim:n,policy:o,signAlg:a}));return this.authModule?await this.wpClient.startKeygen({setups:i,authModule:this.authModule}):await this.wpClient.startKeygen({setups:i})}async signMessage(e,t,r,n){this.validateQuorumSetup({threshold:e}),Oe(r);let o=new m({t:e,key_id:t,signAlg:r,message:n});if(this.authModule){if(this.authModule instanceof q&&new Map(Object.entries(JSON.parse(n))).size>1)throw new Error("For Passkey Authentication only one message in signing request is supported");return await this.wpClient.startSigngen({setup:o,authModule:this.authModule})}else return await this.wpClient.startSigngen({setup:o})}async refreshKey(e,t,r){let n=new M({t:e,keyId:t,signAlg:r});return this.authModule?await this.wpClient.startKeyRefresh({payload:n,authModule:this.authModule}):await this.wpClient.startKeyRefresh({payload:n})}async addEphemeralKey(e,t){let r=new I(e,t);if(!this.authModule)throw new Error("Add ephemeral key is not supported in no auth mode");return await this.wpClient.addEphemeralKey({payload:r,authModule:this.authModule})}async revokeEphemeralKey(e,t){h("keyId",e);let r=new C(e,t);if(!this.authModule)throw new Error("Revoke ephemeral key is not supported in no auth mode");return await this.wpClient.revokeEphemeralKey({payload:r,authModule:this.authModule})}async registerPasskey(e){let t=new D(e!=null?e:"passkey options");if(!this.authModule)throw new Error("Register passkey is not supported in no auth mode");return await this.wpClient.registerPasskey({payload:t,authModule:this.authModule})}async updatePolicy(e,t){let r=new w({keyId:e,policy:t});return this.authModule?await this.wpClient.updatePolicy({payload:r,authModule:this.authModule}):await this.wpClient.updatePolicy({payload:r})}async deletePolicy(e){let t=new P({keyId:e});return this.authModule?await this.wpClient.deletePolicy({payload:t,authModule:this.authModule}):await this.wpClient.deletePolicy({payload:t})}};var Ge=require("json-canonicalize");var Re=class extends Error{constructor(t,r,n){super(n||r);this.status=t;this.statusText=r;this.name="HttpError"}},_=class{constructor(e="",t={}){c(this,"baseURL");c(this,"defaultHeaders");this.baseURL=e,this.validateHeaders(t),this.defaultHeaders={"Content-Type":"application/json",...t}}validateHeaders(e){if(typeof e!="object"||e===null)throw new Error("Headers must be an object.");for(let[t,r]of Object.entries(e))if(typeof t!="string"||typeof r!="string")throw new Error(`Invalid header: ${t}. Header names and values must be strings.`)}setDefaultHeaders(e){this.defaultHeaders={...this.defaultHeaders,...e}}buildUrl(e){return`${this.baseURL}${e}`}async handleResponse(e){if(!e.ok){let r;try{r=(await e.json()).message||e.statusText}catch{r=e.statusText}throw new Re(e.status,e.statusText,r)}let t=e.headers.get("content-type");return t&&t.includes("application/json")?e.json():e.text()}async request(e,t,r,n={}){let o=this.buildUrl(t),i={...this.defaultHeaders,...n.headers},a={method:e,headers:i,...n,body:r?(0,Ge.canonicalize)(r):null},l=await fetch(o,a);return this.handleResponse(l)}async get(e,t){return this.request("GET",e,void 0,t)}async post(e,t,r){return this.request("POST",e,t,r)}async put(e,t,r){return this.request("PUT",e,t,r)}async patch(e,t,r){return this.request("PATCH",e,t,r)}async delete(e,t){return this.request("DELETE",e,void 0,t)}};var ne=require("viem/accounts"),ze=require("@noble/curves/secp256k1"),L=require("viem"),ht=require("js-base64");function ie(s){if(s.startsWith("0x")&&(s=s.slice(2)),s.startsWith("04"))return(0,ne.publicKeyToAddress)(`0x${s} `);if(s.startsWith("02")||s.startsWith("03")){let e=ze.secp256k1.ProjectivePoint.fromHex(s).toHex(!1);return(0,ne.publicKeyToAddress)(`0x${e}`)}else throw new Error("Invalid public key")}var Ke={};Ue(Ke,{Action:()=>xe,ChainType:()=>Ee,IssuerType:()=>Ae,Logic:()=>be,Operator:()=>Ce,Policy:()=>ce,Rule:()=>ae,TransactionAttribute:()=>ke,TransactionType:()=>ve});var je=require("json-canonicalize");var oe=512,Ae=(r=>(r.SessionKeyId="SessionKeyId",r.UserId="UserId",r.All="*",r))(Ae||{}),xe=(t=>(t.Allow="allow",t.Deny="deny",t))(xe||{}),be=(t=>(t.Or="or",t.And="and",t))(be||{}),Ee=(r=>(r.Off="off",r.Ethereum="ethereum",r.Solana="solana",r))(Ee||{}),ve=(i=>(i.Eip712="eip712",i.Eip191="eip191",i.Erc20="erc20",i.Erc721="erc721",i.NativeTransfer="nativeTransfer",i.SolanaTransaction="solanaTransaction",i))(ve||{}),ke=(y=>(y.Sender="sender",y.Receiver="receiver",y.NativeValue="nativeValue",y.ChainId="chainId",y.FunctionSelector="functionSelector",y.Message="message",y.VerifyingContract="verifyingContract",y.PrimaryType="primaryType",y.DomainName="domainName",y.DomainVersion="domainVersion",y.SolanaAccountKeys="solanaAccountKeys",y.SplTransferAmount="splTransferAmount",y.SplTokenMint="splTokenMint",y.CustomProgramInstruction="customProgramInstruction",y.SystemInstructionName="systemInstructionName",y.SplInstructionName="splInstructionName",y))(ke||{}),Ce=(l=>(l.Eq="eq",l.Neq="neq",l.Lt="lt",l.Lte="lte",l.Gt="gt",l.Gte="gte",l.In="in",l.All="all",l))(Ce||{}),ae=class{constructor({description:e,chain_type:t,conditions:r,issuer:n,action:o,logic:i}){c(this,"description");c(this,"issuer");c(this,"action");c(this,"logic");c(this,"chain_type");c(this,"conditions");if(!r.length)throw new Error("Rule must have at least one condition");if(!t)throw new Error("Chain type must be set");if(e.length>oe)throw new Error(`Description length exceeds maximum of ${oe}`);this.description=e,this.chain_type=t,this.conditions=r,this.issuer=n||[{type:"*",id:"*"}],this.action=o||"allow",this.logic=i||"and"}},ce=class{constructor({version:e,description:t,rules:r}){c(this,"version");c(this,"description");c(this,"rules");if(!r.length)throw new Error("Policy must have at least one rule");if(t.length>oe)throw new Error(`Description length exceeds maximum of ${oe}`);this.version=e!=null?e:"1.0",this.description=t,this.rules=r}toJSON(){try{return(0,je.canonicalize)({version:this.version,description:this.description,rules:this.rules})}catch(e){throw console.error("Error while serializing policy",e),new Error("Error while serializing policy")}}};var dt={KeygenSetupOpts:S,InitPresignOpts:T,FinishPresignOpts:R,SignSetupOpts:m,UserSignatures:x,NetworkSigner:F,SignRequestBuilder:U,WalletProviderServiceClient:B,NoAuthWalletProviderServiceClient:E,HttpClient:_,EOAAuth:$,EphAuth:V,PasskeyAuth:q,PasskeyRegister:W,generateEphPrivateKey:j,getEphPublicKey:O,EphKeyClaim:K,computeAddress:ie,flattenSignature:re,UpdatePolicyRequest:w,DeletePolicyRequest:P,...Ke};0&&(module.exports={Action,ChainType,DeletePolicyRequest,EOAAuth,EphAuth,EphKeyClaim,FinishPresignOpts,HttpClient,InitPresignOpts,IssuerType,KeygenSetupOpts,Logic,NetworkSigner,NoAuthWalletProviderServiceClient,Operator,PasskeyAuth,PasskeyRegister,Policy,Rule,SignRequestBuilder,SignSetupOpts,TransactionAttribute,TransactionType,UpdatePolicyRequest,UserSignatures,WalletProviderServiceClient,computeAddress,flattenSignature,generateEphPrivateKey,getEphPublicKey});
|
|
2
2
|
/*! Bundled license information:
|
|
3
3
|
|
|
4
4
|
@noble/hashes/esm/utils.js:
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export type { SignRequestType } from './builder/signRequest';
|
|
2
|
+
export type { UserSignaturesOptionalParams } from './builder/userAuth';
|
|
2
3
|
export type { ApiVersion, ClientConfig, IWalletProviderServiceClient, INoAuthWpServiceClient, } from './client/walletProviderServiceClientInterface';
|
|
3
4
|
export type { IBrowserWallet, TypedData } from './auth/EOAauthentication';
|
|
4
5
|
export type { PasskeyUser, RelyingPartyConfig } from './auth/passkeyAuthentication';
|
|
5
6
|
export type { UserAuthentication } from './auth/authentication';
|
|
6
|
-
export type { KeygenResponse, KeyRefreshResponse, SignResponse, AddEphKeyResponse, RevokeEphKeyResponse, RegisterPasskeyResponse, } from './client/networkResponse';
|
|
7
|
+
export type { KeygenResponse, KeyRefreshResponse, SignResponse, AddEphKeyResponse, RevokeEphKeyResponse, RegisterPasskeyResponse, UpdatePolicyResponse, DeletePolicyResponse, } from './client/networkResponse';
|
|
7
8
|
export type { MPCSignAlgorithm } from './client/networkSigner';
|
|
8
9
|
export type { EphKeySignAlgorithm } from './auth/ephemeralAuthentication';
|
|
9
10
|
export type { DSGOpts } from './viemSigner';
|
|
@@ -12,12 +13,13 @@ export { UserSignatures } from './builder/userAuth';
|
|
|
12
13
|
export { flattenSignature } from './client/ethUtil';
|
|
13
14
|
export { NetworkSigner } from './client/networkSigner';
|
|
14
15
|
export { WalletProviderServiceClient, NoAuthWalletProviderServiceClient } from './client/walletProviderServiceClient';
|
|
15
|
-
export { parseSigngenResult, parseKeygenResult, parseEphKeyOperationResult } from './client/networkResponse';
|
|
16
16
|
export { HttpClient } from './client/httpClient';
|
|
17
17
|
export { EOAAuth, EphAuth, PasskeyAuth, PasskeyRegister } from './auth/authentication';
|
|
18
18
|
export { generateEphPrivateKey, getEphPublicKey, EphKeyClaim } from './auth/ephemeralAuthentication';
|
|
19
19
|
export { computeAddress } from './viemSigner';
|
|
20
|
-
export { KeygenSetupOpts, InitPresignOpts, FinishPresignOpts } from './setupMessage';
|
|
20
|
+
export { KeygenSetupOpts, InitPresignOpts, FinishPresignOpts, SignSetupOpts } from './setupMessage';
|
|
21
|
+
export { UpdatePolicyRequest, DeletePolicyRequest } from './client/networkRequest';
|
|
22
|
+
export * from './policy';
|
|
21
23
|
import { SignRequestBuilder } from './builder/signRequest';
|
|
22
24
|
import { UserSignatures } from './builder/userAuth';
|
|
23
25
|
import { NetworkSigner } from './client/networkSigner';
|
|
@@ -26,11 +28,23 @@ import { HttpClient } from './client/httpClient';
|
|
|
26
28
|
import { EOAAuth, EphAuth, PasskeyAuth, PasskeyRegister } from './auth/authentication';
|
|
27
29
|
import { generateEphPrivateKey, getEphPublicKey, EphKeyClaim } from './auth/ephemeralAuthentication';
|
|
28
30
|
import { computeAddress } from './viemSigner';
|
|
29
|
-
import { KeygenSetupOpts, InitPresignOpts, FinishPresignOpts } from './setupMessage';
|
|
31
|
+
import { KeygenSetupOpts, InitPresignOpts, FinishPresignOpts, SignSetupOpts } from './setupMessage';
|
|
32
|
+
import { UpdatePolicyRequest, DeletePolicyRequest } from './client/networkRequest';
|
|
33
|
+
import * as policy from './policy';
|
|
30
34
|
declare const _default: {
|
|
35
|
+
IssuerType: typeof policy.IssuerType;
|
|
36
|
+
Action: typeof policy.Action;
|
|
37
|
+
Logic: typeof policy.Logic;
|
|
38
|
+
ChainType: typeof policy.ChainType;
|
|
39
|
+
TransactionType: typeof policy.TransactionType;
|
|
40
|
+
TransactionAttribute: typeof policy.TransactionAttribute;
|
|
41
|
+
Operator: typeof policy.Operator;
|
|
42
|
+
Rule: typeof policy.Rule;
|
|
43
|
+
Policy: typeof policy.Policy;
|
|
31
44
|
KeygenSetupOpts: typeof KeygenSetupOpts;
|
|
32
45
|
InitPresignOpts: typeof InitPresignOpts;
|
|
33
46
|
FinishPresignOpts: typeof FinishPresignOpts;
|
|
47
|
+
SignSetupOpts: typeof SignSetupOpts;
|
|
34
48
|
UserSignatures: typeof UserSignatures;
|
|
35
49
|
NetworkSigner: typeof NetworkSigner;
|
|
36
50
|
SignRequestBuilder: typeof SignRequestBuilder;
|
|
@@ -46,8 +60,7 @@ declare const _default: {
|
|
|
46
60
|
EphKeyClaim: typeof EphKeyClaim;
|
|
47
61
|
computeAddress: typeof computeAddress;
|
|
48
62
|
flattenSignature: (signgenResponse: import(".").SignResponse) => `0x${string}`;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
parseEphKeyOperationResult: (operationsResult: string) => import(".").AddEphKeyResponse[];
|
|
63
|
+
UpdatePolicyRequest: typeof UpdatePolicyRequest;
|
|
64
|
+
DeletePolicyRequest: typeof DeletePolicyRequest;
|
|
52
65
|
};
|
|
53
66
|
export default _default;
|