@stxapp/stx-typescript 0.6.1 → 0.6.2
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 +4 -0
- package/dist/{chunk-7O5ZGZQI.cjs → chunk-WGIYEJBI.cjs} +159 -28
- package/dist/chunk-WGIYEJBI.cjs.map +1 -0
- package/dist/{chunk-P7ZEHWKM.js → chunk-X7B7WXJ3.js} +141 -10
- package/dist/chunk-X7B7WXJ3.js.map +1 -0
- package/dist/{client-wriBXPDx.d.cts → client-C0G5lsiP.d.cts} +13 -8
- package/dist/{client-wriBXPDx.d.ts → client-C0G5lsiP.d.ts} +13 -8
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/oauth.cjs +17 -17
- package/dist/oauth.d.cts +2 -2
- package/dist/oauth.d.ts +2 -2
- package/dist/oauth.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-7O5ZGZQI.cjs.map +0 -1
- package/dist/chunk-P7ZEHWKM.js.map +0 -1
|
@@ -2370,9 +2370,9 @@ declare class STXValidationException extends STXAPIException {
|
|
|
2370
2370
|
declare class STXAuthenticationException extends STXAPIException {
|
|
2371
2371
|
}
|
|
2372
2372
|
/**
|
|
2373
|
-
* 403: the key is read-only, or the account may not do this.
|
|
2374
|
-
*
|
|
2375
|
-
*
|
|
2373
|
+
* 403: the key is read-only, or the account may not do this. When the server
|
|
2374
|
+
* names the scopes that would satisfy the call (in the `WWW-Authenticate`
|
|
2375
|
+
* challenge), `requiredScopes` lists them.
|
|
2376
2376
|
*/
|
|
2377
2377
|
declare class STXForbiddenException extends STXAPIException {
|
|
2378
2378
|
readonly requiredScopes: readonly string[];
|
|
@@ -2556,8 +2556,8 @@ declare class ApiKeyCredentials implements AuthProvider {
|
|
|
2556
2556
|
toString(): string;
|
|
2557
2557
|
}
|
|
2558
2558
|
|
|
2559
|
-
declare const VERSION = "0.6.
|
|
2560
|
-
declare const USER_AGENT = "stx-typescript/0.6.
|
|
2559
|
+
declare const VERSION = "0.6.2";
|
|
2560
|
+
declare const USER_AGENT = "stx-typescript/0.6.2";
|
|
2561
2561
|
/**
|
|
2562
2562
|
* `Symbol.asyncDispose` where the runtime has it (Node 20+, Bun), so
|
|
2563
2563
|
* `await using client = new STX()` works there; a registered stand-in on
|
|
@@ -3212,9 +3212,14 @@ declare class STX {
|
|
|
3212
3212
|
*/
|
|
3213
3213
|
me(): Promise<Me>;
|
|
3214
3214
|
/**
|
|
3215
|
-
* The
|
|
3216
|
-
*
|
|
3217
|
-
|
|
3215
|
+
* @internal The cached `me()` when it has both ids, else a fresh `me()`.
|
|
3216
|
+
* Never falls back to `balance()`, so the channel fallbacks can use it.
|
|
3217
|
+
*/
|
|
3218
|
+
_identity(): Promise<Me>;
|
|
3219
|
+
/**
|
|
3220
|
+
* The user id from `me()`, fetched once and cached. If `me()` is not
|
|
3221
|
+
* permitted, the id comes from `balance()`, which carries the same
|
|
3222
|
+
* `user_id`.
|
|
3218
3223
|
*/
|
|
3219
3224
|
userId(): Promise<string>;
|
|
3220
3225
|
/**
|
|
@@ -2370,9 +2370,9 @@ declare class STXValidationException extends STXAPIException {
|
|
|
2370
2370
|
declare class STXAuthenticationException extends STXAPIException {
|
|
2371
2371
|
}
|
|
2372
2372
|
/**
|
|
2373
|
-
* 403: the key is read-only, or the account may not do this.
|
|
2374
|
-
*
|
|
2375
|
-
*
|
|
2373
|
+
* 403: the key is read-only, or the account may not do this. When the server
|
|
2374
|
+
* names the scopes that would satisfy the call (in the `WWW-Authenticate`
|
|
2375
|
+
* challenge), `requiredScopes` lists them.
|
|
2376
2376
|
*/
|
|
2377
2377
|
declare class STXForbiddenException extends STXAPIException {
|
|
2378
2378
|
readonly requiredScopes: readonly string[];
|
|
@@ -2556,8 +2556,8 @@ declare class ApiKeyCredentials implements AuthProvider {
|
|
|
2556
2556
|
toString(): string;
|
|
2557
2557
|
}
|
|
2558
2558
|
|
|
2559
|
-
declare const VERSION = "0.6.
|
|
2560
|
-
declare const USER_AGENT = "stx-typescript/0.6.
|
|
2559
|
+
declare const VERSION = "0.6.2";
|
|
2560
|
+
declare const USER_AGENT = "stx-typescript/0.6.2";
|
|
2561
2561
|
/**
|
|
2562
2562
|
* `Symbol.asyncDispose` where the runtime has it (Node 20+, Bun), so
|
|
2563
2563
|
* `await using client = new STX()` works there; a registered stand-in on
|
|
@@ -3212,9 +3212,14 @@ declare class STX {
|
|
|
3212
3212
|
*/
|
|
3213
3213
|
me(): Promise<Me>;
|
|
3214
3214
|
/**
|
|
3215
|
-
* The
|
|
3216
|
-
*
|
|
3217
|
-
|
|
3215
|
+
* @internal The cached `me()` when it has both ids, else a fresh `me()`.
|
|
3216
|
+
* Never falls back to `balance()`, so the channel fallbacks can use it.
|
|
3217
|
+
*/
|
|
3218
|
+
_identity(): Promise<Me>;
|
|
3219
|
+
/**
|
|
3220
|
+
* The user id from `me()`, fetched once and cached. If `me()` is not
|
|
3221
|
+
* permitted, the id comes from `balance()`, which carries the same
|
|
3222
|
+
* `user_id`.
|
|
3218
3223
|
*/
|
|
3219
3224
|
userId(): Promise<string>;
|
|
3220
3225
|
/**
|
package/dist/index.cjs
CHANGED
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
|
|
58
58
|
|
|
59
59
|
|
|
60
|
-
var
|
|
60
|
+
var _chunkWGIYEJBIcjs = require('./chunk-WGIYEJBI.cjs');
|
|
61
61
|
|
|
62
62
|
|
|
63
63
|
|
|
@@ -117,5 +117,5 @@ var _chunk7O5ZGZQIcjs = require('./chunk-7O5ZGZQI.cjs');
|
|
|
117
117
|
|
|
118
118
|
|
|
119
119
|
|
|
120
|
-
exports.AccountView =
|
|
120
|
+
exports.AccountView = _chunkWGIYEJBIcjs.AccountView; exports.ApiKeyCredentials = _chunkWGIYEJBIcjs.ApiKeyCredentials; exports.Channel = _chunkWGIYEJBIcjs.Channel; exports.ChannelMessage = _chunkWGIYEJBIcjs.ChannelMessage; exports.Environment = _chunkWGIYEJBIcjs.Environment; exports.Environments = _chunkWGIYEJBIcjs.Environments; exports.HOSTS = _chunkWGIYEJBIcjs.HOSTS; exports.KEY_HEADER = _chunkWGIYEJBIcjs.KEY_HEADER; exports.NO_RETRY = _chunkWGIYEJBIcjs.NO_RETRY; exports.OPERATIONS = _chunkWGIYEJBIcjs.OPERATIONS; exports.Page = _chunkWGIYEJBIcjs.Page; exports.ReconnectPolicy = _chunkWGIYEJBIcjs.ReconnectPolicy; exports.Region = _chunkWGIYEJBIcjs.Region; exports.RetryPolicy = _chunkWGIYEJBIcjs.RetryPolicy; exports.SIGNATURE_HEADER = _chunkWGIYEJBIcjs.SIGNATURE_HEADER; exports.SNAPSHOT_EVENTS = _chunkWGIYEJBIcjs.SNAPSHOT_EVENTS; exports.STX = _chunkWGIYEJBIcjs.STX; exports.STXAPIException = _chunkWGIYEJBIcjs.STXAPIException; exports.STXAuthenticationException = _chunkWGIYEJBIcjs.STXAuthenticationException; exports.STXChannelException = _chunkWGIYEJBIcjs.STXChannelException; exports.STXConfigException = _chunkWGIYEJBIcjs.STXConfigException; exports.STXException = _chunkWGIYEJBIcjs.STXException; exports.STXForbiddenException = _chunkWGIYEJBIcjs.STXForbiddenException; exports.STXGeoLocationException = _chunkWGIYEJBIcjs.STXGeoLocationException; exports.STXInsufficientScopeException = _chunkWGIYEJBIcjs.STXInsufficientScopeException; exports.STXInvalidTokenException = _chunkWGIYEJBIcjs.STXInvalidTokenException; exports.STXNotFoundException = _chunkWGIYEJBIcjs.STXNotFoundException; exports.STXRateLimitException = _chunkWGIYEJBIcjs.STXRateLimitException; exports.STXRejectedException = _chunkWGIYEJBIcjs.STXRejectedException; exports.STXServerException = _chunkWGIYEJBIcjs.STXServerException; exports.STXTimeoutException = _chunkWGIYEJBIcjs.STXTimeoutException; exports.STXTransportException = _chunkWGIYEJBIcjs.STXTransportException; exports.STXValidationException = _chunkWGIYEJBIcjs.STXValidationException; exports.STXWebSocket = _chunkWGIYEJBIcjs.STXWebSocket; exports.TERMINAL_ORDER_STATUSES = _chunkWGIYEJBIcjs.TERMINAL_ORDER_STATUSES; exports.TIMESTAMP_HEADER = _chunkWGIYEJBIcjs.TIMESTAMP_HEADER; exports.USER_AGENT = _chunkWGIYEJBIcjs.USER_AGENT; exports.VERSION = _chunkWGIYEJBIcjs.VERSION; exports.baseUrlFor = _chunkWGIYEJBIcjs.baseUrlFor; exports.buildMessage = _chunkWGIYEJBIcjs.buildMessage; exports.centsToDollars = _chunkWGIYEJBIcjs.centsToDollars; exports.convertBook = _chunkWGIYEJBIcjs.convertBook; exports.convertMarketChannelPayload = _chunkWGIYEJBIcjs.convertMarketChannelPayload; exports.convertMarketPayload = _chunkWGIYEJBIcjs.convertMarketPayload; exports.convertMarketsFrame = _chunkWGIYEJBIcjs.convertMarketsFrame; exports.environmentNamed = _chunkWGIYEJBIcjs.environmentNamed; exports.errorForStatus = _chunkWGIYEJBIcjs.errorForStatus; exports.geoRejection = _chunkWGIYEJBIcjs.geoRejection; exports.handshakePath = _chunkWGIYEJBIcjs.handshakePath; exports.loadPrivateKey = _chunkWGIYEJBIcjs.loadPrivateKey; exports.orderBody = _chunkWGIYEJBIcjs.orderBody; exports.requestPath = _chunkWGIYEJBIcjs.requestPath; exports.resolveHost = _chunkWGIYEJBIcjs.resolveHost; exports.resolveSettings = _chunkWGIYEJBIcjs.resolveSettings; exports.signerFromPrivateKey = _chunkWGIYEJBIcjs.signerFromPrivateKey; exports.socketUrlFor = _chunkWGIYEJBIcjs.socketUrlFor; exports.toDollarString = _chunkWGIYEJBIcjs.toDollarString; exports.toQuantity = _chunkWGIYEJBIcjs.toQuantity;
|
|
121
121
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AcceptTermsOptions, a as AccountChange, b as AccountChangeKind, c as AccountState, d as AccountView, e as AccountViewOptions, f as ApiKeyCredentials, g as AuthProvider, h as AuthRequest, B as Balance, i as BatchOrderResult, j as BookLevel, C as Cancellation, k as Channel, l as ChannelMessage, E as Environment, m as Environments, n as Error, o as Event, p as EventsQuery, F as FeeTransaction, q as FetchLike, r as Fill, s as FillsQuery, G as GeoCheckResult, t as GeoLocationProvider, u as GeoOption, v as GeoRejection, H as HOSTS, K as KEY_HEADER, L as Logger, M as Market, w as MarketFilter, x as MarketStat, y as MarketStatsQuery, z as MarketsQuery, D as Me, I as MessageHandler, N as NO_RETRY, J as NewOrder, O as NewOrderInput, P as OPERATIONS, Q as Operation, R as OperationId, S as Order, T as OrderOptions, U as OrdersQuery, V as Page, W as PageQuery, X as PaymentTransaction, Y as Position, Z as PrivateKeyInput, _ as RecentTrade, $ as ReconnectPolicy, a0 as ReconnectPolicyOptions, a1 as Region, a2 as ResponseEvent, a3 as RetryPolicy, a4 as RetryPolicyOptions, a5 as SIGNATURE_HEADER, a6 as SNAPSHOT_EVENTS, a7 as STX, a8 as STXAPIException, a9 as STXAuthenticationException, aa as STXChannelException, ab as STXConfigException, ac as STXEnvironment, ad as STXException, ae as STXForbiddenException, af as STXGeoLocationException, ag as STXInsufficientScopeException, ah as STXInvalidTokenException, ai as STXNotFoundException, aj as STXOptions, ak as STXRateLimitException, al as STXRejectedException, am as STXServerException, an as STXTimeoutException, ao as STXTransportException, ap as STXValidationException, aq as STXWebSocket, ar as STXWebSocketOptions, as as Settlement, at as SettlementsQuery, au as Signer, av as StatDetail, aw as StrList, ax as TERMINAL_ORDER_STATUSES, ay as TIMESTAMP_HEADER, az as Transaction, aA as USER_AGENT, aB as VERSION, aC as WebSocketAuthContext, aD as baseUrlFor, aE as buildMessage, aF as environmentNamed, aG as errorForStatus, aH as geoRejection, aI as handshakePath, aJ as loadPrivateKey, aK as models, aL as orderBody, aM as requestPath, aN as resolveHost, aO as signerFromPrivateKey, aP as socketUrlFor } from './client-
|
|
1
|
+
export { A as AcceptTermsOptions, a as AccountChange, b as AccountChangeKind, c as AccountState, d as AccountView, e as AccountViewOptions, f as ApiKeyCredentials, g as AuthProvider, h as AuthRequest, B as Balance, i as BatchOrderResult, j as BookLevel, C as Cancellation, k as Channel, l as ChannelMessage, E as Environment, m as Environments, n as Error, o as Event, p as EventsQuery, F as FeeTransaction, q as FetchLike, r as Fill, s as FillsQuery, G as GeoCheckResult, t as GeoLocationProvider, u as GeoOption, v as GeoRejection, H as HOSTS, K as KEY_HEADER, L as Logger, M as Market, w as MarketFilter, x as MarketStat, y as MarketStatsQuery, z as MarketsQuery, D as Me, I as MessageHandler, N as NO_RETRY, J as NewOrder, O as NewOrderInput, P as OPERATIONS, Q as Operation, R as OperationId, S as Order, T as OrderOptions, U as OrdersQuery, V as Page, W as PageQuery, X as PaymentTransaction, Y as Position, Z as PrivateKeyInput, _ as RecentTrade, $ as ReconnectPolicy, a0 as ReconnectPolicyOptions, a1 as Region, a2 as ResponseEvent, a3 as RetryPolicy, a4 as RetryPolicyOptions, a5 as SIGNATURE_HEADER, a6 as SNAPSHOT_EVENTS, a7 as STX, a8 as STXAPIException, a9 as STXAuthenticationException, aa as STXChannelException, ab as STXConfigException, ac as STXEnvironment, ad as STXException, ae as STXForbiddenException, af as STXGeoLocationException, ag as STXInsufficientScopeException, ah as STXInvalidTokenException, ai as STXNotFoundException, aj as STXOptions, ak as STXRateLimitException, al as STXRejectedException, am as STXServerException, an as STXTimeoutException, ao as STXTransportException, ap as STXValidationException, aq as STXWebSocket, ar as STXWebSocketOptions, as as Settlement, at as SettlementsQuery, au as Signer, av as StatDetail, aw as StrList, ax as TERMINAL_ORDER_STATUSES, ay as TIMESTAMP_HEADER, az as Transaction, aA as USER_AGENT, aB as VERSION, aC as WebSocketAuthContext, aD as baseUrlFor, aE as buildMessage, aF as environmentNamed, aG as errorForStatus, aH as geoRejection, aI as handshakePath, aJ as loadPrivateKey, aK as models, aL as orderBody, aM as requestPath, aN as resolveHost, aO as signerFromPrivateKey, aP as socketUrlFor } from './client-C0G5lsiP.cjs';
|
|
2
2
|
import 'node:crypto';
|
|
3
3
|
|
|
4
4
|
/** The fully resolved configuration the clients consume. */
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AcceptTermsOptions, a as AccountChange, b as AccountChangeKind, c as AccountState, d as AccountView, e as AccountViewOptions, f as ApiKeyCredentials, g as AuthProvider, h as AuthRequest, B as Balance, i as BatchOrderResult, j as BookLevel, C as Cancellation, k as Channel, l as ChannelMessage, E as Environment, m as Environments, n as Error, o as Event, p as EventsQuery, F as FeeTransaction, q as FetchLike, r as Fill, s as FillsQuery, G as GeoCheckResult, t as GeoLocationProvider, u as GeoOption, v as GeoRejection, H as HOSTS, K as KEY_HEADER, L as Logger, M as Market, w as MarketFilter, x as MarketStat, y as MarketStatsQuery, z as MarketsQuery, D as Me, I as MessageHandler, N as NO_RETRY, J as NewOrder, O as NewOrderInput, P as OPERATIONS, Q as Operation, R as OperationId, S as Order, T as OrderOptions, U as OrdersQuery, V as Page, W as PageQuery, X as PaymentTransaction, Y as Position, Z as PrivateKeyInput, _ as RecentTrade, $ as ReconnectPolicy, a0 as ReconnectPolicyOptions, a1 as Region, a2 as ResponseEvent, a3 as RetryPolicy, a4 as RetryPolicyOptions, a5 as SIGNATURE_HEADER, a6 as SNAPSHOT_EVENTS, a7 as STX, a8 as STXAPIException, a9 as STXAuthenticationException, aa as STXChannelException, ab as STXConfigException, ac as STXEnvironment, ad as STXException, ae as STXForbiddenException, af as STXGeoLocationException, ag as STXInsufficientScopeException, ah as STXInvalidTokenException, ai as STXNotFoundException, aj as STXOptions, ak as STXRateLimitException, al as STXRejectedException, am as STXServerException, an as STXTimeoutException, ao as STXTransportException, ap as STXValidationException, aq as STXWebSocket, ar as STXWebSocketOptions, as as Settlement, at as SettlementsQuery, au as Signer, av as StatDetail, aw as StrList, ax as TERMINAL_ORDER_STATUSES, ay as TIMESTAMP_HEADER, az as Transaction, aA as USER_AGENT, aB as VERSION, aC as WebSocketAuthContext, aD as baseUrlFor, aE as buildMessage, aF as environmentNamed, aG as errorForStatus, aH as geoRejection, aI as handshakePath, aJ as loadPrivateKey, aK as models, aL as orderBody, aM as requestPath, aN as resolveHost, aO as signerFromPrivateKey, aP as socketUrlFor } from './client-
|
|
1
|
+
export { A as AcceptTermsOptions, a as AccountChange, b as AccountChangeKind, c as AccountState, d as AccountView, e as AccountViewOptions, f as ApiKeyCredentials, g as AuthProvider, h as AuthRequest, B as Balance, i as BatchOrderResult, j as BookLevel, C as Cancellation, k as Channel, l as ChannelMessage, E as Environment, m as Environments, n as Error, o as Event, p as EventsQuery, F as FeeTransaction, q as FetchLike, r as Fill, s as FillsQuery, G as GeoCheckResult, t as GeoLocationProvider, u as GeoOption, v as GeoRejection, H as HOSTS, K as KEY_HEADER, L as Logger, M as Market, w as MarketFilter, x as MarketStat, y as MarketStatsQuery, z as MarketsQuery, D as Me, I as MessageHandler, N as NO_RETRY, J as NewOrder, O as NewOrderInput, P as OPERATIONS, Q as Operation, R as OperationId, S as Order, T as OrderOptions, U as OrdersQuery, V as Page, W as PageQuery, X as PaymentTransaction, Y as Position, Z as PrivateKeyInput, _ as RecentTrade, $ as ReconnectPolicy, a0 as ReconnectPolicyOptions, a1 as Region, a2 as ResponseEvent, a3 as RetryPolicy, a4 as RetryPolicyOptions, a5 as SIGNATURE_HEADER, a6 as SNAPSHOT_EVENTS, a7 as STX, a8 as STXAPIException, a9 as STXAuthenticationException, aa as STXChannelException, ab as STXConfigException, ac as STXEnvironment, ad as STXException, ae as STXForbiddenException, af as STXGeoLocationException, ag as STXInsufficientScopeException, ah as STXInvalidTokenException, ai as STXNotFoundException, aj as STXOptions, ak as STXRateLimitException, al as STXRejectedException, am as STXServerException, an as STXTimeoutException, ao as STXTransportException, ap as STXValidationException, aq as STXWebSocket, ar as STXWebSocketOptions, as as Settlement, at as SettlementsQuery, au as Signer, av as StatDetail, aw as StrList, ax as TERMINAL_ORDER_STATUSES, ay as TIMESTAMP_HEADER, az as Transaction, aA as USER_AGENT, aB as VERSION, aC as WebSocketAuthContext, aD as baseUrlFor, aE as buildMessage, aF as environmentNamed, aG as errorForStatus, aH as geoRejection, aI as handshakePath, aJ as loadPrivateKey, aK as models, aL as orderBody, aM as requestPath, aN as resolveHost, aO as signerFromPrivateKey, aP as socketUrlFor } from './client-C0G5lsiP.js';
|
|
2
2
|
import 'node:crypto';
|
|
3
3
|
|
|
4
4
|
/** The fully resolved configuration the clients consume. */
|
package/dist/index.js
CHANGED
package/dist/oauth.cjs
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkWGIYEJBIcjs = require('./chunk-WGIYEJBI.cjs');
|
|
11
11
|
|
|
12
12
|
// src/oauth/endpoints.ts
|
|
13
13
|
var DEFAULT_ENDPOINTS = {
|
|
@@ -24,12 +24,12 @@ var WELL_KNOWN = {
|
|
|
24
24
|
function resolveOAuthConfig(input) {
|
|
25
25
|
const env = _nullishCoalesce(_optionalChain([globalThis, 'access', _ => _.process, 'optionalAccess', _2 => _2.env]), () => ( {}));
|
|
26
26
|
const host = _nullishCoalesce(_nullishCoalesce(input.baseUrl, () => ( env.STX_HOST)), () => ( env.STX_BASE_URL));
|
|
27
|
-
if (!host) throw new (0,
|
|
27
|
+
if (!host) throw new (0, _chunkWGIYEJBIcjs.STXConfigException)("An OAuth base URL is required. Pass { baseUrl } or set STX_HOST.");
|
|
28
28
|
const fetchImpl = _nullishCoalesce(input.fetch, () => ( globalThis.fetch));
|
|
29
29
|
if (typeof fetchImpl !== "function") {
|
|
30
|
-
throw new (0,
|
|
30
|
+
throw new (0, _chunkWGIYEJBIcjs.STXConfigException)("No fetch implementation available. Use Node 18+, or pass { fetch }.");
|
|
31
31
|
}
|
|
32
|
-
return { baseUrl:
|
|
32
|
+
return { baseUrl: _chunkWGIYEJBIcjs.baseUrlFor.call(void 0, null, null, host), fetch: fetchImpl };
|
|
33
33
|
}
|
|
34
34
|
function joinUrl(baseUrl, path) {
|
|
35
35
|
if (/^https?:\/\//i.test(path)) return path;
|
|
@@ -37,7 +37,7 @@ function joinUrl(baseUrl, path) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
// src/oauth/errors.ts
|
|
40
|
-
var STXOAuthException = class extends
|
|
40
|
+
var STXOAuthException = class extends _chunkWGIYEJBIcjs.STXAuthenticationException {
|
|
41
41
|
/** The RFC error code: `invalid_client`, `invalid_grant`, `invalid_scope`, ... */
|
|
42
42
|
|
|
43
43
|
|
|
@@ -56,7 +56,7 @@ var STXOAuthException = class extends _chunk7O5ZGZQIcjs.STXAuthenticationExcepti
|
|
|
56
56
|
this.retryAfter = retryAfter;
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
|
-
var STXGrantRevokedException = class extends
|
|
59
|
+
var STXGrantRevokedException = class extends _chunkWGIYEJBIcjs.STXAuthenticationException {
|
|
60
60
|
constructor(message = "OAuth grant revoked: the member must re-authorize.") {
|
|
61
61
|
super(message, { statusCode: 400 });
|
|
62
62
|
}
|
|
@@ -141,7 +141,7 @@ function rfcError(text) {
|
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
function httpError(status, text, path) {
|
|
144
|
-
return new (0,
|
|
144
|
+
return new (0, _chunkWGIYEJBIcjs.STXAPIException)(`HTTP ${status} from ${path}: ${text.slice(0, 500)}`, {
|
|
145
145
|
statusCode: status,
|
|
146
146
|
body: text,
|
|
147
147
|
path
|
|
@@ -290,7 +290,7 @@ var OAuthClient = (_class = class _OAuthClient {
|
|
|
290
290
|
*/
|
|
291
291
|
async beginAuthorization(pending, params = {}) {
|
|
292
292
|
const redirectUri = _nullishCoalesce(params.redirectUri, () => ( this.redirectUri));
|
|
293
|
-
if (!redirectUri) throw new (0,
|
|
293
|
+
if (!redirectUri) throw new (0, _chunkWGIYEJBIcjs.STXConfigException)("redirectUri is required to build an authorize URL.");
|
|
294
294
|
const auth = await this.authorizationUrl({ ...params, redirectUri });
|
|
295
295
|
await pending.put(auth.state, {
|
|
296
296
|
codeVerifier: auth.codeVerifier,
|
|
@@ -332,7 +332,7 @@ var OAuthClient = (_class = class _OAuthClient {
|
|
|
332
332
|
let memberKey;
|
|
333
333
|
if (opts.store) {
|
|
334
334
|
memberKey = typeof opts.memberKey === "function" ? opts.memberKey(entry.data) : opts.memberKey;
|
|
335
|
-
if (!memberKey) throw new (0,
|
|
335
|
+
if (!memberKey) throw new (0, _chunkWGIYEJBIcjs.STXConfigException)("Pass memberKey along with store.");
|
|
336
336
|
await opts.store.set(memberKey, tokenSetToStored(tokens));
|
|
337
337
|
}
|
|
338
338
|
return { tokens, scopes: parseScopes(tokens.scope), data: entry.data, memberKey };
|
|
@@ -341,7 +341,7 @@ var OAuthClient = (_class = class _OAuthClient {
|
|
|
341
341
|
buildAuthorizeUrl(params) {
|
|
342
342
|
const redirectUri = _nullishCoalesce(params.redirectUri, () => ( this.redirectUri));
|
|
343
343
|
if (!redirectUri) {
|
|
344
|
-
throw new (0,
|
|
344
|
+
throw new (0, _chunkWGIYEJBIcjs.STXConfigException)("redirectUri is required to build an authorize URL.");
|
|
345
345
|
}
|
|
346
346
|
const url = new URL(joinUrl(this.baseUrl, this.endpoints.authorize));
|
|
347
347
|
const search = {
|
|
@@ -363,7 +363,7 @@ var OAuthClient = (_class = class _OAuthClient {
|
|
|
363
363
|
exchangeCode(args) {
|
|
364
364
|
const redirectUri = _nullishCoalesce(args.redirectUri, () => ( this.redirectUri));
|
|
365
365
|
if (!redirectUri) {
|
|
366
|
-
throw new (0,
|
|
366
|
+
throw new (0, _chunkWGIYEJBIcjs.STXConfigException)("redirectUri is required to exchange a code.");
|
|
367
367
|
}
|
|
368
368
|
return this.postToken(
|
|
369
369
|
new URLSearchParams({
|
|
@@ -404,7 +404,7 @@ var OAuthClient = (_class = class _OAuthClient {
|
|
|
404
404
|
*/
|
|
405
405
|
clientCredentials(scope) {
|
|
406
406
|
if (this.isPublic) {
|
|
407
|
-
throw new (0,
|
|
407
|
+
throw new (0, _chunkWGIYEJBIcjs.STXConfigException)(
|
|
408
408
|
"client_credentials needs a client secret; a public client cannot mint an app token."
|
|
409
409
|
);
|
|
410
410
|
}
|
|
@@ -508,7 +508,7 @@ var OAuthClient = (_class = class _OAuthClient {
|
|
|
508
508
|
*/
|
|
509
509
|
memberClient(store, memberKey, opts = {}) {
|
|
510
510
|
const { session, ...rest } = opts;
|
|
511
|
-
return new (0,
|
|
511
|
+
return new (0, _chunkWGIYEJBIcjs.STX)({
|
|
512
512
|
...rest,
|
|
513
513
|
host: this.baseUrl,
|
|
514
514
|
fetch: _nullishCoalesce(rest.fetch, () => ( this.fetch)),
|
|
@@ -521,7 +521,7 @@ var OAuthClient = (_class = class _OAuthClient {
|
|
|
521
521
|
* market channels. Scope defaults to every app scope the client may hold.
|
|
522
522
|
*/
|
|
523
523
|
appClient(scope, opts = {}) {
|
|
524
|
-
return new (0,
|
|
524
|
+
return new (0, _chunkWGIYEJBIcjs.STX)({ ...opts, host: this.baseUrl, fetch: _nullishCoalesce(opts.fetch, () => ( this.fetch)), auth: this.app(scope) });
|
|
525
525
|
}
|
|
526
526
|
/** @internal The in-flight refresh map for one store; see `OAuthSessionAuth`. */
|
|
527
527
|
_refreshesFor(store) {
|
|
@@ -697,7 +697,7 @@ var OAuthSessionAuth = (_class4 = class {
|
|
|
697
697
|
async tokens() {
|
|
698
698
|
let tokens = await this.load();
|
|
699
699
|
if (!tokens) {
|
|
700
|
-
throw new (0,
|
|
700
|
+
throw new (0, _chunkWGIYEJBIcjs.STXConfigException)(`No tokens stored for member "${this.memberKey}". Complete the OAuth flow first.`);
|
|
701
701
|
}
|
|
702
702
|
if (tokens.refreshToken && tokens.expiresAt !== void 0 && tokens.expiresAt - Date.now() <= this.skewMs) {
|
|
703
703
|
const refreshed = await this.refresh(tokens.refreshToken);
|
|
@@ -879,7 +879,7 @@ async function fetchWellKnown(baseUrl, path, opts) {
|
|
|
879
879
|
}
|
|
880
880
|
}
|
|
881
881
|
function httpError2(status, text, path) {
|
|
882
|
-
return new (0,
|
|
882
|
+
return new (0, _chunkWGIYEJBIcjs.STXAPIException)(`HTTP ${status} from ${path}: ${text.slice(0, 500)}`, {
|
|
883
883
|
statusCode: status,
|
|
884
884
|
body: text,
|
|
885
885
|
path
|
|
@@ -963,5 +963,5 @@ var MemoryPendingAuthorizationStore = (_class7 = class {constructor() { _class7.
|
|
|
963
963
|
|
|
964
964
|
|
|
965
965
|
|
|
966
|
-
exports.ALL_APP_SCOPES = ALL_APP_SCOPES; exports.ALL_MEMBER_SCOPES = ALL_MEMBER_SCOPES; exports.AppScopes = AppScopes; exports.AppTokenProvider = AppTokenProvider; exports.DEFAULT_ENDPOINTS = DEFAULT_ENDPOINTS; exports.LEGACY_SCOPES = LEGACY_SCOPES; exports.MemberScopes = MemberScopes; exports.MemoryPendingAuthorizationStore = MemoryPendingAuthorizationStore; exports.MemoryTokenStore = MemoryTokenStore; exports.OAuthAppAuth = OAuthAppAuth; exports.OAuthBearerAuth = OAuthBearerAuth; exports.OAuthClient = OAuthClient; exports.OAuthSessionAuth = OAuthSessionAuth; exports.STXAuthenticationException =
|
|
966
|
+
exports.ALL_APP_SCOPES = ALL_APP_SCOPES; exports.ALL_MEMBER_SCOPES = ALL_MEMBER_SCOPES; exports.AppScopes = AppScopes; exports.AppTokenProvider = AppTokenProvider; exports.DEFAULT_ENDPOINTS = DEFAULT_ENDPOINTS; exports.LEGACY_SCOPES = LEGACY_SCOPES; exports.MemberScopes = MemberScopes; exports.MemoryPendingAuthorizationStore = MemoryPendingAuthorizationStore; exports.MemoryTokenStore = MemoryTokenStore; exports.OAuthAppAuth = OAuthAppAuth; exports.OAuthBearerAuth = OAuthBearerAuth; exports.OAuthClient = OAuthClient; exports.OAuthSessionAuth = OAuthSessionAuth; exports.STXAuthenticationException = _chunkWGIYEJBIcjs.STXAuthenticationException; exports.STXForbiddenException = _chunkWGIYEJBIcjs.STXForbiddenException; exports.STXGrantRevokedException = STXGrantRevokedException; exports.STXInsufficientScopeException = _chunkWGIYEJBIcjs.STXInsufficientScopeException; exports.STXInvalidTokenException = _chunkWGIYEJBIcjs.STXInvalidTokenException; exports.STXOAuthException = STXOAuthException; exports.Scopes = Scopes; exports.WELL_KNOWN = WELL_KNOWN; exports.base64url = base64url; exports.canonicalScope = canonicalScope; exports.codeChallengeS256 = codeChallengeS256; exports.createPkce = createPkce; exports.discoverMetadata = discoverMetadata; exports.discoverProtectedResource = discoverProtectedResource; exports.formatScopes = formatScopes; exports.generateCodeVerifier = generateCodeVerifier; exports.generateState = generateState; exports.isAppScope = isAppScope; exports.isMemberScope = isMemberScope; exports.joinUrl = joinUrl; exports.parseScopes = parseScopes; exports.parseTokenResponse = parseTokenResponse; exports.readCallback = readCallback; exports.registerClient = registerClient; exports.rfcError = rfcError; exports.tokenSetToStored = tokenSetToStored;
|
|
967
967
|
//# sourceMappingURL=oauth.cjs.map
|
package/dist/oauth.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a9 as STXAuthenticationException, g as AuthProvider, h as AuthRequest, aC as WebSocketAuthContext, aj as STXOptions, a7 as STX } from './client-
|
|
2
|
-
export { ae as STXForbiddenException, ag as STXInsufficientScopeException, ah as STXInvalidTokenException } from './client-
|
|
1
|
+
import { a9 as STXAuthenticationException, g as AuthProvider, h as AuthRequest, aC as WebSocketAuthContext, aj as STXOptions, a7 as STX } from './client-C0G5lsiP.cjs';
|
|
2
|
+
export { ae as STXForbiddenException, ag as STXInsufficientScopeException, ah as STXInvalidTokenException } from './client-C0G5lsiP.cjs';
|
|
3
3
|
import 'node:crypto';
|
|
4
4
|
|
|
5
5
|
interface OAuthEndpoints$1 {
|
package/dist/oauth.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a9 as STXAuthenticationException, g as AuthProvider, h as AuthRequest, aC as WebSocketAuthContext, aj as STXOptions, a7 as STX } from './client-
|
|
2
|
-
export { ae as STXForbiddenException, ag as STXInsufficientScopeException, ah as STXInvalidTokenException } from './client-
|
|
1
|
+
import { a9 as STXAuthenticationException, g as AuthProvider, h as AuthRequest, aC as WebSocketAuthContext, aj as STXOptions, a7 as STX } from './client-C0G5lsiP.js';
|
|
2
|
+
export { ae as STXForbiddenException, ag as STXInsufficientScopeException, ah as STXInvalidTokenException } from './client-C0G5lsiP.js';
|
|
3
3
|
import 'node:crypto';
|
|
4
4
|
|
|
5
5
|
interface OAuthEndpoints$1 {
|
package/dist/oauth.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stxapp/stx-typescript",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "The TypeScript SDK for the STX exchange: markets, trading, your account and live WebSocket channels, with API-key signing and typed responses.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|