@sudoplatform/sudo-common 8.0.0 → 8.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.
Files changed (39) hide show
  1. package/package.json +17 -8
  2. package/{cjs → types}/configurationManager/defaultConfigurationManager.d.ts +0 -0
  3. package/{cjs → types}/errors/error.d.ts +0 -0
  4. package/{cjs → types}/index.d.ts +0 -0
  5. package/{cjs → types}/logging/bunyanLogger.d.ts +0 -0
  6. package/{cjs → types}/logging/logger.d.ts +0 -0
  7. package/{cjs → types}/sudoKeyArchive/index.d.ts +0 -0
  8. package/{cjs → types}/sudoKeyArchive/keyArchive.d.ts +0 -0
  9. package/{cjs → types}/sudoKeyArchive/keyInfo.d.ts +0 -0
  10. package/{cjs → types}/sudoKeyArchive/keyType.d.ts +0 -0
  11. package/{cjs → types}/sudoKeyArchive/sudoKeyArchive.d.ts +0 -0
  12. package/{cjs → types}/sudoKeyManager/index.d.ts +0 -0
  13. package/{cjs → types}/sudoKeyManager/keyData.d.ts +0 -0
  14. package/{cjs → types}/sudoKeyManager/publicKey.d.ts +0 -0
  15. package/{cjs → types}/sudoKeyManager/sudoCryptoProvider.d.ts +0 -0
  16. package/{cjs → types}/sudoKeyManager/sudoKeyManager.d.ts +0 -0
  17. package/{cjs → types}/types/types.d.ts +0 -0
  18. package/{cjs → types}/utils/base64.d.ts +0 -0
  19. package/{cjs → types}/utils/buffer.d.ts +0 -0
  20. package/{cjs → types}/utils/stream.d.ts +0 -0
  21. package/lib/configurationManager/defaultConfigurationManager.d.ts +0 -123
  22. package/lib/errors/error.d.ts +0 -263
  23. package/lib/index.d.ts +0 -9
  24. package/lib/logging/bunyanLogger.d.ts +0 -8
  25. package/lib/logging/logger.d.ts +0 -87
  26. package/lib/sudoKeyArchive/index.d.ts +0 -4
  27. package/lib/sudoKeyArchive/keyArchive.d.ts +0 -137
  28. package/lib/sudoKeyArchive/keyInfo.d.ts +0 -41
  29. package/lib/sudoKeyArchive/keyType.d.ts +0 -13
  30. package/lib/sudoKeyArchive/sudoKeyArchive.d.ts +0 -190
  31. package/lib/sudoKeyManager/index.d.ts +0 -4
  32. package/lib/sudoKeyManager/keyData.d.ts +0 -56
  33. package/lib/sudoKeyManager/publicKey.d.ts +0 -8
  34. package/lib/sudoKeyManager/sudoCryptoProvider.d.ts +0 -324
  35. package/lib/sudoKeyManager/sudoKeyManager.d.ts +0 -344
  36. package/lib/types/types.d.ts +0 -115
  37. package/lib/utils/base64.d.ts +0 -44
  38. package/lib/utils/buffer.d.ts +0 -13
  39. package/lib/utils/stream.d.ts +0 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sudoplatform/sudo-common",
3
- "version": "8.0.0",
3
+ "version": "8.0.1",
4
4
  "author": "Anonyome Labs, Inc.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -10,7 +10,7 @@
10
10
  "scripts": {
11
11
  "audit-with-suppressions": "bin/yarn-audit-with-suppression.sh",
12
12
  "outdated-with-suppressions": "bin/outdated-with-suppression.sh",
13
- "clean": "rimraf ./docs ./cjs ./lib",
13
+ "clean": "rimraf ./docs ./cjs ./lib ./types",
14
14
  "lint": "yarn lint:eslint && yarn lint:prettier",
15
15
  "lint:eslint": "eslint \"{bin,integration-tests,src,test}/**/*.{ts,tsx}\"",
16
16
  "lint:prettier": "prettier -l \"**/*.{js,json,ts,yml}\"",
@@ -19,14 +19,22 @@
19
19
  "test": "jest",
20
20
  "build": "yarn clean && yarn build:transpile && yarn build:verify && yarn build:doc",
21
21
  "build:verify": "yarn audit-with-suppressions && yarn lint && yarn test --coverage",
22
- "build:transpile": "concurrently \"yarn build:transpile:cjs\" \"yarn build:transpile:esm\"",
22
+ "build:transpile": "concurrently \"yarn build:transpile:declarations\" \"yarn build:transpile:cjs\" \"yarn build:transpile:esm\"",
23
23
  "build:transpile:cjs": "tsc --project tsconfig.commonjs.json",
24
24
  "build:transpile:esm": "tsc",
25
+ "build:transpile:declarations": "tsc --project tsconfig.declarations.json",
25
26
  "build:doc": "typedoc --treatWarningsAsErrors --excludePrivate --out docs src/index.ts"
26
27
  },
27
28
  "main": "./cjs/index.js",
28
- "types": "./cjs/index.d.ts",
29
- "module": "./lib/index.js",
29
+ "types": "./types/index.d.ts",
30
+ "exports": {
31
+ ".": {
32
+ "types": "./types/index.d.ts",
33
+ "import": "./lib/index.js",
34
+ "require": "./cjs/index.js",
35
+ "default": "./lib/index.js"
36
+ }
37
+ },
30
38
  "sideEffects": false,
31
39
  "bin": {
32
40
  "audit-with-suppressions": "bin/yarn-audit-with-suppression.sh",
@@ -37,7 +45,8 @@
37
45
  "files": [
38
46
  "bin",
39
47
  "cjs",
40
- "lib"
48
+ "lib",
49
+ "types"
41
50
  ],
42
51
  "resolutions": {
43
52
  "**/apollo-cache-inmemory": "^1.6.6",
@@ -47,7 +56,7 @@
47
56
  "minimist": "^1.2.6"
48
57
  },
49
58
  "dependencies": {
50
- "@aws-sdk/client-s3": "^3.145.0",
59
+ "@aws-sdk/client-s3": "^3.154.0",
51
60
  "apollo-client": "^2.6.10",
52
61
  "browser-bunyan": "^1.8.0",
53
62
  "fflate": "^0.7.3",
@@ -59,7 +68,7 @@
59
68
  },
60
69
  "devDependencies": {
61
70
  "@types/jest": "^27.5.2",
62
- "@types/node": "^16.11.49",
71
+ "@types/node": "^16.11.51",
63
72
  "@typescript-eslint/eslint-plugin": "^5.33.0",
64
73
  "@typescript-eslint/parser": "^5.33.0",
65
74
  "aws-sdk-mock": "^5.7.0",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,123 +0,0 @@
1
- import * as t from 'io-ts';
2
- /**
3
- * Service compatibility information.
4
- */
5
- export interface ServiceCompatibilityInfo {
6
- /**
7
- * The name of the service associated with the compatibility info. This matches one of the
8
- * service name present in sudoplatformconfig.json.
9
- */
10
- name: string;
11
- /**
12
- * The version of the service config present in sudoplatformconfig.json. It defaults
13
- * to 1 if not present.
14
- */
15
- configVersion: number;
16
- /**
17
- * The minimum supported service config version currently supported by the backend.
18
- */
19
- minSupportedVersion?: number;
20
- /**
21
- * Any service config version less than or equal to this version is considered deprecated
22
- * and the backend may remove the support for those versions after a grace period.
23
- */
24
- deprecatedVersion?: number;
25
- /**
26
- * After this time any deprecated service config versions will no longer be compatible
27
- * with the backend. It is recommended to warn the user prior to the deprecation grace.
28
- */
29
- deprecationGrace?: Date;
30
- }
31
- /**
32
- * Result returned by `validateConfig` API if an incompatible client config is found when compared
33
- * to the deployed backend services.
34
- */
35
- export interface ValidationResult {
36
- /**
37
- * The list of incompatible services. The client must be upgraded to the latest
38
- * version in order to use these services.
39
- */
40
- incompatible: ServiceCompatibilityInfo[];
41
- /**
42
- * The list of services that will be made incompatible with the current version of the
43
- * client. The users should be warned that after the specified grace period these services will be
44
- * made incompatible.
45
- */
46
- deprecated: ServiceCompatibilityInfo[];
47
- }
48
- /**
49
- * Interface that encapsulates the APIs common to all configuration manager implementations.
50
- * A configuration manager should be a singleton that holds reference to a parsed config
51
- * and returns the configuration set specific to a given namespace.
52
- */
53
- export interface ConfigurationManager {
54
- /**
55
- * Set config that will be parsed as JSON
56
- *
57
- * @param config A string representation of configuration
58
- *
59
- * @returns ConfigurationManager
60
- */
61
- setConfig(config: string): ConfigurationManager;
62
- /**
63
- * Get a subset of configuration by namespace
64
- *
65
- * @param namespace The key for the nested json object
66
- *
67
- * @returns Configuration set specific to a given namespace
68
- *
69
- * @throws {@link ConfigurationNotSetError}
70
- */
71
- getConfigSet(namespace?: string): string | undefined;
72
- /**
73
- * Decode a configuration set to a given type
74
- *
75
- * @param configSet Configuration set specific to a given namespace
76
- * @param codec The codec to bind the configuration set to
77
- *
78
- * @returns Configuration as a given type
79
- *
80
- * @throws {@link DecodeError}
81
- */
82
- bind<T>(configSet: unknown, codec: t.Mixed): T;
83
- /**
84
- * Get a configuration by namespace and decode and validate
85
- * that configuration set to a given type. If no namespace
86
- * provided, try and use the whole configuration object
87
- * to bind to the given type.
88
- *
89
- * @param namespace The key for the nested json object or undefined
90
- * @param codec The codec to bind the configuration set to
91
- *
92
- * @returns Configuration as a given type
93
- *
94
- * @throws {@link ConfigurationNotSetError}
95
- * @throws {@link ConfigurationSetNotFoundError}
96
- * @throws {@link DecodeError}
97
- */
98
- bindConfigSet<T>(codec: t.Mixed, namespace?: string): T;
99
- /**
100
- * Validates the client configuration (sudoplatformconfig.json) against the currently deployed set of
101
- * backend services. If the client configuration is valid, i.e. the client is compatible will all deployed
102
- * backend services, then the call will complete with `success` result. If any part of the client
103
- * configuration is incompatible then a detailed information on the incompatible service will be
104
- * returned in `failure` result. See `SudoConfigManagerError.compatibilityIssueFound` for more details.
105
- *
106
- * @return validation result with the details of incompatible or deprecated service configurations.
107
- */
108
- validateConfig(): Promise<ValidationResult>;
109
- }
110
- /**
111
- * Singleton to manage configuration
112
- */
113
- export declare class DefaultConfigurationManager implements ConfigurationManager {
114
- private static instance;
115
- private _config;
116
- private constructor();
117
- static getInstance(): DefaultConfigurationManager;
118
- setConfig(config: string): DefaultConfigurationManager;
119
- getConfigSet(namespace?: string): string;
120
- bind<T>(configSet: unknown, codec: t.Mixed): T;
121
- bindConfigSet<T>(codec: t.Mixed, namespace?: string): T;
122
- validateConfig(): Promise<ValidationResult>;
123
- }
@@ -1,263 +0,0 @@
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;
package/lib/index.d.ts DELETED
@@ -1,9 +0,0 @@
1
- export * from './configurationManager/defaultConfigurationManager';
2
- export * from './sudoKeyArchive';
3
- export * from './sudoKeyManager';
4
- export * from './utils/base64';
5
- export * from './utils/buffer';
6
- export * from './utils/stream';
7
- export * from './errors/error';
8
- export * from './logging/logger';
9
- export * from './types/types';
@@ -1,8 +0,0 @@
1
- import { createLogger } from 'browser-bunyan';
2
- import * as t from 'io-ts';
3
- declare const Level: t.UnionC<[t.LiteralC<"trace">, t.LiteralC<"debug">, t.LiteralC<"info">, t.LiteralC<"warn">, t.LiteralC<"error">, t.LiteralC<"fatal">]>;
4
- declare type Level = t.TypeOf<typeof Level>;
5
- export declare function getLogLevel(level: string | undefined): Level | undefined;
6
- export declare function createBunyanLogger(identifier?: string, logLevel?: string): BunyanLogger;
7
- export declare type BunyanLogger = ReturnType<typeof createLogger>;
8
- export {};
@@ -1,87 +0,0 @@
1
- /**
2
- * Interface encapsulating logger functions.
3
- */
4
- export interface Logger {
5
- /**
6
- * @returns Whether or not trace level logging is enabled
7
- */
8
- trace(): boolean;
9
- /**
10
- * Will log the given message with the logger implementation using the TRACE level
11
- * @param message the message to be logged
12
- * @param fields optional fields that represent an object
13
- */
14
- trace(message: string, fields?: Record<string, unknown>): void;
15
- /**
16
- * @returns Whether or not debug level logging is enabled
17
- */
18
- debug(): boolean;
19
- /**
20
- * Will log the given message with the logger implementation using the DEBUG level
21
- * @param message the message to be logged
22
- * @param fields optional fields that represent an object
23
- */
24
- debug(message: string, fields?: Record<string, unknown>): void;
25
- /**
26
- * @returns Whether or not info level logging is enabled
27
- */
28
- info(): boolean;
29
- /**
30
- * Will log the given message with the logger implementation using the INFO level
31
- * @param message the message to be logged
32
- * @param fields optional fields that represent an object
33
- */
34
- info(message: string, fields?: Record<string, unknown>): void;
35
- /**
36
- * @returns Whether or not warn level logging is enabled
37
- */
38
- warn(): boolean;
39
- /**
40
- * Will log the given message with the logger implementation using the WARN level
41
- * @param message the message to be logged
42
- * @param fields optional fields that represent an object
43
- */
44
- warn(message: string, fields?: Record<string, unknown>): void;
45
- /**
46
- * @returns Whether or not error level logging is enabled
47
- */
48
- error(): boolean;
49
- /**
50
- * Will log the given message with the logger implementation using the ERROR level
51
- * @param message the message to be logged
52
- * @param fields optional fields that represent an object
53
- */
54
- error(message: string, fields?: Record<string, unknown>): void;
55
- /**
56
- * @returns Whether or not fatal level logging is enabled
57
- */
58
- fatal(): boolean;
59
- /**
60
- * Will log the given message with the logger implementation using the FATAL level
61
- * @param message the message to be logged
62
- * @param fields optional fields that represent an object
63
- */
64
- fatal(message: string, fields?: Record<string, unknown>): void;
65
- }
66
- export declare class DefaultLogger implements Logger {
67
- private logger;
68
- /**
69
- * The default logger implementation which wraps browser-bunyan
70
- *
71
- * @param identifier the name of the module
72
- * @param logLevel the log level for the module
73
- */
74
- constructor(identifier?: string, logLevel?: string);
75
- trace(): boolean;
76
- trace(message: string, fields?: Record<string, unknown>): void;
77
- debug(): boolean;
78
- debug(message: string, fields?: Record<string, unknown>): void;
79
- info(): boolean;
80
- info(message: string, fields?: Record<string, unknown>): void;
81
- warn(): boolean;
82
- warn(message: string, fields?: Record<string, unknown>): void;
83
- error(): boolean;
84
- error(message: string, fields?: Record<string, unknown>): void;
85
- fatal(): boolean;
86
- fatal(message: string, fields?: Record<string, unknown>): void;
87
- }
@@ -1,4 +0,0 @@
1
- export * from './keyArchive';
2
- export * from './keyInfo';
3
- export * from './keyType';
4
- export * from './sudoKeyArchive';