@stxapp/stx-typescript 0.8.1 → 0.8.3

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/oauth.cjs CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
 
9
9
 
10
- var _chunkVLNOUSFWcjs = require('./chunk-VLNOUSFW.cjs');
10
+ var _chunkSI3EILHNcjs = require('./chunk-SI3EILHN.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, _chunkVLNOUSFWcjs.STXConfigException)("An OAuth base URL is required. Pass { baseUrl } or set STX_HOST.");
27
+ if (!host) throw new (0, _chunkSI3EILHNcjs.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, _chunkVLNOUSFWcjs.STXConfigException)("No fetch implementation available. Use Node 18+, or pass { fetch }.");
30
+ throw new (0, _chunkSI3EILHNcjs.STXConfigException)("No fetch implementation available. Use Node 18+, or pass { fetch }.");
31
31
  }
32
- return { baseUrl: _chunkVLNOUSFWcjs.baseUrlFor.call(void 0, null, null, host), fetch: fetchImpl };
32
+ return { baseUrl: _chunkSI3EILHNcjs.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 _chunkVLNOUSFWcjs.STXAuthenticationException {
40
+ var STXOAuthException = class extends _chunkSI3EILHNcjs.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 _chunkVLNOUSFWcjs.STXAuthenticationExcepti
56
56
  this.retryAfter = retryAfter;
57
57
  }
58
58
  };
59
- var STXGrantRevokedException = class extends _chunkVLNOUSFWcjs.STXAuthenticationException {
59
+ var STXGrantRevokedException = class extends _chunkSI3EILHNcjs.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, _chunkVLNOUSFWcjs.STXAPIException)(`HTTP ${status} from ${path}: ${text.slice(0, 500)}`, {
144
+ return new (0, _chunkSI3EILHNcjs.STXAPIException)(`HTTP ${status} from ${path}: ${text.slice(0, 500)}`, {
145
145
  statusCode: status,
146
146
  body: text,
147
147
  path
@@ -292,7 +292,7 @@ var OAuthClient = (_class = class _OAuthClient {
292
292
  */
293
293
  async beginAuthorization(pending, params = {}) {
294
294
  const redirectUri = _nullishCoalesce(params.redirectUri, () => ( this.redirectUri));
295
- if (!redirectUri) throw new (0, _chunkVLNOUSFWcjs.STXConfigException)("redirectUri is required to build an authorize URL.");
295
+ if (!redirectUri) throw new (0, _chunkSI3EILHNcjs.STXConfigException)("redirectUri is required to build an authorize URL.");
296
296
  const auth = await this.authorizationUrl({ ...params, redirectUri });
297
297
  await pending.put(auth.state, {
298
298
  codeVerifier: auth.codeVerifier,
@@ -334,7 +334,7 @@ var OAuthClient = (_class = class _OAuthClient {
334
334
  let memberKey;
335
335
  if (opts.store) {
336
336
  memberKey = typeof opts.memberKey === "function" ? opts.memberKey(entry.data) : opts.memberKey;
337
- if (!memberKey) throw new (0, _chunkVLNOUSFWcjs.STXConfigException)("Pass memberKey along with store.");
337
+ if (!memberKey) throw new (0, _chunkSI3EILHNcjs.STXConfigException)("Pass memberKey along with store.");
338
338
  await opts.store.set(memberKey, tokenSetToStored(tokens));
339
339
  }
340
340
  return { tokens, scopes: parseScopes(tokens.scope), data: entry.data, memberKey };
@@ -343,7 +343,7 @@ var OAuthClient = (_class = class _OAuthClient {
343
343
  buildAuthorizeUrl(params) {
344
344
  const redirectUri = _nullishCoalesce(params.redirectUri, () => ( this.redirectUri));
345
345
  if (!redirectUri) {
346
- throw new (0, _chunkVLNOUSFWcjs.STXConfigException)("redirectUri is required to build an authorize URL.");
346
+ throw new (0, _chunkSI3EILHNcjs.STXConfigException)("redirectUri is required to build an authorize URL.");
347
347
  }
348
348
  const url = new URL(joinUrl(this.baseUrl, this.endpoints.authorize));
349
349
  const search = {
@@ -365,7 +365,7 @@ var OAuthClient = (_class = class _OAuthClient {
365
365
  exchangeCode(args) {
366
366
  const redirectUri = _nullishCoalesce(args.redirectUri, () => ( this.redirectUri));
367
367
  if (!redirectUri) {
368
- throw new (0, _chunkVLNOUSFWcjs.STXConfigException)("redirectUri is required to exchange a code.");
368
+ throw new (0, _chunkSI3EILHNcjs.STXConfigException)("redirectUri is required to exchange a code.");
369
369
  }
370
370
  return this.postToken(
371
371
  new URLSearchParams({
@@ -406,7 +406,7 @@ var OAuthClient = (_class = class _OAuthClient {
406
406
  */
407
407
  clientCredentials(scope) {
408
408
  if (this.isPublic) {
409
- throw new (0, _chunkVLNOUSFWcjs.STXConfigException)(
409
+ throw new (0, _chunkSI3EILHNcjs.STXConfigException)(
410
410
  "client_credentials needs a client secret; a public client cannot mint an app token."
411
411
  );
412
412
  }
@@ -510,7 +510,7 @@ var OAuthClient = (_class = class _OAuthClient {
510
510
  */
511
511
  memberClient(store, memberKey, opts = {}) {
512
512
  const { session, ...rest } = opts;
513
- return new (0, _chunkVLNOUSFWcjs.STX)({
513
+ return new (0, _chunkSI3EILHNcjs.STX)({
514
514
  ...rest,
515
515
  host: this.baseUrl,
516
516
  fetch: _nullishCoalesce(rest.fetch, () => ( this.fetch)),
@@ -523,7 +523,7 @@ var OAuthClient = (_class = class _OAuthClient {
523
523
  * market channels. Scope defaults to every app scope the client may hold.
524
524
  */
525
525
  appClient(scope, opts = {}) {
526
- return new (0, _chunkVLNOUSFWcjs.STX)({ ...opts, host: this.baseUrl, fetch: _nullishCoalesce(opts.fetch, () => ( this.fetch)), auth: this.app(scope) });
526
+ return new (0, _chunkSI3EILHNcjs.STX)({ ...opts, host: this.baseUrl, fetch: _nullishCoalesce(opts.fetch, () => ( this.fetch)), auth: this.app(scope) });
527
527
  }
528
528
  /** @internal The in-flight refresh map for one store; see `OAuthSessionAuth`. */
529
529
  _refreshesFor(store) {
@@ -699,7 +699,7 @@ var OAuthSessionAuth = (_class4 = class {
699
699
  async tokens() {
700
700
  let tokens = await this.load();
701
701
  if (!tokens) {
702
- throw new (0, _chunkVLNOUSFWcjs.STXConfigException)(`No tokens stored for member "${this.memberKey}". Complete the OAuth flow first.`);
702
+ throw new (0, _chunkSI3EILHNcjs.STXConfigException)(`No tokens stored for member "${this.memberKey}". Complete the OAuth flow first.`);
703
703
  }
704
704
  if (tokens.refreshToken && tokens.expiresAt !== void 0 && tokens.expiresAt - Date.now() <= this.skewMs) {
705
705
  const refreshed = await this.refresh(tokens.refreshToken);
@@ -881,7 +881,7 @@ async function fetchWellKnown(baseUrl, path, opts) {
881
881
  }
882
882
  }
883
883
  function httpError2(status, text, path) {
884
- return new (0, _chunkVLNOUSFWcjs.STXAPIException)(`HTTP ${status} from ${path}: ${text.slice(0, 500)}`, {
884
+ return new (0, _chunkSI3EILHNcjs.STXAPIException)(`HTTP ${status} from ${path}: ${text.slice(0, 500)}`, {
885
885
  statusCode: status,
886
886
  body: text,
887
887
  path
@@ -965,5 +965,5 @@ var MemoryPendingAuthorizationStore = (_class7 = class {constructor() { _class7.
965
965
 
966
966
 
967
967
 
968
- 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 = _chunkVLNOUSFWcjs.STXAuthenticationException; exports.STXForbiddenException = _chunkVLNOUSFWcjs.STXForbiddenException; exports.STXGrantRevokedException = STXGrantRevokedException; exports.STXInsufficientScopeException = _chunkVLNOUSFWcjs.STXInsufficientScopeException; exports.STXInvalidTokenException = _chunkVLNOUSFWcjs.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;
968
+ 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 = _chunkSI3EILHNcjs.STXAuthenticationException; exports.STXForbiddenException = _chunkSI3EILHNcjs.STXForbiddenException; exports.STXGrantRevokedException = STXGrantRevokedException; exports.STXInsufficientScopeException = _chunkSI3EILHNcjs.STXInsufficientScopeException; exports.STXInvalidTokenException = _chunkSI3EILHNcjs.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;
969
969
  //# sourceMappingURL=oauth.cjs.map
package/dist/oauth.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { aR as STXAuthenticationException, g as AuthProvider, h as AuthRequest, bn as WebSocketAuthContext, b2 as STXOptions, aP as STX } from './client-CRccD5B2.cjs';
2
- export { aZ as STXForbiddenException, a$ as STXInsufficientScopeException, b0 as STXInvalidTokenException } from './client-CRccD5B2.cjs';
1
+ import { aR as STXAuthenticationException, g as AuthProvider, h as AuthRequest, bn as WebSocketAuthContext, b2 as STXOptions, aP as STX } from './client-BrHjO1__.cjs';
2
+ export { aZ as STXForbiddenException, a$ as STXInsufficientScopeException, b0 as STXInvalidTokenException } from './client-BrHjO1__.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 { aR as STXAuthenticationException, g as AuthProvider, h as AuthRequest, bn as WebSocketAuthContext, b2 as STXOptions, aP as STX } from './client-CRccD5B2.js';
2
- export { aZ as STXForbiddenException, a$ as STXInsufficientScopeException, b0 as STXInvalidTokenException } from './client-CRccD5B2.js';
1
+ import { aR as STXAuthenticationException, g as AuthProvider, h as AuthRequest, bn as WebSocketAuthContext, b2 as STXOptions, aP as STX } from './client-BrHjO1__.js';
2
+ export { aZ as STXForbiddenException, a$ as STXInsufficientScopeException, b0 as STXInvalidTokenException } from './client-BrHjO1__.js';
3
3
  import 'node:crypto';
4
4
 
5
5
  interface OAuthEndpoints$1 {
package/dist/oauth.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  STXInsufficientScopeException,
8
8
  STXInvalidTokenException,
9
9
  baseUrlFor
10
- } from "./chunk-GLUTQFBV.js";
10
+ } from "./chunk-SIYERAKK.js";
11
11
 
12
12
  // src/oauth/endpoints.ts
13
13
  var DEFAULT_ENDPOINTS = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stxapp/stx-typescript",
3
- "version": "0.8.1",
3
+ "version": "0.8.3",
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",