@icure/api 5.0.30 → 5.0.32
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/icc-x-api/icc-crypto-x-api.d.ts +7 -12
- package/icc-x-api/icc-crypto-x-api.js +66 -67
- package/icc-x-api/icc-crypto-x-api.js.map +1 -1
- package/icc-x-api/storage/KeyStorageFacade.d.ts +37 -0
- package/icc-x-api/storage/KeyStorageFacade.js +3 -0
- package/icc-x-api/storage/KeyStorageFacade.js.map +1 -0
- package/icc-x-api/storage/KeyStorageImpl.d.ts +17 -0
- package/icc-x-api/storage/KeyStorageImpl.js +34 -0
- package/icc-x-api/storage/KeyStorageImpl.js.map +1 -0
- package/icc-x-api/storage/LocalStorageImpl.d.ts +10 -0
- package/icc-x-api/storage/LocalStorageImpl.js +25 -0
- package/icc-x-api/storage/LocalStorageImpl.js.map +1 -0
- package/icc-x-api/storage/StorageFacade.d.ts +19 -0
- package/icc-x-api/storage/StorageFacade.js +3 -0
- package/icc-x-api/storage/StorageFacade.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface KeyStorageFacade {
|
|
2
|
+
/**
|
|
3
|
+
* Returns the publicKey of the provided key from the storage
|
|
4
|
+
* @param key Key of the value to retrieve
|
|
5
|
+
* @return The publicKey associated to the provided key or undefined if not found.
|
|
6
|
+
*/
|
|
7
|
+
getPublicKey(key: string): JsonWebKey | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Returns the privateKey of the provided key from the storage
|
|
10
|
+
* @param key Key of the value to retrieve
|
|
11
|
+
* @return The privateKey associated to the provided key or undefined if not found.
|
|
12
|
+
*/
|
|
13
|
+
getPrivateKey(key: string): JsonWebKey | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Get the keyPair associated to the provided key
|
|
16
|
+
* @param key Key of the value to retrieve
|
|
17
|
+
* @return The keyPair associated to the provided key or undefined if not found.
|
|
18
|
+
*/
|
|
19
|
+
getKeypair(key: string): {
|
|
20
|
+
publicKey: JsonWebKey;
|
|
21
|
+
privateKey: JsonWebKey;
|
|
22
|
+
} | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Delete the keyPair associated to the provided key
|
|
25
|
+
* @param key Key of the value to delete
|
|
26
|
+
*/
|
|
27
|
+
deleteKeypair(key: string): void;
|
|
28
|
+
/**
|
|
29
|
+
* Stores the given keyPair under the given key in the storage.
|
|
30
|
+
* @param key The id of the entry in storage
|
|
31
|
+
* @param keyPair should be JWK
|
|
32
|
+
*/
|
|
33
|
+
storeKeyPair(key: string, keyPair: {
|
|
34
|
+
publicKey: JsonWebKey;
|
|
35
|
+
privateKey: JsonWebKey;
|
|
36
|
+
}): void;
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KeyStorageFacade.js","sourceRoot":"","sources":["../../../icc-x-api/storage/KeyStorageFacade.ts"],"names":[],"mappings":"","sourcesContent":["export interface KeyStorageFacade {\n /**\n * Returns the publicKey of the provided key from the storage\n * @param key Key of the value to retrieve\n * @return The publicKey associated to the provided key or undefined if not found.\n */\n getPublicKey(key: string): JsonWebKey | undefined\n\n /**\n * Returns the privateKey of the provided key from the storage\n * @param key Key of the value to retrieve\n * @return The privateKey associated to the provided key or undefined if not found.\n */\n getPrivateKey(key: string): JsonWebKey | undefined\n\n /**\n * Get the keyPair associated to the provided key\n * @param key Key of the value to retrieve\n * @return The keyPair associated to the provided key or undefined if not found.\n */\n getKeypair(key: string): { publicKey: JsonWebKey; privateKey: JsonWebKey } | undefined\n\n /**\n * Delete the keyPair associated to the provided key\n * @param key Key of the value to delete\n */\n deleteKeypair(key: string): void\n\n /**\n * Stores the given keyPair under the given key in the storage.\n * @param key The id of the entry in storage\n * @param keyPair should be JWK\n */\n storeKeyPair(key: string, keyPair: { publicKey: JsonWebKey; privateKey: JsonWebKey }): void\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { StorageFacade } from './StorageFacade';
|
|
2
|
+
import { KeyStorageFacade } from './KeyStorageFacade';
|
|
3
|
+
export declare class KeyStorageImpl implements KeyStorageFacade {
|
|
4
|
+
private readonly _storage;
|
|
5
|
+
constructor(storage: StorageFacade<string>);
|
|
6
|
+
deleteKeypair(key: string): void;
|
|
7
|
+
getKeypair(key: string): {
|
|
8
|
+
publicKey: JsonWebKey;
|
|
9
|
+
privateKey: JsonWebKey;
|
|
10
|
+
} | undefined;
|
|
11
|
+
getPrivateKey(key: string): JsonWebKey | undefined;
|
|
12
|
+
getPublicKey(key: string): JsonWebKey | undefined;
|
|
13
|
+
storeKeyPair(key: string, keyPair: {
|
|
14
|
+
publicKey: JsonWebKey;
|
|
15
|
+
privateKey: JsonWebKey;
|
|
16
|
+
}): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KeyStorageImpl = void 0;
|
|
4
|
+
class KeyStorageImpl {
|
|
5
|
+
constructor(storage) {
|
|
6
|
+
this._storage = storage;
|
|
7
|
+
}
|
|
8
|
+
deleteKeypair(key) {
|
|
9
|
+
return this._storage.deleteItem(key);
|
|
10
|
+
}
|
|
11
|
+
getKeypair(key) {
|
|
12
|
+
var _a;
|
|
13
|
+
const keyPair = JSON.parse((_a = this._storage.getItem(key)) !== null && _a !== void 0 ? _a : '');
|
|
14
|
+
return keyPair.hasOwnProperty('publicKey') && keyPair.hasOwnProperty('privateKey')
|
|
15
|
+
? {
|
|
16
|
+
publicKey: keyPair.publicKey,
|
|
17
|
+
privateKey: keyPair.privateKey,
|
|
18
|
+
}
|
|
19
|
+
: undefined;
|
|
20
|
+
}
|
|
21
|
+
getPrivateKey(key) {
|
|
22
|
+
var _a;
|
|
23
|
+
return (_a = this.getKeypair(key)) === null || _a === void 0 ? void 0 : _a.privateKey;
|
|
24
|
+
}
|
|
25
|
+
getPublicKey(key) {
|
|
26
|
+
var _a;
|
|
27
|
+
return (_a = this.getKeypair(key)) === null || _a === void 0 ? void 0 : _a.publicKey;
|
|
28
|
+
}
|
|
29
|
+
storeKeyPair(key, keyPair) {
|
|
30
|
+
return this._storage.setItem(key, JSON.stringify(keyPair));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.KeyStorageImpl = KeyStorageImpl;
|
|
34
|
+
//# sourceMappingURL=KeyStorageImpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KeyStorageImpl.js","sourceRoot":"","sources":["../../../icc-x-api/storage/KeyStorageImpl.ts"],"names":[],"mappings":";;;AAIA,MAAa,cAAc;IAGzB,YAAY,OAA8B;QACxC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;IACzB,CAAC;IAED,aAAa,CAAC,GAAW;QACvB,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;IACtC,CAAC;IAED,UAAU,CAAC,GAAW;;QACpB,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAA,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,mCAAI,EAAE,CAAC,CAAA;QAC5D,OAAO,OAAO,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC;YAChF,CAAC,CAAC;gBACE,SAAS,EAAE,OAAO,CAAC,SAAuB;gBAC1C,UAAU,EAAE,OAAO,CAAC,UAAwB;aAC7C;YACH,CAAC,CAAC,SAAS,CAAA;IACf,CAAC;IAED,aAAa,CAAC,GAAW;;QACvB,OAAO,MAAA,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,0CAAE,UAAU,CAAA;IACzC,CAAC;IAED,YAAY,CAAC,GAAW;;QACtB,OAAO,MAAA,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,0CAAE,SAAS,CAAA;IACxC,CAAC;IAED,YAAY,CAAC,GAAW,EAAE,OAA0D;QAClF,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAA;IAC5D,CAAC;CACF;AAhCD,wCAgCC","sourcesContent":["import { StorageFacade } from './StorageFacade'\nimport { KeyStorageFacade } from './KeyStorageFacade'\nimport { b2a } from '../../icc-api/model/ModelHelper'\n\nexport class KeyStorageImpl implements KeyStorageFacade {\n private readonly _storage: StorageFacade<string>\n\n constructor(storage: StorageFacade<string>) {\n this._storage = storage\n }\n\n deleteKeypair(key: string): void {\n return this._storage.deleteItem(key)\n }\n\n getKeypair(key: string): { publicKey: JsonWebKey; privateKey: JsonWebKey } | undefined {\n const keyPair = JSON.parse(this._storage.getItem(key) ?? '')\n return keyPair.hasOwnProperty('publicKey') && keyPair.hasOwnProperty('privateKey')\n ? {\n publicKey: keyPair.publicKey as JsonWebKey,\n privateKey: keyPair.privateKey as JsonWebKey,\n }\n : undefined\n }\n\n getPrivateKey(key: string): JsonWebKey | undefined {\n return this.getKeypair(key)?.privateKey\n }\n\n getPublicKey(key: string): JsonWebKey | undefined {\n return this.getKeypair(key)?.publicKey\n }\n\n storeKeyPair(key: string, keyPair: { publicKey: JsonWebKey; privateKey: JsonWebKey }): void {\n return this._storage.setItem(key, JSON.stringify(keyPair))\n }\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { StorageFacade } from './StorageFacade';
|
|
2
|
+
export declare class LocalStorageImpl implements StorageFacade<string> {
|
|
3
|
+
getItem(key: string): string | undefined;
|
|
4
|
+
deleteItem(key: string): void;
|
|
5
|
+
setItem(key: string, valueToStore: string): void;
|
|
6
|
+
storeKeyPair(key: string, keyPair: {
|
|
7
|
+
publicKey: any;
|
|
8
|
+
privateKey: any;
|
|
9
|
+
}): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LocalStorageImpl = void 0;
|
|
4
|
+
class LocalStorageImpl {
|
|
5
|
+
getItem(key) {
|
|
6
|
+
var _a;
|
|
7
|
+
return (_a = localStorage.getItem(key)) !== null && _a !== void 0 ? _a : undefined;
|
|
8
|
+
}
|
|
9
|
+
deleteItem(key) {
|
|
10
|
+
return localStorage.removeItem(key);
|
|
11
|
+
}
|
|
12
|
+
setItem(key, valueToStore) {
|
|
13
|
+
return localStorage.setItem(key, valueToStore);
|
|
14
|
+
}
|
|
15
|
+
storeKeyPair(key, keyPair) {
|
|
16
|
+
if (typeof Storage === 'undefined') {
|
|
17
|
+
console.error('Your browser does not support HTML5 Browser Local Storage !');
|
|
18
|
+
throw 'Your browser does not support HTML5 Browser Local Storage !';
|
|
19
|
+
}
|
|
20
|
+
//TODO: encryption
|
|
21
|
+
this.setItem(key, JSON.stringify(keyPair));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.LocalStorageImpl = LocalStorageImpl;
|
|
25
|
+
//# sourceMappingURL=LocalStorageImpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalStorageImpl.js","sourceRoot":"","sources":["../../../icc-x-api/storage/LocalStorageImpl.ts"],"names":[],"mappings":";;;AAEA,MAAa,gBAAgB;IAC3B,OAAO,CAAC,GAAW;;QACjB,OAAO,MAAA,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,mCAAI,SAAS,CAAA;IAC/C,CAAC;IAED,UAAU,CAAC,GAAW;QACpB,OAAO,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;IACrC,CAAC;IAED,OAAO,CAAC,GAAW,EAAE,YAAoB;QACvC,OAAO,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,YAAY,CAAC,CAAA;IAChD,CAAC;IAED,YAAY,CAAC,GAAW,EAAE,OAA4C;QACpE,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE;YAClC,OAAO,CAAC,KAAK,CAAC,6DAA6D,CAAC,CAAA;YAC5E,MAAM,6DAA6D,CAAA;SACpE;QACD,kBAAkB;QAClB,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAA;IAC5C,CAAC;CACF;AArBD,4CAqBC","sourcesContent":["import { StorageFacade } from './StorageFacade'\n\nexport class LocalStorageImpl implements StorageFacade<string> {\n getItem(key: string): string | undefined {\n return localStorage.getItem(key) ?? undefined\n }\n\n deleteItem(key: string): void {\n return localStorage.removeItem(key)\n }\n\n setItem(key: string, valueToStore: string): void {\n return localStorage.setItem(key, valueToStore)\n }\n\n storeKeyPair(key: string, keyPair: { publicKey: any; privateKey: any }): void {\n if (typeof Storage === 'undefined') {\n console.error('Your browser does not support HTML5 Browser Local Storage !')\n throw 'Your browser does not support HTML5 Browser Local Storage !'\n }\n //TODO: encryption\n this.setItem(key, JSON.stringify(keyPair))\n }\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface StorageFacade<T> {
|
|
2
|
+
/**
|
|
3
|
+
* Returns the value of the provided key from the storage
|
|
4
|
+
* @param key Key of the value to retrieve
|
|
5
|
+
* @return The value associated to the provided key or null if not found.
|
|
6
|
+
*/
|
|
7
|
+
getItem(key: string): T | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Set an item in the storage for the given key
|
|
10
|
+
* @param key Key of the value to set
|
|
11
|
+
* @param valueToStore
|
|
12
|
+
*/
|
|
13
|
+
setItem(key: string, valueToStore: T): void;
|
|
14
|
+
/**
|
|
15
|
+
* Removes the item with the given key from the storage.
|
|
16
|
+
* @param key The key of the item to remove.
|
|
17
|
+
*/
|
|
18
|
+
deleteItem(key: string): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StorageFacade.js","sourceRoot":"","sources":["../../../icc-x-api/storage/StorageFacade.ts"],"names":[],"mappings":"","sourcesContent":["export interface StorageFacade<T> {\n /**\n * Returns the value of the provided key from the storage\n * @param key Key of the value to retrieve\n * @return The value associated to the provided key or null if not found.\n */\n getItem(key: string): T | undefined\n\n /**\n * Set an item in the storage for the given key\n * @param key Key of the value to set\n * @param valueToStore\n */\n setItem(key: string, valueToStore: T): void\n\n /**\n * Removes the item with the given key from the storage.\n * @param key The key of the item to remove.\n */\n deleteItem(key: string): void\n}\n"]}
|