@antseed/payments 0.1.68 → 0.1.70
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/card-link.d.ts +29 -4
- package/dist/card-link.js +46 -6
- package/dist/card-link.js.map +1 -1
- package/dist/card-link.test.js +76 -6
- package/dist/card-link.test.js.map +1 -1
- package/package.json +4 -4
package/dist/card-link.d.ts
CHANGED
|
@@ -12,12 +12,35 @@
|
|
|
12
12
|
export type AntseedPayIntegration = 'crossmint' | 'stripe';
|
|
13
13
|
export declare const ANTSEED_PAY_INTEGRATIONS: readonly AntseedPayIntegration[];
|
|
14
14
|
export declare const DEFAULT_ANTSEED_PAY_URL = "https://antseed-pay.com/";
|
|
15
|
+
/**
|
|
16
|
+
* The pay page's link rules (its `parseLink`): `amount` is required, whole
|
|
17
|
+
* dollars or up to two decimals, and between $1 and $200. A link outside
|
|
18
|
+
* these bounds — including one with no amount at all — is refused as
|
|
19
|
+
* "invalid or was altered" before the signature is even checked.
|
|
20
|
+
*/
|
|
21
|
+
export declare const ANTSEED_PAY_MIN_USD = 1;
|
|
22
|
+
export declare const ANTSEED_PAY_MAX_USD = 200;
|
|
23
|
+
/** Opened when the caller has no amount; the user can change it on the page. */
|
|
24
|
+
export declare const ANTSEED_PAY_DEFAULT_AMOUNT = "20";
|
|
25
|
+
/**
|
|
26
|
+
* The amount as the page accepts it, or null when the page would refuse the
|
|
27
|
+
* link. Takes the desktop's `String(Number(input))` form and user input
|
|
28
|
+
* ("10.50" → "10.5"); '' and other non-amounts are null.
|
|
29
|
+
*/
|
|
30
|
+
export declare function antseedPayAmount(input: unknown): string | null;
|
|
31
|
+
/**
|
|
32
|
+
* The amount a funding link opens on: the caller's when the page accepts it,
|
|
33
|
+
* else `ANTSEED_PAY_DEFAULT_AMOUNT`. The page refuses an empty amount, so a
|
|
34
|
+
* link is never signed without one.
|
|
35
|
+
*/
|
|
36
|
+
export declare function antseedPayLinkAmount(input: unknown): string;
|
|
15
37
|
/**
|
|
16
38
|
* The signed message. Its header is a wire-format constant matching the pay
|
|
17
39
|
* page's `buildFundingMessage` byte for byte ("AntSeed Pay", capital S) — not
|
|
18
40
|
* display copy, so it must not follow product-name renames. The address is
|
|
19
41
|
* lowercased (verified against the reference sig the page accepts); the URL
|
|
20
|
-
* param stays checksummed. `amount`
|
|
42
|
+
* param stays checksummed. `amount` must be one the page accepts (see
|
|
43
|
+
* `antseedPayAmount`): the page signs the same string it reads from the URL.
|
|
21
44
|
*/
|
|
22
45
|
export declare function antseedPayMessage(address: string, amount: string): string;
|
|
23
46
|
/**
|
|
@@ -29,9 +52,11 @@ export declare function antseedPayMessage(address: string, amount: string): stri
|
|
|
29
52
|
*/
|
|
30
53
|
export declare function resolveCardProviderUrl(template: string, address: string, amount: string): URL;
|
|
31
54
|
/**
|
|
32
|
-
* Adds the Antseed Pay params to `url` in place: address, currency, amount
|
|
33
|
-
*
|
|
34
|
-
*
|
|
55
|
+
* Adds the Antseed Pay params to `url` in place: address, currency, amount,
|
|
56
|
+
* the wallet's signature over `antseedPayMessage`, and the integration to
|
|
57
|
+
* open (unsigned, UX only). Throws when `amount` is one the page refuses
|
|
58
|
+
* (empty, more than two decimals, or outside $1–$200): the link would open
|
|
59
|
+
* to "invalid or was altered", so callers pass `antseedPayLinkAmount(...)`.
|
|
35
60
|
*/
|
|
36
61
|
export declare function signAntseedPayUrl(url: URL, input: {
|
|
37
62
|
wallet: {
|
package/dist/card-link.js
CHANGED
|
@@ -11,12 +11,48 @@
|
|
|
11
11
|
export const ANTSEED_PAY_INTEGRATIONS = ['crossmint', 'stripe'];
|
|
12
12
|
export const DEFAULT_ANTSEED_PAY_URL = 'https://antseed-pay.com/';
|
|
13
13
|
const ANTSEED_PAY_CURRENCY = 'USD';
|
|
14
|
+
/**
|
|
15
|
+
* The pay page's link rules (its `parseLink`): `amount` is required, whole
|
|
16
|
+
* dollars or up to two decimals, and between $1 and $200. A link outside
|
|
17
|
+
* these bounds — including one with no amount at all — is refused as
|
|
18
|
+
* "invalid or was altered" before the signature is even checked.
|
|
19
|
+
*/
|
|
20
|
+
export const ANTSEED_PAY_MIN_USD = 1;
|
|
21
|
+
export const ANTSEED_PAY_MAX_USD = 200;
|
|
22
|
+
const ANTSEED_PAY_AMOUNT_RE = /^\d+(\.\d{1,2})?$/;
|
|
23
|
+
/** Opened when the caller has no amount; the user can change it on the page. */
|
|
24
|
+
export const ANTSEED_PAY_DEFAULT_AMOUNT = '20';
|
|
25
|
+
/**
|
|
26
|
+
* The amount as the page accepts it, or null when the page would refuse the
|
|
27
|
+
* link. Takes the desktop's `String(Number(input))` form and user input
|
|
28
|
+
* ("10.50" → "10.5"); '' and other non-amounts are null.
|
|
29
|
+
*/
|
|
30
|
+
export function antseedPayAmount(input) {
|
|
31
|
+
let amount = Number.NaN;
|
|
32
|
+
if (typeof input === 'number')
|
|
33
|
+
amount = input;
|
|
34
|
+
else if (typeof input === 'string' && input.trim() !== '')
|
|
35
|
+
amount = Number(input);
|
|
36
|
+
if (!Number.isFinite(amount) || amount < ANTSEED_PAY_MIN_USD || amount > ANTSEED_PAY_MAX_USD)
|
|
37
|
+
return null;
|
|
38
|
+
const text = String(amount);
|
|
39
|
+
return ANTSEED_PAY_AMOUNT_RE.test(text) ? text : null;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The amount a funding link opens on: the caller's when the page accepts it,
|
|
43
|
+
* else `ANTSEED_PAY_DEFAULT_AMOUNT`. The page refuses an empty amount, so a
|
|
44
|
+
* link is never signed without one.
|
|
45
|
+
*/
|
|
46
|
+
export function antseedPayLinkAmount(input) {
|
|
47
|
+
return antseedPayAmount(input) ?? ANTSEED_PAY_DEFAULT_AMOUNT;
|
|
48
|
+
}
|
|
14
49
|
/**
|
|
15
50
|
* The signed message. Its header is a wire-format constant matching the pay
|
|
16
51
|
* page's `buildFundingMessage` byte for byte ("AntSeed Pay", capital S) — not
|
|
17
52
|
* display copy, so it must not follow product-name renames. The address is
|
|
18
53
|
* lowercased (verified against the reference sig the page accepts); the URL
|
|
19
|
-
* param stays checksummed. `amount`
|
|
54
|
+
* param stays checksummed. `amount` must be one the page accepts (see
|
|
55
|
+
* `antseedPayAmount`): the page signs the same string it reads from the URL.
|
|
20
56
|
*/
|
|
21
57
|
export function antseedPayMessage(address, amount) {
|
|
22
58
|
return [
|
|
@@ -57,16 +93,20 @@ export function resolveCardProviderUrl(template, address, amount) {
|
|
|
57
93
|
return parsed;
|
|
58
94
|
}
|
|
59
95
|
/**
|
|
60
|
-
* Adds the Antseed Pay params to `url` in place: address, currency, amount
|
|
61
|
-
*
|
|
62
|
-
*
|
|
96
|
+
* Adds the Antseed Pay params to `url` in place: address, currency, amount,
|
|
97
|
+
* the wallet's signature over `antseedPayMessage`, and the integration to
|
|
98
|
+
* open (unsigned, UX only). Throws when `amount` is one the page refuses
|
|
99
|
+
* (empty, more than two decimals, or outside $1–$200): the link would open
|
|
100
|
+
* to "invalid or was altered", so callers pass `antseedPayLinkAmount(...)`.
|
|
63
101
|
*/
|
|
64
102
|
export async function signAntseedPayUrl(url, input) {
|
|
65
103
|
const { wallet, amount, integration } = input;
|
|
104
|
+
if (antseedPayAmount(amount) !== amount) {
|
|
105
|
+
throw new Error(`Antseed Pay amount must be $${ANTSEED_PAY_MIN_USD}–$${ANTSEED_PAY_MAX_USD} with at most 2 decimals`);
|
|
106
|
+
}
|
|
66
107
|
url.searchParams.set('address', wallet.address);
|
|
67
108
|
url.searchParams.set('cur', ANTSEED_PAY_CURRENCY);
|
|
68
|
-
|
|
69
|
-
url.searchParams.set('amount', amount);
|
|
109
|
+
url.searchParams.set('amount', amount);
|
|
70
110
|
url.searchParams.set('sig', await wallet.signMessage(antseedPayMessage(wallet.address, amount)));
|
|
71
111
|
url.searchParams.set('provider', integration);
|
|
72
112
|
return url;
|
package/dist/card-link.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card-link.js","sourceRoot":"","sources":["../src/card-link.ts"],"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,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACtF,OAAO,CAAC,MAAM,iBAAiB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;AAC1D,CAAC"}
|
package/dist/card-link.test.js
CHANGED
|
@@ -1,8 +1,36 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { Wallet, verifyMessage } from 'ethers';
|
|
3
|
-
import { antseedPayMessage, buildAntseedPayLink, DEFAULT_ANTSEED_PAY_URL, resolveCardProviderUrl, signAntseedPayUrl, } from './card-link.js';
|
|
2
|
+
import { getAddress, Wallet, verifyMessage } from 'ethers';
|
|
3
|
+
import { ANTSEED_PAY_DEFAULT_AMOUNT, antseedPayAmount, antseedPayLinkAmount, antseedPayMessage, buildAntseedPayLink, DEFAULT_ANTSEED_PAY_URL, resolveCardProviderUrl, signAntseedPayUrl, } from './card-link.js';
|
|
4
4
|
// Obvious fake key.
|
|
5
5
|
const WALLET = new Wallet(`0x${'11'.repeat(32)}`);
|
|
6
|
+
/**
|
|
7
|
+
* The deployed antseed-pay.com link check, transcribed from its bundle
|
|
8
|
+
* (`buildFundingMessage` / `parseLink`): the page refuses a link whose
|
|
9
|
+
* amount is missing, has more than two decimals or is outside $1–$200
|
|
10
|
+
* before it checks the signature, and recovers the signer from the same
|
|
11
|
+
* header + lowercased address + currency + amount lines. Keep in step with
|
|
12
|
+
* the page; a signer that drifts from it opens to "This funding link is
|
|
13
|
+
* invalid or was altered".
|
|
14
|
+
*/
|
|
15
|
+
function payPageParseLink(link) {
|
|
16
|
+
const params = new URL(link).searchParams;
|
|
17
|
+
const address = getAddress(params.get('address') ?? '');
|
|
18
|
+
const cur = params.get('cur') ?? '';
|
|
19
|
+
const amount = params.get('amount') ?? '';
|
|
20
|
+
const sig = params.get('sig') ?? '';
|
|
21
|
+
if (!['USD', 'GBP', 'EUR'].includes(cur))
|
|
22
|
+
throw new Error('unsupported currency');
|
|
23
|
+
if (!/^\d+(\.\d{1,2})?$/.test(amount))
|
|
24
|
+
throw new Error('invalid amount format');
|
|
25
|
+
if (Number(amount) < 1 || Number(amount) > 200)
|
|
26
|
+
throw new Error('amount must be between 1 and 200');
|
|
27
|
+
if (!/^0x[0-9a-fA-F]{130}$/.test(sig))
|
|
28
|
+
throw new Error('invalid signature format');
|
|
29
|
+
const message = ['AntSeed Pay', `address: ${address.toLowerCase()}`, `currency: ${cur}`, `amount: ${amount}`].join('\n');
|
|
30
|
+
if (verifyMessage(message, sig).toLowerCase() !== address.toLowerCase())
|
|
31
|
+
throw new Error('signature does not match the address');
|
|
32
|
+
return { address, amount };
|
|
33
|
+
}
|
|
6
34
|
describe('card link', () => {
|
|
7
35
|
it('signs the pay page wire format', () => {
|
|
8
36
|
expect(antseedPayMessage('0xAbCdEf0000000000000000000000000000000001', '10.5'))
|
|
@@ -23,10 +51,52 @@ describe('card link', () => {
|
|
|
23
51
|
expect(resolveCardProviderUrl('https://pay.example.test/?buyer={address}&amt={amount}', '0xabc', '').toString())
|
|
24
52
|
.toBe('https://pay.example.test/?buyer=0xabc');
|
|
25
53
|
});
|
|
26
|
-
it('
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
54
|
+
it('refuses to sign an amount the pay page would reject', async () => {
|
|
55
|
+
for (const amount of ['', '0.5', '250', '10.123', '1e1', ' 10', 'abc']) {
|
|
56
|
+
await expect(signAntseedPayUrl(new URL('https://pay.example.test/'), { wallet: WALLET, amount, integration: 'crossmint' }))
|
|
57
|
+
.rejects.toThrow('Antseed Pay amount must be $1–$200 with at most 2 decimals');
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
it('normalises amounts to what the pay page accepts', () => {
|
|
61
|
+
expect(antseedPayAmount('10.50')).toBe('10.5');
|
|
62
|
+
expect(antseedPayAmount(20)).toBe('20');
|
|
63
|
+
expect(antseedPayAmount('1')).toBe('1');
|
|
64
|
+
expect(antseedPayAmount('200')).toBe('200');
|
|
65
|
+
expect(antseedPayAmount('199.99')).toBe('199.99');
|
|
66
|
+
for (const bad of ['', '0', '0.99', '200.01', '10.125', 'abc', null, undefined, Number.NaN]) {
|
|
67
|
+
expect(antseedPayAmount(bad)).toBeNull();
|
|
68
|
+
}
|
|
69
|
+
expect(antseedPayLinkAmount('')).toBe(ANTSEED_PAY_DEFAULT_AMOUNT);
|
|
70
|
+
expect(antseedPayLinkAmount('25')).toBe('25');
|
|
71
|
+
expect(antseedPayLinkAmount('0.5')).toBe(ANTSEED_PAY_DEFAULT_AMOUNT);
|
|
72
|
+
});
|
|
73
|
+
// Regression: the desktop's Add Credits chooser opens the page with no
|
|
74
|
+
// amount entered, and the page refuses a link without one. Every link the
|
|
75
|
+
// signer builds — with or without a user amount — must pass the page's
|
|
76
|
+
// own check.
|
|
77
|
+
it('builds links the deployed pay page accepts, with and without a user amount', async () => {
|
|
78
|
+
for (const [input, expected] of [['', ANTSEED_PAY_DEFAULT_AMOUNT], ['5', '5'], ['10.50', '10.5'], ['200', '200']]) {
|
|
79
|
+
const link = await buildAntseedPayLink({
|
|
80
|
+
baseUrl: DEFAULT_ANTSEED_PAY_URL,
|
|
81
|
+
wallet: WALLET,
|
|
82
|
+
amount: antseedPayLinkAmount(input),
|
|
83
|
+
integration: 'crossmint',
|
|
84
|
+
});
|
|
85
|
+
expect(payPageParseLink(link)).toEqual({ address: WALLET.address, amount: expected });
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
it('is rejected by the pay page when the signed header or address casing drifts', async () => {
|
|
89
|
+
const good = antseedPayMessage(WALLET.address, '20');
|
|
90
|
+
const link = (sig) => `${DEFAULT_ANTSEED_PAY_URL}?address=${WALLET.address}&cur=USD&amount=20&sig=${sig}`;
|
|
91
|
+
expect(payPageParseLink(link(await WALLET.signMessage(good)))).toEqual({ address: WALLET.address, amount: '20' });
|
|
92
|
+
// The copy rename that broke the link once (CHANGELOG: "Antseed Pay").
|
|
93
|
+
const renamed = await WALLET.signMessage(good.replace('AntSeed Pay', 'Antseed Pay'));
|
|
94
|
+
expect(() => payPageParseLink(link(renamed))).toThrow('signature does not match the address');
|
|
95
|
+
const checksummed = await WALLET.signMessage(good.replace(WALLET.address.toLowerCase(), WALLET.address));
|
|
96
|
+
expect(() => payPageParseLink(link(checksummed))).toThrow('signature does not match the address');
|
|
97
|
+
// And a link with no amount at all is refused before the signature is read.
|
|
98
|
+
const unsigned = `${DEFAULT_ANTSEED_PAY_URL}?address=${WALLET.address}&cur=USD&sig=${await WALLET.signMessage(antseedPayMessage(WALLET.address, ''))}`;
|
|
99
|
+
expect(() => payPageParseLink(unsigned)).toThrow('invalid amount format');
|
|
30
100
|
});
|
|
31
101
|
it('allows loopback http and refuses other plain http or bad URLs', () => {
|
|
32
102
|
expect(() => resolveCardProviderUrl('http://localhost:3120/', '0xabc', '1')).not.toThrow();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card-link.test.js","sourceRoot":"","sources":["../src/card-link.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"card-link.test.js","sourceRoot":"","sources":["../src/card-link.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC3D,OAAO,EACL,0BAA0B,EAC1B,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,uBAAuB,EACvB,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,gBAAgB,CAAC;AAExB,oBAAoB;AACpB,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,EAAE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C,iBAAiB,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC;QACvJ,MAAM,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+DAA+D,EAAE,GAAG,EAAE;QACvE,MAAM,CAAC,GAAG,EAAE,CAAC,sBAAsB,CAAC,wBAAwB,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QAC3F,MAAM,CAAC,GAAG,EAAE,CAAC,sBAAsB,CAAC,0BAA0B,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,iCAAiC,CAAC,CAAC;QAC1H,MAAM,CAAC,GAAG,EAAE,CAAC,sBAAsB,CAAC,WAAW,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,8BAA8B,CAAC,CAAC;IAC1G,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antseed/payments",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.70",
|
|
4
4
|
"description": "Buyer payments portal for AntSeed",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"@fastify/cors": "^10.0.0",
|
|
16
16
|
"@fastify/static": "^9.0.0",
|
|
17
17
|
"fastify": "^5.7.4",
|
|
18
|
-
"@antseed/node": "0.2.
|
|
18
|
+
"@antseed/node": "0.2.143"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@metamask/sdk": "^0.34.0",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"vite": "^6.0.0",
|
|
36
36
|
"vitest": "^2.1.9",
|
|
37
37
|
"wagmi": "^2.14.0",
|
|
38
|
-
"@antseed/
|
|
39
|
-
"@antseed/
|
|
38
|
+
"@antseed/wallet-config": "0.0.0",
|
|
39
|
+
"@antseed/ui": "0.0.0"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build": "npm run build:server && npm run build:web",
|