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