@takeal/cusfront-sdk 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/CHANGELOG.md +66 -0
- package/LICENSE +21 -0
- package/README.md +283 -0
- package/dist/customer-CoxPwe5o.d.cts +32 -0
- package/dist/customer-CoxPwe5o.d.ts +32 -0
- package/dist/http-BkZZZI8K.d.cts +72 -0
- package/dist/http-BkZZZI8K.d.ts +72 -0
- package/dist/index.cjs +486 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +149 -0
- package/dist/index.d.ts +149 -0
- package/dist/index.js +478 -0
- package/dist/index.js.map +1 -0
- package/dist/react/index.cjs +82 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.cts +93 -0
- package/dist/react/index.d.ts +93 -0
- package/dist/react/index.js +75 -0
- package/dist/react/index.js.map +1 -0
- package/dist/resources/auth.cjs +88 -0
- package/dist/resources/auth.cjs.map +1 -0
- package/dist/resources/auth.d.cts +132 -0
- package/dist/resources/auth.d.ts +132 -0
- package/dist/resources/auth.js +86 -0
- package/dist/resources/auth.js.map +1 -0
- package/dist/resources/balance.cjs +21 -0
- package/dist/resources/balance.cjs.map +1 -0
- package/dist/resources/balance.d.cts +27 -0
- package/dist/resources/balance.d.ts +27 -0
- package/dist/resources/balance.js +19 -0
- package/dist/resources/balance.js.map +1 -0
- package/dist/resources/blog.cjs +39 -0
- package/dist/resources/blog.cjs.map +1 -0
- package/dist/resources/blog.d.cts +112 -0
- package/dist/resources/blog.d.ts +112 -0
- package/dist/resources/blog.js +37 -0
- package/dist/resources/blog.js.map +1 -0
- package/dist/resources/branding.cjs +16 -0
- package/dist/resources/branding.cjs.map +1 -0
- package/dist/resources/branding.d.cts +35 -0
- package/dist/resources/branding.d.ts +35 -0
- package/dist/resources/branding.js +14 -0
- package/dist/resources/branding.js.map +1 -0
- package/dist/resources/cards.cjs +91 -0
- package/dist/resources/cards.cjs.map +1 -0
- package/dist/resources/cards.d.cts +166 -0
- package/dist/resources/cards.d.ts +166 -0
- package/dist/resources/cards.js +89 -0
- package/dist/resources/cards.js.map +1 -0
- package/dist/resources/deposits.cjs +52 -0
- package/dist/resources/deposits.cjs.map +1 -0
- package/dist/resources/deposits.d.cts +168 -0
- package/dist/resources/deposits.d.ts +168 -0
- package/dist/resources/deposits.js +50 -0
- package/dist/resources/deposits.js.map +1 -0
- package/dist/resources/subscriptions.cjs +24 -0
- package/dist/resources/subscriptions.cjs.map +1 -0
- package/dist/resources/subscriptions.d.cts +36 -0
- package/dist/resources/subscriptions.d.ts +36 -0
- package/dist/resources/subscriptions.js +22 -0
- package/dist/resources/subscriptions.js.map +1 -0
- package/dist/telegram.cjs +557 -0
- package/dist/telegram.cjs.map +1 -0
- package/dist/telegram.d.cts +105 -0
- package/dist/telegram.d.ts +105 -0
- package/dist/telegram.js +550 -0
- package/dist/telegram.js.map +1 -0
- package/dist/webhooks.cjs +78 -0
- package/dist/webhooks.cjs.map +1 -0
- package/dist/webhooks.d.cts +70 -0
- package/dist/webhooks.d.ts +70 -0
- package/dist/webhooks.js +72 -0
- package/dist/webhooks.js.map +1 -0
- package/package.json +123 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { T as TokenStore, F as FetchLike } from './http-BkZZZI8K.cjs';
|
|
2
|
+
export { d as defaultBrowserStore, i as inMemoryStore } from './http-BkZZZI8K.cjs';
|
|
3
|
+
import { AuthResource } from './resources/auth.cjs';
|
|
4
|
+
import { DepositsResource } from './resources/deposits.cjs';
|
|
5
|
+
export { CreateDepositRefundInput, CreateQuoteInput, Deposit, DepositMethod, DepositStatus, FundingQuote, InitiateDepositInput, Refund } from './resources/deposits.cjs';
|
|
6
|
+
import { CardsResource } from './resources/cards.cjs';
|
|
7
|
+
export { Card, CardBalance, CardStatus, CardType, CreateCardInput, RevealCardInput, RevealedCard } from './resources/cards.cjs';
|
|
8
|
+
import { BalanceResource } from './resources/balance.cjs';
|
|
9
|
+
export { Balance } from './resources/balance.cjs';
|
|
10
|
+
import { BrandingResource } from './resources/branding.cjs';
|
|
11
|
+
export { Branding } from './resources/branding.cjs';
|
|
12
|
+
import { BlogResource } from './resources/blog.cjs';
|
|
13
|
+
export { BlogBlock, BlogList, BlogListInput, BlogPost } from './resources/blog.cjs';
|
|
14
|
+
import { SubscriptionsResource } from './resources/subscriptions.cjs';
|
|
15
|
+
export { BroadcastChannel, Subscriptions } from './resources/subscriptions.cjs';
|
|
16
|
+
export { A as Address, C as CustomerInfo } from './customer-CoxPwe5o.cjs';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Brand config — runtime-passed, not build-time-baked.
|
|
20
|
+
*
|
|
21
|
+
* Whitelabel customers swap brand without forking the SDK. The SDK
|
|
22
|
+
* exposes `client.brand` for the UI layer to read; nothing else inside
|
|
23
|
+
* the SDK depends on the brand.
|
|
24
|
+
*
|
|
25
|
+
* Optional. When omitted, `client.brand` is `undefined` and the
|
|
26
|
+
* consumer is expected to render its own brand surface independently.
|
|
27
|
+
*/
|
|
28
|
+
interface BrandConfig {
|
|
29
|
+
/** Display name shown in headers / titles / footer. */
|
|
30
|
+
name: string;
|
|
31
|
+
/** Absolute or root-relative URL to a logo asset. */
|
|
32
|
+
logoUrl?: string;
|
|
33
|
+
/** CSS colour token consumed by the Cusfront's theme provider.
|
|
34
|
+
* Hex, rgb(), or any CSS-valid colour string. */
|
|
35
|
+
primaryColor?: string;
|
|
36
|
+
/** Deep link to a support channel (Telegram, email, etc.). When set
|
|
37
|
+
* the Cusfront's footer renders a "Need help?" link. */
|
|
38
|
+
supportUrl?: string;
|
|
39
|
+
/** Label for the end-user's balance ("Wallet", "Acme Wallet").
|
|
40
|
+
* Build-time fallback; `client.branding.get()` returns the live value. */
|
|
41
|
+
walletLabel?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Errors surfaced by the SDK. All HTTP failures map onto `ApiError`;
|
|
46
|
+
* network-level / abort / serialisation failures get the generic
|
|
47
|
+
* `NetworkError`. Consumers catch on the discriminator field
|
|
48
|
+
* (`isApiError` / `isNetworkError`) rather than `instanceof` — works
|
|
49
|
+
* across bundler boundaries where multiple copies of the class can
|
|
50
|
+
* coexist.
|
|
51
|
+
*/
|
|
52
|
+
declare class ApiError extends Error {
|
|
53
|
+
/** HTTP status code returned by the Takeal API. */
|
|
54
|
+
readonly status: number;
|
|
55
|
+
/** Stable machine-readable code (e.g. `"insufficient_funds"`,
|
|
56
|
+
* `"permission_required"`, `"validation"`). Same enum the
|
|
57
|
+
* TypeScript types pin via openapi-typescript. */
|
|
58
|
+
readonly code: string;
|
|
59
|
+
/** Full parsed response body when available. Carries field-level
|
|
60
|
+
* validation details for `code = "validation"`. */
|
|
61
|
+
readonly body?: unknown | undefined;
|
|
62
|
+
readonly isApiError: true;
|
|
63
|
+
constructor(
|
|
64
|
+
/** HTTP status code returned by the Takeal API. */
|
|
65
|
+
status: number,
|
|
66
|
+
/** Stable machine-readable code (e.g. `"insufficient_funds"`,
|
|
67
|
+
* `"permission_required"`, `"validation"`). Same enum the
|
|
68
|
+
* TypeScript types pin via openapi-typescript. */
|
|
69
|
+
code: string,
|
|
70
|
+
/** Human-readable message. English; the consumer maps to its
|
|
71
|
+
* own i18n layer before showing to end-users. */
|
|
72
|
+
message: string,
|
|
73
|
+
/** Full parsed response body when available. Carries field-level
|
|
74
|
+
* validation details for `code = "validation"`. */
|
|
75
|
+
body?: unknown | undefined);
|
|
76
|
+
}
|
|
77
|
+
declare class NetworkError extends Error {
|
|
78
|
+
readonly cause?: unknown | undefined;
|
|
79
|
+
readonly isNetworkError: true;
|
|
80
|
+
constructor(message: string, cause?: unknown | undefined);
|
|
81
|
+
}
|
|
82
|
+
/** Type guard — preferred over `instanceof` (bundler-safe). */
|
|
83
|
+
declare function isApiError(e: unknown): e is ApiError;
|
|
84
|
+
declare function isNetworkError(e: unknown): e is NetworkError;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* `@takeal/cusfront-sdk` — typed client for the Takeal end-user API.
|
|
88
|
+
*
|
|
89
|
+
* Entry point: `createClient({ baseUrl, brand?, tokenStore?, fetch? })`.
|
|
90
|
+
* Resources are accessed off the returned client (`client.auth.login`,
|
|
91
|
+
* `client.cards.list`, …). Sub-exports under `@takeal/cusfront-sdk/<resource>`
|
|
92
|
+
* publish each resource independently so a Cusfront only pulls what
|
|
93
|
+
* it imports.
|
|
94
|
+
*
|
|
95
|
+
* Brand-neutral by design. No customer / deployment names embedded.
|
|
96
|
+
* Brand swap happens at runtime via `BrandConfig`.
|
|
97
|
+
*/
|
|
98
|
+
|
|
99
|
+
interface CreateClientOptions {
|
|
100
|
+
/** Absolute origin of the Takeal API deployment, no trailing slash.
|
|
101
|
+
* e.g. `"https://api.takeal.example.com"`. */
|
|
102
|
+
baseUrl: string;
|
|
103
|
+
/** Runtime brand config. Optional; consumer renders its own brand
|
|
104
|
+
* if omitted. */
|
|
105
|
+
brand?: BrandConfig;
|
|
106
|
+
/** Token persistence. Defaults to `defaultBrowserStore()` when
|
|
107
|
+
* `window.localStorage` is present, else `inMemoryStore()`. */
|
|
108
|
+
tokenStore?: TokenStore;
|
|
109
|
+
/** Override the `fetch` implementation — useful for Node < 18,
|
|
110
|
+
* React Native < 0.74, MSW intercept layers, etc. */
|
|
111
|
+
fetch?: FetchLike;
|
|
112
|
+
/** When true, the SDK runs every response through a zod schema
|
|
113
|
+
* before handing it to the caller. Requires `zod` >= 3.22 as a
|
|
114
|
+
* peer dep. Off by default; types-only validation is sufficient
|
|
115
|
+
* for the steady-state case. */
|
|
116
|
+
validate?: boolean;
|
|
117
|
+
}
|
|
118
|
+
interface CusfrontClient {
|
|
119
|
+
/** Read-only brand config — pass through from createClient args. */
|
|
120
|
+
readonly brand: BrandConfig | undefined;
|
|
121
|
+
/** Auth resource: login, refresh, current user, logout. */
|
|
122
|
+
readonly auth: AuthResource;
|
|
123
|
+
/** Deposits (money IN via a funder connector): initiate, get, list, refund. */
|
|
124
|
+
readonly deposits: DepositsResource;
|
|
125
|
+
/** Cards (money OUT via an issuer connector): create, get, list, balance. */
|
|
126
|
+
readonly cards: CardsResource;
|
|
127
|
+
/** Wallet balance lookup, per currency. */
|
|
128
|
+
readonly balance: BalanceResource;
|
|
129
|
+
/** Runtime white-label config (`GET /branding`, public): names, logo, wallet label. */
|
|
130
|
+
readonly branding: BrandingResource;
|
|
131
|
+
/** Public blog posts, returned as structured blocks to render in your own style. */
|
|
132
|
+
readonly blog: BlogResource;
|
|
133
|
+
/** The user's announcement channel subscriptions. */
|
|
134
|
+
readonly subscriptions: SubscriptionsResource;
|
|
135
|
+
/** Direct access to the token store (e.g. for an explicit sign-out
|
|
136
|
+
* on Capacitor's lifecycle "app pausing" event). */
|
|
137
|
+
readonly tokens: TokenStore;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Build a new client. Stateless across calls — multiple clients can
|
|
141
|
+
* coexist (e.g. an admin Cusfront with a different baseUrl than the
|
|
142
|
+
* end-user one). Each gets its own `TokenStore`.
|
|
143
|
+
*
|
|
144
|
+
* `validate: true` is honoured by individual resources that ship
|
|
145
|
+
* matching zod schemas; resources without a schema ignore it.
|
|
146
|
+
*/
|
|
147
|
+
declare function createClient(opts: CreateClientOptions): CusfrontClient;
|
|
148
|
+
|
|
149
|
+
export { ApiError, type BrandConfig, type CreateClientOptions, type CusfrontClient, NetworkError, TokenStore, createClient, isApiError, isNetworkError };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { T as TokenStore, F as FetchLike } from './http-BkZZZI8K.js';
|
|
2
|
+
export { d as defaultBrowserStore, i as inMemoryStore } from './http-BkZZZI8K.js';
|
|
3
|
+
import { AuthResource } from './resources/auth.js';
|
|
4
|
+
import { DepositsResource } from './resources/deposits.js';
|
|
5
|
+
export { CreateDepositRefundInput, CreateQuoteInput, Deposit, DepositMethod, DepositStatus, FundingQuote, InitiateDepositInput, Refund } from './resources/deposits.js';
|
|
6
|
+
import { CardsResource } from './resources/cards.js';
|
|
7
|
+
export { Card, CardBalance, CardStatus, CardType, CreateCardInput, RevealCardInput, RevealedCard } from './resources/cards.js';
|
|
8
|
+
import { BalanceResource } from './resources/balance.js';
|
|
9
|
+
export { Balance } from './resources/balance.js';
|
|
10
|
+
import { BrandingResource } from './resources/branding.js';
|
|
11
|
+
export { Branding } from './resources/branding.js';
|
|
12
|
+
import { BlogResource } from './resources/blog.js';
|
|
13
|
+
export { BlogBlock, BlogList, BlogListInput, BlogPost } from './resources/blog.js';
|
|
14
|
+
import { SubscriptionsResource } from './resources/subscriptions.js';
|
|
15
|
+
export { BroadcastChannel, Subscriptions } from './resources/subscriptions.js';
|
|
16
|
+
export { A as Address, C as CustomerInfo } from './customer-CoxPwe5o.js';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Brand config — runtime-passed, not build-time-baked.
|
|
20
|
+
*
|
|
21
|
+
* Whitelabel customers swap brand without forking the SDK. The SDK
|
|
22
|
+
* exposes `client.brand` for the UI layer to read; nothing else inside
|
|
23
|
+
* the SDK depends on the brand.
|
|
24
|
+
*
|
|
25
|
+
* Optional. When omitted, `client.brand` is `undefined` and the
|
|
26
|
+
* consumer is expected to render its own brand surface independently.
|
|
27
|
+
*/
|
|
28
|
+
interface BrandConfig {
|
|
29
|
+
/** Display name shown in headers / titles / footer. */
|
|
30
|
+
name: string;
|
|
31
|
+
/** Absolute or root-relative URL to a logo asset. */
|
|
32
|
+
logoUrl?: string;
|
|
33
|
+
/** CSS colour token consumed by the Cusfront's theme provider.
|
|
34
|
+
* Hex, rgb(), or any CSS-valid colour string. */
|
|
35
|
+
primaryColor?: string;
|
|
36
|
+
/** Deep link to a support channel (Telegram, email, etc.). When set
|
|
37
|
+
* the Cusfront's footer renders a "Need help?" link. */
|
|
38
|
+
supportUrl?: string;
|
|
39
|
+
/** Label for the end-user's balance ("Wallet", "Acme Wallet").
|
|
40
|
+
* Build-time fallback; `client.branding.get()` returns the live value. */
|
|
41
|
+
walletLabel?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Errors surfaced by the SDK. All HTTP failures map onto `ApiError`;
|
|
46
|
+
* network-level / abort / serialisation failures get the generic
|
|
47
|
+
* `NetworkError`. Consumers catch on the discriminator field
|
|
48
|
+
* (`isApiError` / `isNetworkError`) rather than `instanceof` — works
|
|
49
|
+
* across bundler boundaries where multiple copies of the class can
|
|
50
|
+
* coexist.
|
|
51
|
+
*/
|
|
52
|
+
declare class ApiError extends Error {
|
|
53
|
+
/** HTTP status code returned by the Takeal API. */
|
|
54
|
+
readonly status: number;
|
|
55
|
+
/** Stable machine-readable code (e.g. `"insufficient_funds"`,
|
|
56
|
+
* `"permission_required"`, `"validation"`). Same enum the
|
|
57
|
+
* TypeScript types pin via openapi-typescript. */
|
|
58
|
+
readonly code: string;
|
|
59
|
+
/** Full parsed response body when available. Carries field-level
|
|
60
|
+
* validation details for `code = "validation"`. */
|
|
61
|
+
readonly body?: unknown | undefined;
|
|
62
|
+
readonly isApiError: true;
|
|
63
|
+
constructor(
|
|
64
|
+
/** HTTP status code returned by the Takeal API. */
|
|
65
|
+
status: number,
|
|
66
|
+
/** Stable machine-readable code (e.g. `"insufficient_funds"`,
|
|
67
|
+
* `"permission_required"`, `"validation"`). Same enum the
|
|
68
|
+
* TypeScript types pin via openapi-typescript. */
|
|
69
|
+
code: string,
|
|
70
|
+
/** Human-readable message. English; the consumer maps to its
|
|
71
|
+
* own i18n layer before showing to end-users. */
|
|
72
|
+
message: string,
|
|
73
|
+
/** Full parsed response body when available. Carries field-level
|
|
74
|
+
* validation details for `code = "validation"`. */
|
|
75
|
+
body?: unknown | undefined);
|
|
76
|
+
}
|
|
77
|
+
declare class NetworkError extends Error {
|
|
78
|
+
readonly cause?: unknown | undefined;
|
|
79
|
+
readonly isNetworkError: true;
|
|
80
|
+
constructor(message: string, cause?: unknown | undefined);
|
|
81
|
+
}
|
|
82
|
+
/** Type guard — preferred over `instanceof` (bundler-safe). */
|
|
83
|
+
declare function isApiError(e: unknown): e is ApiError;
|
|
84
|
+
declare function isNetworkError(e: unknown): e is NetworkError;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* `@takeal/cusfront-sdk` — typed client for the Takeal end-user API.
|
|
88
|
+
*
|
|
89
|
+
* Entry point: `createClient({ baseUrl, brand?, tokenStore?, fetch? })`.
|
|
90
|
+
* Resources are accessed off the returned client (`client.auth.login`,
|
|
91
|
+
* `client.cards.list`, …). Sub-exports under `@takeal/cusfront-sdk/<resource>`
|
|
92
|
+
* publish each resource independently so a Cusfront only pulls what
|
|
93
|
+
* it imports.
|
|
94
|
+
*
|
|
95
|
+
* Brand-neutral by design. No customer / deployment names embedded.
|
|
96
|
+
* Brand swap happens at runtime via `BrandConfig`.
|
|
97
|
+
*/
|
|
98
|
+
|
|
99
|
+
interface CreateClientOptions {
|
|
100
|
+
/** Absolute origin of the Takeal API deployment, no trailing slash.
|
|
101
|
+
* e.g. `"https://api.takeal.example.com"`. */
|
|
102
|
+
baseUrl: string;
|
|
103
|
+
/** Runtime brand config. Optional; consumer renders its own brand
|
|
104
|
+
* if omitted. */
|
|
105
|
+
brand?: BrandConfig;
|
|
106
|
+
/** Token persistence. Defaults to `defaultBrowserStore()` when
|
|
107
|
+
* `window.localStorage` is present, else `inMemoryStore()`. */
|
|
108
|
+
tokenStore?: TokenStore;
|
|
109
|
+
/** Override the `fetch` implementation — useful for Node < 18,
|
|
110
|
+
* React Native < 0.74, MSW intercept layers, etc. */
|
|
111
|
+
fetch?: FetchLike;
|
|
112
|
+
/** When true, the SDK runs every response through a zod schema
|
|
113
|
+
* before handing it to the caller. Requires `zod` >= 3.22 as a
|
|
114
|
+
* peer dep. Off by default; types-only validation is sufficient
|
|
115
|
+
* for the steady-state case. */
|
|
116
|
+
validate?: boolean;
|
|
117
|
+
}
|
|
118
|
+
interface CusfrontClient {
|
|
119
|
+
/** Read-only brand config — pass through from createClient args. */
|
|
120
|
+
readonly brand: BrandConfig | undefined;
|
|
121
|
+
/** Auth resource: login, refresh, current user, logout. */
|
|
122
|
+
readonly auth: AuthResource;
|
|
123
|
+
/** Deposits (money IN via a funder connector): initiate, get, list, refund. */
|
|
124
|
+
readonly deposits: DepositsResource;
|
|
125
|
+
/** Cards (money OUT via an issuer connector): create, get, list, balance. */
|
|
126
|
+
readonly cards: CardsResource;
|
|
127
|
+
/** Wallet balance lookup, per currency. */
|
|
128
|
+
readonly balance: BalanceResource;
|
|
129
|
+
/** Runtime white-label config (`GET /branding`, public): names, logo, wallet label. */
|
|
130
|
+
readonly branding: BrandingResource;
|
|
131
|
+
/** Public blog posts, returned as structured blocks to render in your own style. */
|
|
132
|
+
readonly blog: BlogResource;
|
|
133
|
+
/** The user's announcement channel subscriptions. */
|
|
134
|
+
readonly subscriptions: SubscriptionsResource;
|
|
135
|
+
/** Direct access to the token store (e.g. for an explicit sign-out
|
|
136
|
+
* on Capacitor's lifecycle "app pausing" event). */
|
|
137
|
+
readonly tokens: TokenStore;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Build a new client. Stateless across calls — multiple clients can
|
|
141
|
+
* coexist (e.g. an admin Cusfront with a different baseUrl than the
|
|
142
|
+
* end-user one). Each gets its own `TokenStore`.
|
|
143
|
+
*
|
|
144
|
+
* `validate: true` is honoured by individual resources that ship
|
|
145
|
+
* matching zod schemas; resources without a schema ignore it.
|
|
146
|
+
*/
|
|
147
|
+
declare function createClient(opts: CreateClientOptions): CusfrontClient;
|
|
148
|
+
|
|
149
|
+
export { ApiError, type BrandConfig, type CreateClientOptions, type CusfrontClient, NetworkError, TokenStore, createClient, isApiError, isNetworkError };
|