suioutkit 1.1.1 → 1.2.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 +11 -12
- package/dist/config/api.d.ts +2 -2
- package/dist/config/modes.d.ts +6 -0
- package/dist/index.d.ts +2 -5
- package/dist/index.js +12 -2
- package/dist/types/index.d.ts +6 -1
- package/package.json +1 -1
- package/src/config/api.ts +2 -3
- package/src/config/modes.ts +16 -0
- package/src/index.ts +8 -5
- package/src/types/index.ts +7 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
Browser SDK for SuiOutKit checkout: create sessions, open a ready-made payment modal, or build a custom UI with helpers.
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
Defaults to the **hosted SuiOutKit API** at `https://api.suioutkit.xyz` (`mode: "live"`). Switch with `mode: "test"` or `mode: "local"` for development. All routes under `/v1/`. The SDK does not perform settlement, treasury checks, or provider calls itself.
|
|
13
13
|
|
|
14
14
|
| Resource | Link |
|
|
15
15
|
|----------|------|
|
|
@@ -47,7 +47,7 @@ import { SuiOutKit } from "suioutkit";
|
|
|
47
47
|
|
|
48
48
|
const sdk = new SuiOutKit({
|
|
49
49
|
merchantAddress: "0xYOUR_MERCHANT_SUI_ADDRESS",
|
|
50
|
-
//
|
|
50
|
+
// mode optional - defaults to "live" (https://api.suioutkit.xyz, mainnet)
|
|
51
51
|
});
|
|
52
52
|
|
|
53
53
|
export function PayButton() {
|
|
@@ -86,14 +86,10 @@ For simple demos you can serve the built SDK bundle from any static host. Build
|
|
|
86
86
|
| Option | Type | Required | Description |
|
|
87
87
|
|--------|------|----------|-------------|
|
|
88
88
|
| `merchantAddress` | `string` | Yes | Sui address that receives settlement |
|
|
89
|
-
| `
|
|
89
|
+
| `mode` | `"local" \| "test" \| "live"` | No | Default: `"live"`. `"local"` → `http://localhost:5000` (testnet), `"test"` → `https://api.staging.suioutkit.xyz` (testnet), `"live"` → `https://api.suioutkit.xyz` (mainnet). |
|
|
90
|
+
| `backendUrl` | `string` | No | Override API origin (no trailing slash). Takes precedence over `mode`. |
|
|
90
91
|
|
|
91
|
-
|
|
92
|
-
The modal reads `window.SuiOutKitNetwork` - set to `"mainnet"` or `"testnet"` before opening the modal if you need a specific network for wallet / outPay flows.
|
|
93
|
-
|
|
94
|
-
```html
|
|
95
|
-
<script>window.SuiOutKitNetwork = "testnet";</script>
|
|
96
|
-
```
|
|
92
|
+
The SDK automatically sets `window.SuiOutKitNetwork` to the correct Sui network based on `mode` - no manual `<script>` tag needed.
|
|
97
93
|
|
|
98
94
|
## API reference
|
|
99
95
|
### `initCheckout(options)`
|
|
@@ -103,6 +99,7 @@ Creates a checkout session on the backend.
|
|
|
103
99
|
const session = await sdk.initCheckout({
|
|
104
100
|
amount: 45000, // integer in major units (e.g. 45000 NGN)
|
|
105
101
|
currency: "NGN", // e.g. "NGN"
|
|
102
|
+
coinType?: "0x2::sui::SUI", // optional: override settlement coin
|
|
106
103
|
metadata?: { orderId: "ORDER-123" },
|
|
107
104
|
});
|
|
108
105
|
```
|
|
@@ -116,6 +113,7 @@ const session = await sdk.initCheckout({
|
|
|
116
113
|
| `amount`, `currency` | Checkout totals |
|
|
117
114
|
| `merchantAddress` | Normalized Sui address |
|
|
118
115
|
| `coinType` | Settlement coin type (from backend config) |
|
|
116
|
+
| `supportedCoins` | Array of `{ symbol, type, decimals }` for available settlement coins |
|
|
119
117
|
| `estimatedRate` | FX preview (NGN → token) when applicable |
|
|
120
118
|
| `packageId`, `cryptoRegistryId`, `cryptoRegistryName` | On-chain config for crypto paths |
|
|
121
119
|
|
|
@@ -158,6 +156,7 @@ Binds checkout to a DOM button.
|
|
|
158
156
|
| `selector` | `string` | CSS selector (e.g. `"#pay-btn"`) |
|
|
159
157
|
| `options.amount` | `number` | Checkout amount |
|
|
160
158
|
| `options.currency` | `string` | e.g. `"NGN"` |
|
|
159
|
+
| `options.coinType` | `string` | Optional settlement coin type override |
|
|
161
160
|
| `options.metadata` | `object` | Optional passthrough to `initCheckout` |
|
|
162
161
|
|
|
163
162
|
---
|
|
@@ -270,7 +269,7 @@ Webhooks (`/v1/checkout/webhook`, `/v1/checkout/stripe-webhook`) are server-to-p
|
|
|
270
269
|
| `409 Treasury insufficient` | Operator vault underfunded for FX settlement amount |
|
|
271
270
|
| Modal stuck on “waiting for settlement” | Webhook not reaching backend (Flutterwave hash, Stripe CLI, or ngrok) |
|
|
272
271
|
| Stripe card errors on small NGN amounts | Backend enforces ~$0.50 USD equivalent minimum |
|
|
273
|
-
| Crypto connect fails | Wrong `
|
|
272
|
+
| Crypto connect fails | Wrong `mode` or registry env on backend |
|
|
274
273
|
| Styles missing | Backend not serving `/style.css` or wrong `backendUrl` |
|
|
275
274
|
|
|
276
275
|
See also [Developer Guide - Troubleshooting](/docs/developer-guide.md#troubleshooting).
|
|
@@ -278,9 +277,9 @@ See also [Developer Guide - Troubleshooting](/docs/developer-guide.md#troublesho
|
|
|
278
277
|
|
|
279
278
|
|
|
280
279
|
## Security
|
|
281
|
-
- Only `merchantAddress` and `backendUrl` belong in browser code.
|
|
280
|
+
- Only `merchantAddress`, `mode`, and `backendUrl` belong in browser code.
|
|
282
281
|
- Never embed operator keys, Flutterwave secrets, or Stripe secret keys in the client.
|
|
283
|
-
- Use **HTTPS** for
|
|
282
|
+
- Use **HTTPS** for the API endpoint in production (default when `mode: "live"`).
|
|
284
283
|
|
|
285
284
|
Report vulnerabilities through your project’s private security channel (do not file public issues with key material).
|
|
286
285
|
|
package/dist/config/api.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/** Production SuiOutKit API origin (versioned paths under /v1/). */
|
|
2
|
-
export declare const DEFAULT_API_ORIGIN = "
|
|
1
|
+
/** Production SuiOutKit API origin (versioned paths under /v1/). Use `mode` config to switch between local/test/live. */
|
|
2
|
+
export declare const DEFAULT_API_ORIGIN = "https://api.suioutkit.xyz";
|
|
3
3
|
/** API version prefix - all checkout and payment routes live under this path. */
|
|
4
4
|
export declare const API_V1_PREFIX = "/v1";
|
|
5
5
|
export declare function joinApiPath(origin: string, ...segments: string[]): string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import { CheckoutSession, CheckoutSessionOptions, CryptoConfirmResponse, SuiOutKitModalOptions } from "./types/index.js";
|
|
1
|
+
import { CheckoutSession, CheckoutSessionOptions, CryptoConfirmResponse, SuiOutKitModalOptions, SuiOutKitConfig } from "./types/index.js";
|
|
2
2
|
import { SuiOutKitModal } from "./components/modal.js";
|
|
3
3
|
export { DEFAULT_API_ORIGIN, API_V1_PREFIX } from "./config/api.js";
|
|
4
4
|
export declare class SuiOutKit {
|
|
5
5
|
private backendUrl;
|
|
6
6
|
private merchantAddress;
|
|
7
|
-
constructor(config:
|
|
8
|
-
merchantAddress: string;
|
|
9
|
-
backendUrl?: string;
|
|
10
|
-
});
|
|
7
|
+
constructor(config: SuiOutKitConfig);
|
|
11
8
|
/**
|
|
12
9
|
* Initializes a brand-new isolated checkout session from the backend.
|
|
13
10
|
*/
|
package/dist/index.js
CHANGED
|
@@ -51981,7 +51981,7 @@ var loadStripe = function loadStripe2() {
|
|
|
51981
51981
|
var import_react = __toESM(require_react());
|
|
51982
51982
|
|
|
51983
51983
|
// src/config/api.ts
|
|
51984
|
-
var DEFAULT_API_ORIGIN = "
|
|
51984
|
+
var DEFAULT_API_ORIGIN = "https://api.suioutkit.xyz";
|
|
51985
51985
|
var API_V1_PREFIX = "/v1";
|
|
51986
51986
|
function joinApiPath(origin, ...segments) {
|
|
51987
51987
|
const base = origin.replace(/\/+$/, "");
|
|
@@ -52912,6 +52912,13 @@ var SuiOutKitModal = class {
|
|
|
52912
52912
|
}
|
|
52913
52913
|
};
|
|
52914
52914
|
|
|
52915
|
+
// src/config/modes.ts
|
|
52916
|
+
var MODE_MAP = {
|
|
52917
|
+
local: { backendUrl: "http://localhost:5000", suiNetwork: "testnet" },
|
|
52918
|
+
test: { backendUrl: "https://api.staging.suioutkit.xyz", suiNetwork: "testnet" },
|
|
52919
|
+
live: { backendUrl: "https://api.suioutkit.xyz", suiNetwork: "mainnet" }
|
|
52920
|
+
};
|
|
52921
|
+
|
|
52915
52922
|
// src/utils/http.ts
|
|
52916
52923
|
var HttpError = class extends Error {
|
|
52917
52924
|
constructor(message, status = null, body = null) {
|
|
@@ -53012,8 +53019,11 @@ var SuiOutKit = class {
|
|
|
53012
53019
|
if (!config.merchantAddress) {
|
|
53013
53020
|
throw new Error("SuiOutKit Error: merchantAddress is required.");
|
|
53014
53021
|
}
|
|
53015
|
-
|
|
53022
|
+
const mode = config.mode || "live";
|
|
53023
|
+
const modeCfg = MODE_MAP[mode];
|
|
53024
|
+
this.backendUrl = (config.backendUrl || modeCfg.backendUrl).replace(/\/+$/, "");
|
|
53016
53025
|
this.merchantAddress = config.merchantAddress;
|
|
53026
|
+
window.SuiOutKitNetwork = modeCfg.suiNetwork;
|
|
53017
53027
|
}
|
|
53018
53028
|
/**
|
|
53019
53029
|
* Initializes a brand-new isolated checkout session from the backend.
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type SuiOutKitMode = "local" | "test" | "live";
|
|
2
|
+
export interface SuiOutKitConfig {
|
|
3
|
+
merchantAddress: string;
|
|
4
|
+
mode?: SuiOutKitMode;
|
|
5
|
+
backendUrl?: string;
|
|
6
|
+
}
|
|
2
7
|
export interface SupportedCoin {
|
|
3
8
|
symbol: string;
|
|
4
9
|
type: string;
|
package/package.json
CHANGED
package/src/config/api.ts
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
// Copyright (c) 2026 The3rdWebLabs (https://github.com/the3rdweblabs)
|
|
3
3
|
// Author: @CYBWithFlourish (https://github.com/CYBWithFlourish)
|
|
4
4
|
|
|
5
|
-
/** Production SuiOutKit API origin (versioned paths under /v1/). */
|
|
6
|
-
|
|
7
|
-
export const DEFAULT_API_ORIGIN = "http://localhost:5000";
|
|
5
|
+
/** Production SuiOutKit API origin (versioned paths under /v1/). Use `mode` config to switch between local/test/live. */
|
|
6
|
+
export const DEFAULT_API_ORIGIN = "https://api.suioutkit.xyz";
|
|
8
7
|
|
|
9
8
|
/** API version prefix - all checkout and payment routes live under this path. */
|
|
10
9
|
export const API_V1_PREFIX = "/v1";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0
|
|
2
|
+
// Copyright (c) 2026 The3rdWebLabs (https://github.com/the3rdweblabs)
|
|
3
|
+
// Author: @CYBWithFlourish (https://github.com/CYBWithFlourish)
|
|
4
|
+
|
|
5
|
+
export type SuiOutKitMode = "local" | "test" | "live";
|
|
6
|
+
|
|
7
|
+
export interface ModeConfig {
|
|
8
|
+
backendUrl: string;
|
|
9
|
+
suiNetwork: "mainnet" | "testnet";
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const MODE_MAP: Record<SuiOutKitMode, ModeConfig> = {
|
|
13
|
+
local: { backendUrl: "http://localhost:5000", suiNetwork: "testnet" },
|
|
14
|
+
test: { backendUrl: "https://api.staging.suioutkit.xyz", suiNetwork: "testnet" },
|
|
15
|
+
live: { backendUrl: "https://api.suioutkit.xyz", suiNetwork: "mainnet" },
|
|
16
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
// Copyright (c) 2026 The3rdWebLabs (https://github.com/the3rdweblabs)
|
|
3
3
|
// Author: @CYBWithFlourish (https://github.com/CYBWithFlourish)
|
|
4
4
|
|
|
5
|
-
import { CheckoutSession, CheckoutSessionOptions, CryptoConfirmResponse, SuiOutKitModalOptions } from "./types/index.js";
|
|
5
|
+
import { CheckoutSession, CheckoutSessionOptions, CryptoConfirmResponse, SuiOutKitModalOptions, SuiOutKitConfig, SuiOutKitMode } from "./types/index.js";
|
|
6
6
|
import { SuiOutKitModal } from "./components/modal.js";
|
|
7
|
-
import {
|
|
7
|
+
import { joinApiPath, DEFAULT_API_ORIGIN } from "./config/api.js";
|
|
8
|
+
import { MODE_MAP } from "./config/modes.js";
|
|
8
9
|
|
|
9
10
|
export { DEFAULT_API_ORIGIN, API_V1_PREFIX } from "./config/api.js";
|
|
10
11
|
|
|
@@ -12,13 +13,15 @@ export class SuiOutKit {
|
|
|
12
13
|
private backendUrl: string;
|
|
13
14
|
private merchantAddress: string;
|
|
14
15
|
|
|
15
|
-
constructor(config:
|
|
16
|
+
constructor(config: SuiOutKitConfig) {
|
|
16
17
|
if (!config.merchantAddress) {
|
|
17
18
|
throw new Error("SuiOutKit Error: merchantAddress is required.");
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
const mode: SuiOutKitMode = config.mode || "live";
|
|
21
|
+
const modeCfg = MODE_MAP[mode];
|
|
22
|
+
this.backendUrl = (config.backendUrl || modeCfg.backendUrl).replace(/\/+$/, "");
|
|
21
23
|
this.merchantAddress = config.merchantAddress;
|
|
24
|
+
(window as any).SuiOutKitNetwork = modeCfg.suiNetwork;
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
/**
|
package/src/types/index.ts
CHANGED
|
@@ -2,7 +2,13 @@
|
|
|
2
2
|
// Copyright (c) 2026 The3rdWebLabs (https://github.com/the3rdweblabs)
|
|
3
3
|
// Author: @CYBWithFlourish (https://github.com/CYBWithFlourish)
|
|
4
4
|
|
|
5
|
-
export type
|
|
5
|
+
export type SuiOutKitMode = "local" | "test" | "live";
|
|
6
|
+
|
|
7
|
+
export interface SuiOutKitConfig {
|
|
8
|
+
merchantAddress: string;
|
|
9
|
+
mode?: SuiOutKitMode;
|
|
10
|
+
backendUrl?: string;
|
|
11
|
+
}
|
|
6
12
|
|
|
7
13
|
export interface SupportedCoin {
|
|
8
14
|
symbol: string;
|