unwallet-client-sdk 0.22.0 → 0.24.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 +44 -25
- package/dist/index.d.cts +4 -14
- package/dist/index.d.ts +4 -14
- package/dist/index.js +4 -7
- package/package.json +11 -12
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,29 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
// \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
20
|
+
value: mod,
|
|
21
|
+
enumerable: true
|
|
22
|
+
}) : target, mod));
|
|
2
23
|
let viem = require("viem");
|
|
3
24
|
let zod = require("zod");
|
|
4
|
-
|
|
25
|
+
zod = __toESM(zod, 1);
|
|
26
|
+
// src/error.ts
|
|
5
27
|
var UWError = class extends Error {
|
|
6
28
|
static {
|
|
7
29
|
this.prototype.name = "UWError";
|
|
@@ -11,8 +33,7 @@ var UWError = class extends Error {
|
|
|
11
33
|
this.code = code;
|
|
12
34
|
}
|
|
13
35
|
};
|
|
14
|
-
|
|
15
|
-
//#region src/config.ts
|
|
36
|
+
// src/config.ts
|
|
16
37
|
const envToUnWalletConfig = {
|
|
17
38
|
prod: {
|
|
18
39
|
frontend: { origin: "https://id.unwallet.world" },
|
|
@@ -29,8 +50,8 @@ const envToUnWalletConfig = {
|
|
|
29
50
|
}
|
|
30
51
|
}
|
|
31
52
|
};
|
|
32
|
-
const xRequestSchema = zod.
|
|
33
|
-
zod.
|
|
53
|
+
const xRequestSchema = zod.object({ action: zod.enum(["getConnectionID"]) }).readonly();
|
|
54
|
+
zod.string().transform((val, ctx) => {
|
|
34
55
|
try {
|
|
35
56
|
return JSON.parse(val);
|
|
36
57
|
} catch {
|
|
@@ -38,28 +59,28 @@ zod.z.string().transform((val, ctx) => {
|
|
|
38
59
|
code: "custom",
|
|
39
60
|
message: "Invalid JSON string"
|
|
40
61
|
});
|
|
41
|
-
return zod.
|
|
62
|
+
return zod.NEVER;
|
|
42
63
|
}
|
|
43
64
|
}).pipe(xRequestSchema);
|
|
44
|
-
const xResponseSchema = zod.
|
|
45
|
-
zod.
|
|
46
|
-
type: zod.
|
|
47
|
-
value: zod.
|
|
65
|
+
const xResponseSchema = zod.union([
|
|
66
|
+
zod.object({
|
|
67
|
+
type: zod.literal("connectionID"),
|
|
68
|
+
value: zod.string().nonempty()
|
|
48
69
|
}),
|
|
49
|
-
zod.
|
|
50
|
-
type: zod.
|
|
51
|
-
value: zod.
|
|
70
|
+
zod.object({
|
|
71
|
+
type: zod.literal("signature"),
|
|
72
|
+
value: zod.string().refine(viem.isHex, { error: "Invalid hex" })
|
|
52
73
|
}),
|
|
53
|
-
zod.
|
|
54
|
-
type: zod.
|
|
55
|
-
value: zod.
|
|
74
|
+
zod.object({
|
|
75
|
+
type: zod.literal("transactionID"),
|
|
76
|
+
value: zod.string().nonempty()
|
|
56
77
|
}),
|
|
57
|
-
zod.
|
|
58
|
-
type: zod.
|
|
59
|
-
value: zod.
|
|
78
|
+
zod.object({
|
|
79
|
+
type: zod.literal("error"),
|
|
80
|
+
value: zod.string().nonempty()
|
|
60
81
|
})
|
|
61
82
|
]).readonly();
|
|
62
|
-
const xResponsePayloadSchema = zod.
|
|
83
|
+
const xResponsePayloadSchema = zod.string().transform((val, ctx) => {
|
|
63
84
|
try {
|
|
64
85
|
return JSON.parse(val);
|
|
65
86
|
} catch {
|
|
@@ -67,7 +88,7 @@ const xResponsePayloadSchema = zod.z.string().transform((val, ctx) => {
|
|
|
67
88
|
code: "custom",
|
|
68
89
|
message: "Invalid JSON string"
|
|
69
90
|
});
|
|
70
|
-
return zod.
|
|
91
|
+
return zod.NEVER;
|
|
71
92
|
}
|
|
72
93
|
}).pipe(xResponseSchema);
|
|
73
94
|
var XConnection = class XConnection {
|
|
@@ -179,7 +200,7 @@ function safeParseXResponsePayload(data) {
|
|
|
179
200
|
const result = xResponsePayloadSchema.safeParse(data);
|
|
180
201
|
if (!result.success) return {
|
|
181
202
|
success: false,
|
|
182
|
-
error: new UWError("INVALID_RESPONSE", `invalid payload: ${zod.
|
|
203
|
+
error: new UWError("INVALID_RESPONSE", `invalid payload: ${zod.prettifyError(result.error)}`)
|
|
183
204
|
};
|
|
184
205
|
return {
|
|
185
206
|
success: true,
|
|
@@ -195,8 +216,7 @@ function newUnexpectedXResponseTypeError(resp) {
|
|
|
195
216
|
function newConnectionClosedError(event) {
|
|
196
217
|
return new UWError("CONNECTION_CLOSED", event.reason.length > 0 ? event.reason : void 0);
|
|
197
218
|
}
|
|
198
|
-
|
|
199
|
-
//#region src/unwallet.ts
|
|
219
|
+
// src/unwallet.ts
|
|
200
220
|
var UnWallet = class UnWallet {
|
|
201
221
|
constructor(args) {
|
|
202
222
|
this.env = args.env;
|
|
@@ -310,6 +330,5 @@ var UnWallet = class UnWallet {
|
|
|
310
330
|
this.xConnection.close();
|
|
311
331
|
}
|
|
312
332
|
};
|
|
313
|
-
//#endregion
|
|
314
333
|
exports.UWError = UWError;
|
|
315
334
|
exports.UnWallet = UnWallet;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Address, Hash, Hex } from "viem";
|
|
2
|
-
import
|
|
3
|
-
//#region src/config.d.ts
|
|
2
|
+
import * as z from "zod";
|
|
4
3
|
type Env = "prod" | "dev";
|
|
5
4
|
interface Config {
|
|
6
5
|
env?: Env;
|
|
@@ -10,8 +9,6 @@ interface UnWalletXAPIConfig {
|
|
|
10
9
|
url: string;
|
|
11
10
|
connectionTimeout: number;
|
|
12
11
|
}
|
|
13
|
-
//#endregion
|
|
14
|
-
//#region src/eip712.d.ts
|
|
15
12
|
interface EIP712TypedData {
|
|
16
13
|
types: Record<string, Array<EIP712TypedDataField>>;
|
|
17
14
|
primaryType: string;
|
|
@@ -29,15 +26,11 @@ interface EIP712TypedDataField {
|
|
|
29
26
|
name: string;
|
|
30
27
|
type: string;
|
|
31
28
|
}
|
|
32
|
-
//#endregion
|
|
33
|
-
//#region src/error.d.ts
|
|
34
29
|
type UWErrorCode = "CONNECTION_TIMEOUT" | "CONNECTION_FAILED" | "CONNECTION_NOT_OPENED" | "CONNECTION_CLOSED" | "INVALID_REQUEST" | "REQUEST_IN_PROGRESS" | "REQUEST_REJECTED" | "INVALID_RESPONSE";
|
|
35
|
-
declare class UWError extends Error {
|
|
30
|
+
export declare class UWError extends Error {
|
|
36
31
|
readonly code: UWErrorCode;
|
|
37
32
|
constructor(code: UWErrorCode, msg?: string);
|
|
38
33
|
}
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region src/xconn.d.ts
|
|
41
34
|
declare const xResponseSchema: z.ZodReadonly<z.ZodUnion<readonly [z.ZodObject<{
|
|
42
35
|
type: z.ZodLiteral<"connectionID">;
|
|
43
36
|
value: z.ZodString;
|
|
@@ -82,8 +75,6 @@ declare class XConnection {
|
|
|
82
75
|
setResponseHandler(respHandler: XResponseHandler | null): void;
|
|
83
76
|
close(): void;
|
|
84
77
|
}
|
|
85
|
-
//#endregion
|
|
86
|
-
//#region src/unwallet.d.ts
|
|
87
78
|
type AuthorizationResponseMode = "fragment" | "form_post";
|
|
88
79
|
interface SignResult {
|
|
89
80
|
digest: Hash;
|
|
@@ -92,7 +83,7 @@ interface SignResult {
|
|
|
92
83
|
interface SendTransactionResult {
|
|
93
84
|
transactionID: string;
|
|
94
85
|
}
|
|
95
|
-
declare class UnWallet {
|
|
86
|
+
export declare class UnWallet {
|
|
96
87
|
private readonly env;
|
|
97
88
|
private readonly clientID;
|
|
98
89
|
private readonly xConnection;
|
|
@@ -128,5 +119,4 @@ declare class UnWallet {
|
|
|
128
119
|
private request;
|
|
129
120
|
close(): void;
|
|
130
121
|
}
|
|
131
|
-
|
|
132
|
-
export { type AuthorizationResponseMode, type Config, type EIP712TypedData, type EIP712TypedDataDomain, type EIP712TypedDataField, type Env, type SendTransactionResult, type SignResult, UWError, type UWErrorCode, UnWallet };
|
|
122
|
+
export type { AuthorizationResponseMode, Config, EIP712TypedData, EIP712TypedDataDomain, EIP712TypedDataField, Env, SendTransactionResult, SignResult, UWErrorCode };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Address, Hash, Hex } from "viem";
|
|
2
|
-
import
|
|
3
|
-
//#region src/config.d.ts
|
|
2
|
+
import * as z from "zod";
|
|
4
3
|
type Env = "prod" | "dev";
|
|
5
4
|
interface Config {
|
|
6
5
|
env?: Env;
|
|
@@ -10,8 +9,6 @@ interface UnWalletXAPIConfig {
|
|
|
10
9
|
url: string;
|
|
11
10
|
connectionTimeout: number;
|
|
12
11
|
}
|
|
13
|
-
//#endregion
|
|
14
|
-
//#region src/eip712.d.ts
|
|
15
12
|
interface EIP712TypedData {
|
|
16
13
|
types: Record<string, Array<EIP712TypedDataField>>;
|
|
17
14
|
primaryType: string;
|
|
@@ -29,15 +26,11 @@ interface EIP712TypedDataField {
|
|
|
29
26
|
name: string;
|
|
30
27
|
type: string;
|
|
31
28
|
}
|
|
32
|
-
//#endregion
|
|
33
|
-
//#region src/error.d.ts
|
|
34
29
|
type UWErrorCode = "CONNECTION_TIMEOUT" | "CONNECTION_FAILED" | "CONNECTION_NOT_OPENED" | "CONNECTION_CLOSED" | "INVALID_REQUEST" | "REQUEST_IN_PROGRESS" | "REQUEST_REJECTED" | "INVALID_RESPONSE";
|
|
35
|
-
declare class UWError extends Error {
|
|
30
|
+
export declare class UWError extends Error {
|
|
36
31
|
readonly code: UWErrorCode;
|
|
37
32
|
constructor(code: UWErrorCode, msg?: string);
|
|
38
33
|
}
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region src/xconn.d.ts
|
|
41
34
|
declare const xResponseSchema: z.ZodReadonly<z.ZodUnion<readonly [z.ZodObject<{
|
|
42
35
|
type: z.ZodLiteral<"connectionID">;
|
|
43
36
|
value: z.ZodString;
|
|
@@ -82,8 +75,6 @@ declare class XConnection {
|
|
|
82
75
|
setResponseHandler(respHandler: XResponseHandler | null): void;
|
|
83
76
|
close(): void;
|
|
84
77
|
}
|
|
85
|
-
//#endregion
|
|
86
|
-
//#region src/unwallet.d.ts
|
|
87
78
|
type AuthorizationResponseMode = "fragment" | "form_post";
|
|
88
79
|
interface SignResult {
|
|
89
80
|
digest: Hash;
|
|
@@ -92,7 +83,7 @@ interface SignResult {
|
|
|
92
83
|
interface SendTransactionResult {
|
|
93
84
|
transactionID: string;
|
|
94
85
|
}
|
|
95
|
-
declare class UnWallet {
|
|
86
|
+
export declare class UnWallet {
|
|
96
87
|
private readonly env;
|
|
97
88
|
private readonly clientID;
|
|
98
89
|
private readonly xConnection;
|
|
@@ -128,5 +119,4 @@ declare class UnWallet {
|
|
|
128
119
|
private request;
|
|
129
120
|
close(): void;
|
|
130
121
|
}
|
|
131
|
-
|
|
132
|
-
export { type AuthorizationResponseMode, type Config, type EIP712TypedData, type EIP712TypedDataDomain, type EIP712TypedDataField, type Env, type SendTransactionResult, type SignResult, UWError, type UWErrorCode, UnWallet };
|
|
122
|
+
export type { AuthorizationResponseMode, Config, EIP712TypedData, EIP712TypedDataDomain, EIP712TypedDataField, Env, SendTransactionResult, SignResult, UWErrorCode };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseError, hashTypedData, isHex, sha256, toBytes, validateTypedData } from "viem";
|
|
2
|
-
import
|
|
3
|
-
|
|
2
|
+
import * as z from "zod";
|
|
3
|
+
// src/error.ts
|
|
4
4
|
var UWError = class extends Error {
|
|
5
5
|
static {
|
|
6
6
|
this.prototype.name = "UWError";
|
|
@@ -10,8 +10,7 @@ var UWError = class extends Error {
|
|
|
10
10
|
this.code = code;
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
|
-
|
|
14
|
-
//#region src/config.ts
|
|
13
|
+
// src/config.ts
|
|
15
14
|
const envToUnWalletConfig = {
|
|
16
15
|
prod: {
|
|
17
16
|
frontend: { origin: "https://id.unwallet.world" },
|
|
@@ -194,8 +193,7 @@ function newUnexpectedXResponseTypeError(resp) {
|
|
|
194
193
|
function newConnectionClosedError(event) {
|
|
195
194
|
return new UWError("CONNECTION_CLOSED", event.reason.length > 0 ? event.reason : void 0);
|
|
196
195
|
}
|
|
197
|
-
|
|
198
|
-
//#region src/unwallet.ts
|
|
196
|
+
// src/unwallet.ts
|
|
199
197
|
var UnWallet = class UnWallet {
|
|
200
198
|
constructor(args) {
|
|
201
199
|
this.env = args.env;
|
|
@@ -309,5 +307,4 @@ var UnWallet = class UnWallet {
|
|
|
309
307
|
this.xConnection.close();
|
|
310
308
|
}
|
|
311
309
|
};
|
|
312
|
-
//#endregion
|
|
313
310
|
export { UWError, UnWallet };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unwallet-client-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"description": "unWallet client-side SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "SIVIRA",
|
|
@@ -29,22 +29,21 @@
|
|
|
29
29
|
"url": "git+https://github.com/SIVIRA/unwallet-client-sdk-js.git"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"viem": "2.
|
|
33
|
-
"zod": "4.
|
|
32
|
+
"viem": "2.57.11",
|
|
33
|
+
"zod": "4.6.7"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@commitlint/cli": "21.2.
|
|
37
|
-
"@commitlint/config-conventional": "21.2.
|
|
38
|
-
"@commitlint/types": "21.2.0",
|
|
36
|
+
"@commitlint/cli": "21.2.4",
|
|
37
|
+
"@commitlint/config-conventional": "21.2.4",
|
|
39
38
|
"@tsconfig/strictest": "2.0.8",
|
|
40
|
-
"@vitest/coverage-v8": "
|
|
41
|
-
"czg": "1.
|
|
39
|
+
"@vitest/coverage-v8": "5.0.5",
|
|
40
|
+
"czg": "1.14.0",
|
|
42
41
|
"husky": "9.1.7",
|
|
43
42
|
"msw": "2.15.0",
|
|
44
|
-
"publint": "0.3.
|
|
45
|
-
"tsdown": "0.
|
|
46
|
-
"typescript": "
|
|
47
|
-
"vitest": "
|
|
43
|
+
"publint": "0.3.25",
|
|
44
|
+
"tsdown": "0.23.2",
|
|
45
|
+
"typescript": "6.0.3",
|
|
46
|
+
"vitest": "5.0.5"
|
|
48
47
|
},
|
|
49
48
|
"scripts": {}
|
|
50
49
|
}
|