unwallet-client-sdk 0.18.2 → 0.20.0
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/dist/index.cjs +294 -413
- package/dist/index.d.cts +85 -84
- package/dist/index.d.ts +85 -84
- package/dist/index.js +292 -390
- package/package.json +14 -9
package/dist/index.d.cts
CHANGED
|
@@ -1,108 +1,109 @@
|
|
|
1
|
-
import { Address, Hex } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
type Env = (typeof VALID_ENVS)[number];
|
|
1
|
+
import { Address, Hex } from "viem";
|
|
2
|
+
//#region src/config.d.ts
|
|
3
|
+
type Env = "prod" | "dev";
|
|
5
4
|
interface Config {
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
env?: Env;
|
|
6
|
+
clientID: string;
|
|
8
7
|
}
|
|
9
8
|
interface UnWalletXAPIConfig {
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
url: string;
|
|
10
|
+
connectionTimeout: number;
|
|
12
11
|
}
|
|
13
|
-
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/eip712.d.ts
|
|
14
14
|
interface EIP712TypedData {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
types: Record<string, Array<EIP712TypedDataField>>;
|
|
16
|
+
primaryType: string;
|
|
17
|
+
domain: EIP712TypedDataDomain;
|
|
18
|
+
message: Record<string, any>;
|
|
19
19
|
}
|
|
20
20
|
interface EIP712TypedDataDomain {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
name?: string;
|
|
22
|
+
version?: string;
|
|
23
|
+
chainId?: number;
|
|
24
|
+
verifyingContract?: Address;
|
|
25
|
+
salt?: Hex;
|
|
26
26
|
}
|
|
27
27
|
interface EIP712TypedDataField {
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
name: string;
|
|
29
|
+
type: string;
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
type UWErrorCode =
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/error.d.ts
|
|
33
|
+
type UWErrorCode = "CONNECTION_TIMEOUT" | "CONNECTION_FAILED" | "CONNECTION_NOT_OPENED" | "CONNECTION_CLOSED" | "INVALID_REQUEST" | "REQUEST_IN_PROGRESS" | "REQUEST_REJECTED" | "INVALID_RESPONSE";
|
|
34
34
|
declare class UWError extends Error {
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
readonly code: UWErrorCode;
|
|
36
|
+
constructor(code: UWErrorCode, message?: string);
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/x.d.ts
|
|
40
|
+
declare const X_RESPONSE_TYPES: readonly ["connectionID", "signature", "transactionID", "error"];
|
|
41
|
+
type XResponseType = (typeof X_RESPONSE_TYPES)[number];
|
|
41
42
|
interface XResponse {
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
readonly type: XResponseType;
|
|
44
|
+
readonly value: string;
|
|
44
45
|
}
|
|
45
46
|
interface XResponseHandler {
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
resolve: (resp: XResponse) => void;
|
|
48
|
+
reject: (err: UWError) => void;
|
|
48
49
|
}
|
|
49
50
|
declare class XConnection {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
51
|
+
readonly id: string;
|
|
52
|
+
private socket;
|
|
53
|
+
private responseHandler;
|
|
54
|
+
constructor(args: {
|
|
55
|
+
id: string;
|
|
56
|
+
socket: WebSocket;
|
|
57
|
+
});
|
|
58
|
+
static init(config: UnWalletXAPIConfig): Promise<XConnection>;
|
|
59
|
+
private initListeners;
|
|
60
|
+
get readyState(): number;
|
|
61
|
+
get hasResponseHandler(): boolean;
|
|
62
|
+
setResponseHandler(handler: XResponseHandler | null): void;
|
|
62
63
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
type AuthorizationResponseMode =
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/unwallet.d.ts
|
|
66
|
+
type AuthorizationResponseMode = "fragment" | "form_post";
|
|
66
67
|
interface SignResult {
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
digest: string;
|
|
69
|
+
signature: string;
|
|
69
70
|
}
|
|
70
71
|
interface SendTransactionResult {
|
|
71
|
-
|
|
72
|
+
transactionID: string;
|
|
72
73
|
}
|
|
73
74
|
declare class UnWallet {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
75
|
+
private env;
|
|
76
|
+
private clientID;
|
|
77
|
+
private xConnection;
|
|
78
|
+
constructor(args: {
|
|
79
|
+
env: Env;
|
|
80
|
+
clientID: string;
|
|
81
|
+
xConnection: XConnection;
|
|
82
|
+
});
|
|
83
|
+
static init(config: Config): Promise<UnWallet>;
|
|
84
|
+
private get unWalletConfig();
|
|
85
|
+
authorize(args: {
|
|
86
|
+
responseMode?: AuthorizationResponseMode;
|
|
87
|
+
redirectURL: string;
|
|
88
|
+
nonce?: string;
|
|
89
|
+
isVirtual?: boolean;
|
|
90
|
+
chainID?: number;
|
|
91
|
+
}): void;
|
|
92
|
+
sign(args: {
|
|
93
|
+
message: string;
|
|
94
|
+
ticketToken: string;
|
|
95
|
+
}): Promise<SignResult>;
|
|
96
|
+
signEIP712TypedData(args: {
|
|
97
|
+
typedData: EIP712TypedData;
|
|
98
|
+
ticketToken: string;
|
|
99
|
+
}): Promise<SignResult>;
|
|
100
|
+
sendTransaction(args: {
|
|
101
|
+
chainID: number;
|
|
102
|
+
toAddress: string;
|
|
103
|
+
value?: string;
|
|
104
|
+
data?: string;
|
|
105
|
+
ticketToken: string;
|
|
106
|
+
}): Promise<SendTransactionResult>;
|
|
106
107
|
}
|
|
107
|
-
|
|
108
|
-
export { type AuthorizationResponseMode, type Config, type EIP712TypedData, type EIP712TypedDataDomain, type EIP712TypedDataField, type Env, type SendTransactionResult, type SignResult, UWError, type UWErrorCode, UnWallet };
|
|
108
|
+
//#endregion
|
|
109
|
+
export { type AuthorizationResponseMode, type Config, type EIP712TypedData, type EIP712TypedDataDomain, type EIP712TypedDataField, type Env, type SendTransactionResult, type SignResult, UWError, type UWErrorCode, UnWallet };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,108 +1,109 @@
|
|
|
1
|
-
import { Address, Hex } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
type Env = (typeof VALID_ENVS)[number];
|
|
1
|
+
import { Address, Hex } from "viem";
|
|
2
|
+
//#region src/config.d.ts
|
|
3
|
+
type Env = "prod" | "dev";
|
|
5
4
|
interface Config {
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
env?: Env;
|
|
6
|
+
clientID: string;
|
|
8
7
|
}
|
|
9
8
|
interface UnWalletXAPIConfig {
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
url: string;
|
|
10
|
+
connectionTimeout: number;
|
|
12
11
|
}
|
|
13
|
-
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/eip712.d.ts
|
|
14
14
|
interface EIP712TypedData {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
types: Record<string, Array<EIP712TypedDataField>>;
|
|
16
|
+
primaryType: string;
|
|
17
|
+
domain: EIP712TypedDataDomain;
|
|
18
|
+
message: Record<string, any>;
|
|
19
19
|
}
|
|
20
20
|
interface EIP712TypedDataDomain {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
name?: string;
|
|
22
|
+
version?: string;
|
|
23
|
+
chainId?: number;
|
|
24
|
+
verifyingContract?: Address;
|
|
25
|
+
salt?: Hex;
|
|
26
26
|
}
|
|
27
27
|
interface EIP712TypedDataField {
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
name: string;
|
|
29
|
+
type: string;
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
type UWErrorCode =
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/error.d.ts
|
|
33
|
+
type UWErrorCode = "CONNECTION_TIMEOUT" | "CONNECTION_FAILED" | "CONNECTION_NOT_OPENED" | "CONNECTION_CLOSED" | "INVALID_REQUEST" | "REQUEST_IN_PROGRESS" | "REQUEST_REJECTED" | "INVALID_RESPONSE";
|
|
34
34
|
declare class UWError extends Error {
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
readonly code: UWErrorCode;
|
|
36
|
+
constructor(code: UWErrorCode, message?: string);
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/x.d.ts
|
|
40
|
+
declare const X_RESPONSE_TYPES: readonly ["connectionID", "signature", "transactionID", "error"];
|
|
41
|
+
type XResponseType = (typeof X_RESPONSE_TYPES)[number];
|
|
41
42
|
interface XResponse {
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
readonly type: XResponseType;
|
|
44
|
+
readonly value: string;
|
|
44
45
|
}
|
|
45
46
|
interface XResponseHandler {
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
resolve: (resp: XResponse) => void;
|
|
48
|
+
reject: (err: UWError) => void;
|
|
48
49
|
}
|
|
49
50
|
declare class XConnection {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
51
|
+
readonly id: string;
|
|
52
|
+
private socket;
|
|
53
|
+
private responseHandler;
|
|
54
|
+
constructor(args: {
|
|
55
|
+
id: string;
|
|
56
|
+
socket: WebSocket;
|
|
57
|
+
});
|
|
58
|
+
static init(config: UnWalletXAPIConfig): Promise<XConnection>;
|
|
59
|
+
private initListeners;
|
|
60
|
+
get readyState(): number;
|
|
61
|
+
get hasResponseHandler(): boolean;
|
|
62
|
+
setResponseHandler(handler: XResponseHandler | null): void;
|
|
62
63
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
type AuthorizationResponseMode =
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/unwallet.d.ts
|
|
66
|
+
type AuthorizationResponseMode = "fragment" | "form_post";
|
|
66
67
|
interface SignResult {
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
digest: string;
|
|
69
|
+
signature: string;
|
|
69
70
|
}
|
|
70
71
|
interface SendTransactionResult {
|
|
71
|
-
|
|
72
|
+
transactionID: string;
|
|
72
73
|
}
|
|
73
74
|
declare class UnWallet {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
75
|
+
private env;
|
|
76
|
+
private clientID;
|
|
77
|
+
private xConnection;
|
|
78
|
+
constructor(args: {
|
|
79
|
+
env: Env;
|
|
80
|
+
clientID: string;
|
|
81
|
+
xConnection: XConnection;
|
|
82
|
+
});
|
|
83
|
+
static init(config: Config): Promise<UnWallet>;
|
|
84
|
+
private get unWalletConfig();
|
|
85
|
+
authorize(args: {
|
|
86
|
+
responseMode?: AuthorizationResponseMode;
|
|
87
|
+
redirectURL: string;
|
|
88
|
+
nonce?: string;
|
|
89
|
+
isVirtual?: boolean;
|
|
90
|
+
chainID?: number;
|
|
91
|
+
}): void;
|
|
92
|
+
sign(args: {
|
|
93
|
+
message: string;
|
|
94
|
+
ticketToken: string;
|
|
95
|
+
}): Promise<SignResult>;
|
|
96
|
+
signEIP712TypedData(args: {
|
|
97
|
+
typedData: EIP712TypedData;
|
|
98
|
+
ticketToken: string;
|
|
99
|
+
}): Promise<SignResult>;
|
|
100
|
+
sendTransaction(args: {
|
|
101
|
+
chainID: number;
|
|
102
|
+
toAddress: string;
|
|
103
|
+
value?: string;
|
|
104
|
+
data?: string;
|
|
105
|
+
ticketToken: string;
|
|
106
|
+
}): Promise<SendTransactionResult>;
|
|
106
107
|
}
|
|
107
|
-
|
|
108
|
-
export { type AuthorizationResponseMode, type Config, type EIP712TypedData, type EIP712TypedDataDomain, type EIP712TypedDataField, type Env, type SendTransactionResult, type SignResult, UWError, type UWErrorCode, UnWallet };
|
|
108
|
+
//#endregion
|
|
109
|
+
export { type AuthorizationResponseMode, type Config, type EIP712TypedData, type EIP712TypedDataDomain, type EIP712TypedDataField, type Env, type SendTransactionResult, type SignResult, UWError, type UWErrorCode, UnWallet };
|