@4mica/sdk 1.2.10 → 1.2.12

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.
Files changed (56) hide show
  1. package/dist/package.json +76 -0
  2. package/dist/{rpc.js → src/rpc.js} +3 -1
  3. package/dist/{x402 → src/x402}/index.js +3 -2
  4. package/package.json +1 -1
  5. /package/dist/{abi → src/abi}/core4mica.d.ts +0 -0
  6. /package/dist/{abi → src/abi}/core4mica.js +0 -0
  7. /package/dist/{abi → src/abi}/erc20.d.ts +0 -0
  8. /package/dist/{abi → src/abi}/erc20.js +0 -0
  9. /package/dist/{auth.d.ts → src/auth.d.ts} +0 -0
  10. /package/dist/{auth.js → src/auth.js} +0 -0
  11. /package/dist/{bls.d.ts → src/bls.d.ts} +0 -0
  12. /package/dist/{bls.js → src/bls.js} +0 -0
  13. /package/dist/{chain.d.ts → src/chain.d.ts} +0 -0
  14. /package/dist/{chain.js → src/chain.js} +0 -0
  15. /package/dist/{client → src/client}/index.d.ts +0 -0
  16. /package/dist/{client → src/client}/index.js +0 -0
  17. /package/dist/{client → src/client}/recipient.d.ts +0 -0
  18. /package/dist/{client → src/client}/recipient.js +0 -0
  19. /package/dist/{client → src/client}/shared.d.ts +0 -0
  20. /package/dist/{client → src/client}/shared.js +0 -0
  21. /package/dist/{client → src/client}/user.d.ts +0 -0
  22. /package/dist/{client → src/client}/user.js +0 -0
  23. /package/dist/{config.d.ts → src/config.d.ts} +0 -0
  24. /package/dist/{config.js → src/config.js} +0 -0
  25. /package/dist/{constants.d.ts → src/constants.d.ts} +0 -0
  26. /package/dist/{constants.js → src/constants.js} +0 -0
  27. /package/dist/{contract.d.ts → src/contract.d.ts} +0 -0
  28. /package/dist/{contract.js → src/contract.js} +0 -0
  29. /package/dist/{debug.d.ts → src/debug.d.ts} +0 -0
  30. /package/dist/{debug.js → src/debug.js} +0 -0
  31. /package/dist/{errors.d.ts → src/errors.d.ts} +0 -0
  32. /package/dist/{errors.js → src/errors.js} +0 -0
  33. /package/dist/{guarantee.d.ts → src/guarantee.d.ts} +0 -0
  34. /package/dist/{guarantee.js → src/guarantee.js} +0 -0
  35. /package/dist/{http.d.ts → src/http.d.ts} +0 -0
  36. /package/dist/{http.js → src/http.js} +0 -0
  37. /package/dist/{index.d.ts → src/index.d.ts} +0 -0
  38. /package/dist/{index.js → src/index.js} +0 -0
  39. /package/dist/{models.d.ts → src/models.d.ts} +0 -0
  40. /package/dist/{models.js → src/models.js} +0 -0
  41. /package/dist/{networks.d.ts → src/networks.d.ts} +0 -0
  42. /package/dist/{networks.js → src/networks.js} +0 -0
  43. /package/dist/{payment.d.ts → src/payment.d.ts} +0 -0
  44. /package/dist/{payment.js → src/payment.js} +0 -0
  45. /package/dist/{rpc.d.ts → src/rpc.d.ts} +0 -0
  46. /package/dist/{serde.d.ts → src/serde.d.ts} +0 -0
  47. /package/dist/{serde.js → src/serde.js} +0 -0
  48. /package/dist/{signing.d.ts → src/signing.d.ts} +0 -0
  49. /package/dist/{signing.js → src/signing.js} +0 -0
  50. /package/dist/{utils.d.ts → src/utils.d.ts} +0 -0
  51. /package/dist/{utils.js → src/utils.js} +0 -0
  52. /package/dist/{validation.d.ts → src/validation.d.ts} +0 -0
  53. /package/dist/{validation.js → src/validation.js} +0 -0
  54. /package/dist/{x402 → src/x402}/index.d.ts +0 -0
  55. /package/dist/{x402 → src/x402}/models.d.ts +0 -0
  56. /package/dist/{x402 → src/x402}/models.js +0 -0
@@ -0,0 +1,76 @@
1
+ {
2
+ "name": "@4mica/sdk",
3
+ "version": "1.2.12",
4
+ "description": "TypeScript SDK for interacting with the 4Mica payment network",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/4mica-Network/ts-sdk-4mica.git"
9
+ },
10
+ "homepage": "https://github.com/4mica-Network/ts-sdk-4mica#readme",
11
+ "bugs": {
12
+ "url": "https://github.com/4mica-Network/ts-sdk-4mica/issues"
13
+ },
14
+ "main": "dist/index.js",
15
+ "types": "dist/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "default": "./dist/index.js"
20
+ }
21
+ },
22
+ "files": [
23
+ "dist"
24
+ ],
25
+ "sideEffects": false,
26
+ "engines": {
27
+ "node": ">=18"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "keywords": [
33
+ "4mica",
34
+ "payments",
35
+ "payment-network",
36
+ "blockchain",
37
+ "sdk",
38
+ "typescript",
39
+ "ethers"
40
+ ],
41
+ "scripts": {
42
+ "clean": "node -e \"require('node:fs').rmSync('dist',{ recursive: true, force: true })\"",
43
+ "build": "npm run clean && tsc -p tsconfig.build.json",
44
+ "test": "vitest run",
45
+ "test:e2e": "vitest run --config vitest.e2e.config.ts",
46
+ "example:base-sepolia:x402-v2": "node_modules/.bin/tsx examples/base-sepolia-x402-facilitator-e2e.ts",
47
+ "example:manual:agents": "node_modules/.bin/tsx examples/manual-agents/demo.ts",
48
+ "example:wachai:v2": "node_modules/.bin/tsx examples/wachai-v2-demo/demo.ts",
49
+ "example:deposit": "node_modules/.bin/tsx examples/deposit.ts",
50
+ "example:yield": "node_modules/.bin/tsx examples/yield.ts",
51
+ "lint": "eslint . --ext .ts",
52
+ "fmt": "prettier --check \"{src,tests}/**/*.{ts,js,json}\""
53
+ },
54
+ "dependencies": {
55
+ "@noble/curves": "^2.2.0",
56
+ "@quillai-network/wachai-validation-sdk": "^0.1.0",
57
+ "viem": "^2.45.1"
58
+ },
59
+ "devDependencies": {
60
+ "@4mica/x402": "^1.2.0",
61
+ "@eslint/js": "^9.39.2",
62
+ "@types/node": "^25.2.0",
63
+ "@typescript-eslint/eslint-plugin": "^8.54.0",
64
+ "@typescript-eslint/parser": "^8.54.0",
65
+ "dotenv-cli": "^11.0.0",
66
+ "eslint": "^9.39.2",
67
+ "eslint-config-prettier": "^10.1.8",
68
+ "eslint-plugin-react": "^7.37.5",
69
+ "globals": "^17.3.0",
70
+ "prettier": "^3.8.1",
71
+ "tsx": "^4.21.0",
72
+ "typescript": "^5.3.3",
73
+ "typescript-eslint": "^8.54.0",
74
+ "vitest": "^4.0.17"
75
+ }
76
+ }
@@ -5,6 +5,8 @@ const constants_1 = require("./constants");
5
5
  const models_1 = require("./models");
6
6
  const errors_1 = require("./errors");
7
7
  const http_1 = require("./http");
8
+ const package_json_1 = require("../package.json");
9
+ const SDK_CLIENT_HEADER_VALUE = `ts-sdk-4mica/${package_json_1.version}`;
8
10
  function serializeTabId(tabId) {
9
11
  return `0x${BigInt(tabId).toString(16)}`;
10
12
  }
@@ -31,7 +33,7 @@ class RpcProxy {
31
33
  return this;
32
34
  }
33
35
  async headers() {
34
- const headers = {};
36
+ const headers = { 'x-4mica-sdk': SDK_CLIENT_HEADER_VALUE };
35
37
  if (this.adminApiKey) {
36
38
  headers[constants_1.ADMIN_API_KEY_HEADER] = this.adminApiKey;
37
39
  }
@@ -106,8 +106,9 @@ class X402Flow {
106
106
  */
107
107
  async signPaymentV2(paymentRequired, accepted, userAddress) {
108
108
  X402Flow.validateScheme(accepted.scheme);
109
- const tab = await this.requestTab(2, accepted, userAddress, paymentRequired.resource);
110
- const claims = hasValidationPolicy(accepted.extra)
109
+ const isV2Claims = hasValidationPolicy(accepted.extra);
110
+ const tab = await this.requestTab(isV2Claims ? 2 : 1, accepted, userAddress, paymentRequired.resource);
111
+ const claims = isV2Claims
111
112
  ? this.buildClaimsV2(accepted, tab, userAddress)
112
113
  : this.buildClaims(accepted, tab, userAddress);
113
114
  const signature = await this.signer.signPayment(claims, models_1.SigningScheme.EIP712);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@4mica/sdk",
3
- "version": "1.2.10",
3
+ "version": "1.2.12",
4
4
  "description": "TypeScript SDK for interacting with the 4Mica payment network",
5
5
  "license": "MIT",
6
6
  "repository": {
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes