Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ <h2 class="page-header">API Reference</h2>
<a href="./api" class="list-group-item">Meetings API Reference</a>
<a href="./calling" class="list-group-item">Calling API Reference</a>
<a href="./byods" class="list-group-item">BYoDS API Reference</a>
<a href="./plugin-encryption" class="list-group-item">Encryption API Reference</a>
</div>
</div>
<div class="col-md-4">
Expand Down
27 changes: 21 additions & 6 deletions packages/@webex/plugin-encryption/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

[![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)

> Encryption plugin for the Cisco Webex JS SDK.
# Encryption plugin for the Cisco Webex JS SDK

- [Install](#install)
- [Usage](#usage)
- [Development](#development)
- [API Docs and Sample App](#api-docs-and-sample-app)
- [Sample Code](#sample-code)
- [Contribute](#contribute)
- [Maintainers](#maintainers)
Expand All @@ -18,9 +18,24 @@
npm install --save @webex/plugin-encryption
```

In addition to the module consumption via NPMJS, this module can also be consumed via our CDN. See the below examples of how to consume this via CDN:

```html
<html>
<head>
<!-- via unpkg -->
<script crossorigin src="https://unpkg.com/webex@latest/umd/encryption.min.js"></script>

<!-- via jsdelivr -->
<script crossorigin src="https://cdn.jsdelivr.net/npm/webex/umd/encryption.min.js"></script>
</head>
<!-- ...application html... -->
</html>
```

## Usage

This is a plugin for the Cisco Webex JS SDK . Please see our [developer portal](https://developer.webex.com/) and the [API reference](https://webex.github.io/webex-js-sdk/plugin-encryption/) for full details.
This is a plugin for the Cisco Webex JS SDK. Please see our [developer portal](https://developer.webex.com/) and the [API reference](https://webex.github.io/webex-js-sdk/plugin-encryption/) for full details.

## API Docs and Sample App

Expand All @@ -31,7 +46,7 @@ This is a plugin for the Cisco Webex JS SDK . Please see our [developer portal](
## Sample Code

```typescript
import Webex from 'webex/plugin-encryption';
import Webex from '@webex/plugin-encryption';

const webex = Webex.init({
credentials: {
Expand All @@ -40,7 +55,7 @@ const webex = Webex.init({
});

webex.once('ready', () => {
webex.cypher.register().then(() => {
webex.cypher.register().then(async () => {
try {
const attachmentURL = 'https:/myfileurl.xyz/zzz/fileid?keyUri=somekeyuri&JWE=somejwe';
const options = {
Expand All @@ -63,7 +78,7 @@ webex.cypher.deregister().then(() => {
});
```

#### Development
## Development

To use `webpack-dev-server` to load this package, run `yarn run samples:serve`.

Expand Down
18 changes: 10 additions & 8 deletions packages/@webex/plugin-encryption/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
module.exports = {
"presets": [
plugins: ['@webex/babel-config-legacy/inject-package-version'],
presets: [
[
"@babel/preset-env",
'@babel/preset-env',
{
"targets": {
"node": "current"
}
}
targets: {
node: 'current',
},
},
],
"@babel/preset-typescript"
'@babel/preset-typescript',
],
}
sourceMaps: true,
};
20 changes: 8 additions & 12 deletions packages/@webex/plugin-encryption/developer-quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,27 +71,23 @@ async function decryptFile(webex, encryptedFileUrl, options, decryptedFileName,
console.error('Error decrypting file:', error);
}
}

const attachmentURL = 'https:/myfileurl.xyz/zzz/fileid?keyUri=somekeyuri&JWE=somejwe';
const options = {
useFileService: false,
jwe: somejwe, // Provide the JWE here if not already present in the attachmentURL
keyUri: someKeyUri // Provide the keyURI here if not already present in the attachmentURL
};

await decryptFile(webex, attachmentURL, options, 'MyFile.png', 'image/png');
```

### Example Usage

```typescript
const accessToken = 'YOUR_ACCESS_TOKEN';
const encryptedFileUrl = 'https://example.com/encrypted-file';
const attachmentURL = 'https://myfileurl.xyz/zzz/fileid?keyUri=somekeyuri&JWE=somejwe';
const decryptedFileName = 'my-decrypted-file.jpeg';
const mimeType = 'image/jpeg';
const options = {
useFileService: false,
jwe: somejwe, // Provide the JWE here if not already present in the attachmentURL
keyUri: someKeyUri // Provide the keyURI here if not already present in the attachmentURL
};

initializeWebex(accessToken).then((webex) => {
decryptFile(webex, encryptedFileUrl, decryptedFileName, mimeType);
initializeWebex(accessToken).then(async (webex) => {
await decryptFile(webex, attachmentURL, options, decryptedFileName, mimeType);
});
```

Expand Down
4 changes: 3 additions & 1 deletion packages/@webex/plugin-encryption/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ const config = require('@webex/jest-config-legacy');

const jestConfig = {
rootDir: './',
transformIgnorePatterns: [],
transformIgnorePatterns: [
'/node_modules/(?!(uuid)/)', // Transform `uuid` using Babel
],
testPathIgnorePatterns: ['/node_modules/', '/dist/'],
testResultsProcessor: 'jest-junit',
// Clear mocks in between tests by default
Expand Down
21 changes: 16 additions & 5 deletions packages/@webex/plugin-encryption/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,25 @@
},
"license": "https://github.com/webex/webex-js-sdk/blob/next/LICENSE.md",
"contributors": [
"Bharath Balan <[email protected]>"
"Adhwaith Menon <[email protected]>",
"Bharath Balan <[email protected]>",
"Kesava Krishnan Madavan <[email protected]>",
"Priya Kesari <[email protected]>",
"Rajesh Kumar <[email protected]>",
"Ravi Chandra Sekhar Sarika <[email protected]>",
"Shreyas Sharma <[email protected]>",
"Sreekanth Narayanan <[email protected]>"
],
"main": "dist/index.js",
"main": "dist/webex.js",
"devMain": "src/index.ts",
"exports": {
".": "./dist/webex.js",
"./package": "./package.json"
},
"types": "dist/types/index.d.ts",
"scripts": {
"build": "yarn run -T tsc --declaration true --declarationDir ./dist/types",
"build:docs": "typedoc --out ../../../docs/plugin-encrption",
"build:docs": "typedoc --out ../../../docs/plugin-encryption",
"build:src": "webex-legacy-tools build -dest \"./dist\" -src \"./src\" -js -ts -maps && yarn build",
"deploy:npm": "yarn npm publish",
"test:browser": "webex-legacy-tools test --integration --runner karma",
Expand Down Expand Up @@ -51,6 +63,5 @@
},
"engines": {
"node": ">=16"
},
"devMain": "src/index.js"
}
}
15 changes: 15 additions & 0 deletions packages/@webex/plugin-encryption/src/webex-config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {MemoryStoreAdapter} from '@webex/webex-core';

export default {
hydra: process.env.HYDRA_SERVICE_URL || 'https://api.ciscospark.com/v1',
hydraServiceUrl: process.env.HYDRA_SERVICE_URL || 'https://api.ciscospark.com/v1',
credentials: {},
device: {
validateDomains: true,
ephemeral: true,
},
storage: {
boundedAdapter: MemoryStoreAdapter,
unboundedAdapter: MemoryStoreAdapter,
},
};
35 changes: 35 additions & 0 deletions packages/@webex/plugin-encryption/src/webex.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*!
* Copyright (c) 2015-2025 Cisco Systems, Inc. See the LICENSE file.
*/

// Note: this file is written using commonjs instead of import/export to
// simplify consumption by those less familiar with the current state of
// JavaScript modularization

/* istanbul ignore else */
if (!global._babelPolyfill) {
/* eslint global-require: [0] */
require('@babel/polyfill');
}

require('@webex/plugin-authorization');
require('@webex/internal-plugin-encryption'); // required
require('./index');

const merge = require('lodash/merge');
const WebexCore = require('@webex/webex-core').default;

const config = require('./webex-config');

const Webex = WebexCore.extend({
webex: true,
version: PACKAGE_VERSION,
});

Webex.init = function init(attrs = {}) {
attrs.config = merge({}, config, attrs.config); // eslint-disable-line no-param-reassign

return new Webex(attrs);
};

module.exports = Webex;
1 change: 1 addition & 0 deletions packages/webex-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"@webex/plugin-attachment-actions": "workspace:*",
"@webex/plugin-authorization": "workspace:*",
"@webex/plugin-device-manager": "workspace:*",
"@webex/plugin-encryption": "workspace:*",
"@webex/plugin-logger": "workspace:*",
"@webex/plugin-memberships": "workspace:*",
"@webex/plugin-messages": "workspace:*",
Expand Down
1 change: 1 addition & 0 deletions packages/webex-node/src/webex-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ require('@webex/plugin-rooms');
require('@webex/plugin-teams');
require('@webex/plugin-team-memberships');
require('@webex/plugin-webhooks');
require('@webex/plugin-encryption');

const merge = require('lodash/merge');
const WebexCore = require('@webex/webex-core').default;
Expand Down
1 change: 0 additions & 1 deletion packages/webex/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"exports": {
"./calling": "./dist/calling.js",
".": "./dist/index.js",
"./encryption": "./dist/encryption.js",
"./meetings": "./dist/meetings.js",
"./package": "./package.json"
},
Expand Down
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module.exports = (env = {NODE_ENV: process.env.NODE_ENV || 'production'}) => ({
},
},
encryption: {
import: `${path.resolve(__dirname)}/packages/webex/src/encryption.js`,
import: `${path.resolve(__dirname)}/packages/@webex/plugin-encryption/src/webex.js`,
library: {
name: 'Webex',
type: 'umd',
Expand Down
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -34211,6 +34211,7 @@ __metadata:
"@webex/plugin-attachment-actions": "workspace:*"
"@webex/plugin-authorization": "workspace:*"
"@webex/plugin-device-manager": "workspace:*"
"@webex/plugin-encryption": "workspace:*"
"@webex/plugin-logger": "workspace:*"
"@webex/plugin-memberships": "workspace:*"
"@webex/plugin-messages": "workspace:*"
Expand Down
Loading