@silencelaboratories/walletprovider-sdk 0.0.4 → 0.0.6
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 +24 -1
- package/dist/EOAauthentication.d.ts +33 -0
- package/dist/EOAauthentication.d.ts.map +1 -1
- package/dist/authentication.d.ts +11 -3
- package/dist/authentication.d.ts.map +1 -1
- package/dist/index.d.ts +2 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -18425
- package/dist/networkSigner.d.ts +56 -8
- package/dist/networkSigner.d.ts.map +1 -1
- package/dist/walletProviderServiceClient.d.ts +6 -1
- package/dist/walletProviderServiceClient.d.ts.map +1 -1
- package/dist/walletProviderServiceClientInterface.d.ts +3 -0
- package/dist/walletProviderServiceClientInterface.d.ts.map +1 -1
- package/package.json +7 -4
package/README.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# walletprovider-sdk
|
|
2
2
|
|
|
3
|
+
# Documentation
|
|
4
|
+
|
|
5
|
+
Please refer to [documentation](./docs/walletprovider-sdk.md)
|
|
6
|
+
|
|
7
|
+
# Demo
|
|
8
|
+
|
|
9
|
+
Under the [demo](./demo) directory we provide the sample webpage that shows example usage of the library.
|
|
10
|
+
In order to run it execute the following
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
cd demo
|
|
14
|
+
npm install
|
|
15
|
+
npm run dev
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
# Build
|
|
19
|
+
|
|
3
20
|
## Bun runtime is required
|
|
4
21
|
|
|
5
22
|
Install bun from https://bun.sh
|
|
@@ -31,5 +48,11 @@ bun run test:watch
|
|
|
31
48
|
## Format the code
|
|
32
49
|
|
|
33
50
|
```bash
|
|
34
|
-
|
|
51
|
+
bun run format
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Generate the documentation
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
bun run docs
|
|
35
58
|
```
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/** Externally Owned Account (EOA) atuhentication. Uses secret key stored on a wallet to sign requests.
|
|
2
|
+
* The requests are presented to the user in a readable form by using TypedData (EIP712).
|
|
3
|
+
*/
|
|
1
4
|
import { KeygenSetupOpts, type SignSetupOpts } from './networkSigner.ts';
|
|
2
5
|
import { type UserAuthentication } from './authentication.ts';
|
|
3
6
|
import type { TypedDataDomain } from 'viem';
|
|
@@ -5,15 +8,45 @@ export type FieldDefinition = {
|
|
|
5
8
|
name: string;
|
|
6
9
|
type: string;
|
|
7
10
|
};
|
|
11
|
+
/** EIP-712 Typed data struct definition.
|
|
12
|
+
* @alpha
|
|
13
|
+
* */
|
|
8
14
|
export type TypedData<T> = {
|
|
15
|
+
/** contains the schema definition of the types that are in `msg` */
|
|
9
16
|
types: Record<string, Array<FieldDefinition>>;
|
|
17
|
+
/** is the signature domain separator */
|
|
10
18
|
domain: TypedDataDomain;
|
|
19
|
+
/** points to the type from `types`. It's the root object of `message` */
|
|
11
20
|
primaryType: string;
|
|
21
|
+
/** the request that User is asked to sign */
|
|
12
22
|
message: T;
|
|
13
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* Interface to implement communication between this library, and a Browser Wallet. In order to
|
|
26
|
+
* request the signature from the User.
|
|
27
|
+
* @alpha
|
|
28
|
+
*/
|
|
14
29
|
export interface IBrowserWallet {
|
|
30
|
+
/** Sign data using the secret key stored on Browser Wallet
|
|
31
|
+
* It creates a popup window, presenting the human readable form of `request`
|
|
32
|
+
* @param from - the address used to sign the request
|
|
33
|
+
* @param request - the request to sign by the User in the form of EIP712 typed data.
|
|
34
|
+
* @throws Throws an error if User rejected signature
|
|
35
|
+
* @example The example implementation:
|
|
36
|
+
* ```ts
|
|
37
|
+
* async signTypedData<T>(from: string, request: TypedData<T>): Promise<unknown> {
|
|
38
|
+
* return await browserWallet.request({
|
|
39
|
+
* method: 'eth_signTypedData_v4',
|
|
40
|
+
* params: [from, JSON.stringify(request)],
|
|
41
|
+
* });
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
15
45
|
signTypedData<T>(from: string, request: TypedData<T>): Promise<unknown>;
|
|
16
46
|
}
|
|
47
|
+
/** Present the request to the User using wallet UI, and ask for sign.
|
|
48
|
+
* The signature is the authorization for the operation
|
|
49
|
+
*/
|
|
17
50
|
export declare function authenticateUsingEOA({ setup, user_id, challenge, browserWallet, }: {
|
|
18
51
|
setup: KeygenSetupOpts | SignSetupOpts;
|
|
19
52
|
user_id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EOAauthentication.d.ts","sourceRoot":"","sources":["../src/EOAauthentication.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EOAauthentication.d.ts","sourceRoot":"","sources":["../src/EOAauthentication.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAmB,eAAe,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC1F,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAE5C,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;KAEK;AACL,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI;IACzB,oEAAoE;IACpE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC;IAC9C,wCAAwC;IACxC,MAAM,EAAE,eAAe,CAAC;IACxB,yEAAyE;IACzE,WAAW,EAAE,MAAM,CAAC;IACpB,6CAA6C;IAC7C,OAAO,EAAE,CAAC,CAAC;CACZ,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;;;;;;;;;;OAcG;IACH,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACzE;AAgJD;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,EACzC,KAAK,EACL,OAAO,EACP,SAAS,EACT,aAAa,GACd,EAAE;IACD,KAAK,EAAE,eAAe,GAAG,aAAa,CAAC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,cAAc,CAAC;CAC/B,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA4B9B"}
|
package/dist/authentication.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { KeygenSetupOpts, SignSetupOpts } from './networkSigner';
|
|
2
2
|
import { IBrowserWallet } from './EOAauthentication';
|
|
3
|
-
|
|
3
|
+
/** Type of the request authentication
|
|
4
|
+
* @alpha
|
|
5
|
+
*/
|
|
4
6
|
export declare enum AuthMethod {
|
|
7
|
+
/** Authentication using Externally Owned Account */
|
|
5
8
|
EOA = 0,
|
|
9
|
+
/** No authentication */
|
|
6
10
|
NONE = 1
|
|
7
11
|
}
|
|
8
12
|
export type UserCredentials = {
|
|
@@ -20,11 +24,15 @@ export interface AuthModule {
|
|
|
20
24
|
challenge: string;
|
|
21
25
|
}): Promise<UserAuthentication>;
|
|
22
26
|
}
|
|
27
|
+
/** The `AuthModule` implementing Externally Owned Account authentication.
|
|
28
|
+
* @alpha
|
|
29
|
+
*/
|
|
23
30
|
export declare class EOAAuth implements AuthModule {
|
|
31
|
+
/** User ID, typically the ETH address that is used to do authentication */
|
|
24
32
|
userId: string;
|
|
33
|
+
/** An interface to the wallet, like MetaMask, that is used to sign the requests */
|
|
25
34
|
browserWallet: IBrowserWallet;
|
|
26
|
-
|
|
27
|
-
constructor(userId: string, browserWallet: IBrowserWallet, wpClient: IWalletProviderServiceClient);
|
|
35
|
+
constructor(userId: string, browserWallet: IBrowserWallet);
|
|
28
36
|
authenticate({ setup, challenge, }: {
|
|
29
37
|
setup: KeygenSetupOpts | SignSetupOpts;
|
|
30
38
|
challenge: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authentication.d.ts","sourceRoot":"","sources":["../src/authentication.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,cAAc,EAAwB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"authentication.d.ts","sourceRoot":"","sources":["../src/authentication.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,cAAc,EAAwB,MAAM,qBAAqB,CAAC;AAE3E;;GAEG;AACH,oBAAY,UAAU;IACpB,oDAAoD;IACpD,GAAG,IAAA;IACH,wBAAwB;IACxB,IAAI,IAAA;CACL;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,MAAM,CAAC;IAEX,MAAM,EAAE,MAAM,CAAC;IAEf,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,WAAW,EAAE,eAAe,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,WAAW,UAAU;IACzB,YAAY,CAAC,EACX,KAAK,EACL,SAAS,GACV,EAAE;QACD,KAAK,EAAE,eAAe,GAAG,aAAa,CAAC;QACvC,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;CACjC;AAED;;GAEG;AACH,qBAAa,OAAQ,YAAW,UAAU;IACxC,2EAA2E;IAC3E,MAAM,EAAE,MAAM,CAAC;IACf,mFAAmF;IACnF,aAAa,EAAE,cAAc,CAAC;gBAElB,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc;IAKnD,YAAY,CAAC,EACjB,KAAK,EACL,SAAS,GACV,EAAE;QACD,KAAK,EAAE,eAAe,GAAG,aAAa,CAAC;QACvC,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAQhC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { createViemAccount } from './viemSigner.ts';
|
|
1
|
+
export { NetworkSigner, SignResponse, KeygenResponse } from './networkSigner.ts';
|
|
3
2
|
export { AuthMethod, EOAAuth } from './authentication.ts';
|
|
4
|
-
export type { TypedData } from './EOAauthentication.ts';
|
|
5
|
-
export type { UserAuthenticatedRequest, KeygenResponse, SignSetupOpts, SignResponse } from './networkSigner.ts';
|
|
3
|
+
export type { IBrowserWallet, TypedData } from './EOAauthentication.ts';
|
|
6
4
|
export type { IWalletProviderServiceClient } from './walletProviderServiceClientInterface.ts';
|
|
7
5
|
export { WalletProviderServiceClient } from './walletProviderServiceClient.ts';
|
|
8
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE1D,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExE,YAAY,EAAE,4BAA4B,EAAE,MAAM,2CAA2C,CAAC;AAC9F,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC"}
|