@sudoplatform/sudo-common 7.1.3 → 8.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.
- package/bin/outdated-with-suppression.sh +203 -0
- package/bin/suppress-audit.sh +15 -0
- package/bin/suppress-outdated.sh +60 -0
- package/bin/yarn-audit-with-suppression.sh +19 -0
- package/cjs/configurationManager/defaultConfigurationManager.d.ts +123 -0
- package/cjs/configurationManager/defaultConfigurationManager.js +122 -0
- package/cjs/configurationManager/defaultConfigurationManager.js.map +1 -0
- package/cjs/errors/error.d.ts +263 -0
- package/cjs/errors/error.js +442 -0
- package/cjs/errors/error.js.map +1 -0
- package/cjs/index.d.ts +9 -0
- package/cjs/index.js +13 -0
- package/cjs/index.js.map +1 -0
- package/cjs/logging/bunyanLogger.d.ts +8 -0
- package/cjs/logging/bunyanLogger.js +36 -0
- package/cjs/logging/bunyanLogger.js.map +1 -0
- package/cjs/logging/logger.d.ts +87 -0
- package/cjs/logging/logger.js +77 -0
- package/cjs/logging/logger.js.map +1 -0
- package/cjs/sudoKeyArchive/index.d.ts +4 -0
- package/cjs/sudoKeyArchive/index.js +8 -0
- package/cjs/sudoKeyArchive/index.js.map +1 -0
- package/cjs/sudoKeyArchive/keyArchive.d.ts +137 -0
- package/cjs/sudoKeyArchive/keyArchive.js +84 -0
- package/cjs/sudoKeyArchive/keyArchive.js.map +1 -0
- package/cjs/sudoKeyArchive/keyInfo.d.ts +41 -0
- package/cjs/sudoKeyArchive/keyInfo.js +17 -0
- package/cjs/sudoKeyArchive/keyInfo.js.map +1 -0
- package/cjs/sudoKeyArchive/keyType.d.ts +13 -0
- package/cjs/sudoKeyArchive/keyType.js +39 -0
- package/cjs/sudoKeyArchive/keyType.js.map +1 -0
- package/cjs/sudoKeyArchive/sudoKeyArchive.d.ts +190 -0
- package/cjs/sudoKeyArchive/sudoKeyArchive.js +373 -0
- package/cjs/sudoKeyArchive/sudoKeyArchive.js.map +1 -0
- package/cjs/sudoKeyManager/index.d.ts +4 -0
- package/cjs/sudoKeyManager/index.js +8 -0
- package/cjs/sudoKeyManager/index.js.map +1 -0
- package/cjs/sudoKeyManager/keyData.d.ts +56 -0
- package/cjs/sudoKeyManager/keyData.js +46 -0
- package/cjs/sudoKeyManager/keyData.js.map +1 -0
- package/cjs/sudoKeyManager/publicKey.d.ts +8 -0
- package/cjs/sudoKeyManager/publicKey.js +9 -0
- package/cjs/sudoKeyManager/publicKey.js.map +1 -0
- package/cjs/sudoKeyManager/sudoCryptoProvider.d.ts +324 -0
- package/cjs/sudoKeyManager/sudoCryptoProvider.js +12 -0
- package/cjs/sudoKeyManager/sudoCryptoProvider.js.map +1 -0
- package/cjs/sudoKeyManager/sudoKeyManager.d.ts +344 -0
- package/cjs/sudoKeyManager/sudoKeyManager.js +140 -0
- package/cjs/sudoKeyManager/sudoKeyManager.js.map +1 -0
- package/cjs/types/types.d.ts +115 -0
- package/cjs/types/types.js +45 -0
- package/cjs/types/types.js.map +1 -0
- package/cjs/utils/base64.d.ts +44 -0
- package/cjs/utils/base64.js +71 -0
- package/cjs/utils/base64.js.map +1 -0
- package/cjs/utils/buffer.d.ts +13 -0
- package/cjs/utils/buffer.js +37 -0
- package/cjs/utils/buffer.js.map +1 -0
- package/cjs/utils/stream.d.ts +6 -0
- package/cjs/utils/stream.js +70 -0
- package/cjs/utils/stream.js.map +1 -0
- package/lib/configurationManager/defaultConfigurationManager.js +106 -156
- package/lib/configurationManager/defaultConfigurationManager.js.map +1 -0
- package/lib/errors/error.js +226 -438
- package/lib/errors/error.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +10 -109
- package/lib/index.js.map +1 -0
- package/lib/logging/bunyanLogger.js +29 -41
- package/lib/logging/bunyanLogger.js.map +1 -0
- package/lib/logging/logger.js +66 -92
- package/lib/logging/logger.js.map +1 -0
- package/lib/sudoKeyArchive/index.js +5 -57
- package/lib/sudoKeyArchive/index.js.map +1 -0
- package/lib/sudoKeyArchive/keyArchive.d.ts +8 -8
- package/lib/sudoKeyArchive/keyArchive.js +69 -96
- package/lib/sudoKeyArchive/keyArchive.js.map +1 -0
- package/lib/sudoKeyArchive/keyInfo.js +11 -49
- package/lib/sudoKeyArchive/keyInfo.js.map +1 -0
- package/lib/sudoKeyArchive/keyType.js +27 -37
- package/lib/sudoKeyArchive/keyType.js.map +1 -0
- package/lib/sudoKeyArchive/sudoKeyArchive.js +351 -444
- package/lib/sudoKeyArchive/sudoKeyArchive.js.map +1 -0
- package/lib/sudoKeyManager/index.js +5 -57
- package/lib/sudoKeyManager/index.js.map +1 -0
- package/lib/sudoKeyManager/keyData.js +38 -33
- package/lib/sudoKeyManager/keyData.js.map +1 -0
- package/lib/sudoKeyManager/publicKey.js +5 -12
- package/lib/sudoKeyManager/publicKey.js.map +1 -0
- package/lib/sudoKeyManager/sudoCryptoProvider.js +8 -26
- package/lib/sudoKeyManager/sudoCryptoProvider.js.map +1 -0
- package/lib/sudoKeyManager/sudoKeyManager.js +135 -173
- package/lib/sudoKeyManager/sudoKeyManager.js.map +1 -0
- package/lib/types/types.js +27 -33
- package/lib/types/types.js.map +1 -0
- package/lib/utils/base64.js +63 -93
- package/lib/utils/base64.js.map +1 -0
- package/lib/utils/buffer.js +28 -46
- package/lib/utils/buffer.js.map +1 -0
- package/lib/utils/stream.d.ts +6 -0
- package/lib/utils/stream.js +63 -0
- package/lib/utils/stream.js.map +1 -0
- package/package.json +35 -27
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { GraphQLError } from 'graphql';
|
|
2
|
+
export declare type AppSyncError = GraphQLError & {
|
|
3
|
+
errorType?: string | null;
|
|
4
|
+
};
|
|
5
|
+
export declare type AppSyncNetworkError = Error & {
|
|
6
|
+
networkError: Error & {
|
|
7
|
+
statusCode?: number;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export declare function isAppSyncNetworkError(u: Error): u is AppSyncNetworkError;
|
|
11
|
+
/**
|
|
12
|
+
* Indicates the GraphQL API returned an error that's not recognized by
|
|
13
|
+
* the client.
|
|
14
|
+
*/
|
|
15
|
+
export declare class UnknownGraphQLError extends Error {
|
|
16
|
+
constructor(cause: unknown);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The configuration set was not found by the given key
|
|
20
|
+
*/
|
|
21
|
+
export declare class ConfigurationSetNotFoundError extends Error {
|
|
22
|
+
constructor(key?: string);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The configuration has not been set on the ConfigurationManager
|
|
26
|
+
* before trying operations that need it
|
|
27
|
+
*/
|
|
28
|
+
export declare class ConfigurationNotSetError extends Error {
|
|
29
|
+
constructor();
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A decode error message
|
|
33
|
+
*/
|
|
34
|
+
export declare class DecodeError extends Error {
|
|
35
|
+
constructor(message?: string);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* An error occurred during the authentication process. This may be due to invalid credentials
|
|
39
|
+
* being supplied, or authentication tokens not able to be retrieved from storage.
|
|
40
|
+
*/
|
|
41
|
+
export declare class AuthenticationError extends Error {
|
|
42
|
+
constructor(message: string);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* An error occurred during the sign out process.
|
|
46
|
+
*/
|
|
47
|
+
export declare class SignOutError extends Error {
|
|
48
|
+
constructor(message: string);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* An error occurred during the registration process.
|
|
52
|
+
* This may be due to the client already being registered.
|
|
53
|
+
*/
|
|
54
|
+
export declare class RegisterError extends Error {
|
|
55
|
+
constructor(message: string);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* An error occurred indicating that the user is not registered.
|
|
59
|
+
*/
|
|
60
|
+
export declare class NotRegisteredError extends Error {
|
|
61
|
+
constructor(message?: string);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The user is not authorized to perform the requested operation. This maybe
|
|
65
|
+
* due to specifying the wrong key deriving key or password.
|
|
66
|
+
*/
|
|
67
|
+
export declare class NotAuthorizedError extends Error {
|
|
68
|
+
constructor(message?: string);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Indicates the operation requires the user to be signed in but the user is
|
|
72
|
+
* currently not signed in.
|
|
73
|
+
*/
|
|
74
|
+
export declare class NotSignedInError extends Error {
|
|
75
|
+
constructor();
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Indicates that the user was registered but is not confirmed due to not
|
|
79
|
+
* passing all the required validation.
|
|
80
|
+
*/
|
|
81
|
+
export declare class UserNotConfirmedError extends Error {
|
|
82
|
+
constructor();
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* The version of the vault that's being updated does not match the version
|
|
86
|
+
* stored in the backed. It is likely that another client updated the vault
|
|
87
|
+
* first so the caller should reconcile the changes before attempting to
|
|
88
|
+
* update the vault.
|
|
89
|
+
*/
|
|
90
|
+
export declare class VersionMismatchError extends Error {
|
|
91
|
+
constructor();
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Indicates that the ownership proof was invalid.
|
|
95
|
+
*/
|
|
96
|
+
export declare class InvalidOwnershipProofError extends Error {
|
|
97
|
+
constructor();
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Indicates that the user does not have sufficient entitlements to perform
|
|
101
|
+
* the requested operation.
|
|
102
|
+
*/
|
|
103
|
+
export declare class InsufficientEntitlementsError extends Error {
|
|
104
|
+
constructor();
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Indicates the requested operation failed because the user account is locked.
|
|
108
|
+
*/
|
|
109
|
+
export declare class AccountLockedError extends Error {
|
|
110
|
+
constructor();
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Indicates that an internal server error caused the operation to fail. The error
|
|
114
|
+
* is possibly transient and retrying at a later time may cause the operation to
|
|
115
|
+
* complete successfully.
|
|
116
|
+
*/
|
|
117
|
+
export declare class ServiceError extends Error {
|
|
118
|
+
constructor(message: string);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Error when expected arguments are missing or invalid
|
|
122
|
+
*/
|
|
123
|
+
export declare class IllegalArgumentError extends Error {
|
|
124
|
+
constructor(message?: string);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Error when the state of the program is expecting a value to
|
|
128
|
+
* be set or available and it is not.
|
|
129
|
+
*/
|
|
130
|
+
export declare class IllegalStateError extends Error {
|
|
131
|
+
constructor(message: string);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Operation failed due to it exceeding some limits imposed for the API. For example,
|
|
135
|
+
* this error can occur if the resource size exceeds the database record size limit.
|
|
136
|
+
*/
|
|
137
|
+
export declare class LimitExceededError extends Error {
|
|
138
|
+
constructor();
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* API request failed due to network error or unexpected server error.
|
|
142
|
+
*/
|
|
143
|
+
export declare class RequestFailedError extends Error {
|
|
144
|
+
/**
|
|
145
|
+
* Underlying error that cause the request to fail.
|
|
146
|
+
*/
|
|
147
|
+
cause?: Error;
|
|
148
|
+
/**
|
|
149
|
+
* HTTP status code if a valid response was received with unexpected
|
|
150
|
+
* status code.
|
|
151
|
+
*/
|
|
152
|
+
statusCode?: number;
|
|
153
|
+
constructor(cause?: Error, statusCode?: number);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* An unexpected error was encountered. This may result from programmatic error
|
|
157
|
+
* and is unlikley to be user recoverable.
|
|
158
|
+
*/
|
|
159
|
+
export declare class FatalError extends Error {
|
|
160
|
+
constructor(message: string);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* No entitlements assigned to user.
|
|
164
|
+
*/
|
|
165
|
+
export declare class NoEntitlementsError extends Error {
|
|
166
|
+
constructor();
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Token presented was not valid for the purpose.
|
|
170
|
+
*/
|
|
171
|
+
export declare class InvalidTokenError extends Error {
|
|
172
|
+
constructor();
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Key not found from store when using cryptoProvider
|
|
176
|
+
*/
|
|
177
|
+
export declare class KeyNotFoundError extends Error {
|
|
178
|
+
constructor(message?: string);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Underlying secure key store does not support key export
|
|
182
|
+
*/
|
|
183
|
+
export declare class KeyStoreNotExportableError extends Error {
|
|
184
|
+
constructor(message?: string);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* No key archive provided prior to unarchiving
|
|
188
|
+
*/
|
|
189
|
+
export declare class KeyArchiveMissingError extends Error {
|
|
190
|
+
constructor(message?: string);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* No password provided to unarchive secure archive
|
|
194
|
+
*/
|
|
195
|
+
export declare class KeyArchivePasswordRequiredError extends Error {
|
|
196
|
+
constructor(message?: string);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* No password required to unarchive insecure archive
|
|
200
|
+
*/
|
|
201
|
+
export declare class KeyArchiveNoPasswordRequiredError extends Error {
|
|
202
|
+
constructor(message?: string);
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Key archive data could not be decoded as expected
|
|
206
|
+
*/
|
|
207
|
+
export declare class KeyArchiveDecodingError extends Error {
|
|
208
|
+
constructor(message?: string);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Key archive was unable to be decrypted using the provided password
|
|
212
|
+
*/
|
|
213
|
+
export declare class KeyArchiveIncorrectPasswordError extends Error {
|
|
214
|
+
constructor(message?: string);
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Key archive type is not supported
|
|
218
|
+
*/
|
|
219
|
+
export declare class KeyArchiveTypeError extends Error {
|
|
220
|
+
constructor(keyArchiveType: string);
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Key archive version is not supported
|
|
224
|
+
*/
|
|
225
|
+
export declare class KeyArchiveVersionError extends Error {
|
|
226
|
+
constructor(version: number);
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Key archive key type is not recognized
|
|
230
|
+
*/
|
|
231
|
+
export declare class KeyArchiveUnknownKeyTypeError extends Error {
|
|
232
|
+
constructor(message?: string);
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Operation not implemented
|
|
236
|
+
*/
|
|
237
|
+
export declare class OperationNotImplementedError extends Error {
|
|
238
|
+
constructor(message?: string);
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Encryption algorithm is not recognized
|
|
242
|
+
*/
|
|
243
|
+
export declare class UnrecognizedAlgorithmError extends Error {
|
|
244
|
+
constructor(message?: string);
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Helper method for mapping an App Sync error to common errors.
|
|
248
|
+
*
|
|
249
|
+
* For consumption by other Sudo Platform SDKs
|
|
250
|
+
*
|
|
251
|
+
* @param error The App Sync error to map
|
|
252
|
+
* @returns The mapped error
|
|
253
|
+
*/
|
|
254
|
+
export declare function mapGraphQLToClientError(error: Pick<AppSyncError, 'errorType' | 'message'>): Error;
|
|
255
|
+
/**
|
|
256
|
+
* Call this in error handling when testing with isAppSyncNetworkError on
|
|
257
|
+
* a caught error from an AppSync operation returns true.
|
|
258
|
+
*
|
|
259
|
+
* @param error AppSyncNetworkError to map
|
|
260
|
+
*
|
|
261
|
+
* @returns Mapped error
|
|
262
|
+
*/
|
|
263
|
+
export declare function mapNetworkErrorToClientError(error: AppSyncNetworkError): Error;
|
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapNetworkErrorToClientError = exports.mapGraphQLToClientError = exports.UnrecognizedAlgorithmError = exports.OperationNotImplementedError = exports.KeyArchiveUnknownKeyTypeError = exports.KeyArchiveVersionError = exports.KeyArchiveTypeError = exports.KeyArchiveIncorrectPasswordError = exports.KeyArchiveDecodingError = exports.KeyArchiveNoPasswordRequiredError = exports.KeyArchivePasswordRequiredError = exports.KeyArchiveMissingError = exports.KeyStoreNotExportableError = exports.KeyNotFoundError = exports.InvalidTokenError = exports.NoEntitlementsError = exports.FatalError = exports.RequestFailedError = exports.LimitExceededError = exports.IllegalStateError = exports.IllegalArgumentError = exports.ServiceError = exports.AccountLockedError = exports.InsufficientEntitlementsError = exports.InvalidOwnershipProofError = exports.VersionMismatchError = exports.UserNotConfirmedError = exports.NotSignedInError = exports.NotAuthorizedError = exports.NotRegisteredError = exports.RegisterError = exports.SignOutError = exports.AuthenticationError = exports.DecodeError = exports.ConfigurationNotSetError = exports.ConfigurationSetNotFoundError = exports.UnknownGraphQLError = exports.isAppSyncNetworkError = void 0;
|
|
4
|
+
function isAppSyncNetworkError(u) {
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
|
+
return !!u.networkError;
|
|
7
|
+
}
|
|
8
|
+
exports.isAppSyncNetworkError = isAppSyncNetworkError;
|
|
9
|
+
/**
|
|
10
|
+
* Indicates the GraphQL API returned an error that's not recognized by
|
|
11
|
+
* the client.
|
|
12
|
+
*/
|
|
13
|
+
class UnknownGraphQLError extends Error {
|
|
14
|
+
constructor(cause) {
|
|
15
|
+
const maybeAppSyncError = cause;
|
|
16
|
+
let message;
|
|
17
|
+
if (maybeAppSyncError?.errorType) {
|
|
18
|
+
message = `type: ${maybeAppSyncError.errorType}, message: ${maybeAppSyncError.message}`;
|
|
19
|
+
}
|
|
20
|
+
else if (maybeAppSyncError?.message) {
|
|
21
|
+
message = maybeAppSyncError?.message;
|
|
22
|
+
}
|
|
23
|
+
else if (maybeAppSyncError?.name) {
|
|
24
|
+
message = maybeAppSyncError.name;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
message = 'unknown cause';
|
|
28
|
+
}
|
|
29
|
+
super(message);
|
|
30
|
+
this.name = 'UnknownGraphQLError';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.UnknownGraphQLError = UnknownGraphQLError;
|
|
34
|
+
/**
|
|
35
|
+
* The configuration set was not found by the given key
|
|
36
|
+
*/
|
|
37
|
+
class ConfigurationSetNotFoundError extends Error {
|
|
38
|
+
constructor(key) {
|
|
39
|
+
super('Configuration set not found.');
|
|
40
|
+
if (key) {
|
|
41
|
+
this.message += ` Key: ${key}`;
|
|
42
|
+
}
|
|
43
|
+
this.name = 'ConfigurationSetNotFoundError';
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.ConfigurationSetNotFoundError = ConfigurationSetNotFoundError;
|
|
47
|
+
/**
|
|
48
|
+
* The configuration has not been set on the ConfigurationManager
|
|
49
|
+
* before trying operations that need it
|
|
50
|
+
*/
|
|
51
|
+
class ConfigurationNotSetError extends Error {
|
|
52
|
+
constructor() {
|
|
53
|
+
super('Configuration has not been set.');
|
|
54
|
+
this.name = 'ConfigurationNotSetError';
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.ConfigurationNotSetError = ConfigurationNotSetError;
|
|
58
|
+
/**
|
|
59
|
+
* A decode error message
|
|
60
|
+
*/
|
|
61
|
+
class DecodeError extends Error {
|
|
62
|
+
constructor(message) {
|
|
63
|
+
super(message);
|
|
64
|
+
this.name = 'DecodeError';
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.DecodeError = DecodeError;
|
|
68
|
+
/**
|
|
69
|
+
* An error occurred during the authentication process. This may be due to invalid credentials
|
|
70
|
+
* being supplied, or authentication tokens not able to be retrieved from storage.
|
|
71
|
+
*/
|
|
72
|
+
class AuthenticationError extends Error {
|
|
73
|
+
constructor(message) {
|
|
74
|
+
super(message);
|
|
75
|
+
this.name = 'AuthenticationError';
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.AuthenticationError = AuthenticationError;
|
|
79
|
+
/**
|
|
80
|
+
* An error occurred during the sign out process.
|
|
81
|
+
*/
|
|
82
|
+
class SignOutError extends Error {
|
|
83
|
+
constructor(message) {
|
|
84
|
+
super(message);
|
|
85
|
+
this.name = 'SignOutError';
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.SignOutError = SignOutError;
|
|
89
|
+
/**
|
|
90
|
+
* An error occurred during the registration process.
|
|
91
|
+
* This may be due to the client already being registered.
|
|
92
|
+
*/
|
|
93
|
+
class RegisterError extends Error {
|
|
94
|
+
constructor(message) {
|
|
95
|
+
super(message);
|
|
96
|
+
this.name = 'RegisterError';
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.RegisterError = RegisterError;
|
|
100
|
+
/**
|
|
101
|
+
* An error occurred indicating that the user is not registered.
|
|
102
|
+
*/
|
|
103
|
+
class NotRegisteredError extends Error {
|
|
104
|
+
constructor(message) {
|
|
105
|
+
super(message ?? 'User is not registered.');
|
|
106
|
+
this.name = 'NotRegisteredError';
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.NotRegisteredError = NotRegisteredError;
|
|
110
|
+
/**
|
|
111
|
+
* The user is not authorized to perform the requested operation. This maybe
|
|
112
|
+
* due to specifying the wrong key deriving key or password.
|
|
113
|
+
*/
|
|
114
|
+
class NotAuthorizedError extends Error {
|
|
115
|
+
constructor(message) {
|
|
116
|
+
super(message ?? 'User is not authorized perform the requested operation.');
|
|
117
|
+
this.name = 'NotAuthorizedError';
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.NotAuthorizedError = NotAuthorizedError;
|
|
121
|
+
/**
|
|
122
|
+
* Indicates the operation requires the user to be signed in but the user is
|
|
123
|
+
* currently not signed in.
|
|
124
|
+
*/
|
|
125
|
+
class NotSignedInError extends Error {
|
|
126
|
+
constructor() {
|
|
127
|
+
super('Not signed in.');
|
|
128
|
+
this.name = 'NotSignedInError';
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
exports.NotSignedInError = NotSignedInError;
|
|
132
|
+
/**
|
|
133
|
+
* Indicates that the user was registered but is not confirmed due to not
|
|
134
|
+
* passing all the required validation.
|
|
135
|
+
*/
|
|
136
|
+
class UserNotConfirmedError extends Error {
|
|
137
|
+
constructor() {
|
|
138
|
+
super('User not confirmed.');
|
|
139
|
+
this.name = 'UserNotConfirmedError';
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
exports.UserNotConfirmedError = UserNotConfirmedError;
|
|
143
|
+
/**
|
|
144
|
+
* The version of the vault that's being updated does not match the version
|
|
145
|
+
* stored in the backed. It is likely that another client updated the vault
|
|
146
|
+
* first so the caller should reconcile the changes before attempting to
|
|
147
|
+
* update the vault.
|
|
148
|
+
*/
|
|
149
|
+
class VersionMismatchError extends Error {
|
|
150
|
+
constructor() {
|
|
151
|
+
super('Expected object version does not match the actual object version.');
|
|
152
|
+
this.name = 'VersionMismatchError';
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
exports.VersionMismatchError = VersionMismatchError;
|
|
156
|
+
/**
|
|
157
|
+
* Indicates that the ownership proof was invalid.
|
|
158
|
+
*/
|
|
159
|
+
class InvalidOwnershipProofError extends Error {
|
|
160
|
+
constructor() {
|
|
161
|
+
super('Ownership proof was invalid.');
|
|
162
|
+
this.name = 'InvalidOwnershipProofError';
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
exports.InvalidOwnershipProofError = InvalidOwnershipProofError;
|
|
166
|
+
/**
|
|
167
|
+
* Indicates that the user does not have sufficient entitlements to perform
|
|
168
|
+
* the requested operation.
|
|
169
|
+
*/
|
|
170
|
+
class InsufficientEntitlementsError extends Error {
|
|
171
|
+
constructor() {
|
|
172
|
+
super('The user does not have sufficient entitlements to perform the requested operation.');
|
|
173
|
+
this.name = 'InsufficientEntitlementsError';
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
exports.InsufficientEntitlementsError = InsufficientEntitlementsError;
|
|
177
|
+
/**
|
|
178
|
+
* Indicates the requested operation failed because the user account is locked.
|
|
179
|
+
*/
|
|
180
|
+
class AccountLockedError extends Error {
|
|
181
|
+
constructor() {
|
|
182
|
+
super('The requested operation failed because the user account is locked.');
|
|
183
|
+
this.name = 'AccountLockedError';
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
exports.AccountLockedError = AccountLockedError;
|
|
187
|
+
/**
|
|
188
|
+
* Indicates that an internal server error caused the operation to fail. The error
|
|
189
|
+
* is possibly transient and retrying at a later time may cause the operation to
|
|
190
|
+
* complete successfully.
|
|
191
|
+
*/
|
|
192
|
+
class ServiceError extends Error {
|
|
193
|
+
constructor(message) {
|
|
194
|
+
super(message);
|
|
195
|
+
this.name = 'ServiceError';
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
exports.ServiceError = ServiceError;
|
|
199
|
+
/**
|
|
200
|
+
* Error when expected arguments are missing or invalid
|
|
201
|
+
*/
|
|
202
|
+
class IllegalArgumentError extends Error {
|
|
203
|
+
constructor(message) {
|
|
204
|
+
super(message ?? 'Invalid arguments were specified');
|
|
205
|
+
this.name = 'IllegalArgumentError';
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
exports.IllegalArgumentError = IllegalArgumentError;
|
|
209
|
+
/**
|
|
210
|
+
* Error when the state of the program is expecting a value to
|
|
211
|
+
* be set or available and it is not.
|
|
212
|
+
*/
|
|
213
|
+
class IllegalStateError extends Error {
|
|
214
|
+
constructor(message) {
|
|
215
|
+
super(message);
|
|
216
|
+
this.name = 'IllegalStateError';
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
exports.IllegalStateError = IllegalStateError;
|
|
220
|
+
/**
|
|
221
|
+
* Operation failed due to it exceeding some limits imposed for the API. For example,
|
|
222
|
+
* this error can occur if the resource size exceeds the database record size limit.
|
|
223
|
+
*/
|
|
224
|
+
class LimitExceededError extends Error {
|
|
225
|
+
constructor() {
|
|
226
|
+
super('API limit exceeded.');
|
|
227
|
+
this.name = 'LimitExceededError';
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
exports.LimitExceededError = LimitExceededError;
|
|
231
|
+
/**
|
|
232
|
+
* API request failed due to network error or unexpected server error.
|
|
233
|
+
*/
|
|
234
|
+
class RequestFailedError extends Error {
|
|
235
|
+
constructor(cause, statusCode) {
|
|
236
|
+
super(`API request failed. cause: ${cause?.message ?? '<none>'}, statusCode: ${statusCode ?? '<none>'}`);
|
|
237
|
+
this.name = 'RequestFailedError';
|
|
238
|
+
this.cause = cause;
|
|
239
|
+
this.statusCode = statusCode;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
exports.RequestFailedError = RequestFailedError;
|
|
243
|
+
/**
|
|
244
|
+
* An unexpected error was encountered. This may result from programmatic error
|
|
245
|
+
* and is unlikley to be user recoverable.
|
|
246
|
+
*/
|
|
247
|
+
class FatalError extends Error {
|
|
248
|
+
constructor(message) {
|
|
249
|
+
super(message);
|
|
250
|
+
this.name = 'FatalError';
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
exports.FatalError = FatalError;
|
|
254
|
+
/**
|
|
255
|
+
* No entitlements assigned to user.
|
|
256
|
+
*/
|
|
257
|
+
class NoEntitlementsError extends Error {
|
|
258
|
+
constructor() {
|
|
259
|
+
super('No entitlements assigned to user.');
|
|
260
|
+
this.name = 'NoEntitlementsError';
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
exports.NoEntitlementsError = NoEntitlementsError;
|
|
264
|
+
/**
|
|
265
|
+
* Token presented was not valid for the purpose.
|
|
266
|
+
*/
|
|
267
|
+
class InvalidTokenError extends Error {
|
|
268
|
+
constructor() {
|
|
269
|
+
super('Invalid token.');
|
|
270
|
+
this.name = 'InvalidTokenError';
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
exports.InvalidTokenError = InvalidTokenError;
|
|
274
|
+
/**
|
|
275
|
+
* Key not found from store when using cryptoProvider
|
|
276
|
+
*/
|
|
277
|
+
class KeyNotFoundError extends Error {
|
|
278
|
+
constructor(message) {
|
|
279
|
+
super(message ?? 'Key not found.');
|
|
280
|
+
this.name = 'KeyNotFoundError';
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
exports.KeyNotFoundError = KeyNotFoundError;
|
|
284
|
+
/**
|
|
285
|
+
* Underlying secure key store does not support key export
|
|
286
|
+
*/
|
|
287
|
+
class KeyStoreNotExportableError extends Error {
|
|
288
|
+
constructor(message) {
|
|
289
|
+
super(message ?? 'Key store not exportable.');
|
|
290
|
+
this.name = 'KeyStoreNotExportableError';
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
exports.KeyStoreNotExportableError = KeyStoreNotExportableError;
|
|
294
|
+
/**
|
|
295
|
+
* No key archive provided prior to unarchiving
|
|
296
|
+
*/
|
|
297
|
+
class KeyArchiveMissingError extends Error {
|
|
298
|
+
constructor(message) {
|
|
299
|
+
super(message ?? 'No key archive provided prior to unarchiving');
|
|
300
|
+
this.name = 'KeyArchiveMissingError';
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
exports.KeyArchiveMissingError = KeyArchiveMissingError;
|
|
304
|
+
/**
|
|
305
|
+
* No password provided to unarchive secure archive
|
|
306
|
+
*/
|
|
307
|
+
class KeyArchivePasswordRequiredError extends Error {
|
|
308
|
+
constructor(message) {
|
|
309
|
+
super(message ?? 'No password provided to unarchive secure archive');
|
|
310
|
+
this.name = 'KeyArchivePasswordRequiredError';
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
exports.KeyArchivePasswordRequiredError = KeyArchivePasswordRequiredError;
|
|
314
|
+
/**
|
|
315
|
+
* No password required to unarchive insecure archive
|
|
316
|
+
*/
|
|
317
|
+
class KeyArchiveNoPasswordRequiredError extends Error {
|
|
318
|
+
constructor(message) {
|
|
319
|
+
super(message ?? 'No password required to unarchive insecure archive');
|
|
320
|
+
this.name = 'KeyArchiveNoPasswordRequiredError';
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
exports.KeyArchiveNoPasswordRequiredError = KeyArchiveNoPasswordRequiredError;
|
|
324
|
+
/**
|
|
325
|
+
* Key archive data could not be decoded as expected
|
|
326
|
+
*/
|
|
327
|
+
class KeyArchiveDecodingError extends Error {
|
|
328
|
+
constructor(message) {
|
|
329
|
+
super(message ?? 'Key archive data could not be decoded as expected');
|
|
330
|
+
this.name = 'KeyArchiveDecodingError';
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
exports.KeyArchiveDecodingError = KeyArchiveDecodingError;
|
|
334
|
+
/**
|
|
335
|
+
* Key archive was unable to be decrypted using the provided password
|
|
336
|
+
*/
|
|
337
|
+
class KeyArchiveIncorrectPasswordError extends Error {
|
|
338
|
+
constructor(message) {
|
|
339
|
+
super(message ??
|
|
340
|
+
'Key archive was unable to be decrypted using the provided password');
|
|
341
|
+
this.name = 'KeyArchiveIncorrectPasswordError';
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
exports.KeyArchiveIncorrectPasswordError = KeyArchiveIncorrectPasswordError;
|
|
345
|
+
/**
|
|
346
|
+
* Key archive type is not supported
|
|
347
|
+
*/
|
|
348
|
+
class KeyArchiveTypeError extends Error {
|
|
349
|
+
constructor(keyArchiveType) {
|
|
350
|
+
super(`Key archive type ${keyArchiveType} is not supported`);
|
|
351
|
+
this.name = 'KeyArchiveTypeError';
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
exports.KeyArchiveTypeError = KeyArchiveTypeError;
|
|
355
|
+
/**
|
|
356
|
+
* Key archive version is not supported
|
|
357
|
+
*/
|
|
358
|
+
class KeyArchiveVersionError extends Error {
|
|
359
|
+
constructor(version) {
|
|
360
|
+
super(`Key archive version ${version} is not supported`);
|
|
361
|
+
this.name = 'KeyArchiveVersionError';
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
exports.KeyArchiveVersionError = KeyArchiveVersionError;
|
|
365
|
+
/**
|
|
366
|
+
* Key archive key type is not recognized
|
|
367
|
+
*/
|
|
368
|
+
class KeyArchiveUnknownKeyTypeError extends Error {
|
|
369
|
+
constructor(message) {
|
|
370
|
+
super(message ?? 'Key type is not recognized');
|
|
371
|
+
this.name = 'KeyArchiveUnknownKeyTypeError';
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
exports.KeyArchiveUnknownKeyTypeError = KeyArchiveUnknownKeyTypeError;
|
|
375
|
+
/**
|
|
376
|
+
* Operation not implemented
|
|
377
|
+
*/
|
|
378
|
+
class OperationNotImplementedError extends Error {
|
|
379
|
+
constructor(message) {
|
|
380
|
+
super(message ?? 'Operation is not implemented');
|
|
381
|
+
this.name = 'OperationNotImplementedError';
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
exports.OperationNotImplementedError = OperationNotImplementedError;
|
|
385
|
+
/**
|
|
386
|
+
* Encryption algorithm is not recognized
|
|
387
|
+
*/
|
|
388
|
+
class UnrecognizedAlgorithmError extends Error {
|
|
389
|
+
constructor(message) {
|
|
390
|
+
super(message ?? 'Unrecognized encryption algorithm name.');
|
|
391
|
+
this.name = 'UnrecognizedAlgorithmError';
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
exports.UnrecognizedAlgorithmError = UnrecognizedAlgorithmError;
|
|
395
|
+
/**
|
|
396
|
+
* Helper method for mapping an App Sync error to common errors.
|
|
397
|
+
*
|
|
398
|
+
* For consumption by other Sudo Platform SDKs
|
|
399
|
+
*
|
|
400
|
+
* @param error The App Sync error to map
|
|
401
|
+
* @returns The mapped error
|
|
402
|
+
*/
|
|
403
|
+
function mapGraphQLToClientError(error) {
|
|
404
|
+
switch (error.errorType) {
|
|
405
|
+
case 'sudoplatform.AccountLockedError':
|
|
406
|
+
return new AccountLockedError();
|
|
407
|
+
case 'sudoplatform.InsufficientEntitlementsError':
|
|
408
|
+
return new InsufficientEntitlementsError();
|
|
409
|
+
case 'sudoplatform.InvalidTokenError':
|
|
410
|
+
return new InvalidTokenError();
|
|
411
|
+
case 'sudoplatform.InvalidArgumentError':
|
|
412
|
+
return new IllegalArgumentError();
|
|
413
|
+
case 'sudoplatform.LimitExceededError':
|
|
414
|
+
return new LimitExceededError();
|
|
415
|
+
case 'sudoplatform.NoEntitlementsError':
|
|
416
|
+
return new NoEntitlementsError();
|
|
417
|
+
case 'sudoplatform.ServiceError':
|
|
418
|
+
return new ServiceError(error.message);
|
|
419
|
+
default:
|
|
420
|
+
return new UnknownGraphQLError(error);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
exports.mapGraphQLToClientError = mapGraphQLToClientError;
|
|
424
|
+
/**
|
|
425
|
+
* Call this in error handling when testing with isAppSyncNetworkError on
|
|
426
|
+
* a caught error from an AppSync operation returns true.
|
|
427
|
+
*
|
|
428
|
+
* @param error AppSyncNetworkError to map
|
|
429
|
+
*
|
|
430
|
+
* @returns Mapped error
|
|
431
|
+
*/
|
|
432
|
+
function mapNetworkErrorToClientError(error) {
|
|
433
|
+
const networkError = error.networkError;
|
|
434
|
+
switch (networkError.statusCode) {
|
|
435
|
+
case 401:
|
|
436
|
+
return new NotAuthorizedError();
|
|
437
|
+
default:
|
|
438
|
+
return new RequestFailedError(networkError, networkError.statusCode);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
exports.mapNetworkErrorToClientError = mapNetworkErrorToClientError;
|
|
442
|
+
//# sourceMappingURL=error.js.map
|