@delopay/sdk 0.94.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-TSYU2IQK.js → chunk-6BVLBNEZ.js} +63 -1
- package/dist/chunk-6BVLBNEZ.js.map +1 -0
- package/dist/index.cjs +62 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +45 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.js +1 -1
- package/dist/internal.cjs +62 -0
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.js +1 -1
- package/package.json +17 -18
- package/dist/chunk-TSYU2IQK.js.map +0 -1
|
@@ -2677,6 +2677,33 @@ var Users = class {
|
|
|
2677
2677
|
async signOut() {
|
|
2678
2678
|
return this.request("POST", "/user/signout");
|
|
2679
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
|
+
}
|
|
2680
2707
|
/**
|
|
2681
2708
|
* Paginated login history for the authenticated user -- IP, User-Agent,
|
|
2682
2709
|
* country / city / lat-lon (when GeoIP is enabled), success and failure
|
|
@@ -3944,6 +3971,41 @@ var Delopay = class {
|
|
|
3944
3971
|
clearJwtToken() {
|
|
3945
3972
|
this.jwtToken = void 0;
|
|
3946
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
|
+
}
|
|
3947
4009
|
/**
|
|
3948
4010
|
* Make a raw HTTP request to the Delopay API.
|
|
3949
4011
|
*
|
|
@@ -5971,4 +6033,4 @@ export {
|
|
|
5971
6033
|
focusedCheckoutUrl,
|
|
5972
6034
|
CHECKOUT_EVENT_KINDS
|
|
5973
6035
|
};
|
|
5974
|
-
//# sourceMappingURL=chunk-
|
|
6036
|
+
//# sourceMappingURL=chunk-6BVLBNEZ.js.map
|