@olane/o-tools-common 0.1.6 → 0.2.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/dist/encryption/encryption.tool.d.ts +9 -0
- package/dist/encryption/encryption.tool.d.ts.map +1 -0
- package/dist/encryption/encryption.tool.js +31 -0
- package/dist/encryption/index.d.ts +2 -0
- package/dist/encryption/index.d.ts.map +1 -0
- package/dist/encryption/index.js +1 -0
- package/dist/encryption/lib/encryption.d.ts.map +1 -0
- package/dist/encryption/methods/encryption.methods.d.ts +5 -0
- package/dist/encryption/methods/encryption.methods.d.ts.map +1 -0
- package/dist/encryption/methods/encryption.methods.js +30 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/init.d.ts +4 -4
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +5 -5
- package/dist/plan/encrypted-plan-storage.tool.d.ts +11 -0
- package/dist/plan/encrypted-plan-storage.tool.d.ts.map +1 -0
- package/dist/plan/encrypted-plan-storage.tool.js +10 -0
- package/dist/registry/registry-memory.tool.d.ts +1 -0
- package/dist/registry/registry-memory.tool.d.ts.map +1 -1
- package/dist/registry/registry-memory.tool.js +7 -0
- package/dist/registry/registry.tool.d.ts +1 -0
- package/dist/registry/registry.tool.d.ts.map +1 -1
- package/dist/storage/index.d.ts +1 -0
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +1 -0
- package/dist/storage/providers/disk-storage-provider.tool.d.ts +2 -2
- package/dist/storage/providers/disk-storage-provider.tool.d.ts.map +1 -1
- package/dist/storage/providers/secure-storage-provider.tool.d.ts +25 -0
- package/dist/storage/providers/secure-storage-provider.tool.d.ts.map +1 -0
- package/dist/storage/providers/secure-storage-provider.tool.js +71 -0
- package/dist/storage/storage.tool.d.ts.map +1 -1
- package/dist/storage/storage.tool.js +7 -2
- package/package.json +10 -20
- package/dist/vault/index.d.ts +0 -2
- package/dist/vault/index.d.ts.map +0 -1
- package/dist/vault/index.js +0 -1
- package/dist/vault/lib/encryption.d.ts.map +0 -1
- package/dist/vault/methods/vault.methods.d.ts +0 -5
- package/dist/vault/methods/vault.methods.d.ts.map +0 -1
- package/dist/vault/methods/vault.methods.js +0 -37
- package/dist/vault/vault.tool.d.ts +0 -10
- package/dist/vault/vault.tool.d.ts.map +0 -1
- package/dist/vault/vault.tool.js +0 -36
- /package/dist/{vault → encryption}/lib/encryption.d.ts +0 -0
- /package/dist/{vault → encryption}/lib/encryption.js +0 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { oToolConfig, oVirtualTool, ToolResult } from '@olane/o-tool';
|
|
2
|
+
import { oRequest } from '@olane/o-core';
|
|
3
|
+
export declare class EncryptionTool extends oVirtualTool {
|
|
4
|
+
private encryptionService;
|
|
5
|
+
constructor(config: oToolConfig);
|
|
6
|
+
_tool_encrypt(request: oRequest): Promise<ToolResult>;
|
|
7
|
+
_tool_decrypt(request: oRequest): Promise<ToolResult>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=encryption.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encryption.tool.d.ts","sourceRoot":"","sources":["../../src/encryption/encryption.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAY,QAAQ,EAAE,MAAM,eAAe,CAAC;AAInD,qBAAa,cAAe,SAAQ,YAAY;IAC9C,OAAO,CAAC,iBAAiB,CAAoB;gBAEjC,MAAM,EAAE,WAAW;IAUzB,aAAa,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAWrD,aAAa,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;CAU5D"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { oVirtualTool } from '@olane/o-tool';
|
|
2
|
+
import { oAddress } from '@olane/o-core';
|
|
3
|
+
import { EncryptionService } from './lib/encryption.js';
|
|
4
|
+
import { ENCRYPTION_PARAMS } from './methods/encryption.methods.js';
|
|
5
|
+
export class EncryptionTool extends oVirtualTool {
|
|
6
|
+
constructor(config) {
|
|
7
|
+
super({
|
|
8
|
+
...config,
|
|
9
|
+
address: new oAddress('o://encryption'),
|
|
10
|
+
methods: ENCRYPTION_PARAMS,
|
|
11
|
+
description: 'Tool to encrypt and decrypt sensitive data',
|
|
12
|
+
});
|
|
13
|
+
this.encryptionService = new EncryptionService(process.env.VAULT_KEY);
|
|
14
|
+
}
|
|
15
|
+
async _tool_encrypt(request) {
|
|
16
|
+
const params = request.params;
|
|
17
|
+
const { value } = params;
|
|
18
|
+
const encryptedValue = await this.encryptionService.encryptToBase64(value);
|
|
19
|
+
return {
|
|
20
|
+
value: encryptedValue,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
async _tool_decrypt(request) {
|
|
24
|
+
const params = request.params;
|
|
25
|
+
const { value } = params;
|
|
26
|
+
const decryptedValue = await this.encryptionService.decryptFromBase64(value);
|
|
27
|
+
return {
|
|
28
|
+
value: decryptedValue,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/encryption/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './encryption.tool.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encryption.d.ts","sourceRoot":"","sources":["../../../src/encryption/lib/encryption.ts"],"names":[],"mappings":"AAGA,UAAU,aAAa;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;CACb;AAUD,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmB;IAC1C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;gBAEvB,SAAS,CAAC,EAAE,MAAM;IAoB9B;;;;OAIG;IACU,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IA+B/D;;;;OAIG;IACU,OAAO,CAAC,aAAa,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IA4BnE;;;;OAIG;IACU,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAMhE;;;;OAIG;IACU,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAYnE;;;OAGG;WACW,iBAAiB,IAAI,MAAM;CAG1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encryption.methods.d.ts","sourceRoot":"","sources":["../../../src/encryption/methods/encryption.methods.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,eAAO,MAAM,iBAAiB,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CA6BvD,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export const ENCRYPTION_PARAMS = {
|
|
2
|
+
encrypt: {
|
|
3
|
+
name: 'encrypt',
|
|
4
|
+
description: 'Encrypt value prior to storing in the vault',
|
|
5
|
+
dependencies: [],
|
|
6
|
+
parameters: [
|
|
7
|
+
{
|
|
8
|
+
name: 'value',
|
|
9
|
+
type: 'string',
|
|
10
|
+
value: 'string',
|
|
11
|
+
description: 'The value to encrypt',
|
|
12
|
+
required: true,
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
decrypt: {
|
|
17
|
+
name: 'decrypt',
|
|
18
|
+
description: 'Decrypt value prior to retrieving from the vault',
|
|
19
|
+
dependencies: [],
|
|
20
|
+
parameters: [
|
|
21
|
+
{
|
|
22
|
+
name: 'value',
|
|
23
|
+
type: 'string',
|
|
24
|
+
value: 'string',
|
|
25
|
+
description: 'The value to decrypt',
|
|
26
|
+
required: true,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
};
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/init.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { RegistryMemoryTool } from './registry/registry-memory.tool.js';
|
|
2
|
-
import { oNode } from '@olane/o-core';
|
|
3
2
|
import { StorageTool } from './storage/index.js';
|
|
4
|
-
import { VaultTool } from './vault/vault.tool.js';
|
|
5
3
|
import { SearchTool } from './search/search.tool.js';
|
|
6
4
|
import { SetupTool } from './setup/setup.tool.js';
|
|
7
|
-
import {
|
|
8
|
-
|
|
5
|
+
import { EncryptionTool } from './encryption/encryption.tool.js';
|
|
6
|
+
import { EncryptedPlanStorageTool } from './plan/encrypted-plan-storage.tool.js';
|
|
7
|
+
import { oHostNodeTool, oVirtualTool } from '@olane/o-tool';
|
|
8
|
+
export declare const initCommonTools: (oNode: oVirtualTool | oHostNodeTool) => (RegistryMemoryTool | StorageTool | SearchTool | SetupTool | EncryptionTool | EncryptedPlanStorageTool)[];
|
|
9
9
|
//# sourceMappingURL=init.d.ts.map
|
package/dist/init.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAExE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE5D,eAAO,MAAM,eAAe,UAAW,YAAY,GAAG,aAAa,8GAoClE,CAAC"}
|
package/dist/init.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { RegistryMemoryTool } from './registry/registry-memory.tool.js';
|
|
2
2
|
import { oAddress } from '@olane/o-core';
|
|
3
3
|
import { StorageTool } from './storage/index.js';
|
|
4
|
-
import { VaultTool } from './vault/vault.tool.js';
|
|
5
4
|
import { SearchTool } from './search/search.tool.js';
|
|
6
5
|
import { SetupTool } from './setup/setup.tool.js';
|
|
7
|
-
import {
|
|
6
|
+
import { EncryptionTool } from './encryption/encryption.tool.js';
|
|
7
|
+
import { EncryptedPlanStorageTool } from './plan/encrypted-plan-storage.tool.js';
|
|
8
8
|
export const initCommonTools = (oNode) => {
|
|
9
9
|
const params = {
|
|
10
10
|
parent: oNode.address,
|
|
@@ -19,8 +19,8 @@ export const initCommonTools = (oNode) => {
|
|
|
19
19
|
name: 'storage',
|
|
20
20
|
...params,
|
|
21
21
|
}),
|
|
22
|
-
new
|
|
23
|
-
name: '
|
|
22
|
+
new EncryptionTool({
|
|
23
|
+
name: 'encryption',
|
|
24
24
|
...params,
|
|
25
25
|
}),
|
|
26
26
|
new SearchTool({
|
|
@@ -31,7 +31,7 @@ export const initCommonTools = (oNode) => {
|
|
|
31
31
|
name: 'setup',
|
|
32
32
|
...params,
|
|
33
33
|
}),
|
|
34
|
-
new
|
|
34
|
+
new EncryptedPlanStorageTool({
|
|
35
35
|
name: 'plan',
|
|
36
36
|
address: new oAddress('o://plan'),
|
|
37
37
|
...params,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { oAddress } from '@olane/o-core';
|
|
2
|
+
import { oToolConfig } from '@olane/o-tool';
|
|
3
|
+
import { SecureStorageProvider } from '../storage/index.js';
|
|
4
|
+
declare const EncryptedPlanStorageTool_base: typeof SecureStorageProvider & (new (...args: any[]) => any);
|
|
5
|
+
export declare class EncryptedPlanStorageTool extends EncryptedPlanStorageTool_base {
|
|
6
|
+
constructor(config: oToolConfig & {
|
|
7
|
+
address: oAddress;
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=encrypted-plan-storage.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encrypted-plan-storage.tool.d.ts","sourceRoot":"","sources":["../../src/plan/encrypted-plan-storage.tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;;AAM5D,qBAAa,wBAAyB,SAAQ,6BAE7C;gBACa,MAAM,EAAE,WAAW,GAAG;QAAE,OAAO,EAAE,QAAQ,CAAA;KAAE;CAMxD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { oPlanStorageTool } from './plan-storage.tool.js';
|
|
2
|
+
import { SecureStorageProvider } from '../storage/index.js';
|
|
3
|
+
export class EncryptedPlanStorageTool extends oPlanStorageTool(SecureStorageProvider) {
|
|
4
|
+
constructor(config) {
|
|
5
|
+
super({
|
|
6
|
+
...config,
|
|
7
|
+
description: 'Encrypted disk-based plan storage for the network',
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -4,5 +4,6 @@ export declare class RegistryMemoryTool extends RegistryTool {
|
|
|
4
4
|
_tool_commit(request: oRequest): Promise<any>;
|
|
5
5
|
_tool_find_all(request: oRequest): Promise<any>;
|
|
6
6
|
_tool_search(request: oRequest): Promise<any>;
|
|
7
|
+
_tool_remove(request: oRequest): Promise<any>;
|
|
7
8
|
}
|
|
8
9
|
//# sourceMappingURL=registry-memory.tool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry-memory.tool.d.ts","sourceRoot":"","sources":["../../src/registry/registry-memory.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,qBAAa,kBAAmB,SAAQ,YAAY;IAC5C,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IAuB7C,cAAc,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IAI/C,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"registry-memory.tool.d.ts","sourceRoot":"","sources":["../../src/registry/registry-memory.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,qBAAa,kBAAmB,SAAQ,YAAY;IAC5C,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IAuB7C,cAAc,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IAI/C,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IA8B7C,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;CAOpD"}
|
|
@@ -8,5 +8,6 @@ export declare abstract class RegistryTool extends oVirtualTool {
|
|
|
8
8
|
abstract _tool_commit(request: oRequest): Promise<ToolResult>;
|
|
9
9
|
abstract _tool_search(request: oRequest): Promise<ToolResult>;
|
|
10
10
|
abstract _tool_find_all(request: oRequest): Promise<ToolResult>;
|
|
11
|
+
abstract _tool_remove(request: oRequest): Promise<ToolResult>;
|
|
11
12
|
}
|
|
12
13
|
//# sourceMappingURL=registry.tool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.tool.d.ts","sourceRoot":"","sources":["../../src/registry/registry.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAY,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGnD,8BAAsB,YAAa,SAAQ,YAAY;IACrD,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAa;IAC1E,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAa;gBAE1D,MAAM,EAAE,WAAW;IAS/B,QAAQ,CAAC,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAC7D,QAAQ,CAAC,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAC7D,QAAQ,CAAC,cAAc,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"registry.tool.d.ts","sourceRoot":"","sources":["../../src/registry/registry.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAY,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGnD,8BAAsB,YAAa,SAAQ,YAAY;IACrD,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAa;IAC1E,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAa;gBAE1D,MAAM,EAAE,WAAW;IAS/B,QAAQ,CAAC,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAC7D,QAAQ,CAAC,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAC7D,QAAQ,CAAC,cAAc,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAC/D,QAAQ,CAAC,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;CAC9D"}
|
package/dist/storage/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './storage.tool.js';
|
|
2
2
|
export * from './providers/memory-storage-provider.tool.js';
|
|
3
3
|
export * from './providers/disk-storage-provider.tool.js';
|
|
4
|
+
export * from './providers/secure-storage-provider.tool.js';
|
|
4
5
|
export * from './providers/storage-provider.tool.js';
|
|
5
6
|
export * from './interfaces/index.js';
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,6CAA6C,CAAC;AAC5D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,sCAAsC,CAAC;AACrD,cAAc,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,6CAA6C,CAAC;AAC5D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,6CAA6C,CAAC;AAC5D,cAAc,sCAAsC,CAAC;AACrD,cAAc,uBAAuB,CAAC"}
|
package/dist/storage/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './storage.tool.js';
|
|
2
2
|
export * from './providers/memory-storage-provider.tool.js';
|
|
3
3
|
export * from './providers/disk-storage-provider.tool.js';
|
|
4
|
+
export * from './providers/secure-storage-provider.tool.js';
|
|
4
5
|
export * from './providers/storage-provider.tool.js';
|
|
5
6
|
export * from './interfaces/index.js';
|
|
@@ -12,11 +12,11 @@ export declare class DiskStorageProvider extends StorageProviderTool {
|
|
|
12
12
|
/**
|
|
13
13
|
* Ensure the storage directory exists
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
protected ensureStorageDir(): Promise<void>;
|
|
16
16
|
/**
|
|
17
17
|
* Get the file path for a given key
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
protected getFilePath(key: string): string;
|
|
20
20
|
/**
|
|
21
21
|
* Store data on disk
|
|
22
22
|
* @param key The key to store the data under
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"disk-storage-provider.tool.d.ts","sourceRoot":"","sources":["../../../src/storage/providers/disk-storage-provider.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAuB,QAAQ,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAIxE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAGrE,UAAU,iBAAkB,SAAQ,WAAW;IAC7C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,QAAQ,CAAC;CACpB;AAOD,qBAAa,mBAAoB,SAAQ,mBAAmB;IAC1D,OAAO,CAAC,UAAU,CAAS;gBAEf,MAAM,EAAE,iBAAiB;IAYrC;;OAEG;
|
|
1
|
+
{"version":3,"file":"disk-storage-provider.tool.d.ts","sourceRoot":"","sources":["../../../src/storage/providers/disk-storage-provider.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAuB,QAAQ,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAIxE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAGrE,UAAU,iBAAkB,SAAQ,WAAW;IAC7C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,QAAQ,CAAC;CACpB;AAOD,qBAAa,mBAAoB,SAAQ,mBAAmB;IAC1D,OAAO,CAAC,UAAU,CAAS;gBAEf,MAAM,EAAE,iBAAiB;IAYrC;;OAEG;cACa,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAQjD;;OAEG;IACH,SAAS,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAM1C;;;;OAIG;IACG,SAAS,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IA0BvD;;;;OAIG;IACG,SAAS,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,eAAe,CAAC;IAW5D;;;OAGG;IACG,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAyB1D;;;;OAIG;IACG,SAAS,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;CAyBxD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { oToolConfig, ToolResult } from '@olane/o-tool';
|
|
2
|
+
import { oAddress, oRequest } from '@olane/o-core';
|
|
3
|
+
import { GetDataResponse } from '../interfaces/get-data.response.js';
|
|
4
|
+
import { DiskStorageProvider } from './disk-storage-provider.tool.js';
|
|
5
|
+
interface DiskStorageConfig extends oToolConfig {
|
|
6
|
+
storageDir?: string;
|
|
7
|
+
address?: oAddress;
|
|
8
|
+
}
|
|
9
|
+
export declare class SecureStorageProvider extends DiskStorageProvider {
|
|
10
|
+
constructor(config: DiskStorageConfig);
|
|
11
|
+
/**
|
|
12
|
+
* Store data on disk
|
|
13
|
+
* @param key The key to store the data under
|
|
14
|
+
* @param value The data to store
|
|
15
|
+
*/
|
|
16
|
+
_tool_put(request: oRequest): Promise<ToolResult>;
|
|
17
|
+
/**
|
|
18
|
+
* Retrieve data from disk
|
|
19
|
+
* @param key The key to retrieve
|
|
20
|
+
* @returns The stored data or null if not found
|
|
21
|
+
*/
|
|
22
|
+
_tool_get(request: oRequest): Promise<GetDataResponse>;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=secure-storage-provider.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secure-storage-provider.tool.d.ts","sourceRoot":"","sources":["../../../src/storage/providers/secure-storage-provider.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAExD,OAAO,EAAuB,QAAQ,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAIxE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAGtE,UAAU,iBAAkB,SAAQ,WAAW;IAC7C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,QAAQ,CAAC;CACpB;AAOD,qBAAa,qBAAsB,SAAQ,mBAAmB;gBAChD,MAAM,EAAE,iBAAiB;IAQrC;;;;OAIG;IACG,SAAS,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAoCvD;;;;OAIG;IACG,SAAS,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,eAAe,CAAC;CAsB7D"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { oAddress } from '@olane/o-core';
|
|
2
|
+
import fs from 'fs/promises';
|
|
3
|
+
import { STORAGE_PARAMS } from '../methods/storage.methods.js';
|
|
4
|
+
import { DiskStorageProvider } from './disk-storage-provider.tool.js';
|
|
5
|
+
export class SecureStorageProvider extends DiskStorageProvider {
|
|
6
|
+
constructor(config) {
|
|
7
|
+
super({
|
|
8
|
+
...config,
|
|
9
|
+
address: config.address || new oAddress('o://secure-storage'),
|
|
10
|
+
methods: STORAGE_PARAMS,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Store data on disk
|
|
15
|
+
* @param key The key to store the data under
|
|
16
|
+
* @param value The data to store
|
|
17
|
+
*/
|
|
18
|
+
async _tool_put(request) {
|
|
19
|
+
try {
|
|
20
|
+
await this.ensureStorageDir();
|
|
21
|
+
const { key, value } = request.params;
|
|
22
|
+
const filePath = this.getFilePath(key);
|
|
23
|
+
// encrypt the value
|
|
24
|
+
const response = await this.use(new oAddress('o://encryption'), {
|
|
25
|
+
method: 'encrypt',
|
|
26
|
+
params: {
|
|
27
|
+
value: value,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
const { value: encryptedValue } = response.result.data;
|
|
31
|
+
// Store the data as JSON with metadata
|
|
32
|
+
const data = {
|
|
33
|
+
value: encryptedValue,
|
|
34
|
+
timestamp: new Date().toISOString(),
|
|
35
|
+
key: key,
|
|
36
|
+
};
|
|
37
|
+
await fs.writeFile(filePath, JSON.stringify(data, null, 2), 'utf8');
|
|
38
|
+
return {
|
|
39
|
+
success: true,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
return {
|
|
44
|
+
success: false,
|
|
45
|
+
error: `Failed to store data: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Retrieve data from disk
|
|
51
|
+
* @param key The key to retrieve
|
|
52
|
+
* @returns The stored data or null if not found
|
|
53
|
+
*/
|
|
54
|
+
async _tool_get(request) {
|
|
55
|
+
const { key } = request.params;
|
|
56
|
+
const filePath = this.getFilePath(key);
|
|
57
|
+
const fileContent = await fs.readFile(filePath, 'utf8');
|
|
58
|
+
const { value } = JSON.parse(fileContent);
|
|
59
|
+
// decrypt the value
|
|
60
|
+
const response = await this.use(new oAddress('o://encryption'), {
|
|
61
|
+
method: 'decrypt',
|
|
62
|
+
params: {
|
|
63
|
+
value: value,
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
const { value: decryptedValue } = response.result.data;
|
|
67
|
+
return {
|
|
68
|
+
value: decryptedValue,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.tool.d.ts","sourceRoot":"","sources":["../../src/storage/storage.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,QAAQ,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"storage.tool.d.ts","sourceRoot":"","sources":["../../src/storage/storage.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,QAAQ,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAGpE,qBAAa,WAAY,SAAQ,mBAAmB;gBACtC,MAAM,EAAE,WAAW;IA4BzB,SAAS,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAKjD,SAAS,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,eAAe,CAAC;IAItD,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAIpD,SAAS,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;CAGxD"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { oAddress } from '@olane/o-core';
|
|
2
2
|
import { DiskStorageProvider } from './providers/disk-storage-provider.tool.js';
|
|
3
3
|
import { MemoryStorageProvider } from './providers/memory-storage-provider.tool.js';
|
|
4
4
|
import { StorageProviderTool } from './providers/storage-provider.tool.js';
|
|
5
|
+
import { SecureStorageProvider } from './providers/secure-storage-provider.tool.js';
|
|
5
6
|
export class StorageTool extends StorageProviderTool {
|
|
6
7
|
constructor(config) {
|
|
7
8
|
super({
|
|
@@ -18,9 +19,13 @@ export class StorageTool extends StorageProviderTool {
|
|
|
18
19
|
address: new oAddress('o://memory'),
|
|
19
20
|
...config,
|
|
20
21
|
}));
|
|
22
|
+
this.addChildNode(new SecureStorageProvider({
|
|
23
|
+
name: 'secure',
|
|
24
|
+
address: new oAddress('o://secure'),
|
|
25
|
+
...config,
|
|
26
|
+
}));
|
|
21
27
|
}
|
|
22
28
|
async _tool_put(request) {
|
|
23
|
-
const result = LocalSearch.search(this, 'hello');
|
|
24
29
|
// return this.use()
|
|
25
30
|
throw new Error('Not implemented');
|
|
26
31
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olane/o-tools-common",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -32,43 +32,33 @@
|
|
|
32
32
|
"license": "ISC",
|
|
33
33
|
"description": "oLane Core",
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@babel/core": "^7.27.4",
|
|
36
|
-
"@babel/preset-env": "^7.27.2",
|
|
37
|
-
"@babel/preset-react": "^7.27.1",
|
|
38
|
-
"@babel/preset-typescript": "^7.27.1",
|
|
39
35
|
"@eslint/eslintrc": "^3.3.1",
|
|
40
36
|
"@eslint/js": "^9.29.0",
|
|
41
|
-
"@olane/o-config": "^0.
|
|
42
|
-
"@olane/o-core": "^0.
|
|
43
|
-
"@olane/o-protocol": "^0.
|
|
44
|
-
"@olane/o-tool": "^0.
|
|
37
|
+
"@olane/o-config": "^0.2.0",
|
|
38
|
+
"@olane/o-core": "^0.2.0",
|
|
39
|
+
"@olane/o-protocol": "^0.2.0",
|
|
40
|
+
"@olane/o-tool": "^0.2.0",
|
|
45
41
|
"@tsconfig/node20": "^20.1.6",
|
|
46
42
|
"@types/jest": "^30.0.0",
|
|
47
43
|
"@typescript-eslint/eslint-plugin": "^8.34.1",
|
|
48
44
|
"@typescript-eslint/parser": "^8.34.1",
|
|
49
|
-
"babel-loader": "^10.0.0",
|
|
50
45
|
"eslint": "^9.29.0",
|
|
51
46
|
"eslint-config-prettier": "^10.1.6",
|
|
52
47
|
"eslint-plugin-prettier": "^5.5.0",
|
|
53
48
|
"globals": "^16.2.0",
|
|
54
49
|
"jest": "^30.0.0",
|
|
55
|
-
"nodemon": "^3.1.10",
|
|
56
50
|
"prettier": "^3.5.3",
|
|
57
51
|
"ts-jest": "^29.4.0",
|
|
58
|
-
"ts-loader": "^9.5.2",
|
|
59
52
|
"ts-node": "^10.9.2",
|
|
60
53
|
"tsconfig-paths": "^4.2.0",
|
|
61
54
|
"tsx": "^4.20.3",
|
|
62
|
-
"typescript": "5.4.5"
|
|
63
|
-
"webpack": "^5.99.9",
|
|
64
|
-
"webpack-cli": "^6.0.1",
|
|
65
|
-
"webpack-dev-server": "^5.2.2"
|
|
55
|
+
"typescript": "5.4.5"
|
|
66
56
|
},
|
|
67
57
|
"peerDependencies": {
|
|
68
|
-
"@olane/o-config": "^0.
|
|
69
|
-
"@olane/o-core": "^0.
|
|
70
|
-
"@olane/o-protocol": "^0.
|
|
71
|
-
"@olane/o-tool": "^0.
|
|
58
|
+
"@olane/o-config": "^0.2.0",
|
|
59
|
+
"@olane/o-core": "^0.2.0",
|
|
60
|
+
"@olane/o-protocol": "^0.2.0",
|
|
61
|
+
"@olane/o-tool": "^0.2.0"
|
|
72
62
|
},
|
|
73
63
|
"dependencies": {
|
|
74
64
|
"debug": "^4.4.1",
|
package/dist/vault/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vault/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
package/dist/vault/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './vault.tool.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encryption.d.ts","sourceRoot":"","sources":["../../../src/vault/lib/encryption.ts"],"names":[],"mappings":"AAGA,UAAU,aAAa;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;CACb;AAUD,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmB;IAC1C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;gBAEvB,SAAS,CAAC,EAAE,MAAM;IAoB9B;;;;OAIG;IACU,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IA+B/D;;;;OAIG;IACU,OAAO,CAAC,aAAa,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IA4BnE;;;;OAIG;IACU,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAMhE;;;;OAIG;IACU,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAYnE;;;OAGG;WACW,iBAAiB,IAAI,MAAM;CAG1C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vault.methods.d.ts","sourceRoot":"","sources":["../../../src/vault/methods/vault.methods.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,eAAO,MAAM,YAAY,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAoClD,CAAC"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export const VAULT_PARAMS = {
|
|
2
|
-
get: {
|
|
3
|
-
name: 'get',
|
|
4
|
-
description: 'Retrieve data from the vault',
|
|
5
|
-
dependencies: [],
|
|
6
|
-
parameters: [
|
|
7
|
-
{
|
|
8
|
-
name: 'key',
|
|
9
|
-
type: 'string',
|
|
10
|
-
value: 'string',
|
|
11
|
-
description: 'The key to retrieve',
|
|
12
|
-
required: true,
|
|
13
|
-
},
|
|
14
|
-
],
|
|
15
|
-
},
|
|
16
|
-
store: {
|
|
17
|
-
name: 'store',
|
|
18
|
-
description: 'Store data in the vault',
|
|
19
|
-
dependencies: [],
|
|
20
|
-
parameters: [
|
|
21
|
-
{
|
|
22
|
-
name: 'key',
|
|
23
|
-
type: 'string',
|
|
24
|
-
value: 'string',
|
|
25
|
-
description: 'The key to store',
|
|
26
|
-
required: true,
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
name: 'value',
|
|
30
|
-
type: 'string',
|
|
31
|
-
value: 'string',
|
|
32
|
-
description: 'The value to store',
|
|
33
|
-
required: true,
|
|
34
|
-
},
|
|
35
|
-
],
|
|
36
|
-
},
|
|
37
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { oToolConfig, oVirtualTool, ToolResult } from '@olane/o-tool';
|
|
2
|
-
import { oRequest } from '@olane/o-core';
|
|
3
|
-
export declare class VaultTool extends oVirtualTool {
|
|
4
|
-
private encryptionService;
|
|
5
|
-
private store;
|
|
6
|
-
constructor(config: oToolConfig);
|
|
7
|
-
_tool_store(request: oRequest): Promise<ToolResult>;
|
|
8
|
-
_tool_get(request: oRequest): Promise<ToolResult>;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=vault.tool.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vault.tool.d.ts","sourceRoot":"","sources":["../../src/vault/vault.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAY,QAAQ,EAAE,MAAM,eAAe,CAAC;AAInD,qBAAa,SAAU,SAAQ,YAAY;IACzC,OAAO,CAAC,iBAAiB,CAAoB;IAC7C,OAAO,CAAC,KAAK,CAAkC;gBAEnC,MAAM,EAAE,WAAW;IAUzB,WAAW,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAanD,SAAS,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;CAYxD"}
|
package/dist/vault/vault.tool.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { oVirtualTool } from '@olane/o-tool';
|
|
2
|
-
import { oAddress } from '@olane/o-core';
|
|
3
|
-
import { EncryptionService } from './lib/encryption.js';
|
|
4
|
-
import { VAULT_PARAMS } from './methods/vault.methods.js';
|
|
5
|
-
export class VaultTool extends oVirtualTool {
|
|
6
|
-
constructor(config) {
|
|
7
|
-
super({
|
|
8
|
-
...config,
|
|
9
|
-
address: new oAddress('o://vault'),
|
|
10
|
-
methods: VAULT_PARAMS,
|
|
11
|
-
description: 'Tool to store and retrieve sensitive data from the network',
|
|
12
|
-
});
|
|
13
|
-
this.store = new Map();
|
|
14
|
-
this.encryptionService = new EncryptionService();
|
|
15
|
-
}
|
|
16
|
-
async _tool_store(request) {
|
|
17
|
-
const params = request.params;
|
|
18
|
-
const { key, value } = params;
|
|
19
|
-
const b64key = btoa(key);
|
|
20
|
-
const encryptedValue = await this.encryptionService.encryptToBase64(value);
|
|
21
|
-
this.store.set(b64key, encryptedValue);
|
|
22
|
-
return {
|
|
23
|
-
message: 'Successfully stored value for key: ' + b64key,
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
async _tool_get(request) {
|
|
27
|
-
const params = request.params;
|
|
28
|
-
const { key } = params;
|
|
29
|
-
const b64key = btoa(key);
|
|
30
|
-
const encryptedValue = this.store.get(b64key);
|
|
31
|
-
const decryptedValue = await this.encryptionService.decryptFromBase64(encryptedValue);
|
|
32
|
-
return {
|
|
33
|
-
value: decryptedValue,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
}
|
|
File without changes
|
|
File without changes
|