@augustdigital/sdk 4.27.3 → 5.1.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.
Files changed (159) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +58 -0
  3. package/lib/core/analytics/sanitize.d.ts +3 -0
  4. package/lib/core/analytics/sanitize.js +74 -0
  5. package/lib/core/analytics/sentry.d.ts +1 -1
  6. package/lib/core/analytics/sentry.js +4 -1
  7. package/lib/core/auth/verify.js +9 -4
  8. package/lib/core/base.class.d.ts +5 -1
  9. package/lib/core/base.class.js +19 -2
  10. package/lib/core/errors/index.d.ts +40 -0
  11. package/lib/core/errors/index.js +103 -0
  12. package/lib/core/fetcher.d.ts +2 -0
  13. package/lib/core/fetcher.js +149 -41
  14. package/lib/core/helpers/web3.d.ts +3 -3
  15. package/lib/core/helpers/web3.js +45 -9
  16. package/lib/core/index.d.ts +2 -0
  17. package/lib/core/index.js +2 -0
  18. package/lib/core/logger/index.d.ts +10 -0
  19. package/lib/core/logger/index.js +37 -4
  20. package/lib/core/logger/slack.js +6 -2
  21. package/lib/core/version-check.d.ts +6 -0
  22. package/lib/core/version-check.js +101 -0
  23. package/lib/index.d.ts +1 -0
  24. package/lib/index.js +1 -7
  25. package/lib/main.d.ts +7 -2
  26. package/lib/main.js +5 -2
  27. package/lib/modules/vaults/getters.d.ts +5 -1
  28. package/lib/modules/vaults/getters.js +44 -23
  29. package/lib/modules/vaults/main.d.ts +7 -1
  30. package/lib/modules/vaults/main.js +30 -1
  31. package/lib/polyfills.d.ts +1 -0
  32. package/lib/polyfills.js +10 -0
  33. package/package.json +14 -5
  34. package/lib/abis/AddressResolver.js.map +0 -1
  35. package/lib/abis/ChainlinkV3.js.map +0 -1
  36. package/lib/abis/ERC20.js.map +0 -1
  37. package/lib/abis/ERC20_Bytes32.js.map +0 -1
  38. package/lib/abis/ERC4626.js.map +0 -1
  39. package/lib/abis/ERC721.js.map +0 -1
  40. package/lib/abis/FeeOracle.js.map +0 -1
  41. package/lib/abis/LendingPool.js.map +0 -1
  42. package/lib/abis/LendingPoolV2.js.map +0 -1
  43. package/lib/abis/LendingPoolV3.js.map +0 -1
  44. package/lib/abis/Loan.js.map +0 -1
  45. package/lib/abis/MultiAssetNativeDepositWrapper.js.map +0 -1
  46. package/lib/abis/Multicall3.js.map +0 -1
  47. package/lib/abis/OFT.js.map +0 -1
  48. package/lib/abis/PoolAdapter.js.map +0 -1
  49. package/lib/abis/RewardDistributor.js.map +0 -1
  50. package/lib/abis/RwaRedeemSubaccount.js.map +0 -1
  51. package/lib/abis/SmartAccount.js.map +0 -1
  52. package/lib/abis/TextResolver.js.map +0 -1
  53. package/lib/abis/TokenizedVaultV2.js.map +0 -1
  54. package/lib/abis/TokenizedVaultV2DepositWithPermit.js.map +0 -1
  55. package/lib/abis/TokenizedVaultV2Receipt.js.map +0 -1
  56. package/lib/abis/TokenizedVaultV2SenderAllocationWhitelist.js.map +0 -1
  57. package/lib/abis/TokenizedVaultV2WhitelistedAllocation.js.map +0 -1
  58. package/lib/abis/TokenizedVaultV2WhitelistedAssets.js.map +0 -1
  59. package/lib/abis/UniversalResolverResolve.js.map +0 -1
  60. package/lib/abis/UniversalSignatureValidator.js.map +0 -1
  61. package/lib/abis/WrapperAdapter.js.map +0 -1
  62. package/lib/abis/index.js.map +0 -1
  63. package/lib/adapters/evm/getters.js.map +0 -1
  64. package/lib/adapters/evm/index.js.map +0 -1
  65. package/lib/adapters/evm/utils.js.map +0 -1
  66. package/lib/adapters/solana/constants.js.map +0 -1
  67. package/lib/adapters/solana/getters.js.map +0 -1
  68. package/lib/adapters/solana/idl/vault-idl.js.map +0 -1
  69. package/lib/adapters/solana/index.js.map +0 -1
  70. package/lib/adapters/solana/types.js.map +0 -1
  71. package/lib/adapters/solana/utils.js.map +0 -1
  72. package/lib/adapters/solana/vault.actions.js.map +0 -1
  73. package/lib/adapters/stellar/actions.js.map +0 -1
  74. package/lib/adapters/stellar/constants.js.map +0 -1
  75. package/lib/adapters/stellar/getters.js.map +0 -1
  76. package/lib/adapters/stellar/index.js.map +0 -1
  77. package/lib/adapters/stellar/soroban.js.map +0 -1
  78. package/lib/adapters/stellar/submit.js.map +0 -1
  79. package/lib/adapters/stellar/types.js.map +0 -1
  80. package/lib/adapters/stellar/utils.js.map +0 -1
  81. package/lib/adapters/sui/constants.js.map +0 -1
  82. package/lib/adapters/sui/getters.js.map +0 -1
  83. package/lib/adapters/sui/index.js.map +0 -1
  84. package/lib/adapters/sui/transformer.js.map +0 -1
  85. package/lib/adapters/sui/types.js.map +0 -1
  86. package/lib/adapters/sui/utils.js.map +0 -1
  87. package/lib/core/analytics/constants.js.map +0 -1
  88. package/lib/core/analytics/index.js.map +0 -1
  89. package/lib/core/analytics/instrumentation.js.map +0 -1
  90. package/lib/core/analytics/metrics.js.map +0 -1
  91. package/lib/core/analytics/sanitize.js.map +0 -1
  92. package/lib/core/analytics/sentry.js.map +0 -1
  93. package/lib/core/analytics/types.js.map +0 -1
  94. package/lib/core/analytics/user-identity.js.map +0 -1
  95. package/lib/core/auth/index.js.map +0 -1
  96. package/lib/core/auth/verify.js.map +0 -1
  97. package/lib/core/base.class.js.map +0 -1
  98. package/lib/core/constants/adapters.js.map +0 -1
  99. package/lib/core/constants/core.js.map +0 -1
  100. package/lib/core/constants/vaults.js.map +0 -1
  101. package/lib/core/constants/web3.js.map +0 -1
  102. package/lib/core/fetcher.js.map +0 -1
  103. package/lib/core/helpers/adapters.js.map +0 -1
  104. package/lib/core/helpers/core.js.map +0 -1
  105. package/lib/core/helpers/signer.js.map +0 -1
  106. package/lib/core/helpers/vaults.js.map +0 -1
  107. package/lib/core/helpers/web3.js.map +0 -1
  108. package/lib/core/index.js.map +0 -1
  109. package/lib/core/logger/index.js.map +0 -1
  110. package/lib/core/logger/slack.js.map +0 -1
  111. package/lib/evm/index.js.map +0 -1
  112. package/lib/evm/methods/crossChainVault.js.map +0 -1
  113. package/lib/evm/methods/index.js.map +0 -1
  114. package/lib/evm/types/crossChain.js.map +0 -1
  115. package/lib/evm/types/index.js.map +0 -1
  116. package/lib/index.js.map +0 -1
  117. package/lib/main.js.map +0 -1
  118. package/lib/modules/sub-accounts/fetcher.js.map +0 -1
  119. package/lib/modules/sub-accounts/index.js.map +0 -1
  120. package/lib/modules/sub-accounts/main.js.map +0 -1
  121. package/lib/modules/sub-accounts/utils.js.map +0 -1
  122. package/lib/modules/vaults/adapter.helpers.js.map +0 -1
  123. package/lib/modules/vaults/fetcher.js.map +0 -1
  124. package/lib/modules/vaults/getters.js.map +0 -1
  125. package/lib/modules/vaults/index.js.map +0 -1
  126. package/lib/modules/vaults/main.js.map +0 -1
  127. package/lib/modules/vaults/read.actions.js.map +0 -1
  128. package/lib/modules/vaults/types.js.map +0 -1
  129. package/lib/modules/vaults/utils/call-data-decoder.js.map +0 -1
  130. package/lib/modules/vaults/utils/date-utils.js.map +0 -1
  131. package/lib/modules/vaults/utils.js.map +0 -1
  132. package/lib/modules/vaults/write.actions.js.map +0 -1
  133. package/lib/services/coingecko/fetcher.js.map +0 -1
  134. package/lib/services/coingecko/index.js.map +0 -1
  135. package/lib/services/coingecko/utils.js.map +0 -1
  136. package/lib/services/debank/fetcher.js.map +0 -1
  137. package/lib/services/debank/index.js.map +0 -1
  138. package/lib/services/debank/utils.js.map +0 -1
  139. package/lib/services/layerzero/deposits.js.map +0 -1
  140. package/lib/services/layerzero/redeems.js.map +0 -1
  141. package/lib/services/layerzero/utils.js.map +0 -1
  142. package/lib/services/octavfi/fetcher.js.map +0 -1
  143. package/lib/services/octavfi/index.js.map +0 -1
  144. package/lib/services/octavfi/types.js.map +0 -1
  145. package/lib/services/octavfi/utils.js.map +0 -1
  146. package/lib/services/subgraph/fetcher.js.map +0 -1
  147. package/lib/services/subgraph/index.js.map +0 -1
  148. package/lib/services/subgraph/vaults.js.map +0 -1
  149. package/lib/types/index.js.map +0 -1
  150. package/lib/types/points.js.map +0 -1
  151. package/lib/types/pools.js.map +0 -1
  152. package/lib/types/staking.js.map +0 -1
  153. package/lib/types/sub-accounts.js.map +0 -1
  154. package/lib/types/subgraph.js.map +0 -1
  155. package/lib/types/typed-contract.js.map +0 -1
  156. package/lib/types/user.js.map +0 -1
  157. package/lib/types/vaults.js.map +0 -1
  158. package/lib/types/web3.js.map +0 -1
  159. package/lib/types/webserver.js.map +0 -1
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 August Digital
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -29,6 +29,9 @@ import { AugustSDK } from '@augustdigital/sdk';
29
29
 
30
30
  // Initialize with RPC providers
31
31
  const sdk = new AugustSDK({
32
+ // Required: a stable kebab-case slug identifying your application.
33
+ // See "App Name" below for what this is used for.
34
+ appName: 'acme-trader',
32
35
  providers: {
33
36
  1: 'https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY',
34
37
  42161: 'https://arb-mainnet.g.alchemy.com/v2/YOUR_KEY',
@@ -58,6 +61,61 @@ const positions = await sdk.getVaultPositions({
58
61
  });
59
62
  ```
60
63
 
64
+ ### App Name
65
+
66
+ `appName` is required on every `AugustSDK` constructor call. Pass a
67
+ stable kebab-case slug identifying your application (e.g.
68
+ `'acme-trader'`, `'my-defi-app'`):
69
+
70
+ - **What it's used for.** August Digital tags outbound analytics events
71
+ with `app.name = <yourSlug>`. We use this to (a) reach out about
72
+ breaking changes that will affect you, (b) attribute error spikes to
73
+ the right consuming app, and (c) prioritize bug fixes by impact.
74
+ - **What it is _not_.** It's not a secret, not a license key, not an
75
+ auth token, and despite the friendly name it's **not a display
76
+ label**. It's a self-issued identifier — pick a slug once and reuse
77
+ it across deployments.
78
+ - **Constraints.** 3–64 characters, only `[a-zA-Z0-9._-]`. Use a slug
79
+ like `'acme-trader'`, **not** a display name like `'Acme Trader'`
80
+ (spaces and special characters will throw). The SDK throws
81
+ synchronously from the constructor if the value is missing or
82
+ invalid, so a wrong value fails loudly at integration time rather
83
+ than silently in production.
84
+
85
+ ```typescript
86
+ // Will throw — appName is required.
87
+ new AugustSDK({
88
+ providers: {
89
+ /* ... */
90
+ },
91
+ keys: {
92
+ /* ... */
93
+ },
94
+ } as any);
95
+
96
+ // Will throw — display name, not a slug. Use 'acme-trader' instead.
97
+ new AugustSDK({
98
+ appName: 'Acme Trader',
99
+ providers: {
100
+ /* ... */
101
+ },
102
+ keys: {
103
+ /* ... */
104
+ },
105
+ });
106
+
107
+ // Correct.
108
+ new AugustSDK({
109
+ appName: 'acme-trader',
110
+ providers: {
111
+ /* ... */
112
+ },
113
+ keys: {
114
+ /* ... */
115
+ },
116
+ });
117
+ ```
118
+
61
119
  ## Architecture
62
120
 
63
121
  ```
@@ -1,2 +1,5 @@
1
+ export declare function sanitizeString(input: string): string;
2
+ export declare function sanitizeError(err: unknown): unknown;
3
+ export declare function sanitizeForLogging(input: unknown, depth?: number): unknown;
1
4
  export declare function sanitizeArgs(args: unknown[]): Record<string, unknown>;
2
5
  export declare function sanitizeObject(obj: Record<string, unknown>, depth?: number): Record<string, unknown>;
@@ -1,22 +1,96 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sanitizeString = sanitizeString;
4
+ exports.sanitizeError = sanitizeError;
5
+ exports.sanitizeForLogging = sanitizeForLogging;
3
6
  exports.sanitizeArgs = sanitizeArgs;
4
7
  exports.sanitizeObject = sanitizeObject;
5
8
  const SENSITIVE_KEYS = [
6
9
  'apikey',
7
10
  'api_key',
8
11
  'apiKey',
12
+ 'x-api-key',
9
13
  'password',
10
14
  'secret',
11
15
  'token',
12
16
  'bearer',
13
17
  'authorization',
18
+ 'proxy-authorization',
19
+ 'cookie',
20
+ 'set-cookie',
14
21
  'privatekey',
15
22
  'private_key',
16
23
  'privateKey',
17
24
  'mnemonic',
18
25
  'seed',
19
26
  ];
27
+ const STRING_REDACTION_PATTERNS = [
28
+ [/(authorization\s*[:=]\s*)(bearer|basic|token)\s+\S+/gi, '$1$2 [REDACTED]'],
29
+ [
30
+ /([?&](?:api[-_]?key|apikey|access[-_]?token|token|key|auth)=)[^&\s#]+/gi,
31
+ '$1[REDACTED]',
32
+ ],
33
+ [/(gateway\.thegraph\.com\/api\/)[A-Za-z0-9]{20,}(\/)/g, '$1[REDACTED]$2'],
34
+ [/eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g, '[REDACTED_JWT]'],
35
+ [/\bnpm_[A-Za-z0-9]{30,}\b/g, '[REDACTED_NPM_TOKEN]'],
36
+ [
37
+ /(\b(?:api[-_]?key|apikey|password|secret|private[-_]?key|mnemonic|seed)\s*[:=]\s*)["']?[^\s"',;}&#]+["']?/gi,
38
+ '$1[REDACTED]',
39
+ ],
40
+ ];
41
+ function sanitizeString(input) {
42
+ if (!input)
43
+ return input;
44
+ let out = input;
45
+ for (const [pattern, replacement] of STRING_REDACTION_PATTERNS) {
46
+ out = out.replace(pattern, replacement);
47
+ }
48
+ return out;
49
+ }
50
+ function sanitizeError(err) {
51
+ if (!(err instanceof Error))
52
+ return err;
53
+ const safe = Object.create(Object.getPrototypeOf(err));
54
+ for (const key of Object.getOwnPropertyNames(err)) {
55
+ const value = err[key];
56
+ if (key === 'message' && typeof value === 'string') {
57
+ safe[key] = sanitizeString(value);
58
+ }
59
+ else if (key === 'stack' && typeof value === 'string') {
60
+ safe[key] = sanitizeString(value);
61
+ }
62
+ else {
63
+ safe[key] = value;
64
+ }
65
+ }
66
+ if (!safe.message && typeof err.message === 'string') {
67
+ safe.message = sanitizeString(err.message);
68
+ }
69
+ if (!safe.stack && typeof err.stack === 'string') {
70
+ safe.stack = sanitizeString(err.stack);
71
+ }
72
+ safe.name = err.name;
73
+ return safe;
74
+ }
75
+ function sanitizeForLogging(input, depth = 0) {
76
+ if (input === null || input === undefined)
77
+ return input;
78
+ if (depth > 3)
79
+ return '[TRUNCATED]';
80
+ if (typeof input === 'string')
81
+ return sanitizeString(input);
82
+ if (typeof input === 'number' || typeof input === 'boolean')
83
+ return input;
84
+ if (input instanceof Error)
85
+ return sanitizeError(input);
86
+ if (Array.isArray(input)) {
87
+ return input.slice(0, 10).map((v) => sanitizeForLogging(v, depth + 1));
88
+ }
89
+ if (typeof input === 'object') {
90
+ return sanitizeObject(input, depth);
91
+ }
92
+ return `[${typeof input}]`;
93
+ }
20
94
  function sanitizeArgs(args) {
21
95
  const sanitized = {};
22
96
  args.forEach((arg, index) => {
@@ -1,7 +1,7 @@
1
1
  import * as Sentry from '@sentry/browser';
2
2
  import { IEnv } from '../../types';
3
3
  import { IAnalyticsConfig } from './types';
4
- export declare function initializeSentry(config: IAnalyticsConfig, environment: IEnv, walletAddress?: string, apiKey?: string): void;
4
+ export declare function initializeSentry(config: IAnalyticsConfig, environment: IEnv, walletAddress?: string, apiKey?: string, appName?: string): void;
5
5
  export declare function updateUser(walletAddress?: string, environment?: IEnv): void;
6
6
  export declare function clearUser(): void;
7
7
  export declare function isAnalyticsEnabled(): boolean;
@@ -84,7 +84,7 @@ function safeSetUser(user) {
84
84
  catch {
85
85
  }
86
86
  }
87
- function initializeSentry(config, environment, walletAddress, apiKey) {
87
+ function initializeSentry(config, environment, walletAddress, apiKey, appName) {
88
88
  if (config.enabled === false) {
89
89
  isEnabled = false;
90
90
  console.log('August SDK: Analytics disabled');
@@ -125,6 +125,9 @@ function initializeSentry(config, environment, walletAddress, apiKey) {
125
125
  updateUser(walletAddress, environment);
126
126
  safeSetTag('sdk', 'august-digital');
127
127
  safeSetTag('sdk.version', getSDKVersion());
128
+ if (appName) {
129
+ safeSetTag('app.name', appName);
130
+ }
128
131
  isInitialized = true;
129
132
  console.log('August SDK: Analytics initialized. Disable with { analytics: { enabled: false } }');
130
133
  }
@@ -13,9 +13,14 @@ async function verifyInfuraKey(key) {
13
13
  return true;
14
14
  }
15
15
  async function verifyAugustKey(key) {
16
- const verify = await (0, fetcher_1.fetchAugustWithKey)(key, core_1.WEBSERVER_ENDPOINTS.auth.verify);
17
- if (verify.status === 200)
18
- return true;
19
- return false;
16
+ if (!key)
17
+ return false;
18
+ try {
19
+ const verify = await (0, fetcher_1.fetchAugustWithKey)(key, core_1.WEBSERVER_ENDPOINTS.auth.verify);
20
+ return verify.status === 200;
21
+ }
22
+ catch {
23
+ return false;
24
+ }
20
25
  }
21
26
  //# sourceMappingURL=verify.js.map
@@ -1,5 +1,6 @@
1
1
  import { ISolanaConfig, IAddress, IChainId, IEnv, IProvidersConfig, IWSMonitorHeaders } from '../types';
2
2
  import { IAnalyticsConfig } from './analytics';
3
+ import { IVersionCheckConfig } from './version-check';
3
4
  interface IKeys {
4
5
  august?: string;
5
6
  graph?: string;
@@ -11,11 +12,13 @@ interface IMonitoring extends IWSMonitorHeaders {
11
12
  env?: IEnv;
12
13
  }
13
14
  export interface IAugustBase {
15
+ appName: string;
14
16
  providers?: IProvidersConfig;
15
17
  solana?: ISolanaConfig;
16
18
  keys: IKeys;
17
19
  monitoring?: IMonitoring;
18
20
  analytics?: IAnalyticsConfig;
21
+ versionCheck?: IVersionCheckConfig;
19
22
  }
20
23
  interface IActiveNetwork {
21
24
  chainId: IChainId;
@@ -27,7 +30,8 @@ export declare class AugustBase {
27
30
  authorized: boolean;
28
31
  activeNetwork?: IActiveNetwork;
29
32
  providers: IProvidersConfig;
30
- constructor({ providers, keys, monitoring, analytics }: IAugustBase);
33
+ appName: string;
34
+ constructor({ appName, providers, keys, monitoring, analytics, versionCheck, }: IAugustBase);
31
35
  init(): Promise<void>;
32
36
  protected requireActiveNetwork(): IActiveNetwork;
33
37
  switchNetwork(chainId: IChainId): void;
@@ -4,12 +4,28 @@ exports.AugustBase = void 0;
4
4
  const auth_1 = require("./auth");
5
5
  const logger_1 = require("./logger");
6
6
  const analytics_1 = require("./analytics");
7
+ const version_check_1 = require("./version-check");
8
+ function validateAppName(value) {
9
+ const docsHint = 'See https://docs.augustdigital.io/developers/typescript-sdk#app-name';
10
+ if (typeof value !== 'string' || value.trim().length === 0) {
11
+ throw new Error(`August SDK: \`appName\` is required. Pass a stable kebab-case slug identifying your application (e.g. "acme-trader"). ${docsHint}`);
12
+ }
13
+ const trimmed = value.trim();
14
+ if (trimmed.length < 3 || trimmed.length > 64) {
15
+ throw new Error(`August SDK: \`appName\` must be 3-64 characters (got ${trimmed.length}). ${docsHint}`);
16
+ }
17
+ if (!/^[a-zA-Z0-9._-]+$/.test(trimmed)) {
18
+ throw new Error(`August SDK: \`appName\` may only contain letters, digits, '.', '_' and '-' (got "${trimmed}"). Use a slug like "acme-trader", not a display name. ${docsHint}`);
19
+ }
20
+ return trimmed;
21
+ }
7
22
  class AugustBase {
8
- constructor({ providers = {}, keys, monitoring, analytics }) {
23
+ constructor({ appName, providers = {}, keys, monitoring, analytics, versionCheck, }) {
9
24
  this.monitoring = {
10
25
  'x-user-id': undefined,
11
26
  'x-environment': undefined,
12
27
  };
28
+ this.appName = validateAppName(appName);
13
29
  this.authorized = true;
14
30
  this.providers = providers;
15
31
  if (Object.keys(providers).length > 0) {
@@ -25,7 +41,8 @@ class AugustBase {
25
41
  'x-environment': environment,
26
42
  };
27
43
  logger_1.Logger.setDevMode(environment === 'DEV');
28
- (0, analytics_1.initializeSentry)(analytics ?? { enabled: true }, environment, monitoring?.['x-user-id'], keys?.august);
44
+ (0, analytics_1.initializeSentry)(analytics ?? { enabled: true }, environment, monitoring?.['x-user-id'], keys?.august, this.appName);
45
+ (0, version_check_1.runVersionCheck)(versionCheck);
29
46
  }
30
47
  async init() {
31
48
  const [augustCheck] = await Promise.all([
@@ -0,0 +1,40 @@
1
+ export type AugustErrorCode = 'AUTH_MISSING_KEY' | 'AUTH_INVALID_KEY' | 'AUTH_FORBIDDEN' | 'AUTH_UNAUTHORIZED' | 'INVALID_URL' | 'INVALID_INPUT' | 'INVALID_CHAIN' | 'INVALID_ADDRESS' | 'NETWORK_ERROR' | 'TIMEOUT' | 'RATE_LIMITED' | 'SERVER_ERROR' | 'UNKNOWN';
2
+ export interface AugustErrorOptions {
3
+ cause?: unknown;
4
+ correlationId?: string;
5
+ context?: Record<string, unknown>;
6
+ }
7
+ export declare class AugustSDKError extends Error {
8
+ readonly code: AugustErrorCode;
9
+ readonly correlationId?: string;
10
+ readonly context?: Record<string, unknown>;
11
+ constructor(code: AugustErrorCode, message: string, options?: AugustErrorOptions);
12
+ toJSON(): Record<string, unknown>;
13
+ }
14
+ export declare class AugustAuthError extends AugustSDKError {
15
+ constructor(code: Extract<AugustErrorCode, 'AUTH_MISSING_KEY' | 'AUTH_INVALID_KEY' | 'AUTH_FORBIDDEN' | 'AUTH_UNAUTHORIZED'>, message: string, options?: AugustErrorOptions);
16
+ }
17
+ export declare class AugustNetworkError extends AugustSDKError {
18
+ constructor(message: string, options?: AugustErrorOptions);
19
+ }
20
+ export declare class AugustTimeoutError extends AugustSDKError {
21
+ readonly timeoutMs: number;
22
+ constructor(message: string, timeoutMs: number, options?: AugustErrorOptions);
23
+ toJSON(): Record<string, unknown>;
24
+ }
25
+ export declare class AugustValidationError extends AugustSDKError {
26
+ constructor(code: Extract<AugustErrorCode, 'INVALID_URL' | 'INVALID_INPUT' | 'INVALID_CHAIN' | 'INVALID_ADDRESS'>, message: string, options?: AugustErrorOptions);
27
+ }
28
+ export declare class AugustRateLimitError extends AugustSDKError {
29
+ readonly retryAfterMs?: number;
30
+ constructor(message: string, options?: AugustErrorOptions & {
31
+ retryAfterMs?: number;
32
+ });
33
+ toJSON(): Record<string, unknown>;
34
+ }
35
+ export declare class AugustServerError extends AugustSDKError {
36
+ readonly status: number;
37
+ constructor(status: number, message: string, options?: AugustErrorOptions);
38
+ toJSON(): Record<string, unknown>;
39
+ }
40
+ export declare function isAugustSDKError(err: unknown): err is AugustSDKError;
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AugustServerError = exports.AugustRateLimitError = exports.AugustValidationError = exports.AugustTimeoutError = exports.AugustNetworkError = exports.AugustAuthError = exports.AugustSDKError = void 0;
4
+ exports.isAugustSDKError = isAugustSDKError;
5
+ class AugustSDKError extends Error {
6
+ constructor(code, message, options = {}) {
7
+ super(message);
8
+ this.name = 'AugustSDKError';
9
+ this.code = code;
10
+ this.correlationId = options.correlationId;
11
+ this.context = options.context;
12
+ if (options.cause !== undefined) {
13
+ this.cause = options.cause;
14
+ }
15
+ Object.setPrototypeOf(this, new.target.prototype);
16
+ }
17
+ toJSON() {
18
+ const out = {
19
+ name: this.name,
20
+ message: this.message,
21
+ code: this.code,
22
+ };
23
+ if (this.correlationId !== undefined)
24
+ out.correlationId = this.correlationId;
25
+ if (this.context !== undefined)
26
+ out.context = this.context;
27
+ if (this.stack !== undefined)
28
+ out.stack = this.stack;
29
+ const cause = this.cause;
30
+ if (cause !== undefined) {
31
+ out.cause =
32
+ cause instanceof Error
33
+ ? { name: cause.name, message: cause.message }
34
+ : cause;
35
+ }
36
+ return out;
37
+ }
38
+ }
39
+ exports.AugustSDKError = AugustSDKError;
40
+ class AugustAuthError extends AugustSDKError {
41
+ constructor(code, message, options) {
42
+ super(code, message, options);
43
+ this.name = 'AugustAuthError';
44
+ }
45
+ }
46
+ exports.AugustAuthError = AugustAuthError;
47
+ class AugustNetworkError extends AugustSDKError {
48
+ constructor(message, options) {
49
+ super('NETWORK_ERROR', message, options);
50
+ this.name = 'AugustNetworkError';
51
+ }
52
+ }
53
+ exports.AugustNetworkError = AugustNetworkError;
54
+ class AugustTimeoutError extends AugustSDKError {
55
+ constructor(message, timeoutMs, options) {
56
+ super('TIMEOUT', message, options);
57
+ this.name = 'AugustTimeoutError';
58
+ this.timeoutMs = timeoutMs;
59
+ }
60
+ toJSON() {
61
+ return { ...super.toJSON(), timeoutMs: this.timeoutMs };
62
+ }
63
+ }
64
+ exports.AugustTimeoutError = AugustTimeoutError;
65
+ class AugustValidationError extends AugustSDKError {
66
+ constructor(code, message, options) {
67
+ super(code, message, options);
68
+ this.name = 'AugustValidationError';
69
+ }
70
+ }
71
+ exports.AugustValidationError = AugustValidationError;
72
+ class AugustRateLimitError extends AugustSDKError {
73
+ constructor(message, options) {
74
+ super('RATE_LIMITED', message, options);
75
+ this.name = 'AugustRateLimitError';
76
+ this.retryAfterMs = options?.retryAfterMs;
77
+ }
78
+ toJSON() {
79
+ const base = super.toJSON();
80
+ if (this.retryAfterMs !== undefined)
81
+ base.retryAfterMs = this.retryAfterMs;
82
+ return base;
83
+ }
84
+ }
85
+ exports.AugustRateLimitError = AugustRateLimitError;
86
+ class AugustServerError extends AugustSDKError {
87
+ constructor(status, message, options) {
88
+ super('SERVER_ERROR', message, options);
89
+ this.name = 'AugustServerError';
90
+ this.status = status;
91
+ }
92
+ toJSON() {
93
+ return { ...super.toJSON(), status: this.status };
94
+ }
95
+ }
96
+ exports.AugustServerError = AugustServerError;
97
+ function isAugustSDKError(err) {
98
+ return (err instanceof AugustSDKError ||
99
+ (err instanceof Error &&
100
+ typeof err.code === 'string' &&
101
+ err.name.startsWith('August')));
102
+ }
103
+ //# sourceMappingURL=index.js.map
@@ -7,6 +7,8 @@ export type IFetchAugustOptions = {
7
7
  headers?: Record<string, string>;
8
8
  data?: any;
9
9
  server?: keyof typeof WEBSERVER_URL;
10
+ signal?: AbortSignal;
11
+ timeoutMs?: number;
10
12
  override?: boolean;
11
13
  };
12
14
  export declare const CACHE: LRUCache<string, any, unknown>;