@takeal/cusfront-sdk 0.1.0 → 0.3.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 +104 -2
- package/README.md +393 -14
- package/dist/devices-C3JHi2Hi.d.cts +165 -0
- package/dist/devices-DP_hxwmW.d.ts +165 -0
- package/dist/{http-BkZZZI8K.d.cts → http-B-OQwMYn.d.cts} +13 -2
- package/dist/{http-BkZZZI8K.d.ts → http-B-OQwMYn.d.ts} +13 -2
- package/dist/index.cjs +425 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +77 -8
- package/dist/index.d.ts +77 -8
- package/dist/index.js +422 -26
- package/dist/index.js.map +1 -1
- package/dist/react/index.cjs +133 -6
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +65 -3
- package/dist/react/index.d.ts +65 -3
- package/dist/react/index.js +131 -8
- package/dist/react/index.js.map +1 -1
- package/dist/resources/auth.cjs +73 -15
- package/dist/resources/auth.cjs.map +1 -1
- package/dist/resources/auth.d.cts +100 -9
- package/dist/resources/auth.d.ts +100 -9
- package/dist/resources/auth.js +73 -15
- package/dist/resources/auth.js.map +1 -1
- package/dist/resources/balance.cjs +4 -3
- package/dist/resources/balance.cjs.map +1 -1
- package/dist/resources/balance.d.cts +8 -9
- package/dist/resources/balance.d.ts +8 -9
- package/dist/resources/balance.js +4 -3
- package/dist/resources/balance.js.map +1 -1
- package/dist/resources/blog.d.cts +1 -1
- package/dist/resources/blog.d.ts +1 -1
- package/dist/resources/branding.cjs.map +1 -1
- package/dist/resources/branding.d.cts +8 -2
- package/dist/resources/branding.d.ts +8 -2
- package/dist/resources/branding.js.map +1 -1
- package/dist/resources/cards.cjs +33 -1
- package/dist/resources/cards.cjs.map +1 -1
- package/dist/resources/cards.d.cts +105 -4
- package/dist/resources/cards.d.ts +105 -4
- package/dist/resources/cards.js +33 -1
- package/dist/resources/cards.js.map +1 -1
- package/dist/resources/deposits.d.cts +1 -1
- package/dist/resources/deposits.d.ts +1 -1
- package/dist/resources/devices.cjs +92 -0
- package/dist/resources/devices.cjs.map +1 -0
- package/dist/resources/devices.d.cts +3 -0
- package/dist/resources/devices.d.ts +3 -0
- package/dist/resources/devices.js +89 -0
- package/dist/resources/devices.js.map +1 -0
- package/dist/resources/me.cjs +32 -0
- package/dist/resources/me.cjs.map +1 -0
- package/dist/resources/me.d.cts +40 -0
- package/dist/resources/me.d.ts +40 -0
- package/dist/resources/me.js +30 -0
- package/dist/resources/me.js.map +1 -0
- package/dist/resources/notifications.cjs +53 -0
- package/dist/resources/notifications.cjs.map +1 -0
- package/dist/resources/notifications.d.cts +109 -0
- package/dist/resources/notifications.d.ts +109 -0
- package/dist/resources/notifications.js +51 -0
- package/dist/resources/notifications.js.map +1 -0
- package/dist/resources/push.cjs +65 -0
- package/dist/resources/push.cjs.map +1 -0
- package/dist/resources/push.d.cts +76 -0
- package/dist/resources/push.d.ts +76 -0
- package/dist/resources/push.js +62 -0
- package/dist/resources/push.js.map +1 -0
- package/dist/resources/sessions.cjs +26 -0
- package/dist/resources/sessions.cjs.map +1 -0
- package/dist/resources/sessions.d.cts +43 -0
- package/dist/resources/sessions.d.ts +43 -0
- package/dist/resources/sessions.js +24 -0
- package/dist/resources/sessions.js.map +1 -0
- package/dist/resources/subscriptions.cjs.map +1 -1
- package/dist/resources/subscriptions.d.cts +8 -1
- package/dist/resources/subscriptions.d.ts +8 -1
- package/dist/resources/subscriptions.js.map +1 -1
- package/dist/resources/wallet.cjs +24 -0
- package/dist/resources/wallet.cjs.map +1 -0
- package/dist/resources/wallet.d.cts +39 -0
- package/dist/resources/wallet.d.ts +39 -0
- package/dist/resources/wallet.js +22 -0
- package/dist/resources/wallet.js.map +1 -0
- package/dist/telegram.cjs +466 -28
- package/dist/telegram.cjs.map +1 -1
- package/dist/telegram.d.cts +65 -7
- package/dist/telegram.d.ts +65 -7
- package/dist/telegram.js +465 -29
- package/dist/telegram.js.map +1 -1
- package/package.json +37 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,30 @@
|
|
|
1
|
-
import { T as TokenStore, F as FetchLike } from './http-
|
|
2
|
-
export { d as defaultBrowserStore, i as inMemoryStore } from './http-
|
|
1
|
+
import { T as TokenStore, F as FetchLike } from './http-B-OQwMYn.js';
|
|
2
|
+
export { d as defaultBrowserStore, i as inMemoryStore } from './http-B-OQwMYn.js';
|
|
3
3
|
import { AuthResource } from './resources/auth.js';
|
|
4
|
+
export { ChangePasswordInput, ExchangeTelegramInput, JwtIssued, LinkTelegramInput, LoginInput, LoginResponse, OtpSentResponse, RegisterInput, Session, TelegramLink, TelegramUnknown, TotpRequired, TotpSetupComplete, TotpSetupRequired, User } from './resources/auth.js';
|
|
4
5
|
import { DepositsResource } from './resources/deposits.js';
|
|
5
6
|
export { CreateDepositRefundInput, CreateQuoteInput, Deposit, DepositMethod, DepositStatus, FundingQuote, InitiateDepositInput, Refund } from './resources/deposits.js';
|
|
6
7
|
import { CardsResource } from './resources/cards.js';
|
|
7
|
-
export { Card, CardBalance, CardStatus, CardType, CreateCardInput, RevealCardInput, RevealedCard } from './resources/cards.js';
|
|
8
|
+
export { Card, CardBalance, CardDesignRef, CardProduct, CardProductPrice, CardStatus, CardType, CreateCardInput, RevealCardInput, RevealedCard, UpdateCardInput } from './resources/cards.js';
|
|
8
9
|
import { BalanceResource } from './resources/balance.js';
|
|
9
10
|
export { Balance } from './resources/balance.js';
|
|
10
11
|
import { BrandingResource } from './resources/branding.js';
|
|
11
12
|
export { Branding } from './resources/branding.js';
|
|
13
|
+
import { WalletResource } from './resources/wallet.js';
|
|
14
|
+
export { Wallet } from './resources/wallet.js';
|
|
12
15
|
import { BlogResource } from './resources/blog.js';
|
|
13
16
|
export { BlogBlock, BlogList, BlogListInput, BlogPost } from './resources/blog.js';
|
|
14
17
|
import { SubscriptionsResource } from './resources/subscriptions.js';
|
|
15
18
|
export { BroadcastChannel, Subscriptions } from './resources/subscriptions.js';
|
|
19
|
+
import { SessionsResource } from './resources/sessions.js';
|
|
20
|
+
export { UserSession } from './resources/sessions.js';
|
|
21
|
+
import { PushResource } from './resources/push.js';
|
|
22
|
+
export { PushCapableRegistration, PushStatus, PushSubscriptionInput } from './resources/push.js';
|
|
23
|
+
import { MeResource } from './resources/me.js';
|
|
24
|
+
import { NotificationsResource } from './resources/notifications.js';
|
|
25
|
+
export { InboxItem, ListNotificationsParams, NotificationCategory, NotificationCategoryPreferences, NotificationChannel, NotificationLocale, NotificationPage, NotificationPreferences, NotificationPreferencesInput } from './resources/notifications.js';
|
|
26
|
+
import { C as ClientDescriptor, R as ResolvedClientDescriptor, D as DevicesResource } from './devices-DP_hxwmW.js';
|
|
27
|
+
export { a as CLIENT_HEADER, b as ClientPlatform, c as Device, d as DeviceKind, e as DevicePlatform, M as MobilePushCredential, f as RegisterDeviceInput, g as RegisterWebPushOptions, h as RegisteredDevice, U as UnregisterWebPushOptions, W as WebPushCredential, i as detectClientPlatform } from './devices-DP_hxwmW.js';
|
|
16
28
|
export { A as Address, C as CustomerInfo } from './customer-CoxPwe5o.js';
|
|
17
29
|
|
|
18
30
|
/**
|
|
@@ -41,6 +53,22 @@ interface BrandConfig {
|
|
|
41
53
|
walletLabel?: string;
|
|
42
54
|
}
|
|
43
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Resolve an image URL the API hands back (`design.image_url`, a logo, …)
|
|
58
|
+
* into something a browser can load.
|
|
59
|
+
*
|
|
60
|
+
* The API returns either an absolute URL (uploaded artwork served from
|
|
61
|
+
* object storage) or a path relative to the API origin (the deployment's
|
|
62
|
+
* default card design, `/card-designs/default.svg`). Absolute URLs — and
|
|
63
|
+
* `data:` / `blob:` URIs — come back unchanged; a relative path is joined
|
|
64
|
+
* onto `baseUrl`, which is the bare API origin the client was built with.
|
|
65
|
+
* These paths are host-level, so no `/v1` prefix is added.
|
|
66
|
+
*
|
|
67
|
+
* `baseUrl` is the same value passed to `createClient`; a trailing slash is
|
|
68
|
+
* tolerated. `client.assetUrl()` calls this with the client's own base.
|
|
69
|
+
*/
|
|
70
|
+
declare function resolveAssetUrl(baseUrl: string, url: string): string;
|
|
71
|
+
|
|
44
72
|
/**
|
|
45
73
|
* Errors surfaced by the SDK. All HTTP failures map onto `ApiError`;
|
|
46
74
|
* network-level / abort / serialisation failures get the generic
|
|
@@ -83,10 +111,20 @@ declare class NetworkError extends Error {
|
|
|
83
111
|
declare function isApiError(e: unknown): e is ApiError;
|
|
84
112
|
declare function isNetworkError(e: unknown): e is NetworkError;
|
|
85
113
|
|
|
114
|
+
/**
|
|
115
|
+
* The SDK's own version, sent as the default `X-Takeal-Client` version.
|
|
116
|
+
*
|
|
117
|
+
* Kept as a plain constant so every entry point (ESM, CJS, the
|
|
118
|
+
* sub-exports) reads the same value without a JSON import or a bundler
|
|
119
|
+
* `define`. `src/version.test.ts` checks it matches `package.json`, so a
|
|
120
|
+
* release bump that forgets this file fails the test run.
|
|
121
|
+
*/
|
|
122
|
+
declare const SDK_VERSION = "0.3.0";
|
|
123
|
+
|
|
86
124
|
/**
|
|
87
125
|
* `@takeal/cusfront-sdk` — typed client for the Takeal end-user API.
|
|
88
126
|
*
|
|
89
|
-
* Entry point: `createClient({ baseUrl, brand?, tokenStore?, fetch? })`.
|
|
127
|
+
* Entry point: `createClient({ baseUrl, brand?, client?, tokenStore?, fetch? })`.
|
|
90
128
|
* Resources are accessed off the returned client (`client.auth.login`,
|
|
91
129
|
* `client.cards.list`, …). Sub-exports under `@takeal/cusfront-sdk/<resource>`
|
|
92
130
|
* publish each resource independently so a Cusfront only pulls what
|
|
@@ -103,6 +141,14 @@ interface CreateClientOptions {
|
|
|
103
141
|
/** Runtime brand config. Optional; consumer renders its own brand
|
|
104
142
|
* if omitted. */
|
|
105
143
|
brand?: BrandConfig;
|
|
144
|
+
/** What kind of app this is, sent on every request as
|
|
145
|
+
* `X-Takeal-Client: <platform>; <version>`. The server uses it to spot
|
|
146
|
+
* a sign-in from a new device and to pick the notification channel.
|
|
147
|
+
* `platform` is detected at runtime when omitted (`telegram-miniapp`
|
|
148
|
+
* inside Telegram, `pwa` when installed, `web` otherwise); `version`
|
|
149
|
+
* defaults to the SDK version. Native wrappers should pass
|
|
150
|
+
* `{ platform: "ios" | "android", version }`. */
|
|
151
|
+
client?: ClientDescriptor;
|
|
106
152
|
/** Token persistence. Defaults to `defaultBrowserStore()` when
|
|
107
153
|
* `window.localStorage` is present, else `inMemoryStore()`. */
|
|
108
154
|
tokenStore?: TokenStore;
|
|
@@ -118,23 +164,46 @@ interface CreateClientOptions {
|
|
|
118
164
|
interface CusfrontClient {
|
|
119
165
|
/** Read-only brand config — pass through from createClient args. */
|
|
120
166
|
readonly brand: BrandConfig | undefined;
|
|
167
|
+
/** The platform and version this client announces in `X-Takeal-Client`. */
|
|
168
|
+
readonly client: ResolvedClientDescriptor;
|
|
121
169
|
/** Auth resource: login, refresh, current user, logout. */
|
|
122
170
|
readonly auth: AuthResource;
|
|
123
171
|
/** Deposits (money IN via a funder connector): initiate, get, list, refund. */
|
|
124
172
|
readonly deposits: DepositsResource;
|
|
125
|
-
/** Cards (money OUT via an issuer connector): create, get, list, balance. */
|
|
173
|
+
/** Cards (money OUT via an issuer connector): the product catalog, create, get, list, update, balance. */
|
|
126
174
|
readonly cards: CardsResource;
|
|
127
|
-
/** Wallet balance lookup
|
|
175
|
+
/** Wallet balance lookup (defaults to the wallet's own currency). */
|
|
128
176
|
readonly balance: BalanceResource;
|
|
177
|
+
/** The wallet's currency: read it, switch it while the wallet is empty. */
|
|
178
|
+
readonly wallet: WalletResource;
|
|
129
179
|
/** Runtime white-label config (`GET /branding`, public): names, logo, wallet label. */
|
|
130
180
|
readonly branding: BrandingResource;
|
|
131
181
|
/** Public blog posts, returned as structured blocks to render in your own style. */
|
|
132
182
|
readonly blog: BlogResource;
|
|
133
|
-
/** The user's announcement channel subscriptions.
|
|
183
|
+
/** The user's announcement channel subscriptions.
|
|
184
|
+
* @deprecated Use `notifications.setPreferences({ categories: { marketing: {...} } })`. */
|
|
134
185
|
readonly subscriptions: SubscriptionsResource;
|
|
186
|
+
/** Where the user is signed in: list sessions, sign one or all others out. */
|
|
187
|
+
readonly sessions: SessionsResource;
|
|
188
|
+
/** Web Push subscription for the signed-in user.
|
|
189
|
+
* @deprecated Use `devices.registerWebPush` / `devices.unregisterWebPush`. */
|
|
190
|
+
readonly push: PushResource;
|
|
191
|
+
/** The user's inbox and notification preferences. */
|
|
192
|
+
readonly notifications: NotificationsResource;
|
|
193
|
+
/** The user's devices: browsers with Web Push, phones, the Telegram Mini App. */
|
|
194
|
+
readonly devices: DevicesResource;
|
|
195
|
+
/** Profile actions for the signed-in user: link or unlink Telegram. */
|
|
196
|
+
readonly me: MeResource;
|
|
135
197
|
/** Direct access to the token store (e.g. for an explicit sign-out
|
|
136
198
|
* on Capacitor's lifecycle "app pausing" event). */
|
|
137
199
|
readonly tokens: TokenStore;
|
|
200
|
+
/**
|
|
201
|
+
* Turn an image URL from the API (`card.design.image_url`,
|
|
202
|
+
* `product.design.image_url`) into one a browser can load. Absolute URLs
|
|
203
|
+
* pass through; a path relative to the API origin (the default card
|
|
204
|
+
* design, `/card-designs/default.svg`) is joined onto `baseUrl`.
|
|
205
|
+
*/
|
|
206
|
+
assetUrl(url: string): string;
|
|
138
207
|
}
|
|
139
208
|
/**
|
|
140
209
|
* Build a new client. Stateless across calls — multiple clients can
|
|
@@ -146,4 +215,4 @@ interface CusfrontClient {
|
|
|
146
215
|
*/
|
|
147
216
|
declare function createClient(opts: CreateClientOptions): CusfrontClient;
|
|
148
217
|
|
|
149
|
-
export { ApiError, type BrandConfig, type CreateClientOptions, type CusfrontClient, NetworkError, TokenStore, createClient, isApiError, isNetworkError };
|
|
218
|
+
export { ApiError, type BrandConfig, ClientDescriptor, type CreateClientOptions, type CusfrontClient, MeResource, NetworkError, ResolvedClientDescriptor, SDK_VERSION, TokenStore, createClient, isApiError, isNetworkError, resolveAssetUrl };
|