@strimz/shared-config 0.1.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/LICENSE +21 -0
- package/README.md +32 -0
- package/dist/agents.cjs +65 -0
- package/dist/agents.cjs.map +1 -0
- package/dist/agents.d.cts +39 -0
- package/dist/agents.d.ts +39 -0
- package/dist/agents.js +60 -0
- package/dist/agents.js.map +1 -0
- package/dist/api-keys.cjs +37 -0
- package/dist/api-keys.cjs.map +1 -0
- package/dist/api-keys.d.cts +28 -0
- package/dist/api-keys.d.ts +28 -0
- package/dist/api-keys.js +30 -0
- package/dist/api-keys.js.map +1 -0
- package/dist/cctp.cjs +51 -0
- package/dist/cctp.cjs.map +1 -0
- package/dist/cctp.d.cts +38 -0
- package/dist/cctp.d.ts +38 -0
- package/dist/cctp.js +46 -0
- package/dist/cctp.js.map +1 -0
- package/dist/chains.cjs +64 -0
- package/dist/chains.cjs.map +1 -0
- package/dist/chains.d.cts +23 -0
- package/dist/chains.d.ts +23 -0
- package/dist/chains.js +56 -0
- package/dist/chains.js.map +1 -0
- package/dist/index.cjs +403 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +363 -0
- package/dist/index.js.map +1 -0
- package/dist/tiers.cjs +73 -0
- package/dist/tiers.cjs.map +1 -0
- package/dist/tiers.d.cts +34 -0
- package/dist/tiers.d.ts +34 -0
- package/dist/tiers.js +68 -0
- package/dist/tiers.js.map +1 -0
- package/dist/tokens.cjs +107 -0
- package/dist/tokens.cjs.map +1 -0
- package/dist/tokens.d.cts +44 -0
- package/dist/tokens.d.ts +44 -0
- package/dist/tokens.js +99 -0
- package/dist/tokens.js.map +1 -0
- package/dist/webhooks.cjs +73 -0
- package/dist/webhooks.cjs.map +1 -0
- package/dist/webhooks.d.cts +55 -0
- package/dist/webhooks.d.ts +55 -0
- package/dist/webhooks.js +65 -0
- package/dist/webhooks.js.map +1 -0
- package/package.json +96 -0
- package/src/agents.ts +102 -0
- package/src/api-keys.ts +43 -0
- package/src/cctp.ts +68 -0
- package/src/chains.ts +70 -0
- package/src/index.ts +17 -0
- package/src/tiers.ts +89 -0
- package/src/tokens.ts +96 -0
- package/src/webhooks.ts +80 -0
package/dist/tokens.cjs
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var viem = require('viem');
|
|
4
|
+
|
|
5
|
+
// src/chains.ts
|
|
6
|
+
var ARC_TESTNET_CHAIN_ID = 5042002;
|
|
7
|
+
var ARC_MAINNET_CHAIN_ID = 5040001;
|
|
8
|
+
var NATIVE_USDC = {
|
|
9
|
+
name: "USD Coin",
|
|
10
|
+
symbol: "USDC",
|
|
11
|
+
decimals: 6
|
|
12
|
+
};
|
|
13
|
+
viem.defineChain({
|
|
14
|
+
id: ARC_TESTNET_CHAIN_ID,
|
|
15
|
+
name: "Arc Testnet",
|
|
16
|
+
nativeCurrency: NATIVE_USDC,
|
|
17
|
+
rpcUrls: {
|
|
18
|
+
default: { http: ["https://rpc.testnet.arc.network"] },
|
|
19
|
+
public: { http: ["https://rpc.testnet.arc.network"] }
|
|
20
|
+
},
|
|
21
|
+
blockExplorers: {
|
|
22
|
+
default: {
|
|
23
|
+
name: "ArcScan",
|
|
24
|
+
url: "https://testnet.arcscan.app"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
testnet: true
|
|
28
|
+
});
|
|
29
|
+
viem.defineChain({
|
|
30
|
+
id: ARC_MAINNET_CHAIN_ID,
|
|
31
|
+
name: "Arc",
|
|
32
|
+
nativeCurrency: NATIVE_USDC,
|
|
33
|
+
rpcUrls: {
|
|
34
|
+
default: { http: ["https://rpc.arc.network"] },
|
|
35
|
+
public: { http: ["https://rpc.arc.network"] }
|
|
36
|
+
},
|
|
37
|
+
blockExplorers: {
|
|
38
|
+
default: {
|
|
39
|
+
name: "ArcScan",
|
|
40
|
+
url: "https://arcscan.app"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
testnet: false
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// src/tokens.ts
|
|
47
|
+
var PAYMENT_TOKENS = ["USDC", "EURC"];
|
|
48
|
+
var TOKENS = {
|
|
49
|
+
USDC: {
|
|
50
|
+
symbol: "USDC",
|
|
51
|
+
name: "USD Coin",
|
|
52
|
+
decimals: 6,
|
|
53
|
+
paymentEligible: true,
|
|
54
|
+
yieldBearing: false
|
|
55
|
+
},
|
|
56
|
+
EURC: {
|
|
57
|
+
symbol: "EURC",
|
|
58
|
+
name: "Euro Coin",
|
|
59
|
+
decimals: 6,
|
|
60
|
+
paymentEligible: true,
|
|
61
|
+
yieldBearing: false
|
|
62
|
+
},
|
|
63
|
+
USYC: {
|
|
64
|
+
symbol: "USYC",
|
|
65
|
+
name: "US Yield Coin",
|
|
66
|
+
decimals: 6,
|
|
67
|
+
paymentEligible: false,
|
|
68
|
+
yieldBearing: true
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
var TOKEN_ADDRESSES = {
|
|
72
|
+
testnet: {
|
|
73
|
+
USDC: "0x3600000000000000000000000000000000000000",
|
|
74
|
+
EURC: "0x89B50855Aa3bE2F677cD6303Cec089B5F319D72a",
|
|
75
|
+
USYC: "0xe9185F0c5F296Ed1797AaE4238D26CCaBEadb86C"
|
|
76
|
+
},
|
|
77
|
+
mainnet: {
|
|
78
|
+
// Mainnet addresses pending Arc mainnet beta launch; placeholders mirror
|
|
79
|
+
// testnet for now and must be replaced when Circle publishes the canonical
|
|
80
|
+
// mainnet token registry.
|
|
81
|
+
USDC: "0x3600000000000000000000000000000000000000",
|
|
82
|
+
EURC: "0x89B50855Aa3bE2F677cD6303Cec089B5F319D72a",
|
|
83
|
+
USYC: "0xe9185F0c5F296Ed1797AaE4238D26CCaBEadb86C"
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
function getTokenAddress(env, symbol) {
|
|
87
|
+
return TOKEN_ADDRESSES[env][symbol];
|
|
88
|
+
}
|
|
89
|
+
function getTokenBySymbol(symbol) {
|
|
90
|
+
return TOKENS[symbol];
|
|
91
|
+
}
|
|
92
|
+
function isPaymentToken(symbol) {
|
|
93
|
+
return PAYMENT_TOKENS.includes(symbol);
|
|
94
|
+
}
|
|
95
|
+
function chainIdFor(env) {
|
|
96
|
+
return env === "testnet" ? ARC_TESTNET_CHAIN_ID : ARC_MAINNET_CHAIN_ID;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
exports.PAYMENT_TOKENS = PAYMENT_TOKENS;
|
|
100
|
+
exports.TOKENS = TOKENS;
|
|
101
|
+
exports.TOKEN_ADDRESSES = TOKEN_ADDRESSES;
|
|
102
|
+
exports.chainIdFor = chainIdFor;
|
|
103
|
+
exports.getTokenAddress = getTokenAddress;
|
|
104
|
+
exports.getTokenBySymbol = getTokenBySymbol;
|
|
105
|
+
exports.isPaymentToken = isPaymentToken;
|
|
106
|
+
//# sourceMappingURL=tokens.cjs.map
|
|
107
|
+
//# sourceMappingURL=tokens.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/chains.ts","../src/tokens.ts"],"names":["defineChain"],"mappings":";;;;;AAaO,IAAM,oBAAA,GAAuB,OAAA;AAC7B,IAAM,oBAAA,GAAuB,OAAA;AAEpC,IAAM,WAAA,GAAc;AAAA,EAClB,IAAA,EAAM,UAAA;AAAA,EACN,MAAA,EAAQ,MAAA;AAAA,EACR,QAAA,EAAU;AACZ,CAAA;AAEiCA,gBAAA,CAAY;AAAA,EAC3C,EAAA,EAAI,oBAAA;AAAA,EACJ,IAAA,EAAM,aAAA;AAAA,EACN,cAAA,EAAgB,WAAA;AAAA,EAChB,OAAA,EAAS;AAAA,IACP,OAAA,EAAS,EAAE,IAAA,EAAM,CAAC,iCAAiC,CAAA,EAAE;AAAA,IACrD,MAAA,EAAQ,EAAE,IAAA,EAAM,CAAC,iCAAiC,CAAA;AAAE,GACtD;A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F,OAAA,EAAS;AAAA,IACP,IAAA,EAAM,4CAAA;AAAA,IACN,IAAA,EAAM,4CAAA;AAAA,IACN,IAAA,EAAM;AAAA,GACR;AAAA,EACA,OAAA,EAAS;AAAA;AAAA;AAAA;AAAA,IAIP,IAAA,EAAM,4CAAA;AAAA,IACN,IAAA,EAAM,4CAAA;AAAA,IACN,IAAA,EAAM;AAAA;AAEV;AAEO,SAAS,eAAA,CAAgB,KAAqB,MAAA,EAA8B;AACjF,EAAA,OAAO,eAAA,CAAgB,GAAG,CAAA,CAAE,MAAM,CAAA;AACpC;AAEO,SAAS,iBAAiB,MAAA,EAA6C;AAC5E,EAAA,OAAQ,OAA2C,MAAM,CAAA;AAC3D;AAEO,SAAS,eAAe,MAAA,EAAwC;AACrE,EAAA,OAAO,cAAA,CAAe,SAAS,MAAsB,CAAA;AACvD;AAEO,SAAS,WAAW,GAAA,EAA6B;AACtD,EAAA,OAAO,GAAA,KAAQ,YAAY,oBAAA,GAAuB,oBAAA;AACpD","file":"tokens.cjs","sourcesContent":["/**\n * Arc blockchain definitions.\n *\n * Arc is Circle's stablecoin-native L1 where gas is paid in USDC.\n * - Testnet is live (chain id 5042002).\n * - Mainnet beta is expected in 2026; the mainnet entry is a placeholder\n * until Circle publishes the production chain id and RPC endpoint.\n *\n * @see https://docs.arc.network\n */\n\nimport { defineChain, type Chain } from 'viem'\n\nexport const ARC_TESTNET_CHAIN_ID = 5042002 as const\nexport const ARC_MAINNET_CHAIN_ID = 5040001 as const\n\nconst NATIVE_USDC = {\n name: 'USD Coin',\n symbol: 'USDC',\n decimals: 6,\n} as const\n\nexport const arcTestnet: Chain = defineChain({\n id: ARC_TESTNET_CHAIN_ID,\n name: 'Arc Testnet',\n nativeCurrency: NATIVE_USDC,\n rpcUrls: {\n default: { http: ['https://rpc.testnet.arc.network'] },\n public: { http: ['https://rpc.testnet.arc.network'] },\n },\n blockExplorers: {\n default: {\n name: 'ArcScan',\n url: 'https://testnet.arcscan.app',\n },\n },\n testnet: true,\n})\n\nexport const arcMainnet: Chain = defineChain({\n id: ARC_MAINNET_CHAIN_ID,\n name: 'Arc',\n nativeCurrency: NATIVE_USDC,\n rpcUrls: {\n default: { http: ['https://rpc.arc.network'] },\n public: { http: ['https://rpc.arc.network'] },\n },\n blockExplorers: {\n default: {\n name: 'ArcScan',\n url: 'https://arcscan.app',\n },\n },\n testnet: false,\n})\n\nexport type ArcEnvironment = 'testnet' | 'mainnet'\n\nexport const ARC_CHAINS: Record<ArcEnvironment, Chain> = {\n testnet: arcTestnet,\n mainnet: arcMainnet,\n}\n\nexport function getArcChain(env: ArcEnvironment): Chain {\n return ARC_CHAINS[env]\n}\n\nexport function isArcChain(chainId: number): boolean {\n return chainId === ARC_TESTNET_CHAIN_ID || chainId === ARC_MAINNET_CHAIN_ID\n}\n","/**\n * Token registry for Arc.\n *\n * USDC and EURC are first-class payment tokens — they can be requested in a\n * payment session and used as a subscription currency.\n *\n * USYC is yield-bearing and is treated as a treasury asset only — merchants\n * can hold and earn yield, but a payer cannot pay in USYC.\n */\n\nimport type { Address } from 'viem'\nimport { ARC_TESTNET_CHAIN_ID, ARC_MAINNET_CHAIN_ID, type ArcEnvironment } from './chains.js'\n\nexport type TokenSymbol = 'USDC' | 'EURC' | 'USYC'\n\n/** Tokens accepted as direct payment by Strimz. USYC is excluded by design. */\nexport type PaymentToken = Extract<TokenSymbol, 'USDC' | 'EURC'>\n\nexport const PAYMENT_TOKENS: readonly PaymentToken[] = ['USDC', 'EURC'] as const\n\nexport interface TokenDescriptor {\n symbol: TokenSymbol\n name: string\n decimals: number\n /** Whether the token is accepted as direct payment. */\n paymentEligible: boolean\n /** Whether the token is yield-bearing. */\n yieldBearing: boolean\n}\n\nexport interface TokenAddress {\n symbol: TokenSymbol\n address: Address\n chainId: number\n}\n\nexport const TOKENS: Record<TokenSymbol, TokenDescriptor> = {\n USDC: {\n symbol: 'USDC',\n name: 'USD Coin',\n decimals: 6,\n paymentEligible: true,\n yieldBearing: false,\n },\n EURC: {\n symbol: 'EURC',\n name: 'Euro Coin',\n decimals: 6,\n paymentEligible: true,\n yieldBearing: false,\n },\n USYC: {\n symbol: 'USYC',\n name: 'US Yield Coin',\n decimals: 6,\n paymentEligible: false,\n yieldBearing: true,\n },\n}\n\n/**\n * Native, Circle-issued addresses on Arc.\n * The same address is reused across testnet and mainnet for native tokens\n * since Arc preserves canonical addresses across environments where possible.\n */\nexport const TOKEN_ADDRESSES: Record<ArcEnvironment, Record<TokenSymbol, Address>> = {\n testnet: {\n USDC: '0x3600000000000000000000000000000000000000',\n EURC: '0x89B50855Aa3bE2F677cD6303Cec089B5F319D72a',\n USYC: '0xe9185F0c5F296Ed1797AaE4238D26CCaBEadb86C',\n },\n mainnet: {\n // Mainnet addresses pending Arc mainnet beta launch; placeholders mirror\n // testnet for now and must be replaced when Circle publishes the canonical\n // mainnet token registry.\n USDC: '0x3600000000000000000000000000000000000000',\n EURC: '0x89B50855Aa3bE2F677cD6303Cec089B5F319D72a',\n USYC: '0xe9185F0c5F296Ed1797AaE4238D26CCaBEadb86C',\n },\n}\n\nexport function getTokenAddress(env: ArcEnvironment, symbol: TokenSymbol): Address {\n return TOKEN_ADDRESSES[env][symbol]\n}\n\nexport function getTokenBySymbol(symbol: string): TokenDescriptor | undefined {\n return (TOKENS as Record<string, TokenDescriptor>)[symbol]\n}\n\nexport function isPaymentToken(symbol: string): symbol is PaymentToken {\n return PAYMENT_TOKENS.includes(symbol as PaymentToken)\n}\n\nexport function chainIdFor(env: ArcEnvironment): number {\n return env === 'testnet' ? ARC_TESTNET_CHAIN_ID : ARC_MAINNET_CHAIN_ID\n}\n"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Address } from 'viem';
|
|
2
|
+
import { ArcEnvironment } from './chains.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Token registry for Arc.
|
|
6
|
+
*
|
|
7
|
+
* USDC and EURC are first-class payment tokens — they can be requested in a
|
|
8
|
+
* payment session and used as a subscription currency.
|
|
9
|
+
*
|
|
10
|
+
* USYC is yield-bearing and is treated as a treasury asset only — merchants
|
|
11
|
+
* can hold and earn yield, but a payer cannot pay in USYC.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
type TokenSymbol = 'USDC' | 'EURC' | 'USYC';
|
|
15
|
+
/** Tokens accepted as direct payment by Strimz. USYC is excluded by design. */
|
|
16
|
+
type PaymentToken = Extract<TokenSymbol, 'USDC' | 'EURC'>;
|
|
17
|
+
declare const PAYMENT_TOKENS: readonly PaymentToken[];
|
|
18
|
+
interface TokenDescriptor {
|
|
19
|
+
symbol: TokenSymbol;
|
|
20
|
+
name: string;
|
|
21
|
+
decimals: number;
|
|
22
|
+
/** Whether the token is accepted as direct payment. */
|
|
23
|
+
paymentEligible: boolean;
|
|
24
|
+
/** Whether the token is yield-bearing. */
|
|
25
|
+
yieldBearing: boolean;
|
|
26
|
+
}
|
|
27
|
+
interface TokenAddress {
|
|
28
|
+
symbol: TokenSymbol;
|
|
29
|
+
address: Address;
|
|
30
|
+
chainId: number;
|
|
31
|
+
}
|
|
32
|
+
declare const TOKENS: Record<TokenSymbol, TokenDescriptor>;
|
|
33
|
+
/**
|
|
34
|
+
* Native, Circle-issued addresses on Arc.
|
|
35
|
+
* The same address is reused across testnet and mainnet for native tokens
|
|
36
|
+
* since Arc preserves canonical addresses across environments where possible.
|
|
37
|
+
*/
|
|
38
|
+
declare const TOKEN_ADDRESSES: Record<ArcEnvironment, Record<TokenSymbol, Address>>;
|
|
39
|
+
declare function getTokenAddress(env: ArcEnvironment, symbol: TokenSymbol): Address;
|
|
40
|
+
declare function getTokenBySymbol(symbol: string): TokenDescriptor | undefined;
|
|
41
|
+
declare function isPaymentToken(symbol: string): symbol is PaymentToken;
|
|
42
|
+
declare function chainIdFor(env: ArcEnvironment): number;
|
|
43
|
+
|
|
44
|
+
export { PAYMENT_TOKENS, type PaymentToken, TOKENS, TOKEN_ADDRESSES, type TokenAddress, type TokenDescriptor, type TokenSymbol, chainIdFor, getTokenAddress, getTokenBySymbol, isPaymentToken };
|
package/dist/tokens.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Address } from 'viem';
|
|
2
|
+
import { ArcEnvironment } from './chains.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Token registry for Arc.
|
|
6
|
+
*
|
|
7
|
+
* USDC and EURC are first-class payment tokens — they can be requested in a
|
|
8
|
+
* payment session and used as a subscription currency.
|
|
9
|
+
*
|
|
10
|
+
* USYC is yield-bearing and is treated as a treasury asset only — merchants
|
|
11
|
+
* can hold and earn yield, but a payer cannot pay in USYC.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
type TokenSymbol = 'USDC' | 'EURC' | 'USYC';
|
|
15
|
+
/** Tokens accepted as direct payment by Strimz. USYC is excluded by design. */
|
|
16
|
+
type PaymentToken = Extract<TokenSymbol, 'USDC' | 'EURC'>;
|
|
17
|
+
declare const PAYMENT_TOKENS: readonly PaymentToken[];
|
|
18
|
+
interface TokenDescriptor {
|
|
19
|
+
symbol: TokenSymbol;
|
|
20
|
+
name: string;
|
|
21
|
+
decimals: number;
|
|
22
|
+
/** Whether the token is accepted as direct payment. */
|
|
23
|
+
paymentEligible: boolean;
|
|
24
|
+
/** Whether the token is yield-bearing. */
|
|
25
|
+
yieldBearing: boolean;
|
|
26
|
+
}
|
|
27
|
+
interface TokenAddress {
|
|
28
|
+
symbol: TokenSymbol;
|
|
29
|
+
address: Address;
|
|
30
|
+
chainId: number;
|
|
31
|
+
}
|
|
32
|
+
declare const TOKENS: Record<TokenSymbol, TokenDescriptor>;
|
|
33
|
+
/**
|
|
34
|
+
* Native, Circle-issued addresses on Arc.
|
|
35
|
+
* The same address is reused across testnet and mainnet for native tokens
|
|
36
|
+
* since Arc preserves canonical addresses across environments where possible.
|
|
37
|
+
*/
|
|
38
|
+
declare const TOKEN_ADDRESSES: Record<ArcEnvironment, Record<TokenSymbol, Address>>;
|
|
39
|
+
declare function getTokenAddress(env: ArcEnvironment, symbol: TokenSymbol): Address;
|
|
40
|
+
declare function getTokenBySymbol(symbol: string): TokenDescriptor | undefined;
|
|
41
|
+
declare function isPaymentToken(symbol: string): symbol is PaymentToken;
|
|
42
|
+
declare function chainIdFor(env: ArcEnvironment): number;
|
|
43
|
+
|
|
44
|
+
export { PAYMENT_TOKENS, type PaymentToken, TOKENS, TOKEN_ADDRESSES, type TokenAddress, type TokenDescriptor, type TokenSymbol, chainIdFor, getTokenAddress, getTokenBySymbol, isPaymentToken };
|
package/dist/tokens.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { defineChain } from 'viem';
|
|
2
|
+
|
|
3
|
+
// src/chains.ts
|
|
4
|
+
var ARC_TESTNET_CHAIN_ID = 5042002;
|
|
5
|
+
var ARC_MAINNET_CHAIN_ID = 5040001;
|
|
6
|
+
var NATIVE_USDC = {
|
|
7
|
+
name: "USD Coin",
|
|
8
|
+
symbol: "USDC",
|
|
9
|
+
decimals: 6
|
|
10
|
+
};
|
|
11
|
+
defineChain({
|
|
12
|
+
id: ARC_TESTNET_CHAIN_ID,
|
|
13
|
+
name: "Arc Testnet",
|
|
14
|
+
nativeCurrency: NATIVE_USDC,
|
|
15
|
+
rpcUrls: {
|
|
16
|
+
default: { http: ["https://rpc.testnet.arc.network"] },
|
|
17
|
+
public: { http: ["https://rpc.testnet.arc.network"] }
|
|
18
|
+
},
|
|
19
|
+
blockExplorers: {
|
|
20
|
+
default: {
|
|
21
|
+
name: "ArcScan",
|
|
22
|
+
url: "https://testnet.arcscan.app"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
testnet: true
|
|
26
|
+
});
|
|
27
|
+
defineChain({
|
|
28
|
+
id: ARC_MAINNET_CHAIN_ID,
|
|
29
|
+
name: "Arc",
|
|
30
|
+
nativeCurrency: NATIVE_USDC,
|
|
31
|
+
rpcUrls: {
|
|
32
|
+
default: { http: ["https://rpc.arc.network"] },
|
|
33
|
+
public: { http: ["https://rpc.arc.network"] }
|
|
34
|
+
},
|
|
35
|
+
blockExplorers: {
|
|
36
|
+
default: {
|
|
37
|
+
name: "ArcScan",
|
|
38
|
+
url: "https://arcscan.app"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
testnet: false
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// src/tokens.ts
|
|
45
|
+
var PAYMENT_TOKENS = ["USDC", "EURC"];
|
|
46
|
+
var TOKENS = {
|
|
47
|
+
USDC: {
|
|
48
|
+
symbol: "USDC",
|
|
49
|
+
name: "USD Coin",
|
|
50
|
+
decimals: 6,
|
|
51
|
+
paymentEligible: true,
|
|
52
|
+
yieldBearing: false
|
|
53
|
+
},
|
|
54
|
+
EURC: {
|
|
55
|
+
symbol: "EURC",
|
|
56
|
+
name: "Euro Coin",
|
|
57
|
+
decimals: 6,
|
|
58
|
+
paymentEligible: true,
|
|
59
|
+
yieldBearing: false
|
|
60
|
+
},
|
|
61
|
+
USYC: {
|
|
62
|
+
symbol: "USYC",
|
|
63
|
+
name: "US Yield Coin",
|
|
64
|
+
decimals: 6,
|
|
65
|
+
paymentEligible: false,
|
|
66
|
+
yieldBearing: true
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
var TOKEN_ADDRESSES = {
|
|
70
|
+
testnet: {
|
|
71
|
+
USDC: "0x3600000000000000000000000000000000000000",
|
|
72
|
+
EURC: "0x89B50855Aa3bE2F677cD6303Cec089B5F319D72a",
|
|
73
|
+
USYC: "0xe9185F0c5F296Ed1797AaE4238D26CCaBEadb86C"
|
|
74
|
+
},
|
|
75
|
+
mainnet: {
|
|
76
|
+
// Mainnet addresses pending Arc mainnet beta launch; placeholders mirror
|
|
77
|
+
// testnet for now and must be replaced when Circle publishes the canonical
|
|
78
|
+
// mainnet token registry.
|
|
79
|
+
USDC: "0x3600000000000000000000000000000000000000",
|
|
80
|
+
EURC: "0x89B50855Aa3bE2F677cD6303Cec089B5F319D72a",
|
|
81
|
+
USYC: "0xe9185F0c5F296Ed1797AaE4238D26CCaBEadb86C"
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
function getTokenAddress(env, symbol) {
|
|
85
|
+
return TOKEN_ADDRESSES[env][symbol];
|
|
86
|
+
}
|
|
87
|
+
function getTokenBySymbol(symbol) {
|
|
88
|
+
return TOKENS[symbol];
|
|
89
|
+
}
|
|
90
|
+
function isPaymentToken(symbol) {
|
|
91
|
+
return PAYMENT_TOKENS.includes(symbol);
|
|
92
|
+
}
|
|
93
|
+
function chainIdFor(env) {
|
|
94
|
+
return env === "testnet" ? ARC_TESTNET_CHAIN_ID : ARC_MAINNET_CHAIN_ID;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export { PAYMENT_TOKENS, TOKENS, TOKEN_ADDRESSES, chainIdFor, getTokenAddress, getTokenBySymbol, isPaymentToken };
|
|
98
|
+
//# sourceMappingURL=tokens.js.map
|
|
99
|
+
//# sourceMappingURL=tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/chains.ts","../src/tokens.ts"],"names":[],"mappings":";;;AAaO,IAAM,oBAAA,GAAuB,OAAA;AAC7B,IAAM,oBAAA,GAAuB,OAAA;AAEpC,IAAM,WAAA,GAAc;AAAA,EAClB,IAAA,EAAM,UAAA;AAAA,EACN,MAAA,EAAQ,MAAA;AAAA,EACR,QAAA,EAAU;AACZ,CAAA;AAEiC,WAAA,CAAY;AAAA,EAC3C,EAAA,EAAI,oBAAA;AAAA,EACJ,IAAA,EAAM,aAAA;AAAA,EACN,cAAA,EAAgB,WAAA;AAAA,EAChB,OAAA,EAAS;AAAA,IACP,OAAA,EAAS,EAAE,IAAA,EAAM,CAAC,iCAAiC,CAAA,EAAE;AAAA,IACrD,MAAA,EAAQ,EAAE,IAAA,EAAM,CAAC,iCAAiC,CAAA;AAAE,GACtD;AAAA,EACA,cAAA,EAAgB;AAAA,IACd,OAAA,EAAS;AAAA,MACP,IAAA,EAAM,SAAA;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AA,IACN,IAAA,EAAM;AAAA,GACR;AAAA,EACA,OAAA,EAAS;AAAA;AAAA;AAAA;AAAA,IAIP,IAAA,EAAM,4CAAA;AAAA,IACN,IAAA,EAAM,4CAAA;AAAA,IACN,IAAA,EAAM;AAAA;AAEV;AAEO,SAAS,eAAA,CAAgB,KAAqB,MAAA,EAA8B;AACjF,EAAA,OAAO,eAAA,CAAgB,GAAG,CAAA,CAAE,MAAM,CAAA;AACpC;AAEO,SAAS,iBAAiB,MAAA,EAA6C;AAC5E,EAAA,OAAQ,OAA2C,MAAM,CAAA;AAC3D;AAEO,SAAS,eAAe,MAAA,EAAwC;AACrE,EAAA,OAAO,cAAA,CAAe,SAAS,MAAsB,CAAA;AACvD;AAEO,SAAS,WAAW,GAAA,EAA6B;AACtD,EAAA,OAAO,GAAA,KAAQ,YAAY,oBAAA,GAAuB,oBAAA;AACpD","file":"tokens.js","sourcesContent":["/**\n * Arc blockchain definitions.\n *\n * Arc is Circle's stablecoin-native L1 where gas is paid in USDC.\n * - Testnet is live (chain id 5042002).\n * - Mainnet beta is expected in 2026; the mainnet entry is a placeholder\n * until Circle publishes the production chain id and RPC endpoint.\n *\n * @see https://docs.arc.network\n */\n\nimport { defineChain, type Chain } from 'viem'\n\nexport const ARC_TESTNET_CHAIN_ID = 5042002 as const\nexport const ARC_MAINNET_CHAIN_ID = 5040001 as const\n\nconst NATIVE_USDC = {\n name: 'USD Coin',\n symbol: 'USDC',\n decimals: 6,\n} as const\n\nexport const arcTestnet: Chain = defineChain({\n id: ARC_TESTNET_CHAIN_ID,\n name: 'Arc Testnet',\n nativeCurrency: NATIVE_USDC,\n rpcUrls: {\n default: { http: ['https://rpc.testnet.arc.network'] },\n public: { http: ['https://rpc.testnet.arc.network'] },\n },\n blockExplorers: {\n default: {\n name: 'ArcScan',\n url: 'https://testnet.arcscan.app',\n },\n },\n testnet: true,\n})\n\nexport const arcMainnet: Chain = defineChain({\n id: ARC_MAINNET_CHAIN_ID,\n name: 'Arc',\n nativeCurrency: NATIVE_USDC,\n rpcUrls: {\n default: { http: ['https://rpc.arc.network'] },\n public: { http: ['https://rpc.arc.network'] },\n },\n blockExplorers: {\n default: {\n name: 'ArcScan',\n url: 'https://arcscan.app',\n },\n },\n testnet: false,\n})\n\nexport type ArcEnvironment = 'testnet' | 'mainnet'\n\nexport const ARC_CHAINS: Record<ArcEnvironment, Chain> = {\n testnet: arcTestnet,\n mainnet: arcMainnet,\n}\n\nexport function getArcChain(env: ArcEnvironment): Chain {\n return ARC_CHAINS[env]\n}\n\nexport function isArcChain(chainId: number): boolean {\n return chainId === ARC_TESTNET_CHAIN_ID || chainId === ARC_MAINNET_CHAIN_ID\n}\n","/**\n * Token registry for Arc.\n *\n * USDC and EURC are first-class payment tokens — they can be requested in a\n * payment session and used as a subscription currency.\n *\n * USYC is yield-bearing and is treated as a treasury asset only — merchants\n * can hold and earn yield, but a payer cannot pay in USYC.\n */\n\nimport type { Address } from 'viem'\nimport { ARC_TESTNET_CHAIN_ID, ARC_MAINNET_CHAIN_ID, type ArcEnvironment } from './chains.js'\n\nexport type TokenSymbol = 'USDC' | 'EURC' | 'USYC'\n\n/** Tokens accepted as direct payment by Strimz. USYC is excluded by design. */\nexport type PaymentToken = Extract<TokenSymbol, 'USDC' | 'EURC'>\n\nexport const PAYMENT_TOKENS: readonly PaymentToken[] = ['USDC', 'EURC'] as const\n\nexport interface TokenDescriptor {\n symbol: TokenSymbol\n name: string\n decimals: number\n /** Whether the token is accepted as direct payment. */\n paymentEligible: boolean\n /** Whether the token is yield-bearing. */\n yieldBearing: boolean\n}\n\nexport interface TokenAddress {\n symbol: TokenSymbol\n address: Address\n chainId: number\n}\n\nexport const TOKENS: Record<TokenSymbol, TokenDescriptor> = {\n USDC: {\n symbol: 'USDC',\n name: 'USD Coin',\n decimals: 6,\n paymentEligible: true,\n yieldBearing: false,\n },\n EURC: {\n symbol: 'EURC',\n name: 'Euro Coin',\n decimals: 6,\n paymentEligible: true,\n yieldBearing: false,\n },\n USYC: {\n symbol: 'USYC',\n name: 'US Yield Coin',\n decimals: 6,\n paymentEligible: false,\n yieldBearing: true,\n },\n}\n\n/**\n * Native, Circle-issued addresses on Arc.\n * The same address is reused across testnet and mainnet for native tokens\n * since Arc preserves canonical addresses across environments where possible.\n */\nexport const TOKEN_ADDRESSES: Record<ArcEnvironment, Record<TokenSymbol, Address>> = {\n testnet: {\n USDC: '0x3600000000000000000000000000000000000000',\n EURC: '0x89B50855Aa3bE2F677cD6303Cec089B5F319D72a',\n USYC: '0xe9185F0c5F296Ed1797AaE4238D26CCaBEadb86C',\n },\n mainnet: {\n // Mainnet addresses pending Arc mainnet beta launch; placeholders mirror\n // testnet for now and must be replaced when Circle publishes the canonical\n // mainnet token registry.\n USDC: '0x3600000000000000000000000000000000000000',\n EURC: '0x89B50855Aa3bE2F677cD6303Cec089B5F319D72a',\n USYC: '0xe9185F0c5F296Ed1797AaE4238D26CCaBEadb86C',\n },\n}\n\nexport function getTokenAddress(env: ArcEnvironment, symbol: TokenSymbol): Address {\n return TOKEN_ADDRESSES[env][symbol]\n}\n\nexport function getTokenBySymbol(symbol: string): TokenDescriptor | undefined {\n return (TOKENS as Record<string, TokenDescriptor>)[symbol]\n}\n\nexport function isPaymentToken(symbol: string): symbol is PaymentToken {\n return PAYMENT_TOKENS.includes(symbol as PaymentToken)\n}\n\nexport function chainIdFor(env: ArcEnvironment): number {\n return env === 'testnet' ? ARC_TESTNET_CHAIN_ID : ARC_MAINNET_CHAIN_ID\n}\n"]}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/webhooks.ts
|
|
4
|
+
var WEBHOOK_EVENTS = {
|
|
5
|
+
payment: {
|
|
6
|
+
created: "payment.created",
|
|
7
|
+
completed: "payment.completed",
|
|
8
|
+
failed: "payment.failed"
|
|
9
|
+
},
|
|
10
|
+
subscription: {
|
|
11
|
+
created: "subscription.created",
|
|
12
|
+
charged: "subscription.charged",
|
|
13
|
+
chargeFailed: "subscription.charge_failed",
|
|
14
|
+
recoveryAttempt: "subscription.recovery_attempt",
|
|
15
|
+
recoveryOutcome: "subscription.recovery_outcome",
|
|
16
|
+
cancelled: "subscription.cancelled",
|
|
17
|
+
lapsed: "subscription.lapsed"
|
|
18
|
+
},
|
|
19
|
+
refund: {
|
|
20
|
+
created: "refund.created",
|
|
21
|
+
completed: "refund.completed",
|
|
22
|
+
failed: "refund.failed"
|
|
23
|
+
},
|
|
24
|
+
invoice: {
|
|
25
|
+
created: "invoice.created",
|
|
26
|
+
paid: "invoice.paid",
|
|
27
|
+
overdue: "invoice.overdue"
|
|
28
|
+
},
|
|
29
|
+
agent: {
|
|
30
|
+
actionExecuted: "agent.action_executed",
|
|
31
|
+
jobProposed: "agent.job_proposed",
|
|
32
|
+
jobCompleted: "agent.job_completed",
|
|
33
|
+
jobDisputed: "agent.job_disputed"
|
|
34
|
+
},
|
|
35
|
+
compliance: {
|
|
36
|
+
walletFlagged: "compliance.wallet_flagged",
|
|
37
|
+
walletBlocked: "compliance.wallet_blocked"
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
var ALL_WEBHOOK_EVENTS = [
|
|
41
|
+
...Object.values(WEBHOOK_EVENTS.payment),
|
|
42
|
+
...Object.values(WEBHOOK_EVENTS.subscription),
|
|
43
|
+
...Object.values(WEBHOOK_EVENTS.refund),
|
|
44
|
+
...Object.values(WEBHOOK_EVENTS.invoice),
|
|
45
|
+
...Object.values(WEBHOOK_EVENTS.agent),
|
|
46
|
+
...Object.values(WEBHOOK_EVENTS.compliance)
|
|
47
|
+
];
|
|
48
|
+
var WEBHOOK_RETRY_SCHEDULE_SECONDS = [
|
|
49
|
+
60,
|
|
50
|
+
// 1 minute
|
|
51
|
+
300,
|
|
52
|
+
// 5 minutes
|
|
53
|
+
1800,
|
|
54
|
+
// 30 minutes
|
|
55
|
+
7200,
|
|
56
|
+
// 2 hours
|
|
57
|
+
86400
|
|
58
|
+
// 24 hours
|
|
59
|
+
];
|
|
60
|
+
var WEBHOOK_MAX_ATTEMPTS = WEBHOOK_RETRY_SCHEDULE_SECONDS.length + 1;
|
|
61
|
+
var WEBHOOK_SIGNATURE_TOLERANCE_SECONDS = 300;
|
|
62
|
+
var WEBHOOK_SIGNATURE_HEADER = "strimz-signature";
|
|
63
|
+
var WEBHOOK_DELIVERY_ID_HEADER = "strimz-delivery-id";
|
|
64
|
+
|
|
65
|
+
exports.ALL_WEBHOOK_EVENTS = ALL_WEBHOOK_EVENTS;
|
|
66
|
+
exports.WEBHOOK_DELIVERY_ID_HEADER = WEBHOOK_DELIVERY_ID_HEADER;
|
|
67
|
+
exports.WEBHOOK_EVENTS = WEBHOOK_EVENTS;
|
|
68
|
+
exports.WEBHOOK_MAX_ATTEMPTS = WEBHOOK_MAX_ATTEMPTS;
|
|
69
|
+
exports.WEBHOOK_RETRY_SCHEDULE_SECONDS = WEBHOOK_RETRY_SCHEDULE_SECONDS;
|
|
70
|
+
exports.WEBHOOK_SIGNATURE_HEADER = WEBHOOK_SIGNATURE_HEADER;
|
|
71
|
+
exports.WEBHOOK_SIGNATURE_TOLERANCE_SECONDS = WEBHOOK_SIGNATURE_TOLERANCE_SECONDS;
|
|
72
|
+
//# sourceMappingURL=webhooks.cjs.map
|
|
73
|
+
//# sourceMappingURL=webhooks.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/webhooks.ts"],"names":[],"mappings":";;;AAOO,IAAM,cAAA,GAAiB;AAAA,EAC5B,OAAA,EAAS;AAAA,IACP,OAAA,EAAS,iBAAA;AAAA,IACT,SAAA,EAAW,mBAAA;AAAA,IACX,MAAA,EAAQ;AAAA,GACV;AAAA,EACA,YAAA,EAAc;AAAA,IACZ,OAAA,EAAS,sBAAA;AAAA,IACT,OAAA,EAAS,sBAAA;AAAA,IACT,YAAA,EAAc,4BAAA;AAAA,IACd,eAAA,EAAiB,+BAAA;AAAA,IACjB,eAAA,EAAiB,+BAAA;AAAA,IACjB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hooks.cjs","sourcesContent":["/**\n * Webhook event names.\n *\n * Wire format is `<resource>.<action>`. Every event payload is versioned at\n * the envelope level so additive changes do not break consumers.\n */\n\nexport const WEBHOOK_EVENTS = {\n payment: {\n created: 'payment.created',\n completed: 'payment.completed',\n failed: 'payment.failed',\n },\n subscription: {\n created: 'subscription.created',\n charged: 'subscription.charged',\n chargeFailed: 'subscription.charge_failed',\n recoveryAttempt: 'subscription.recovery_attempt',\n recoveryOutcome: 'subscription.recovery_outcome',\n cancelled: 'subscription.cancelled',\n lapsed: 'subscription.lapsed',\n },\n refund: {\n created: 'refund.created',\n completed: 'refund.completed',\n failed: 'refund.failed',\n },\n invoice: {\n created: 'invoice.created',\n paid: 'invoice.paid',\n overdue: 'invoice.overdue',\n },\n agent: {\n actionExecuted: 'agent.action_executed',\n jobProposed: 'agent.job_proposed',\n jobCompleted: 'agent.job_completed',\n jobDisputed: 'agent.job_disputed',\n },\n compliance: {\n walletFlagged: 'compliance.wallet_flagged',\n walletBlocked: 'compliance.wallet_blocked',\n },\n} as const\n\nexport type WebhookEventName =\n | (typeof WEBHOOK_EVENTS.payment)[keyof typeof WEBHOOK_EVENTS.payment]\n | (typeof WEBHOOK_EVENTS.subscription)[keyof typeof WEBHOOK_EVENTS.subscription]\n | (typeof WEBHOOK_EVENTS.refund)[keyof typeof WEBHOOK_EVENTS.refund]\n | (typeof WEBHOOK_EVENTS.invoice)[keyof typeof WEBHOOK_EVENTS.invoice]\n | (typeof WEBHOOK_EVENTS.agent)[keyof typeof WEBHOOK_EVENTS.agent]\n | (typeof WEBHOOK_EVENTS.compliance)[keyof typeof WEBHOOK_EVENTS.compliance]\n\nexport const ALL_WEBHOOK_EVENTS: readonly WebhookEventName[] = [\n ...Object.values(WEBHOOK_EVENTS.payment),\n ...Object.values(WEBHOOK_EVENTS.subscription),\n ...Object.values(WEBHOOK_EVENTS.refund),\n ...Object.values(WEBHOOK_EVENTS.invoice),\n ...Object.values(WEBHOOK_EVENTS.agent),\n ...Object.values(WEBHOOK_EVENTS.compliance),\n] as const\n\n/** Exponential backoff schedule for webhook delivery, in seconds. */\nexport const WEBHOOK_RETRY_SCHEDULE_SECONDS: readonly number[] = [\n 60, // 1 minute\n 300, // 5 minutes\n 1_800, // 30 minutes\n 7_200, // 2 hours\n 86_400, // 24 hours\n] as const\n\nexport const WEBHOOK_MAX_ATTEMPTS = WEBHOOK_RETRY_SCHEDULE_SECONDS.length + 1\n\n/** Webhook signatures older than this are rejected to prevent replay. */\nexport const WEBHOOK_SIGNATURE_TOLERANCE_SECONDS = 300\n\n/** HTTP header carrying the HMAC signature. */\nexport const WEBHOOK_SIGNATURE_HEADER = 'strimz-signature'\n\n/** HTTP header carrying the unique delivery id (idempotency key for the receiver). */\nexport const WEBHOOK_DELIVERY_ID_HEADER = 'strimz-delivery-id'\n"]}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Webhook event names.
|
|
3
|
+
*
|
|
4
|
+
* Wire format is `<resource>.<action>`. Every event payload is versioned at
|
|
5
|
+
* the envelope level so additive changes do not break consumers.
|
|
6
|
+
*/
|
|
7
|
+
declare const WEBHOOK_EVENTS: {
|
|
8
|
+
readonly payment: {
|
|
9
|
+
readonly created: "payment.created";
|
|
10
|
+
readonly completed: "payment.completed";
|
|
11
|
+
readonly failed: "payment.failed";
|
|
12
|
+
};
|
|
13
|
+
readonly subscription: {
|
|
14
|
+
readonly created: "subscription.created";
|
|
15
|
+
readonly charged: "subscription.charged";
|
|
16
|
+
readonly chargeFailed: "subscription.charge_failed";
|
|
17
|
+
readonly recoveryAttempt: "subscription.recovery_attempt";
|
|
18
|
+
readonly recoveryOutcome: "subscription.recovery_outcome";
|
|
19
|
+
readonly cancelled: "subscription.cancelled";
|
|
20
|
+
readonly lapsed: "subscription.lapsed";
|
|
21
|
+
};
|
|
22
|
+
readonly refund: {
|
|
23
|
+
readonly created: "refund.created";
|
|
24
|
+
readonly completed: "refund.completed";
|
|
25
|
+
readonly failed: "refund.failed";
|
|
26
|
+
};
|
|
27
|
+
readonly invoice: {
|
|
28
|
+
readonly created: "invoice.created";
|
|
29
|
+
readonly paid: "invoice.paid";
|
|
30
|
+
readonly overdue: "invoice.overdue";
|
|
31
|
+
};
|
|
32
|
+
readonly agent: {
|
|
33
|
+
readonly actionExecuted: "agent.action_executed";
|
|
34
|
+
readonly jobProposed: "agent.job_proposed";
|
|
35
|
+
readonly jobCompleted: "agent.job_completed";
|
|
36
|
+
readonly jobDisputed: "agent.job_disputed";
|
|
37
|
+
};
|
|
38
|
+
readonly compliance: {
|
|
39
|
+
readonly walletFlagged: "compliance.wallet_flagged";
|
|
40
|
+
readonly walletBlocked: "compliance.wallet_blocked";
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
type WebhookEventName = (typeof WEBHOOK_EVENTS.payment)[keyof typeof WEBHOOK_EVENTS.payment] | (typeof WEBHOOK_EVENTS.subscription)[keyof typeof WEBHOOK_EVENTS.subscription] | (typeof WEBHOOK_EVENTS.refund)[keyof typeof WEBHOOK_EVENTS.refund] | (typeof WEBHOOK_EVENTS.invoice)[keyof typeof WEBHOOK_EVENTS.invoice] | (typeof WEBHOOK_EVENTS.agent)[keyof typeof WEBHOOK_EVENTS.agent] | (typeof WEBHOOK_EVENTS.compliance)[keyof typeof WEBHOOK_EVENTS.compliance];
|
|
44
|
+
declare const ALL_WEBHOOK_EVENTS: readonly WebhookEventName[];
|
|
45
|
+
/** Exponential backoff schedule for webhook delivery, in seconds. */
|
|
46
|
+
declare const WEBHOOK_RETRY_SCHEDULE_SECONDS: readonly number[];
|
|
47
|
+
declare const WEBHOOK_MAX_ATTEMPTS: number;
|
|
48
|
+
/** Webhook signatures older than this are rejected to prevent replay. */
|
|
49
|
+
declare const WEBHOOK_SIGNATURE_TOLERANCE_SECONDS = 300;
|
|
50
|
+
/** HTTP header carrying the HMAC signature. */
|
|
51
|
+
declare const WEBHOOK_SIGNATURE_HEADER = "strimz-signature";
|
|
52
|
+
/** HTTP header carrying the unique delivery id (idempotency key for the receiver). */
|
|
53
|
+
declare const WEBHOOK_DELIVERY_ID_HEADER = "strimz-delivery-id";
|
|
54
|
+
|
|
55
|
+
export { ALL_WEBHOOK_EVENTS, WEBHOOK_DELIVERY_ID_HEADER, WEBHOOK_EVENTS, WEBHOOK_MAX_ATTEMPTS, WEBHOOK_RETRY_SCHEDULE_SECONDS, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_SIGNATURE_TOLERANCE_SECONDS, type WebhookEventName };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Webhook event names.
|
|
3
|
+
*
|
|
4
|
+
* Wire format is `<resource>.<action>`. Every event payload is versioned at
|
|
5
|
+
* the envelope level so additive changes do not break consumers.
|
|
6
|
+
*/
|
|
7
|
+
declare const WEBHOOK_EVENTS: {
|
|
8
|
+
readonly payment: {
|
|
9
|
+
readonly created: "payment.created";
|
|
10
|
+
readonly completed: "payment.completed";
|
|
11
|
+
readonly failed: "payment.failed";
|
|
12
|
+
};
|
|
13
|
+
readonly subscription: {
|
|
14
|
+
readonly created: "subscription.created";
|
|
15
|
+
readonly charged: "subscription.charged";
|
|
16
|
+
readonly chargeFailed: "subscription.charge_failed";
|
|
17
|
+
readonly recoveryAttempt: "subscription.recovery_attempt";
|
|
18
|
+
readonly recoveryOutcome: "subscription.recovery_outcome";
|
|
19
|
+
readonly cancelled: "subscription.cancelled";
|
|
20
|
+
readonly lapsed: "subscription.lapsed";
|
|
21
|
+
};
|
|
22
|
+
readonly refund: {
|
|
23
|
+
readonly created: "refund.created";
|
|
24
|
+
readonly completed: "refund.completed";
|
|
25
|
+
readonly failed: "refund.failed";
|
|
26
|
+
};
|
|
27
|
+
readonly invoice: {
|
|
28
|
+
readonly created: "invoice.created";
|
|
29
|
+
readonly paid: "invoice.paid";
|
|
30
|
+
readonly overdue: "invoice.overdue";
|
|
31
|
+
};
|
|
32
|
+
readonly agent: {
|
|
33
|
+
readonly actionExecuted: "agent.action_executed";
|
|
34
|
+
readonly jobProposed: "agent.job_proposed";
|
|
35
|
+
readonly jobCompleted: "agent.job_completed";
|
|
36
|
+
readonly jobDisputed: "agent.job_disputed";
|
|
37
|
+
};
|
|
38
|
+
readonly compliance: {
|
|
39
|
+
readonly walletFlagged: "compliance.wallet_flagged";
|
|
40
|
+
readonly walletBlocked: "compliance.wallet_blocked";
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
type WebhookEventName = (typeof WEBHOOK_EVENTS.payment)[keyof typeof WEBHOOK_EVENTS.payment] | (typeof WEBHOOK_EVENTS.subscription)[keyof typeof WEBHOOK_EVENTS.subscription] | (typeof WEBHOOK_EVENTS.refund)[keyof typeof WEBHOOK_EVENTS.refund] | (typeof WEBHOOK_EVENTS.invoice)[keyof typeof WEBHOOK_EVENTS.invoice] | (typeof WEBHOOK_EVENTS.agent)[keyof typeof WEBHOOK_EVENTS.agent] | (typeof WEBHOOK_EVENTS.compliance)[keyof typeof WEBHOOK_EVENTS.compliance];
|
|
44
|
+
declare const ALL_WEBHOOK_EVENTS: readonly WebhookEventName[];
|
|
45
|
+
/** Exponential backoff schedule for webhook delivery, in seconds. */
|
|
46
|
+
declare const WEBHOOK_RETRY_SCHEDULE_SECONDS: readonly number[];
|
|
47
|
+
declare const WEBHOOK_MAX_ATTEMPTS: number;
|
|
48
|
+
/** Webhook signatures older than this are rejected to prevent replay. */
|
|
49
|
+
declare const WEBHOOK_SIGNATURE_TOLERANCE_SECONDS = 300;
|
|
50
|
+
/** HTTP header carrying the HMAC signature. */
|
|
51
|
+
declare const WEBHOOK_SIGNATURE_HEADER = "strimz-signature";
|
|
52
|
+
/** HTTP header carrying the unique delivery id (idempotency key for the receiver). */
|
|
53
|
+
declare const WEBHOOK_DELIVERY_ID_HEADER = "strimz-delivery-id";
|
|
54
|
+
|
|
55
|
+
export { ALL_WEBHOOK_EVENTS, WEBHOOK_DELIVERY_ID_HEADER, WEBHOOK_EVENTS, WEBHOOK_MAX_ATTEMPTS, WEBHOOK_RETRY_SCHEDULE_SECONDS, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_SIGNATURE_TOLERANCE_SECONDS, type WebhookEventName };
|
package/dist/webhooks.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// src/webhooks.ts
|
|
2
|
+
var WEBHOOK_EVENTS = {
|
|
3
|
+
payment: {
|
|
4
|
+
created: "payment.created",
|
|
5
|
+
completed: "payment.completed",
|
|
6
|
+
failed: "payment.failed"
|
|
7
|
+
},
|
|
8
|
+
subscription: {
|
|
9
|
+
created: "subscription.created",
|
|
10
|
+
charged: "subscription.charged",
|
|
11
|
+
chargeFailed: "subscription.charge_failed",
|
|
12
|
+
recoveryAttempt: "subscription.recovery_attempt",
|
|
13
|
+
recoveryOutcome: "subscription.recovery_outcome",
|
|
14
|
+
cancelled: "subscription.cancelled",
|
|
15
|
+
lapsed: "subscription.lapsed"
|
|
16
|
+
},
|
|
17
|
+
refund: {
|
|
18
|
+
created: "refund.created",
|
|
19
|
+
completed: "refund.completed",
|
|
20
|
+
failed: "refund.failed"
|
|
21
|
+
},
|
|
22
|
+
invoice: {
|
|
23
|
+
created: "invoice.created",
|
|
24
|
+
paid: "invoice.paid",
|
|
25
|
+
overdue: "invoice.overdue"
|
|
26
|
+
},
|
|
27
|
+
agent: {
|
|
28
|
+
actionExecuted: "agent.action_executed",
|
|
29
|
+
jobProposed: "agent.job_proposed",
|
|
30
|
+
jobCompleted: "agent.job_completed",
|
|
31
|
+
jobDisputed: "agent.job_disputed"
|
|
32
|
+
},
|
|
33
|
+
compliance: {
|
|
34
|
+
walletFlagged: "compliance.wallet_flagged",
|
|
35
|
+
walletBlocked: "compliance.wallet_blocked"
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var ALL_WEBHOOK_EVENTS = [
|
|
39
|
+
...Object.values(WEBHOOK_EVENTS.payment),
|
|
40
|
+
...Object.values(WEBHOOK_EVENTS.subscription),
|
|
41
|
+
...Object.values(WEBHOOK_EVENTS.refund),
|
|
42
|
+
...Object.values(WEBHOOK_EVENTS.invoice),
|
|
43
|
+
...Object.values(WEBHOOK_EVENTS.agent),
|
|
44
|
+
...Object.values(WEBHOOK_EVENTS.compliance)
|
|
45
|
+
];
|
|
46
|
+
var WEBHOOK_RETRY_SCHEDULE_SECONDS = [
|
|
47
|
+
60,
|
|
48
|
+
// 1 minute
|
|
49
|
+
300,
|
|
50
|
+
// 5 minutes
|
|
51
|
+
1800,
|
|
52
|
+
// 30 minutes
|
|
53
|
+
7200,
|
|
54
|
+
// 2 hours
|
|
55
|
+
86400
|
|
56
|
+
// 24 hours
|
|
57
|
+
];
|
|
58
|
+
var WEBHOOK_MAX_ATTEMPTS = WEBHOOK_RETRY_SCHEDULE_SECONDS.length + 1;
|
|
59
|
+
var WEBHOOK_SIGNATURE_TOLERANCE_SECONDS = 300;
|
|
60
|
+
var WEBHOOK_SIGNATURE_HEADER = "strimz-signature";
|
|
61
|
+
var WEBHOOK_DELIVERY_ID_HEADER = "strimz-delivery-id";
|
|
62
|
+
|
|
63
|
+
export { ALL_WEBHOOK_EVENTS, WEBHOOK_DELIVERY_ID_HEADER, WEBHOOK_EVENTS, WEBHOOK_MAX_ATTEMPTS, WEBHOOK_RETRY_SCHEDULE_SECONDS, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_SIGNATURE_TOLERANCE_SECONDS };
|
|
64
|
+
//# sourceMappingURL=webhooks.js.map
|
|
65
|
+
//# sourceMappingURL=webhooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/webhooks.ts"],"names":[],"mappings":";AAOO,IAAM,cAAA,GAAiB;AAAA,EAC5B,OAAA,EAAS;AAAA,IACP,OAAA,EAAS,iBAAA;AAAA,IACT,SAAA,EAAW,mBAAA;AAAA,IACX,MAAA,EAAQ;AAAA,GACV;AAAA,EACA,YAAA,EAAc;AAAA,IACZ,OAAA,EAAS,sBAAA;AAAA,IACT,OAAA,EAAS,sBAAA;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A+B,MAAA,GAAS;AAGrE,IAAM,mCAAA,GAAsC;AAG5C,IAAM,wBAAA,GAA2B;AAGjC,IAAM,0BAAA,GAA6B","file":"webhooks.js","sourcesContent":["/**\n * Webhook event names.\n *\n * Wire format is `<resource>.<action>`. Every event payload is versioned at\n * the envelope level so additive changes do not break consumers.\n */\n\nexport const WEBHOOK_EVENTS = {\n payment: {\n created: 'payment.created',\n completed: 'payment.completed',\n failed: 'payment.failed',\n },\n subscription: {\n created: 'subscription.created',\n charged: 'subscription.charged',\n chargeFailed: 'subscription.charge_failed',\n recoveryAttempt: 'subscription.recovery_attempt',\n recoveryOutcome: 'subscription.recovery_outcome',\n cancelled: 'subscription.cancelled',\n lapsed: 'subscription.lapsed',\n },\n refund: {\n created: 'refund.created',\n completed: 'refund.completed',\n failed: 'refund.failed',\n },\n invoice: {\n created: 'invoice.created',\n paid: 'invoice.paid',\n overdue: 'invoice.overdue',\n },\n agent: {\n actionExecuted: 'agent.action_executed',\n jobProposed: 'agent.job_proposed',\n jobCompleted: 'agent.job_completed',\n jobDisputed: 'agent.job_disputed',\n },\n compliance: {\n walletFlagged: 'compliance.wallet_flagged',\n walletBlocked: 'compliance.wallet_blocked',\n },\n} as const\n\nexport type WebhookEventName =\n | (typeof WEBHOOK_EVENTS.payment)[keyof typeof WEBHOOK_EVENTS.payment]\n | (typeof WEBHOOK_EVENTS.subscription)[keyof typeof WEBHOOK_EVENTS.subscription]\n | (typeof WEBHOOK_EVENTS.refund)[keyof typeof WEBHOOK_EVENTS.refund]\n | (typeof WEBHOOK_EVENTS.invoice)[keyof typeof WEBHOOK_EVENTS.invoice]\n | (typeof WEBHOOK_EVENTS.agent)[keyof typeof WEBHOOK_EVENTS.agent]\n | (typeof WEBHOOK_EVENTS.compliance)[keyof typeof WEBHOOK_EVENTS.compliance]\n\nexport const ALL_WEBHOOK_EVENTS: readonly WebhookEventName[] = [\n ...Object.values(WEBHOOK_EVENTS.payment),\n ...Object.values(WEBHOOK_EVENTS.subscription),\n ...Object.values(WEBHOOK_EVENTS.refund),\n ...Object.values(WEBHOOK_EVENTS.invoice),\n ...Object.values(WEBHOOK_EVENTS.agent),\n ...Object.values(WEBHOOK_EVENTS.compliance),\n] as const\n\n/** Exponential backoff schedule for webhook delivery, in seconds. */\nexport const WEBHOOK_RETRY_SCHEDULE_SECONDS: readonly number[] = [\n 60, // 1 minute\n 300, // 5 minutes\n 1_800, // 30 minutes\n 7_200, // 2 hours\n 86_400, // 24 hours\n] as const\n\nexport const WEBHOOK_MAX_ATTEMPTS = WEBHOOK_RETRY_SCHEDULE_SECONDS.length + 1\n\n/** Webhook signatures older than this are rejected to prevent replay. */\nexport const WEBHOOK_SIGNATURE_TOLERANCE_SECONDS = 300\n\n/** HTTP header carrying the HMAC signature. */\nexport const WEBHOOK_SIGNATURE_HEADER = 'strimz-signature'\n\n/** HTTP header carrying the unique delivery id (idempotency key for the receiver). */\nexport const WEBHOOK_DELIVERY_ID_HEADER = 'strimz-delivery-id'\n"]}
|