@lifeready/core 6.1.1 → 6.1.2
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/bundles/lifeready-core.umd.js +23 -74
- package/bundles/lifeready-core.umd.js.map +1 -1
- package/bundles/lifeready-core.umd.min.js +1 -1
- package/bundles/lifeready-core.umd.min.js.map +1 -1
- package/esm2015/lib/encryption/encryption.service.js +7 -6
- package/esm2015/lib/item2/item2.service.js +3 -2
- package/esm2015/lib/key/key-graph.service.js +3 -3
- package/esm2015/lib/key/key-meta.service.js +1 -57
- package/esm2015/lib/key/key.types.js +6 -1
- package/fesm2015/lifeready-core.js +23 -74
- package/fesm2015/lifeready-core.js.map +1 -1
- package/lib/item2/item2.service.d.ts +1 -1
- package/lib/key/key.types.d.ts +4 -1
- package/lifeready-core.metadata.json +1 -1
- package/package.json +1 -1
|
@@ -341,6 +341,22 @@
|
|
|
341
341
|
return value;
|
|
342
342
|
}
|
|
343
343
|
|
|
344
|
+
var KeyGraphNodeType;
|
|
345
|
+
(function (KeyGraphNodeType) {
|
|
346
|
+
KeyGraphNodeType["Key"] = "key";
|
|
347
|
+
KeyGraphNodeType["PassKey"] = "passKey";
|
|
348
|
+
})(KeyGraphNodeType || (KeyGraphNodeType = {}));
|
|
349
|
+
var KeyGraphEdgeType;
|
|
350
|
+
(function (KeyGraphEdgeType) {
|
|
351
|
+
KeyGraphEdgeType["KeyLink"] = "keyLink";
|
|
352
|
+
KeyGraphEdgeType["PassKeyLink"] = "passKeyLink";
|
|
353
|
+
})(KeyGraphEdgeType || (KeyGraphEdgeType = {}));
|
|
354
|
+
var PayloadType;
|
|
355
|
+
(function (PayloadType) {
|
|
356
|
+
PayloadType["JSON"] = "JSON";
|
|
357
|
+
PayloadType["UINT_8_ARRAY"] = "UINT_8_ARRAY";
|
|
358
|
+
})(PayloadType || (PayloadType = {}));
|
|
359
|
+
|
|
344
360
|
function handleApolloError(errors) {
|
|
345
361
|
if (!errors || !errors.length)
|
|
346
362
|
return;
|
|
@@ -803,11 +819,11 @@
|
|
|
803
819
|
JoseSerialization["COMPACT"] = "COMPACT";
|
|
804
820
|
})(JoseSerialization || (JoseSerialization = {}));
|
|
805
821
|
var VERIFY_OPTIONS_DEFAULT = {
|
|
806
|
-
payloadType:
|
|
822
|
+
payloadType: PayloadType.JSON,
|
|
807
823
|
returnOnlyPayload: true,
|
|
808
824
|
};
|
|
809
825
|
var DECRYPT_OPTIONS_DEFAULT = {
|
|
810
|
-
payloadType:
|
|
826
|
+
payloadType: PayloadType.JSON,
|
|
811
827
|
returnOnlyPayload: true,
|
|
812
828
|
serializations: [JoseSerialization.JSON],
|
|
813
829
|
};
|
|
@@ -878,7 +894,7 @@
|
|
|
878
894
|
});
|
|
879
895
|
});
|
|
880
896
|
};
|
|
881
|
-
// TODO rename this to encrypt() and use as the most common
|
|
897
|
+
// TODO rename this to encrypt() and use as the most common use case
|
|
882
898
|
EncryptionService.prototype.encryptToString = function (key, content) {
|
|
883
899
|
return __awaiter(this, void 0, void 0, function () {
|
|
884
900
|
var _a, _b;
|
|
@@ -1017,9 +1033,9 @@
|
|
|
1017
1033
|
};
|
|
1018
1034
|
EncryptionService.prototype.decodePayload = function (payloadType, payload) {
|
|
1019
1035
|
switch (payloadType) {
|
|
1020
|
-
case
|
|
1036
|
+
case PayloadType.JSON:
|
|
1021
1037
|
return JSON.parse(new TextDecoder().decode(payload));
|
|
1022
|
-
case
|
|
1038
|
+
case PayloadType.UINT_8_ARRAY:
|
|
1023
1039
|
return payload;
|
|
1024
1040
|
default:
|
|
1025
1041
|
throw new KcBadArgumentException("Unknown payloadType: " + payloadType);
|
|
@@ -1850,17 +1866,6 @@
|
|
|
1850
1866
|
{ type: PersistService }
|
|
1851
1867
|
]; };
|
|
1852
1868
|
|
|
1853
|
-
var KeyGraphNodeType;
|
|
1854
|
-
(function (KeyGraphNodeType) {
|
|
1855
|
-
KeyGraphNodeType["Key"] = "key";
|
|
1856
|
-
KeyGraphNodeType["PassKey"] = "passKey";
|
|
1857
|
-
})(KeyGraphNodeType || (KeyGraphNodeType = {}));
|
|
1858
|
-
var KeyGraphEdgeType;
|
|
1859
|
-
(function (KeyGraphEdgeType) {
|
|
1860
|
-
KeyGraphEdgeType["KeyLink"] = "keyLink";
|
|
1861
|
-
KeyGraphEdgeType["PassKeyLink"] = "passKeyLink";
|
|
1862
|
-
})(KeyGraphEdgeType || (KeyGraphEdgeType = {}));
|
|
1863
|
-
|
|
1864
1869
|
var KeyGraphService = /** @class */ (function () {
|
|
1865
1870
|
// private keyCache: {
|
|
1866
1871
|
// [id: string]: Key;
|
|
@@ -2210,7 +2215,7 @@
|
|
|
2210
2215
|
case 1:
|
|
2211
2216
|
key = _a.sent();
|
|
2212
2217
|
return [4 /*yield*/, this.encryptionService.decrypt(key, file, {
|
|
2213
|
-
payloadType:
|
|
2218
|
+
payloadType: PayloadType.UINT_8_ARRAY,
|
|
2214
2219
|
})];
|
|
2215
2220
|
case 2: return [2 /*return*/, (_a.sent())];
|
|
2216
2221
|
}
|
|
@@ -4133,21 +4138,6 @@
|
|
|
4133
4138
|
this.keyService = keyService;
|
|
4134
4139
|
this.keyFactory = keyFactory;
|
|
4135
4140
|
}
|
|
4136
|
-
// async decryptFromString<T>(
|
|
4137
|
-
// keyOrId: string | Key,
|
|
4138
|
-
// cipherData: string,
|
|
4139
|
-
// options?: DecryptOptions
|
|
4140
|
-
// ): Promise<T> {
|
|
4141
|
-
// if (cipherData) {
|
|
4142
|
-
// const key = await this.keyGraphService.getJwkKey(keyOrId);
|
|
4143
|
-
// return (await this.encryptionService.decrypt(
|
|
4144
|
-
// key,
|
|
4145
|
-
// JSON.parse(cipherData),
|
|
4146
|
-
// options
|
|
4147
|
-
// )) as any;
|
|
4148
|
-
// }
|
|
4149
|
-
// return null;
|
|
4150
|
-
// }
|
|
4151
4141
|
KeyMetaService.prototype.decryptMeta = function (metaHaver) {
|
|
4152
4142
|
return __awaiter(this, void 0, void 0, function () {
|
|
4153
4143
|
var key;
|
|
@@ -4165,47 +4155,6 @@
|
|
|
4165
4155
|
});
|
|
4166
4156
|
});
|
|
4167
4157
|
};
|
|
4168
|
-
// async decryptFile(keyId: string, file: any): Promise<any> {
|
|
4169
|
-
// const key = await this.keyGraphService.getJwkKey(keyId);
|
|
4170
|
-
// return (await this.encryptionService.decrypt(key, file, {
|
|
4171
|
-
// payloadType: 'ArrayBuffer',
|
|
4172
|
-
// })) as any;
|
|
4173
|
-
// }
|
|
4174
|
-
// // TODO rename this to encrypt() and use as the most common usecase
|
|
4175
|
-
// async encryptToString(
|
|
4176
|
-
// key: string | Key | JWK.Key,
|
|
4177
|
-
// content: any
|
|
4178
|
-
// ): Promise<string> {
|
|
4179
|
-
// // Empty string should be encrypted since you want to clear the field.
|
|
4180
|
-
// // Null is not encrypted because it's not valid JSON in the old JSON spec. Use
|
|
4181
|
-
// // empty string instead. It'll function as a logic false as well.
|
|
4182
|
-
// // Note that passing in empty string means it'll be encrypted which verifies
|
|
4183
|
-
// // it's integrity. But we still want to have a way to set the DB field
|
|
4184
|
-
// // to NULL, so we explicitly return null when content == null. A null
|
|
4185
|
-
// // variable in graphql mutation on KC server clears the field to NULL.
|
|
4186
|
-
// if (content == null) {
|
|
4187
|
-
// return null;
|
|
4188
|
-
// }
|
|
4189
|
-
// const jwk =
|
|
4190
|
-
// asJwk(key) || (await this.keyGraphService.getJwkKey(key as string | Key));
|
|
4191
|
-
// return JSON.stringify(await this.encryptionService.encrypt(jwk, content));
|
|
4192
|
-
// }
|
|
4193
|
-
// // Wraps a symmetric encryption key.
|
|
4194
|
-
// // Throws exception if wrapping public keys.
|
|
4195
|
-
// async wrapKey<T>(
|
|
4196
|
-
// wrappingKey: string | Key | JWK.Key,
|
|
4197
|
-
// key: JWK.Key
|
|
4198
|
-
// ): Promise<string> {
|
|
4199
|
-
// if (!isSymmetricKey(key)) {
|
|
4200
|
-
// throw new LrBadArgumentException(
|
|
4201
|
-
// 'Only allowing wrapping of symmetric keys.'
|
|
4202
|
-
// );
|
|
4203
|
-
// }
|
|
4204
|
-
// return this.encryptToString(wrappingKey, key.toJSON(true));
|
|
4205
|
-
// }
|
|
4206
|
-
// // TODO
|
|
4207
|
-
// // async wrapPublicKey<T>();
|
|
4208
|
-
// // async wrapPrivateKey<T>();
|
|
4209
4158
|
KeyMetaService.prototype.doubleWrapContent = function (secureContent, categoryIds, fileContent) {
|
|
4210
4159
|
return __awaiter(this, void 0, void 0, function () {
|
|
4211
4160
|
var key, wrappedContent, _a, _b, _c, _d, _e, _f, _g;
|
|
@@ -7267,7 +7216,7 @@
|
|
|
7267
7216
|
case 2:
|
|
7268
7217
|
fileStateKey = _d.sent();
|
|
7269
7218
|
return [2 /*return*/, this.keyGraph.decryptFromString(fileStateKey, fileContent, {
|
|
7270
|
-
payloadType:
|
|
7219
|
+
payloadType: PayloadType.UINT_8_ARRAY,
|
|
7271
7220
|
})];
|
|
7272
7221
|
}
|
|
7273
7222
|
});
|