@delopay/sdk 0.94.0 → 0.96.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/dist/{chunk-TSYU2IQK.js → chunk-MMDPBYRI.js} +90 -1
- package/dist/chunk-MMDPBYRI.js.map +1 -0
- package/dist/index.cjs +89 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +386 -1
- package/dist/index.d.ts +386 -1
- package/dist/index.js +1 -1
- package/dist/internal.cjs +124 -0
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +24 -3
- package/dist/internal.d.ts +24 -3
- package/dist/internal.js +36 -1
- package/dist/internal.js.map +1 -1
- package/package.json +17 -18
- package/dist/chunk-TSYU2IQK.js.map +0 -1
package/dist/internal.cjs
CHANGED
|
@@ -2803,6 +2803,33 @@ var Users = class {
|
|
|
2803
2803
|
async signOut() {
|
|
2804
2804
|
return this.request("POST", "/user/signout");
|
|
2805
2805
|
}
|
|
2806
|
+
/**
|
|
2807
|
+
* Sliding-session refresh: exchange the current (still-valid) login JWT
|
|
2808
|
+
* for a fresh one with the same claims and a full lifetime. The backend
|
|
2809
|
+
* keeps the session's identity (`jti`), slides `user_session.expires_at`
|
|
2810
|
+
* forward and re-sets the `login_token` cookie.
|
|
2811
|
+
*
|
|
2812
|
+
* Requires a token backed by a revocable session (a `jti` claim). Signin
|
|
2813
|
+
* and switch-merchant/-profile tokens have one; **session-less tokens do
|
|
2814
|
+
* not and are rejected with 400** — team-impersonation tokens are the
|
|
2815
|
+
* case in practice, and they are deliberately tab-scoped and
|
|
2816
|
+
* time-bounded rather than renewable. A 400 here is not a dead session:
|
|
2817
|
+
* the token remains valid for ordinary calls, it simply cannot slide.
|
|
2818
|
+
*
|
|
2819
|
+
* Rejected (401) for expired, blacklisted or revoked tokens — refresh can
|
|
2820
|
+
* only extend a session that is still alive. Rate-limited server-side
|
|
2821
|
+
* (429) to one mint per session per minute; treat a 429 as "still fresh
|
|
2822
|
+
* enough", not as an error.
|
|
2823
|
+
*
|
|
2824
|
+
* The returned token is NOT applied to this client automatically — pass
|
|
2825
|
+
* it to `setJwtToken()`, or use {@link Delopay.refreshSession} which does
|
|
2826
|
+
* both.
|
|
2827
|
+
*
|
|
2828
|
+
* `POST /user/token/refresh`. Requires a logged-in JWT.
|
|
2829
|
+
*/
|
|
2830
|
+
async refreshToken() {
|
|
2831
|
+
return this.request("POST", "/user/token/refresh");
|
|
2832
|
+
}
|
|
2806
2833
|
/**
|
|
2807
2834
|
* Paginated login history for the authenticated user -- IP, User-Agent,
|
|
2808
2835
|
* country / city / lat-lon (when GeoIP is enabled), success and failure
|
|
@@ -3316,6 +3343,33 @@ var Analytics = class {
|
|
|
3316
3343
|
query: params
|
|
3317
3344
|
});
|
|
3318
3345
|
}
|
|
3346
|
+
/**
|
|
3347
|
+
* Device analytics over the canonical client-context observation per
|
|
3348
|
+
* payment (browser/platform families, device classes and models, checkout
|
|
3349
|
+
* channel mix, time-to-pay), pinned server-side to your own merchant and
|
|
3350
|
+
* drillable via `project_id` / `shop_id` exactly like `scope`. Gated on the
|
|
3351
|
+
* client-context optimisation-use switch: when it is off the server answers
|
|
3352
|
+
* 200 with `enabled: false` and a caveat naming the switch.
|
|
3353
|
+
* `GET /analytics/devices`
|
|
3354
|
+
*/
|
|
3355
|
+
async devices(params) {
|
|
3356
|
+
return this.request("GET", "/analytics/devices", {
|
|
3357
|
+
query: params
|
|
3358
|
+
});
|
|
3359
|
+
}
|
|
3360
|
+
/**
|
|
3361
|
+
* Geo analytics over the canonical client-context observation per payment:
|
|
3362
|
+
* country totals, city bubbles (IP mode), buyer languages, buyer-local
|
|
3363
|
+
* purchase hours and the IP-vs-billing mismatch share. `mode` selects the
|
|
3364
|
+
* location claim (`ip` default, `billing`); the two are never coalesced.
|
|
3365
|
+
* Same drill, window and gating contract as `devices`.
|
|
3366
|
+
* `GET /analytics/geo`
|
|
3367
|
+
*/
|
|
3368
|
+
async geo(params) {
|
|
3369
|
+
return this.request("GET", "/analytics/geo", {
|
|
3370
|
+
query: params
|
|
3371
|
+
});
|
|
3372
|
+
}
|
|
3319
3373
|
/** Global search. `POST /analytics/search` */
|
|
3320
3374
|
async search(params) {
|
|
3321
3375
|
return this.request("POST", "/analytics/search", { body: params });
|
|
@@ -4070,6 +4124,41 @@ var Delopay = class {
|
|
|
4070
4124
|
clearJwtToken() {
|
|
4071
4125
|
this.jwtToken = void 0;
|
|
4072
4126
|
}
|
|
4127
|
+
/**
|
|
4128
|
+
* Refresh the current login JWT (see {@link Users.refreshToken}) and
|
|
4129
|
+
* apply the fresh token to this client, so subsequent requests use it.
|
|
4130
|
+
* Returns the fresh token for the caller to persist (e.g. session
|
|
4131
|
+
* storage) — the backend has already re-set the `login_token` cookie.
|
|
4132
|
+
*
|
|
4133
|
+
* If the client's auth state changes while the refresh is pending —
|
|
4134
|
+
* `clearJwtToken()` on sign-out, or `setJwtToken()` switching to another
|
|
4135
|
+
* session — the stale completion is discarded and this rejects with a
|
|
4136
|
+
* `session_changed` `DelopayError` (status 0), so the explicit change
|
|
4137
|
+
* wins and the caller never persists a token for a session that is gone.
|
|
4138
|
+
*
|
|
4139
|
+
* Otherwise throws like any other request; in particular a 401 means the
|
|
4140
|
+
* session is dead (expired/blacklisted/revoked), a 429 means a refresh
|
|
4141
|
+
* was already minted for this session within the last minute, and a 400
|
|
4142
|
+
* means this token has no revocable session to slide (no `jti` — team
|
|
4143
|
+
* impersonation is the case in practice) and can never be refreshed,
|
|
4144
|
+
* though it stays valid for ordinary calls.
|
|
4145
|
+
*/
|
|
4146
|
+
async refreshSession() {
|
|
4147
|
+
const originatingToken = this.jwtToken;
|
|
4148
|
+
const response = await this.users.refreshToken();
|
|
4149
|
+
if (this.jwtToken !== originatingToken) {
|
|
4150
|
+
throw new DelopayError(
|
|
4151
|
+
"Auth state changed while the refresh was pending; refreshed token discarded",
|
|
4152
|
+
{
|
|
4153
|
+
status: 0,
|
|
4154
|
+
code: "session_changed",
|
|
4155
|
+
type: "session_changed"
|
|
4156
|
+
}
|
|
4157
|
+
);
|
|
4158
|
+
}
|
|
4159
|
+
this.setJwtToken(response.token);
|
|
4160
|
+
return response;
|
|
4161
|
+
}
|
|
4073
4162
|
/**
|
|
4074
4163
|
* Make a raw HTTP request to the Delopay API.
|
|
4075
4164
|
*
|
|
@@ -6128,6 +6217,27 @@ var AdminPortal = class {
|
|
|
6128
6217
|
query: params
|
|
6129
6218
|
});
|
|
6130
6219
|
}
|
|
6220
|
+
/**
|
|
6221
|
+
* Device analytics over the canonical client-context observation per
|
|
6222
|
+
* payment, rooted at all merchants and drillable via `merchant_id` /
|
|
6223
|
+
* `project_id` / `shop_id` like `analyticsScope`. Answers 200 with
|
|
6224
|
+
* `enabled: false` when the client-context optimisation-use switch is off.
|
|
6225
|
+
*/
|
|
6226
|
+
async analyticsDevices(params) {
|
|
6227
|
+
return this.request("GET", "/admin-portal/analytics/devices", {
|
|
6228
|
+
query: params
|
|
6229
|
+
});
|
|
6230
|
+
}
|
|
6231
|
+
/**
|
|
6232
|
+
* Geo analytics over the canonical client-context observation per payment,
|
|
6233
|
+
* rooted at all merchants. `mode` selects the location claim (`ip` default,
|
|
6234
|
+
* `billing`).
|
|
6235
|
+
*/
|
|
6236
|
+
async analyticsGeo(params) {
|
|
6237
|
+
return this.request("GET", "/admin-portal/analytics/geo", {
|
|
6238
|
+
query: params
|
|
6239
|
+
});
|
|
6240
|
+
}
|
|
6131
6241
|
/**
|
|
6132
6242
|
* Platform billing dashboard: total balance across all ledger accounts (+
|
|
6133
6243
|
* the net change), top-ups, fees collected, and the day-by-day ledger flow.
|
|
@@ -6206,6 +6316,20 @@ var AdminPortal = class {
|
|
|
6206
6316
|
{ body: { iframe_allowed_origins: origins } }
|
|
6207
6317
|
);
|
|
6208
6318
|
}
|
|
6319
|
+
/**
|
|
6320
|
+
* Set (or clear) a target merchant shop's home country — the geo
|
|
6321
|
+
* dashboard's cross-border baseline. Internal-admin route. Pass `null` to
|
|
6322
|
+
* clear back to "international / no home country" (the default).
|
|
6323
|
+
*
|
|
6324
|
+
* `POST /admin-portal/accounts/{merchantId}/business-profile/{profileId}/home-country`
|
|
6325
|
+
*/
|
|
6326
|
+
async updateShopHomeCountry(merchantId, profileId, homeCountry) {
|
|
6327
|
+
return this.request(
|
|
6328
|
+
"POST",
|
|
6329
|
+
`/admin-portal/accounts/${encodeURIComponent(merchantId)}/business-profile/${encodeURIComponent(profileId)}/home-country`,
|
|
6330
|
+
{ body: { home_country: homeCountry } }
|
|
6331
|
+
);
|
|
6332
|
+
}
|
|
6209
6333
|
/**
|
|
6210
6334
|
* Soft-delete a transaction of ANY merchant. Only payments whose status
|
|
6211
6335
|
* is in the admin delete policy can be deleted; the action is audited.
|