@capsara/sdk 1.0.5 → 2.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/README.md +110 -28
- package/dist/builder/capsa-builder.d.ts +29 -13
- package/dist/builder/capsa-builder.d.ts.map +1 -1
- package/dist/builder/capsa-builder.js +302 -84
- package/dist/builder/capsa-builder.js.map +1 -1
- package/dist/client/capsara-client.d.ts +30 -26
- package/dist/client/capsara-client.d.ts.map +1 -1
- package/dist/client/capsara-client.js +102 -60
- package/dist/client/capsara-client.js.map +1 -1
- package/dist/errors/account-error.d.ts +5 -70
- package/dist/errors/account-error.d.ts.map +1 -1
- package/dist/errors/account-error.js +8 -146
- package/dist/errors/account-error.js.map +1 -1
- package/dist/errors/audit-error.d.ts +4 -28
- package/dist/errors/audit-error.d.ts.map +1 -1
- package/dist/errors/audit-error.js +9 -82
- package/dist/errors/audit-error.js.map +1 -1
- package/dist/errors/auth-error.d.ts +4 -35
- package/dist/errors/auth-error.d.ts.map +1 -1
- package/dist/errors/auth-error.js +6 -77
- package/dist/errors/auth-error.js.map +1 -1
- package/dist/errors/capsa-error.d.ts +5 -59
- package/dist/errors/capsa-error.d.ts.map +1 -1
- package/dist/errors/capsa-error.js +9 -156
- package/dist/errors/capsa-error.js.map +1 -1
- package/dist/errors/capsara-error.d.ts +24 -24
- package/dist/errors/capsara-error.d.ts.map +1 -1
- package/dist/errors/capsara-error.js +141 -34
- package/dist/errors/capsara-error.js.map +1 -1
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/capsa-cache.d.ts +0 -3
- package/dist/internal/capsa-cache.d.ts.map +1 -1
- package/dist/internal/capsa-cache.js +7 -23
- package/dist/internal/capsa-cache.js.map +1 -1
- package/dist/internal/config/http-client.d.ts.map +1 -1
- package/dist/internal/config/http-client.js +48 -21
- package/dist/internal/config/http-client.js.map +1 -1
- package/dist/internal/config/retry-interceptor.d.ts +26 -3
- package/dist/internal/config/retry-interceptor.d.ts.map +1 -1
- package/dist/internal/config/retry-interceptor.js +111 -83
- package/dist/internal/config/retry-interceptor.js.map +1 -1
- package/dist/internal/config/token-refresh.d.ts +12 -0
- package/dist/internal/config/token-refresh.d.ts.map +1 -0
- package/dist/internal/config/token-refresh.js +43 -0
- package/dist/internal/config/token-refresh.js.map +1 -0
- package/dist/internal/crypto/compression.d.ts +12 -0
- package/dist/internal/crypto/compression.d.ts.map +1 -1
- package/dist/internal/crypto/compression.js +14 -1
- package/dist/internal/crypto/compression.js.map +1 -1
- package/dist/internal/crypto/key-generator.d.ts +39 -4
- package/dist/internal/crypto/key-generator.d.ts.map +1 -1
- package/dist/internal/crypto/key-generator.js +93 -24
- package/dist/internal/crypto/key-generator.js.map +1 -1
- package/dist/internal/crypto/primitives.d.ts +1 -2
- package/dist/internal/crypto/primitives.d.ts.map +1 -1
- package/dist/internal/crypto/primitives.js +15 -14
- package/dist/internal/crypto/primitives.js.map +1 -1
- package/dist/internal/crypto/signatures.d.ts +3 -1
- package/dist/internal/crypto/signatures.d.ts.map +1 -1
- package/dist/internal/crypto/signatures.js +14 -6
- package/dist/internal/crypto/signatures.js.map +1 -1
- package/dist/internal/decryptor/capsa-decryptor.d.ts +11 -54
- package/dist/internal/decryptor/capsa-decryptor.d.ts.map +1 -1
- package/dist/internal/decryptor/capsa-decryptor.js +167 -160
- package/dist/internal/decryptor/capsa-decryptor.js.map +1 -1
- package/dist/internal/http-factory.d.ts +3 -47
- package/dist/internal/http-factory.d.ts.map +1 -1
- package/dist/internal/http-factory.js +2 -157
- package/dist/internal/http-factory.js.map +1 -1
- package/dist/internal/logging.d.ts +13 -0
- package/dist/internal/logging.d.ts.map +1 -0
- package/dist/internal/logging.js +22 -0
- package/dist/internal/logging.js.map +1 -0
- package/dist/internal/services/account-service.d.ts +11 -33
- package/dist/internal/services/account-service.d.ts.map +1 -1
- package/dist/internal/services/account-service.js +38 -53
- package/dist/internal/services/account-service.js.map +1 -1
- package/dist/internal/services/audit-service.d.ts.map +1 -1
- package/dist/internal/services/audit-service.js +17 -1
- package/dist/internal/services/audit-service.js.map +1 -1
- package/dist/internal/services/auth-service.d.ts +17 -1
- package/dist/internal/services/auth-service.d.ts.map +1 -1
- package/dist/internal/services/auth-service.js +188 -51
- package/dist/internal/services/auth-service.js.map +1 -1
- package/dist/internal/services/capsa-service.d.ts +8 -26
- package/dist/internal/services/capsa-service.d.ts.map +1 -1
- package/dist/internal/services/capsa-service.js +91 -44
- package/dist/internal/services/capsa-service.js.map +1 -1
- package/dist/internal/services/download-service.d.ts +17 -25
- package/dist/internal/services/download-service.d.ts.map +1 -1
- package/dist/internal/services/download-service.js +30 -56
- package/dist/internal/services/download-service.js.map +1 -1
- package/dist/internal/services/key-service.d.ts +6 -14
- package/dist/internal/services/key-service.d.ts.map +1 -1
- package/dist/internal/services/key-service.js +63 -21
- package/dist/internal/services/key-service.js.map +1 -1
- package/dist/internal/services/limits-service.d.ts +14 -16
- package/dist/internal/services/limits-service.d.ts.map +1 -1
- package/dist/internal/services/limits-service.js +60 -28
- package/dist/internal/services/limits-service.js.map +1 -1
- package/dist/internal/services/upload-service.d.ts +33 -27
- package/dist/internal/services/upload-service.d.ts.map +1 -1
- package/dist/internal/services/upload-service.js +307 -133
- package/dist/internal/services/upload-service.js.map +1 -1
- package/dist/internal/types.d.ts +0 -7
- package/dist/internal/types.d.ts.map +1 -1
- package/dist/internal/upload/multipart-builder.d.ts +0 -15
- package/dist/internal/upload/multipart-builder.d.ts.map +1 -1
- package/dist/internal/upload/multipart-builder.js +0 -26
- package/dist/internal/upload/multipart-builder.js.map +1 -1
- package/dist/internal/utils/filename-check.d.ts +11 -0
- package/dist/internal/utils/filename-check.d.ts.map +1 -0
- package/dist/internal/utils/filename-check.js +28 -0
- package/dist/internal/utils/filename-check.js.map +1 -0
- package/dist/internal/utils/rfc3339.d.ts +15 -0
- package/dist/internal/utils/rfc3339.d.ts.map +1 -0
- package/dist/internal/utils/rfc3339.js +53 -0
- package/dist/internal/utils/rfc3339.js.map +1 -0
- package/dist/internal/utils/safe-filename.d.ts +31 -0
- package/dist/internal/utils/safe-filename.d.ts.map +1 -0
- package/dist/internal/utils/safe-filename.js +126 -0
- package/dist/internal/utils/safe-filename.js.map +1 -0
- package/dist/internal/version.d.ts +18 -14
- package/dist/internal/version.d.ts.map +1 -1
- package/dist/internal/version.js +47 -14
- package/dist/internal/version.js.map +1 -1
- package/dist/types/index.d.ts +26 -10
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/package.json +13 -11
- package/dist/internal/index.d.ts +0 -5
- package/dist/internal/index.d.ts.map +0 -1
- package/dist/internal/index.js +0 -5
- package/dist/internal/index.js.map +0 -1
- package/dist/internal/retry-executor.d.ts +0 -74
- package/dist/internal/retry-executor.d.ts.map +0 -1
- package/dist/internal/retry-executor.js +0 -204
- package/dist/internal/retry-executor.js.map +0 -1
|
@@ -1,73 +1,8 @@
|
|
|
1
|
-
/** Errors from account operations (
|
|
2
|
-
import { CapsaraError, type ApiErrorResponse, type
|
|
1
|
+
/** Errors from account operations (keys, key history). */
|
|
2
|
+
import { CapsaraError, type ApiErrorResponse, type CapsaraErrorExtras } from './capsara-error.js';
|
|
3
|
+
import { CapsaraAuthError } from './auth-error.js';
|
|
3
4
|
export declare class CapsaraAccountError extends CapsaraError {
|
|
4
|
-
constructor(message: string, code: string, statusCode: number, details?:
|
|
5
|
-
|
|
6
|
-
* Unauthorized - missing or invalid authentication
|
|
7
|
-
* HTTP 401 - UNAUTHORIZED
|
|
8
|
-
*/
|
|
9
|
-
static unauthorized(): CapsaraAccountError;
|
|
10
|
-
/**
|
|
11
|
-
* Resource not found (webhook, license, appointment, etc.)
|
|
12
|
-
* HTTP 404 - NOT_FOUND
|
|
13
|
-
*/
|
|
14
|
-
static notFound(resourceType: string, identifier?: string): CapsaraAccountError;
|
|
15
|
-
/**
|
|
16
|
-
* Webhook not found
|
|
17
|
-
* HTTP 404 - WEBHOOK_NOT_FOUND
|
|
18
|
-
*/
|
|
19
|
-
static webhookNotFound(webhookId?: string): CapsaraAccountError;
|
|
20
|
-
/**
|
|
21
|
-
* License not found
|
|
22
|
-
* HTTP 404 - LICENSE_NOT_FOUND
|
|
23
|
-
*/
|
|
24
|
-
static licenseNotFound(state?: string, licenseNumber?: string): CapsaraAccountError;
|
|
25
|
-
/**
|
|
26
|
-
* Appointment not found
|
|
27
|
-
* HTTP 404 - APPOINTMENT_NOT_FOUND
|
|
28
|
-
*/
|
|
29
|
-
static appointmentNotFound(carrierPartyId?: string): CapsaraAccountError;
|
|
30
|
-
/**
|
|
31
|
-
* Delegate not found
|
|
32
|
-
* HTTP 404 - DELEGATE_NOT_FOUND
|
|
33
|
-
*/
|
|
34
|
-
static delegateNotFound(delegateId?: string): CapsaraAccountError;
|
|
35
|
-
/**
|
|
36
|
-
* Key not found
|
|
37
|
-
* HTTP 404 - KEY_NOT_FOUND
|
|
38
|
-
*/
|
|
39
|
-
static keyNotFound(keyFingerprint?: string): CapsaraAccountError;
|
|
40
|
-
/**
|
|
41
|
-
* Invalid request body (validation error)
|
|
42
|
-
* HTTP 400 - VALIDATION_ERROR
|
|
43
|
-
*/
|
|
44
|
-
static validationError(message: string, details?: Record<string, unknown>): CapsaraAccountError;
|
|
45
|
-
/**
|
|
46
|
-
* Missing required parameter
|
|
47
|
-
* HTTP 400 - MISSING_PARAM
|
|
48
|
-
*/
|
|
49
|
-
static missingParam(paramName: string): CapsaraAccountError;
|
|
50
|
-
/**
|
|
51
|
-
* Resource already exists (duplicate)
|
|
52
|
-
* HTTP 409 - ALREADY_EXISTS
|
|
53
|
-
*/
|
|
54
|
-
static alreadyExists(resourceType: string, identifier?: string): CapsaraAccountError;
|
|
55
|
-
/**
|
|
56
|
-
* Cannot delete active key
|
|
57
|
-
* HTTP 400 - CANNOT_DELETE_ACTIVE_KEY
|
|
58
|
-
*/
|
|
59
|
-
static cannotDeleteActiveKey(): CapsaraAccountError;
|
|
60
|
-
/**
|
|
61
|
-
* Webhook limit exceeded
|
|
62
|
-
* HTTP 400 - WEBHOOK_LIMIT_EXCEEDED
|
|
63
|
-
*/
|
|
64
|
-
static webhookLimitExceeded(limit: number): CapsaraAccountError;
|
|
65
|
-
/**
|
|
66
|
-
* Invalid webhook URL
|
|
67
|
-
* HTTP 400 - INVALID_WEBHOOK_URL
|
|
68
|
-
*/
|
|
69
|
-
static invalidWebhookUrl(url?: string): CapsaraAccountError;
|
|
70
|
-
/** Maps an API error response to the appropriate factory method. */
|
|
71
|
-
static fromApiError(error: AxiosLikeError): CapsaraAccountError;
|
|
5
|
+
constructor(message: string, code: string, statusCode: number, details?: unknown, response?: ApiErrorResponse, extras?: CapsaraErrorExtras);
|
|
6
|
+
static fromApiError(error: unknown): CapsaraAccountError | CapsaraAuthError;
|
|
72
7
|
}
|
|
73
8
|
//# sourceMappingURL=account-error.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-error.d.ts","sourceRoot":"","sources":["../../src/errors/account-error.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"account-error.d.ts","sourceRoot":"","sources":["../../src/errors/account-error.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAE1D,OAAO,EACL,YAAY,EAEZ,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,qBAAa,mBAAoB,SAAQ,YAAY;gBAEjD,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,OAAO,EACjB,QAAQ,CAAC,EAAE,gBAAgB,EAC3B,MAAM,CAAC,EAAE,kBAAkB;IAM7B,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,mBAAmB,GAAG,gBAAgB;CAO5E"}
|
|
@@ -1,155 +1,17 @@
|
|
|
1
|
-
/** Errors from account operations (
|
|
2
|
-
import { CapsaraError } from './capsara-error.js';
|
|
1
|
+
/** Errors from account operations (keys, key history). */
|
|
2
|
+
import { CapsaraError, parseApiError, } from './capsara-error.js';
|
|
3
|
+
import { CapsaraAuthError } from './auth-error.js';
|
|
3
4
|
export class CapsaraAccountError extends CapsaraError {
|
|
4
|
-
constructor(message, code, statusCode, details, response) {
|
|
5
|
-
super(message, code, statusCode, details, response);
|
|
5
|
+
constructor(message, code, statusCode, details, response, extras) {
|
|
6
|
+
super(message, code, statusCode, details, response, extras);
|
|
6
7
|
this.name = 'CapsaraAccountError';
|
|
7
8
|
}
|
|
8
|
-
/**
|
|
9
|
-
* Unauthorized - missing or invalid authentication
|
|
10
|
-
* HTTP 401 - UNAUTHORIZED
|
|
11
|
-
*/
|
|
12
|
-
static unauthorized() {
|
|
13
|
-
return new CapsaraAccountError('Unauthorized', 'UNAUTHORIZED', 401);
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Resource not found (webhook, license, appointment, etc.)
|
|
17
|
-
* HTTP 404 - NOT_FOUND
|
|
18
|
-
*/
|
|
19
|
-
static notFound(resourceType, identifier) {
|
|
20
|
-
return new CapsaraAccountError(identifier
|
|
21
|
-
? `${resourceType} with identifier ${identifier} not found`
|
|
22
|
-
: `${resourceType} not found`, 'NOT_FOUND', 404, { resourceType, identifier });
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Webhook not found
|
|
26
|
-
* HTTP 404 - WEBHOOK_NOT_FOUND
|
|
27
|
-
*/
|
|
28
|
-
static webhookNotFound(webhookId) {
|
|
29
|
-
return CapsaraAccountError.notFound('Webhook', webhookId);
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* License not found
|
|
33
|
-
* HTTP 404 - LICENSE_NOT_FOUND
|
|
34
|
-
*/
|
|
35
|
-
static licenseNotFound(state, licenseNumber) {
|
|
36
|
-
const identifier = state && licenseNumber ? `${state}/${licenseNumber}` : undefined;
|
|
37
|
-
return CapsaraAccountError.notFound('License', identifier);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Appointment not found
|
|
41
|
-
* HTTP 404 - APPOINTMENT_NOT_FOUND
|
|
42
|
-
*/
|
|
43
|
-
static appointmentNotFound(carrierPartyId) {
|
|
44
|
-
return CapsaraAccountError.notFound('Appointment', carrierPartyId);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Delegate not found
|
|
48
|
-
* HTTP 404 - DELEGATE_NOT_FOUND
|
|
49
|
-
*/
|
|
50
|
-
static delegateNotFound(delegateId) {
|
|
51
|
-
return CapsaraAccountError.notFound('Delegate', delegateId);
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Key not found
|
|
55
|
-
* HTTP 404 - KEY_NOT_FOUND
|
|
56
|
-
*/
|
|
57
|
-
static keyNotFound(keyFingerprint) {
|
|
58
|
-
return CapsaraAccountError.notFound('Key', keyFingerprint);
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Invalid request body (validation error)
|
|
62
|
-
* HTTP 400 - VALIDATION_ERROR
|
|
63
|
-
*/
|
|
64
|
-
static validationError(message, details) {
|
|
65
|
-
return new CapsaraAccountError(message || 'Invalid request body', 'VALIDATION_ERROR', 400, details);
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Missing required parameter
|
|
69
|
-
* HTTP 400 - MISSING_PARAM
|
|
70
|
-
*/
|
|
71
|
-
static missingParam(paramName) {
|
|
72
|
-
return new CapsaraAccountError(`${paramName} is required`, 'MISSING_PARAM', 400, { paramName });
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Resource already exists (duplicate)
|
|
76
|
-
* HTTP 409 - ALREADY_EXISTS
|
|
77
|
-
*/
|
|
78
|
-
static alreadyExists(resourceType, identifier) {
|
|
79
|
-
return new CapsaraAccountError(identifier
|
|
80
|
-
? `${resourceType} with identifier ${identifier} already exists`
|
|
81
|
-
: `${resourceType} already exists`, 'ALREADY_EXISTS', 409, { resourceType, identifier });
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Cannot delete active key
|
|
85
|
-
* HTTP 400 - CANNOT_DELETE_ACTIVE_KEY
|
|
86
|
-
*/
|
|
87
|
-
static cannotDeleteActiveKey() {
|
|
88
|
-
return new CapsaraAccountError('Cannot delete the currently active key', 'CANNOT_DELETE_ACTIVE_KEY', 400);
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Webhook limit exceeded
|
|
92
|
-
* HTTP 400 - WEBHOOK_LIMIT_EXCEEDED
|
|
93
|
-
*/
|
|
94
|
-
static webhookLimitExceeded(limit) {
|
|
95
|
-
return new CapsaraAccountError(`Webhook limit of ${limit} exceeded`, 'WEBHOOK_LIMIT_EXCEEDED', 400, { limit });
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Invalid webhook URL
|
|
99
|
-
* HTTP 400 - INVALID_WEBHOOK_URL
|
|
100
|
-
*/
|
|
101
|
-
static invalidWebhookUrl(url) {
|
|
102
|
-
return new CapsaraAccountError('Invalid webhook URL', 'INVALID_WEBHOOK_URL', 400, url ? { url } : undefined);
|
|
103
|
-
}
|
|
104
|
-
/** Maps an API error response to the appropriate factory method. */
|
|
105
9
|
static fromApiError(error) {
|
|
106
|
-
|
|
107
|
-
if (error.response) {
|
|
108
|
-
const status = error.response.status;
|
|
109
|
-
const data = error.response.data;
|
|
110
|
-
const errorCode = data?.error?.code;
|
|
111
|
-
const errorMessage = data?.error?.message ?? data?.message ?? error.message ?? 'Unknown error';
|
|
112
|
-
const errorDetails = data?.error?.details ?? data?.details;
|
|
113
|
-
// Map known error codes to factory methods
|
|
114
|
-
switch (errorCode) {
|
|
115
|
-
case 'UNAUTHORIZED':
|
|
116
|
-
return CapsaraAccountError.unauthorized();
|
|
117
|
-
case 'WEBHOOK_NOT_FOUND':
|
|
118
|
-
return CapsaraAccountError.webhookNotFound((errorDetails?.webhookId ?? errorDetails?.identifier));
|
|
119
|
-
case 'LICENSE_NOT_FOUND':
|
|
120
|
-
return CapsaraAccountError.licenseNotFound(errorDetails?.state, errorDetails?.licenseNumber);
|
|
121
|
-
case 'APPOINTMENT_NOT_FOUND':
|
|
122
|
-
return CapsaraAccountError.appointmentNotFound((errorDetails?.carrierPartyId ?? errorDetails?.identifier));
|
|
123
|
-
case 'DELEGATE_NOT_FOUND':
|
|
124
|
-
return CapsaraAccountError.delegateNotFound((errorDetails?.delegateId ?? errorDetails?.identifier));
|
|
125
|
-
case 'KEY_NOT_FOUND':
|
|
126
|
-
return CapsaraAccountError.keyNotFound((errorDetails?.keyFingerprint ?? errorDetails?.identifier));
|
|
127
|
-
case 'NOT_FOUND':
|
|
128
|
-
return CapsaraAccountError.notFound(errorDetails?.resourceType ?? 'Resource', errorDetails?.identifier);
|
|
129
|
-
case 'VALIDATION_ERROR':
|
|
130
|
-
return CapsaraAccountError.validationError(errorMessage, errorDetails);
|
|
131
|
-
case 'MISSING_PARAM':
|
|
132
|
-
return CapsaraAccountError.missingParam(errorDetails?.paramName ?? 'Parameter');
|
|
133
|
-
case 'ALREADY_EXISTS':
|
|
134
|
-
return CapsaraAccountError.alreadyExists(errorDetails?.resourceType ?? 'Resource', errorDetails?.identifier);
|
|
135
|
-
case 'CANNOT_DELETE_ACTIVE_KEY':
|
|
136
|
-
return CapsaraAccountError.cannotDeleteActiveKey();
|
|
137
|
-
case 'WEBHOOK_LIMIT_EXCEEDED':
|
|
138
|
-
return CapsaraAccountError.webhookLimitExceeded(errorDetails?.limit ?? 10);
|
|
139
|
-
case 'INVALID_WEBHOOK_URL':
|
|
140
|
-
return CapsaraAccountError.invalidWebhookUrl(errorDetails?.url);
|
|
141
|
-
default:
|
|
142
|
-
// Generic account error with status code
|
|
143
|
-
return new CapsaraAccountError(errorMessage, errorCode ?? 'ACCOUNT_ERROR', status, errorDetails);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
// Handle non-axios errors
|
|
147
|
-
if (error instanceof CapsaraAccountError) {
|
|
10
|
+
if (error instanceof CapsaraAccountError || error instanceof CapsaraAuthError) {
|
|
148
11
|
return error;
|
|
149
12
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
return new CapsaraAccountError(errorMessage, 'ACCOUNT_ERROR', 500, { originalError: errorMessage });
|
|
13
|
+
const parsed = parseApiError(error, 'ACCOUNT_ERROR');
|
|
14
|
+
return new CapsaraAccountError(parsed.message, parsed.code, parsed.statusCode, parsed.details, parsed.response, parsed);
|
|
153
15
|
}
|
|
154
16
|
}
|
|
155
17
|
//# sourceMappingURL=account-error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-error.js","sourceRoot":"","sources":["../../src/errors/account-error.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"account-error.js","sourceRoot":"","sources":["../../src/errors/account-error.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAE1D,OAAO,EACL,YAAY,EACZ,aAAa,GAGd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,OAAO,mBAAoB,SAAQ,YAAY;IACnD,YACE,OAAe,EACf,IAAY,EACZ,UAAkB,EAClB,OAAiB,EACjB,QAA2B,EAC3B,MAA2B;QAE3B,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,KAAc;QAChC,IAAI,KAAK,YAAY,mBAAmB,IAAI,KAAK,YAAY,gBAAgB,EAAE,CAAC;YAC9E,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,MAAM,GAAG,aAAa,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;QACrD,OAAO,IAAI,mBAAmB,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC1H,CAAC;CACF"}
|
|
@@ -1,34 +1,10 @@
|
|
|
1
|
-
import { CapsaraError, type ApiErrorResponse, type AxiosLikeError, type StoredErrorResponse } from './capsara-error.js';
|
|
2
1
|
/** Errors from audit trail operations. */
|
|
2
|
+
import { CapsaraError, type ApiErrorResponse, type CapsaraErrorExtras, type StoredErrorResponse } from './capsara-error.js';
|
|
3
|
+
import { CapsaraAuthError } from './auth-error.js';
|
|
3
4
|
export declare class CapsaraAuditError extends CapsaraError {
|
|
4
5
|
readonly response?: StoredErrorResponse;
|
|
5
|
-
constructor(message: string, code: string, statusCode: number, details?:
|
|
6
|
-
/**
|
|
7
|
-
* Create error for insufficient permissions
|
|
8
|
-
* Thrown when recipient tries to add 'log' action (creator-only)
|
|
9
|
-
*/
|
|
10
|
-
static insufficientPermissions(details?: Record<string, unknown>): CapsaraAuditError;
|
|
11
|
-
/**
|
|
12
|
-
* Create error for invalid audit action
|
|
13
|
-
* Thrown when action is not 'log' or 'processed'
|
|
14
|
-
*/
|
|
15
|
-
static invalidAction(action?: string): CapsaraAuditError;
|
|
16
|
-
/**
|
|
17
|
-
* Create error for access denied
|
|
18
|
-
* Thrown when party is not in capsa keychain
|
|
19
|
-
*/
|
|
20
|
-
static accessDenied(details?: Record<string, unknown>): CapsaraAuditError;
|
|
21
|
-
/**
|
|
22
|
-
* Create error for missing details field
|
|
23
|
-
* Thrown when 'log' action is used without details
|
|
24
|
-
*/
|
|
6
|
+
constructor(message: string, code: string, statusCode: number, details?: unknown, response?: ApiErrorResponse, extras?: CapsaraErrorExtras);
|
|
25
7
|
static missingDetails(): CapsaraAuditError;
|
|
26
|
-
|
|
27
|
-
* Create error for capsa not found
|
|
28
|
-
* Thrown when capsa doesn't exist
|
|
29
|
-
*/
|
|
30
|
-
static capsaNotFound(capsaId: string): CapsaraAuditError;
|
|
31
|
-
/** Maps an API error response to the appropriate factory method. */
|
|
32
|
-
static fromApiError(error: AxiosLikeError): CapsaraAuditError;
|
|
8
|
+
static fromApiError(error: unknown): CapsaraAuditError | CapsaraAuthError;
|
|
33
9
|
}
|
|
34
10
|
//# sourceMappingURL=audit-error.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit-error.d.ts","sourceRoot":"","sources":["../../src/errors/audit-error.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"audit-error.d.ts","sourceRoot":"","sources":["../../src/errors/audit-error.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAE1C,OAAO,EACL,YAAY,EAEZ,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,qBAAa,iBAAkB,SAAQ,YAAY;IACjD,SAAwB,QAAQ,CAAC,EAAE,mBAAmB,CAAC;gBAGrD,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,OAAO,EACjB,QAAQ,CAAC,EAAE,gBAAgB,EAC3B,MAAM,CAAC,EAAE,kBAAkB;IAM7B,MAAM,CAAC,cAAc,IAAI,iBAAiB;IAQ1C,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,iBAAiB,GAAG,gBAAgB;CAO1E"}
|
|
@@ -1,93 +1,20 @@
|
|
|
1
|
-
import { CapsaraError } from './capsara-error.js';
|
|
2
1
|
/** Errors from audit trail operations. */
|
|
2
|
+
import { CapsaraError, parseApiError, } from './capsara-error.js';
|
|
3
|
+
import { CapsaraAuthError } from './auth-error.js';
|
|
3
4
|
export class CapsaraAuditError extends CapsaraError {
|
|
4
|
-
constructor(message, code, statusCode, details, response) {
|
|
5
|
-
super(message, code, statusCode, details, response);
|
|
5
|
+
constructor(message, code, statusCode, details, response, extras) {
|
|
6
|
+
super(message, code, statusCode, details, response, extras);
|
|
6
7
|
this.name = 'CapsaraAuditError';
|
|
7
|
-
Object.setPrototypeOf(this, CapsaraAuditError.prototype);
|
|
8
8
|
}
|
|
9
|
-
/**
|
|
10
|
-
* Create error for insufficient permissions
|
|
11
|
-
* Thrown when recipient tries to add 'log' action (creator-only)
|
|
12
|
-
*/
|
|
13
|
-
static insufficientPermissions(details) {
|
|
14
|
-
return new CapsaraAuditError('You do not have permission to perform this action', 'INSUFFICIENT_PERMISSIONS', 403, details);
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Create error for invalid audit action
|
|
18
|
-
* Thrown when action is not 'log' or 'processed'
|
|
19
|
-
*/
|
|
20
|
-
static invalidAction(action) {
|
|
21
|
-
return new CapsaraAuditError('Invalid audit action', 'INVALID_AUDIT_ACTION', 400, { action });
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Create error for access denied
|
|
25
|
-
* Thrown when party is not in capsa keychain
|
|
26
|
-
*/
|
|
27
|
-
static accessDenied(details) {
|
|
28
|
-
return new CapsaraAuditError('You do not have access to this capsa', 'ACCESS_DENIED', 403, details);
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Create error for missing details field
|
|
32
|
-
* Thrown when 'log' action is used without details
|
|
33
|
-
*/
|
|
34
9
|
static missingDetails() {
|
|
35
|
-
return new CapsaraAuditError('Details field is required for log action', 'MISSING_DETAILS',
|
|
10
|
+
return new CapsaraAuditError('Details field is required for log action', 'MISSING_DETAILS', 0);
|
|
36
11
|
}
|
|
37
|
-
/**
|
|
38
|
-
* Create error for capsa not found
|
|
39
|
-
* Thrown when capsa doesn't exist
|
|
40
|
-
*/
|
|
41
|
-
static capsaNotFound(capsaId) {
|
|
42
|
-
return new CapsaraAuditError('Capsa not found or access denied', 'CAPSA_NOT_FOUND', 404, { capsaId });
|
|
43
|
-
}
|
|
44
|
-
/** Maps an API error response to the appropriate factory method. */
|
|
45
12
|
static fromApiError(error) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const errorMessage = error.response?.data?.error?.message;
|
|
49
|
-
const statusCode = error.response?.status ?? 500;
|
|
50
|
-
const details = error.response?.data?.error?.details;
|
|
51
|
-
const response = error.response;
|
|
52
|
-
// Map known error codes to factory methods
|
|
53
|
-
// Note: Factory methods don't include response, so add it after creation
|
|
54
|
-
let auditError;
|
|
55
|
-
switch (errorCode) {
|
|
56
|
-
case 'INSUFFICIENT_PERMISSIONS':
|
|
57
|
-
auditError = CapsaraAuditError.insufficientPermissions(details);
|
|
58
|
-
break;
|
|
59
|
-
case 'INVALID_AUDIT_ACTION':
|
|
60
|
-
auditError = CapsaraAuditError.invalidAction(details?.action);
|
|
61
|
-
break;
|
|
62
|
-
case 'ACCESS_DENIED':
|
|
63
|
-
auditError = CapsaraAuditError.accessDenied(details);
|
|
64
|
-
break;
|
|
65
|
-
case 'MISSING_DETAILS':
|
|
66
|
-
auditError = CapsaraAuditError.missingDetails();
|
|
67
|
-
break;
|
|
68
|
-
case 'ENVELOPE_NOT_FOUND':
|
|
69
|
-
case 'CAPSA_NOT_FOUND':
|
|
70
|
-
auditError = CapsaraAuditError.capsaNotFound((details?.capsaId ?? details?.envelopeId) ?? '');
|
|
71
|
-
break;
|
|
72
|
-
default:
|
|
73
|
-
// Generic audit error for unknown codes
|
|
74
|
-
return new CapsaraAuditError(errorMessage ?? 'An audit error occurred', errorCode ?? 'UNKNOWN_AUDIT_ERROR', statusCode, details, response);
|
|
75
|
-
}
|
|
76
|
-
// Add response to error created by factory method
|
|
77
|
-
if (response) {
|
|
78
|
-
Object.defineProperty(auditError, 'response', {
|
|
79
|
-
value: {
|
|
80
|
-
status: response.status,
|
|
81
|
-
statusText: response.statusText,
|
|
82
|
-
headers: response.headers,
|
|
83
|
-
data: response.data,
|
|
84
|
-
},
|
|
85
|
-
writable: false,
|
|
86
|
-
enumerable: true,
|
|
87
|
-
configurable: true,
|
|
88
|
-
});
|
|
13
|
+
if (error instanceof CapsaraAuditError || error instanceof CapsaraAuthError) {
|
|
14
|
+
return error;
|
|
89
15
|
}
|
|
90
|
-
|
|
16
|
+
const parsed = parseApiError(error, 'AUDIT_ERROR');
|
|
17
|
+
return new CapsaraAuditError(parsed.message, parsed.code, parsed.statusCode, parsed.details, parsed.response, parsed);
|
|
91
18
|
}
|
|
92
19
|
}
|
|
93
20
|
//# sourceMappingURL=audit-error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit-error.js","sourceRoot":"","sources":["../../src/errors/audit-error.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"audit-error.js","sourceRoot":"","sources":["../../src/errors/audit-error.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAE1C,OAAO,EACL,YAAY,EACZ,aAAa,GAId,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,OAAO,iBAAkB,SAAQ,YAAY;IAGjD,YACE,OAAe,EACf,IAAY,EACZ,UAAkB,EAClB,OAAiB,EACjB,QAA2B,EAC3B,MAA2B;QAE3B,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;IAED,MAAM,CAAC,cAAc;QACnB,OAAO,IAAI,iBAAiB,CAC1B,0CAA0C,EAC1C,iBAAiB,EACjB,CAAC,CACF,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,KAAc;QAChC,IAAI,KAAK,YAAY,iBAAiB,IAAI,KAAK,YAAY,gBAAgB,EAAE,CAAC;YAC5E,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,MAAM,GAAG,aAAa,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;QACnD,OAAO,IAAI,iBAAiB,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACxH,CAAC;CACF"}
|
|
@@ -1,38 +1,7 @@
|
|
|
1
|
-
/** Errors from authentication operations (login,
|
|
2
|
-
import { CapsaraError, type ApiErrorResponse, type
|
|
1
|
+
/** Errors from authentication operations (login, refresh). */
|
|
2
|
+
import { CapsaraError, type ApiErrorResponse, type CapsaraErrorExtras } from './capsara-error.js';
|
|
3
3
|
export declare class CapsaraAuthError extends CapsaraError {
|
|
4
|
-
constructor(message: string, code: string, statusCode: number, details?:
|
|
5
|
-
|
|
6
|
-
* Refresh token is required but not provided
|
|
7
|
-
* HTTP 401 - REFRESH_TOKEN_REQUIRED
|
|
8
|
-
*/
|
|
9
|
-
static refreshTokenRequired(): CapsaraAuthError;
|
|
10
|
-
/**
|
|
11
|
-
* Invalid credentials (email/password don't match)
|
|
12
|
-
* HTTP 401 - INVALID_CREDENTIALS
|
|
13
|
-
*/
|
|
14
|
-
static invalidCredentials(): CapsaraAuthError;
|
|
15
|
-
/**
|
|
16
|
-
* Refresh token is invalid or expired
|
|
17
|
-
* HTTP 401 - INVALID_REFRESH_TOKEN
|
|
18
|
-
*/
|
|
19
|
-
static invalidRefreshToken(): CapsaraAuthError;
|
|
20
|
-
/**
|
|
21
|
-
* Access token is invalid or expired
|
|
22
|
-
* HTTP 401 - UNAUTHORIZED
|
|
23
|
-
*/
|
|
24
|
-
static unauthorized(message?: string): CapsaraAuthError;
|
|
25
|
-
/**
|
|
26
|
-
* Feature not implemented yet
|
|
27
|
-
* HTTP 405 - NOT_IMPLEMENTED
|
|
28
|
-
*/
|
|
29
|
-
static notImplemented(feature: string): CapsaraAuthError;
|
|
30
|
-
/**
|
|
31
|
-
* Invalid request body
|
|
32
|
-
* HTTP 400 - VALIDATION_ERROR
|
|
33
|
-
*/
|
|
34
|
-
static validationError(message: string, details?: Record<string, unknown>): CapsaraAuthError;
|
|
35
|
-
/** Maps an API error response to the appropriate factory method. */
|
|
36
|
-
static fromApiError(error: AxiosLikeError): CapsaraAuthError;
|
|
4
|
+
constructor(message: string, code: string, statusCode: number, details?: unknown, response?: ApiErrorResponse, extras?: CapsaraErrorExtras);
|
|
5
|
+
static fromApiError(error: unknown): CapsaraAuthError;
|
|
37
6
|
}
|
|
38
7
|
//# sourceMappingURL=auth-error.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-error.d.ts","sourceRoot":"","sources":["../../src/errors/auth-error.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"auth-error.d.ts","sourceRoot":"","sources":["../../src/errors/auth-error.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAE9D,OAAO,EACL,YAAY,EAEZ,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACxB,MAAM,oBAAoB,CAAC;AAE5B,qBAAa,gBAAiB,SAAQ,YAAY;gBAE9C,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,OAAO,EACjB,QAAQ,CAAC,EAAE,gBAAgB,EAC3B,MAAM,CAAC,EAAE,kBAAkB;IAM7B,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,gBAAgB;CAOtD"}
|
|
@@ -1,87 +1,16 @@
|
|
|
1
|
-
/** Errors from authentication operations (login,
|
|
2
|
-
import { CapsaraError } from './capsara-error.js';
|
|
1
|
+
/** Errors from authentication operations (login, refresh). */
|
|
2
|
+
import { CapsaraError, parseApiError, } from './capsara-error.js';
|
|
3
3
|
export class CapsaraAuthError extends CapsaraError {
|
|
4
|
-
constructor(message, code, statusCode, details, response) {
|
|
5
|
-
super(message, code, statusCode, details, response);
|
|
4
|
+
constructor(message, code, statusCode, details, response, extras) {
|
|
5
|
+
super(message, code, statusCode, details, response, extras);
|
|
6
6
|
this.name = 'CapsaraAuthError';
|
|
7
7
|
}
|
|
8
|
-
/**
|
|
9
|
-
* Refresh token is required but not provided
|
|
10
|
-
* HTTP 401 - REFRESH_TOKEN_REQUIRED
|
|
11
|
-
*/
|
|
12
|
-
static refreshTokenRequired() {
|
|
13
|
-
return new CapsaraAuthError('Refresh token is required', 'REFRESH_TOKEN_REQUIRED', 401);
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Invalid credentials (email/password don't match)
|
|
17
|
-
* HTTP 401 - INVALID_CREDENTIALS
|
|
18
|
-
*/
|
|
19
|
-
static invalidCredentials() {
|
|
20
|
-
return new CapsaraAuthError('Invalid email or password', 'INVALID_CREDENTIALS', 401);
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Refresh token is invalid or expired
|
|
24
|
-
* HTTP 401 - INVALID_REFRESH_TOKEN
|
|
25
|
-
*/
|
|
26
|
-
static invalidRefreshToken() {
|
|
27
|
-
return new CapsaraAuthError('Refresh token is invalid or expired', 'INVALID_REFRESH_TOKEN', 401);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Access token is invalid or expired
|
|
31
|
-
* HTTP 401 - UNAUTHORIZED
|
|
32
|
-
*/
|
|
33
|
-
static unauthorized(message = 'Unauthorized - invalid or expired access token') {
|
|
34
|
-
return new CapsaraAuthError(message, 'UNAUTHORIZED', 401);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Feature not implemented yet
|
|
38
|
-
* HTTP 405 - NOT_IMPLEMENTED
|
|
39
|
-
*/
|
|
40
|
-
static notImplemented(feature) {
|
|
41
|
-
return new CapsaraAuthError(`${feature} endpoint not yet implemented`, 'NOT_IMPLEMENTED', 405, { feature });
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Invalid request body
|
|
45
|
-
* HTTP 400 - VALIDATION_ERROR
|
|
46
|
-
*/
|
|
47
|
-
static validationError(message, details) {
|
|
48
|
-
return new CapsaraAuthError(message, 'VALIDATION_ERROR', 400, details);
|
|
49
|
-
}
|
|
50
|
-
/** Maps an API error response to the appropriate factory method. */
|
|
51
8
|
static fromApiError(error) {
|
|
52
|
-
// Handle axios errors
|
|
53
|
-
if (error.response) {
|
|
54
|
-
const status = error.response.status;
|
|
55
|
-
const data = error.response.data;
|
|
56
|
-
const errorCode = data?.error?.code;
|
|
57
|
-
const errorMessage = data?.error?.message ?? data?.message ?? error.message ?? 'Unknown error';
|
|
58
|
-
const errorDetails = data?.error?.details ?? data?.details;
|
|
59
|
-
// Map known error codes to factory methods
|
|
60
|
-
switch (errorCode) {
|
|
61
|
-
case 'REFRESH_TOKEN_REQUIRED':
|
|
62
|
-
return CapsaraAuthError.refreshTokenRequired();
|
|
63
|
-
case 'INVALID_CREDENTIALS':
|
|
64
|
-
return CapsaraAuthError.invalidCredentials();
|
|
65
|
-
case 'INVALID_REFRESH_TOKEN':
|
|
66
|
-
return CapsaraAuthError.invalidRefreshToken();
|
|
67
|
-
case 'UNAUTHORIZED':
|
|
68
|
-
return CapsaraAuthError.unauthorized(errorMessage);
|
|
69
|
-
case 'NOT_IMPLEMENTED':
|
|
70
|
-
return CapsaraAuthError.notImplemented(errorDetails?.feature ?? 'Feature');
|
|
71
|
-
case 'VALIDATION_ERROR':
|
|
72
|
-
return CapsaraAuthError.validationError(errorMessage, errorDetails);
|
|
73
|
-
default:
|
|
74
|
-
// Generic auth error with status code
|
|
75
|
-
return new CapsaraAuthError(errorMessage, errorCode ?? 'AUTH_ERROR', status, errorDetails);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
// Handle non-axios errors
|
|
79
9
|
if (error instanceof CapsaraAuthError) {
|
|
80
10
|
return error;
|
|
81
11
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
return new CapsaraAuthError(errorMessage, 'AUTH_ERROR', 500, { originalError: errorMessage });
|
|
12
|
+
const parsed = parseApiError(error, 'AUTH_ERROR');
|
|
13
|
+
return new CapsaraAuthError(parsed.message, parsed.code, parsed.statusCode, parsed.details, parsed.response, parsed);
|
|
85
14
|
}
|
|
86
15
|
}
|
|
87
16
|
//# sourceMappingURL=auth-error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-error.js","sourceRoot":"","sources":["../../src/errors/auth-error.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"auth-error.js","sourceRoot":"","sources":["../../src/errors/auth-error.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAE9D,OAAO,EACL,YAAY,EACZ,aAAa,GAGd,MAAM,oBAAoB,CAAC;AAE5B,MAAM,OAAO,gBAAiB,SAAQ,YAAY;IAChD,YACE,OAAe,EACf,IAAY,EACZ,UAAkB,EAClB,OAAiB,EACjB,QAA2B,EAC3B,MAA2B;QAE3B,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,KAAc;QAChC,IAAI,KAAK,YAAY,gBAAgB,EAAE,CAAC;YACtC,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,MAAM,GAAG,aAAa,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QAClD,OAAO,IAAI,gBAAgB,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACvH,CAAC;CACF"}
|