@sparkvault/sdk-js 12.0.5 → 13.0.1

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/errors.d.ts CHANGED
@@ -13,16 +13,43 @@ export declare class SparkVaultError extends Error {
13
13
  * carried none the policy could read, or no answer arrived.
14
14
  */
15
15
  readonly retryAfterMs: number | null;
16
- constructor(message: string, code: string, statusCode?: number, details?: Record<string, unknown>, retryAfterMs?: number | null);
16
+ /**
17
+ * The machine-readable code the API answered with (`INVALID_CURSOR`,
18
+ * `LICENSE_REQUIRED`), on every error the SDK's API client builds from a
19
+ * refused call of a data-plane module (`vaults`, `ingots`, `folders`,
20
+ * `sparks`, `entropy`, `notify`, `products.notify`); `api_error` when the
21
+ * answer named none (a gateway's HTML). A typed refusal's `code` names its
22
+ * class of failure: one per 400 (`validation_error`), two per 401
23
+ * (`authentication_error`, `UNAUTHORIZED`), 402 (`PLAN_REQUIRED`,
24
+ * `QUOTA_EXCEEDED`) and 403 (`authorization_error`, `NOTIFY_SUBSCRIPTION_REQUIRED`;
25
+ * http.ts createErrorFromResponse), so this is what tells apart two
26
+ * refusals that share a code.
27
+ * Undefined on an error the SDK raised itself, on the Identity product's
28
+ * errors (`products.identity`, whose `code` is the service's own), and on the
29
+ * errors of an upload's transfer (`UploadApiError`, which names Core's code in
30
+ * its `code` or `details.coreCode`, a staging call Core refused for good among
31
+ * them) and of a download (`download_failed`, its status alone).
32
+ */
33
+ readonly serviceCode?: string;
34
+ constructor(message: string, code: string, statusCode?: number, details?: Record<string, unknown>, retryAfterMs?: number | null, serviceCode?: string);
17
35
  }
18
36
  export declare class AuthenticationError extends SparkVaultError {
19
- constructor(message: string, details?: Record<string, unknown>, retryAfterMs?: number | null);
37
+ constructor(message: string, details?: Record<string, unknown>, retryAfterMs?: number | null, serviceCode?: string);
38
+ }
39
+ /**
40
+ * A key the request presents was refused (401 UNAUTHORIZED): the DVAK an
41
+ * unseal names is invalid or revoked. The caller's own credential stood, so
42
+ * this is no ended session, and signing in again changes nothing: present a
43
+ * live key. Every other 401 is an {@link AuthenticationError}.
44
+ */
45
+ export declare class UnauthorizedError extends SparkVaultError {
46
+ constructor(message: string, details?: Record<string, unknown>, retryAfterMs?: number | null, serviceCode?: string);
20
47
  }
21
48
  export declare class AuthorizationError extends SparkVaultError {
22
- constructor(message: string, details?: Record<string, unknown>, retryAfterMs?: number | null);
49
+ constructor(message: string, details?: Record<string, unknown>, retryAfterMs?: number | null, serviceCode?: string);
23
50
  }
24
51
  export declare class ValidationError extends SparkVaultError {
25
- constructor(message: string, details?: Record<string, unknown>, retryAfterMs?: number | null);
52
+ constructor(message: string, details?: Record<string, unknown>, retryAfterMs?: number | null, serviceCode?: string);
26
53
  }
27
54
  /**
28
55
  * The pooled-capacity resource a quota gate refers to. Only the byte pools
@@ -37,7 +64,7 @@ export type QuotaResource = 'storage' | 'bandwidth';
37
64
  * to admins, or "ask your account admin" to members.
38
65
  */
39
66
  export declare class PlanRequiredError extends SparkVaultError {
40
- constructor(message: string, details?: Record<string, unknown>, retryAfterMs?: number | null);
67
+ constructor(message: string, details?: Record<string, unknown>, retryAfterMs?: number | null, serviceCode?: string);
41
68
  }
42
69
  /**
43
70
  * Quota exceeded gate (402 QUOTA_EXCEEDED) — a pooled-capacity limit is
@@ -46,16 +73,19 @@ export declare class PlanRequiredError extends SparkVaultError {
46
73
  */
47
74
  export declare class QuotaExceededError extends SparkVaultError {
48
75
  readonly resource?: QuotaResource;
49
- constructor(message: string, details?: Record<string, unknown>, retryAfterMs?: number | null);
76
+ constructor(message: string, details?: Record<string, unknown>, retryAfterMs?: number | null, serviceCode?: string);
50
77
  }
51
78
  /**
52
- * Notify subscription gate (403 NOTIFY_SUBSCRIPTION_REQUIRED) — the account has
53
- * no active Notify subscription and attempted a send. Distinct from a generic
54
- * authorization failure: the credential is fine and re-authenticating changes
55
- * nothing, so surface a subscribe CTA rather than a sign-in prompt.
79
+ * Notify subscription gate (403 NOTIFY_SUBSCRIPTION_REQUIRED) — the account
80
+ * does not hold Notify and attempted a send that names no accepted send's
81
+ * `sendId` (a replay of an accepted send, the same request under its `sendId`,
82
+ * is answered with the stored send), or a config save that selects a new
83
+ * `email.sending_domain`. Distinct from a generic authorization failure: the
84
+ * credential is fine and re-authenticating changes nothing, so surface a
85
+ * subscribe CTA rather than a sign-in prompt.
56
86
  */
57
87
  export declare class NotifySubscriptionRequiredError extends SparkVaultError {
58
- constructor(message: string, details?: Record<string, unknown>, retryAfterMs?: number | null);
88
+ constructor(message: string, details?: Record<string, unknown>, retryAfterMs?: number | null, serviceCode?: string);
59
89
  }
60
90
  export declare class NetworkError extends SparkVaultError {
61
91
  constructor(message: string, details?: Record<string, unknown>);
package/dist/http.d.ts CHANGED
@@ -25,12 +25,14 @@ export declare class HttpClient {
25
25
  request<T = unknown>(path: ApiPath, options?: RequestOptions): Promise<ApiResponse<T>>;
26
26
  private parseResponse;
27
27
  /**
28
- * The SDK error for a failed answer, typed by its status: the gates a host
29
- * page branches on get their own class, and every other answer is the base
30
- * error under the service's own code. Each carries the answer's
31
- * `Retry-After` (`retryAfterMs`), the floor for whoever retries it — the
32
- * SDK's own transfers when the answer is a download link's mint, and the
33
- * host page otherwise.
28
+ * The SDK error for a failed answer, typed by its status (a 402's or a 403's
29
+ * by its code too): the gates a host page branches on get their own class,
30
+ * and every other answer is the base error under the service's own code.
31
+ * Each carries the service's code (`serviceCode`), which tells apart two
32
+ * refusals that share a typed class's `code`, and the answer's `Retry-After`
33
+ * (`retryAfterMs`), the floor for whoever retries it — the SDK's own
34
+ * transfers when the answer is a download link's mint, and the host page
35
+ * otherwise.
34
36
  */
35
37
  private createErrorFromResponse;
36
38
  private unwrapApiResponse;