Skip to content

Commit 96bb498

Browse files
brichetafshin
andauthored
Isolate secrets from others extensions (#13)
* Requires plugin to 'sign' to the secrets manager to be able to use a secrets namespace * Connector must be set to the manager, instead of providing a token * Add dependency to @jupyterlab/coreutils * Export the SecretsManager * Apply suggestions from code review Co-authored-by: Afshin Taylor Darian <git@darian.link> * Wait for the connector to be provided before any action * Avoid confusion between namespace and id when retrieving the full secret ID ('namespace:id') * Move the connector getter/setter in private namespace * Update comments * Set detach method as async * Better handling of the promise delegate * Make the inputs less discovarable --------- Co-authored-by: Afshin Taylor Darian <git@darian.link>
1 parent 1a6272c commit 96bb498

File tree

5 files changed

+284
-107
lines changed

5 files changed

+284
-107
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
},
5858
"dependencies": {
5959
"@jupyterlab/application": "^4.0.0",
60+
"@jupyterlab/coreutils": "^6.0.0",
6061
"@jupyterlab/statedb": "^4.0.0",
6162
"@lumino/algorithm": "^2.0.0",
6263
"@lumino/coreutils": "^2.1.2"

src/index.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ import {
33
JupyterFrontEndPlugin
44
} from '@jupyterlab/application';
55
import { SecretsManager } from './manager';
6-
import { ISecretsConnector, ISecretsManager } from './token';
6+
import { ISecretsManager } from './token';
77
import { InMemoryConnector } from './connectors';
88

99
/**
1010
* A basic secret connector extension, that should be disabled to provide a new
1111
* connector.
1212
*/
13-
const inMemoryConnector: JupyterFrontEndPlugin<ISecretsConnector> = {
13+
const inMemoryConnector: JupyterFrontEndPlugin<void> = {
1414
id: 'jupyter-secrets-manager:connector',
1515
description: 'A JupyterLab extension to manage secrets.',
1616
autoStart: true,
17-
provides: ISecretsConnector,
18-
activate: (app: JupyterFrontEnd): ISecretsConnector => {
19-
return new InMemoryConnector();
17+
requires: [ISecretsManager],
18+
activate: (app: JupyterFrontEnd, manager: ISecretsManager): void => {
19+
manager.setConnector(new InMemoryConnector());
2020
}
2121
};
2222

@@ -28,16 +28,13 @@ const manager: JupyterFrontEndPlugin<ISecretsManager> = {
2828
description: 'A JupyterLab extension to manage secrets.',
2929
autoStart: true,
3030
provides: ISecretsManager,
31-
requires: [ISecretsConnector],
32-
activate: (
33-
app: JupyterFrontEnd,
34-
connector: ISecretsConnector
35-
): ISecretsManager => {
31+
activate: (app: JupyterFrontEnd): ISecretsManager => {
3632
console.log('JupyterLab extension jupyter-secrets-manager is activated!');
37-
return new SecretsManager({ connector });
33+
return new SecretsManager();
3834
}
3935
};
4036

4137
export * from './connectors';
38+
export * from './manager';
4239
export * from './token';
4340
export default [inMemoryConnector, manager];

0 commit comments

Comments
 (0)