neo4j-driver 6.3.0 → 6.3.1

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.
@@ -12069,6 +12069,8 @@
12069
12069
 
12070
12070
  var encapsulatedKeyManager = {};
12071
12071
 
12072
+ var encryptionProfile = {};
12073
+
12072
12074
  /**
12073
12075
  * Copyright (c) "Neo4j"
12074
12076
  * Neo4j Sweden AB [https://neo4j.com]
@@ -12121,9 +12123,298 @@
12121
12123
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
12122
12124
  }
12123
12125
  };
12126
+ Object.defineProperty(encryptionProfile, "__esModule", { value: true });
12127
+ encryptionProfile.EnvelopeEncryptionProfile = void 0;
12128
+ var error_1$8 = error;
12129
+ var integer_1$1 = integer;
12130
+ var json_1$2 = json$3;
12131
+ /**
12132
+ * An encryption profile that enables Envelope Encryption for Neo4j Property Encryption.
12133
+ *
12134
+ * @since 6.3.0
12135
+ * @experimental Part of the Client-Side Encrytion preview feature
12136
+ */
12137
+ var EnvelopeEncryptionProfile = /** @class */ (function () {
12138
+ /**
12139
+ *
12140
+ * @param {Object} config - Configurations
12141
+ * @param {string} config.name - Name of the profile, must be the same on all drivers used to access the encrypted data.
12142
+ * @param {KeyEncapsulationService} config.encapsulationService - Encapsulation service used to encapsulate and dencapsulate keys. The driver ships with {@link LocalKeyEncapsulationService}, other implementations can be found as separate packages.
12143
+ * @param {EncapsulatedKeyRecordRepository} config.keyRepository - Implementation of the {@link EncapsulatedKeyRecordRepository} interface, must be implemented so that the driver can access your key repository.
12144
+ * @param {number} config.keyCacheTTL - How How long in milliseconds to keep a retrieved encapsulated keys cached by Id - defaults to 15 minutes
12145
+ * @param {number} config.keyCacheMaxSize - How many items to keep in the key cache before pruning the oldest, setting to 0 will disable the cache - defaults to 100
12146
+ * @param {number} config.keyAliasIndexTTL - How How long in milliseconds to keep the mapping of alias to key cached - defaults to 15 seconds
12147
+ * @param {number} config.keyAliasIndexMaxSize - How many items to keep in the alias cache before pruning the oldest, setting to 0 will disable the index - defaults to 100
12148
+ */
12149
+ function EnvelopeEncryptionProfile(config) {
12150
+ var _a, _b, _c, _d;
12151
+ this.name = config.name;
12152
+ this.encapsulationService = config.encapsulationService;
12153
+ this.keyRepository = config.keyRepository;
12154
+ if (config.keyCacheMaxSize !== 0) {
12155
+ this._keyCache = new Map();
12156
+ }
12157
+ this._keyCacheTTL = (_a = config.keyCacheTTL) !== null && _a !== void 0 ? _a : 15 * 60 * 1000;
12158
+ this._keyCacheMaxSize = (_b = config.keyCacheMaxSize) !== null && _b !== void 0 ? _b : 100;
12159
+ if (this._keyCache != null && config.keyAliasIndexMaxSize !== 0) {
12160
+ this._aliasIndex = new Map();
12161
+ }
12162
+ this._keyAliasIndexTTL = (_c = config.keyAliasIndexTTL) !== null && _c !== void 0 ? _c : 15 * 1000;
12163
+ this._keyAliasIndexMaxSize = (_d = config.keyAliasIndexMaxSize) !== null && _d !== void 0 ? _d : 100;
12164
+ this.type = 'ENVELOPE';
12165
+ this.version = (0, integer_1$1.int)(1);
12166
+ }
12167
+ /**
12168
+ * @private
12169
+ */
12170
+ EnvelopeEncryptionProfile.prototype.findKey = function (options) {
12171
+ return __awaiter$g(this, void 0, void 0, function () {
12172
+ var key;
12173
+ return __generator$i(this, function (_a) {
12174
+ switch (_a.label) {
12175
+ case 0:
12176
+ if (!(typeof options === 'string')) return [3 /*break*/, 2];
12177
+ return [4 /*yield*/, this._findById(options)];
12178
+ case 1:
12179
+ key = _a.sent();
12180
+ return [3 /*break*/, 7];
12181
+ case 2:
12182
+ if (!(options.id != null)) return [3 /*break*/, 4];
12183
+ return [4 /*yield*/, this._findById(options.id)];
12184
+ case 3:
12185
+ key = _a.sent();
12186
+ return [3 /*break*/, 7];
12187
+ case 4:
12188
+ if (!(options.alias != null)) return [3 /*break*/, 6];
12189
+ return [4 /*yield*/, this._findByAlias(options.alias)];
12190
+ case 5:
12191
+ key = _a.sent();
12192
+ return [3 /*break*/, 7];
12193
+ case 6: throw (0, error_1$8.newError)("invalid key options: ".concat((0, json_1$2.stringify)(options)));
12194
+ case 7: return [2 /*return*/, key];
12195
+ }
12196
+ });
12197
+ });
12198
+ };
12199
+ /**
12200
+ * @private
12201
+ */
12202
+ EnvelopeEncryptionProfile.prototype.saveKey = function (alias, encapsulation, metadata) {
12203
+ return __awaiter$g(this, void 0, void 0, function () {
12204
+ var key, e_1;
12205
+ return __generator$i(this, function (_a) {
12206
+ switch (_a.label) {
12207
+ case 0:
12208
+ _a.trys.push([0, 2, , 3]);
12209
+ return [4 /*yield*/, this.keyRepository.create(alias, encapsulation, metadata)];
12210
+ case 1:
12211
+ key = _a.sent();
12212
+ if (this._keyCache != null) {
12213
+ this._keyCache.set(key.id(), { entry: key, retrieved: new Date() });
12214
+ this._pruneCache(this._keyCache, this._keyCacheMaxSize);
12215
+ if (this._aliasIndex != null && alias != null) {
12216
+ this._aliasIndex.set(alias, { entry: key.id(), retrieved: new Date() });
12217
+ this._pruneCache(this._aliasIndex, this._keyAliasIndexMaxSize);
12218
+ }
12219
+ }
12220
+ return [2 /*return*/, key];
12221
+ case 2:
12222
+ e_1 = _a.sent();
12223
+ throw (0, error_1$8.newError)('Call to EncapsulatedKeyRepository.create threw error, see cause', '50N42', e_1);
12224
+ case 3: return [2 /*return*/];
12225
+ }
12226
+ });
12227
+ });
12228
+ };
12229
+ /**
12230
+ * @private
12231
+ */
12232
+ EnvelopeEncryptionProfile.prototype._findById = function (id) {
12233
+ return __awaiter$g(this, void 0, void 0, function () {
12234
+ var entry, key, e_2;
12235
+ var _a, _b;
12236
+ return __generator$i(this, function (_c) {
12237
+ switch (_c.label) {
12238
+ case 0:
12239
+ if (this._keyCache != null) {
12240
+ entry = this._keyCache.get(id);
12241
+ if (entry != null) {
12242
+ if (new Date().getTime() - ((_a = entry === null || entry === void 0 ? void 0 : entry.retrieved.getTime()) !== null && _a !== void 0 ? _a : 0) < ((_b = this._keyCacheTTL) !== null && _b !== void 0 ? _b : 0)) {
12243
+ return [2 /*return*/, entry === null || entry === void 0 ? void 0 : entry.entry];
12244
+ }
12245
+ else {
12246
+ this._keyCache.delete(id);
12247
+ }
12248
+ }
12249
+ }
12250
+ _c.label = 1;
12251
+ case 1:
12252
+ _c.trys.push([1, 3, , 4]);
12253
+ return [4 /*yield*/, this.keyRepository.findById(id)];
12254
+ case 2:
12255
+ key = _c.sent();
12256
+ return [3 /*break*/, 4];
12257
+ case 3:
12258
+ e_2 = _c.sent();
12259
+ throw (0, error_1$8.newError)('Call to EncapsulatedKeyRepository.findById threw error, see cause', '50N42', e_2);
12260
+ case 4:
12261
+ if (key == null) {
12262
+ return [2 /*return*/, undefined];
12263
+ }
12264
+ if (this._keyCache != null) {
12265
+ this._keyCache.set(id, { entry: key, retrieved: new Date() });
12266
+ this._pruneCache(this._keyCache, this._keyCacheMaxSize);
12267
+ }
12268
+ return [2 /*return*/, key];
12269
+ }
12270
+ });
12271
+ });
12272
+ };
12273
+ /**
12274
+ * @private
12275
+ */
12276
+ EnvelopeEncryptionProfile.prototype._findByAlias = function (alias) {
12277
+ return __awaiter$g(this, void 0, void 0, function () {
12278
+ var entry, key, e_3;
12279
+ var _a, _b;
12280
+ return __generator$i(this, function (_c) {
12281
+ switch (_c.label) {
12282
+ case 0:
12283
+ if (!(this._aliasIndex != null)) return [3 /*break*/, 3];
12284
+ entry = this._aliasIndex.get(alias);
12285
+ if (!(entry != null)) return [3 /*break*/, 3];
12286
+ if (!(new Date().getTime() - ((_a = entry === null || entry === void 0 ? void 0 : entry.retrieved.getTime()) !== null && _a !== void 0 ? _a : 0) < ((_b = this._keyAliasIndexTTL) !== null && _b !== void 0 ? _b : 0))) return [3 /*break*/, 2];
12287
+ return [4 /*yield*/, this._findById(entry === null || entry === void 0 ? void 0 : entry.entry)];
12288
+ case 1: return [2 /*return*/, _c.sent()];
12289
+ case 2:
12290
+ this._aliasIndex.delete(alias);
12291
+ _c.label = 3;
12292
+ case 3:
12293
+ _c.trys.push([3, 5, , 6]);
12294
+ return [4 /*yield*/, this.keyRepository.findByAlias(alias)];
12295
+ case 4:
12296
+ key = _c.sent();
12297
+ return [3 /*break*/, 6];
12298
+ case 5:
12299
+ e_3 = _c.sent();
12300
+ throw (0, error_1$8.newError)('Call to EncapsulatedKeyRepository.findByAlias threw error, see cause', '50N42', e_3);
12301
+ case 6:
12302
+ if (key == null) {
12303
+ return [2 /*return*/, undefined];
12304
+ }
12305
+ if (this._keyCache != null) {
12306
+ this._keyCache.set(key.id(), { entry: key, retrieved: new Date() });
12307
+ this._pruneCache(this._keyCache, this._keyCacheMaxSize);
12308
+ if (this._aliasIndex != null) {
12309
+ this._aliasIndex.set(alias, { entry: key.id(), retrieved: new Date() });
12310
+ this._pruneCache(this._aliasIndex, this._keyAliasIndexMaxSize);
12311
+ }
12312
+ }
12313
+ return [2 /*return*/, key];
12314
+ }
12315
+ });
12316
+ });
12317
+ };
12318
+ /**
12319
+ * @private
12320
+ */
12321
+ EnvelopeEncryptionProfile.prototype._pruneCache = function (cache, maxSize) {
12322
+ if (cache.size > maxSize) {
12323
+ var entries = Array.from(cache.entries());
12324
+ entries.sort(function (a, b) { return a[1].retrieved.getTime() - b[1].retrieved.getTime(); });
12325
+ var i = 0;
12326
+ while (cache.size > maxSize) {
12327
+ cache.delete(entries[i][0]);
12328
+ i++;
12329
+ }
12330
+ }
12331
+ };
12332
+ /**
12333
+ * @private
12334
+ */
12335
+ EnvelopeEncryptionProfile.prototype.removeFromKeyCache = function (id) {
12336
+ if (this._keyCache != null) {
12337
+ this._keyCache.delete(id);
12338
+ this.setAliasIndexEntry(id, undefined);
12339
+ }
12340
+ };
12341
+ EnvelopeEncryptionProfile.prototype.setAliasIndexEntry = function (id, alias) {
12342
+ var _this = this;
12343
+ var _a;
12344
+ (_a = this._keyCache) === null || _a === void 0 ? void 0 : _a.delete(id);
12345
+ if (this._aliasIndex != null) {
12346
+ this._aliasIndex.forEach(function (val, key) {
12347
+ if (val.entry === id) {
12348
+ if (_this._aliasIndex != null) {
12349
+ _this._aliasIndex.delete(key);
12350
+ }
12351
+ }
12352
+ });
12353
+ if (alias != null) {
12354
+ this._aliasIndex.set(alias, { entry: id, retrieved: new Date() });
12355
+ }
12356
+ }
12357
+ };
12358
+ return EnvelopeEncryptionProfile;
12359
+ }());
12360
+ encryptionProfile.EnvelopeEncryptionProfile = EnvelopeEncryptionProfile;
12361
+
12362
+ /**
12363
+ * Copyright (c) "Neo4j"
12364
+ * Neo4j Sweden AB [https://neo4j.com]
12365
+ *
12366
+ * Licensed under the Apache License, Version 2.0 (the "License");
12367
+ * you may not use this file except in compliance with the License.
12368
+ * You may obtain a copy of the License at
12369
+ *
12370
+ * http://www.apache.org/licenses/LICENSE-2.0
12371
+ *
12372
+ * Unless required by applicable law or agreed to in writing, software
12373
+ * distributed under the License is distributed on an "AS IS" BASIS,
12374
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12375
+ * See the License for the specific language governing permissions and
12376
+ * limitations under the License.
12377
+ */
12378
+ var __awaiter$f = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
12379
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
12380
+ return new (P || (P = Promise))(function (resolve, reject) {
12381
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
12382
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
12383
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12384
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
12385
+ });
12386
+ };
12387
+ var __generator$h = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
12388
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
12389
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
12390
+ function verb(n) { return function (v) { return step([n, v]); }; }
12391
+ function step(op) {
12392
+ if (f) throw new TypeError("Generator is already executing.");
12393
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
12394
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
12395
+ if (y = 0, t) op = [op[0] & 2, t.value];
12396
+ switch (op[0]) {
12397
+ case 0: case 1: t = op; break;
12398
+ case 4: _.label++; return { value: op[1], done: false };
12399
+ case 5: _.label++; y = op[1]; op = [0]; continue;
12400
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
12401
+ default:
12402
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
12403
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
12404
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
12405
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
12406
+ if (t[2]) _.ops.pop();
12407
+ _.trys.pop(); continue;
12408
+ }
12409
+ op = body.call(thisArg, _);
12410
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
12411
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
12412
+ }
12413
+ };
12124
12414
  Object.defineProperty(encapsulatedKeyManager, "__esModule", { value: true });
12125
12415
  encapsulatedKeyManager.EncapsulatedKeyManager = void 0;
12126
- var error_1$8 = error;
12416
+ var encryption_profile_1 = encryptionProfile;
12417
+ var error_1$7 = error;
12127
12418
  /**
12128
12419
  * A manager for encapsulated keys.
12129
12420
  *
@@ -12149,9 +12440,9 @@
12149
12440
  * @returns {Promise<void>} Promise that resolves when the key is created, saved and ready to use.
12150
12441
  */
12151
12442
  EncapsulatedKeyManager.prototype.create = function (name) {
12152
- return __awaiter$g(this, void 0, void 0, function () {
12443
+ return __awaiter$f(this, void 0, void 0, function () {
12153
12444
  var encapulated;
12154
- return __generator$i(this, function (_a) {
12445
+ return __generator$h(this, function (_a) {
12155
12446
  switch (_a.label) {
12156
12447
  case 0: return [4 /*yield*/, this._keyEncapsulationService.encapsulate({})];
12157
12448
  case 1:
@@ -12169,9 +12460,9 @@
12169
12460
  * @return the encapsulated key or undefined when no key with the given id exists
12170
12461
  */
12171
12462
  EncapsulatedKeyManager.prototype.findById = function (id) {
12172
- return __awaiter$g(this, void 0, void 0, function () {
12463
+ return __awaiter$f(this, void 0, void 0, function () {
12173
12464
  var record;
12174
- return __generator$i(this, function (_a) {
12465
+ return __generator$h(this, function (_a) {
12175
12466
  switch (_a.label) {
12176
12467
  case 0: return [4 /*yield*/, this._profile.findKey({ id: id })];
12177
12468
  case 1:
@@ -12193,9 +12484,9 @@
12193
12484
  * @return the encapsulated key or undefined when no key with the given alias exists
12194
12485
  */
12195
12486
  EncapsulatedKeyManager.prototype.findByAlias = function (alias) {
12196
- return __awaiter$g(this, void 0, void 0, function () {
12487
+ return __awaiter$f(this, void 0, void 0, function () {
12197
12488
  var record;
12198
- return __generator$i(this, function (_a) {
12489
+ return __generator$h(this, function (_a) {
12199
12490
  switch (_a.label) {
12200
12491
  case 0: return [4 /*yield*/, this._profile.findKey({ alias: alias })];
12201
12492
  case 1:
@@ -12218,17 +12509,22 @@
12218
12509
  * @param {string | undefined} alias the new key alias
12219
12510
  */
12220
12511
  EncapsulatedKeyManager.prototype.setAliasById = function (id, alias) {
12221
- return __awaiter$g(this, void 0, void 0, function () {
12512
+ return __awaiter$f(this, void 0, void 0, function () {
12222
12513
  var e_1;
12223
- return __generator$i(this, function (_a) {
12514
+ return __generator$h(this, function (_a) {
12224
12515
  switch (_a.label) {
12225
12516
  case 0:
12226
12517
  _a.trys.push([0, 2, , 3]);
12227
12518
  return [4 /*yield*/, this._profile.keyRepository.setAliasById(id, alias)];
12228
- case 1: return [2 /*return*/, _a.sent()];
12519
+ case 1:
12520
+ _a.sent();
12521
+ if (this._profile instanceof encryption_profile_1.EnvelopeEncryptionProfile) {
12522
+ this._profile.setAliasIndexEntry(id, alias);
12523
+ }
12524
+ return [3 /*break*/, 3];
12229
12525
  case 2:
12230
12526
  e_1 = _a.sent();
12231
- throw (0, error_1$8.newError)('Call to EncapsulatedKeyRepository.setAliasById threw error, see cause', '50N42', e_1);
12527
+ throw (0, error_1$7.newError)('Call to EncapsulatedKeyRepository.setAliasById threw error, see cause', '50N42', e_1);
12232
12528
  case 3: return [2 /*return*/];
12233
12529
  }
12234
12530
  });
@@ -12240,8 +12536,8 @@
12240
12536
  * @param {string} id the key id
12241
12537
  */
12242
12538
  EncapsulatedKeyManager.prototype.deleteAliasById = function (id) {
12243
- return __awaiter$g(this, void 0, void 0, function () {
12244
- return __generator$i(this, function (_a) {
12539
+ return __awaiter$f(this, void 0, void 0, function () {
12540
+ return __generator$h(this, function (_a) {
12245
12541
  switch (_a.label) {
12246
12542
  case 0: return [4 /*yield*/, this.setAliasById(id, undefined)];
12247
12543
  case 1: return [2 /*return*/, _a.sent()];
@@ -12255,17 +12551,22 @@
12255
12551
  * @param {string} id the key id, must not be {@literal null}
12256
12552
  */
12257
12553
  EncapsulatedKeyManager.prototype.deleteById = function (id) {
12258
- return __awaiter$g(this, void 0, void 0, function () {
12554
+ return __awaiter$f(this, void 0, void 0, function () {
12259
12555
  var e_2;
12260
- return __generator$i(this, function (_a) {
12556
+ return __generator$h(this, function (_a) {
12261
12557
  switch (_a.label) {
12262
12558
  case 0:
12263
12559
  _a.trys.push([0, 2, , 3]);
12264
12560
  return [4 /*yield*/, this._profile.keyRepository.deleteById(id)];
12265
- case 1: return [2 /*return*/, _a.sent()];
12561
+ case 1:
12562
+ _a.sent();
12563
+ if (this._profile instanceof encryption_profile_1.EnvelopeEncryptionProfile) {
12564
+ this._profile.removeFromKeyCache(id);
12565
+ }
12566
+ return [3 /*break*/, 3];
12266
12567
  case 2:
12267
12568
  e_2 = _a.sent();
12268
- throw (0, error_1$8.newError)('Call to EncapsulatedKeyRepository.deleteById threw error, see cause', '50N42', e_2);
12569
+ throw (0, error_1$7.newError)('Call to EncapsulatedKeyRepository.deleteById threw error, see cause', '50N42', e_2);
12269
12570
  case 3: return [2 /*return*/];
12270
12571
  }
12271
12572
  });
@@ -12293,7 +12594,7 @@
12293
12594
  * See the License for the specific language governing permissions and
12294
12595
  * limitations under the License.
12295
12596
  */
12296
- var __awaiter$f = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
12597
+ var __awaiter$e = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
12297
12598
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
12298
12599
  return new (P || (P = Promise))(function (resolve, reject) {
12299
12600
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
@@ -12302,7 +12603,7 @@
12302
12603
  step((generator = generator.apply(thisArg, _arguments || [])).next());
12303
12604
  });
12304
12605
  };
12305
- var __generator$h = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
12606
+ var __generator$g = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
12306
12607
  var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
12307
12608
  return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
12308
12609
  function verb(n) { return function (v) { return step([n, v]); }; }
@@ -12337,10 +12638,10 @@
12337
12638
  function CryptoProvider() {
12338
12639
  }
12339
12640
  CryptoProvider.prototype.encrypt = function (key, message, aad) {
12340
- return __awaiter$f(this, void 0, void 0, function () {
12641
+ return __awaiter$e(this, void 0, void 0, function () {
12341
12642
  var iv, _a, _b, _c;
12342
12643
  var _d;
12343
- return __generator$h(this, function (_e) {
12644
+ return __generator$g(this, function (_e) {
12344
12645
  switch (_e.label) {
12345
12646
  case 0:
12346
12647
  iv = this.getRandomValues(12);
@@ -12368,9 +12669,9 @@
12368
12669
  });
12369
12670
  };
12370
12671
  CryptoProvider.prototype.decrypt = function (key, iv, message, aad) {
12371
- return __awaiter$f(this, void 0, void 0, function () {
12672
+ return __awaiter$e(this, void 0, void 0, function () {
12372
12673
  var _a, _b, _c;
12373
- return __generator$h(this, function (_d) {
12674
+ return __generator$g(this, function (_d) {
12374
12675
  switch (_d.label) {
12375
12676
  case 0:
12376
12677
  _b = (_a = window.crypto.subtle).decrypt;
@@ -12421,7 +12722,7 @@
12421
12722
  Object.defineProperty(vector$1, "__esModule", { value: true });
12422
12723
  vector$1.vector = vector;
12423
12724
  vector$1.isVector = isVector;
12424
- var error_1$7 = error;
12725
+ var error_1$6 = error;
12425
12726
  var VECTOR_IDENTIFIER_PROPERTY = '__isVector__';
12426
12727
  /**
12427
12728
  * @typedef {'INT8' | 'INT16' | 'INT32' | 'INT64' | 'FLOAT32' | 'FLOAT64'} VectorType
@@ -12467,7 +12768,7 @@
12467
12768
  this._type = vectorTypes.FLOAT64;
12468
12769
  }
12469
12770
  else {
12470
- throw (0, error_1$7.newError)("Invalid argument type passed to Vector constructor: should be signed integer or float TypedArray, got: ".concat((_b = (_a = typedArray === null || typedArray === void 0 ? void 0 : typedArray.constructor) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : 'undefined or type without constructor name'));
12771
+ throw (0, error_1$6.newError)("Invalid argument type passed to Vector constructor: should be signed integer or float TypedArray, got: ".concat((_b = (_a = typedArray === null || typedArray === void 0 ? void 0 : typedArray.constructor) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : 'undefined or type without constructor name'));
12471
12772
  }
12472
12773
  this._typedArray = typedArray;
12473
12774
  }
@@ -12506,7 +12807,7 @@
12506
12807
  case 'FLOAT64':
12507
12808
  return 'FLOAT NOT NULL';
12508
12809
  default:
12509
- throw (0, error_1$7.newError)("Cannot stringify vector with unsupported type. Got type: ".concat(type));
12810
+ throw (0, error_1$6.newError)("Cannot stringify vector with unsupported type. Got type: ".concat(type));
12510
12811
  }
12511
12812
  }
12512
12813
  Object.defineProperty(Vector.prototype, VECTOR_IDENTIFIER_PROPERTY, {
@@ -12527,7 +12828,7 @@
12527
12828
  return new Vector(typedArray);
12528
12829
  }
12529
12830
  catch (_c) {
12530
- throw (0, error_1$7.newError)("Invalid argument type passed to vector constructor function: should be signed integer or float TypedArray, got: ".concat((_b = (_a = typedArray === null || typedArray === void 0 ? void 0 : typedArray.constructor) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : 'undefined or type without constructor name'));
12831
+ throw (0, error_1$6.newError)("Invalid argument type passed to vector constructor function: should be signed integer or float TypedArray, got: ".concat((_b = (_a = typedArray === null || typedArray === void 0 ? void 0 : typedArray.constructor) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : 'undefined or type without constructor name'));
12531
12832
  }
12532
12833
  }
12533
12834
  /**
@@ -12560,7 +12861,7 @@
12560
12861
  Object.defineProperty(uuid$1, "__esModule", { value: true });
12561
12862
  uuid$1.uuid = uuid;
12562
12863
  uuid$1.isUUID = isUUID;
12563
- var error_1$6 = error;
12864
+ var error_1$5 = error;
12564
12865
  var UUID_IDENTIFIER_PROPERTY = '__isUUID__';
12565
12866
  var uuidV4DashLocations = [3, 5, 7, 9];
12566
12867
  /**
@@ -12575,7 +12876,7 @@
12575
12876
  var UUID = /** @class */ (function () {
12576
12877
  function UUID(typedArray) {
12577
12878
  if (typedArray.length !== 16) {
12578
- throw (0, error_1$6.newError)("Uint8Array representation of UUID must be of length 16, got ".concat(typedArray.toString()));
12879
+ throw (0, error_1$5.newError)("Uint8Array representation of UUID must be of length 16, got ".concat(typedArray.toString()));
12579
12880
  }
12580
12881
  this._typedArray = typedArray;
12581
12882
  Object.freeze(this);
@@ -12611,7 +12912,7 @@
12611
12912
  UUID.fromString = function (uuidString) {
12612
12913
  if (uuidString.match(/^[\da-fA-F]{32}$/) === null &&
12613
12914
  uuidString.match(/^[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}$/) === null) {
12614
- throw (0, error_1$6.newError)("UUID string base16 encoded should be of format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx or without any dashes, got: ".concat(uuidString));
12915
+ throw (0, error_1$5.newError)("UUID string base16 encoded should be of format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx or without any dashes, got: ".concat(uuidString));
12615
12916
  }
12616
12917
  uuidString = uuidString.replace(/-/g, '');
12617
12918
  var result = [];
@@ -12646,7 +12947,7 @@
12646
12947
  return new UUID(rawUUID);
12647
12948
  }
12648
12949
  // @ts-expect-error
12649
- throw (0, error_1$6.newError)("Invalid argument type passed to UUID constructor function: expected Uint8Array or uuid string, got: ".concat((_b = (_a = rawUUID === null || rawUUID === void 0 ? void 0 : rawUUID.constructor) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : 'undefined or type without constructor name'));
12950
+ throw (0, error_1$5.newError)("Invalid argument type passed to UUID constructor function: expected Uint8Array or uuid string, got: ".concat((_b = (_a = rawUUID === null || rawUUID === void 0 ? void 0 : rawUUID.constructor) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : 'undefined or type without constructor name'));
12650
12951
  }
12651
12952
  /**
12652
12953
  * Test if given object is an instance of the {@link UUID} class.
@@ -12782,7 +13083,7 @@
12782
13083
  return result;
12783
13084
  };
12784
13085
  })();
12785
- var __awaiter$e = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
13086
+ var __awaiter$d = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
12786
13087
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
12787
13088
  return new (P || (P = Promise))(function (resolve, reject) {
12788
13089
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
@@ -12791,7 +13092,7 @@
12791
13092
  step((generator = generator.apply(thisArg, _arguments || [])).next());
12792
13093
  });
12793
13094
  };
12794
- var __generator$g = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
13095
+ var __generator$f = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
12795
13096
  var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
12796
13097
  return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
12797
13098
  function verb(n) { return function (v) { return step([n, v]); }; }
@@ -12822,7 +13123,7 @@
12822
13123
  return (mod && mod.__esModule) ? mod : { "default": mod };
12823
13124
  };
12824
13125
  Object.defineProperty(encryption, "__esModule", { value: true });
12825
- var integer_1$1 = __importStar$6(integer);
13126
+ var integer_1 = __importStar$6(integer);
12826
13127
  var encrypted_value_1 = encryptedValue;
12827
13128
  var encapsulated_key_manager_1 = encapsulatedKeyManager;
12828
13129
  var crypto_1$1 = __importDefault$10(crypto);
@@ -12830,8 +13131,8 @@
12830
13131
  var vector_1 = vector$1;
12831
13132
  var spatial_types_1 = spatialTypes;
12832
13133
  var uuid_1 = uuid$1;
12833
- var error_1$5 = error;
12834
- var json_1$2 = json$3;
13134
+ var error_1$4 = error;
13135
+ var json_1$1 = json$3;
12835
13136
  var protocol_version_1 = protocolVersion;
12836
13137
  var unsupported_type_1$1 = __importDefault$10(unsupportedType);
12837
13138
  var supportedAADTypes = ['BOOLEAN', 'DATE', 'INTEGER', 'LOCAL TIME', 'POINT', 'STRING', 'ZONED TIME', 'UUID', 'BYTES'];
@@ -12851,7 +13152,7 @@
12851
13152
  this._profiles = new Map();
12852
13153
  profiles.forEach(function (profile) {
12853
13154
  if (_this._profiles.has(profile.name)) {
12854
- throw (0, error_1$5.newError)("Multiple profiles with name ".concat(profile.name, " configured, each profile must have a unique name."));
13155
+ throw (0, error_1$4.newError)("Multiple profiles with name ".concat(profile.name, " configured, each profile must have a unique name."));
12855
13156
  }
12856
13157
  _this._profiles.set(profile.name, { profile: profile, keyManager: new encapsulated_key_manager_1.EncapsulatedKeyManager(profile, profile.encapsulationService) });
12857
13158
  });
@@ -12870,9 +13171,9 @@
12870
13171
  * @returns {Promise<Int8Array>} A Int8Array that can be stored as a ByteArray in a Neo4j database.
12871
13172
  */
12872
13173
  EncryptionService.prototype.encrypt = function (encryptRequest) {
12873
- return __awaiter$e(this, void 0, void 0, function () {
13174
+ return __awaiter$d(this, void 0, void 0, function () {
12874
13175
  var profile, _a, typeName, typeProtocolMajor, typeProtocolMinor, encodedValue, encodedAAD, aadType, key, decapsulatedKey, _b, cyphertext, iv, metadata, e_1;
12875
- return __generator$g(this, function (_c) {
13176
+ return __generator$f(this, function (_c) {
12876
13177
  switch (_c.label) {
12877
13178
  case 0:
12878
13179
  profile = this._getProfile(encryptRequest.encryptionProfile);
@@ -12881,7 +13182,7 @@
12881
13182
  if (encryptRequest.aad !== undefined) {
12882
13183
  aadType = this._identifyType(encryptRequest.aad);
12883
13184
  if (!supportedAADTypes.includes(aadType.typeName)) {
12884
- throw (0, error_1$5.newError)("Unsupported AAD property type ".concat(aadType.typeName, ", supported values are ").concat(supportedAADTypes.toString()));
13185
+ throw (0, error_1$4.newError)("Unsupported AAD property type ".concat(aadType.typeName, ", supported values are ").concat(supportedAADTypes.toString()));
12885
13186
  }
12886
13187
  encodedAAD = this._boltProvider.encodeValue(encryptRequest.aad);
12887
13188
  }
@@ -12907,7 +13208,7 @@
12907
13208
  return [2 /*return*/, this._boltProvider.encodeObject(new encrypted_value_1.EncryptedValue(new Int8Array(cyphertext), profile.profile.name, profile.profile.type, profile.profile.version, typeName, typeProtocolMajor, typeProtocolMinor, metadata))];
12908
13209
  case 5:
12909
13210
  e_1 = _c.sent();
12910
- throw (0, error_1$5.newError)('Property encryption failed due to internal error, see cause.', '50N42', e_1);
13211
+ throw (0, error_1$4.newError)('Property encryption failed due to internal error, see cause.', '50N42', e_1);
12911
13212
  case 6: return [2 /*return*/];
12912
13213
  }
12913
13214
  });
@@ -12924,26 +13225,28 @@
12924
13225
  * @returns {Promise<T | UnsupportedType>} The decrypted property or an {@link UnsupportedType} if decoding the decrypted bytes failed.
12925
13226
  */
12926
13227
  EncryptionService.prototype.decrypt = function (decryptRequest) {
12927
- return __awaiter$e(this, void 0, void 0, function () {
13228
+ return __awaiter$d(this, void 0, void 0, function () {
12928
13229
  var encodedAAD, struct, aadType, profile, key, decapsulatedKey, decodedValue, _a, _b, type, e_2;
12929
- return __generator$g(this, function (_c) {
13230
+ return __generator$f(this, function (_c) {
12930
13231
  switch (_c.label) {
12931
13232
  case 0:
12932
13233
  struct = this._boltProvider.decodeObject(decryptRequest.ciphertext);
12933
- if (struct.typeProtocolMajor.notEquals((0, integer_1$1.int)(1)) || struct.typeProtocolMinor.greaterThan((0, integer_1$1.int)(0))) {
13234
+ if (struct.typeProtocolMajor.notEquals((0, integer_1.int)(1)) || struct.typeProtocolMinor.greaterThan((0, integer_1.int)(0))) {
12934
13235
  return [2 /*return*/, new unsupported_type_1$1.default('Undecryptable Value', struct.typeProtocolMajor.toNumber(), struct.typeProtocolMinor.toNumber(), 'Encrypted value was encoded with a newer driver, you must update your driver version to decode it.')];
12935
13236
  }
12936
- if (!(struct.profileType === 'ENVELOPE' && struct.profileVersion.equals((0, integer_1$1.int)(1)))) return [3 /*break*/, 7];
13237
+ if (!(struct.profileType === 'ENVELOPE' && struct.profileVersion.equals((0, integer_1.int)(1)))) return [3 /*break*/, 7];
12937
13238
  if (decryptRequest.usePersistedAad === true) {
12938
13239
  encodedAAD = struct.metadata.aad !== undefined ? struct.metadata.aad.buffer : undefined;
12939
13240
  }
12940
13241
  else if (decryptRequest.aad !== undefined) {
12941
13242
  aadType = this._identifyType(decryptRequest.aad);
12942
- if (aadType.typeProtocolMajor !== struct.metadata.aad_encoding_scheme_major || aadType.typeProtocolMinor !== struct.metadata.aad_encoding_scheme_minor) {
12943
- encodedAAD = this._boltProvider.encodeAAD(decryptRequest.aad, new protocol_version_1.ProtocolVersion(struct.metadata.aad_encoding_scheme_major, struct.metadata.aad_encoding_scheme_minor));
13243
+ // The below if statement functions until there are multiple major version encoding schemes.
13244
+ if (struct.metadata.aad_encoding_scheme_major == null || struct.metadata.aad_encoding_scheme_minor == null ||
13245
+ aadType.typeProtocolMajor.equals(struct.metadata.aad_encoding_scheme_major) || aadType.typeProtocolMinor.equals(struct.metadata.aad_encoding_scheme_minor)) {
13246
+ encodedAAD = this._boltProvider.encodeAAD(decryptRequest.aad, new protocol_version_1.ProtocolVersion(aadType.typeProtocolMajor.toNumber(), aadType.typeProtocolMinor.toNumber()));
12944
13247
  }
12945
13248
  else {
12946
- throw (0, error_1$5.newError)('AAD used to encrypt was encoded with a newer encoding scheme than this driver supports');
13249
+ throw (0, error_1$4.newError)('AAD used to encrypt was encoded with a different encoding scheme than this driver supports');
12947
13250
  }
12948
13251
  }
12949
13252
  profile = this._getProfile(struct.profileName);
@@ -12969,9 +13272,9 @@
12969
13272
  }
12970
13273
  case 5:
12971
13274
  e_2 = _c.sent();
12972
- throw (0, error_1$5.newError)('Property decryption failed due to internal error, see cause.', '50N42', e_2);
13275
+ throw (0, error_1$4.newError)('Property decryption failed due to internal error, see cause.', '50N42', e_2);
12973
13276
  case 6: return [3 /*break*/, 8];
12974
- case 7: throw (0, error_1$5.newError)("Unsupported encryption profile version ".concat(struct.profileVersion.toString(), " of profile type ").concat(struct.profileType, "."));
13277
+ case 7: throw (0, error_1$4.newError)("Unsupported encryption profile version ".concat(struct.profileVersion.toString(), " of profile type ").concat(struct.profileType, "."));
12975
13278
  case 8: return [2 /*return*/];
12976
13279
  }
12977
13280
  });
@@ -12990,88 +13293,88 @@
12990
13293
  // This function will need to be dynamic based on which version of the encoding is being used, currently only 1.0 (based on bolt 6.1) exists.
12991
13294
  EncryptionService.prototype._identifyType = function (value) {
12992
13295
  if (value === null) {
12993
- var verification = function (_) { throw (0, error_1$5.newError)('Encrypted arrays cannot contain null values'); };
12994
- return { typeName: 'NULL', typeProtocolMajor: (0, integer_1$1.int)(1), typeProtocolMinor: (0, integer_1$1.int)(0), verification: verification };
13296
+ var verification = function (_) { throw (0, error_1$4.newError)('Encrypted arrays cannot contain null values'); };
13297
+ return { typeName: 'NULL', typeProtocolMajor: (0, integer_1.int)(1), typeProtocolMinor: (0, integer_1.int)(0), verification: verification };
12995
13298
  }
12996
13299
  if (typeof value === 'string') {
12997
13300
  var verification = function (value) { return typeof value === 'string'; };
12998
- return { typeName: 'STRING', typeProtocolMajor: (0, integer_1$1.int)(1), typeProtocolMinor: (0, integer_1$1.int)(0), verification: verification };
13301
+ return { typeName: 'STRING', typeProtocolMajor: (0, integer_1.int)(1), typeProtocolMinor: (0, integer_1.int)(0), verification: verification };
12999
13302
  }
13000
13303
  if (typeof value === 'boolean') {
13001
13304
  var verification = function (value) { return typeof value === 'boolean'; };
13002
- return { typeName: 'BOOLEAN', typeProtocolMajor: (0, integer_1$1.int)(1), typeProtocolMinor: (0, integer_1$1.int)(0), verification: verification };
13305
+ return { typeName: 'BOOLEAN', typeProtocolMajor: (0, integer_1.int)(1), typeProtocolMinor: (0, integer_1.int)(0), verification: verification };
13003
13306
  }
13004
13307
  if (typeof value === 'number') {
13005
13308
  var verification = function (value) { return typeof value === 'number'; };
13006
- return { typeName: 'FLOAT', typeProtocolMajor: (0, integer_1$1.int)(1), typeProtocolMinor: (0, integer_1$1.int)(0), verification: verification };
13309
+ return { typeName: 'FLOAT', typeProtocolMajor: (0, integer_1.int)(1), typeProtocolMinor: (0, integer_1.int)(0), verification: verification };
13007
13310
  }
13008
13311
  if (typeof value === 'bigint') {
13009
13312
  var verification = function (value) { return typeof value === 'bigint'; };
13010
- return { typeName: 'INTEGER', typeProtocolMajor: (0, integer_1$1.int)(1), typeProtocolMinor: (0, integer_1$1.int)(0), verification: verification };
13313
+ return { typeName: 'INTEGER', typeProtocolMajor: (0, integer_1.int)(1), typeProtocolMinor: (0, integer_1.int)(0), verification: verification };
13011
13314
  }
13012
- if ((0, integer_1$1.isInt)(value)) {
13013
- var verification = function (value) { return (0, integer_1$1.isInt)(value); };
13014
- return { typeName: 'INTEGER', typeProtocolMajor: (0, integer_1$1.int)(1), typeProtocolMinor: (0, integer_1$1.int)(0), verification: verification };
13315
+ if ((0, integer_1.isInt)(value)) {
13316
+ var verification = function (value) { return (0, integer_1.isInt)(value); };
13317
+ return { typeName: 'INTEGER', typeProtocolMajor: (0, integer_1.int)(1), typeProtocolMinor: (0, integer_1.int)(0), verification: verification };
13015
13318
  }
13016
13319
  if ((0, temporal_types_1.isDate)(value)) {
13017
13320
  var verification = function (value) { return (0, temporal_types_1.isDate)(value); };
13018
- return { typeName: 'DATE', typeProtocolMajor: (0, integer_1$1.int)(1), typeProtocolMinor: (0, integer_1$1.int)(0), verification: verification };
13321
+ return { typeName: 'DATE', typeProtocolMajor: (0, integer_1.int)(1), typeProtocolMinor: (0, integer_1.int)(0), verification: verification };
13019
13322
  }
13020
13323
  if ((0, temporal_types_1.isDuration)(value)) {
13021
13324
  var verification = function (value) { return (0, temporal_types_1.isDuration)(value); };
13022
- return { typeName: 'DURATION', typeProtocolMajor: (0, integer_1$1.int)(1), typeProtocolMinor: (0, integer_1$1.int)(0), verification: verification };
13325
+ return { typeName: 'DURATION', typeProtocolMajor: (0, integer_1.int)(1), typeProtocolMinor: (0, integer_1.int)(0), verification: verification };
13023
13326
  }
13024
13327
  if ((0, vector_1.isVector)(value)) {
13025
- var verification = function (_) { throw (0, error_1$5.newError)('Encrypted arrays cannot contain vector values'); };
13026
- return { typeName: 'VECTOR', typeProtocolMajor: (0, integer_1$1.int)(1), typeProtocolMinor: (0, integer_1$1.int)(0), verification: verification };
13328
+ var verification = function (_) { throw (0, error_1$4.newError)('Encrypted arrays cannot contain vector values'); };
13329
+ return { typeName: 'VECTOR', typeProtocolMajor: (0, integer_1.int)(1), typeProtocolMinor: (0, integer_1.int)(0), verification: verification };
13027
13330
  }
13028
13331
  if (value instanceof Int8Array) {
13029
13332
  var verification = function (value) { return value instanceof Int8Array; };
13030
- return { typeName: 'BYTES', typeProtocolMajor: (0, integer_1$1.int)(1), typeProtocolMinor: (0, integer_1$1.int)(0), verification: verification };
13333
+ return { typeName: 'BYTES', typeProtocolMajor: (0, integer_1.int)(1), typeProtocolMinor: (0, integer_1.int)(0), verification: verification };
13031
13334
  }
13032
13335
  if ((0, temporal_types_1.isLocalDateTime)(value)) {
13033
13336
  var verification = function (value) { return (0, temporal_types_1.isLocalDateTime)(value); };
13034
- return { typeName: 'LOCAL DATETIME', typeProtocolMajor: (0, integer_1$1.int)(1), typeProtocolMinor: (0, integer_1$1.int)(0), verification: verification };
13337
+ return { typeName: 'LOCAL DATETIME', typeProtocolMajor: (0, integer_1.int)(1), typeProtocolMinor: (0, integer_1.int)(0), verification: verification };
13035
13338
  }
13036
13339
  if ((0, temporal_types_1.isLocalTime)(value)) {
13037
13340
  var verification = function (value) { return (0, temporal_types_1.isLocalTime)(value); };
13038
- return { typeName: 'LOCAL TIME', typeProtocolMajor: (0, integer_1$1.int)(1), typeProtocolMinor: (0, integer_1$1.int)(0), verification: verification };
13341
+ return { typeName: 'LOCAL TIME', typeProtocolMajor: (0, integer_1.int)(1), typeProtocolMinor: (0, integer_1.int)(0), verification: verification };
13039
13342
  }
13040
13343
  if ((0, temporal_types_1.isDateTime)(value)) {
13041
13344
  var verification = function (value) { return (0, temporal_types_1.isDateTime)(value); };
13042
- return { typeName: 'ZONED DATETIME', typeProtocolMajor: (0, integer_1$1.int)(1), typeProtocolMinor: (0, integer_1$1.int)(0), verification: verification };
13345
+ return { typeName: 'ZONED DATETIME', typeProtocolMajor: (0, integer_1.int)(1), typeProtocolMinor: (0, integer_1.int)(0), verification: verification };
13043
13346
  }
13044
13347
  if ((0, temporal_types_1.isTime)(value)) {
13045
13348
  var verification = function (value) { return (0, temporal_types_1.isTime)(value); };
13046
- return { typeName: 'ZONED TIME', typeProtocolMajor: (0, integer_1$1.int)(1), typeProtocolMinor: (0, integer_1$1.int)(0), verification: verification };
13349
+ return { typeName: 'ZONED TIME', typeProtocolMajor: (0, integer_1.int)(1), typeProtocolMinor: (0, integer_1.int)(0), verification: verification };
13047
13350
  }
13048
13351
  if ((0, spatial_types_1.isPoint)(value)) {
13049
13352
  var verification = function (point) {
13050
13353
  if ((0, spatial_types_1.isPoint)(point)) {
13051
- if ((point.srid instanceof BigInt ? integer_1$1.default.fromString(point.srid.toString()) : (0, integer_1$1.int)(point.srid))
13052
- .notEquals(value.srid instanceof BigInt ? integer_1$1.default.fromString(value.srid.toString()) : (0, integer_1$1.int)(value.srid))) {
13053
- throw (0, error_1$5.newError)('Encrypted arrays of Points must only contain Points with identical srids');
13354
+ if ((point.srid instanceof BigInt ? integer_1.default.fromString(point.srid.toString()) : (0, integer_1.int)(point.srid))
13355
+ .notEquals(value.srid instanceof BigInt ? integer_1.default.fromString(value.srid.toString()) : (0, integer_1.int)(value.srid))) {
13356
+ throw (0, error_1$4.newError)('Encrypted arrays of Points must only contain Points with identical srids');
13054
13357
  }
13055
13358
  if ((point.z == null && value.z != null) || (point.z != null && value.z == null)) {
13056
- throw (0, error_1$5.newError)('Encrypted arrays of Points must only contain Points of the same dimensionality.');
13359
+ throw (0, error_1$4.newError)('Encrypted arrays of Points must only contain Points of the same dimensionality.');
13057
13360
  }
13058
13361
  return true;
13059
13362
  }
13060
13363
  return false;
13061
13364
  };
13062
- return { typeName: 'POINT', typeProtocolMajor: (0, integer_1$1.int)(1), typeProtocolMinor: (0, integer_1$1.int)(0), verification: verification };
13365
+ return { typeName: 'POINT', typeProtocolMajor: (0, integer_1.int)(1), typeProtocolMinor: (0, integer_1.int)(0), verification: verification };
13063
13366
  }
13064
13367
  if ((0, uuid_1.isUUID)(value)) {
13065
13368
  var verification = function (value) { return (0, uuid_1.isUUID)(value); };
13066
- return { typeName: 'UUID', typeProtocolMajor: (0, integer_1$1.int)(1), typeProtocolMinor: (0, integer_1$1.int)(0), verification: verification };
13369
+ return { typeName: 'UUID', typeProtocolMajor: (0, integer_1.int)(1), typeProtocolMinor: (0, integer_1.int)(0), verification: verification };
13067
13370
  }
13068
13371
  if (Array.isArray(value)) {
13069
13372
  var type_1 = this._identifyType(value[0]);
13070
13373
  if (!value.map(function (element) { return type_1.verification(element); }).every(function (element) { return element; })) {
13071
- throw (0, error_1$5.newError)('Every element of an encrypted array must be of the same property type');
13374
+ throw (0, error_1$4.newError)('Every element of an encrypted array must be of the same property type');
13072
13375
  }
13073
- var major = (0, integer_1$1.int)(1);
13074
- var minor = (0, integer_1$1.int)(0);
13376
+ var major = (0, integer_1.int)(1);
13377
+ var minor = (0, integer_1.int)(0);
13075
13378
  if (type_1.typeProtocolMajor.greaterThan(major) || (type_1.typeProtocolMajor.equals(major) && type_1.typeProtocolMinor.greaterThan(minor))) {
13076
13379
  major = type_1.typeProtocolMajor;
13077
13380
  minor = type_1.typeProtocolMinor;
@@ -13079,7 +13382,7 @@
13079
13382
  var verification = function (_) { return false; };
13080
13383
  return { typeName: 'LIST', typeProtocolMajor: major, typeProtocolMinor: minor, verification: verification };
13081
13384
  }
13082
- throw (0, error_1$5.newError)("could not identify type of: ".concat((0, json_1$2.stringify)(value)));
13385
+ throw (0, error_1$4.newError)("could not identify type of: ".concat((0, json_1$1.stringify)(value)));
13083
13386
  };
13084
13387
  EncryptionService.prototype._getProfile = function (name) {
13085
13388
  if (name == null) {
@@ -13088,27 +13391,27 @@
13088
13391
  return this._profiles.get(this._profiles.keys().next().value);
13089
13392
  }
13090
13393
  else {
13091
- throw (0, error_1$5.newError)('When using a driver with multiple encryption profiles configured, which encryption profile to use must be explicitly provided');
13394
+ throw (0, error_1$4.newError)('When using a driver with multiple encryption profiles configured, which encryption profile to use must be explicitly provided');
13092
13395
  }
13093
13396
  }
13094
13397
  else {
13095
13398
  var profile = this._profiles.get(name);
13096
13399
  if (profile === undefined) {
13097
- throw (0, error_1$5.newError)("Could not find encryption profile with name ".concat(name));
13400
+ throw (0, error_1$4.newError)("Could not find encryption profile with name ".concat(name));
13098
13401
  }
13099
13402
  return profile;
13100
13403
  }
13101
13404
  };
13102
13405
  EncryptionService.prototype._getKeyRecord = function (profile, options) {
13103
- return __awaiter$e(this, void 0, void 0, function () {
13406
+ return __awaiter$d(this, void 0, void 0, function () {
13104
13407
  var key;
13105
- return __generator$g(this, function (_a) {
13408
+ return __generator$f(this, function (_a) {
13106
13409
  switch (_a.label) {
13107
13410
  case 0: return [4 /*yield*/, profile.findKey(options)];
13108
13411
  case 1:
13109
13412
  key = _a.sent();
13110
13413
  if (key == null) {
13111
- throw (0, error_1$5.newError)("Could not find key with key options: ".concat((0, json_1$2.stringify)(options)));
13414
+ throw (0, error_1$4.newError)("Could not find key with key options: ".concat((0, json_1$1.stringify)(options)));
13112
13415
  }
13113
13416
  return [2 /*return*/, key];
13114
13417
  }
@@ -13116,15 +13419,15 @@
13116
13419
  });
13117
13420
  };
13118
13421
  EncryptionService.prototype._decapsulateKey = function (profile, key) {
13119
- return __awaiter$e(this, void 0, void 0, function () {
13422
+ return __awaiter$d(this, void 0, void 0, function () {
13120
13423
  var decapsulatedKey;
13121
- return __generator$g(this, function (_a) {
13424
+ return __generator$f(this, function (_a) {
13122
13425
  switch (_a.label) {
13123
13426
  case 0: return [4 /*yield*/, profile.encapsulationService.decapsulate(key.encapsulation(), key.metadata())];
13124
13427
  case 1:
13125
13428
  decapsulatedKey = _a.sent();
13126
13429
  if (decapsulatedKey.length !== 32) {
13127
- throw (0, error_1$5.newError)("Expected decapulated key to be 32 bytes, found ".concat(decapsulatedKey.length));
13430
+ throw (0, error_1$4.newError)("Expected decapulated key to be 32 bytes, found ".concat(decapsulatedKey.length));
13128
13431
  }
13129
13432
  return [2 /*return*/, decapsulatedKey];
13130
13433
  }
@@ -13146,7 +13449,7 @@
13146
13449
  };
13147
13450
  return __assign$w.apply(this, arguments);
13148
13451
  };
13149
- var __awaiter$d = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
13452
+ var __awaiter$c = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
13150
13453
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13151
13454
  return new (P || (P = Promise))(function (resolve, reject) {
13152
13455
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
@@ -13155,7 +13458,7 @@
13155
13458
  step((generator = generator.apply(thisArg, _arguments || [])).next());
13156
13459
  });
13157
13460
  };
13158
- var __generator$f = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
13461
+ var __generator$e = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
13159
13462
  var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13160
13463
  return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13161
13464
  function verb(n) { return function (v) { return step([n, v]); }; }
@@ -13196,7 +13499,7 @@
13196
13499
  var bookmark_manager_1 = bookmarkManager$1;
13197
13500
  var result_transformers_1 = __importDefault$$(resultTransformers$1);
13198
13501
  var query_executor_1 = __importDefault$$(queryExecutor);
13199
- var error_1$4 = error;
13502
+ var error_1$3 = error;
13200
13503
  var homedb_cache_1 = __importDefault$$(homedbCache);
13201
13504
  var auth_util_1 = authUtil;
13202
13505
  var encryption_1 = __importDefault$$(encryption);
@@ -13694,18 +13997,18 @@
13694
13997
  * @see {@link resultTransformers} for provided result transformers.
13695
13998
  */
13696
13999
  Driver.prototype.executeQuery = function (query_1, parameters_1) {
13697
- return __awaiter$d(this, arguments, void 0, function (query, parameters, config, parameterRules) {
14000
+ return __awaiter$c(this, arguments, void 0, function (query, parameters, config, parameterRules) {
13698
14001
  var bookmarkManager, resultTransformer, routingConfig;
13699
14002
  var _a, _b, _c;
13700
14003
  if (config === void 0) { config = {}; }
13701
- return __generator$f(this, function (_d) {
14004
+ return __generator$e(this, function (_d) {
13702
14005
  switch (_d.label) {
13703
14006
  case 0:
13704
14007
  bookmarkManager = config.bookmarkManager === null ? undefined : ((_a = config.bookmarkManager) !== null && _a !== void 0 ? _a : this.executeQueryBookmarkManager);
13705
14008
  resultTransformer = ((_b = config.resultTransformer) !== null && _b !== void 0 ? _b : result_transformers_1.default.eager());
13706
14009
  routingConfig = (_c = config.routing) !== null && _c !== void 0 ? _c : routing.WRITE;
13707
14010
  if (routingConfig !== routing.READ && routingConfig !== routing.WRITE) {
13708
- throw (0, error_1$4.newError)("Illegal query routing config: \"".concat(routingConfig, "\""));
14011
+ throw (0, error_1$3.newError)("Illegal query routing config: \"".concat(routingConfig, "\""));
13709
14012
  }
13710
14013
  return [4 /*yield*/, this._queryExecutor.execute({
13711
14014
  resultTransformer: resultTransformer,
@@ -13749,10 +14052,10 @@
13749
14052
  * authentication issue and rejected with error if non-authentication error happens.
13750
14053
  */
13751
14054
  Driver.prototype.verifyAuthentication = function () {
13752
- return __awaiter$d(this, arguments, void 0, function (_a) {
14055
+ return __awaiter$c(this, arguments, void 0, function (_a) {
13753
14056
  var connectionProvider;
13754
14057
  var _b = _a === void 0 ? {} : _a, database = _b.database, auth = _b.auth;
13755
- return __generator$f(this, function (_c) {
14058
+ return __generator$e(this, function (_c) {
13756
14059
  switch (_c.label) {
13757
14060
  case 0:
13758
14061
  connectionProvider = this._getOrCreateConnectionProvider();
@@ -14106,9 +14409,9 @@
14106
14409
  * See the License for the specific language governing permissions and
14107
14410
  * limitations under the License.
14108
14411
  */
14109
- Object.defineProperty(auth$1, "__esModule", { value: true });
14110
- var error_1$3 = error;
14111
- var json_1$1 = json$3;
14412
+ Object.defineProperty(auth$1, "__esModule", { value: true });
14413
+ var error_1$2 = error;
14414
+ var json_1 = json$3;
14112
14415
  /**
14113
14416
  * @property {function(username: string, password: string, realm: ?string)} basic the function to create a
14114
14417
  * basic authentication token.
@@ -14164,12 +14467,12 @@
14164
14467
  }
14165
14468
  if (isNotEmpty(parameters)) {
14166
14469
  try {
14167
- (0, json_1$1.stringify)(parameters);
14470
+ (0, json_1.stringify)(parameters);
14168
14471
  }
14169
14472
  catch (e) {
14170
14473
  // eslint-disable-next-line
14171
14474
  // @ts-ignore
14172
- throw (0, error_1$3.newError)('Circular references in custom auth token parameters', undefined, e);
14475
+ throw (0, error_1$2.newError)('Circular references in custom auth token parameters', undefined, e);
14173
14476
  }
14174
14477
  output.parameters = parameters;
14175
14478
  }
@@ -14202,7 +14505,7 @@
14202
14505
  * See the License for the specific language governing permissions and
14203
14506
  * limitations under the License.
14204
14507
  */
14205
- var __awaiter$c = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
14508
+ var __awaiter$b = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
14206
14509
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14207
14510
  return new (P || (P = Promise))(function (resolve, reject) {
14208
14511
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
@@ -14211,7 +14514,7 @@
14211
14514
  step((generator = generator.apply(thisArg, _arguments || [])).next());
14212
14515
  });
14213
14516
  };
14214
- var __generator$e = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
14517
+ var __generator$d = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
14215
14518
  var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
14216
14519
  return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14217
14520
  function verb(n) { return function (v) { return step([n, v]); }; }
@@ -14352,9 +14655,9 @@
14352
14655
  if (typeof tokenProvider !== 'function') {
14353
14656
  throw new TypeError("tokenProvider should be function, but got: ".concat(typeof tokenProvider));
14354
14657
  }
14355
- return new ExpirationBasedAuthTokenManager(function () { return __awaiter$c(_this, void 0, void 0, function () {
14658
+ return new ExpirationBasedAuthTokenManager(function () { return __awaiter$b(_this, void 0, void 0, function () {
14356
14659
  var _a;
14357
- return __generator$e(this, function (_b) {
14660
+ return __generator$d(this, function (_b) {
14358
14661
  switch (_b.label) {
14359
14662
  case 0:
14360
14663
  _a = {};
@@ -14408,9 +14711,9 @@
14408
14711
  this._refreshObservable = _refreshObservable;
14409
14712
  }
14410
14713
  ExpirationBasedAuthTokenManager.prototype.getToken = function () {
14411
- return __awaiter$c(this, void 0, void 0, function () {
14714
+ return __awaiter$b(this, void 0, void 0, function () {
14412
14715
  var _a;
14413
- return __generator$e(this, function (_b) {
14716
+ return __generator$d(this, function (_b) {
14414
14717
  switch (_b.label) {
14415
14718
  case 0:
14416
14719
  if (!(this._currentAuthData === undefined ||
@@ -14459,9 +14762,9 @@
14459
14762
  }
14460
14763
  };
14461
14764
  ExpirationBasedAuthTokenManager.prototype._refreshAuthToken = function () {
14462
- return __awaiter$c(this, void 0, void 0, function () {
14765
+ return __awaiter$b(this, void 0, void 0, function () {
14463
14766
  var _this = this;
14464
- return __generator$e(this, function (_a) {
14767
+ return __generator$d(this, function (_a) {
14465
14768
  switch (_a.label) {
14466
14769
  case 0: return [4 /*yield*/, new Promise(function (resolve, reject) {
14467
14770
  _this._scheduleRefreshAuthToken({
@@ -16137,7 +16440,7 @@
16137
16440
  };
16138
16441
  Object.defineProperty(boltProvider, "__esModule", { value: true });
16139
16442
  boltProvider.BoltProvider = void 0;
16140
- var error_1$2 = error;
16443
+ var error_1$1 = error;
16141
16444
  var unsupported_type_1 = __importDefault$Z(unsupportedType);
16142
16445
  var BoltProvider = /** @class */ (function () {
16143
16446
  function BoltProvider(boltVersions, defaultVersion, alloc) {
@@ -16161,7 +16464,7 @@
16161
16464
  packer.packable(value, this._defaultBolt.transformer.toStructure)();
16162
16465
  return buf.buffer();
16163
16466
  }
16164
- throw (0, error_1$2.newError)('Could not encode provided AAD as it was encoded with an unsupported encoding scheme');
16467
+ throw (0, error_1$1.newError)('Could not encode provided AAD as it was encoded with an unsupported encoding scheme');
16165
16468
  };
16166
16469
  BoltProvider.prototype.decodeValue = function (buffer, protocolVersion) {
16167
16470
  var version = this._boltVersions.get(protocolVersion.getMajor().toString());
@@ -16181,19 +16484,19 @@
16181
16484
  };
16182
16485
  BoltProvider.prototype.decodeObject = function (buffer) {
16183
16486
  if (buffer.length === 0) {
16184
- throw (0, error_1$2.newError)('Empty byte array provided as ciphertext to decryption.');
16487
+ throw (0, error_1$1.newError)('Empty byte array provided as ciphertext to decryption.');
16185
16488
  }
16186
16489
  if (buffer[0] === 1) {
16187
16490
  var transformer = this._defaultBolt.transformer;
16188
16491
  var packBuf = this._alloc(buffer.buffer.slice(1));
16189
16492
  var struct = this._defaultBolt.unpack(packBuf);
16190
16493
  if (packBuf.hasRemaining() !== false) {
16191
- throw (0, error_1$2.newError)('Found data remaining after decoding ciphertext and metadata, unclean decode.');
16494
+ throw (0, error_1$1.newError)('Found data remaining after decoding ciphertext and metadata, unclean decode.');
16192
16495
  }
16193
16496
  return transformer.fromStructure(struct);
16194
16497
  }
16195
16498
  else {
16196
- throw (0, error_1$2.newError)("Object is encoded with version ".concat(buffer[0], ", this driver only supports version 1."));
16499
+ throw (0, error_1$1.newError)("Object is encoded with version ".concat(buffer[0], ", this driver only supports version 1."));
16197
16500
  }
16198
16501
  };
16199
16502
  return BoltProvider;
@@ -16272,7 +16575,7 @@
16272
16575
  * See the License for the specific language governing permissions and
16273
16576
  * limitations under the License.
16274
16577
  */
16275
- var __awaiter$b = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
16578
+ var __awaiter$a = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
16276
16579
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16277
16580
  return new (P || (P = Promise))(function (resolve, reject) {
16278
16581
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
@@ -16281,7 +16584,7 @@
16281
16584
  step((generator = generator.apply(thisArg, _arguments || [])).next());
16282
16585
  });
16283
16586
  };
16284
- var __generator$d = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
16587
+ var __generator$c = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
16285
16588
  var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
16286
16589
  return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
16287
16590
  function verb(n) { return function (v) { return step([n, v]); }; }
@@ -16339,7 +16642,7 @@
16339
16642
  Object.defineProperty(localKeyEncapsulation, "__esModule", { value: true });
16340
16643
  localKeyEncapsulation.LocalEncapsulationResult = localKeyEncapsulation.LocalKeyEncapsulationService = void 0;
16341
16644
  localKeyEncapsulation.localKeyEncapsulationService = localKeyEncapsulationService;
16342
- var error_1$1 = error;
16645
+ var error_1 = error;
16343
16646
  var crypto_1 = __importDefault$Y(crypto);
16344
16647
  function u8ToB64(u) {
16345
16648
  return btoa(String.fromCharCode.apply(String, __spreadArray$l([], __read$q(u), false)));
@@ -16355,7 +16658,7 @@
16355
16658
  var LocalKeyEncapsulationService = /** @class */ (function () {
16356
16659
  function LocalKeyEncapsulationService(kek) {
16357
16660
  if (kek.byteLength !== 32) {
16358
- throw (0, error_1$1.newError)("LocalKeyEncapsualationService master key must be of byteLength 32 (256 bits), got ".concat(kek.byteLength, " (").concat(kek.byteLength * 8, " bits)"));
16661
+ throw (0, error_1.newError)("LocalKeyEncapsualationService master key must be of byteLength 32 (256 bits), got ".concat(kek.byteLength, " (").concat(kek.byteLength * 8, " bits)"));
16359
16662
  }
16360
16663
  this._kek = kek;
16361
16664
  this._cryptoProvider = new crypto_1.default();
@@ -16368,9 +16671,9 @@
16368
16671
  * @experimental Part of the Client-Side Encrytion preview feature
16369
16672
  */
16370
16673
  LocalKeyEncapsulationService.prototype.encapsulate = function (options) {
16371
- return __awaiter$b(this, void 0, void 0, function () {
16674
+ return __awaiter$a(this, void 0, void 0, function () {
16372
16675
  var DEK, encapulatedDEK;
16373
- return __generator$d(this, function (_a) {
16676
+ return __generator$c(this, function (_a) {
16374
16677
  switch (_a.label) {
16375
16678
  case 0:
16376
16679
  DEK = this._cryptoProvider.getRandomValues(32);
@@ -16391,9 +16694,9 @@
16391
16694
  * @experimental Part of the Client-Side Encrytion preview feature
16392
16695
  */
16393
16696
  LocalKeyEncapsulationService.prototype.decapsulate = function (encapsulation, metadata) {
16394
- return __awaiter$b(this, void 0, void 0, function () {
16697
+ return __awaiter$a(this, void 0, void 0, function () {
16395
16698
  var _a;
16396
- return __generator$d(this, function (_b) {
16699
+ return __generator$c(this, function (_b) {
16397
16700
  switch (_b.label) {
16398
16701
  case 0:
16399
16702
  _a = Uint8Array.bind;
@@ -16439,257 +16742,6 @@
16439
16742
  return new LocalKeyEncapsulationService(masterKey);
16440
16743
  }
16441
16744
 
16442
- var encryptionProfile = {};
16443
-
16444
- /**
16445
- * Copyright (c) "Neo4j"
16446
- * Neo4j Sweden AB [https://neo4j.com]
16447
- *
16448
- * Licensed under the Apache License, Version 2.0 (the "License");
16449
- * you may not use this file except in compliance with the License.
16450
- * You may obtain a copy of the License at
16451
- *
16452
- * http://www.apache.org/licenses/LICENSE-2.0
16453
- *
16454
- * Unless required by applicable law or agreed to in writing, software
16455
- * distributed under the License is distributed on an "AS IS" BASIS,
16456
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16457
- * See the License for the specific language governing permissions and
16458
- * limitations under the License.
16459
- */
16460
- var __awaiter$a = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
16461
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16462
- return new (P || (P = Promise))(function (resolve, reject) {
16463
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16464
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
16465
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
16466
- step((generator = generator.apply(thisArg, _arguments || [])).next());
16467
- });
16468
- };
16469
- var __generator$c = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
16470
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
16471
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
16472
- function verb(n) { return function (v) { return step([n, v]); }; }
16473
- function step(op) {
16474
- if (f) throw new TypeError("Generator is already executing.");
16475
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
16476
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
16477
- if (y = 0, t) op = [op[0] & 2, t.value];
16478
- switch (op[0]) {
16479
- case 0: case 1: t = op; break;
16480
- case 4: _.label++; return { value: op[1], done: false };
16481
- case 5: _.label++; y = op[1]; op = [0]; continue;
16482
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
16483
- default:
16484
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
16485
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
16486
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
16487
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
16488
- if (t[2]) _.ops.pop();
16489
- _.trys.pop(); continue;
16490
- }
16491
- op = body.call(thisArg, _);
16492
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
16493
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
16494
- }
16495
- };
16496
- Object.defineProperty(encryptionProfile, "__esModule", { value: true });
16497
- encryptionProfile.EnvelopeEncryptionProfile = void 0;
16498
- var error_1 = error;
16499
- var integer_1 = integer;
16500
- var json_1 = json$3;
16501
- /**
16502
- * An encryption profile that enables Envelope Encryption for Neo4j Property Encryption.
16503
- *
16504
- * @since 6.3.0
16505
- * @experimental Part of the Client-Side Encrytion preview feature
16506
- */
16507
- var EnvelopeEncryptionProfile = /** @class */ (function () {
16508
- /**
16509
- *
16510
- * @param {Object} config - Configurations
16511
- * @param {string} config.name - Name of the profile, must be the same on all drivers used to access the encrypted data.
16512
- * @param {KeyEncapsulationService} config.encapsulationService - Encapsulation service used to encapsulate and dencapsulate keys. The driver ships with {@link LocalKeyEncapsulationService}, other implementations can be found as separate packages.
16513
- * @param {EncapsulatedKeyRecordRepository} config.keyRepository - Implementation of the {@link EncapsulatedKeyRecordRepository} interface, must be implemented so that the driver can access your key repository.
16514
- * @param {number} config.keyCacheTTL - How How long in milliseconds to keep a retrieved encapsulated keys cached by Id - defaults to 15 minutes
16515
- * @param {number} config.keyCacheMaxSize - How many items to keep in the key cache before pruning the oldest, setting to 0 will disable the cache - defaults to 100
16516
- * @param {number} config.keyAliasIndexTTL - How How long in milliseconds to keep the mapping of alias to key cached - defaults to 15 seconds
16517
- * @param {number} config.keyAliasIndexMaxSize - How many items to keep in the alias cache before pruning the oldest, setting to 0 will disable the index - defaults to 100
16518
- */
16519
- function EnvelopeEncryptionProfile(config) {
16520
- var _a, _b, _c, _d;
16521
- this.name = config.name;
16522
- this.encapsulationService = config.encapsulationService;
16523
- this.keyRepository = config.keyRepository;
16524
- this._keyCacheEnabled = config.keyCacheMaxSize !== 0;
16525
- this._keyCacheTTL = (_a = config.keyCacheTTL) !== null && _a !== void 0 ? _a : 15 * 60 * 1000;
16526
- this._keyCacheMaxSize = (_b = config.keyCacheMaxSize) !== null && _b !== void 0 ? _b : 100;
16527
- this._keyCache = new Map();
16528
- if (this._keyCacheEnabled) {
16529
- this._keyAliasIndexEnabled = config.keyAliasIndexMaxSize !== 0;
16530
- }
16531
- else {
16532
- this._keyAliasIndexEnabled = false;
16533
- }
16534
- this._keyAliasIndexTTL = (_c = config.keyAliasIndexTTL) !== null && _c !== void 0 ? _c : 15 * 1000;
16535
- this._keyAliasIndexMaxSize = (_d = config.keyAliasIndexMaxSize) !== null && _d !== void 0 ? _d : 100;
16536
- this._aliasIndex = new Map();
16537
- this.type = 'ENVELOPE';
16538
- this.version = (0, integer_1.int)(1);
16539
- }
16540
- /**
16541
- * @private
16542
- */
16543
- EnvelopeEncryptionProfile.prototype.findKey = function (options) {
16544
- return __awaiter$a(this, void 0, void 0, function () {
16545
- var key;
16546
- return __generator$c(this, function (_a) {
16547
- switch (_a.label) {
16548
- case 0:
16549
- if (!(typeof options === 'string')) return [3 /*break*/, 2];
16550
- return [4 /*yield*/, this._findById(options)];
16551
- case 1:
16552
- key = _a.sent();
16553
- return [3 /*break*/, 7];
16554
- case 2:
16555
- if (!(options.id != null)) return [3 /*break*/, 4];
16556
- return [4 /*yield*/, this._findById(options.id)];
16557
- case 3:
16558
- key = _a.sent();
16559
- return [3 /*break*/, 7];
16560
- case 4:
16561
- if (!(options.alias != null)) return [3 /*break*/, 6];
16562
- return [4 /*yield*/, this._findByAlias(options.alias)];
16563
- case 5:
16564
- key = _a.sent();
16565
- return [3 /*break*/, 7];
16566
- case 6: throw (0, error_1.newError)("invalid key options: ".concat((0, json_1.stringify)(options)));
16567
- case 7: return [2 /*return*/, key];
16568
- }
16569
- });
16570
- });
16571
- };
16572
- /**
16573
- * @private
16574
- */
16575
- EnvelopeEncryptionProfile.prototype.saveKey = function (alias, encapsulation, metadata) {
16576
- return __awaiter$a(this, void 0, void 0, function () {
16577
- var e_1;
16578
- return __generator$c(this, function (_a) {
16579
- switch (_a.label) {
16580
- case 0:
16581
- _a.trys.push([0, 2, , 3]);
16582
- return [4 /*yield*/, this.keyRepository.create(alias, encapsulation, metadata)];
16583
- case 1: return [2 /*return*/, _a.sent()];
16584
- case 2:
16585
- e_1 = _a.sent();
16586
- throw (0, error_1.newError)('Call to EncapsulatedKeyRepository.create threw error, see cause', '50N42', e_1);
16587
- case 3: return [2 /*return*/];
16588
- }
16589
- });
16590
- });
16591
- };
16592
- /**
16593
- * @private
16594
- */
16595
- EnvelopeEncryptionProfile.prototype._findById = function (id) {
16596
- return __awaiter$a(this, void 0, void 0, function () {
16597
- var entry, key, e_2;
16598
- var _a, _b;
16599
- return __generator$c(this, function (_c) {
16600
- switch (_c.label) {
16601
- case 0:
16602
- if (this._keyCacheEnabled) {
16603
- entry = this._keyCache.get(id);
16604
- if (entry != null) {
16605
- if (new Date().getTime() - ((_a = entry === null || entry === void 0 ? void 0 : entry.retrieved.getTime()) !== null && _a !== void 0 ? _a : 0) < ((_b = this._keyCacheTTL) !== null && _b !== void 0 ? _b : 0)) {
16606
- return [2 /*return*/, entry === null || entry === void 0 ? void 0 : entry.entry];
16607
- }
16608
- else {
16609
- this._keyCache.delete(id);
16610
- }
16611
- }
16612
- }
16613
- _c.label = 1;
16614
- case 1:
16615
- _c.trys.push([1, 3, , 4]);
16616
- return [4 /*yield*/, this.keyRepository.findById(id)];
16617
- case 2:
16618
- key = _c.sent();
16619
- return [3 /*break*/, 4];
16620
- case 3:
16621
- e_2 = _c.sent();
16622
- throw (0, error_1.newError)('Call to EncapsulatedKeyRepository.findById threw error, see cause', '50N42', e_2);
16623
- case 4:
16624
- if (key == null) {
16625
- return [2 /*return*/, undefined];
16626
- }
16627
- this._keyCache.set(id, { entry: key, retrieved: new Date() });
16628
- this._pruneCache(this._keyCache, this._keyCacheMaxSize);
16629
- return [2 /*return*/, key];
16630
- }
16631
- });
16632
- });
16633
- };
16634
- /**
16635
- * @private
16636
- */
16637
- EnvelopeEncryptionProfile.prototype._findByAlias = function (alias) {
16638
- return __awaiter$a(this, void 0, void 0, function () {
16639
- var entry, key, e_3;
16640
- var _a, _b;
16641
- return __generator$c(this, function (_c) {
16642
- switch (_c.label) {
16643
- case 0:
16644
- if (!this._keyAliasIndexEnabled) return [3 /*break*/, 3];
16645
- entry = this._aliasIndex.get(alias);
16646
- if (!(entry != null)) return [3 /*break*/, 3];
16647
- if (!(new Date().getTime() - ((_a = entry === null || entry === void 0 ? void 0 : entry.retrieved.getTime()) !== null && _a !== void 0 ? _a : 0) < ((_b = this._keyAliasIndexTTL) !== null && _b !== void 0 ? _b : 0))) return [3 /*break*/, 2];
16648
- return [4 /*yield*/, this._findById(entry === null || entry === void 0 ? void 0 : entry.entry)];
16649
- case 1: return [2 /*return*/, _c.sent()];
16650
- case 2:
16651
- this._aliasIndex.delete(alias);
16652
- _c.label = 3;
16653
- case 3:
16654
- _c.trys.push([3, 5, , 6]);
16655
- return [4 /*yield*/, this.keyRepository.findByAlias(alias)];
16656
- case 4:
16657
- key = _c.sent();
16658
- return [3 /*break*/, 6];
16659
- case 5:
16660
- e_3 = _c.sent();
16661
- throw (0, error_1.newError)('Call to EncapsulatedKeyRepository.findByAlias threw error, see cause', '50N42', e_3);
16662
- case 6:
16663
- if (key == null) {
16664
- return [2 /*return*/, undefined];
16665
- }
16666
- this._aliasIndex.set(alias, { entry: key.id(), retrieved: new Date() });
16667
- this._keyCache.set(key.id(), { entry: key, retrieved: new Date() });
16668
- this._pruneCache(this._aliasIndex, this._keyAliasIndexMaxSize);
16669
- this._pruneCache(this._keyCache, this._keyCacheMaxSize);
16670
- return [2 /*return*/, key];
16671
- }
16672
- });
16673
- });
16674
- };
16675
- /**
16676
- * @private
16677
- */
16678
- EnvelopeEncryptionProfile.prototype._pruneCache = function (cache, maxSize) {
16679
- if (cache.size > maxSize) {
16680
- var entries = Array.from(cache.entries());
16681
- entries.sort(function (a, b) { return a[1].retrieved.getTime() - b[1].retrieved.getTime(); });
16682
- var i = 0;
16683
- while (cache.size > maxSize) {
16684
- cache.delete(entries[i][0]);
16685
- i++;
16686
- }
16687
- }
16688
- };
16689
- return EnvelopeEncryptionProfile;
16690
- }());
16691
- encryptionProfile.EnvelopeEncryptionProfile = EnvelopeEncryptionProfile;
16692
-
16693
16745
  (function (exports) {
16694
16746
  /**
16695
16747
  * Copyright (c) "Neo4j"
@@ -25969,7 +26021,7 @@
25969
26021
  // This is set up this way to keep the version in the code in
25970
26022
  // sync with the npm package version, and to allow the build
25971
26023
  // system to control version names at packaging time.
25972
- version$1.default = '6.3.0';
26024
+ version$1.default = '6.3.1';
25973
26025
 
25974
26026
  var lib = {};
25975
26027