@ilands/payments 0.0.0-stage → 0.1.0-next.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/README.md +76 -2
- package/dist/base44.d.ts +12 -0
- package/dist/base44.js +27 -0
- package/dist/client.d.ts +39 -0
- package/dist/client.js +103 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/server.d.ts +67 -0
- package/dist/server.js +224 -0
- package/dist/types.d.ts +201 -0
- package/dist/types.js +15 -0
- package/package.json +43 -4
package/README.md
CHANGED
|
@@ -1,3 +1,77 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@ilands/payments`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Thin, zero-dependency payment SDK for Agent-built websites (Base44 and custom hosts) backed by iLands's unified Stripe checkout, transaction snapshot, delivery evidence, and after-sales infrastructure.
|
|
4
|
+
|
|
5
|
+
## Entrypoints
|
|
6
|
+
|
|
7
|
+
- `@ilands/payments/server` — For Base44 Backend Functions / Deno / Node / CF Workers. Uses `fetch` + WebCrypto only.
|
|
8
|
+
- `@ilands/payments/client` — For website frontends (standalone browser and iLands mobile WebView).
|
|
9
|
+
- `@ilands/payments/base44` — Versioned `custom_instructions` template (`buildBase44PaymentInstructions`) injected into Base44 apps.
|
|
10
|
+
|
|
11
|
+
## Quickstart (Base44 Backend Function)
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { createILandsPayments } from "@ilands/payments/server";
|
|
15
|
+
|
|
16
|
+
const ilands = createILandsPayments({
|
|
17
|
+
secretKey: process.env.ILANDS_PAYMENT_SECRET_KEY!, // ilp_test_sk_* or ilp_live_sk_*
|
|
18
|
+
webhookSecret: process.env.ILANDS_PAYMENT_WEBHOOK_SECRET!, // ilp_whsec_*
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// 1. Create checkout after computing price server-side
|
|
22
|
+
const created = await ilands.payments.create({
|
|
23
|
+
merchantOrderId: order.id,
|
|
24
|
+
amountCents: product.priceCents,
|
|
25
|
+
terms: {
|
|
26
|
+
title: product.title,
|
|
27
|
+
description: product.description,
|
|
28
|
+
deliveryType: "digital_download",
|
|
29
|
+
deliverySummary: "Instant ZIP download after payment",
|
|
30
|
+
refundPolicy: "no_refund_after_download",
|
|
31
|
+
},
|
|
32
|
+
buyer: { siteUserId: user?.id ?? null, email: user?.email ?? null },
|
|
33
|
+
returnUrl: `https://my-site.base44.app/orders/${order.id}`,
|
|
34
|
+
cancelUrl: "https://my-site.base44.app/pricing",
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// 2. Handle inbound webhook from iLands (raw body required!)
|
|
38
|
+
const event = await ilands.webhooks.verifyAndParse({
|
|
39
|
+
rawBody: await req.text(),
|
|
40
|
+
signatureHeader: req.headers.get("x-ilands-signature"),
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
if (event.type === "payment.paid") {
|
|
44
|
+
// Idempotently fulfill order, then upload artifact & report delivery:
|
|
45
|
+
const artifact = await ilands.deliveries.uploadArtifact(event.data.paymentId, {
|
|
46
|
+
filename: "pack.zip",
|
|
47
|
+
contentType: "application/zip",
|
|
48
|
+
bytes: fileBytes,
|
|
49
|
+
});
|
|
50
|
+
await ilands.deliveries.report(event.data.paymentId, {
|
|
51
|
+
idempotencyKey: `deliver:${event.data.merchantOrderId}:v1`,
|
|
52
|
+
deliveryType: "digital_download",
|
|
53
|
+
contentVersion: "1.0.0",
|
|
54
|
+
summary: "Delivered ZIP file",
|
|
55
|
+
artifactId: artifact.artifactId,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Quickstart (Frontend)
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
import { openCheckout, pollOrderStatus, openReceipt } from "@ilands/payments/client";
|
|
64
|
+
|
|
65
|
+
openCheckout({ checkoutUrl: res.checkoutUrl });
|
|
66
|
+
|
|
67
|
+
// On returnUrl page: poll YOUR backend (never trust ?paid=1 in URL)
|
|
68
|
+
const { state } = await pollOrderStatus({
|
|
69
|
+
fetcher: () => fetch(`/api/orders/${orderId}`).then((r) => r.json()),
|
|
70
|
+
isTerminal: (o) => o.status === "delivered" || o.status === "refunded",
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Test vs Live Isolation
|
|
75
|
+
|
|
76
|
+
- `ilp_test_sk_*` credentials use Stripe test mode (`sk_test_*`) and **never** credit live Agent wallets or `ledger_transfers`.
|
|
77
|
+
- `ilp_live_sk_*` credentials run only in live mode after pre-publish verification passes.
|
package/dist/base44.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical Base44 `custom_instructions` template for Agent-built websites
|
|
3
|
+
* integrating `@ilands/payments`.
|
|
4
|
+
*
|
|
5
|
+
* Passed into Base44's `customInstructions` field when creating a site and
|
|
6
|
+
* verified via read-back before allowing live payments.
|
|
7
|
+
*/
|
|
8
|
+
export declare const BASE44_PAYMENT_INSTRUCTIONS_VERSION = "2026-11-26.v1";
|
|
9
|
+
export declare function buildBase44PaymentInstructions(options?: {
|
|
10
|
+
apiBaseUrl?: string;
|
|
11
|
+
webhookPath?: string;
|
|
12
|
+
}): string;
|
package/dist/base44.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical Base44 `custom_instructions` template for Agent-built websites
|
|
3
|
+
* integrating `@ilands/payments`.
|
|
4
|
+
*
|
|
5
|
+
* Passed into Base44's `customInstructions` field when creating a site and
|
|
6
|
+
* verified via read-back before allowing live payments.
|
|
7
|
+
*/
|
|
8
|
+
export const BASE44_PAYMENT_INSTRUCTIONS_VERSION = "2026-11-26.v1";
|
|
9
|
+
export function buildBase44PaymentInstructions(options) {
|
|
10
|
+
const apiBaseUrl = options?.apiBaseUrl ?? "https://staging-edge.ilands.ai";
|
|
11
|
+
const webhookPath = options?.webhookPath ?? "/api/ilands-payments-webhook";
|
|
12
|
+
return [
|
|
13
|
+
`# iLands Payment SDK Integration Rules (${BASE44_PAYMENT_INSTRUCTIONS_VERSION})`,
|
|
14
|
+
"",
|
|
15
|
+
"Use `@ilands/payments` (`@ilands/payments/server` in backend functions, `@ilands/payments/client` in frontend pages) to accept card payments via iLands.",
|
|
16
|
+
"",
|
|
17
|
+
"## Mandatory Security & Reliability Invariants",
|
|
18
|
+
"1. **Server-side pricing only**: The browser MUST send only product/item IDs and quantities. Backend functions MUST look up prices in the site database, create a local order row (`status: 'pending'`), and compute integer `amountCents` on the server. NEVER trust client-supplied prices or totals.",
|
|
19
|
+
"2. **Secrets stay in Backend Secrets**: Read `ILANDS_PAYMENT_SECRET_KEY`, `ILANDS_PAYMENT_WEBHOOK_SECRET`, and `ILANDS_PAYMENT_API_BASE_URL` ONLY inside Base44 Backend Functions. Pass `baseUrl: Deno.env.get('ILANDS_PAYMENT_API_BASE_URL')` to `createILandsPayments(...)`. NEVER hardcode keys, expose them to frontend code, or call Stripe directly.",
|
|
20
|
+
"3. **Freeze immutable terms before checkout**: Always pass complete `terms` (`title`, `deliveryType`, `deliverySummary`, `refundPolicy`) and your local `merchantOrderId` to `ilands.payments.create(...)`. Never overwrite historical order terms when editing catalog descriptions later.",
|
|
21
|
+
`4. **Authoritative fulfillment only**: NEVER deliver files or grant entitlements based on return URL query parameters. Deliver ONLY after verifying the signed webhook at \`${webhookPath}\` via \`ilands.webhooks.verifyAndParse({ rawBody, signatureHeader })\` OR after your backend calls \`ilands.payments.get(paymentId)\` and confirms \`status === "paid"\`, matching \`amountCents\` and \`merchantOrderId\`.`,
|
|
22
|
+
"5. **Idempotent delivery & evidence reporting**: Deduplicate fulfillment by `paymentId`. After delivering, ALWAYS call `ilands.deliveries.report(paymentId, ...)` (and for downloadable files, first upload an immutable copy via `ilands.deliveries.uploadArtifact(paymentId, ...)`). Handle `payment.refunded` and `payment.dispute.closed` by revoking or adjusting entitlements.",
|
|
23
|
+
"6. **Guest recovery & after-sales link**: Persist the `receiptUrl` returned by `ilands.payments.create(...)` on your order record and display it clearly to buyers on the order confirmation page so guests can recover orders and access iLands support without relying on browser localStorage.",
|
|
24
|
+
"",
|
|
25
|
+
`API Base URL: \`${apiBaseUrl}\``,
|
|
26
|
+
].join("\n");
|
|
27
|
+
}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser & WebView entrypoint (`@ilands/payments/client`).
|
|
3
|
+
*
|
|
4
|
+
* Security model: the browser NEVER creates Stripe checkouts directly, NEVER
|
|
5
|
+
* holds a site secret key, and NEVER trusts `?paid=1` query params on redirect.
|
|
6
|
+
* It opens the Stripe Hosted Checkout URL returned by the website's own backend
|
|
7
|
+
* and polls the website's backend to observe authoritative fulfillment state.
|
|
8
|
+
*/
|
|
9
|
+
export interface OpenCheckoutOptions {
|
|
10
|
+
/** Stripe Hosted Checkout URL returned by your website backend. */
|
|
11
|
+
checkoutUrl: string;
|
|
12
|
+
/** "auto" detects iLands App WebView bridge; "same_tab" navigates window.location; "new_tab" uses window.open. */
|
|
13
|
+
mode?: "auto" | "same_tab" | "new_tab";
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Open Stripe Hosted Checkout safely in standalone browsers or embedded
|
|
17
|
+
* inside the iLands mobile WebView.
|
|
18
|
+
*/
|
|
19
|
+
export declare function openCheckout(options: OpenCheckoutOptions): void;
|
|
20
|
+
/** Open the canonical iLands transaction receipt & after-sales support page. */
|
|
21
|
+
export declare function openReceipt(receiptUrl: string): void;
|
|
22
|
+
export interface PollOrderStatusOptions<T> {
|
|
23
|
+
/** Calls YOUR website backend (which checks DB or falls back to `ilands.payments.get`). */
|
|
24
|
+
fetcher: () => Promise<T>;
|
|
25
|
+
isTerminal: (state: T) => boolean;
|
|
26
|
+
intervalMs?: number;
|
|
27
|
+
timeoutMs?: number;
|
|
28
|
+
signal?: AbortSignal;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Poll your website backend on the return page after checkout until payment
|
|
32
|
+
* confirmation and fulfillment settle (or timeout). Never mark an order paid
|
|
33
|
+
* solely from browser return URL parameters.
|
|
34
|
+
*/
|
|
35
|
+
export declare function pollOrderStatus<T>(options: PollOrderStatusOptions<T>): Promise<{
|
|
36
|
+
settled: boolean;
|
|
37
|
+
state: T;
|
|
38
|
+
}>;
|
|
39
|
+
export * from "./types.js";
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser & WebView entrypoint (`@ilands/payments/client`).
|
|
3
|
+
*
|
|
4
|
+
* Security model: the browser NEVER creates Stripe checkouts directly, NEVER
|
|
5
|
+
* holds a site secret key, and NEVER trusts `?paid=1` query params on redirect.
|
|
6
|
+
* It opens the Stripe Hosted Checkout URL returned by the website's own backend
|
|
7
|
+
* and polls the website's backend to observe authoritative fulfillment state.
|
|
8
|
+
*/
|
|
9
|
+
function assertSafeCheckoutUrl(raw) {
|
|
10
|
+
let parsed;
|
|
11
|
+
try {
|
|
12
|
+
parsed = new URL(raw);
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
throw new Error("Invalid checkoutUrl");
|
|
16
|
+
}
|
|
17
|
+
if (parsed.protocol !== "https:") {
|
|
18
|
+
throw new Error("checkoutUrl must use https:");
|
|
19
|
+
}
|
|
20
|
+
const host = parsed.hostname.toLowerCase();
|
|
21
|
+
if (host !== "checkout.stripe.com" && !host.endsWith(".stripe.com")) {
|
|
22
|
+
throw new Error("checkoutUrl must point to Stripe Hosted Checkout");
|
|
23
|
+
}
|
|
24
|
+
return parsed.toString();
|
|
25
|
+
}
|
|
26
|
+
function assertSafeReceiptUrl(raw) {
|
|
27
|
+
let parsed;
|
|
28
|
+
try {
|
|
29
|
+
parsed = new URL(raw);
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
throw new Error("Invalid receiptUrl");
|
|
33
|
+
}
|
|
34
|
+
if (parsed.protocol !== "https:") {
|
|
35
|
+
throw new Error("receiptUrl must use https:");
|
|
36
|
+
}
|
|
37
|
+
return parsed.toString();
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Open Stripe Hosted Checkout safely in standalone browsers or embedded
|
|
41
|
+
* inside the iLands mobile WebView.
|
|
42
|
+
*/
|
|
43
|
+
export function openCheckout(options) {
|
|
44
|
+
const safeUrl = assertSafeCheckoutUrl(options.checkoutUrl);
|
|
45
|
+
const win = window;
|
|
46
|
+
const mode = options.mode ?? "auto";
|
|
47
|
+
if (mode === "auto") {
|
|
48
|
+
if (typeof win.ilands?.openExternalUrl === "function") {
|
|
49
|
+
win.ilands.openExternalUrl(safeUrl);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (typeof win.ReactNativeWebView?.postMessage === "function") {
|
|
53
|
+
win.ReactNativeWebView.postMessage(JSON.stringify({ type: "ilands.payments.open_checkout", url: safeUrl }));
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (mode === "new_tab") {
|
|
58
|
+
const opened = win.open(safeUrl, "_blank", "noopener,noreferrer");
|
|
59
|
+
if (!opened) {
|
|
60
|
+
win.location.assign(safeUrl);
|
|
61
|
+
}
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
win.location.assign(safeUrl);
|
|
65
|
+
}
|
|
66
|
+
/** Open the canonical iLands transaction receipt & after-sales support page. */
|
|
67
|
+
export function openReceipt(receiptUrl) {
|
|
68
|
+
const safeUrl = assertSafeReceiptUrl(receiptUrl);
|
|
69
|
+
const opened = window.open(safeUrl, "_blank", "noopener,noreferrer");
|
|
70
|
+
if (!opened) {
|
|
71
|
+
window.location.assign(safeUrl);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Poll your website backend on the return page after checkout until payment
|
|
76
|
+
* confirmation and fulfillment settle (or timeout). Never mark an order paid
|
|
77
|
+
* solely from browser return URL parameters.
|
|
78
|
+
*/
|
|
79
|
+
export async function pollOrderStatus(options) {
|
|
80
|
+
const intervalMs = Math.max(500, options.intervalMs ?? 1_500);
|
|
81
|
+
const timeoutMs = Math.max(intervalMs, options.timeoutMs ?? 30_000);
|
|
82
|
+
const deadline = Date.now() + timeoutMs;
|
|
83
|
+
let latest = await options.fetcher();
|
|
84
|
+
while (!options.isTerminal(latest) && Date.now() < deadline) {
|
|
85
|
+
if (options.signal?.aborted)
|
|
86
|
+
break;
|
|
87
|
+
await new Promise((resolve) => {
|
|
88
|
+
const timer = setTimeout(resolve, intervalMs);
|
|
89
|
+
options.signal?.addEventListener("abort", () => {
|
|
90
|
+
clearTimeout(timer);
|
|
91
|
+
resolve();
|
|
92
|
+
}, { once: true });
|
|
93
|
+
});
|
|
94
|
+
if (options.signal?.aborted)
|
|
95
|
+
break;
|
|
96
|
+
latest = await options.fetcher();
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
settled: options.isTerminal(latest),
|
|
100
|
+
state: latest,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
export * from "./types.js";
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-side SDK entrypoint (`@ilands/payments/server`) for Base44 Backend
|
|
3
|
+
* Functions, Cloudflare Workers, Deno, and Node >= 20.
|
|
4
|
+
*
|
|
5
|
+
* Uses ONLY standard WebCrypto (`crypto.subtle`) and `fetch` — zero Node-only
|
|
6
|
+
* or third-party dependencies.
|
|
7
|
+
*/
|
|
8
|
+
import { type CreatedSitePayment, type CreatePaymentInput, type PaymentDeliveryRecord, type PaymentRefundRecord, type ReportDeliveryInput, type RequestRefundInput, type SitePaymentDetail, type SitePaymentWebhookEvent, type UploadArtifactInput, type UploadedArtifact } from "./types.js";
|
|
9
|
+
export interface ILandsPaymentsServerConfig {
|
|
10
|
+
/** Per-site secret key (`ilp_live_sk_*` or `ilp_test_sk_*`). Never expose to browsers. */
|
|
11
|
+
secretKey: string;
|
|
12
|
+
/** Per-site webhook signing secret (`ilp_whsec_*`) used to verify inbound webhooks. */
|
|
13
|
+
webhookSecret?: string;
|
|
14
|
+
/** Defaults to `https://api.ilands.ai`. */
|
|
15
|
+
baseUrl?: string;
|
|
16
|
+
timeoutMs?: number;
|
|
17
|
+
fetch?: typeof fetch;
|
|
18
|
+
}
|
|
19
|
+
export declare function verifyWebhookSignature(params: {
|
|
20
|
+
rawBody: string;
|
|
21
|
+
signatureHeader: string | null | undefined;
|
|
22
|
+
webhookSecret: string;
|
|
23
|
+
nowEpochSeconds?: number;
|
|
24
|
+
toleranceSeconds?: number;
|
|
25
|
+
}): Promise<{
|
|
26
|
+
ok: true;
|
|
27
|
+
timestamp: number;
|
|
28
|
+
} | {
|
|
29
|
+
ok: false;
|
|
30
|
+
reason: string;
|
|
31
|
+
}>;
|
|
32
|
+
export declare function createILandsPayments(config: ILandsPaymentsServerConfig): {
|
|
33
|
+
payments: {
|
|
34
|
+
/** Freeze terms snapshot and create (or idempotently reuse) a Stripe Hosted Checkout session. */
|
|
35
|
+
create(input: CreatePaymentInput): Promise<CreatedSitePayment>;
|
|
36
|
+
/** Fetch authoritative payment, delivery, refund, and dispute state by paymentId. */
|
|
37
|
+
get(paymentId: string): Promise<SitePaymentDetail>;
|
|
38
|
+
/** Fetch authoritative payment state by your own website's merchantOrderId. */
|
|
39
|
+
getByMerchantOrderId(merchantOrderId: string): Promise<SitePaymentDetail>;
|
|
40
|
+
/** Request a Stripe refund (requires `refunds:request` scope on the site credential). */
|
|
41
|
+
refund(paymentId: string, input: RequestRefundInput): Promise<PaymentRefundRecord>;
|
|
42
|
+
};
|
|
43
|
+
deliveries: {
|
|
44
|
+
/**
|
|
45
|
+
* Upload an immutable deliverable file copy into iLands private R2
|
|
46
|
+
* evidence storage before calling `deliveries.report`.
|
|
47
|
+
*/
|
|
48
|
+
uploadArtifact(paymentId: string, input: UploadArtifactInput): Promise<UploadedArtifact>;
|
|
49
|
+
/** Append an immutable delivery proof record (never overwrites prior proofs). */
|
|
50
|
+
report(paymentId: string, input: ReportDeliveryInput): Promise<PaymentDeliveryRecord>;
|
|
51
|
+
};
|
|
52
|
+
webhooks: {
|
|
53
|
+
/**
|
|
54
|
+
* Verify `X-iLands-Signature` over the RAW request body and return the
|
|
55
|
+
* strongly typed event object. Throws `ILandsPaymentsError` on invalid
|
|
56
|
+
* signature or expired timestamp.
|
|
57
|
+
*/
|
|
58
|
+
verifyAndParse(params: {
|
|
59
|
+
rawBody: string;
|
|
60
|
+
signatureHeader: string | null | undefined;
|
|
61
|
+
webhookSecret?: string;
|
|
62
|
+
toleranceSeconds?: number;
|
|
63
|
+
nowEpochSeconds?: number;
|
|
64
|
+
}): Promise<SitePaymentWebhookEvent>;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
export * from "./types.js";
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-side SDK entrypoint (`@ilands/payments/server`) for Base44 Backend
|
|
3
|
+
* Functions, Cloudflare Workers, Deno, and Node >= 20.
|
|
4
|
+
*
|
|
5
|
+
* Uses ONLY standard WebCrypto (`crypto.subtle`) and `fetch` — zero Node-only
|
|
6
|
+
* or third-party dependencies.
|
|
7
|
+
*/
|
|
8
|
+
import { ILandsPaymentsError, } from "./types.js";
|
|
9
|
+
const DEFAULT_API_BASE_URL = "https://api.ilands.ai";
|
|
10
|
+
const DEFAULT_WEBHOOK_TOLERANCE_SECONDS = 300;
|
|
11
|
+
const DEFAULT_TIMEOUT_MS = 20_000;
|
|
12
|
+
function bytesToHex(bytes) {
|
|
13
|
+
let out = "";
|
|
14
|
+
for (let i = 0; i < bytes.length; i += 1) {
|
|
15
|
+
out += bytes[i].toString(16).padStart(2, "0");
|
|
16
|
+
}
|
|
17
|
+
return out;
|
|
18
|
+
}
|
|
19
|
+
function hexToBytes(hex) {
|
|
20
|
+
if (hex.length === 0 || hex.length % 2 !== 0 || !/^[0-9a-f]+$/i.test(hex)) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const out = new Uint8Array(hex.length / 2);
|
|
24
|
+
for (let i = 0; i < out.length; i += 1) {
|
|
25
|
+
out[i] = Number.parseInt(hex.slice(i * 2, i * 2 + 2), 16);
|
|
26
|
+
}
|
|
27
|
+
return out;
|
|
28
|
+
}
|
|
29
|
+
function constantTimeEqual(a, b) {
|
|
30
|
+
if (a.length !== b.length)
|
|
31
|
+
return false;
|
|
32
|
+
let diff = 0;
|
|
33
|
+
for (let i = 0; i < a.length; i += 1)
|
|
34
|
+
diff |= a[i] ^ b[i];
|
|
35
|
+
return diff === 0;
|
|
36
|
+
}
|
|
37
|
+
async function sha256HexBytes(bytes) {
|
|
38
|
+
const copy = new Uint8Array(bytes.byteLength);
|
|
39
|
+
copy.set(bytes);
|
|
40
|
+
const digest = await crypto.subtle.digest("SHA-256", copy);
|
|
41
|
+
return bytesToHex(new Uint8Array(digest));
|
|
42
|
+
}
|
|
43
|
+
async function hmacSha256Hex(secret, message) {
|
|
44
|
+
const encoder = new TextEncoder();
|
|
45
|
+
const key = await crypto.subtle.importKey("raw", encoder.encode(secret), { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
|
|
46
|
+
const mac = await crypto.subtle.sign("HMAC", key, encoder.encode(message));
|
|
47
|
+
return bytesToHex(new Uint8Array(mac));
|
|
48
|
+
}
|
|
49
|
+
function asRecord(value) {
|
|
50
|
+
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
51
|
+
? value
|
|
52
|
+
: {};
|
|
53
|
+
}
|
|
54
|
+
export async function verifyWebhookSignature(params) {
|
|
55
|
+
if (!params.signatureHeader) {
|
|
56
|
+
return { ok: false, reason: "malformed_header" };
|
|
57
|
+
}
|
|
58
|
+
let timestamp = null;
|
|
59
|
+
const signatures = [];
|
|
60
|
+
for (const part of params.signatureHeader.split(",")) {
|
|
61
|
+
const trimmed = part.trim();
|
|
62
|
+
const eq = trimmed.indexOf("=");
|
|
63
|
+
if (eq <= 0)
|
|
64
|
+
continue;
|
|
65
|
+
const key = trimmed.slice(0, eq);
|
|
66
|
+
const val = trimmed.slice(eq + 1);
|
|
67
|
+
if (key === "t") {
|
|
68
|
+
const parsed = Number(val);
|
|
69
|
+
if (Number.isInteger(parsed) && parsed > 0)
|
|
70
|
+
timestamp = parsed;
|
|
71
|
+
}
|
|
72
|
+
else if (key === "v1" && /^[0-9a-f]{64}$/i.test(val)) {
|
|
73
|
+
signatures.push(val.toLowerCase());
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (timestamp === null || signatures.length === 0) {
|
|
77
|
+
return { ok: false, reason: "malformed_header" };
|
|
78
|
+
}
|
|
79
|
+
const now = params.nowEpochSeconds ?? Math.floor(Date.now() / 1000);
|
|
80
|
+
const tolerance = params.toleranceSeconds ?? DEFAULT_WEBHOOK_TOLERANCE_SECONDS;
|
|
81
|
+
if (Math.abs(now - timestamp) > tolerance) {
|
|
82
|
+
return { ok: false, reason: "timestamp_out_of_tolerance" };
|
|
83
|
+
}
|
|
84
|
+
const expectedHex = await hmacSha256Hex(params.webhookSecret, `${timestamp}.${params.rawBody}`);
|
|
85
|
+
const expectedBytes = hexToBytes(expectedHex);
|
|
86
|
+
if (!expectedBytes)
|
|
87
|
+
return { ok: false, reason: "signature_mismatch" };
|
|
88
|
+
for (const sig of signatures) {
|
|
89
|
+
const provided = hexToBytes(sig);
|
|
90
|
+
if (provided && constantTimeEqual(expectedBytes, provided)) {
|
|
91
|
+
return { ok: true, timestamp };
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return { ok: false, reason: "signature_mismatch" };
|
|
95
|
+
}
|
|
96
|
+
export function createILandsPayments(config) {
|
|
97
|
+
const secretKey = config.secretKey.trim();
|
|
98
|
+
if (!secretKey.startsWith("ilp_live_sk_") && !secretKey.startsWith("ilp_test_sk_")) {
|
|
99
|
+
throw new ILandsPaymentsError("INVALID_SECRET_KEY", 0, "secretKey must start with ilp_live_sk_ or ilp_test_sk_");
|
|
100
|
+
}
|
|
101
|
+
const baseUrl = (config.baseUrl ?? DEFAULT_API_BASE_URL).replace(/\/+$/, "");
|
|
102
|
+
const timeoutMs = config.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
103
|
+
const fetcher = config.fetch ?? fetch;
|
|
104
|
+
async function request(method, path, body) {
|
|
105
|
+
const response = await fetcher(`${baseUrl}${path}`, {
|
|
106
|
+
method,
|
|
107
|
+
headers: {
|
|
108
|
+
Authorization: `Bearer ${secretKey}`,
|
|
109
|
+
...(body !== undefined ? { "Content-Type": "application/json" } : {}),
|
|
110
|
+
},
|
|
111
|
+
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
112
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
113
|
+
});
|
|
114
|
+
const parsed = asRecord(await response.json().catch(() => ({})));
|
|
115
|
+
if (!response.ok) {
|
|
116
|
+
const err = asRecord(parsed["error"]);
|
|
117
|
+
throw new ILandsPaymentsError(typeof err["code"] === "string" ? err["code"] : `HTTP_${response.status}`, response.status, typeof err["message"] === "string"
|
|
118
|
+
? err["message"]
|
|
119
|
+
: `iLands Payments API failed with HTTP ${response.status}`, err["issues"]);
|
|
120
|
+
}
|
|
121
|
+
return parsed["data"];
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
payments: {
|
|
125
|
+
/** Freeze terms snapshot and create (or idempotently reuse) a Stripe Hosted Checkout session. */
|
|
126
|
+
create(input) {
|
|
127
|
+
return request("POST", "/api/v1/site-payments", {
|
|
128
|
+
...input,
|
|
129
|
+
currency: input.currency ?? "usd",
|
|
130
|
+
});
|
|
131
|
+
},
|
|
132
|
+
/** Fetch authoritative payment, delivery, refund, and dispute state by paymentId. */
|
|
133
|
+
get(paymentId) {
|
|
134
|
+
return request("GET", `/api/v1/site-payments/${encodeURIComponent(paymentId)}`);
|
|
135
|
+
},
|
|
136
|
+
/** Fetch authoritative payment state by your own website's merchantOrderId. */
|
|
137
|
+
getByMerchantOrderId(merchantOrderId) {
|
|
138
|
+
return request("GET", `/api/v1/site-payments/by-order/${encodeURIComponent(merchantOrderId)}`);
|
|
139
|
+
},
|
|
140
|
+
/** Request a Stripe refund (requires `refunds:request` scope on the site credential). */
|
|
141
|
+
refund(paymentId, input) {
|
|
142
|
+
return request("POST", `/api/v1/site-payments/${encodeURIComponent(paymentId)}/refunds`, input);
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
deliveries: {
|
|
146
|
+
/**
|
|
147
|
+
* Upload an immutable deliverable file copy into iLands private R2
|
|
148
|
+
* evidence storage before calling `deliveries.report`.
|
|
149
|
+
*/
|
|
150
|
+
async uploadArtifact(paymentId, input) {
|
|
151
|
+
const bytes = input.bytes instanceof Uint8Array
|
|
152
|
+
? input.bytes
|
|
153
|
+
: new Uint8Array(input.bytes);
|
|
154
|
+
const sha256 = await sha256HexBytes(bytes);
|
|
155
|
+
const presigned = await request("POST", `/api/v1/site-payments/${encodeURIComponent(paymentId)}/deliveries/upload-url`, {
|
|
156
|
+
filename: input.filename,
|
|
157
|
+
contentType: input.contentType,
|
|
158
|
+
sizeBytes: bytes.byteLength,
|
|
159
|
+
sha256,
|
|
160
|
+
});
|
|
161
|
+
const uploadBody = new Uint8Array(bytes.byteLength);
|
|
162
|
+
uploadBody.set(bytes);
|
|
163
|
+
const putRes = await fetcher(presigned.uploadUrl, {
|
|
164
|
+
method: "PUT",
|
|
165
|
+
headers: presigned.requiredHeaders,
|
|
166
|
+
body: uploadBody,
|
|
167
|
+
signal: AbortSignal.timeout(Math.max(timeoutMs, 60_000)),
|
|
168
|
+
});
|
|
169
|
+
if (!putRes.ok) {
|
|
170
|
+
throw new ILandsPaymentsError("ARTIFACT_UPLOAD_FAILED", putRes.status, `Failed to upload delivery artifact to storage (HTTP ${putRes.status})`);
|
|
171
|
+
}
|
|
172
|
+
return {
|
|
173
|
+
artifactId: presigned.artifactId,
|
|
174
|
+
sha256,
|
|
175
|
+
sizeBytes: bytes.byteLength,
|
|
176
|
+
};
|
|
177
|
+
},
|
|
178
|
+
/** Append an immutable delivery proof record (never overwrites prior proofs). */
|
|
179
|
+
report(paymentId, input) {
|
|
180
|
+
return request("POST", `/api/v1/site-payments/${encodeURIComponent(paymentId)}/deliveries`, input);
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
webhooks: {
|
|
184
|
+
/**
|
|
185
|
+
* Verify `X-iLands-Signature` over the RAW request body and return the
|
|
186
|
+
* strongly typed event object. Throws `ILandsPaymentsError` on invalid
|
|
187
|
+
* signature or expired timestamp.
|
|
188
|
+
*/
|
|
189
|
+
async verifyAndParse(params) {
|
|
190
|
+
const secret = (params.webhookSecret ?? config.webhookSecret ?? "").trim();
|
|
191
|
+
if (!secret) {
|
|
192
|
+
throw new ILandsPaymentsError("WEBHOOK_SECRET_MISSING", 0, "webhookSecret is required to verify inbound webhooks");
|
|
193
|
+
}
|
|
194
|
+
const verdict = await verifyWebhookSignature({
|
|
195
|
+
rawBody: params.rawBody,
|
|
196
|
+
signatureHeader: params.signatureHeader,
|
|
197
|
+
webhookSecret: secret,
|
|
198
|
+
toleranceSeconds: params.toleranceSeconds,
|
|
199
|
+
nowEpochSeconds: params.nowEpochSeconds,
|
|
200
|
+
});
|
|
201
|
+
if (!verdict.ok) {
|
|
202
|
+
throw new ILandsPaymentsError("INVALID_WEBHOOK_SIGNATURE", 400, `Webhook signature verification failed: ${verdict.reason}`);
|
|
203
|
+
}
|
|
204
|
+
let parsed;
|
|
205
|
+
try {
|
|
206
|
+
parsed = JSON.parse(params.rawBody);
|
|
207
|
+
}
|
|
208
|
+
catch {
|
|
209
|
+
throw new ILandsPaymentsError("INVALID_WEBHOOK_PAYLOAD", 400, "Webhook body is not valid JSON");
|
|
210
|
+
}
|
|
211
|
+
const obj = asRecord(parsed);
|
|
212
|
+
const type = obj["type"];
|
|
213
|
+
if (type !== "payment.paid" &&
|
|
214
|
+
type !== "payment.refunded" &&
|
|
215
|
+
type !== "payment.dispute.created" &&
|
|
216
|
+
type !== "payment.dispute.closed") {
|
|
217
|
+
throw new ILandsPaymentsError("UNSUPPORTED_WEBHOOK_EVENT", 400, `Unsupported webhook event type: ${String(type)}`);
|
|
218
|
+
}
|
|
219
|
+
return obj;
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
export * from "./types.js";
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared public types for `@ilands/payments` (zero runtime dependencies).
|
|
3
|
+
*/
|
|
4
|
+
export type PaymentMode = "test" | "live";
|
|
5
|
+
export type PaymentStatus = "creating" | "pending" | "paid" | "partially_refunded" | "refunded" | "expired" | "canceled";
|
|
6
|
+
export type DeliveryType = "digital_download" | "entitlement" | "service";
|
|
7
|
+
export type VerificationLevel = "site_reported" | "system_verified" | "buyer_confirmed";
|
|
8
|
+
export type RefundPolicy = "refundable" | "no_refund_after_download" | "no_refund_after_delivery" | "custom";
|
|
9
|
+
export interface PaymentTermsInput {
|
|
10
|
+
/** Short buyer-facing title displayed on Stripe Checkout and receipts (1-120 chars). */
|
|
11
|
+
title: string;
|
|
12
|
+
/** Optional detailed description frozen onto the order snapshot. */
|
|
13
|
+
description?: string | null;
|
|
14
|
+
deliveryType: DeliveryType;
|
|
15
|
+
/** Plain-text description of what and when the buyer receives (1-500 chars). */
|
|
16
|
+
deliverySummary: string;
|
|
17
|
+
refundPolicy: RefundPolicy;
|
|
18
|
+
/** Optional custom refund policy terms frozen at checkout time. */
|
|
19
|
+
policyText?: string | null;
|
|
20
|
+
/** Optional entitlement duration (e.g. "30d", "lifetime", or ISO date). */
|
|
21
|
+
entitlementDuration?: string | null;
|
|
22
|
+
}
|
|
23
|
+
export interface CreatePaymentInput {
|
|
24
|
+
/** Unique order ID in the website's own database. Serves as the creation idempotency key. */
|
|
25
|
+
merchantOrderId: string;
|
|
26
|
+
/** Price in integer USD cents (e.g. 500 = $5.00). Must be computed server-side. */
|
|
27
|
+
amountCents: number;
|
|
28
|
+
currency?: "usd";
|
|
29
|
+
terms: PaymentTermsInput;
|
|
30
|
+
buyer?: {
|
|
31
|
+
siteUserId?: string | null;
|
|
32
|
+
email?: string | null;
|
|
33
|
+
};
|
|
34
|
+
returnUrl: string;
|
|
35
|
+
cancelUrl: string;
|
|
36
|
+
metadata?: Record<string, unknown>;
|
|
37
|
+
}
|
|
38
|
+
export interface PaymentTermsSnapshot {
|
|
39
|
+
title: string;
|
|
40
|
+
description: string | null;
|
|
41
|
+
deliveryType: DeliveryType;
|
|
42
|
+
deliverySummary: string;
|
|
43
|
+
refundPolicy: RefundPolicy;
|
|
44
|
+
policyText: string | null;
|
|
45
|
+
entitlementDuration: string | null;
|
|
46
|
+
}
|
|
47
|
+
export interface SitePayment {
|
|
48
|
+
paymentId: string;
|
|
49
|
+
siteId: string;
|
|
50
|
+
mode: PaymentMode;
|
|
51
|
+
merchantOrderId: string;
|
|
52
|
+
status: PaymentStatus;
|
|
53
|
+
amountCents: number;
|
|
54
|
+
currency: string;
|
|
55
|
+
checkoutUrl: string | null;
|
|
56
|
+
expiresAt: string | null;
|
|
57
|
+
returnUrl: string;
|
|
58
|
+
cancelUrl: string;
|
|
59
|
+
receiptUrl: string;
|
|
60
|
+
siteBuyerRef: string | null;
|
|
61
|
+
payerEmail: string | null;
|
|
62
|
+
paidGrossCents: number | null;
|
|
63
|
+
paidAt: string | null;
|
|
64
|
+
refundedCents: number;
|
|
65
|
+
legalHold: boolean;
|
|
66
|
+
terms: PaymentTermsSnapshot;
|
|
67
|
+
termsSnapshotHash: string;
|
|
68
|
+
metadata: Record<string, unknown>;
|
|
69
|
+
createdAt: string;
|
|
70
|
+
updatedAt: string;
|
|
71
|
+
}
|
|
72
|
+
export interface CreatedSitePayment extends SitePayment {
|
|
73
|
+
/** Present on first creation; store or pass to buyer for guest receipt/support access. */
|
|
74
|
+
guestAccessToken?: string;
|
|
75
|
+
}
|
|
76
|
+
export interface PaymentDeliveryRecord {
|
|
77
|
+
id: string;
|
|
78
|
+
payment_id: string;
|
|
79
|
+
site_id: string;
|
|
80
|
+
idempotency_key: string;
|
|
81
|
+
delivery_type: DeliveryType;
|
|
82
|
+
verification_level: VerificationLevel;
|
|
83
|
+
content_version: string | null;
|
|
84
|
+
summary: string;
|
|
85
|
+
entitlement_snapshot: Record<string, unknown> | null;
|
|
86
|
+
artifact_id: string | null;
|
|
87
|
+
artifact_r2_key: string | null;
|
|
88
|
+
artifact_sha256: string | null;
|
|
89
|
+
artifact_size_bytes: number | null;
|
|
90
|
+
artifact_content_type: string | null;
|
|
91
|
+
retention_until: string | null;
|
|
92
|
+
created_at: string;
|
|
93
|
+
}
|
|
94
|
+
export interface PaymentRefundRecord {
|
|
95
|
+
id: string;
|
|
96
|
+
payment_id: string;
|
|
97
|
+
idempotency_key: string;
|
|
98
|
+
initiated_by: "site_api" | "admin_support" | "system_duplicate";
|
|
99
|
+
amount_cents: number;
|
|
100
|
+
reason: string;
|
|
101
|
+
stripe_refund_id: string | null;
|
|
102
|
+
status: "requested" | "pending" | "succeeded" | "failed" | "canceled";
|
|
103
|
+
failure_reason: string | null;
|
|
104
|
+
created_at: string;
|
|
105
|
+
updated_at: string;
|
|
106
|
+
}
|
|
107
|
+
export interface PaymentDisputeRecord {
|
|
108
|
+
id: string;
|
|
109
|
+
payment_id: string;
|
|
110
|
+
stripe_dispute_id: string;
|
|
111
|
+
amount_cents: number;
|
|
112
|
+
reason: string | null;
|
|
113
|
+
status: string;
|
|
114
|
+
evidence_due_by: string | null;
|
|
115
|
+
closed_outcome: "won" | "lost" | null;
|
|
116
|
+
created_at: string;
|
|
117
|
+
updated_at: string;
|
|
118
|
+
}
|
|
119
|
+
export interface SitePaymentDetail extends SitePayment {
|
|
120
|
+
deliveries: PaymentDeliveryRecord[];
|
|
121
|
+
refunds: PaymentRefundRecord[];
|
|
122
|
+
disputes: PaymentDisputeRecord[];
|
|
123
|
+
}
|
|
124
|
+
export interface UploadArtifactInput {
|
|
125
|
+
filename: string;
|
|
126
|
+
contentType: string;
|
|
127
|
+
bytes: Uint8Array | ArrayBuffer;
|
|
128
|
+
}
|
|
129
|
+
export interface UploadedArtifact {
|
|
130
|
+
artifactId: string;
|
|
131
|
+
sha256: string;
|
|
132
|
+
sizeBytes: number;
|
|
133
|
+
}
|
|
134
|
+
export interface ReportDeliveryInput {
|
|
135
|
+
idempotencyKey: string;
|
|
136
|
+
deliveryType: DeliveryType;
|
|
137
|
+
contentVersion?: string | null;
|
|
138
|
+
summary: string;
|
|
139
|
+
artifactId?: string | null;
|
|
140
|
+
entitlement?: Record<string, unknown> | null;
|
|
141
|
+
}
|
|
142
|
+
export interface RequestRefundInput {
|
|
143
|
+
idempotencyKey: string;
|
|
144
|
+
amountCents?: number;
|
|
145
|
+
reason?: "duplicate" | "fraudulent" | "requested_by_customer";
|
|
146
|
+
note?: string;
|
|
147
|
+
}
|
|
148
|
+
export type WebhookEventType = "payment.paid" | "payment.refunded" | "payment.dispute.created" | "payment.dispute.closed";
|
|
149
|
+
export interface WebhookEventBaseData {
|
|
150
|
+
paymentId: string;
|
|
151
|
+
siteId: string;
|
|
152
|
+
mode: PaymentMode;
|
|
153
|
+
merchantOrderId: string;
|
|
154
|
+
amountCents: number;
|
|
155
|
+
currency: string;
|
|
156
|
+
siteBuyerRef: string | null;
|
|
157
|
+
termsSnapshotHash: string;
|
|
158
|
+
metadata: Record<string, unknown>;
|
|
159
|
+
}
|
|
160
|
+
export type SitePaymentWebhookEvent = {
|
|
161
|
+
type: "payment.paid";
|
|
162
|
+
occurredAt: string;
|
|
163
|
+
data: WebhookEventBaseData & {
|
|
164
|
+
status: "paid";
|
|
165
|
+
paidGrossCents: number;
|
|
166
|
+
payerEmail: string | null;
|
|
167
|
+
stripeSessionId: string;
|
|
168
|
+
};
|
|
169
|
+
} | {
|
|
170
|
+
type: "payment.refunded";
|
|
171
|
+
occurredAt: string;
|
|
172
|
+
data: WebhookEventBaseData & {
|
|
173
|
+
status: "partially_refunded" | "refunded";
|
|
174
|
+
refundedCents: number;
|
|
175
|
+
fullRefund: boolean;
|
|
176
|
+
};
|
|
177
|
+
} | {
|
|
178
|
+
type: "payment.dispute.created";
|
|
179
|
+
occurredAt: string;
|
|
180
|
+
data: WebhookEventBaseData & {
|
|
181
|
+
stripeDisputeId: string;
|
|
182
|
+
disputeStatus: string;
|
|
183
|
+
reason: string | null;
|
|
184
|
+
closedOutcome: null;
|
|
185
|
+
};
|
|
186
|
+
} | {
|
|
187
|
+
type: "payment.dispute.closed";
|
|
188
|
+
occurredAt: string;
|
|
189
|
+
data: WebhookEventBaseData & {
|
|
190
|
+
stripeDisputeId: string;
|
|
191
|
+
disputeStatus: string;
|
|
192
|
+
reason: string | null;
|
|
193
|
+
closedOutcome: "won" | "lost" | null;
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
export declare class ILandsPaymentsError extends Error {
|
|
197
|
+
readonly code: string;
|
|
198
|
+
readonly status: number;
|
|
199
|
+
readonly details?: unknown | undefined;
|
|
200
|
+
constructor(code: string, status: number, message: string, details?: unknown | undefined);
|
|
201
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared public types for `@ilands/payments` (zero runtime dependencies).
|
|
3
|
+
*/
|
|
4
|
+
export class ILandsPaymentsError extends Error {
|
|
5
|
+
code;
|
|
6
|
+
status;
|
|
7
|
+
details;
|
|
8
|
+
constructor(code, status, message, details) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.code = code;
|
|
11
|
+
this.status = status;
|
|
12
|
+
this.details = details;
|
|
13
|
+
this.name = "ILandsPaymentsError";
|
|
14
|
+
}
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ilands/payments",
|
|
3
|
-
"version": "0.0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0-next.0",
|
|
4
|
+
"description": "iLands Website Payment SDK — thin server and browser client for Agent-built sites",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/PawLogic/ilands.git",
|
|
13
|
+
"directory": "libs/sdk/payments"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": "./dist/index.js",
|
|
23
|
+
"default": "./dist/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./server": {
|
|
26
|
+
"types": "./dist/server.d.ts",
|
|
27
|
+
"import": "./dist/server.js",
|
|
28
|
+
"default": "./dist/server.js"
|
|
29
|
+
},
|
|
30
|
+
"./client": {
|
|
31
|
+
"types": "./dist/client.d.ts",
|
|
32
|
+
"import": "./dist/client.js",
|
|
33
|
+
"default": "./dist/client.js"
|
|
34
|
+
},
|
|
35
|
+
"./base44": {
|
|
36
|
+
"types": "./dist/base44.d.ts",
|
|
37
|
+
"import": "./dist/base44.js",
|
|
38
|
+
"default": "./dist/base44.js"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "node ../scripts/build.mjs payments",
|
|
43
|
+
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
44
|
+
}
|
|
45
|
+
}
|