@stxapp/stx-typescript 0.6.2 → 0.7.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/CHANGELOG.md +8 -0
- package/dist/{chunk-WGIYEJBI.cjs → chunk-ASOLCDBG.cjs} +26 -157
- package/dist/chunk-ASOLCDBG.cjs.map +1 -0
- package/dist/{chunk-X7B7WXJ3.js → chunk-CDXZOW53.js} +8 -139
- package/dist/chunk-CDXZOW53.js.map +1 -0
- package/dist/{client-C0G5lsiP.d.cts → client-CA1d-osT.d.cts} +4 -9
- package/dist/{client-C0G5lsiP.d.ts → client-CA1d-osT.d.ts} +4 -9
- 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 +21 -21
- package/dist/oauth.cjs.map +1 -1
- package/dist/oauth.d.cts +8 -8
- package/dist/oauth.d.ts +8 -8
- package/dist/oauth.js +5 -5
- package/dist/oauth.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-WGIYEJBI.cjs.map +0 -1
- package/dist/chunk-X7B7WXJ3.js.map +0 -1
|
@@ -89,7 +89,7 @@ declare const Environments: {
|
|
|
89
89
|
readonly name: "ontario-production";
|
|
90
90
|
readonly region: "ontario";
|
|
91
91
|
readonly env: "production";
|
|
92
|
-
readonly host: "stxapp.ca";
|
|
92
|
+
readonly host: "api.on.stxapp.ca";
|
|
93
93
|
readonly realMoney: true;
|
|
94
94
|
};
|
|
95
95
|
};
|
|
@@ -2556,8 +2556,8 @@ declare class ApiKeyCredentials implements AuthProvider {
|
|
|
2556
2556
|
toString(): string;
|
|
2557
2557
|
}
|
|
2558
2558
|
|
|
2559
|
-
declare const VERSION = "0.
|
|
2560
|
-
declare const USER_AGENT = "stx-typescript/0.
|
|
2559
|
+
declare const VERSION = "0.7.0";
|
|
2560
|
+
declare const USER_AGENT = "stx-typescript/0.7.0";
|
|
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
|
|
@@ -3211,11 +3211,6 @@ declare class STX {
|
|
|
3211
3211
|
* (`read_only` or `read_write`).
|
|
3212
3212
|
*/
|
|
3213
3213
|
me(): Promise<Me>;
|
|
3214
|
-
/**
|
|
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
3214
|
/**
|
|
3220
3215
|
* The user id from `me()`, fetched once and cached. If `me()` is not
|
|
3221
3216
|
* permitted, the id comes from `balance()`, which carries the same
|
|
@@ -3309,7 +3304,7 @@ declare class STX {
|
|
|
3309
3304
|
balance(): Promise<Balance>;
|
|
3310
3305
|
/**
|
|
3311
3306
|
* `GET /api/v1/account/market_stats`: your exposure and P&L per market.
|
|
3312
|
-
* Not the
|
|
3307
|
+
* Not the `market_stats` WebSocket channel, which carries price history.
|
|
3313
3308
|
*/
|
|
3314
3309
|
accountMarketStats(query?: MarketStatsQuery): Promise<Page<MarketStat>>;
|
|
3315
3310
|
/** Every per-market stat row, following the cursor. */
|
package/dist/index.cjs
CHANGED
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
|
|
58
58
|
|
|
59
59
|
|
|
60
|
-
var
|
|
60
|
+
var _chunkASOLCDBGcjs = require('./chunk-ASOLCDBG.cjs');
|
|
61
61
|
|
|
62
62
|
|
|
63
63
|
|
|
@@ -117,5 +117,5 @@ var _chunkWGIYEJBIcjs = require('./chunk-WGIYEJBI.cjs');
|
|
|
117
117
|
|
|
118
118
|
|
|
119
119
|
|
|
120
|
-
exports.AccountView =
|
|
120
|
+
exports.AccountView = _chunkASOLCDBGcjs.AccountView; exports.ApiKeyCredentials = _chunkASOLCDBGcjs.ApiKeyCredentials; exports.Channel = _chunkASOLCDBGcjs.Channel; exports.ChannelMessage = _chunkASOLCDBGcjs.ChannelMessage; exports.Environment = _chunkASOLCDBGcjs.Environment; exports.Environments = _chunkASOLCDBGcjs.Environments; exports.HOSTS = _chunkASOLCDBGcjs.HOSTS; exports.KEY_HEADER = _chunkASOLCDBGcjs.KEY_HEADER; exports.NO_RETRY = _chunkASOLCDBGcjs.NO_RETRY; exports.OPERATIONS = _chunkASOLCDBGcjs.OPERATIONS; exports.Page = _chunkASOLCDBGcjs.Page; exports.ReconnectPolicy = _chunkASOLCDBGcjs.ReconnectPolicy; exports.Region = _chunkASOLCDBGcjs.Region; exports.RetryPolicy = _chunkASOLCDBGcjs.RetryPolicy; exports.SIGNATURE_HEADER = _chunkASOLCDBGcjs.SIGNATURE_HEADER; exports.SNAPSHOT_EVENTS = _chunkASOLCDBGcjs.SNAPSHOT_EVENTS; exports.STX = _chunkASOLCDBGcjs.STX; exports.STXAPIException = _chunkASOLCDBGcjs.STXAPIException; exports.STXAuthenticationException = _chunkASOLCDBGcjs.STXAuthenticationException; exports.STXChannelException = _chunkASOLCDBGcjs.STXChannelException; exports.STXConfigException = _chunkASOLCDBGcjs.STXConfigException; exports.STXException = _chunkASOLCDBGcjs.STXException; exports.STXForbiddenException = _chunkASOLCDBGcjs.STXForbiddenException; exports.STXGeoLocationException = _chunkASOLCDBGcjs.STXGeoLocationException; exports.STXInsufficientScopeException = _chunkASOLCDBGcjs.STXInsufficientScopeException; exports.STXInvalidTokenException = _chunkASOLCDBGcjs.STXInvalidTokenException; exports.STXNotFoundException = _chunkASOLCDBGcjs.STXNotFoundException; exports.STXRateLimitException = _chunkASOLCDBGcjs.STXRateLimitException; exports.STXRejectedException = _chunkASOLCDBGcjs.STXRejectedException; exports.STXServerException = _chunkASOLCDBGcjs.STXServerException; exports.STXTimeoutException = _chunkASOLCDBGcjs.STXTimeoutException; exports.STXTransportException = _chunkASOLCDBGcjs.STXTransportException; exports.STXValidationException = _chunkASOLCDBGcjs.STXValidationException; exports.STXWebSocket = _chunkASOLCDBGcjs.STXWebSocket; exports.TERMINAL_ORDER_STATUSES = _chunkASOLCDBGcjs.TERMINAL_ORDER_STATUSES; exports.TIMESTAMP_HEADER = _chunkASOLCDBGcjs.TIMESTAMP_HEADER; exports.USER_AGENT = _chunkASOLCDBGcjs.USER_AGENT; exports.VERSION = _chunkASOLCDBGcjs.VERSION; exports.baseUrlFor = _chunkASOLCDBGcjs.baseUrlFor; exports.buildMessage = _chunkASOLCDBGcjs.buildMessage; exports.centsToDollars = _chunkASOLCDBGcjs.centsToDollars; exports.convertBook = _chunkASOLCDBGcjs.convertBook; exports.convertMarketChannelPayload = _chunkASOLCDBGcjs.convertMarketChannelPayload; exports.convertMarketPayload = _chunkASOLCDBGcjs.convertMarketPayload; exports.convertMarketsFrame = _chunkASOLCDBGcjs.convertMarketsFrame; exports.environmentNamed = _chunkASOLCDBGcjs.environmentNamed; exports.errorForStatus = _chunkASOLCDBGcjs.errorForStatus; exports.geoRejection = _chunkASOLCDBGcjs.geoRejection; exports.handshakePath = _chunkASOLCDBGcjs.handshakePath; exports.loadPrivateKey = _chunkASOLCDBGcjs.loadPrivateKey; exports.orderBody = _chunkASOLCDBGcjs.orderBody; exports.requestPath = _chunkASOLCDBGcjs.requestPath; exports.resolveHost = _chunkASOLCDBGcjs.resolveHost; exports.resolveSettings = _chunkASOLCDBGcjs.resolveSettings; exports.signerFromPrivateKey = _chunkASOLCDBGcjs.signerFromPrivateKey; exports.socketUrlFor = _chunkASOLCDBGcjs.socketUrlFor; exports.toDollarString = _chunkASOLCDBGcjs.toDollarString; exports.toQuantity = _chunkASOLCDBGcjs.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-CA1d-osT.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-CA1d-osT.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 _chunkASOLCDBGcjs = require('./chunk-ASOLCDBG.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, _chunkASOLCDBGcjs.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, _chunkASOLCDBGcjs.STXConfigException)("No fetch implementation available. Use Node 18+, or pass { fetch }.");
|
|
31
31
|
}
|
|
32
|
-
return { baseUrl:
|
|
32
|
+
return { baseUrl: _chunkASOLCDBGcjs.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 _chunkASOLCDBGcjs.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 _chunkWGIYEJBIcjs.STXAuthenticationExcepti
|
|
|
56
56
|
this.retryAfter = retryAfter;
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
|
-
var STXGrantRevokedException = class extends
|
|
59
|
+
var STXGrantRevokedException = class extends _chunkASOLCDBGcjs.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, _chunkASOLCDBGcjs.STXAPIException)(`HTTP ${status} from ${path}: ${text.slice(0, 500)}`, {
|
|
145
145
|
statusCode: status,
|
|
146
146
|
body: text,
|
|
147
147
|
path
|
|
@@ -166,9 +166,9 @@ var MemberScopes = {
|
|
|
166
166
|
TERMS_WRITE: "terms.write"
|
|
167
167
|
};
|
|
168
168
|
var AppScopes = {
|
|
169
|
-
/**
|
|
169
|
+
/** The market catalog (`GET /api/v1/markets`) and the market data channels. */
|
|
170
170
|
MARKET_DATA: "market_data",
|
|
171
|
-
/**
|
|
171
|
+
/** The event catalog (`GET /api/v1/events`) and the `events` channel. */
|
|
172
172
|
EVENTS: "events"
|
|
173
173
|
};
|
|
174
174
|
var Scopes = { ...MemberScopes, ...AppScopes };
|
|
@@ -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, _chunkASOLCDBGcjs.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, _chunkASOLCDBGcjs.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, _chunkASOLCDBGcjs.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, _chunkASOLCDBGcjs.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, _chunkASOLCDBGcjs.STXConfigException)(
|
|
408
408
|
"client_credentials needs a client secret; a public client cannot mint an app token."
|
|
409
409
|
);
|
|
410
410
|
}
|
|
@@ -492,8 +492,8 @@ var OAuthClient = (_class = class _OAuthClient {
|
|
|
492
492
|
return new OAuthSessionAuth(this, store, memberKey, opts);
|
|
493
493
|
}
|
|
494
494
|
/**
|
|
495
|
-
* An adapter authenticated as the APP (client_credentials): the
|
|
496
|
-
* catalog (`markets()`, `events()`) and the
|
|
495
|
+
* An adapter authenticated as the APP (client_credentials): the market
|
|
496
|
+
* catalog (`markets()`, `events()`) and the market data channels. Re-mints
|
|
497
497
|
* before expiry, once on a 401, and fresh on every socket (re)connect.
|
|
498
498
|
*/
|
|
499
499
|
app(scope) {
|
|
@@ -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, _chunkASOLCDBGcjs.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, _chunkASOLCDBGcjs.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, _chunkASOLCDBGcjs.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, _chunkASOLCDBGcjs.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 = _chunkASOLCDBGcjs.STXAuthenticationException; exports.STXForbiddenException = _chunkASOLCDBGcjs.STXForbiddenException; exports.STXGrantRevokedException = STXGrantRevokedException; exports.STXInsufficientScopeException = _chunkASOLCDBGcjs.STXInsufficientScopeException; exports.STXInvalidTokenException = _chunkASOLCDBGcjs.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
|