@webex/plugin-encryption 3.8.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/.eslintrc.js +6 -0
- package/LICENSE +2 -0
- package/README.md +88 -0
- package/babel.config.js +13 -0
- package/browsers.js +97 -0
- package/coverage/clover.xml +176 -0
- package/coverage/coverage-final.json +3 -0
- package/coverage/jest-html-reporters-attach/jest-report/index.js +58 -0
- package/coverage/jest-html-reporters-attach/jest-report/result.js +1 -0
- package/coverage/jest-report.html +1 -0
- package/coverage/junit/coverage-junit.xml +27 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/constants.ts.html +100 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +131 -0
- package/coverage/lcov-report/index.ts.html +562 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov.info +215 -0
- package/developer-quickstart.md +104 -0
- package/dist/config.js +10 -0
- package/dist/config.js.map +1 -0
- package/dist/constants.js +6 -0
- package/dist/constants.js.map +1 -0
- package/dist/cypher/constants.js +12 -0
- package/dist/cypher/constants.js.map +1 -0
- package/dist/cypher/cypher.types.js +6 -0
- package/dist/cypher/cypher.types.js.map +1 -0
- package/dist/cypher/index.js +141 -0
- package/dist/cypher/index.js.map +1 -0
- package/dist/cypher/types.js +6 -0
- package/dist/cypher/types.js.map +1 -0
- package/dist/encryption/constants.js +12 -0
- package/dist/encryption/constants.js.map +1 -0
- package/dist/encryption/encryption.types.js +6 -0
- package/dist/encryption/encryption.types.js.map +1 -0
- package/dist/encryption/index.js +84 -0
- package/dist/encryption/index.js.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/types/config.d.ts +4 -0
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/cypher/constants.d.ts +5 -0
- package/dist/types/cypher/cypher.types.d.ts +25 -0
- package/dist/types/cypher/index.d.ts +53 -0
- package/dist/types/cypher/types.d.ts +25 -0
- package/dist/types/encryption/constants.d.ts +5 -0
- package/dist/types/encryption/encryption.types.d.ts +25 -0
- package/dist/types/encryption/index.d.ts +27 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/types.d.ts +40 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/jest.config.js +44 -0
- package/junit.xml +27 -0
- package/package.json +57 -0
- package/process +1 -0
- package/src/config.ts +3 -0
- package/src/cypher/constants.ts +5 -0
- package/src/cypher/index.ts +159 -0
- package/src/cypher/types.ts +28 -0
- package/src/index.ts +13 -0
- package/src/types.ts +45 -0
- package/test/unit/spec/cypher/index.ts +146 -0
- package/tsconfig.json +18 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
null
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
null
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ENCRYPTION = exports.DECRYPTION_SUCCESS = exports.DECRYPTION_IN_PROGRESS = exports.DECRYPTION_FAILED = exports.DECRYPTION = void 0;
|
|
7
|
+
const ENCRYPTION = exports.ENCRYPTION = 'cypher';
|
|
8
|
+
const DECRYPTION = exports.DECRYPTION = 'decryption';
|
|
9
|
+
const DECRYPTION_FAILED = exports.DECRYPTION_FAILED = 'decryptionFailed';
|
|
10
|
+
const DECRYPTION_IN_PROGRESS = exports.DECRYPTION_IN_PROGRESS = 'decryptionInProgress';
|
|
11
|
+
const DECRYPTION_SUCCESS = exports.DECRYPTION_SUCCESS = 'decryptionSuccess';
|
|
12
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
null
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
null
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _webexCore = require("@webex/webex-core");
|
|
8
|
+
var _constants = require("./constants");
|
|
9
|
+
/* eslint-disable no-unused-expressions */
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @description Encryption APIs for KMS
|
|
13
|
+
* @class
|
|
14
|
+
*/
|
|
15
|
+
class Cypher extends _webexCore.WebexPlugin {
|
|
16
|
+
namespace = _constants.ENCRYPTION;
|
|
17
|
+
constructor(...args) {
|
|
18
|
+
super(...args);
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
this.$webex = this.webex;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Downloads and decrypts a file from the given URI.
|
|
25
|
+
*
|
|
26
|
+
* @param {string} fileUri - The URI of the file to be decrypted.
|
|
27
|
+
* @param {FileDownloadOptions} options - The options for file download.
|
|
28
|
+
* @returns {Promise<ArrayBuffer>} A promise that resolves to the decrypted ArrayBuffer.
|
|
29
|
+
* @throws {Error} If the file download or decryption fails.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const decryptedBuf = await webex.cypher.downloadAndDecryptFile('https://example.com/encrypted-file?JWE=eyJhbGci&keyUri=kms://example.com/keys/1234', {useFileService: false});
|
|
34
|
+
* const file = new File([decryptedBuf], "myFileName.jpeg", {type: 'image/jpeg'});
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
async downloadAndDecryptFile(fileUri, {
|
|
38
|
+
useFileService = false,
|
|
39
|
+
...options
|
|
40
|
+
} = {}) {
|
|
41
|
+
// Sample fileUri: https://someserver.com/3cc29537-7f39-4cce-b204-a529960997fcab9375d8-4fd4-4788-bb12-18426674e95b.jpg?keyUri=kms://kms.wbx2.com/keys/79be16-a4dd-4195-93ef-a72604509aca&JWE=eyJlbmMiOiJBMjU2R0NNIiwiYWxnIjoiZGlyIn0..EHYI5SmnFisaOJgv.6Ie3Zui7LFtAr4eWMSnxXAzfi8Cgixcy2b9jy9cImDWvBjjvJQfwik7qvZewCaq-u8lhtTbjEzsJLeVtOKhW_9RoZt3U0RQ-cKaSh2RaK3N_mvuH7_BsoXCMf5zxaqP1HD-3jXUtVSnqFYvEGdGRWxTCWK-PK9BoIUjX6v5t22CUNYbBQBuHizLWvrGAM0UkSvFNRX5n07Xd3WVJ7OnIhYi0JvOb50lbZIrBn27AQL-_CIKoOQxQLkW9zmVACsVpHxLZx9wIo9XYsBYADRTZaw_l_uTiosAd2P1QAGHgLr_Q_qf1wGUn3eGhmptpPx-YCSJikvs2DttwWOg_-vg4jI3EiIXlc0gGsDnleeNRguCLtrks0PMz5hOp5_w9Z5EW05Cx2UAztnp1hE9_nCvPP9wTzdHsG3flkK82HMbPpeVStWvWmAlzp24vTw2KzYrCemdS2AkrShWsNt6_G7_G8nB4RhUnZ11MKaduE5jYpCXNcTx84RBYwA.vqYHCx8uIn-IMQAsPvrw
|
|
42
|
+
// KeyUri: An attachment level unique ID generated by Webex KMS post encryption of an attachment. In order to
|
|
43
|
+
// decrypt an attachment, KeyUri is a required parameter.
|
|
44
|
+
// JWE: JWE can be decrypted using KMS key to obtain the SCR key.
|
|
45
|
+
// Decrypting an attachment requires the SCR key parameter.
|
|
46
|
+
// We need to download the encrypted file from the given URI and then decrypt it using the SCR key.
|
|
47
|
+
// The decrypted file is then returned.
|
|
48
|
+
|
|
49
|
+
// step 1: parse the fileUri to get the keyUri and JWE
|
|
50
|
+
// step 2: if keyUri and JWE are not present in the fileUri, use the options
|
|
51
|
+
// step 3: use the keyUri to decrypt the JWE to get the SCR
|
|
52
|
+
// step 4: download the file from the fileUri and decrypt it using the SCR
|
|
53
|
+
|
|
54
|
+
// Parse the fileUri & JWE to get the keyUri using urlSearchParams
|
|
55
|
+
const url = new URL(fileUri);
|
|
56
|
+
let keyUri = url.searchParams.get('keyUri');
|
|
57
|
+
let JWE = url.searchParams.get('JWE');
|
|
58
|
+
|
|
59
|
+
// Check if the keyUri and JWE are present, else take it from options
|
|
60
|
+
if (!keyUri || !JWE) {
|
|
61
|
+
keyUri = options.keyUri;
|
|
62
|
+
JWE = options.jwe;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Check if the keyUri and JWE are present, else throw an error
|
|
66
|
+
if (!keyUri || !JWE) {
|
|
67
|
+
throw new Error('KeyUri and JWE are required to decrypt the file. Either provide them in the fileUri or in the options.');
|
|
68
|
+
}
|
|
69
|
+
try {
|
|
70
|
+
// Decrypt the JWE to get the SCR
|
|
71
|
+
const scr = await this.$webex.internal.encryption.decryptScr(keyUri, JWE);
|
|
72
|
+
|
|
73
|
+
// Start the download and decryption process, returning a promise
|
|
74
|
+
|
|
75
|
+
return this.$webex.internal.encryption.download(fileUri, scr, {
|
|
76
|
+
useFileService
|
|
77
|
+
});
|
|
78
|
+
} catch (error) {
|
|
79
|
+
throw new Error(`Failed to decrypt the JWE: ${error.message}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
var _default = exports.default = Cypher;
|
|
84
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
null
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _webexCore = require("@webex/webex-core");
|
|
8
|
+
var _cypher = _interopRequireDefault(require("./cypher"));
|
|
9
|
+
var _config = _interopRequireDefault(require("./config"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
/* eslint-env browser */
|
|
12
|
+
|
|
13
|
+
(0, _webexCore.registerPlugin)('cypher', _cypher.default, {
|
|
14
|
+
config: _config.default
|
|
15
|
+
});
|
|
16
|
+
var _default = exports.default = _cypher.default;
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
null
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const CYPHER = "cypher";
|
|
2
|
+
export declare const DECRYPTION = "decryption";
|
|
3
|
+
export declare const DECRYPTION_FAILED = "decryptionFailed";
|
|
4
|
+
export declare const DECRYPTION_IN_PROGRESS = "decryptionInProgress";
|
|
5
|
+
export declare const DECRYPTION_SUCCESS = "decryptionSuccess";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for downloading a file with encryption.
|
|
3
|
+
*/
|
|
4
|
+
interface FileDownloadOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Indicates whether to use the file service for downloading.
|
|
7
|
+
* If true, the webex files service will be used.
|
|
8
|
+
* If false or undefined, the file will be downloaded directly from the URL.
|
|
9
|
+
*/
|
|
10
|
+
useFileService?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* The JSON Web Encryption (JWE) string used for decrypting the file.
|
|
13
|
+
* This is a required parameter if the url does not contain the JWE.
|
|
14
|
+
*/
|
|
15
|
+
jwe?: string;
|
|
16
|
+
/**
|
|
17
|
+
* The URI of the key used for decrypting the file.
|
|
18
|
+
* This is a required parameter if the url does not contain the keyUri.
|
|
19
|
+
*/
|
|
20
|
+
keyUri?: string;
|
|
21
|
+
}
|
|
22
|
+
interface IEncryption {
|
|
23
|
+
downloadAndDecryptFile(fileUri: string, options: FileDownloadOptions): Promise<ArrayBuffer>;
|
|
24
|
+
}
|
|
25
|
+
export type { IEncryption, FileDownloadOptions };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { WebexPlugin } from '@webex/webex-core';
|
|
2
|
+
import { FileDownloadOptions, IEncryption } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* @description Encryption APIs for KMS
|
|
5
|
+
* @class
|
|
6
|
+
*/
|
|
7
|
+
declare class Cypher extends WebexPlugin implements IEncryption {
|
|
8
|
+
readonly namespace = "cypher";
|
|
9
|
+
private readonly $webex;
|
|
10
|
+
registered: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Constructs an instance of the class.
|
|
13
|
+
*
|
|
14
|
+
* @param {...any[]} args - The arguments to pass to the superclass constructor.
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* This constructor calls the superclass constructor with the provided arguments.
|
|
18
|
+
* It also assigns the `webex` property to the `$webex` property, ignoring TypeScript errors.
|
|
19
|
+
*/
|
|
20
|
+
constructor(...args: any[]);
|
|
21
|
+
/**
|
|
22
|
+
* Registers the device to WDM. This is required for metrics and other services.
|
|
23
|
+
* @returns {Promise<void>}
|
|
24
|
+
*/
|
|
25
|
+
register(): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Deregisters the device.
|
|
28
|
+
* @returns {Promise<void>}
|
|
29
|
+
*/
|
|
30
|
+
deregister(): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Downloads and decrypts a file from the given URI.
|
|
33
|
+
*
|
|
34
|
+
* @param {string} fileUri - The URI of the file to be decrypted.
|
|
35
|
+
* @param {FileDownloadOptions} options - The options for file download.
|
|
36
|
+
* @returns {Promise<ArrayBuffer>} A promise that resolves to the decrypted ArrayBuffer.
|
|
37
|
+
* @throws {Error} If the file download or decryption fails.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const attachmentURL = 'https:/myfileurl.xyz/zzz/fileid?keyUri=somekeyuri&JWE=somejwe';
|
|
42
|
+
* const options: FileDownloadOptions = {
|
|
43
|
+
* useFileService: false,
|
|
44
|
+
* jwe: somejwe, // Provide the JWE here if not already present in the attachmentURL
|
|
45
|
+
* keyUri: someKeyUri, // Provide the keyURI here if not already present in the attachmentURL
|
|
46
|
+
* };
|
|
47
|
+
* const decryptedBuf = await webex.cypher.downloadAndDecryptFile(attachmentURL, options);
|
|
48
|
+
* const file = new File([decryptedBuf], "myFileName.jpeg", {type: 'image/jpeg'});
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
downloadAndDecryptFile(fileUri: string, { useFileService, ...options }?: FileDownloadOptions): Promise<ArrayBuffer>;
|
|
52
|
+
}
|
|
53
|
+
export default Cypher;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for downloading a file with encryption.
|
|
3
|
+
*/
|
|
4
|
+
interface FileDownloadOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Indicates whether to use the file service for downloading.
|
|
7
|
+
* If true, the webex files service will be used.
|
|
8
|
+
* If false or undefined, the file will be downloaded directly from the URL.
|
|
9
|
+
*/
|
|
10
|
+
useFileService?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* The JSON Web Encryption (JWE) string used for decrypting the file.
|
|
13
|
+
* This is a required parameter if the url does not contain the JWE.
|
|
14
|
+
*/
|
|
15
|
+
jwe?: string;
|
|
16
|
+
/**
|
|
17
|
+
* The URI of the key used for decrypting the file.
|
|
18
|
+
* This is a required parameter if the url does not contain the keyUri.
|
|
19
|
+
*/
|
|
20
|
+
keyUri?: string;
|
|
21
|
+
}
|
|
22
|
+
interface IEncryption {
|
|
23
|
+
downloadAndDecryptFile(fileUri: string, options: FileDownloadOptions): Promise<ArrayBuffer>;
|
|
24
|
+
}
|
|
25
|
+
export type { IEncryption, FileDownloadOptions };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const ENCRYPTION = "cypher";
|
|
2
|
+
export declare const DECRYPTION = "decryption";
|
|
3
|
+
export declare const DECRYPTION_FAILED = "decryptionFailed";
|
|
4
|
+
export declare const DECRYPTION_IN_PROGRESS = "decryptionInProgress";
|
|
5
|
+
export declare const DECRYPTION_SUCCESS = "decryptionSuccess";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for downloading a file with encryption.
|
|
3
|
+
*/
|
|
4
|
+
interface FileDownloadOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Indicates whether to use the file service for downloading.
|
|
7
|
+
* If true, the webex files service will be used.
|
|
8
|
+
* If false or undefined, the file will be downloaded directly from the URL.
|
|
9
|
+
*/
|
|
10
|
+
useFileService?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* The JSON Web Encryption (JWE) string used for decrypting the file.
|
|
13
|
+
* This is a required parameter if the url does not contain the JWE.
|
|
14
|
+
*/
|
|
15
|
+
jwe?: string;
|
|
16
|
+
/**
|
|
17
|
+
* The URI of the key used for decrypting the file.
|
|
18
|
+
* This is a required parameter if the url does not contain the keyUri.
|
|
19
|
+
*/
|
|
20
|
+
keyUri?: string;
|
|
21
|
+
}
|
|
22
|
+
interface IEncryption {
|
|
23
|
+
downloadAndDecryptFile(fileUri: string, options: FileDownloadOptions): Promise<ArrayBuffer>;
|
|
24
|
+
}
|
|
25
|
+
export type { IEncryption, FileDownloadOptions };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { WebexPlugin } from '@webex/webex-core';
|
|
2
|
+
import { FileDownloadOptions, IEncryption } from './encryption.types';
|
|
3
|
+
/**
|
|
4
|
+
* @description Encryption APIs for KMS
|
|
5
|
+
* @class
|
|
6
|
+
*/
|
|
7
|
+
declare class Cypher extends WebexPlugin implements IEncryption {
|
|
8
|
+
readonly namespace = "cypher";
|
|
9
|
+
private readonly $webex;
|
|
10
|
+
constructor(...args: any[]);
|
|
11
|
+
/**
|
|
12
|
+
* Downloads and decrypts a file from the given URI.
|
|
13
|
+
*
|
|
14
|
+
* @param {string} fileUri - The URI of the file to be decrypted.
|
|
15
|
+
* @param {FileDownloadOptions} options - The options for file download.
|
|
16
|
+
* @returns {Promise<ArrayBuffer>} A promise that resolves to the decrypted ArrayBuffer.
|
|
17
|
+
* @throws {Error} If the file download or decryption fails.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const decryptedBuf = await webex.cypher.downloadAndDecryptFile('https://example.com/encrypted-file?JWE=eyJhbGci&keyUri=kms://example.com/keys/1234', {useFileService: false});
|
|
22
|
+
* const file = new File([decryptedBuf], "myFileName.jpeg", {type: 'image/jpeg'});
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
downloadAndDecryptFile(fileUri: string, { useFileService, ...options }?: FileDownloadOptions): Promise<ArrayBuffer>;
|
|
26
|
+
}
|
|
27
|
+
export default Cypher;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logging related types
|
|
3
|
+
*/
|
|
4
|
+
export type Logger = {
|
|
5
|
+
log: (payload: string) => void;
|
|
6
|
+
error: (payload: string) => void;
|
|
7
|
+
warn: (payload: string) => void;
|
|
8
|
+
info: (payload: string) => void;
|
|
9
|
+
trace: (payload: string) => void;
|
|
10
|
+
debug: (payload: string) => void;
|
|
11
|
+
};
|
|
12
|
+
interface IWebexInternal {
|
|
13
|
+
mercury: {
|
|
14
|
+
connect: () => Promise<void>;
|
|
15
|
+
disconnect: () => Promise<void>;
|
|
16
|
+
};
|
|
17
|
+
device: {
|
|
18
|
+
register: () => Promise<void>;
|
|
19
|
+
unregister: () => Promise<void>;
|
|
20
|
+
};
|
|
21
|
+
encryption: {
|
|
22
|
+
decryptScr: (keyUri: string, jwe: string) => Promise<string>;
|
|
23
|
+
download: (fileUri: string, scr: string, options: {
|
|
24
|
+
useFileService: boolean;
|
|
25
|
+
}) => Promise<ArrayBuffer>;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export interface WebexSDK {
|
|
29
|
+
version: string;
|
|
30
|
+
canAuthorize: boolean;
|
|
31
|
+
credentials: {
|
|
32
|
+
getUserToken: () => Promise<string>;
|
|
33
|
+
getOrgId: () => string;
|
|
34
|
+
};
|
|
35
|
+
ready: boolean;
|
|
36
|
+
once: (event: string, callBack: () => void) => void;
|
|
37
|
+
internal: IWebexInternal;
|
|
38
|
+
logger: Logger;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
null
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const config = require('@webex/jest-config-legacy');
|
|
2
|
+
|
|
3
|
+
const jestConfig = {
|
|
4
|
+
rootDir: './',
|
|
5
|
+
transformIgnorePatterns: [],
|
|
6
|
+
testPathIgnorePatterns: ['/node_modules/', '/dist/'],
|
|
7
|
+
testResultsProcessor: 'jest-junit',
|
|
8
|
+
// Clear mocks in between tests by default
|
|
9
|
+
clearMocks: true,
|
|
10
|
+
collectCoverage: true,
|
|
11
|
+
coverageThreshold: {
|
|
12
|
+
global: {
|
|
13
|
+
lines: 85,
|
|
14
|
+
functions: 85,
|
|
15
|
+
branches: 85,
|
|
16
|
+
statements: 85,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
coverageDirectory: 'coverage',
|
|
20
|
+
coverageReporters: ['clover', 'json', 'lcov'],
|
|
21
|
+
reporters: [
|
|
22
|
+
'default',
|
|
23
|
+
[
|
|
24
|
+
'jest-junit',
|
|
25
|
+
{
|
|
26
|
+
outputDirectory: 'coverage/junit',
|
|
27
|
+
outputName: 'coverage-junit.xml',
|
|
28
|
+
classNameTemplate: '{classname}',
|
|
29
|
+
titleTemplate: '{title}',
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
[
|
|
33
|
+
'jest-html-reporters',
|
|
34
|
+
{
|
|
35
|
+
publicPath: './coverage',
|
|
36
|
+
filename: 'jest-report.html',
|
|
37
|
+
openReport: false,
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
],
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
module.exports = {...config, ...jestConfig};
|
|
44
|
+
|
package/junit.xml
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<testsuites name="jest tests" tests="11" failures="0" errors="0" time="2.132">
|
|
3
|
+
<testsuite name="Cypher" errors="0" failures="0" skipped="0" timestamp="2025-05-06T09:39:24" time="1.83" tests="11">
|
|
4
|
+
<testcase classname="Cypher downloadAndDecryptFile should throw an error if keyUri and JWE are not present in fileUri or options" name="Cypher downloadAndDecryptFile should throw an error if keyUri and JWE are not present in fileUri or options" time="0.015">
|
|
5
|
+
</testcase>
|
|
6
|
+
<testcase classname="Cypher downloadAndDecryptFile should use keyUri and JWE from options if not present in fileUri" name="Cypher downloadAndDecryptFile should use keyUri and JWE from options if not present in fileUri" time="0.003">
|
|
7
|
+
</testcase>
|
|
8
|
+
<testcase classname="Cypher downloadAndDecryptFile should decrypt and download the file successfully" name="Cypher downloadAndDecryptFile should decrypt and download the file successfully" time="0.003">
|
|
9
|
+
</testcase>
|
|
10
|
+
<testcase classname="Cypher downloadAndDecryptFile should throw an error if decryption fails" name="Cypher downloadAndDecryptFile should throw an error if decryption fails" time="0.002">
|
|
11
|
+
</testcase>
|
|
12
|
+
<testcase classname="Cypher downloadAndDecryptFile should throw an error if download fails" name="Cypher downloadAndDecryptFile should throw an error if download fails" time="0.002">
|
|
13
|
+
</testcase>
|
|
14
|
+
<testcase classname="Cypher register should register the device and connect to Mercury" name="Cypher register should register the device and connect to Mercury" time="0.003">
|
|
15
|
+
</testcase>
|
|
16
|
+
<testcase classname="Cypher register should log already registered message if device is already registered" name="Cypher register should log already registered message if device is already registered" time="0.002">
|
|
17
|
+
</testcase>
|
|
18
|
+
<testcase classname="Cypher register should log an error if device registration fails" name="Cypher register should log an error if device registration fails" time="0.004">
|
|
19
|
+
</testcase>
|
|
20
|
+
<testcase classname="Cypher deregister should deregister the device from WDM" name="Cypher deregister should deregister the device from WDM" time="0.002">
|
|
21
|
+
</testcase>
|
|
22
|
+
<testcase classname="Cypher deregister should log an error if device deregistration fails" name="Cypher deregister should log an error if device deregistration fails" time="0.002">
|
|
23
|
+
</testcase>
|
|
24
|
+
<testcase classname="Cypher deregister should not deregister if device is not registered" name="Cypher deregister should not deregister if device is not registered" time="0.004">
|
|
25
|
+
</testcase>
|
|
26
|
+
</testsuite>
|
|
27
|
+
</testsuites>
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@webex/plugin-encryption",
|
|
3
|
+
"description": "Encryption plugin for the Cisco Webex JS SDK",
|
|
4
|
+
"version": "3.8.0",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/webex/webex-js-sdk.git",
|
|
8
|
+
"directory": "packages/@webex/plugin-encryption"
|
|
9
|
+
},
|
|
10
|
+
"license": "https://github.com/webex/webex-js-sdk/blob/next/LICENSE.md",
|
|
11
|
+
"contributors": [
|
|
12
|
+
"Bharath Balan <bhabalan@cisco.com>"
|
|
13
|
+
],
|
|
14
|
+
"main": "dist/index.js",
|
|
15
|
+
"types": "dist/types/index.d.ts",
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "yarn run -T tsc --declaration true --declarationDir ./dist/types",
|
|
18
|
+
"build:docs": "typedoc --out ../../../docs/plugin-encrption",
|
|
19
|
+
"build:src": "webex-legacy-tools build -dest \"./dist\" -src \"./src\" -js -ts -maps && yarn build",
|
|
20
|
+
"deploy:npm": "yarn npm publish",
|
|
21
|
+
"test:browser": "webex-legacy-tools test --integration --runner karma",
|
|
22
|
+
"test:style": "eslint ./src/**/*.*",
|
|
23
|
+
"test:unit": "webex-legacy-tools test --unit --runner jest"
|
|
24
|
+
},
|
|
25
|
+
"browserify": {
|
|
26
|
+
"transform": [
|
|
27
|
+
"babelify",
|
|
28
|
+
"envify"
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@webex/internal-plugin-encryption": "0.0.0",
|
|
33
|
+
"@webex/webex-core": "0.0.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@babel/preset-typescript": "7.22.11",
|
|
37
|
+
"@types/jsdom": "^21",
|
|
38
|
+
"@webex/babel-config-legacy": "0.0.0",
|
|
39
|
+
"@webex/eslint-config-legacy": "0.0.0",
|
|
40
|
+
"@webex/jest-config-legacy": "0.0.0",
|
|
41
|
+
"@webex/legacy-tools": "0.0.0",
|
|
42
|
+
"@webex/test-helper-mock-webex": "0.0.0",
|
|
43
|
+
"eslint": "^8.24.0",
|
|
44
|
+
"jest-html-reporters": "3.0.11",
|
|
45
|
+
"jest-junit": "13.0.0",
|
|
46
|
+
"jsdom": "19.0.0",
|
|
47
|
+
"jsdom-global": "3.0.2",
|
|
48
|
+
"prettier": "^2.7.1",
|
|
49
|
+
"typed-emitter": "^2.1.0",
|
|
50
|
+
"typedoc": "0.23.26",
|
|
51
|
+
"typescript": "^4.9.5"
|
|
52
|
+
},
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=16"
|
|
55
|
+
},
|
|
56
|
+
"devMain": "src/index.js"
|
|
57
|
+
}
|
package/process
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = {browser: true};
|
package/src/config.ts
ADDED