@pay-skill/sdk 0.1.1 → 0.1.3
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 +154 -154
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +2 -2
- package/dist/auth.js.map +1 -1
- package/dist/client.d.ts +8 -7
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +106 -54
- package/dist/client.js.map +1 -1
- package/dist/eip3009.d.ts +24 -0
- package/dist/eip3009.d.ts.map +1 -0
- package/dist/eip3009.js +56 -0
- package/dist/eip3009.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/models.d.ts +35 -26
- package/dist/models.d.ts.map +1 -1
- package/dist/signer.d.ts +1 -1
- package/dist/signer.d.ts.map +1 -1
- package/dist/signer.js +1 -2
- package/dist/signer.js.map +1 -1
- package/dist/wallet.d.ts.map +1 -1
- package/dist/wallet.js +6 -3
- package/dist/wallet.js.map +1 -1
- package/jsr.json +12 -0
- package/package.json +48 -44
- package/src/auth.ts +200 -200
- package/src/client.ts +644 -644
- package/src/eip3009.ts +79 -79
- package/src/index.ts +51 -51
- package/src/models.ts +77 -77
- package/src/ows-signer.ts +223 -223
- package/src/signer.ts +147 -147
- package/src/wallet.ts +445 -445
- package/tests/test_auth_rejection.ts +154 -154
- package/tests/test_crypto.ts +251 -251
- package/tests/test_e2e.ts +158 -158
- package/tests/test_ows_integration.ts +92 -92
- package/tests/test_ows_signer.ts +365 -365
- package/tests/test_validation.ts +66 -66
package/tests/test_validation.ts
CHANGED
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
import { describe, it } from "node:test";
|
|
2
|
-
import assert from "node:assert/strict";
|
|
3
|
-
import { PayClient } from "../src/client.js";
|
|
4
|
-
import { PayValidationError } from "../src/errors.js";
|
|
5
|
-
import { CallbackSigner } from "../src/signer.js";
|
|
6
|
-
|
|
7
|
-
const VALID_ADDR = "0x" + "a1".repeat(20);
|
|
8
|
-
const dummySigner = new CallbackSigner(() => new Uint8Array(65));
|
|
9
|
-
|
|
10
|
-
const client = new PayClient({
|
|
11
|
-
apiUrl: "http://localhost:9999",
|
|
12
|
-
signer: dummySigner,
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
describe("payDirect validation", () => {
|
|
16
|
-
it("rejects invalid address", async () => {
|
|
17
|
-
await assert.rejects(
|
|
18
|
-
() => client.payDirect("not-an-address", 1_000_000),
|
|
19
|
-
PayValidationError
|
|
20
|
-
);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it("rejects amount below minimum", async () => {
|
|
24
|
-
await assert.rejects(
|
|
25
|
-
() => client.payDirect(VALID_ADDR, 500_000),
|
|
26
|
-
PayValidationError
|
|
27
|
-
);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it("accepts valid inputs (fails on network, not validation)", async () => {
|
|
31
|
-
// This should fail with a network error, not validation
|
|
32
|
-
await assert.rejects(
|
|
33
|
-
() => client.payDirect(VALID_ADDR, 1_000_000),
|
|
34
|
-
(err: Error) => {
|
|
35
|
-
assert.ok(!(err instanceof PayValidationError));
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
);
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
describe("openTab validation", () => {
|
|
44
|
-
it("rejects amount below $5 minimum", async () => {
|
|
45
|
-
await assert.rejects(
|
|
46
|
-
() =>
|
|
47
|
-
client.openTab(VALID_ADDR, 1_000_000, { maxChargePerCall: 100_000 }),
|
|
48
|
-
PayValidationError
|
|
49
|
-
);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("rejects zero maxChargePerCall", async () => {
|
|
53
|
-
await assert.rejects(
|
|
54
|
-
() => client.openTab(VALID_ADDR, 10_000_000, { maxChargePerCall: 0 }),
|
|
55
|
-
PayValidationError
|
|
56
|
-
);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it("rejects invalid provider address", async () => {
|
|
60
|
-
await assert.rejects(
|
|
61
|
-
() =>
|
|
62
|
-
client.openTab("bad-addr", 10_000_000, { maxChargePerCall: 500_000 }),
|
|
63
|
-
PayValidationError
|
|
64
|
-
);
|
|
65
|
-
});
|
|
66
|
-
});
|
|
1
|
+
import { describe, it } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { PayClient } from "../src/client.js";
|
|
4
|
+
import { PayValidationError } from "../src/errors.js";
|
|
5
|
+
import { CallbackSigner } from "../src/signer.js";
|
|
6
|
+
|
|
7
|
+
const VALID_ADDR = "0x" + "a1".repeat(20);
|
|
8
|
+
const dummySigner = new CallbackSigner(() => new Uint8Array(65));
|
|
9
|
+
|
|
10
|
+
const client = new PayClient({
|
|
11
|
+
apiUrl: "http://localhost:9999",
|
|
12
|
+
signer: dummySigner,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
describe("payDirect validation", () => {
|
|
16
|
+
it("rejects invalid address", async () => {
|
|
17
|
+
await assert.rejects(
|
|
18
|
+
() => client.payDirect("not-an-address", 1_000_000),
|
|
19
|
+
PayValidationError
|
|
20
|
+
);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("rejects amount below minimum", async () => {
|
|
24
|
+
await assert.rejects(
|
|
25
|
+
() => client.payDirect(VALID_ADDR, 500_000),
|
|
26
|
+
PayValidationError
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("accepts valid inputs (fails on network, not validation)", async () => {
|
|
31
|
+
// This should fail with a network error, not validation
|
|
32
|
+
await assert.rejects(
|
|
33
|
+
() => client.payDirect(VALID_ADDR, 1_000_000),
|
|
34
|
+
(err: Error) => {
|
|
35
|
+
assert.ok(!(err instanceof PayValidationError));
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
describe("openTab validation", () => {
|
|
44
|
+
it("rejects amount below $5 minimum", async () => {
|
|
45
|
+
await assert.rejects(
|
|
46
|
+
() =>
|
|
47
|
+
client.openTab(VALID_ADDR, 1_000_000, { maxChargePerCall: 100_000 }),
|
|
48
|
+
PayValidationError
|
|
49
|
+
);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("rejects zero maxChargePerCall", async () => {
|
|
53
|
+
await assert.rejects(
|
|
54
|
+
() => client.openTab(VALID_ADDR, 10_000_000, { maxChargePerCall: 0 }),
|
|
55
|
+
PayValidationError
|
|
56
|
+
);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("rejects invalid provider address", async () => {
|
|
60
|
+
await assert.rejects(
|
|
61
|
+
() =>
|
|
62
|
+
client.openTab("bad-addr", 10_000_000, { maxChargePerCall: 500_000 }),
|
|
63
|
+
PayValidationError
|
|
64
|
+
);
|
|
65
|
+
});
|
|
66
|
+
});
|