@genesis-tech/genesispay-seller 0.13.0 → 0.13.1
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/package.json +1 -1
- package/dist/checkout-return.d.ts +0 -41
- package/dist/checkout-return.d.ts.map +0 -1
- package/dist/checkout-return.js +0 -67
- package/dist/checkout-return.js.map +0 -1
- package/dist/client.d.ts +0 -283
- package/dist/client.d.ts.map +0 -1
- package/dist/client.js +0 -629
- package/dist/client.js.map +0 -1
- package/dist/customers.d.ts +0 -41
- package/dist/customers.d.ts.map +0 -1
- package/dist/customers.js +0 -76
- package/dist/customers.js.map +0 -1
- package/dist/entitlements.d.ts +0 -19
- package/dist/entitlements.d.ts.map +0 -1
- package/dist/entitlements.js +0 -30
- package/dist/entitlements.js.map +0 -1
- package/dist/errors.d.ts +0 -63
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -162
- package/dist/errors.js.map +0 -1
- package/dist/genesispay-settlement.d.ts +0 -30
- package/dist/genesispay-settlement.d.ts.map +0 -1
- package/dist/genesispay-settlement.js +0 -103
- package/dist/genesispay-settlement.js.map +0 -1
- package/dist/index.d.ts +0 -16
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -18
- package/dist/index.js.map +0 -1
- package/dist/invoices.d.ts +0 -80
- package/dist/invoices.d.ts.map +0 -1
- package/dist/invoices.js +0 -133
- package/dist/invoices.js.map +0 -1
- package/dist/mandate-gate.d.ts +0 -49
- package/dist/mandate-gate.d.ts.map +0 -1
- package/dist/mandate-gate.js +0 -109
- package/dist/mandate-gate.js.map +0 -1
- package/dist/mandates.d.ts +0 -172
- package/dist/mandates.d.ts.map +0 -1
- package/dist/mandates.js +0 -213
- package/dist/mandates.js.map +0 -1
- package/dist/networks.d.ts +0 -10
- package/dist/networks.d.ts.map +0 -1
- package/dist/networks.js +0 -22
- package/dist/networks.js.map +0 -1
- package/dist/payment-gate.d.ts +0 -67
- package/dist/payment-gate.d.ts.map +0 -1
- package/dist/payment-gate.js +0 -106
- package/dist/payment-gate.js.map +0 -1
- package/dist/peerpay-settlement.d.ts +0 -27
- package/dist/peerpay-settlement.d.ts.map +0 -1
- package/dist/peerpay-settlement.js +0 -100
- package/dist/peerpay-settlement.js.map +0 -1
- package/dist/plans.d.ts +0 -68
- package/dist/plans.d.ts.map +0 -1
- package/dist/plans.js +0 -127
- package/dist/plans.js.map +0 -1
- package/dist/products.d.ts +0 -146
- package/dist/products.d.ts.map +0 -1
- package/dist/products.js +0 -295
- package/dist/products.js.map +0 -1
- package/dist/resource.d.ts +0 -47
- package/dist/resource.d.ts.map +0 -1
- package/dist/resource.js +0 -71
- package/dist/resource.js.map +0 -1
- package/dist/usdc-amount.d.ts +0 -7
- package/dist/usdc-amount.d.ts.map +0 -1
- package/dist/usdc-amount.js +0 -21
- package/dist/usdc-amount.js.map +0 -1
- package/dist/webhooks.d.ts +0 -277
- package/dist/webhooks.d.ts.map +0 -1
- package/dist/webhooks.js +0 -224
- package/dist/webhooks.js.map +0 -1
package/dist/mandates.js
DELETED
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
// `genesispay.mandates.*` — payment mandates over `/api/v1/mandates`.
|
|
2
|
-
//
|
|
3
|
-
// A mandate is a bounded, revocable spending approval a payer signs once (an
|
|
4
|
-
// EIP-2612 permit); the seller then pulls individual charges against it with no
|
|
5
|
-
// further signature. Funds stay in the payer's wallet until each pull.
|
|
6
|
-
//
|
|
7
|
-
// Deliberately absent: `mandates.activate`. Activation submits the payer's
|
|
8
|
-
// *signature* over the permit typed data — it is authorized by the payer's
|
|
9
|
-
// wallet, not by a seller API key, and belongs in the payer-facing frontend
|
|
10
|
-
// (`POST /api/v1/mandates/:id/activate`). `mandates.create` returns the
|
|
11
|
-
// `permitTypedData` for exactly that purpose: hand it to the payer's wallet,
|
|
12
|
-
// and post the resulting signature from there. Offering activate here would
|
|
13
|
-
// suggest a seller can switch on a mandate by itself, which is the one thing
|
|
14
|
-
// the design does not allow.
|
|
15
|
-
import { GenesisPayConfigError } from "./errors.js";
|
|
16
|
-
import { asRecord, optionalAmountString, optionalCount, optionalString, requiredString, toAmountString, toCount, oneOf, } from "./resource.js";
|
|
17
|
-
export function createMandatesResource(request) {
|
|
18
|
-
return {
|
|
19
|
-
create: async (input) => {
|
|
20
|
-
const body = await request({
|
|
21
|
-
method: "POST",
|
|
22
|
-
path: "/api/v1/mandates",
|
|
23
|
-
operation: "POST /api/v1/mandates",
|
|
24
|
-
action: "create a mandate",
|
|
25
|
-
body: {
|
|
26
|
-
payerWallet: input.payerWallet,
|
|
27
|
-
kind: input.kind,
|
|
28
|
-
allowance: input.allowance,
|
|
29
|
-
capPerCharge: input.capPerCharge,
|
|
30
|
-
...(input.amountPerPeriod ? { amountPerPeriod: input.amountPerPeriod } : {}),
|
|
31
|
-
...(input.periodDays === undefined ? {} : { periodDays: input.periodDays }),
|
|
32
|
-
...(input.asset ? { asset: input.asset } : {}),
|
|
33
|
-
...(input.destinationWallet
|
|
34
|
-
? { destinationWallet: input.destinationWallet }
|
|
35
|
-
: {}),
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
const record = asRecord(body);
|
|
39
|
-
const mandate = requireMandate(body, "POST /api/v1/mandates");
|
|
40
|
-
const permitTypedData = asRecord(record?.permitTypedData);
|
|
41
|
-
if (!permitTypedData ||
|
|
42
|
-
!asRecord(permitTypedData.message) ||
|
|
43
|
-
!asRecord(permitTypedData.domain)) {
|
|
44
|
-
// Without the typed data the payer cannot sign, so the mandate can never
|
|
45
|
-
// leave `pending_permit` — better to fail loudly than hand back a stub.
|
|
46
|
-
throw new GenesisPayConfigError(`GenesisPay POST /api/v1/mandates returned a mandate without permitTypedData: ${JSON.stringify(body)}`);
|
|
47
|
-
}
|
|
48
|
-
const spender = requiredString(record?.spender);
|
|
49
|
-
if (!spender) {
|
|
50
|
-
// Degrading to "" would hand back an address-shaped empty string for the
|
|
51
|
-
// account the allowance approves. Same reasoning as permitTypedData:
|
|
52
|
-
// a missing contract field is a broken response, not an old backend.
|
|
53
|
-
throw new GenesisPayConfigError(`GenesisPay POST /api/v1/mandates returned a mandate without a spender: ${JSON.stringify(body)}`);
|
|
54
|
-
}
|
|
55
|
-
return {
|
|
56
|
-
mandate,
|
|
57
|
-
// Verbatim: see the PermitTypedData docs — a signature is over these bytes.
|
|
58
|
-
permitTypedData: permitTypedData,
|
|
59
|
-
spender,
|
|
60
|
-
};
|
|
61
|
-
},
|
|
62
|
-
list: async (opts = {}) => {
|
|
63
|
-
const query = new URLSearchParams();
|
|
64
|
-
if (opts.planId !== undefined) {
|
|
65
|
-
// An explicitly empty filter is refused rather than dropped: silently
|
|
66
|
-
// omitting it would widen the page from "one plan's subscribers" to
|
|
67
|
-
// every mandate on the account — the opposite of what was asked for.
|
|
68
|
-
query.set("planId", requireFilterValue(opts.planId, "planId"));
|
|
69
|
-
}
|
|
70
|
-
if (opts.status !== undefined)
|
|
71
|
-
query.set("status", opts.status);
|
|
72
|
-
if (opts.limit !== undefined)
|
|
73
|
-
query.set("limit", String(opts.limit));
|
|
74
|
-
if (opts.startingAfter !== undefined) {
|
|
75
|
-
// Same reasoning, sharper failure mode: dropping an empty cursor
|
|
76
|
-
// restarts at page 1, which turns a paging loop into an endless one.
|
|
77
|
-
query.set("startingAfter", requireFilterValue(opts.startingAfter, "startingAfter"));
|
|
78
|
-
}
|
|
79
|
-
const search = query.toString();
|
|
80
|
-
const body = await request({
|
|
81
|
-
path: search ? `/api/v1/mandates?${search}` : "/api/v1/mandates",
|
|
82
|
-
// Label without the query string: the operation is what failed, the
|
|
83
|
-
// filter values are not error detail (and `planId` is caller data).
|
|
84
|
-
operation: "GET /api/v1/mandates",
|
|
85
|
-
action: "list mandates",
|
|
86
|
-
});
|
|
87
|
-
const record = asRecord(body);
|
|
88
|
-
const mandates = record?.mandates;
|
|
89
|
-
if (!Array.isArray(mandates)) {
|
|
90
|
-
// A list endpoint answering 200 without a list is a broken contract,
|
|
91
|
-
// not an old backend. Returning [] would hide it as "no mandates yet"
|
|
92
|
-
// — and "this customer has no subscription" is exactly the wrong thing
|
|
93
|
-
// to conclude from a malformed response.
|
|
94
|
-
throw new GenesisPayConfigError(`GenesisPay GET /api/v1/mandates returned no mandates array: ${JSON.stringify(body)}`);
|
|
95
|
-
}
|
|
96
|
-
return {
|
|
97
|
-
// Individual entries stay tolerant: one unusable row must not lose the
|
|
98
|
-
// rest of the page. A row without an id is dropped — it could not be
|
|
99
|
-
// revoked or retrieved anyway.
|
|
100
|
-
mandates: mandates
|
|
101
|
-
.map(asRecord)
|
|
102
|
-
.filter((raw) => raw !== null)
|
|
103
|
-
.filter((raw) => typeof raw.id === "string" && raw.id.length > 0)
|
|
104
|
-
.map(toMandate),
|
|
105
|
-
// Only an explicit `true` means "there is more". Anything else stops
|
|
106
|
-
// the loop above rather than spinning it against a backend that does
|
|
107
|
-
// not report the flag.
|
|
108
|
-
hasMore: record?.hasMore === true,
|
|
109
|
-
};
|
|
110
|
-
},
|
|
111
|
-
retrieve: async (id) => {
|
|
112
|
-
const mandateId = requireMandateId(id, "mandates.retrieve");
|
|
113
|
-
const body = await request({
|
|
114
|
-
path: `/api/v1/mandates/${encodeURIComponent(mandateId)}`,
|
|
115
|
-
operation: `GET /api/v1/mandates/${mandateId}`,
|
|
116
|
-
action: `retrieve mandate "${mandateId}"`,
|
|
117
|
-
notFoundMessage: notFoundMessage(mandateId),
|
|
118
|
-
});
|
|
119
|
-
return requireMandate(body, `GET /api/v1/mandates/${mandateId}`);
|
|
120
|
-
},
|
|
121
|
-
charge: async (id, input) => {
|
|
122
|
-
const mandateId = requireMandateId(id, "mandates.charge");
|
|
123
|
-
const body = await request({
|
|
124
|
-
method: "POST",
|
|
125
|
-
path: `/api/v1/mandates/${encodeURIComponent(mandateId)}/charge`,
|
|
126
|
-
operation: `POST /api/v1/mandates/${mandateId}/charge`,
|
|
127
|
-
action: `charge mandate "${mandateId}"`,
|
|
128
|
-
notFoundMessage: notFoundMessage(mandateId),
|
|
129
|
-
body: {
|
|
130
|
-
amount: input.amount,
|
|
131
|
-
...(input.resourceUrl ? { resourceUrl: input.resourceUrl } : {}),
|
|
132
|
-
...(input.description ? { description: input.description } : {}),
|
|
133
|
-
},
|
|
134
|
-
});
|
|
135
|
-
const raw = asRecord(asRecord(body)?.charge);
|
|
136
|
-
if (!raw || typeof raw.id !== "string" || !raw.id) {
|
|
137
|
-
throw new GenesisPayConfigError(`GenesisPay POST /api/v1/mandates/${mandateId}/charge returned no charge: ${JSON.stringify(body)}`);
|
|
138
|
-
}
|
|
139
|
-
return {
|
|
140
|
-
id: raw.id,
|
|
141
|
-
status: oneOf(raw.status, ["pending", "settled", "failed"], "pending"),
|
|
142
|
-
amountMinor: toAmountString(raw.amountMinor),
|
|
143
|
-
txHash: optionalString(raw.txHash),
|
|
144
|
-
};
|
|
145
|
-
},
|
|
146
|
-
revoke: async (id) => {
|
|
147
|
-
const mandateId = requireMandateId(id, "mandates.revoke");
|
|
148
|
-
const body = await request({
|
|
149
|
-
method: "POST",
|
|
150
|
-
path: `/api/v1/mandates/${encodeURIComponent(mandateId)}/revoke`,
|
|
151
|
-
operation: `POST /api/v1/mandates/${mandateId}/revoke`,
|
|
152
|
-
action: `revoke mandate "${mandateId}"`,
|
|
153
|
-
notFoundMessage: notFoundMessage(mandateId),
|
|
154
|
-
});
|
|
155
|
-
return requireMandate(body, `POST /api/v1/mandates/${mandateId}/revoke`);
|
|
156
|
-
},
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
function notFoundMessage(id) {
|
|
160
|
-
return (`No GenesisPay mandate with id "${id}". Check the id and that it belongs to ` +
|
|
161
|
-
`the account this API key authenticates.`);
|
|
162
|
-
}
|
|
163
|
-
function requireFilterValue(value, field) {
|
|
164
|
-
const trimmed = typeof value === "string" ? value.trim() : "";
|
|
165
|
-
if (!trimmed) {
|
|
166
|
-
throw new GenesisPayConfigError(`mandates.list({ ${field} }) was given an empty value. Omit ${field} ` +
|
|
167
|
-
`entirely to list without it — an empty string would silently change ` +
|
|
168
|
-
`which mandates come back.`);
|
|
169
|
-
}
|
|
170
|
-
return trimmed;
|
|
171
|
-
}
|
|
172
|
-
function requireMandateId(id, method) {
|
|
173
|
-
const mandateId = id?.trim();
|
|
174
|
-
if (!mandateId) {
|
|
175
|
-
throw new GenesisPayConfigError(`${method}(id) requires the mandate id returned by mandates.create().`);
|
|
176
|
-
}
|
|
177
|
-
return mandateId;
|
|
178
|
-
}
|
|
179
|
-
function requireMandate(body, operation) {
|
|
180
|
-
const raw = asRecord(asRecord(body)?.mandate);
|
|
181
|
-
if (!raw || typeof raw.id !== "string" || !raw.id) {
|
|
182
|
-
throw new GenesisPayConfigError(`GenesisPay ${operation} returned no mandate: ${JSON.stringify(body)}`);
|
|
183
|
-
}
|
|
184
|
-
return toMandate(raw);
|
|
185
|
-
}
|
|
186
|
-
export function toMandate(raw) {
|
|
187
|
-
return {
|
|
188
|
-
id: requiredString(raw.id),
|
|
189
|
-
kind: oneOf(raw.kind, ["per_use", "subscription"], "per_use"),
|
|
190
|
-
// An unknown status degrades to `pending_permit`, the inert state: guessing
|
|
191
|
-
// "active" for a status this SDK version has never heard of would invite a
|
|
192
|
-
// caller to serve something it should not.
|
|
193
|
-
status: oneOf(raw.status, ["pending_permit", "active", "past_due", "revoked", "expired"], "pending_permit"),
|
|
194
|
-
asset: oneOf(raw.asset, ["USDC", "EURC"], "USDC"),
|
|
195
|
-
chainId: toCount(raw.chainId),
|
|
196
|
-
payerWallet: requiredString(raw.payerWallet),
|
|
197
|
-
destinationWallet: requiredString(raw.destinationWallet),
|
|
198
|
-
subscriptionPlanId: optionalString(raw.subscriptionPlanId),
|
|
199
|
-
allowanceMinor: toAmountString(raw.allowanceMinor),
|
|
200
|
-
capPerChargeMinor: toAmountString(raw.capPerChargeMinor),
|
|
201
|
-
spentMinor: toAmountString(raw.spentMinor),
|
|
202
|
-
remainingMinor: toAmountString(raw.remainingMinor),
|
|
203
|
-
amountPerPeriodMinor: optionalAmountString(raw.amountPerPeriodMinor),
|
|
204
|
-
periodDays: optionalCount(raw.periodDays),
|
|
205
|
-
nextChargeAt: optionalString(raw.nextChargeAt),
|
|
206
|
-
permitDeadline: requiredString(raw.permitDeadline),
|
|
207
|
-
permitTxHash: optionalString(raw.permitTxHash),
|
|
208
|
-
createdAt: requiredString(raw.createdAt),
|
|
209
|
-
activatedAt: optionalString(raw.activatedAt),
|
|
210
|
-
revokedAt: optionalString(raw.revokedAt),
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
//# sourceMappingURL=mandates.js.map
|
package/dist/mandates.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mandates.js","sourceRoot":"","sources":["../src/mandates.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,EAAE;AACF,6EAA6E;AAC7E,gFAAgF;AAChF,uEAAuE;AACvE,EAAE;AACF,2EAA2E;AAC3E,2EAA2E;AAC3E,4EAA4E;AAC5E,wEAAwE;AACxE,6EAA6E;AAC7E,4EAA4E;AAC5E,6EAA6E;AAC7E,6BAA6B;AAE7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EACL,QAAQ,EACR,oBAAoB,EACpB,aAAa,EACb,cAAc,EACd,cAAc,EACd,cAAc,EACd,OAAO,EACP,KAAK,GAEN,MAAM,eAAe,CAAC;AAwLvB,MAAM,UAAU,sBAAsB,CAAC,OAA0B;IAC/D,OAAO;QACL,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;YACtB,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC;gBACzB,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,kBAAkB;gBACxB,SAAS,EAAE,uBAAuB;gBAClC,MAAM,EAAE,kBAAkB;gBAC1B,IAAI,EAAE;oBACJ,WAAW,EAAE,KAAK,CAAC,WAAW;oBAC9B,IAAI,EAAE,KAAK,CAAC,IAAI;oBAChB,SAAS,EAAE,KAAK,CAAC,SA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AAC;QACxD,kBAAkB,EAAE,cAAc,CAAC,GAAG,CAAC,kBAAkB,CAAC;QAC1D,cAAc,EAAE,cAAc,CAAC,GAAG,CAAC,cAAc,CAAC;QAClD,iBAAiB,EAAE,cAAc,CAAC,GAAG,CAAC,iBAAiB,CAAC;QACxD,UAAU,EAAE,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC;QAC1C,cAAc,EAAE,cAAc,CAAC,GAAG,CAAC,cAAc,CAAC;QAClD,oBAAoB,EAAE,oBAAoB,CAAC,GAAG,CAAC,oBAAoB,CAAC;QACpE,UAAU,EAAE,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC;QACzC,YAAY,EAAE,cAAc,CAAC,GAAG,CAAC,YAAY,CAAC;QAC9C,cAAc,EAAE,cAAc,CAAC,GAAG,CAAC,cAAc,CAAC;QAClD,YAAY,EAAE,cAAc,CAAC,GAAG,CAAC,YAAY,CAAC;QAC9C,SAAS,EAAE,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC;QACxC,WAAW,EAAE,cAAc,CAAC,GAAG,CAAC,WAAW,CAAC;QAC5C,SAAS,EAAE,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC;KACzC,CAAC;AACJ,CAAC"}
|
package/dist/networks.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { EvmAddress } from "@genesis-tech/genesispay-protocol";
|
|
2
|
-
/** Networks the payment gate supports out of the box. */
|
|
3
|
-
export type PaymentGateNetwork = "base" | "base-sepolia";
|
|
4
|
-
export type PaymentGateNetworkConfig = {
|
|
5
|
-
network: PaymentGateNetwork;
|
|
6
|
-
chainId: number;
|
|
7
|
-
usdcAddress: EvmAddress;
|
|
8
|
-
};
|
|
9
|
-
export declare function resolvePaymentGateNetwork(network: PaymentGateNetwork): PaymentGateNetworkConfig;
|
|
10
|
-
//# sourceMappingURL=networks.d.ts.map
|
package/dist/networks.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"networks.d.ts","sourceRoot":"","sources":["../src/networks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAEpE,yDAAyD;AACzD,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,cAAc,CAAC;AAEzD,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,EAAE,kBAAkB,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,UAAU,CAAC;CACzB,CAAC;AAmBF,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,kBAAkB,GAC1B,wBAAwB,CAU1B"}
|
package/dist/networks.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const BASE_MAINNET = {
|
|
2
|
-
network: "base",
|
|
3
|
-
chainId: 8453,
|
|
4
|
-
usdcAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
5
|
-
};
|
|
6
|
-
const BASE_SEPOLIA = {
|
|
7
|
-
network: "base-sepolia",
|
|
8
|
-
chainId: 84532,
|
|
9
|
-
usdcAddress: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
|
|
10
|
-
};
|
|
11
|
-
const NETWORK_CONFIGS = {
|
|
12
|
-
base: BASE_MAINNET,
|
|
13
|
-
"base-sepolia": BASE_SEPOLIA,
|
|
14
|
-
};
|
|
15
|
-
export function resolvePaymentGateNetwork(network) {
|
|
16
|
-
const config = NETWORK_CONFIGS[network];
|
|
17
|
-
if (!config) {
|
|
18
|
-
throw new Error(`Unsupported network "${String(network)}". Supported networks: ${Object.keys(NETWORK_CONFIGS).join(", ")}.`);
|
|
19
|
-
}
|
|
20
|
-
return config;
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=networks.js.map
|
package/dist/networks.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"networks.js","sourceRoot":"","sources":["../src/networks.ts"],"names":[],"mappings":"AAWA,MAAM,YAAY,GAA6B;IAC7C,OAAO,EAAE,MAAM;IACf,OAAO,EAAE,IAAI;IACb,WAAW,EAAE,4CAA4C;CAC1D,CAAC;AAEF,MAAM,YAAY,GAA6B;IAC7C,OAAO,EAAE,cAAc;IACvB,OAAO,EAAE,KAAK;IACd,WAAW,EAAE,4CAA4C;CAC1D,CAAC;AAEF,MAAM,eAAe,GAAyD;IAC5E,IAAI,EAAE,YAAY;IAClB,cAAc,EAAE,YAAY;CAC7B,CAAC;AAEF,MAAM,UAAU,yBAAyB,CACvC,OAA2B;IAE3B,MAAM,MAAM,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;IAExC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CACb,wBAAwB,MAAM,CAAC,OAAO,CAAC,0BAA0B,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAC5G,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/payment-gate.d.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import type { PaymentAccept, PaymentSignaturePayload, SettlementResponsePayload } from "@genesis-tech/genesispay-protocol";
|
|
2
|
-
import type { PaymentGateNetwork } from "./networks.js";
|
|
3
|
-
export type PaymentGateConfig = {
|
|
4
|
-
/** Human-readable decimal USDC amount, e.g. "0.10". */
|
|
5
|
-
amountUsdc: string;
|
|
6
|
-
/** Wallet that receives the USDC payment. */
|
|
7
|
-
payTo: string;
|
|
8
|
-
/** Shown to payers in the PAYMENT-REQUIRED payload. */
|
|
9
|
-
description?: string;
|
|
10
|
-
/** Defaults to "base-sepolia". */
|
|
11
|
-
network?: PaymentGateNetwork;
|
|
12
|
-
/**
|
|
13
|
-
* Canonical resource URL advertised in PAYMENT-REQUIRED. Defaults to the
|
|
14
|
-
* incoming request URL (origin + pathname, query stripped).
|
|
15
|
-
*/
|
|
16
|
-
resource?: string;
|
|
17
|
-
/** MIME type of the paid resource. Defaults to "application/json". */
|
|
18
|
-
mimeType?: string;
|
|
19
|
-
/** Payment authorization validity window advertised to payers. */
|
|
20
|
-
maxTimeoutSeconds?: number;
|
|
21
|
-
/**
|
|
22
|
-
* EIP-712 domain (`name`/`version`) of the settlement asset contract,
|
|
23
|
-
* advertised as the x402 `extra` field so generic clients sign with the
|
|
24
|
-
* exact domain the contract's DOMAIN_SEPARATOR() uses (e.g. Base mainnet
|
|
25
|
-
* USDC is { name: "USD Coin", version: "2" }). Omitted by default —
|
|
26
|
-
* clients then fall back to the standard "USDC"/"2" domain.
|
|
27
|
-
*/
|
|
28
|
-
eip712Domain?: {
|
|
29
|
-
name: string;
|
|
30
|
-
version: string;
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
/** Context handed to the settlement hook once a payment passed structural checks. */
|
|
34
|
-
export type SettlementContext = {
|
|
35
|
-
request: Request;
|
|
36
|
-
/** The raw PAYMENT-SIGNATURE header value, ready to forward to a facilitator. */
|
|
37
|
-
paymentSignatureHeader: string;
|
|
38
|
-
/** The decoded, structurally validated payment payload. */
|
|
39
|
-
payment: PaymentSignaturePayload;
|
|
40
|
-
/** The payment requirement this request must satisfy. */
|
|
41
|
-
requirement: PaymentAccept;
|
|
42
|
-
};
|
|
43
|
-
export type SettlementVerification = {
|
|
44
|
-
ok: true;
|
|
45
|
-
settlement: SettlementResponsePayload;
|
|
46
|
-
} | {
|
|
47
|
-
ok: false;
|
|
48
|
-
errorReason: string;
|
|
49
|
-
settlement?: SettlementResponsePayload;
|
|
50
|
-
};
|
|
51
|
-
export type VerifySettlement = (context: SettlementContext) => Promise<SettlementVerification>;
|
|
52
|
-
export type WrapOptions = {
|
|
53
|
-
verifySettlement: VerifySettlement;
|
|
54
|
-
};
|
|
55
|
-
type WrappableHandler<Args extends unknown[]> = (request: Request, ...args: Args) => Response | Promise<Response>;
|
|
56
|
-
export type PaymentGate = {
|
|
57
|
-
/**
|
|
58
|
-
* Wraps a Web-standard (Request) => Response handler. Works with Next.js
|
|
59
|
-
* route handlers, Hono (`(c) => gated(c.req.raw)`), and Bun.serve.
|
|
60
|
-
*/
|
|
61
|
-
wrap<Args extends unknown[]>(handler: WrappableHandler<Args>, options: WrapOptions): (request: Request, ...args: Args) => Promise<Response>;
|
|
62
|
-
/** Builds the PAYMENT-REQUIRED requirement for a given resource URL. */
|
|
63
|
-
requirementFor(resource: string): PaymentAccept;
|
|
64
|
-
};
|
|
65
|
-
export declare function createPaymentGate(config: PaymentGateConfig): PaymentGate;
|
|
66
|
-
export {};
|
|
67
|
-
//# sourceMappingURL=payment-gate.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"payment-gate.d.ts","sourceRoot":"","sources":["../src/payment-gate.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAEV,aAAa,EAEb,uBAAuB,EACvB,yBAAyB,EAC1B,MAAM,mCAAmC,CAAC;AAI3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAGxD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,uDAAuD;IACvD,UAAU,EAAE,MAAM,CAAC;IACnB,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kCAAkC;IAClC,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sEAAsE;IACtE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kEAAkE;IAClE,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;;OAMG;IACH,YAAY,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAClD,CAAC;AAEF,qFAAqF;AACrF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,OAAO,CAAC;IACj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SIGNATURE_HEADER, buildPaymentRequiredPayload, decodePaymentSignatureHeader, encodePaymentRequiredHeader, encodeSettlementResponseHeader, validatePaymentSignatureAgainstRequirement, } from "@genesis-tech/genesispay-protocol";
|
|
2
|
-
import { getAddress, isAddress } from "viem";
|
|
3
|
-
import { resolvePaymentGateNetwork } from "./networks.js";
|
|
4
|
-
import { parseUsdcAmountToMinorUnits } from "./usdc-amount.js";
|
|
5
|
-
export function createPaymentGate(config) {
|
|
6
|
-
const network = resolvePaymentGateNetwork(config.network ?? "base-sepolia");
|
|
7
|
-
const amountUsdcMinor = parseUsdcAmountToMinorUnits(config.amountUsdc);
|
|
8
|
-
const payTo = normalizePayToAddress(config.payTo);
|
|
9
|
-
const description = config.description ?? "Payment required";
|
|
10
|
-
function buildPayload(resource) {
|
|
11
|
-
return buildPaymentRequiredPayload({
|
|
12
|
-
amount: config.amountUsdc.trim(),
|
|
13
|
-
amountUsdcMinor,
|
|
14
|
-
asset: "USDC",
|
|
15
|
-
assetAddress: network.usdcAddress,
|
|
16
|
-
chainId: network.chainId,
|
|
17
|
-
network: network.network,
|
|
18
|
-
destination: payTo,
|
|
19
|
-
description,
|
|
20
|
-
resource,
|
|
21
|
-
mimeType: config.mimeType,
|
|
22
|
-
maxTimeoutSeconds: config.maxTimeoutSeconds,
|
|
23
|
-
extra: config.eip712Domain,
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
function resolveResource(request) {
|
|
27
|
-
if (config.resource) {
|
|
28
|
-
return config.resource;
|
|
29
|
-
}
|
|
30
|
-
const url = new URL(request.url);
|
|
31
|
-
return `${url.origin}${url.pathname}`;
|
|
32
|
-
}
|
|
33
|
-
return {
|
|
34
|
-
requirementFor(resource) {
|
|
35
|
-
return buildPayload(resource).accepts[0];
|
|
36
|
-
},
|
|
37
|
-
wrap(handler, options) {
|
|
38
|
-
if (typeof options?.verifySettlement !== "function") {
|
|
39
|
-
throw new Error("gate.wrap requires a verifySettlement hook — use genesisPaySettlement({ facilitatorBaseUrl, apiKey }) or provide your own.");
|
|
40
|
-
}
|
|
41
|
-
return async (request, ...args) => {
|
|
42
|
-
const payload = buildPayload(resolveResource(request));
|
|
43
|
-
const paymentSignatureHeader = request.headers.get(PAYMENT_SIGNATURE_HEADER);
|
|
44
|
-
if (!paymentSignatureHeader?.trim()) {
|
|
45
|
-
return paymentRequiredResponse(payload);
|
|
46
|
-
}
|
|
47
|
-
let payment;
|
|
48
|
-
try {
|
|
49
|
-
payment = decodePaymentSignatureHeader(paymentSignatureHeader);
|
|
50
|
-
}
|
|
51
|
-
catch (error) {
|
|
52
|
-
return paymentRequiredResponse(payload, describeError(error));
|
|
53
|
-
}
|
|
54
|
-
const requirement = payload.accepts[0];
|
|
55
|
-
const mismatch = validatePaymentSignatureAgainstRequirement(payment, requirement);
|
|
56
|
-
if (mismatch) {
|
|
57
|
-
return paymentRequiredResponse(payload, mismatch);
|
|
58
|
-
}
|
|
59
|
-
const verification = await options.verifySettlement({
|
|
60
|
-
request,
|
|
61
|
-
paymentSignatureHeader,
|
|
62
|
-
payment,
|
|
63
|
-
requirement,
|
|
64
|
-
});
|
|
65
|
-
if (!verification.ok) {
|
|
66
|
-
return paymentRequiredResponse(payload, verification.errorReason, verification.settlement);
|
|
67
|
-
}
|
|
68
|
-
const response = await handler(request, ...args);
|
|
69
|
-
return withSettlementHeader(response, verification.settlement);
|
|
70
|
-
};
|
|
71
|
-
},
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
function paymentRequiredResponse(payload, errorReason, settlement) {
|
|
75
|
-
const body = errorReason
|
|
76
|
-
? { ...payload, error: errorReason }
|
|
77
|
-
: payload;
|
|
78
|
-
const headers = new Headers({
|
|
79
|
-
"Content-Type": "application/json",
|
|
80
|
-
"Cache-Control": "no-store",
|
|
81
|
-
[PAYMENT_REQUIRED_HEADER]: encodePaymentRequiredHeader(body),
|
|
82
|
-
});
|
|
83
|
-
if (settlement) {
|
|
84
|
-
headers.set(PAYMENT_RESPONSE_HEADER, encodeSettlementResponseHeader(settlement));
|
|
85
|
-
}
|
|
86
|
-
return new Response(JSON.stringify(body), { status: 402, headers });
|
|
87
|
-
}
|
|
88
|
-
function withSettlementHeader(response, settlement) {
|
|
89
|
-
const headers = new Headers(response.headers);
|
|
90
|
-
headers.set(PAYMENT_RESPONSE_HEADER, encodeSettlementResponseHeader(settlement));
|
|
91
|
-
return new Response(response.body, {
|
|
92
|
-
status: response.status,
|
|
93
|
-
statusText: response.statusText,
|
|
94
|
-
headers,
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
function normalizePayToAddress(payTo) {
|
|
98
|
-
if (typeof payTo !== "string" || !isAddress(payTo.trim())) {
|
|
99
|
-
throw new Error(`Invalid payTo address "${String(payTo)}": expected an EVM address like 0x1234....`);
|
|
100
|
-
}
|
|
101
|
-
return getAddress(payTo.trim());
|
|
102
|
-
}
|
|
103
|
-
function describeError(error) {
|
|
104
|
-
return error instanceof Error ? error.message : "Malformed PAYMENT-SIGNATURE header.";
|
|
105
|
-
}
|
|
106
|
-
//# sourceMappingURL=payment-gate.js.map
|
package/dist/payment-gate.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"payment-gate.js","sourceRoot":"","sources":["../src/payment-gate.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,2BAA2B,EAC3B,4BAA4B,EAC5B,2BAA2B,EAC3B,8BAA8B,EAC9B,0CAA0C,GAC3C,MAAM,mCAAmC,CAAC;AAQ3C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAE7C,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAuE/D,MAAM,UAAU,iBAAiB,CAAC,MAAyB;IACzD,MAAM,OAAO,GAAG,yBAAyB,CAAC,MAAM,CAAC,OAAO,IAAI,cAAc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BAA0B,MAAM,CAAC,KAAK,CAAC,4CAA4C,CACpF,CAAC;IACJ,CAAC;IAED,OAAO,UAAU,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;AAClC,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,qCAAqC,CAAC;AACxF,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { VerifySettlement } from "./payment-gate.js";
|
|
2
|
-
/**
|
|
3
|
-
* Default GenesisPay app base URL — the public "development" facilitator. Used
|
|
4
|
-
* when `facilitatorBaseUrl` is omitted so integrators don't have to configure a
|
|
5
|
-
* URL in dev. Set `facilitatorBaseUrl` explicitly for production.
|
|
6
|
-
*/
|
|
7
|
-
export declare const DEFAULT_FACILITATOR_BASE_URL = "https://peerpay-app-development.up.railway.app";
|
|
8
|
-
export type PeerPaySettlementOptions = {
|
|
9
|
-
/**
|
|
10
|
-
* Base URL of the GenesisPay app, e.g. "https://genesispay.example". Defaults to
|
|
11
|
-
* the public development facilitator (DEFAULT_FACILITATOR_BASE_URL) when
|
|
12
|
-
* omitted; set it explicitly in production.
|
|
13
|
-
*/
|
|
14
|
-
facilitatorBaseUrl?: string;
|
|
15
|
-
/** GenesisPay seller API key ("pp_sk_..."). */
|
|
16
|
-
apiKey: string;
|
|
17
|
-
/** Override for testing; defaults to global fetch. */
|
|
18
|
-
fetchFn?: typeof fetch;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Built-in settlement hook that forwards the PAYMENT-SIGNATURE payload to the
|
|
22
|
-
* GenesisPay facilitator (`POST /api/v1/facilitator/settle`). GenesisPay broadcasts
|
|
23
|
-
* the EIP-3009 authorization on-chain (or verifies a payer-provided txHash)
|
|
24
|
-
* and verifies the USDC transfer before reporting success.
|
|
25
|
-
*/
|
|
26
|
-
export declare function peerPaySettlement(options: PeerPaySettlementOptions): VerifySettlement;
|
|
27
|
-
//# sourceMappingURL=peerpay-settlement.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"peerpay-settlement.d.ts","sourceRoot":"","sources":["../src/peerpay-settlement.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAGV,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAE3B;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,mDACS,CAAC;AAEnD,MAAM,MAAM,wBAAwB,GAAG;IACrC;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,OAAO,CAAC,EAAE,OAAO,KAAK,CAAC;CACxB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,wBAAwB,GAChC,gBAAgB,CA6DlB"}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { parseSettlementResponsePayload } from "@genesis-tech/genesispay-protocol";
|
|
2
|
-
/**
|
|
3
|
-
* Default GenesisPay app base URL — the public "development" facilitator. Used
|
|
4
|
-
* when `facilitatorBaseUrl` is omitted so integrators don't have to configure a
|
|
5
|
-
* URL in dev. Set `facilitatorBaseUrl` explicitly for production.
|
|
6
|
-
*/
|
|
7
|
-
export const DEFAULT_FACILITATOR_BASE_URL = "https://peerpay-app-development.up.railway.app";
|
|
8
|
-
/**
|
|
9
|
-
* Built-in settlement hook that forwards the PAYMENT-SIGNATURE payload to the
|
|
10
|
-
* GenesisPay facilitator (`POST /api/v1/facilitator/settle`). GenesisPay broadcasts
|
|
11
|
-
* the EIP-3009 authorization on-chain (or verifies a payer-provided txHash)
|
|
12
|
-
* and verifies the USDC transfer before reporting success.
|
|
13
|
-
*/
|
|
14
|
-
export function peerPaySettlement(options) {
|
|
15
|
-
const settleUrl = buildSettleUrl(options.facilitatorBaseUrl?.trim() || DEFAULT_FACILITATOR_BASE_URL);
|
|
16
|
-
const apiKey = options.apiKey?.trim();
|
|
17
|
-
if (!apiKey) {
|
|
18
|
-
throw new Error("peerPaySettlement requires a GenesisPay seller API key (pp_sk_...).");
|
|
19
|
-
}
|
|
20
|
-
const fetchFn = options.fetchFn ?? fetch;
|
|
21
|
-
return async (context) => {
|
|
22
|
-
const { requirement } = context;
|
|
23
|
-
let response;
|
|
24
|
-
try {
|
|
25
|
-
response = await fetchFn(settleUrl, {
|
|
26
|
-
method: "POST",
|
|
27
|
-
headers: {
|
|
28
|
-
"Content-Type": "application/json",
|
|
29
|
-
Authorization: `Bearer ${apiKey}`,
|
|
30
|
-
},
|
|
31
|
-
body: JSON.stringify({
|
|
32
|
-
paymentSignature: context.paymentSignatureHeader,
|
|
33
|
-
requirement: {
|
|
34
|
-
resource: requirement.resource,
|
|
35
|
-
network: requirement.network,
|
|
36
|
-
chainId: requirement.chainId,
|
|
37
|
-
assetAddress: requirement.assetAddress,
|
|
38
|
-
amountUsdcMinor: requirement.maxAmountRequired,
|
|
39
|
-
payTo: requirement.payTo,
|
|
40
|
-
description: requirement.description || undefined,
|
|
41
|
-
},
|
|
42
|
-
}),
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
catch (error) {
|
|
46
|
-
return {
|
|
47
|
-
ok: false,
|
|
48
|
-
errorReason: `Failed to reach the GenesisPay facilitator: ${describeError(error)}`,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
const body = await readJsonBody(response);
|
|
52
|
-
const settlement = tryParseSettlement(body);
|
|
53
|
-
if (response.ok && settlement?.success) {
|
|
54
|
-
return { ok: true, settlement };
|
|
55
|
-
}
|
|
56
|
-
return {
|
|
57
|
-
ok: false,
|
|
58
|
-
errorReason: settlement?.errorReason ??
|
|
59
|
-
readErrorMessage(body) ??
|
|
60
|
-
`GenesisPay facilitator settlement failed with status ${response.status}.`,
|
|
61
|
-
...(settlement ? { settlement } : {}),
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
function buildSettleUrl(facilitatorBaseUrl) {
|
|
66
|
-
const trimmed = facilitatorBaseUrl?.trim().replace(/\/+$/, "");
|
|
67
|
-
if (!trimmed || !/^https?:\/\//.test(trimmed)) {
|
|
68
|
-
throw new Error(`Invalid facilitatorBaseUrl "${String(facilitatorBaseUrl)}": expected an http(s) URL like "https://genesispay.example".`);
|
|
69
|
-
}
|
|
70
|
-
return `${trimmed}/api/v1/facilitator/settle`;
|
|
71
|
-
}
|
|
72
|
-
async function readJsonBody(response) {
|
|
73
|
-
try {
|
|
74
|
-
return await response.json();
|
|
75
|
-
}
|
|
76
|
-
catch {
|
|
77
|
-
return undefined;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
function tryParseSettlement(body) {
|
|
81
|
-
try {
|
|
82
|
-
return parseSettlementResponsePayload(body);
|
|
83
|
-
}
|
|
84
|
-
catch {
|
|
85
|
-
return undefined;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
function readErrorMessage(body) {
|
|
89
|
-
if (typeof body === "object" &&
|
|
90
|
-
body !== null &&
|
|
91
|
-
"error" in body &&
|
|
92
|
-
typeof body.error === "string") {
|
|
93
|
-
return body.error;
|
|
94
|
-
}
|
|
95
|
-
return undefined;
|
|
96
|
-
}
|
|
97
|
-
function describeError(error) {
|
|
98
|
-
return error instanceof Error ? error.message : "unknown error";
|
|
99
|
-
}
|
|
100
|
-
//# sourceMappingURL=peerpay-settlement.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"peerpay-settlement.js","sourceRoot":"","sources":["../src/peerpay-settlement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,mCAAmC,CAAC;AASnF;;;;GAIG;AACH,MAAM,CAAC,MAAM,4BAA4B,GACvC,gDAAgD,CAAC;AAenD;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAC/B,OAAiC;IAEjC,MAAM,SAAS,GAAG,cAAc,C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