@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
package/dist/index.d.cts
CHANGED
|
@@ -6503,6 +6503,31 @@ declare class Users {
|
|
|
6503
6503
|
signUp(params: SignUpRequest | SignUpWithMerchantRequest): Promise<AuthResponse>;
|
|
6504
6504
|
signIn(params: SignInRequest): Promise<AuthResponse>;
|
|
6505
6505
|
signOut(): Promise<Record<string, unknown>>;
|
|
6506
|
+
/**
|
|
6507
|
+
* Sliding-session refresh: exchange the current (still-valid) login JWT
|
|
6508
|
+
* for a fresh one with the same claims and a full lifetime. The backend
|
|
6509
|
+
* keeps the session's identity (`jti`), slides `user_session.expires_at`
|
|
6510
|
+
* forward and re-sets the `login_token` cookie.
|
|
6511
|
+
*
|
|
6512
|
+
* Requires a token backed by a revocable session (a `jti` claim). Signin
|
|
6513
|
+
* and switch-merchant/-profile tokens have one; **session-less tokens do
|
|
6514
|
+
* not and are rejected with 400** — team-impersonation tokens are the
|
|
6515
|
+
* case in practice, and they are deliberately tab-scoped and
|
|
6516
|
+
* time-bounded rather than renewable. A 400 here is not a dead session:
|
|
6517
|
+
* the token remains valid for ordinary calls, it simply cannot slide.
|
|
6518
|
+
*
|
|
6519
|
+
* Rejected (401) for expired, blacklisted or revoked tokens — refresh can
|
|
6520
|
+
* only extend a session that is still alive. Rate-limited server-side
|
|
6521
|
+
* (429) to one mint per session per minute; treat a 429 as "still fresh
|
|
6522
|
+
* enough", not as an error.
|
|
6523
|
+
*
|
|
6524
|
+
* The returned token is NOT applied to this client automatically — pass
|
|
6525
|
+
* it to `setJwtToken()`, or use {@link Delopay.refreshSession} which does
|
|
6526
|
+
* both.
|
|
6527
|
+
*
|
|
6528
|
+
* `POST /user/token/refresh`. Requires a logged-in JWT.
|
|
6529
|
+
*/
|
|
6530
|
+
refreshToken(): Promise<TokenResponse>;
|
|
6506
6531
|
/**
|
|
6507
6532
|
* Paginated login history for the authenticated user -- IP, User-Agent,
|
|
6508
6533
|
* country / city / lat-lon (when GeoIP is enabled), success and failure
|
|
@@ -7302,6 +7327,26 @@ declare class Delopay {
|
|
|
7302
7327
|
* Clear the JWT token, reverting to API key authentication.
|
|
7303
7328
|
*/
|
|
7304
7329
|
clearJwtToken(): void;
|
|
7330
|
+
/**
|
|
7331
|
+
* Refresh the current login JWT (see {@link Users.refreshToken}) and
|
|
7332
|
+
* apply the fresh token to this client, so subsequent requests use it.
|
|
7333
|
+
* Returns the fresh token for the caller to persist (e.g. session
|
|
7334
|
+
* storage) — the backend has already re-set the `login_token` cookie.
|
|
7335
|
+
*
|
|
7336
|
+
* If the client's auth state changes while the refresh is pending —
|
|
7337
|
+
* `clearJwtToken()` on sign-out, or `setJwtToken()` switching to another
|
|
7338
|
+
* session — the stale completion is discarded and this rejects with a
|
|
7339
|
+
* `session_changed` `DelopayError` (status 0), so the explicit change
|
|
7340
|
+
* wins and the caller never persists a token for a session that is gone.
|
|
7341
|
+
*
|
|
7342
|
+
* Otherwise throws like any other request; in particular a 401 means the
|
|
7343
|
+
* session is dead (expired/blacklisted/revoked), a 429 means a refresh
|
|
7344
|
+
* was already minted for this session within the last minute, and a 400
|
|
7345
|
+
* means this token has no revocable session to slide (no `jti` — team
|
|
7346
|
+
* impersonation is the case in practice) and can never be refreshed,
|
|
7347
|
+
* though it stays valid for ordinary calls.
|
|
7348
|
+
*/
|
|
7349
|
+
refreshSession(): Promise<TokenResponse>;
|
|
7305
7350
|
/**
|
|
7306
7351
|
* Make a raw HTTP request to the Delopay API.
|
|
7307
7352
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -6503,6 +6503,31 @@ declare class Users {
|
|
|
6503
6503
|
signUp(params: SignUpRequest | SignUpWithMerchantRequest): Promise<AuthResponse>;
|
|
6504
6504
|
signIn(params: SignInRequest): Promise<AuthResponse>;
|
|
6505
6505
|
signOut(): Promise<Record<string, unknown>>;
|
|
6506
|
+
/**
|
|
6507
|
+
* Sliding-session refresh: exchange the current (still-valid) login JWT
|
|
6508
|
+
* for a fresh one with the same claims and a full lifetime. The backend
|
|
6509
|
+
* keeps the session's identity (`jti`), slides `user_session.expires_at`
|
|
6510
|
+
* forward and re-sets the `login_token` cookie.
|
|
6511
|
+
*
|
|
6512
|
+
* Requires a token backed by a revocable session (a `jti` claim). Signin
|
|
6513
|
+
* and switch-merchant/-profile tokens have one; **session-less tokens do
|
|
6514
|
+
* not and are rejected with 400** — team-impersonation tokens are the
|
|
6515
|
+
* case in practice, and they are deliberately tab-scoped and
|
|
6516
|
+
* time-bounded rather than renewable. A 400 here is not a dead session:
|
|
6517
|
+
* the token remains valid for ordinary calls, it simply cannot slide.
|
|
6518
|
+
*
|
|
6519
|
+
* Rejected (401) for expired, blacklisted or revoked tokens — refresh can
|
|
6520
|
+
* only extend a session that is still alive. Rate-limited server-side
|
|
6521
|
+
* (429) to one mint per session per minute; treat a 429 as "still fresh
|
|
6522
|
+
* enough", not as an error.
|
|
6523
|
+
*
|
|
6524
|
+
* The returned token is NOT applied to this client automatically — pass
|
|
6525
|
+
* it to `setJwtToken()`, or use {@link Delopay.refreshSession} which does
|
|
6526
|
+
* both.
|
|
6527
|
+
*
|
|
6528
|
+
* `POST /user/token/refresh`. Requires a logged-in JWT.
|
|
6529
|
+
*/
|
|
6530
|
+
refreshToken(): Promise<TokenResponse>;
|
|
6506
6531
|
/**
|
|
6507
6532
|
* Paginated login history for the authenticated user -- IP, User-Agent,
|
|
6508
6533
|
* country / city / lat-lon (when GeoIP is enabled), success and failure
|
|
@@ -7302,6 +7327,26 @@ declare class Delopay {
|
|
|
7302
7327
|
* Clear the JWT token, reverting to API key authentication.
|
|
7303
7328
|
*/
|
|
7304
7329
|
clearJwtToken(): void;
|
|
7330
|
+
/**
|
|
7331
|
+
* Refresh the current login JWT (see {@link Users.refreshToken}) and
|
|
7332
|
+
* apply the fresh token to this client, so subsequent requests use it.
|
|
7333
|
+
* Returns the fresh token for the caller to persist (e.g. session
|
|
7334
|
+
* storage) — the backend has already re-set the `login_token` cookie.
|
|
7335
|
+
*
|
|
7336
|
+
* If the client's auth state changes while the refresh is pending —
|
|
7337
|
+
* `clearJwtToken()` on sign-out, or `setJwtToken()` switching to another
|
|
7338
|
+
* session — the stale completion is discarded and this rejects with a
|
|
7339
|
+
* `session_changed` `DelopayError` (status 0), so the explicit change
|
|
7340
|
+
* wins and the caller never persists a token for a session that is gone.
|
|
7341
|
+
*
|
|
7342
|
+
* Otherwise throws like any other request; in particular a 401 means the
|
|
7343
|
+
* session is dead (expired/blacklisted/revoked), a 429 means a refresh
|
|
7344
|
+
* was already minted for this session within the last minute, and a 400
|
|
7345
|
+
* means this token has no revocable session to slide (no `jti` — team
|
|
7346
|
+
* impersonation is the case in practice) and can never be refreshed,
|
|
7347
|
+
* though it stays valid for ordinary calls.
|
|
7348
|
+
*/
|
|
7349
|
+
refreshSession(): Promise<TokenResponse>;
|
|
7305
7350
|
/**
|
|
7306
7351
|
* Make a raw HTTP request to the Delopay API.
|
|
7307
7352
|
*
|
package/dist/index.js
CHANGED
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
|
|
@@ -4070,6 +4097,41 @@ var Delopay = class {
|
|
|
4070
4097
|
clearJwtToken() {
|
|
4071
4098
|
this.jwtToken = void 0;
|
|
4072
4099
|
}
|
|
4100
|
+
/**
|
|
4101
|
+
* Refresh the current login JWT (see {@link Users.refreshToken}) and
|
|
4102
|
+
* apply the fresh token to this client, so subsequent requests use it.
|
|
4103
|
+
* Returns the fresh token for the caller to persist (e.g. session
|
|
4104
|
+
* storage) — the backend has already re-set the `login_token` cookie.
|
|
4105
|
+
*
|
|
4106
|
+
* If the client's auth state changes while the refresh is pending —
|
|
4107
|
+
* `clearJwtToken()` on sign-out, or `setJwtToken()` switching to another
|
|
4108
|
+
* session — the stale completion is discarded and this rejects with a
|
|
4109
|
+
* `session_changed` `DelopayError` (status 0), so the explicit change
|
|
4110
|
+
* wins and the caller never persists a token for a session that is gone.
|
|
4111
|
+
*
|
|
4112
|
+
* Otherwise throws like any other request; in particular a 401 means the
|
|
4113
|
+
* session is dead (expired/blacklisted/revoked), a 429 means a refresh
|
|
4114
|
+
* was already minted for this session within the last minute, and a 400
|
|
4115
|
+
* means this token has no revocable session to slide (no `jti` — team
|
|
4116
|
+
* impersonation is the case in practice) and can never be refreshed,
|
|
4117
|
+
* though it stays valid for ordinary calls.
|
|
4118
|
+
*/
|
|
4119
|
+
async refreshSession() {
|
|
4120
|
+
const originatingToken = this.jwtToken;
|
|
4121
|
+
const response = await this.users.refreshToken();
|
|
4122
|
+
if (this.jwtToken !== originatingToken) {
|
|
4123
|
+
throw new DelopayError(
|
|
4124
|
+
"Auth state changed while the refresh was pending; refreshed token discarded",
|
|
4125
|
+
{
|
|
4126
|
+
status: 0,
|
|
4127
|
+
code: "session_changed",
|
|
4128
|
+
type: "session_changed"
|
|
4129
|
+
}
|
|
4130
|
+
);
|
|
4131
|
+
}
|
|
4132
|
+
this.setJwtToken(response.token);
|
|
4133
|
+
return response;
|
|
4134
|
+
}
|
|
4073
4135
|
/**
|
|
4074
4136
|
* Make a raw HTTP request to the Delopay API.
|
|
4075
4137
|
*
|