@sudoplatform/sudo-common 6.2.0 → 6.3.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/.yarn/releases/yarn-1.22.18.cjs +147520 -0
- package/.yarnrc +5 -0
- package/dependencies-report.json +1 -1
- package/docs/assets/main.js +2 -2
- package/docs/assets/search.js +1 -1
- package/docs/assets/style.css +3 -2
- package/docs/classes/AccountLockedError.html +1 -1
- package/docs/classes/AuthenticationError.html +1 -1
- package/docs/classes/Base64.html +1 -1
- package/docs/classes/Buffer.html +1 -1
- package/docs/classes/ConfigurationNotSetError.html +1 -1
- package/docs/classes/ConfigurationSetNotFoundError.html +1 -1
- package/docs/classes/DecodeError.html +1 -1
- package/docs/classes/DefaultConfigurationManager.html +1 -1
- package/docs/classes/DefaultLogger.html +1 -1
- package/docs/classes/DefaultSudoKeyArchive.html +1 -1
- package/docs/classes/DefaultSudoKeyManager.html +12 -12
- package/docs/classes/FatalError.html +1 -1
- package/docs/classes/IllegalArgumentError.html +1 -1
- package/docs/classes/IllegalStateError.html +1 -1
- package/docs/classes/InsufficientEntitlementsError.html +1 -1
- package/docs/classes/InvalidOwnershipProofError.html +1 -1
- package/docs/classes/InvalidTokenError.html +1 -1
- package/docs/classes/KeyArchiveDecodingError.html +1 -1
- package/docs/classes/KeyArchiveIncorrectPasswordError.html +1 -1
- package/docs/classes/KeyArchiveMissingError.html +1 -1
- package/docs/classes/KeyArchiveNoPasswordRequiredError.html +1 -1
- package/docs/classes/KeyArchivePasswordRequiredError.html +1 -1
- package/docs/classes/KeyArchiveTypeError.html +1 -1
- package/docs/classes/KeyArchiveUnknownKeyTypeError.html +1 -1
- package/docs/classes/KeyArchiveVersionError.html +1 -1
- package/docs/classes/KeyNotFoundError.html +1 -1
- package/docs/classes/KeyStoreNotExportableError.html +1 -1
- package/docs/classes/LimitExceededError.html +1 -1
- package/docs/classes/NoEntitlementsError.html +1 -1
- package/docs/classes/NotAuthorizedError.html +1 -1
- package/docs/classes/NotRegisteredError.html +1 -1
- package/docs/classes/NotSignedInError.html +1 -1
- package/docs/classes/OperationNotImplementedError.html +1 -1
- package/docs/classes/RegisterError.html +1 -1
- package/docs/classes/RequestFailedError.html +1 -1
- package/docs/classes/ServiceError.html +1 -1
- package/docs/classes/SignOutError.html +1 -1
- package/docs/classes/SudoCryptoProviderDefaults.html +1 -1
- package/docs/classes/UnknownGraphQLError.html +1 -1
- package/docs/classes/UnrecognizedAlgorithmError.html +1 -1
- package/docs/classes/UserNotConfirmedError.html +1 -1
- package/docs/classes/VersionMismatchError.html +1 -1
- package/docs/enums/CachePolicy.html +1 -1
- package/docs/enums/EncryptionAlgorithm.html +2 -2
- package/docs/enums/KeyArchiveKeyType.html +1 -1
- package/docs/enums/KeyDataKeyFormat.html +1 -1
- package/docs/enums/KeyDataKeyType.html +1 -1
- package/docs/enums/ListOperationResultStatus.html +4 -4
- package/docs/enums/PublicKeyFormat.html +1 -1
- package/docs/index.html +1 -1
- package/docs/interfaces/AsymmetricEncryptionOptions.html +1 -1
- package/docs/interfaces/BooleanFilter.html +1 -1
- package/docs/interfaces/ConfigurationManager.html +1 -1
- package/docs/interfaces/KeyData.html +1 -1
- package/docs/interfaces/ListOperationFailureResult.html +2 -2
- package/docs/interfaces/ListOperationPartialResult.html +4 -4
- package/docs/interfaces/ListOperationSuccessResult.html +3 -3
- package/docs/interfaces/ListOutput.html +1 -1
- package/docs/interfaces/Logger.html +1 -1
- package/docs/interfaces/Owner.html +1 -1
- package/docs/interfaces/PublicKey.html +1 -1
- package/docs/interfaces/ServiceCompatibilityInfo.html +1 -1
- package/docs/interfaces/StringFilter.html +1 -1
- package/docs/interfaces/SudoCryptoProvider.html +1 -1
- package/docs/interfaces/SudoKeyArchive.html +1 -1
- package/docs/interfaces/SudoKeyManager.html +1 -1
- package/docs/interfaces/SymmetricEncryptionOptions.html +1 -1
- package/docs/interfaces/ValidationResult.html +1 -1
- package/docs/modules.html +5 -5
- package/github/.yarn/releases/yarn-1.22.18.cjs +147520 -0
- package/github/.yarnrc +5 -0
- package/github/docs/assets/main.js +2 -2
- package/github/docs/assets/search.js +1 -1
- package/github/docs/assets/style.css +3 -2
- package/github/docs/classes/AccountLockedError.html +1 -1
- package/github/docs/classes/AuthenticationError.html +1 -1
- package/github/docs/classes/Base64.html +1 -1
- package/github/docs/classes/Buffer.html +1 -1
- package/github/docs/classes/ConfigurationNotSetError.html +1 -1
- package/github/docs/classes/ConfigurationSetNotFoundError.html +1 -1
- package/github/docs/classes/DecodeError.html +1 -1
- package/github/docs/classes/DefaultConfigurationManager.html +1 -1
- package/github/docs/classes/DefaultLogger.html +1 -1
- package/github/docs/classes/DefaultSudoKeyArchive.html +1 -1
- package/github/docs/classes/DefaultSudoKeyManager.html +12 -12
- package/github/docs/classes/FatalError.html +1 -1
- package/github/docs/classes/IllegalArgumentError.html +1 -1
- package/github/docs/classes/IllegalStateError.html +1 -1
- package/github/docs/classes/InsufficientEntitlementsError.html +1 -1
- package/github/docs/classes/InvalidOwnershipProofError.html +1 -1
- package/github/docs/classes/InvalidTokenError.html +1 -1
- package/github/docs/classes/KeyArchiveDecodingError.html +1 -1
- package/github/docs/classes/KeyArchiveIncorrectPasswordError.html +1 -1
- package/github/docs/classes/KeyArchiveMissingError.html +1 -1
- package/github/docs/classes/KeyArchiveNoPasswordRequiredError.html +1 -1
- package/github/docs/classes/KeyArchivePasswordRequiredError.html +1 -1
- package/github/docs/classes/KeyArchiveTypeError.html +1 -1
- package/github/docs/classes/KeyArchiveUnknownKeyTypeError.html +1 -1
- package/github/docs/classes/KeyArchiveVersionError.html +1 -1
- package/github/docs/classes/KeyNotFoundError.html +1 -1
- package/github/docs/classes/KeyStoreNotExportableError.html +1 -1
- package/github/docs/classes/LimitExceededError.html +1 -1
- package/github/docs/classes/NoEntitlementsError.html +1 -1
- package/github/docs/classes/NotAuthorizedError.html +1 -1
- package/github/docs/classes/NotRegisteredError.html +1 -1
- package/github/docs/classes/NotSignedInError.html +1 -1
- package/github/docs/classes/OperationNotImplementedError.html +1 -1
- package/github/docs/classes/RegisterError.html +1 -1
- package/github/docs/classes/RequestFailedError.html +1 -1
- package/github/docs/classes/ServiceError.html +1 -1
- package/github/docs/classes/SignOutError.html +1 -1
- package/github/docs/classes/SudoCryptoProviderDefaults.html +1 -1
- package/github/docs/classes/UnknownGraphQLError.html +1 -1
- package/github/docs/classes/UnrecognizedAlgorithmError.html +1 -1
- package/github/docs/classes/UserNotConfirmedError.html +1 -1
- package/github/docs/classes/VersionMismatchError.html +1 -1
- package/github/docs/enums/CachePolicy.html +1 -1
- package/github/docs/enums/EncryptionAlgorithm.html +2 -2
- package/github/docs/enums/KeyArchiveKeyType.html +1 -1
- package/github/docs/enums/KeyDataKeyFormat.html +1 -1
- package/github/docs/enums/KeyDataKeyType.html +1 -1
- package/github/docs/enums/ListOperationResultStatus.html +4 -4
- package/github/docs/enums/PublicKeyFormat.html +1 -1
- package/github/docs/index.html +1 -1
- package/github/docs/interfaces/AsymmetricEncryptionOptions.html +1 -1
- package/github/docs/interfaces/BooleanFilter.html +1 -1
- package/github/docs/interfaces/ConfigurationManager.html +1 -1
- package/github/docs/interfaces/KeyData.html +1 -1
- package/github/docs/interfaces/ListOperationFailureResult.html +2 -2
- package/github/docs/interfaces/ListOperationPartialResult.html +4 -4
- package/github/docs/interfaces/ListOperationSuccessResult.html +3 -3
- package/github/docs/interfaces/ListOutput.html +1 -1
- package/github/docs/interfaces/Logger.html +1 -1
- package/github/docs/interfaces/Owner.html +1 -1
- package/github/docs/interfaces/PublicKey.html +1 -1
- package/github/docs/interfaces/ServiceCompatibilityInfo.html +1 -1
- package/github/docs/interfaces/StringFilter.html +1 -1
- package/github/docs/interfaces/SudoCryptoProvider.html +1 -1
- package/github/docs/interfaces/SudoKeyArchive.html +1 -1
- package/github/docs/interfaces/SudoKeyManager.html +1 -1
- package/github/docs/interfaces/SymmetricEncryptionOptions.html +1 -1
- package/github/docs/interfaces/ValidationResult.html +1 -1
- package/github/docs/modules.html +5 -5
- package/github/package.json +17 -16
- package/github/src/errors/error.ts +5 -1
- package/github/src/sudoKeyManager/sudoKeyManager.ts +12 -20
- package/github/src/types/types.ts +1 -0
- package/github/test/unit/errors/error.spec.ts +3 -18
- package/github/test/unit/sudoKeyManager.spec.ts +18 -18
- package/github/yarn.lock +410 -229
- package/lib/errors/error.d.ts +1 -1
- package/lib/errors/error.js +3 -0
- package/lib/sudoKeyManager/sudoKeyManager.js +12 -4
- package/lib/types/types.d.ts +1 -0
- package/lib/types/types.js +1 -0
- package/package.json +18 -17
- package/src/errors/error.ts +5 -1
- package/src/sudoKeyManager/sudoKeyManager.ts +12 -20
- package/src/types/types.ts +1 -0
- package/test/unit/errors/error.spec.ts +3 -18
- package/test/unit/sudoKeyManager.spec.ts +18 -18
- package/yarn.lock +410 -229
package/lib/errors/error.d.ts
CHANGED
|
@@ -251,7 +251,7 @@ export declare class UnrecognizedAlgorithmError extends Error {
|
|
|
251
251
|
* @param error The App Sync error to map
|
|
252
252
|
* @returns The mapped error
|
|
253
253
|
*/
|
|
254
|
-
export declare function mapGraphQLToClientError(error: AppSyncError): Error;
|
|
254
|
+
export declare function mapGraphQLToClientError(error: Pick<AppSyncError, 'errorType' | 'message'>): Error;
|
|
255
255
|
/**
|
|
256
256
|
* Call this in error handling when testing with isAppSyncNetworkError on
|
|
257
257
|
* a caught error from an AppSync operation returns true.
|
package/lib/errors/error.js
CHANGED
|
@@ -577,6 +577,9 @@ function mapGraphQLToClientError(error) {
|
|
|
577
577
|
case 'sudoplatform.InvalidArgumentError':
|
|
578
578
|
return new IllegalArgumentError();
|
|
579
579
|
|
|
580
|
+
case 'sudoplatform.LimitExceededError':
|
|
581
|
+
return new LimitExceededError();
|
|
582
|
+
|
|
580
583
|
case 'sudoplatform.NoEntitlementsError':
|
|
581
584
|
return new NoEntitlementsError();
|
|
582
585
|
|
|
@@ -87,7 +87,9 @@ class DefaultSudoKeyManager {
|
|
|
87
87
|
|
|
88
88
|
encryptWithSymmetricKey(key, data, ivOrOptions) {
|
|
89
89
|
if (_buffer.Buffer.isArrayBuffer(ivOrOptions)) {
|
|
90
|
-
return this.sudoCryptoProvider.encryptWithSymmetricKey(key, data,
|
|
90
|
+
return this.sudoCryptoProvider.encryptWithSymmetricKey(key, data, {
|
|
91
|
+
iv: ivOrOptions
|
|
92
|
+
});
|
|
91
93
|
} else {
|
|
92
94
|
return this.sudoCryptoProvider.encryptWithSymmetricKey(key, data, ivOrOptions);
|
|
93
95
|
}
|
|
@@ -95,7 +97,9 @@ class DefaultSudoKeyManager {
|
|
|
95
97
|
|
|
96
98
|
decryptWithSymmetricKey(key, data, ivOrOptions) {
|
|
97
99
|
if (_buffer.Buffer.isArrayBuffer(ivOrOptions)) {
|
|
98
|
-
return this.sudoCryptoProvider.decryptWithSymmetricKey(key, data,
|
|
100
|
+
return this.sudoCryptoProvider.decryptWithSymmetricKey(key, data, {
|
|
101
|
+
iv: ivOrOptions
|
|
102
|
+
});
|
|
99
103
|
} else {
|
|
100
104
|
return this.sudoCryptoProvider.decryptWithSymmetricKey(key, data, ivOrOptions);
|
|
101
105
|
}
|
|
@@ -103,7 +107,9 @@ class DefaultSudoKeyManager {
|
|
|
103
107
|
|
|
104
108
|
encryptWithSymmetricKeyName(name, data, ivOrOptions) {
|
|
105
109
|
if (_buffer.Buffer.isArrayBuffer(ivOrOptions)) {
|
|
106
|
-
return this.sudoCryptoProvider.encryptWithSymmetricKeyName(name, data,
|
|
110
|
+
return this.sudoCryptoProvider.encryptWithSymmetricKeyName(name, data, {
|
|
111
|
+
iv: ivOrOptions
|
|
112
|
+
});
|
|
107
113
|
} else {
|
|
108
114
|
return this.sudoCryptoProvider.encryptWithSymmetricKeyName(name, data, ivOrOptions);
|
|
109
115
|
}
|
|
@@ -111,7 +117,9 @@ class DefaultSudoKeyManager {
|
|
|
111
117
|
|
|
112
118
|
decryptWithSymmetricKeyName(name, data, ivOrOptions) {
|
|
113
119
|
if (_buffer.Buffer.isArrayBuffer(ivOrOptions)) {
|
|
114
|
-
return this.sudoCryptoProvider.decryptWithSymmetricKeyName(name, data,
|
|
120
|
+
return this.sudoCryptoProvider.decryptWithSymmetricKeyName(name, data, {
|
|
121
|
+
iv: ivOrOptions
|
|
122
|
+
});
|
|
115
123
|
} else {
|
|
116
124
|
return this.sudoCryptoProvider.decryptWithSymmetricKeyName(name, data, ivOrOptions);
|
|
117
125
|
}
|
package/lib/types/types.d.ts
CHANGED
|
@@ -39,6 +39,7 @@ export interface BooleanFilter {
|
|
|
39
39
|
*/
|
|
40
40
|
export declare enum EncryptionAlgorithm {
|
|
41
41
|
AesCbcPkcs7Padding = "AES/CBC/PKCS7Padding",
|
|
42
|
+
AesGcmNoPadding = "AES/GCM/NoPadding",
|
|
42
43
|
RsaOaepSha1 = "RSA/OAEPWithSHA-1"
|
|
43
44
|
}
|
|
44
45
|
export declare type Subset<T, S> = Pick<S, Extract<keyof T, keyof S>> & Partial<Record<Exclude<keyof T, keyof S>, never>>;
|
package/lib/types/types.js
CHANGED
|
@@ -31,6 +31,7 @@ exports.EncryptionAlgorithm = EncryptionAlgorithm;
|
|
|
31
31
|
|
|
32
32
|
(function (EncryptionAlgorithm) {
|
|
33
33
|
EncryptionAlgorithm["AesCbcPkcs7Padding"] = "AES/CBC/PKCS7Padding";
|
|
34
|
+
EncryptionAlgorithm["AesGcmNoPadding"] = "AES/GCM/NoPadding";
|
|
34
35
|
EncryptionAlgorithm["RsaOaepSha1"] = "RSA/OAEPWithSHA-1";
|
|
35
36
|
})(EncryptionAlgorithm || (exports.EncryptionAlgorithm = EncryptionAlgorithm = {}));
|
|
36
37
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sudoplatform/sudo-common",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.3.1",
|
|
4
4
|
"author": "Anonyome Labs, Inc.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -39,44 +39,45 @@
|
|
|
39
39
|
"**/apollo-cache-inmemory": "^1.6.6",
|
|
40
40
|
"**/apollo-client": "^2.6.10",
|
|
41
41
|
"ansi-regex": "^5.0.1",
|
|
42
|
-
"tmpl": "^1.0.5"
|
|
42
|
+
"tmpl": "^1.0.5",
|
|
43
|
+
"minimist": "^1.2.6"
|
|
43
44
|
},
|
|
44
45
|
"dependencies": {
|
|
45
46
|
"apollo-client": "^2.6.10",
|
|
46
47
|
"aws-sdk": "^2.973.0",
|
|
47
48
|
"browser-bunyan": "^1.8.0",
|
|
48
49
|
"fflate": "^0.7.3",
|
|
49
|
-
"graphql": "^15.
|
|
50
|
+
"graphql": "^15.8.0"
|
|
50
51
|
},
|
|
51
52
|
"peerDependencies": {
|
|
52
53
|
"io-ts": "^2.2.10"
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
|
55
|
-
"@babel/cli": "^7.
|
|
56
|
-
"@babel/core": "^7.17.
|
|
56
|
+
"@babel/cli": "^7.17.10",
|
|
57
|
+
"@babel/core": "^7.17.10",
|
|
57
58
|
"@babel/plugin-proposal-class-properties": "^7.16.7",
|
|
58
59
|
"@babel/plugin-proposal-private-methods": "^7.16.11",
|
|
59
|
-
"@babel/preset-env": "^7.
|
|
60
|
+
"@babel/preset-env": "^7.17.10",
|
|
60
61
|
"@babel/preset-typescript": "^7.16.7",
|
|
61
|
-
"@types/jest": "^27.
|
|
62
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
63
|
-
"@typescript-eslint/parser": "^5.
|
|
64
|
-
"aws-sdk-mock": "^5.
|
|
65
|
-
"eslint": "^8.
|
|
66
|
-
"eslint-config-prettier": "^8.
|
|
67
|
-
"eslint-plugin-import": "^2.
|
|
62
|
+
"@types/jest": "^27.5.0",
|
|
63
|
+
"@typescript-eslint/eslint-plugin": "^5.22.0",
|
|
64
|
+
"@typescript-eslint/parser": "^5.22.0",
|
|
65
|
+
"aws-sdk-mock": "^5.7.0",
|
|
66
|
+
"eslint": "^8.14.0",
|
|
67
|
+
"eslint-config-prettier": "^8.5.0",
|
|
68
|
+
"eslint-plugin-import": "^2.26.0",
|
|
68
69
|
"eslint-plugin-prettier": "^4.0.0",
|
|
69
70
|
"fp-ts": "^2.11.8",
|
|
70
71
|
"io-ts": "^2.2.16",
|
|
71
72
|
"io-ts-types": "^0.5.16",
|
|
72
73
|
"isomorphic-webcrypto": "^2.3.8",
|
|
73
74
|
"jest": "^27.5.1",
|
|
74
|
-
"monocle-ts": "^2.3.
|
|
75
|
+
"monocle-ts": "^2.3.13",
|
|
75
76
|
"newtype-ts": "^0.3.5",
|
|
76
|
-
"prettier": "^2.
|
|
77
|
+
"prettier": "^2.6.2",
|
|
77
78
|
"rimraf": "^3.0.2",
|
|
78
79
|
"ts-mockito": "^2.6.1",
|
|
79
|
-
"typedoc": "^0.22.
|
|
80
|
-
"typescript": "^4.
|
|
80
|
+
"typedoc": "^0.22.15",
|
|
81
|
+
"typescript": "^4.6.4"
|
|
81
82
|
}
|
|
82
83
|
}
|
package/src/errors/error.ts
CHANGED
|
@@ -425,7 +425,9 @@ export class UnrecognizedAlgorithmError extends Error {
|
|
|
425
425
|
* @param error The App Sync error to map
|
|
426
426
|
* @returns The mapped error
|
|
427
427
|
*/
|
|
428
|
-
export function mapGraphQLToClientError(
|
|
428
|
+
export function mapGraphQLToClientError(
|
|
429
|
+
error: Pick<AppSyncError, 'errorType' | 'message'>,
|
|
430
|
+
): Error {
|
|
429
431
|
switch (error.errorType) {
|
|
430
432
|
case 'sudoplatform.AccountLockedError':
|
|
431
433
|
return new AccountLockedError()
|
|
@@ -435,6 +437,8 @@ export function mapGraphQLToClientError(error: AppSyncError): Error {
|
|
|
435
437
|
return new InvalidTokenError()
|
|
436
438
|
case 'sudoplatform.InvalidArgumentError':
|
|
437
439
|
return new IllegalArgumentError()
|
|
440
|
+
case 'sudoplatform.LimitExceededError':
|
|
441
|
+
return new LimitExceededError()
|
|
438
442
|
case 'sudoplatform.NoEntitlementsError':
|
|
439
443
|
return new NoEntitlementsError()
|
|
440
444
|
case 'sudoplatform.ServiceError':
|
|
@@ -435,11 +435,9 @@ export class DefaultSudoKeyManager implements SudoKeyManager {
|
|
|
435
435
|
ivOrOptions?: ArrayBuffer | SymmetricEncryptionOptions,
|
|
436
436
|
): Promise<ArrayBuffer> {
|
|
437
437
|
if (BufferUtil.isArrayBuffer(ivOrOptions)) {
|
|
438
|
-
return this.sudoCryptoProvider.encryptWithSymmetricKey(
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
ivOrOptions,
|
|
442
|
-
)
|
|
438
|
+
return this.sudoCryptoProvider.encryptWithSymmetricKey(key, data, {
|
|
439
|
+
iv: ivOrOptions,
|
|
440
|
+
})
|
|
443
441
|
} else {
|
|
444
442
|
return this.sudoCryptoProvider.encryptWithSymmetricKey(
|
|
445
443
|
key,
|
|
@@ -455,11 +453,9 @@ export class DefaultSudoKeyManager implements SudoKeyManager {
|
|
|
455
453
|
ivOrOptions?: ArrayBuffer | SymmetricEncryptionOptions,
|
|
456
454
|
): Promise<ArrayBuffer> {
|
|
457
455
|
if (BufferUtil.isArrayBuffer(ivOrOptions)) {
|
|
458
|
-
return this.sudoCryptoProvider.decryptWithSymmetricKey(
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
ivOrOptions,
|
|
462
|
-
)
|
|
456
|
+
return this.sudoCryptoProvider.decryptWithSymmetricKey(key, data, {
|
|
457
|
+
iv: ivOrOptions,
|
|
458
|
+
})
|
|
463
459
|
} else {
|
|
464
460
|
return this.sudoCryptoProvider.decryptWithSymmetricKey(
|
|
465
461
|
key,
|
|
@@ -475,11 +471,9 @@ export class DefaultSudoKeyManager implements SudoKeyManager {
|
|
|
475
471
|
ivOrOptions?: ArrayBuffer | SymmetricEncryptionOptions,
|
|
476
472
|
): Promise<ArrayBuffer> {
|
|
477
473
|
if (BufferUtil.isArrayBuffer(ivOrOptions)) {
|
|
478
|
-
return this.sudoCryptoProvider.encryptWithSymmetricKeyName(
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
ivOrOptions,
|
|
482
|
-
)
|
|
474
|
+
return this.sudoCryptoProvider.encryptWithSymmetricKeyName(name, data, {
|
|
475
|
+
iv: ivOrOptions,
|
|
476
|
+
})
|
|
483
477
|
} else {
|
|
484
478
|
return this.sudoCryptoProvider.encryptWithSymmetricKeyName(
|
|
485
479
|
name,
|
|
@@ -495,11 +489,9 @@ export class DefaultSudoKeyManager implements SudoKeyManager {
|
|
|
495
489
|
ivOrOptions?: ArrayBuffer | SymmetricEncryptionOptions,
|
|
496
490
|
): Promise<ArrayBuffer> {
|
|
497
491
|
if (BufferUtil.isArrayBuffer(ivOrOptions)) {
|
|
498
|
-
return this.sudoCryptoProvider.decryptWithSymmetricKeyName(
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
ivOrOptions,
|
|
502
|
-
)
|
|
492
|
+
return this.sudoCryptoProvider.decryptWithSymmetricKeyName(name, data, {
|
|
493
|
+
iv: ivOrOptions,
|
|
494
|
+
})
|
|
503
495
|
} else {
|
|
504
496
|
return this.sudoCryptoProvider.decryptWithSymmetricKeyName(
|
|
505
497
|
name,
|
package/src/types/types.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AccountLockedError,
|
|
3
|
-
AppSyncError,
|
|
4
3
|
AppSyncNetworkError,
|
|
5
4
|
IllegalArgumentError,
|
|
6
5
|
InsufficientEntitlementsError,
|
|
7
6
|
InvalidTokenError,
|
|
8
7
|
isAppSyncNetworkError,
|
|
8
|
+
LimitExceededError,
|
|
9
9
|
mapGraphQLToClientError,
|
|
10
10
|
mapNetworkErrorToClientError,
|
|
11
11
|
NoEntitlementsError,
|
|
@@ -26,34 +26,19 @@ describe('error', () => {
|
|
|
26
26
|
${'sudoplatform.InvalidArgumentError'} | ${new IllegalArgumentError()}
|
|
27
27
|
${'sudoplatform.NoEntitlementsError'} | ${new NoEntitlementsError()}
|
|
28
28
|
${'sudoplatform.ServiceError'} | ${new ServiceError(message)}
|
|
29
|
+
${'sudoplatform.LimitExceededError'} | ${new LimitExceededError()}
|
|
29
30
|
`('should map common error $code properly', ({ code, error }) => {
|
|
30
31
|
expect(
|
|
31
32
|
mapGraphQLToClientError({
|
|
32
33
|
message,
|
|
33
|
-
path: [],
|
|
34
|
-
locations: [],
|
|
35
|
-
nodes: [],
|
|
36
|
-
positions: [],
|
|
37
|
-
source: undefined,
|
|
38
|
-
originalError: undefined,
|
|
39
|
-
extensions: [],
|
|
40
|
-
name: code,
|
|
41
34
|
errorType: code,
|
|
42
35
|
}),
|
|
43
36
|
).toEqual(error)
|
|
44
37
|
})
|
|
45
38
|
|
|
46
39
|
it('should map an unrecognized error to UnknownGraphQLError', () => {
|
|
47
|
-
const unrecognized
|
|
40
|
+
const unrecognized = {
|
|
48
41
|
message,
|
|
49
|
-
path: [],
|
|
50
|
-
locations: [],
|
|
51
|
-
nodes: [],
|
|
52
|
-
positions: [],
|
|
53
|
-
source: undefined,
|
|
54
|
-
originalError: undefined,
|
|
55
|
-
extensions: [],
|
|
56
|
-
name: 'unrecognized',
|
|
57
42
|
errorType: 'unrecognized',
|
|
58
43
|
}
|
|
59
44
|
expect(mapGraphQLToClientError(unrecognized)).toEqual(
|
|
@@ -393,8 +393,8 @@ describe('DefaultSudoKeyManager', () => {
|
|
|
393
393
|
expect(actualKeyName).toStrictEqual('VpnKey')
|
|
394
394
|
expect(actualData).toStrictEqual(decrypted)
|
|
395
395
|
expect(actualOptions).toBeDefined()
|
|
396
|
-
expect(actualOptions
|
|
397
|
-
expect(actualOptions
|
|
396
|
+
expect(actualOptions!.iv).toStrictEqual(iv)
|
|
397
|
+
expect(actualOptions!.algorithm).toBeUndefined()
|
|
398
398
|
|
|
399
399
|
verify(
|
|
400
400
|
sudoCryptoProviderMock.encryptWithSymmetricKeyName(
|
|
@@ -430,8 +430,8 @@ describe('DefaultSudoKeyManager', () => {
|
|
|
430
430
|
expect(actualKeyName).toStrictEqual('VpnKey')
|
|
431
431
|
expect(actualData).toStrictEqual(decrypted)
|
|
432
432
|
expect(actualOptions).toBeDefined()
|
|
433
|
-
expect(actualOptions
|
|
434
|
-
expect(actualOptions
|
|
433
|
+
expect(actualOptions!.iv).toStrictEqual(options.iv)
|
|
434
|
+
expect(actualOptions!.algorithm).toStrictEqual(options.algorithm)
|
|
435
435
|
|
|
436
436
|
verify(
|
|
437
437
|
sudoCryptoProviderMock.encryptWithSymmetricKeyName(
|
|
@@ -492,8 +492,8 @@ describe('DefaultSudoKeyManager', () => {
|
|
|
492
492
|
expect(actualKey).toStrictEqual(symmetricKey)
|
|
493
493
|
expect(actualData).toStrictEqual(encrypted)
|
|
494
494
|
expect(actualOptions).toBeDefined()
|
|
495
|
-
expect(actualOptions
|
|
496
|
-
expect(actualOptions
|
|
495
|
+
expect(actualOptions!.iv).toStrictEqual(iv)
|
|
496
|
+
expect(actualOptions!.algorithm).toBeUndefined()
|
|
497
497
|
|
|
498
498
|
verify(
|
|
499
499
|
sudoCryptoProviderMock.encryptWithSymmetricKey(
|
|
@@ -530,8 +530,8 @@ describe('DefaultSudoKeyManager', () => {
|
|
|
530
530
|
expect(actualKey).toStrictEqual(symmetricKey)
|
|
531
531
|
expect(actualData).toStrictEqual(encrypted)
|
|
532
532
|
expect(actualOptions).toBeDefined()
|
|
533
|
-
expect(actualOptions
|
|
534
|
-
expect(actualOptions
|
|
533
|
+
expect(actualOptions!.iv).toBeUndefined()
|
|
534
|
+
expect(actualOptions!.algorithm).toStrictEqual(options.algorithm)
|
|
535
535
|
|
|
536
536
|
verify(
|
|
537
537
|
sudoCryptoProviderMock.encryptWithSymmetricKey(
|
|
@@ -599,8 +599,8 @@ describe('DefaultSudoKeyManager', () => {
|
|
|
599
599
|
expect(actualKeyName).toStrictEqual('VpnKey')
|
|
600
600
|
expect(actualData).toStrictEqual(encrypted)
|
|
601
601
|
expect(actualOptions).toBeDefined()
|
|
602
|
-
expect(actualOptions
|
|
603
|
-
expect(actualOptions
|
|
602
|
+
expect(actualOptions!.iv).toStrictEqual(options.iv)
|
|
603
|
+
expect(actualOptions!.algorithm).toBeUndefined()
|
|
604
604
|
|
|
605
605
|
verify(
|
|
606
606
|
sudoCryptoProviderMock.decryptWithSymmetricKeyName(
|
|
@@ -638,8 +638,8 @@ describe('DefaultSudoKeyManager', () => {
|
|
|
638
638
|
expect(actualKeyName).toStrictEqual('VpnKey')
|
|
639
639
|
expect(actualData).toStrictEqual(encrypted)
|
|
640
640
|
expect(actualOptions).toBeDefined()
|
|
641
|
-
expect(actualOptions
|
|
642
|
-
expect(actualOptions
|
|
641
|
+
expect(actualOptions!.iv).toStrictEqual(options.iv)
|
|
642
|
+
expect(actualOptions!.algorithm).toStrictEqual(options.algorithm)
|
|
643
643
|
|
|
644
644
|
verify(
|
|
645
645
|
sudoCryptoProviderMock.decryptWithSymmetricKeyName(
|
|
@@ -707,8 +707,8 @@ describe('DefaultSudoKeyManager', () => {
|
|
|
707
707
|
expect(actualKey).toStrictEqual(symmetricKey)
|
|
708
708
|
expect(actualData).toStrictEqual(encrypted)
|
|
709
709
|
expect(actualOptions).toBeDefined()
|
|
710
|
-
expect(actualOptions
|
|
711
|
-
expect(actualOptions
|
|
710
|
+
expect(actualOptions!.iv).toStrictEqual(iv)
|
|
711
|
+
expect(actualOptions!.algorithm).toBeUndefined()
|
|
712
712
|
|
|
713
713
|
verify(
|
|
714
714
|
sudoCryptoProviderMock.decryptWithSymmetricKey(
|
|
@@ -746,8 +746,8 @@ describe('DefaultSudoKeyManager', () => {
|
|
|
746
746
|
expect(actualKey).toStrictEqual(symmetricKey)
|
|
747
747
|
expect(actualData).toStrictEqual(encrypted)
|
|
748
748
|
expect(actualOptions).toBeDefined()
|
|
749
|
-
expect(actualOptions
|
|
750
|
-
expect(actualOptions
|
|
749
|
+
expect(actualOptions!.iv).toStrictEqual(iv)
|
|
750
|
+
expect(actualOptions!.algorithm).toStrictEqual(options.algorithm)
|
|
751
751
|
|
|
752
752
|
verify(
|
|
753
753
|
sudoCryptoProviderMock.decryptWithSymmetricKey(
|
|
@@ -811,7 +811,7 @@ describe('DefaultSudoKeyManager', () => {
|
|
|
811
811
|
expect(actualKeyName).toStrictEqual('VpnKey')
|
|
812
812
|
expect(actualData).toStrictEqual(decrypted)
|
|
813
813
|
expect(actualOptions).toBeDefined()
|
|
814
|
-
expect(actualOptions
|
|
814
|
+
expect(actualOptions!.algorithm).toStrictEqual(options.algorithm)
|
|
815
815
|
|
|
816
816
|
verify(
|
|
817
817
|
sudoCryptoProviderMock.encryptWithPublicKey(
|
|
@@ -875,7 +875,7 @@ describe('DefaultSudoKeyManager', () => {
|
|
|
875
875
|
expect(actualKeyName).toStrictEqual('VpnKey')
|
|
876
876
|
expect(actualData).toStrictEqual(encrypted)
|
|
877
877
|
expect(actualOptions).toBeDefined()
|
|
878
|
-
expect(actualOptions
|
|
878
|
+
expect(actualOptions!.algorithm).toStrictEqual(options.algorithm)
|
|
879
879
|
|
|
880
880
|
verify(
|
|
881
881
|
sudoCryptoProviderMock.decryptWithPrivateKey(
|