@delopay/sdk 0.93.0 → 0.95.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-BWTQ34HP.js → chunk-6BVLBNEZ.js} +148 -1
- package/dist/chunk-6BVLBNEZ.js.map +1 -0
- package/dist/index.cjs +147 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +363 -1
- package/dist/index.d.ts +363 -1
- package/dist/index.js +1 -1
- package/dist/internal.cjs +147 -0
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-BWTQ34HP.js.map +0 -1
|
@@ -2089,6 +2089,7 @@ var Routing = class {
|
|
|
2089
2089
|
this.request = request;
|
|
2090
2090
|
this.decision = new RoutingDecisionManager(request);
|
|
2091
2091
|
this.surchargeRules = new SurchargeRules(request);
|
|
2092
|
+
this.checkoutThemeRules = new CheckoutThemeRules(request);
|
|
2092
2093
|
}
|
|
2093
2094
|
/**
|
|
2094
2095
|
* Create a new routing algorithm.
|
|
@@ -2317,6 +2318,90 @@ var SurchargeRules = class {
|
|
|
2317
2318
|
});
|
|
2318
2319
|
}
|
|
2319
2320
|
};
|
|
2321
|
+
var CheckoutThemeRules = class {
|
|
2322
|
+
constructor(request) {
|
|
2323
|
+
this.request = request;
|
|
2324
|
+
}
|
|
2325
|
+
/**
|
|
2326
|
+
* Create or replace the theme program for a scope.
|
|
2327
|
+
*
|
|
2328
|
+
* `PUT /routing/checkout-theme/rules`
|
|
2329
|
+
*
|
|
2330
|
+
* Supersedes rather than overwrites: the previous active version is retired
|
|
2331
|
+
* and a new one stored, so the record of which look was live when survives.
|
|
2332
|
+
* Pass `active: false` to store a revision **without** retiring the live one —
|
|
2333
|
+
* that is where a program drafted against a variant you have not built yet
|
|
2334
|
+
* belongs.
|
|
2335
|
+
*
|
|
2336
|
+
* @example A phone in Germany gets the compact look; everyone else the house style.
|
|
2337
|
+
* ```typescript
|
|
2338
|
+
* await delopay.routing.checkoutThemeRules.upsert({
|
|
2339
|
+
* name: 'Autumn targeting',
|
|
2340
|
+
* profile_id: 'pro_...',
|
|
2341
|
+
* algorithm: {
|
|
2342
|
+
* rules: [
|
|
2343
|
+
* {
|
|
2344
|
+
* name: 'German phones',
|
|
2345
|
+
* connectorSelection: { theme: { variant: 'compact' } },
|
|
2346
|
+
* statements: [
|
|
2347
|
+
* {
|
|
2348
|
+
* condition: [
|
|
2349
|
+
* {
|
|
2350
|
+
* lhs: 'device_class',
|
|
2351
|
+
* comparison: 'equal',
|
|
2352
|
+
* value: { type: 'enum_variant', value: 'phone' },
|
|
2353
|
+
* metadata: {},
|
|
2354
|
+
* },
|
|
2355
|
+
* {
|
|
2356
|
+
* lhs: 'browser_language',
|
|
2357
|
+
* comparison: 'equal',
|
|
2358
|
+
* value: { type: 'enum_variant', value: 'de' },
|
|
2359
|
+
* metadata: {},
|
|
2360
|
+
* },
|
|
2361
|
+
* ],
|
|
2362
|
+
* },
|
|
2363
|
+
* ],
|
|
2364
|
+
* },
|
|
2365
|
+
* ],
|
|
2366
|
+
* defaultSelection: { theme: { variant: 'house' } },
|
|
2367
|
+
* metadata: {},
|
|
2368
|
+
* },
|
|
2369
|
+
* });
|
|
2370
|
+
* ```
|
|
2371
|
+
*/
|
|
2372
|
+
async upsert(params) {
|
|
2373
|
+
return this.request("PUT", "/routing/checkout-theme/rules", { body: params });
|
|
2374
|
+
}
|
|
2375
|
+
/**
|
|
2376
|
+
* Retrieve the active theme program for a scope, or `null` when none is set.
|
|
2377
|
+
*
|
|
2378
|
+
* `GET /routing/checkout-theme/rules?profile_id={profileId}`
|
|
2379
|
+
*
|
|
2380
|
+
* @param profileId - Shop scope. Omit for the merchant-wide program. A
|
|
2381
|
+
* shop-scoped caller that omits it gets its own shop's program.
|
|
2382
|
+
*/
|
|
2383
|
+
async retrieve(profileId) {
|
|
2384
|
+
return this.request("GET", "/routing/checkout-theme/rules", {
|
|
2385
|
+
query: { profile_id: profileId }
|
|
2386
|
+
});
|
|
2387
|
+
}
|
|
2388
|
+
/**
|
|
2389
|
+
* Deactivate the active theme program for a scope. Idempotent.
|
|
2390
|
+
*
|
|
2391
|
+
* `DELETE /routing/checkout-theme/rules?profile_id={profileId}`
|
|
2392
|
+
*
|
|
2393
|
+
* Deactivation, not deletion — the stored row is what says which look was
|
|
2394
|
+
* live when, and that history cannot be reconstructed after the fact. Shops
|
|
2395
|
+
* go back to their default appearance immediately.
|
|
2396
|
+
*
|
|
2397
|
+
* @param profileId - Shop scope. Omit for the merchant-wide program.
|
|
2398
|
+
*/
|
|
2399
|
+
async delete(profileId) {
|
|
2400
|
+
return this.request("DELETE", "/routing/checkout-theme/rules", {
|
|
2401
|
+
query: { profile_id: profileId }
|
|
2402
|
+
});
|
|
2403
|
+
}
|
|
2404
|
+
};
|
|
2320
2405
|
|
|
2321
2406
|
// src/resources/search.ts
|
|
2322
2407
|
var Search = class {
|
|
@@ -2592,6 +2677,33 @@ var Users = class {
|
|
|
2592
2677
|
async signOut() {
|
|
2593
2678
|
return this.request("POST", "/user/signout");
|
|
2594
2679
|
}
|
|
2680
|
+
/**
|
|
2681
|
+
* Sliding-session refresh: exchange the current (still-valid) login JWT
|
|
2682
|
+
* for a fresh one with the same claims and a full lifetime. The backend
|
|
2683
|
+
* keeps the session's identity (`jti`), slides `user_session.expires_at`
|
|
2684
|
+
* forward and re-sets the `login_token` cookie.
|
|
2685
|
+
*
|
|
2686
|
+
* Requires a token backed by a revocable session (a `jti` claim). Signin
|
|
2687
|
+
* and switch-merchant/-profile tokens have one; **session-less tokens do
|
|
2688
|
+
* not and are rejected with 400** — team-impersonation tokens are the
|
|
2689
|
+
* case in practice, and they are deliberately tab-scoped and
|
|
2690
|
+
* time-bounded rather than renewable. A 400 here is not a dead session:
|
|
2691
|
+
* the token remains valid for ordinary calls, it simply cannot slide.
|
|
2692
|
+
*
|
|
2693
|
+
* Rejected (401) for expired, blacklisted or revoked tokens — refresh can
|
|
2694
|
+
* only extend a session that is still alive. Rate-limited server-side
|
|
2695
|
+
* (429) to one mint per session per minute; treat a 429 as "still fresh
|
|
2696
|
+
* enough", not as an error.
|
|
2697
|
+
*
|
|
2698
|
+
* The returned token is NOT applied to this client automatically — pass
|
|
2699
|
+
* it to `setJwtToken()`, or use {@link Delopay.refreshSession} which does
|
|
2700
|
+
* both.
|
|
2701
|
+
*
|
|
2702
|
+
* `POST /user/token/refresh`. Requires a logged-in JWT.
|
|
2703
|
+
*/
|
|
2704
|
+
async refreshToken() {
|
|
2705
|
+
return this.request("POST", "/user/token/refresh");
|
|
2706
|
+
}
|
|
2595
2707
|
/**
|
|
2596
2708
|
* Paginated login history for the authenticated user -- IP, User-Agent,
|
|
2597
2709
|
* country / city / lat-lon (when GeoIP is enabled), success and failure
|
|
@@ -3859,6 +3971,41 @@ var Delopay = class {
|
|
|
3859
3971
|
clearJwtToken() {
|
|
3860
3972
|
this.jwtToken = void 0;
|
|
3861
3973
|
}
|
|
3974
|
+
/**
|
|
3975
|
+
* Refresh the current login JWT (see {@link Users.refreshToken}) and
|
|
3976
|
+
* apply the fresh token to this client, so subsequent requests use it.
|
|
3977
|
+
* Returns the fresh token for the caller to persist (e.g. session
|
|
3978
|
+
* storage) — the backend has already re-set the `login_token` cookie.
|
|
3979
|
+
*
|
|
3980
|
+
* If the client's auth state changes while the refresh is pending —
|
|
3981
|
+
* `clearJwtToken()` on sign-out, or `setJwtToken()` switching to another
|
|
3982
|
+
* session — the stale completion is discarded and this rejects with a
|
|
3983
|
+
* `session_changed` `DelopayError` (status 0), so the explicit change
|
|
3984
|
+
* wins and the caller never persists a token for a session that is gone.
|
|
3985
|
+
*
|
|
3986
|
+
* Otherwise throws like any other request; in particular a 401 means the
|
|
3987
|
+
* session is dead (expired/blacklisted/revoked), a 429 means a refresh
|
|
3988
|
+
* was already minted for this session within the last minute, and a 400
|
|
3989
|
+
* means this token has no revocable session to slide (no `jti` — team
|
|
3990
|
+
* impersonation is the case in practice) and can never be refreshed,
|
|
3991
|
+
* though it stays valid for ordinary calls.
|
|
3992
|
+
*/
|
|
3993
|
+
async refreshSession() {
|
|
3994
|
+
const originatingToken = this.jwtToken;
|
|
3995
|
+
const response = await this.users.refreshToken();
|
|
3996
|
+
if (this.jwtToken !== originatingToken) {
|
|
3997
|
+
throw new DelopayError(
|
|
3998
|
+
"Auth state changed while the refresh was pending; refreshed token discarded",
|
|
3999
|
+
{
|
|
4000
|
+
status: 0,
|
|
4001
|
+
code: "session_changed",
|
|
4002
|
+
type: "session_changed"
|
|
4003
|
+
}
|
|
4004
|
+
);
|
|
4005
|
+
}
|
|
4006
|
+
this.setJwtToken(response.token);
|
|
4007
|
+
return response;
|
|
4008
|
+
}
|
|
3862
4009
|
/**
|
|
3863
4010
|
* Make a raw HTTP request to the Delopay API.
|
|
3864
4011
|
*
|
|
@@ -5886,4 +6033,4 @@ export {
|
|
|
5886
6033
|
focusedCheckoutUrl,
|
|
5887
6034
|
CHECKOUT_EVENT_KINDS
|
|
5888
6035
|
};
|
|
5889
|
-
//# sourceMappingURL=chunk-
|
|
6036
|
+
//# sourceMappingURL=chunk-6BVLBNEZ.js.map
|