@augustdigital/sdk 8.26.0 → 9.0.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.
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Validate an `appName` slug at SDK boundary points (the `AugustSDK`
3
+ * constructor and the standalone {@link initializeSentry} entry point).
4
+ *
5
+ * Rules (kept intentionally narrow so the value is safe to use as a Sentry
6
+ * tag, an HTTP header value, and a filesystem-safe identifier — this is
7
+ * why we accept slugs only, not display names):
8
+ * - non-empty after trim
9
+ * - 3..64 characters
10
+ * - only `[a-zA-Z0-9._-]`
11
+ * - not shaped like an EVM address (`0x` + 40 hex chars) — an address
12
+ * passes the character rules but is a high-cardinality wallet
13
+ * identifier, not an application name. This also catches callers of
14
+ * `initializeSentry` still passing the pre-v9 positional argument
15
+ * order, where a wallet address occupied the slot `appName` now holds.
16
+ *
17
+ * Throws a descriptive `AugustValidationError` (code `INVALID_INPUT`) that
18
+ * names the failed rule and includes a remediation hint pointing at the
19
+ * docs link.
20
+ *
21
+ * @param value - The candidate app name, as received from the caller.
22
+ * @returns The trimmed, validated slug.
23
+ * @throws AugustValidationError when the value is missing, empty,
24
+ * mis-typed, out of the 3–64 length range, contains disallowed
25
+ * characters, or is shaped like an EVM address.
26
+ */
27
+ export declare function validateAppName(value: unknown): string;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateAppName = validateAppName;
4
+ const errors_1 = require("../errors");
5
+ /**
6
+ * Validate an `appName` slug at SDK boundary points (the `AugustSDK`
7
+ * constructor and the standalone {@link initializeSentry} entry point).
8
+ *
9
+ * Rules (kept intentionally narrow so the value is safe to use as a Sentry
10
+ * tag, an HTTP header value, and a filesystem-safe identifier — this is
11
+ * why we accept slugs only, not display names):
12
+ * - non-empty after trim
13
+ * - 3..64 characters
14
+ * - only `[a-zA-Z0-9._-]`
15
+ * - not shaped like an EVM address (`0x` + 40 hex chars) — an address
16
+ * passes the character rules but is a high-cardinality wallet
17
+ * identifier, not an application name. This also catches callers of
18
+ * `initializeSentry` still passing the pre-v9 positional argument
19
+ * order, where a wallet address occupied the slot `appName` now holds.
20
+ *
21
+ * Throws a descriptive `AugustValidationError` (code `INVALID_INPUT`) that
22
+ * names the failed rule and includes a remediation hint pointing at the
23
+ * docs link.
24
+ *
25
+ * @param value - The candidate app name, as received from the caller.
26
+ * @returns The trimmed, validated slug.
27
+ * @throws AugustValidationError when the value is missing, empty,
28
+ * mis-typed, out of the 3–64 length range, contains disallowed
29
+ * characters, or is shaped like an EVM address.
30
+ */
31
+ function validateAppName(value) {
32
+ const docsHint = 'See https://docs.augustdigital.io/developers/typescript-sdk#app-name';
33
+ if (typeof value !== 'string' || value.trim().length === 0) {
34
+ throw new errors_1.AugustValidationError('INVALID_INPUT', `August SDK: \`appName\` is required. Pass a stable kebab-case slug identifying your application (e.g. "acme-trader"). ${docsHint}`);
35
+ }
36
+ const trimmed = value.trim();
37
+ if (trimmed.length < 3 || trimmed.length > 64) {
38
+ throw new errors_1.AugustValidationError('INVALID_INPUT', `August SDK: \`appName\` must be 3-64 characters (got ${trimmed.length}). ${docsHint}`);
39
+ }
40
+ if (!/^[a-zA-Z0-9._-]+$/.test(trimmed)) {
41
+ throw new errors_1.AugustValidationError('INVALID_INPUT', `August SDK: \`appName\` may only contain letters, digits, '.', '_' and '-' (got "${trimmed}"). Use a slug like "acme-trader", not a display name. ${docsHint}`);
42
+ }
43
+ if (/^0x[0-9a-fA-F]{40}$/.test(trimmed)) {
44
+ throw new errors_1.AugustValidationError('INVALID_INPUT', `August SDK: \`appName\` looks like a wallet address ("${trimmed}"). Pass an application slug like "acme-trader" — if you are calling initializeSentry directly, note that since v9 the argument order is (config, environment, appName, walletAddress?, apiKey?). ${docsHint}`);
45
+ }
46
+ return trimmed;
47
+ }
48
+ //# sourceMappingURL=app-name.js.map
@@ -12,16 +12,28 @@ export declare function resetErrorDedupe(): void;
12
12
  * Initialize Sentry with SDK-specific configuration. Idempotent: re-calls
13
13
  * only refresh user identity and the cached API-key hash.
14
14
  *
15
+ * Breaking change in v9: `appName` moved from the optional fifth parameter
16
+ * to the required third parameter, so every telemetry stream carries an
17
+ * application identity (the `AugustSDK` constructor has required it since
18
+ * v5). Callers on the old positional order get a synchronous validation
19
+ * error rather than silently anonymous events.
20
+ *
15
21
  * @param config - Analytics configuration. Pass `tracesSampleRate` to
16
22
  * override the default of `0.1`.
17
23
  * @param environment - Current environment (DEV or PROD).
24
+ * @param appName - App-name slug, required. Set as the global `app.name`
25
+ * tag on every event and used to derive `partner.id`. Identifier-shaped:
26
+ * 3–64 chars, `[a-zA-Z0-9._-]` only, and not an EVM address — the same
27
+ * rules the `AugustSDK` constructor enforces.
18
28
  * @param walletAddress - Optional wallet address for user identification.
19
29
  * @param apiKey - Optional API key (hashed for identification).
20
- * @param appName - Optional app-name slug. Set as the global `app.name`
21
- * tag on every event; falls back to `'unverified:anonymous'` when
22
- * omitted.
30
+ * @throws AugustValidationError (code `INVALID_INPUT`) when `appName` is
31
+ * missing, empty, mis-typed, out of the allowed length range, contains
32
+ * disallowed characters, or is shaped like an EVM address. Thrown before
33
+ * any analytics state mutates, even when analytics would be disabled by
34
+ * config or environment gates.
23
35
  */
24
- export declare function initializeSentry(config: IAnalyticsConfig, environment: IEnv, walletAddress?: string, apiKey?: string, appName?: string): void;
36
+ export declare function initializeSentry(config: IAnalyticsConfig, environment: IEnv, appName: string, walletAddress?: string, apiKey?: string): void;
25
37
  /**
26
38
  * Update the current user identity in Sentry.
27
39
  * Called when wallet address changes.
@@ -9,6 +9,7 @@ exports.getSentry = getSentry;
9
9
  exports.resetAnalytics = resetAnalytics;
10
10
  exports.captureSdkException = captureSdkException;
11
11
  const logger_1 = require("../logger");
12
+ const app_name_1 = require("./app-name");
12
13
  const constants_1 = require("./constants");
13
14
  const env_1 = require("./env");
14
15
  const sentry_runtime_1 = require("./sentry-runtime");
@@ -305,16 +306,32 @@ function createSentrySink() {
305
306
  * Initialize Sentry with SDK-specific configuration. Idempotent: re-calls
306
307
  * only refresh user identity and the cached API-key hash.
307
308
  *
309
+ * Breaking change in v9: `appName` moved from the optional fifth parameter
310
+ * to the required third parameter, so every telemetry stream carries an
311
+ * application identity (the `AugustSDK` constructor has required it since
312
+ * v5). Callers on the old positional order get a synchronous validation
313
+ * error rather than silently anonymous events.
314
+ *
308
315
  * @param config - Analytics configuration. Pass `tracesSampleRate` to
309
316
  * override the default of `0.1`.
310
317
  * @param environment - Current environment (DEV or PROD).
318
+ * @param appName - App-name slug, required. Set as the global `app.name`
319
+ * tag on every event and used to derive `partner.id`. Identifier-shaped:
320
+ * 3–64 chars, `[a-zA-Z0-9._-]` only, and not an EVM address — the same
321
+ * rules the `AugustSDK` constructor enforces.
311
322
  * @param walletAddress - Optional wallet address for user identification.
312
323
  * @param apiKey - Optional API key (hashed for identification).
313
- * @param appName - Optional app-name slug. Set as the global `app.name`
314
- * tag on every event; falls back to `'unverified:anonymous'` when
315
- * omitted.
324
+ * @throws AugustValidationError (code `INVALID_INPUT`) when `appName` is
325
+ * missing, empty, mis-typed, out of the allowed length range, contains
326
+ * disallowed characters, or is shaped like an EVM address. Thrown before
327
+ * any analytics state mutates, even when analytics would be disabled by
328
+ * config or environment gates.
316
329
  */
317
- function initializeSentry(config, environment, walletAddress, apiKey, appName) {
330
+ function initializeSentry(config, environment, appName, walletAddress, apiKey) {
331
+ // Enforce the identity contract before anything else — including the
332
+ // idempotency short-circuit and the disable gates — so a bad appName is
333
+ // equally loud on every call path and in every environment.
334
+ const validatedAppName = (0, app_name_1.validateAppName)(appName);
318
335
  // SDK construction runs this multiple times (base + adapter constructors).
319
336
  // Short-circuit so the disable-reason logs only once per process.
320
337
  if (isInitialized) {
@@ -473,11 +490,9 @@ function initializeSentry(config, environment, walletAddress, apiKey, appName) {
473
490
  safeSetTag('sdk.runtime', (0, sentry_runtime_1.getSentryRuntime)());
474
491
  // `app.name` is the dimension we filter on in Sentry to attribute
475
492
  // events to a specific consuming application — see SDK quickstart docs.
476
- if (appName) {
477
- safeSetTag('app.name', appName);
478
- }
493
+ safeSetTag('app.name', validatedAppName);
479
494
  // `unverified:` prefix until the backend API-key → partner-id endpoint exists.
480
- safeSetTag('partner.id', appName ? `unverified:${appName}` : 'unverified:anonymous');
495
+ safeSetTag('partner.id', `unverified:${validatedAppName}`);
481
496
  safeSetTag('partner.tier', 'unverified');
482
497
  // Bridge the SDK's structured logger into Sentry now that the SDK is live.
483
498
  // Without this, Logger.log.error/warn are no-ops in production (no
@@ -3,4 +3,4 @@
3
3
  * Generated during publish from package.json version
4
4
  * This file is gitignored and created at publish time
5
5
  */
6
- export declare const SDK_VERSION = "8.26.0";
6
+ export declare const SDK_VERSION = "9.0.0";
@@ -6,5 +6,5 @@ exports.SDK_VERSION = void 0;
6
6
  * Generated during publish from package.json version
7
7
  * This file is gitignored and created at publish time
8
8
  */
9
- exports.SDK_VERSION = '8.26.0';
9
+ exports.SDK_VERSION = '9.0.0';
10
10
  //# sourceMappingURL=version.js.map
@@ -25,7 +25,8 @@ export interface IAugustBase {
25
25
  * 3–64 characters, `[a-zA-Z0-9._-]` only. Use a slug ("acme-trader"),
26
26
  * not a display name ("Acme Trader").
27
27
  *
28
- * @throws Throws synchronously from the constructor if missing or empty.
28
+ * @throws AugustValidationError synchronously from the constructor if
29
+ * missing, empty, or malformed.
29
30
  *
30
31
  * @example
31
32
  * ```typescript
@@ -120,8 +121,8 @@ export declare class AugustBase {
120
121
  * Initialize base SDK with provider configuration and API keys.
121
122
  * Sets up the first provider as the active network by default.
122
123
  *
123
- * @throws If `appName` is missing, malformed, or out of the allowed
124
- * length range — see {@link IAugustBase.appName}.
124
+ * @throws AugustValidationError if `appName` is missing, malformed, or
125
+ * out of the allowed length range — see {@link IAugustBase.appName}.
125
126
  */
126
127
  constructor({ appName, providers, keys, monitoring, analytics, versionCheck, timeoutMs, publicApiBaseUrl, attribution, }: IAugustBase);
127
128
  /**
@@ -4,36 +4,10 @@ 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 app_name_1 = require("./analytics/app-name");
7
8
  const version_check_1 = require("./version-check");
8
9
  const fetcher_1 = require("./fetcher");
9
10
  const attribution_1 = require("./attribution");
10
- /**
11
- * Validate an appName at SDK construction time.
12
- *
13
- * Rules (kept intentionally narrow so the value is safe to use as a Sentry
14
- * tag, an HTTP header value, and a filesystem-safe identifier — this is
15
- * why we accept slugs only, not display names):
16
- * - non-empty after trim
17
- * - 3..64 characters
18
- * - only `[a-zA-Z0-9._-]`
19
- *
20
- * Throws a descriptive Error that names the failed rule and includes a
21
- * remediation hint pointing at the docs link.
22
- */
23
- function validateAppName(value) {
24
- const docsHint = 'See https://docs.augustdigital.io/developers/typescript-sdk#app-name';
25
- if (typeof value !== 'string' || value.trim().length === 0) {
26
- throw new Error(`August SDK: \`appName\` is required. Pass a stable kebab-case slug identifying your application (e.g. "acme-trader"). ${docsHint}`);
27
- }
28
- const trimmed = value.trim();
29
- if (trimmed.length < 3 || trimmed.length > 64) {
30
- throw new Error(`August SDK: \`appName\` must be 3-64 characters (got ${trimmed.length}). ${docsHint}`);
31
- }
32
- if (!/^[a-zA-Z0-9._-]+$/.test(trimmed)) {
33
- 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}`);
34
- }
35
- return trimmed;
36
- }
37
11
  /**
38
12
  * Base class providing core SDK functionality including provider management,
39
13
  * network switching, and authentication state.
@@ -53,13 +27,13 @@ class AugustBase {
53
27
  * Initialize base SDK with provider configuration and API keys.
54
28
  * Sets up the first provider as the active network by default.
55
29
  *
56
- * @throws If `appName` is missing, malformed, or out of the allowed
57
- * length range — see {@link IAugustBase.appName}.
30
+ * @throws AugustValidationError if `appName` is missing, malformed, or
31
+ * out of the allowed length range — see {@link IAugustBase.appName}.
58
32
  */
59
33
  constructor({ appName, providers = {}, keys, monitoring, analytics, versionCheck, timeoutMs, publicApiBaseUrl, attribution, }) {
60
34
  // Validate first so the failure mode is a clear, actionable error before
61
35
  // any provider / analytics side effects run.
62
- this.appName = validateAppName(appName);
36
+ this.appName = (0, app_name_1.validateAppName)(appName);
63
37
  // TODO: change this to false later when august key is required
64
38
  this.authorized = true;
65
39
  this.providers = providers;
@@ -82,7 +56,7 @@ class AugustBase {
82
56
  logger_1.Logger.setDevMode(environment === 'DEV');
83
57
  // Initialize analytics (pass API key for hashed identification + the
84
58
  // appName so events can be filtered by consuming application).
85
- (0, analytics_1.initializeSentry)(analytics ?? { enabled: true }, environment, monitoring?.['x-user-id'], keys?.august, this.appName);
59
+ (0, analytics_1.initializeSentry)(analytics ?? { enabled: true }, environment, this.appName, monitoring?.['x-user-id'], keys?.august);
86
60
  // Best-effort version nudge — fire-and-forget, never blocks init, no
87
61
  // network call in production. See `core/version-check.ts` for details.
88
62
  (0, version_check_1.runVersionCheck)(versionCheck);
package/lib/sdk.d.ts CHANGED
@@ -15822,8 +15822,8 @@ declare type AsArray<T> = T extends readonly unknown[] ? T : never;
15822
15822
  * Initialize base SDK with provider configuration and API keys.
15823
15823
  * Sets up the first provider as the active network by default.
15824
15824
  *
15825
- * @throws If `appName` is missing, malformed, or out of the allowed
15826
- * length range — see {@link IAugustBase.appName}.
15825
+ * @throws AugustValidationError if `appName` is missing, malformed, or
15826
+ * out of the allowed length range — see {@link IAugustBase.appName}.
15827
15827
  */
15828
15828
  constructor({ appName, providers, keys, monitoring, analytics, versionCheck, timeoutMs, publicApiBaseUrl, attribution, }: IAugustBase);
15829
15829
  /**
@@ -19960,7 +19960,8 @@ declare type AsArray<T> = T extends readonly unknown[] ? T : never;
19960
19960
  * 3–64 characters, `[a-zA-Z0-9._-]` only. Use a slug ("acme-trader"),
19961
19961
  * not a display name ("Acme Trader").
19962
19962
  *
19963
- * @throws Throws synchronously from the constructor if missing or empty.
19963
+ * @throws AugustValidationError synchronously from the constructor if
19964
+ * missing, empty, or malformed.
19964
19965
  *
19965
19966
  * @example
19966
19967
  * ```typescript
@@ -20983,16 +20984,28 @@ declare type AsArray<T> = T extends readonly unknown[] ? T : never;
20983
20984
  * Initialize Sentry with SDK-specific configuration. Idempotent: re-calls
20984
20985
  * only refresh user identity and the cached API-key hash.
20985
20986
  *
20987
+ * Breaking change in v9: `appName` moved from the optional fifth parameter
20988
+ * to the required third parameter, so every telemetry stream carries an
20989
+ * application identity (the `AugustSDK` constructor has required it since
20990
+ * v5). Callers on the old positional order get a synchronous validation
20991
+ * error rather than silently anonymous events.
20992
+ *
20986
20993
  * @param config - Analytics configuration. Pass `tracesSampleRate` to
20987
20994
  * override the default of `0.1`.
20988
20995
  * @param environment - Current environment (DEV or PROD).
20996
+ * @param appName - App-name slug, required. Set as the global `app.name`
20997
+ * tag on every event and used to derive `partner.id`. Identifier-shaped:
20998
+ * 3–64 chars, `[a-zA-Z0-9._-]` only, and not an EVM address — the same
20999
+ * rules the `AugustSDK` constructor enforces.
20989
21000
  * @param walletAddress - Optional wallet address for user identification.
20990
21001
  * @param apiKey - Optional API key (hashed for identification).
20991
- * @param appName - Optional app-name slug. Set as the global `app.name`
20992
- * tag on every event; falls back to `'unverified:anonymous'` when
20993
- * omitted.
21002
+ * @throws AugustValidationError (code `INVALID_INPUT`) when `appName` is
21003
+ * missing, empty, mis-typed, out of the allowed length range, contains
21004
+ * disallowed characters, or is shaped like an EVM address. Thrown before
21005
+ * any analytics state mutates, even when analytics would be disabled by
21006
+ * config or environment gates.
20994
21007
  */
20995
- export declare function initializeSentry(config: IAnalyticsConfig, environment: IEnv, walletAddress?: string, apiKey?: string, appName?: string): void;
21008
+ export declare function initializeSentry(config: IAnalyticsConfig, environment: IEnv, appName: string, walletAddress?: string, apiKey?: string): void;
20996
21009
 
20997
21010
  export declare type INormalizedNumber = {
20998
21011
  normalized: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@augustdigital/sdk",
3
- "version": "8.26.0",
3
+ "version": "9.0.0",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/sdk.d.ts",
6
6
  "keywords": [