@rozoai/intent-pay 0.1.26 → 0.1.27-beta.2

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 (47) hide show
  1. package/README.md +3 -1
  2. package/build/components/Common/PaymentBreakdown/index.d.ts +3 -1
  3. package/build/constants/rozoConfig.d.ts +2 -0
  4. package/build/hooks/usePaymentState.d.ts +1 -3
  5. package/build/lib/analytics/events.d.ts +6 -0
  6. package/build/package.json.js +53 -53
  7. package/build/provider/AnalyticsProvider.d.ts +10 -2
  8. package/build/provider/RozoPayProvider.d.ts +6 -0
  9. package/build/src/components/Common/Modal/index.js +3 -3
  10. package/build/src/components/Common/Modal/index.js.map +1 -1
  11. package/build/src/components/Common/OptionsList/index.js +3 -3
  12. package/build/src/components/Common/OptionsList/index.js.map +1 -1
  13. package/build/src/components/Common/PaymentBreakdown/index.js +24 -5
  14. package/build/src/components/Common/PaymentBreakdown/index.js.map +1 -1
  15. package/build/src/components/Pages/Confirmation/index.js +12 -0
  16. package/build/src/components/Pages/Confirmation/index.js.map +1 -1
  17. package/build/src/components/Pages/Error/index.js +6 -6
  18. package/build/src/components/Pages/Error/index.js.map +1 -1
  19. package/build/src/components/Pages/PayWithToken/index.js +65 -5
  20. package/build/src/components/Pages/PayWithToken/index.js.map +1 -1
  21. package/build/src/components/Pages/SelectMethod/index.js +42 -2
  22. package/build/src/components/Pages/SelectMethod/index.js.map +1 -1
  23. package/build/src/components/Pages/Solana/PayWithSolanaToken/index.js +108 -7
  24. package/build/src/components/Pages/Solana/PayWithSolanaToken/index.js.map +1 -1
  25. package/build/src/components/Pages/Stellar/PayWithStellarToken/index.js +115 -9
  26. package/build/src/components/Pages/Stellar/PayWithStellarToken/index.js.map +1 -1
  27. package/build/src/components/Pages/WaitingDepositAddress/index.js +12 -11
  28. package/build/src/components/Pages/WaitingDepositAddress/index.js.map +1 -1
  29. package/build/src/constants/rozoConfig.js +6 -1
  30. package/build/src/constants/rozoConfig.js.map +1 -1
  31. package/build/src/hooks/usePaymentState.js +21 -41
  32. package/build/src/hooks/usePaymentState.js.map +1 -1
  33. package/build/src/lib/analytics/events.js +6 -1
  34. package/build/src/lib/analytics/events.js.map +1 -1
  35. package/build/src/payment/createPaymentPayload.js +5 -10
  36. package/build/src/payment/createPaymentPayload.js.map +1 -1
  37. package/build/src/provider/AnalyticsProvider.js +65 -11
  38. package/build/src/provider/AnalyticsProvider.js.map +1 -1
  39. package/build/src/provider/RozoPayProvider.js +5 -6
  40. package/build/src/provider/RozoPayProvider.js.map +1 -1
  41. package/build/src/utils/feeCache.js +39 -0
  42. package/build/src/utils/feeCache.js.map +1 -0
  43. package/build/src/utils/sanitize.js +44 -0
  44. package/build/src/utils/sanitize.js.map +1 -0
  45. package/build/utils/feeCache.d.ts +17 -0
  46. package/build/utils/sanitize.d.ts +10 -0
  47. package/package.json +107 -107
@@ -0,0 +1,39 @@
1
+ import { getFee } from '@rozoai/intent-common';
2
+
3
+ const cache = new Map();
4
+ function getCachedFee(params) {
5
+ const key = JSON.stringify({
6
+ appId: params.appId ?? null,
7
+ type: params.type,
8
+ sourceChainId: params.sourceChainId,
9
+ sourceTokenSymbol: params.sourceTokenSymbol,
10
+ amount: params.amount,
11
+ destChainId: params.destChainId,
12
+ destReceiverAddress: params.destReceiverAddress,
13
+ destTokenSymbol: params.destTokenSymbol,
14
+ });
15
+ const existing = cache.get(key);
16
+ if (existing) {
17
+ if (existing.status === "resolved") {
18
+ return Promise.resolve(existing.value);
19
+ }
20
+ // Another caller is already in-flight for the same params — share the promise
21
+ return existing.promise;
22
+ }
23
+ const promise = getFee(params).then((result) => {
24
+ // Only cache successful responses; errors should be retryable
25
+ if (!result.error) {
26
+ cache.set(key, { status: "resolved", value: result });
27
+ }
28
+ else {
29
+ // Remove the pending entry so a subsequent call can retry
30
+ cache.delete(key);
31
+ }
32
+ return result;
33
+ });
34
+ cache.set(key, { status: "pending", promise });
35
+ return promise;
36
+ }
37
+
38
+ export { getCached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M,CAAC;AAChB,KAAC,CAAC,CAAC;AAEH,IAAA,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC;AAC/C,IAAA,OAAO,OAAO,CAAC;AACjB;;;;"}
@@ -0,0 +1,44 @@
1
+ // EVM address: 0x + 40 hex chars
2
+ const EVM_ADDRESS_RE = /0x[0-9a-fA-F]{40}/g;
3
+ // Solana address: base58, 32–44 chars (not starting with 0x)
4
+ const SOLANA_ADDRESS_RE = /\b[1-9A-HJ-NP-Za-km-z]{32,44}\b/g;
5
+ // Stellar address: G + 55 base32 chars
6
+ const STELLAR_ADDRESS_RE = /\bG[A-Z2-7]{55}\b/g;
7
+ // EVM tx hash: 0x + 64 hex chars
8
+ const TX_HASH_RE = /0x[0-9a-fA-F]{64}/g;
9
+ // Numeric amounts (standalone decimals that look like token amounts)
10
+ const AMOUNT_RE = /\b\d+(\.\d+)?\s*(USDC|USDT|ETH|SOL|XLM|BTC|[A-Z]{2,6})?\b/g;
11
+ /**
12
+ * Strips addresses, tx hashes, and token amounts from a string before
13
+ * sending to analytics. Prevents PII / sensitive financial data leakage.
14
+ */
15
+ function sanitizeForAnalytics(value) {
16
+ return value
17
+ .replace(TX_HASH_RE, "[tx_hash]")
18
+ .replace(EVM_ADDRESS_RE, "[address]")
19
+ .replace(STELLAR_ADDRESS_RE, "[address]")
20
+ .replace(SOLANA_ADDRESS_RE, "[address]")
21
+ .replace(AMOUNT_RE, "[amount]");
22
+ }
23
+ /**
24
+ * Sanitizes all string values in a properties object recursively.
25
+ * Non-string values pass through unchanged.
26
+ */
27
+ function sanitizeProperties(props) {
28
+ const out = {};
29
+ for (const [key, val] of Object.entries(props)) {
30
+ if (typeof val === "string") {
31
+ out[key] = sanitizeForAnalytics(val);
32
+ }
33
+ else if (val !== null && typeof val === "object" && !Array.isArray(val)) {
34
+ out[key] = sanitizeProperties(val);
35
+ }
36
+ else {
37
+ out[key] = val;
38
+ }
39
+ }
40
+ return out;
41
+ }
42
+
43
+ export { sanitizeForAnalytics, sanitizeProperties };
44
+ //# sourceMappingURL=sanitize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sanitize.js","sources":["../../../src/utils/sanitize.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA,MAAM,cAAc,GAAG,oBAAoB,CAAC;AAC5C;AACA,MAAM,iBAAiB,GAAG,kCAAkC,CAAC;AAC7D;AACA,MAAM,kBAAkB,GAAG,oBAAoB,CAAC;AAChD;AACA,MAAM,UAAU,GAAG,oBAAoB,CAAC;AACxC;AACA,MAAM,SAAS,GAAG,4DAA4D,CAAC;AAE/E;;;AAGG;AACG,SAAU,oBAAoB,CAAC,KAAa,EAAA;AAChD,IAAA,OAAO,KAAK;AACT,SAAA,OAAO,CAAC,UAAU,EAAE,WAAW,CAAC;AAChC,SAAA,OAAO,CAAC,cAAc,EAAE,WAAW,CAAC;AACpC,SAAA,OAAO,CAAC,kBAAkB,EAAE,WAAW,CAAC;AACxC,SAAA,OAAO,CAAC,iBAAiB,EAAE,WAAW,CAAC;AACvC,SAAA,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AACpC,CAAC;AAED;;;AAGG;AACG,SAAU,kBAAkB,CAChC,KAA8B,EAAA;IAE9B,MAAM,GAAG,GAA4B,EAAE,CAAC;AACxC,IAAA,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AAC9C,QAAA,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YAC3B,GAAG,CAAC,GAAG,CAAC,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAC;SACtC;AAAM,aAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YACzE,GAAG,CAAC,GAAG,CAAC,GAAG,kBAAkB,CAAC,GAA8B,CAAC,CAAC;SAC/D;aAAM;AACL,YAAA,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;SAChB;KACF;AACD,IAAA,OAAO,GAAG,CAAC;AACb;;;;"}
@@ -0,0 +1,17 @@
1
+ import { getFee, GetFeeParams } from "@rozoai/intent-common";
2
+ /**
3
+ * Module-level cache for getFee results, keyed by a stable JSON representation
4
+ * of the request params. Lives for the lifetime of the page/module, so the same
5
+ * token+chain+amount combo never triggers a second network call within a single
6
+ * user session — even if the component unmounts and remounts (e.g. cancel → retry
7
+ * with the same token).
8
+ *
9
+ * In-flight requests are also deduplicated: if two callers ask for the same key
10
+ * simultaneously, only one network request is made and both callers receive the
11
+ * same resolved value.
12
+ */
13
+ type FeeResult = Awaited<ReturnType<typeof getFee>>;
14
+ export declare function getCachedFee(params: GetFeeParams): Promise<FeeResult>;
15
+ /** Exposed for testing or explicit invalidation if needed. */
16
+ export declare function clearFeeCache(): void;
17
+ export {};
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Strips addresses, tx hashes, and token amounts from a string before
3
+ * sending to analytics. Prevents PII / sensitive financial data leakage.
4
+ */
5
+ export declare function sanitizeForAnalytics(value: string): string;
6
+ /**
7
+ * Sanitizes all string values in a properties object recursively.
8
+ * Non-string values pass through unchanged.
9
+ */
10
+ export declare function sanitizeProperties(props: Record<string, unknown>): Record<string, unknown>;
package/package.json CHANGED
@@ -1,107 +1,107 @@
1
- {
2
- "name": "@rozoai/intent-pay",
3
- "private": false,
4
- "version": "0.1.26",
5
- "author": "RozoAI",
6
- "homepage": "https://github.com/RozoAI/intent-pay",
7
- "license": "BSD-2-Clause",
8
- "description": "Seamless crypto payments. Onboard users from any chain, any coin into your app with one click.",
9
- "main": "./src/index.ts",
10
- "type": "module",
11
- "exports": {
12
- ".": {
13
- "import": "./build/src/index.js",
14
- "types": "./build/index.d.ts"
15
- }
16
- },
17
- "types": "./build/index.d.ts",
18
- "engines": {
19
- "node": ">=12.4"
20
- },
21
- "files": [
22
- "build",
23
- "README.md"
24
- ],
25
- "scripts": {
26
- "start": "rollup --config rollup.config.js -w",
27
- "dev": "rollup --config rollup.config.js -w",
28
- "build": "rollup --config rollup.config.js",
29
- "prepublishOnly": "pnpm run build",
30
- "lint": "eslint 'src/**/*.{js,jsx,ts,tsx}' --quiet",
31
- "release": "bumpp",
32
- "publish:beta": "pnpm publish --no-git-checks --tag beta",
33
- "publish:latest": "pnpm publish --no-git-checks --tag latest"
34
- },
35
- "keywords": [
36
- "ens",
37
- "react-hook",
38
- "blockchain",
39
- "hooks",
40
- "family",
41
- "ethereum",
42
- "react",
43
- "rozoai",
44
- "pay",
45
- "payment",
46
- "crypto"
47
- ],
48
- "dependencies": {
49
- "@reown/appkit": "^1.7.0",
50
- "@rollup/plugin-image": "^3.0.3",
51
- "@rollup/plugin-typescript": "^12.1.2",
52
- "@rozoai/intent-common": "0.1.18",
53
- "@solana/spl-token": "^0.4.14",
54
- "@solana/wallet-adapter-base": "^0.9.27",
55
- "@solana/wallet-adapter-react": "^0.15.39",
56
- "@solana/web3.js": "^1.98.4",
57
- "@trpc/client": "^11.0.0-next-beta.318",
58
- "@trpc/server": "^11.0.0-next-beta.318",
59
- "@walletconnect/sign-client": "^2.22.3",
60
- "@worldcoin/minikit-js": "^1.9.7",
61
- "bs58": "^6.0.0",
62
- "buffer": "^6.0.3",
63
- "detect-browser": "^5.3.0",
64
- "framer-motion": "^11.11.4",
65
- "pusher-js": "^8.4.0",
66
- "qrcode": "^1.5.4",
67
- "react-transition-state": "^1.1.4",
68
- "react-use-measure": "^2.1.1",
69
- "resize-observer-polyfill": "^1.5.1",
70
- "styled-components": "^5.3.5"
71
- },
72
- "peerDependencies": {
73
- "@creit.tech/stellar-wallets-kit": "^1.9.5",
74
- "posthog-js": "^1.0.0",
75
- "@stellar/stellar-sdk": "^14.2.0",
76
- "@tanstack/react-query": ">=5.0.0",
77
- "react": "18.x || 19.x",
78
- "react-dom": "18.x || 19.x",
79
- "viem": "2.x",
80
- "wagmi": "2.x"
81
- },
82
- "peerDependenciesMeta": {
83
- "@worldcoin/minikit-js": {
84
- "optional": true
85
- },
86
- "posthog-js": {
87
- "optional": true
88
- }
89
- },
90
- "devDependencies": {
91
- "@rollup/plugin-json": "^6.1.0",
92
- "@types/node": "^20.14.12",
93
- "@types/qrcode": "^1.4.2",
94
- "@types/react": "^18.2.47",
95
- "@types/react-dom": "^18.2.18",
96
- "@types/styled-components": "^5.1.25",
97
- "@typescript-eslint/eslint-plugin": "^8.0.0",
98
- "@typescript-eslint/parser": "^8.0.0",
99
- "@walletconnect/types": "^2.22.3",
100
- "eslint": "^8.57.0",
101
- "eslint-plugin-react": "^7.37.0",
102
- "eslint-plugin-react-hooks": "^5.2.0",
103
- "rollup": "^3.29.5",
104
- "rollup-plugin-peer-deps-external": "^2.2.4",
105
- "rollup-plugin-visualizer": "^6.0.5"
106
- }
107
- }
1
+ {
2
+ "name": "@rozoai/intent-pay",
3
+ "version": "0.1.27-beta.2",
4
+ "private": false,
5
+ "description": "Seamless crypto payments. Onboard users from any chain, any coin into your app with one click.",
6
+ "keywords": [
7
+ "blockchain",
8
+ "crypto",
9
+ "ens",
10
+ "ethereum",
11
+ "family",
12
+ "hooks",
13
+ "pay",
14
+ "payment",
15
+ "react",
16
+ "react-hook",
17
+ "rozoai"
18
+ ],
19
+ "homepage": "https://github.com/RozoAI/intent-pay",
20
+ "license": "BSD-2-Clause",
21
+ "author": "RozoAI",
22
+ "files": [
23
+ "build",
24
+ "README.md"
25
+ ],
26
+ "type": "module",
27
+ "main": "./src/index.ts",
28
+ "types": "./build/index.d.ts",
29
+ "exports": {
30
+ ".": {
31
+ "import": "./build/src/index.js",
32
+ "types": "./build/index.d.ts"
33
+ }
34
+ },
35
+ "scripts": {
36
+ "start": "rollup --config rollup.config.js -w",
37
+ "dev": "rollup --config rollup.config.js -w",
38
+ "build": "rollup --config rollup.config.js",
39
+ "prepublishOnly": "pnpm run build",
40
+ "lint": "oxlint src/",
41
+ "format": "oxfmt src/",
42
+ "format:check": "oxfmt --check src/",
43
+ "release": "bumpp",
44
+ "publish:beta": "pnpm publish --no-git-checks --tag beta",
45
+ "publish:latest": "pnpm publish --no-git-checks --tag latest"
46
+ },
47
+ "dependencies": {
48
+ "@reown/appkit": "^1.7.0",
49
+ "@rollup/plugin-image": "^3.0.3",
50
+ "@rollup/plugin-typescript": "^12.1.2",
51
+ "@rozoai/intent-common": "0.1.19-beta.2",
52
+ "@solana/spl-memo": "^0.2.5",
53
+ "@solana/spl-token": "^0.4.14",
54
+ "@solana/wallet-adapter-base": "^0.9.27",
55
+ "@solana/wallet-adapter-react": "^0.15.39",
56
+ "@solana/web3.js": "^1.98.4",
57
+ "@trpc/client": "^11.0.0-next-beta.318",
58
+ "@trpc/server": "^11.0.0-next-beta.318",
59
+ "@walletconnect/sign-client": "^2.22.3",
60
+ "@worldcoin/minikit-js": "^1.9.7",
61
+ "bs58": "^6.0.0",
62
+ "buffer": "^6.0.3",
63
+ "detect-browser": "^5.3.0",
64
+ "framer-motion": "^11.11.4",
65
+ "pusher-js": "^8.4.0",
66
+ "qrcode": "^1.5.4",
67
+ "react-transition-state": "^1.1.4",
68
+ "react-use-measure": "^2.1.1",
69
+ "resize-observer-polyfill": "^1.5.1",
70
+ "styled-components": "^5.3.5"
71
+ },
72
+ "devDependencies": {
73
+ "@rollup/plugin-json": "^6.1.0",
74
+ "@types/node": "^20.14.12",
75
+ "@types/qrcode": "^1.4.2",
76
+ "@types/react": "^18.2.47",
77
+ "@types/react-dom": "^18.2.18",
78
+ "@types/styled-components": "^5.1.25",
79
+ "@walletconnect/types": "^2.22.3",
80
+ "oxfmt": "latest",
81
+ "oxlint": "latest",
82
+ "rollup": "^3.29.5",
83
+ "rollup-plugin-peer-deps-external": "^2.2.4",
84
+ "rollup-plugin-visualizer": "^6.0.5"
85
+ },
86
+ "peerDependencies": {
87
+ "@creit.tech/stellar-wallets-kit": "^1.9.5",
88
+ "@stellar/stellar-sdk": "^14.2.0",
89
+ "@tanstack/react-query": ">=5.0.0",
90
+ "posthog-js": "^1.0.0",
91
+ "react": "18.x || 19.x",
92
+ "react-dom": "18.x || 19.x",
93
+ "viem": "2.x",
94
+ "wagmi": "2.x"
95
+ },
96
+ "peerDependenciesMeta": {
97
+ "@worldcoin/minikit-js": {
98
+ "optional": true
99
+ },
100
+ "posthog-js": {
101
+ "optional": true
102
+ }
103
+ },
104
+ "engines": {
105
+ "node": ">=12.4"
106
+ }
107
+ }