react-native-nitro-storage 0.10.3 → 0.10.4

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.
@@ -11,6 +11,24 @@
11
11
 
12
12
  namespace NitroStorage {
13
13
 
14
+ // Storage strings are length-delimited; C-string conversion aliases keys at NUL.
15
+ static NSString* nsStringFromStdString(const std::string& value) {
16
+ NSString* result = [[NSString alloc] initWithBytes:value.data()
17
+ length:value.size() encoding:NSUTF8StringEncoding];
18
+ if (!result) {
19
+ throw std::runtime_error("NitroStorage: String is not valid UTF-8");
20
+ }
21
+ return result;
22
+ }
23
+
24
+ static std::string stdStringFromNSString(NSString* value) {
25
+ const char* bytes = [value UTF8String];
26
+ if (!bytes) {
27
+ throw std::runtime_error("NitroStorage: String cannot be encoded as UTF-8");
28
+ }
29
+ return std::string(bytes, [value lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
30
+ }
31
+
14
32
  static NSString* const kKeychainService = @"com.nitrostorage.keychain";
15
33
  static NSString* const kBiometricKeychainService = @"com.nitrostorage.biometric";
16
34
  static NSString* const kDiskSuiteName = @"com.nitrostorage.disk";
@@ -104,7 +122,7 @@ static std::string NitroDiskStorePath() {
104
122
  attributes:nil
105
123
  error:nil];
106
124
  NSString* path = [[directory URLByAppendingPathComponent:@"nitro-storage-disk.sqlite"] path];
107
- return std::string([path UTF8String]);
125
+ return stdStringFromNSString(path);
108
126
  }
109
127
 
110
128
  static NitroStorage::SqliteDiskStore& NitroSqliteDiskStore() {
@@ -129,7 +147,7 @@ static void migrateSuiteIntoSqlite() {
129
147
  if (![value isKindOfClass:[NSString class]]) {
130
148
  continue;
131
149
  }
132
- pairs.emplace_back(std::string([key UTF8String]), std::string([(NSString*)value UTF8String]));
150
+ pairs.emplace_back(stdStringFromNSString(key), stdStringFromNSString((NSString*)value));
133
151
  }
134
152
  NitroSqliteDiskStore().migrateIfAbsent(pairs);
135
153
  }
@@ -300,7 +318,7 @@ IOSStorageAdapterCpp::~IOSStorageAdapterCpp() {}
300
318
  #ifdef NITRO_STORAGE_TESTING
301
319
  void resetSqliteDiskStoreForTesting() {
302
320
  SqliteDiskStore::resetShared();
303
- NSString* path = [NSString stringWithUTF8String:NitroDiskStorePath().c_str()];
321
+ NSString* path = nsStringFromStdString(NitroDiskStorePath());
304
322
  NSFileManager* files = [NSFileManager defaultManager];
305
323
  [files removeItemAtPath:path error:nil];
306
324
  [files removeItemAtPath:[path stringByAppendingString:@"-wal"] error:nil];
@@ -312,7 +330,7 @@ void resetSqliteDiskStoreForTesting() {
312
330
 
313
331
  void IOSStorageAdapterCpp::setDisk(const std::string& key, const std::string& value) {
314
332
  NitroSqliteDiskStore().set(key, value);
315
- NSString* nsKey = [NSString stringWithUTF8String:key.c_str()];
333
+ NSString* nsKey = nsStringFromStdString(key);
316
334
  NSUserDefaults* defaults = NitroDiskDefaults();
317
335
  NSUserDefaults* standard = [NSUserDefaults standardUserDefaults];
318
336
  if (defaults != standard && [standard objectForKey:nsKey] != nil) {
@@ -325,17 +343,17 @@ std::optional<std::string> IOSStorageAdapterCpp::getDisk(const std::string& key)
325
343
  if (auto stored = NitroSqliteDiskStore().get(key)) {
326
344
  return stored;
327
345
  }
328
- NSString* nsKey = [NSString stringWithUTF8String:key.c_str()];
346
+ NSString* nsKey = nsStringFromStdString(key);
329
347
  NSString* result = migrateLegacyDiskValue(nsKey);
330
348
  if (!result) return std::nullopt;
331
- const std::string value([result UTF8String]);
349
+ const std::string value = stdStringFromNSString(result);
332
350
  NitroSqliteDiskStore().set(key, value);
333
351
  return value;
334
352
  }
335
353
 
336
354
  void IOSStorageAdapterCpp::deleteDisk(const std::string& key) {
337
355
  NitroSqliteDiskStore().remove(key);
338
- NSString* nsKey = [NSString stringWithUTF8String:key.c_str()];
356
+ NSString* nsKey = nsStringFromStdString(key);
339
357
  NSUserDefaults* defaults = NitroDiskDefaults();
340
358
  [defaults removeObjectForKey:nsKey];
341
359
  NSUserDefaults* standard = [NSUserDefaults standardUserDefaults];
@@ -349,7 +367,7 @@ bool IOSStorageAdapterCpp::hasDisk(const std::string& key) {
349
367
  if (NitroSqliteDiskStore().has(key)) {
350
368
  return true;
351
369
  }
352
- NSString* nsKey = [NSString stringWithUTF8String:key.c_str()];
370
+ NSString* nsKey = nsStringFromStdString(key);
353
371
  NSUserDefaults* defaults = NitroDiskDefaults();
354
372
  if ([defaults objectForKey:nsKey] != nil) {
355
373
  return true;
@@ -371,13 +389,13 @@ std::vector<std::string> IOSStorageAdapterCpp::getAllKeysDisk() {
371
389
  NSUserDefaults* standard = [NSUserDefaults standardUserDefaults];
372
390
  for (NSString* key in entries) {
373
391
  if (!isInternalDiskKey(key)) {
374
- combined.insert(std::string([key UTF8String]));
392
+ combined.insert(stdStringFromNSString(key));
375
393
  }
376
394
  }
377
395
  for (NSString* key in [registeredLegacyDiskKeys() allObjects]) {
378
396
  if ([entries objectForKey:key] == nil &&
379
397
  [standard stringForKey:key] != nil) {
380
- combined.insert(std::string([key UTF8String]));
398
+ combined.insert(stdStringFromNSString(key));
381
399
  }
382
400
  }
383
401
  std::vector<std::string> keys;
@@ -419,7 +437,7 @@ void IOSStorageAdapterCpp::setDiskBatch(
419
437
  NSUserDefaults* standard = [NSUserDefaults standardUserDefaults];
420
438
  NSMutableArray* legacyKeysToRemove = [NSMutableArray array];
421
439
  for (size_t i = 0; i < keys.size() && i < values.size(); ++i) {
422
- NSString* nsKey = [NSString stringWithUTF8String:keys[i].c_str()];
440
+ NSString* nsKey = nsStringFromStdString(keys[i]);
423
441
  if (defaults != standard && [standard objectForKey:nsKey] != nil) {
424
442
  [legacyKeysToRemove addObject:nsKey];
425
443
  }
@@ -444,7 +462,7 @@ std::vector<std::optional<std::string>> IOSStorageAdapterCpp::getDiskBatch(
444
462
  void IOSStorageAdapterCpp::deleteDiskBatch(const std::vector<std::string>& keys) {
445
463
  NitroSqliteDiskStore().removeBatch(keys);
446
464
  for (const auto& key : keys) {
447
- NSString* nsKey = [NSString stringWithUTF8String:key.c_str()];
465
+ NSString* nsKey = nsStringFromStdString(key);
448
466
  NSUserDefaults* defaults = NitroDiskDefaults();
449
467
  [defaults removeObjectForKey:nsKey];
450
468
  NSUserDefaults* standard = [NSUserDefaults standardUserDefaults];
@@ -552,7 +570,7 @@ static BiometricKeychainSnapshot captureBiometricValue(
552
570
  throw std::runtime_error("NitroStorage: Biometric snapshot value is not UTF-8");
553
571
  }
554
572
  snapshot.present = true;
555
- snapshot.value = std::string([stringValue UTF8String]);
573
+ snapshot.value = stdStringFromNSString(stringValue);
556
574
  snapshot.accessControl = (SecAccessControlRef)CFRetain((__bridge CFTypeRef)accessControl);
557
575
  CFRelease(result);
558
576
  return snapshot;
@@ -571,10 +589,6 @@ static NSMutableDictionary* allAccountsQuery(NSString* service, NSString* access
571
589
  return query;
572
590
  }
573
591
 
574
- static NSString* nsStringFromStdString(const std::string& value) {
575
- return [NSString stringWithUTF8String:value.c_str()];
576
- }
577
-
578
592
  static NSData* nsDataFromStdString(const std::string& value) {
579
593
  return [nsStringFromStdString(value) dataUsingEncoding:NSUTF8StringEncoding];
580
594
  }
@@ -633,7 +647,7 @@ static std::optional<std::string> getSecureValue(NSString* nsKey, NSString* grou
633
647
  if (status == errSecSuccess && result) {
634
648
  NSData* data = (__bridge_transfer NSData*)result;
635
649
  NSString* str = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
636
- if (str) return std::string([str UTF8String]);
650
+ if (str) return stdStringFromNSString(str);
637
651
  }
638
652
  if (status == errSecInteractionNotAllowed) {
639
653
  throw taggedStorageError(
@@ -727,7 +741,7 @@ static std::vector<std::string> keychainAccountsForService(NSString* service, NS
727
741
  for (NSDictionary* item in itemArray) {
728
742
  NSString* account = item[(__bridge id)kSecAttrAccount];
729
743
  if (account) {
730
- keys.push_back(std::string([account UTF8String]));
744
+ keys.push_back(stdStringFromNSString(account));
731
745
  }
732
746
  }
733
747
  }
@@ -745,7 +759,7 @@ void IOSStorageAdapterCpp::setSecure(const std::string& key, const std::string&
745
759
  groupStr = keychainAccessGroup_;
746
760
  accessControlLevel = accessControlLevel_;
747
761
  }
748
- NSString* group = groupStr.empty() ? nil : [NSString stringWithUTF8String:groupStr.c_str()];
762
+ NSString* group = groupStr.empty() ? nil : nsStringFromStdString(groupStr);
749
763
  setSecureValue(nsKey, data, group, accessControlLevel);
750
764
  markSecureKeySet(key);
751
765
  }
@@ -757,7 +771,7 @@ std::optional<std::string> IOSStorageAdapterCpp::getSecure(const std::string& ke
757
771
  std::lock_guard<std::mutex> lock(accessGroupMutex_);
758
772
  groupStr = keychainAccessGroup_;
759
773
  }
760
- NSString* group = groupStr.empty() ? nil : [NSString stringWithUTF8String:groupStr.c_str()];
774
+ NSString* group = groupStr.empty() ? nil : nsStringFromStdString(groupStr);
761
775
  return getSecureValue(nsKey, group);
762
776
  }
763
777
 
@@ -768,20 +782,20 @@ void IOSStorageAdapterCpp::deleteSecure(const std::string& key) {
768
782
  std::lock_guard<std::mutex> lock(accessGroupMutex_);
769
783
  groupStr = keychainAccessGroup_;
770
784
  }
771
- NSString* group = groupStr.empty() ? nil : [NSString stringWithUTF8String:groupStr.c_str()];
785
+ NSString* group = groupStr.empty() ? nil : nsStringFromStdString(groupStr);
772
786
  deleteSecureValue(nsKey, group);
773
787
  markSecureKeyRemoved(key);
774
788
  markBiometricKeyRemoved(key);
775
789
  }
776
790
 
777
791
  bool IOSStorageAdapterCpp::hasSecure(const std::string& key) {
778
- NSString* nsKey = [NSString stringWithUTF8String:key.c_str()];
792
+ NSString* nsKey = nsStringFromStdString(key);
779
793
  std::string groupStr;
780
794
  {
781
795
  std::lock_guard<std::mutex> lock(accessGroupMutex_);
782
796
  groupStr = keychainAccessGroup_;
783
797
  }
784
- NSString* group = groupStr.empty() ? nil : [NSString stringWithUTF8String:groupStr.c_str()];
798
+ NSString* group = groupStr.empty() ? nil : nsStringFromStdString(groupStr);
785
799
  NSMutableDictionary* secureQuery = baseKeychainQuery(nsKey, kKeychainService, group);
786
800
  disableKeychainInteraction(secureQuery);
787
801
  if (SecItemCopyMatching((__bridge CFDictionaryRef)secureQuery, NULL) == errSecSuccess) {
@@ -836,7 +850,7 @@ void IOSStorageAdapterCpp::setSecureBatch(
836
850
  groupStr = keychainAccessGroup_;
837
851
  accessControlLevel = accessControlLevel_;
838
852
  }
839
- NSString* group = groupStr.empty() ? nil : [NSString stringWithUTF8String:groupStr.c_str()];
853
+ NSString* group = groupStr.empty() ? nil : nsStringFromStdString(groupStr);
840
854
  for (size_t i = 0; i < keys.size() && i < values.size(); ++i) {
841
855
  setSecureValue(
842
856
  nsStringFromStdString(keys[i]),
@@ -856,7 +870,7 @@ std::vector<std::optional<std::string>> IOSStorageAdapterCpp::getSecureBatch(
856
870
  std::lock_guard<std::mutex> lock(accessGroupMutex_);
857
871
  groupStr = keychainAccessGroup_;
858
872
  }
859
- NSString* group = groupStr.empty() ? nil : [NSString stringWithUTF8String:groupStr.c_str()];
873
+ NSString* group = groupStr.empty() ? nil : nsStringFromStdString(groupStr);
860
874
  std::vector<std::optional<std::string>> results;
861
875
  results.reserve(keys.size());
862
876
  for (const auto& key : keys) {
@@ -871,7 +885,7 @@ void IOSStorageAdapterCpp::deleteSecureBatch(const std::vector<std::string>& key
871
885
  std::lock_guard<std::mutex> lock(accessGroupMutex_);
872
886
  groupStr = keychainAccessGroup_;
873
887
  }
874
- NSString* group = groupStr.empty() ? nil : [NSString stringWithUTF8String:groupStr.c_str()];
888
+ NSString* group = groupStr.empty() ? nil : nsStringFromStdString(groupStr);
875
889
  for (const auto& key : keys) {
876
890
  deleteSecureValue(nsStringFromStdString(key), group);
877
891
  markSecureKeyRemoved(key);
@@ -885,7 +899,7 @@ void IOSStorageAdapterCpp::clearSecure() {
885
899
  std::lock_guard<std::mutex> lock(accessGroupMutex_);
886
900
  groupStr = keychainAccessGroup_;
887
901
  }
888
- NSString* group = groupStr.empty() ? nil : [NSString stringWithUTF8String:groupStr.c_str()];
902
+ NSString* group = groupStr.empty() ? nil : nsStringFromStdString(groupStr);
889
903
  NSMutableDictionary* secureQuery = [@{
890
904
  (__bridge id)kSecClass: (__bridge id)kSecClassGenericPassword,
891
905
  (__bridge id)kSecAttrService: kKeychainService
@@ -954,7 +968,7 @@ void IOSStorageAdapterCpp::setSecureBiometricWithLevel(const std::string& key, c
954
968
  if (level < 0 || level > 2) {
955
969
  throw std::runtime_error("NitroStorage: Invalid biometric level");
956
970
  }
957
- NSString* nsKey = [NSString stringWithUTF8String:key.c_str()];
971
+ NSString* nsKey = nsStringFromStdString(key);
958
972
  NSData* data = nsDataFromStdString(value);
959
973
  std::string groupStr;
960
974
  int accessControlLevel;
@@ -963,7 +977,7 @@ void IOSStorageAdapterCpp::setSecureBiometricWithLevel(const std::string& key, c
963
977
  groupStr = keychainAccessGroup_;
964
978
  accessControlLevel = accessControlLevel_;
965
979
  }
966
- NSString* group = groupStr.empty() ? nil : [NSString stringWithUTF8String:groupStr.c_str()];
980
+ NSString* group = groupStr.empty() ? nil : nsStringFromStdString(groupStr);
967
981
 
968
982
  const BiometricKeychainSnapshot previousBiometric = captureBiometricValue(nsKey, group);
969
983
  const std::optional<std::string> previousPlain = getSecureValue(nsKey, group);
@@ -1064,13 +1078,13 @@ void IOSStorageAdapterCpp::setSecureBiometricWithLevel(const std::string& key, c
1064
1078
  }
1065
1079
 
1066
1080
  std::optional<std::string> IOSStorageAdapterCpp::getSecureBiometric(const std::string& key) {
1067
- NSString* nsKey = [NSString stringWithUTF8String:key.c_str()];
1081
+ NSString* nsKey = nsStringFromStdString(key);
1068
1082
  std::string groupStr;
1069
1083
  {
1070
1084
  std::lock_guard<std::mutex> lock(accessGroupMutex_);
1071
1085
  groupStr = keychainAccessGroup_;
1072
1086
  }
1073
- NSString* group = groupStr.empty() ? nil : [NSString stringWithUTF8String:groupStr.c_str()];
1087
+ NSString* group = groupStr.empty() ? nil : nsStringFromStdString(groupStr);
1074
1088
  NSMutableDictionary* query = baseKeychainQuery(nsKey, kBiometricKeychainService, group);
1075
1089
  query[(__bridge id)kSecReturnData] = @YES;
1076
1090
  query[(__bridge id)kSecMatchLimit] = (__bridge id)kSecMatchLimitOne;
@@ -1080,7 +1094,7 @@ std::optional<std::string> IOSStorageAdapterCpp::getSecureBiometric(const std::s
1080
1094
  if (status == errSecSuccess && result) {
1081
1095
  NSData* data = (__bridge_transfer NSData*)result;
1082
1096
  NSString* str = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
1083
- if (str) return std::string([str UTF8String]);
1097
+ if (str) return stdStringFromNSString(str);
1084
1098
  }
1085
1099
  if (status == errSecInteractionNotAllowed) {
1086
1100
  throw taggedStorageError(
@@ -1102,13 +1116,13 @@ std::optional<std::string> IOSStorageAdapterCpp::getSecureBiometric(const std::s
1102
1116
  }
1103
1117
 
1104
1118
  void IOSStorageAdapterCpp::deleteSecureBiometric(const std::string& key) {
1105
- NSString* nsKey = [NSString stringWithUTF8String:key.c_str()];
1119
+ NSString* nsKey = nsStringFromStdString(key);
1106
1120
  std::string groupStr;
1107
1121
  {
1108
1122
  std::lock_guard<std::mutex> lock(accessGroupMutex_);
1109
1123
  groupStr = keychainAccessGroup_;
1110
1124
  }
1111
- NSString* group = groupStr.empty() ? nil : [NSString stringWithUTF8String:groupStr.c_str()];
1125
+ NSString* group = groupStr.empty() ? nil : nsStringFromStdString(groupStr);
1112
1126
  NSMutableDictionary* query = baseKeychainQuery(nsKey, kBiometricKeychainService, group);
1113
1127
  const OSStatus status = SecItemDelete((__bridge CFDictionaryRef)query);
1114
1128
  throwIfDeleteFailed(status, "Biometric delete");
@@ -1116,13 +1130,13 @@ void IOSStorageAdapterCpp::deleteSecureBiometric(const std::string& key) {
1116
1130
  }
1117
1131
 
1118
1132
  bool IOSStorageAdapterCpp::hasSecureBiometric(const std::string& key) {
1119
- NSString* nsKey = [NSString stringWithUTF8String:key.c_str()];
1133
+ NSString* nsKey = nsStringFromStdString(key);
1120
1134
  std::string groupStr;
1121
1135
  {
1122
1136
  std::lock_guard<std::mutex> lock(accessGroupMutex_);
1123
1137
  groupStr = keychainAccessGroup_;
1124
1138
  }
1125
- NSString* group = groupStr.empty() ? nil : [NSString stringWithUTF8String:groupStr.c_str()];
1139
+ NSString* group = groupStr.empty() ? nil : nsStringFromStdString(groupStr);
1126
1140
  NSMutableDictionary* query = baseKeychainQuery(nsKey, kBiometricKeychainService, group);
1127
1141
  disableKeychainInteraction(query);
1128
1142
  const OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query, NULL);
@@ -1143,7 +1157,7 @@ void IOSStorageAdapterCpp::clearSecureBiometric() {
1143
1157
  std::lock_guard<std::mutex> lock(accessGroupMutex_);
1144
1158
  groupStr = keychainAccessGroup_;
1145
1159
  }
1146
- NSString* group = groupStr.empty() ? nil : [NSString stringWithUTF8String:groupStr.c_str()];
1160
+ NSString* group = groupStr.empty() ? nil : nsStringFromStdString(groupStr);
1147
1161
  NSMutableDictionary* query = [@{
1148
1162
  (__bridge id)kSecClass: (__bridge id)kSecClassGenericPassword,
1149
1163
  (__bridge id)kSecAttrService: kBiometricKeychainService
@@ -1179,7 +1193,7 @@ void IOSStorageAdapterCpp::ensureSecureKeyCacheHydrated() {
1179
1193
  std::lock_guard<std::mutex> lock(accessGroupMutex_);
1180
1194
  groupStr = keychainAccessGroup_;
1181
1195
  }
1182
- NSString* nsGroup = groupStr.empty() ? nil : [NSString stringWithUTF8String:groupStr.c_str()];
1196
+ NSString* nsGroup = groupStr.empty() ? nil : nsStringFromStdString(groupStr);
1183
1197
 
1184
1198
  // These can throw errSecInteractionNotAllowed — let the exception propagate
1185
1199
  // so the cache is NOT marked hydrated (will be retried on next access)
@@ -39,6 +39,14 @@ function createStorageCore(buildAdapter) {
39
39
  let eventObserverRedactSecureValues = true;
40
40
  const storageEvents = new _storageEvents.StorageEventRegistry();
41
41
  const metrics = (0, _metrics.createMetricsRegistry)();
42
+ function setOwnDataProperty(target, key, value) {
43
+ Object.defineProperty(target, key, {
44
+ configurable: true,
45
+ enumerable: true,
46
+ value,
47
+ writable: true
48
+ });
49
+ }
42
50
  const durability = (0, _durability.createDurabilityCoordinator)({
43
51
  backend: {
44
52
  setBatch: (keys, values, scope) => {
@@ -643,7 +651,11 @@ function createStorageCore(buildAdapter) {
643
651
  return measureOperation("storage:getKeysByPrefix", scope, () => {
644
652
  (0, _internal.assertValidScope)(scope);
645
653
  if (scope === _Storage.StorageScope.Memory) {
646
- return Array.from(memoryStore.keys()).filter(key => key.startsWith(prefix));
654
+ const keys = [];
655
+ for (const key of memoryStore.keys()) {
656
+ if (key.startsWith(prefix)) keys.push(key);
657
+ }
658
+ return keys;
647
659
  }
648
660
  if (scope === _Storage.StorageScope.Disk) {
649
661
  flushDiskWrites();
@@ -665,7 +677,7 @@ function createStorageCore(buildAdapter) {
665
677
  keys.forEach(key => {
666
678
  const value = memoryStore.get(key);
667
679
  if (typeof value === "string") {
668
- result[key] = value;
680
+ setOwnDataProperty(result, key, (0, _internal.unescapeCollidingRawValue)(value));
669
681
  }
670
682
  });
671
683
  return result;
@@ -680,7 +692,7 @@ function createStorageCore(buildAdapter) {
680
692
  keys.forEach((key, idx) => {
681
693
  const value = values[idx];
682
694
  if (value !== undefined) {
683
- result[key] = (0, _internal.unescapeCollidingRawValue)(value);
695
+ setOwnDataProperty(result, key, (0, _internal.unescapeCollidingRawValue)(value));
684
696
  }
685
697
  });
686
698
  return result;
@@ -691,10 +703,11 @@ function createStorageCore(buildAdapter) {
691
703
  (0, _internal.assertValidScope)(scope);
692
704
  const result = {};
693
705
  if (scope === _Storage.StorageScope.Memory) {
694
- for (const key of memoryStore.keys()) {
695
- const value = memoryStore.get(key);
696
- if (typeof value === "string") result[key] = (0, _internal.unescapeCollidingRawValue)(value);
697
- }
706
+ memoryStore.forEach((value, key) => {
707
+ if (typeof value === "string") {
708
+ setOwnDataProperty(result, key, (0, _internal.unescapeCollidingRawValue)(value));
709
+ }
710
+ });
698
711
  return result;
699
712
  }
700
713
  if (scope === _Storage.StorageScope.Disk) {
@@ -708,7 +721,9 @@ function createStorageCore(buildAdapter) {
708
721
  const values = adapter.backend.getBatch(keys, scope);
709
722
  keys.forEach((key, idx) => {
710
723
  const val = values[idx];
711
- if (val !== undefined) result[key] = (0, _internal.unescapeCollidingRawValue)(val);
724
+ if (val !== undefined) {
725
+ setOwnDataProperty(result, key, (0, _internal.unescapeCollidingRawValue)(val));
726
+ }
712
727
  });
713
728
  return result;
714
729
  });
@@ -2455,7 +2470,7 @@ function createStorageCore(buildAdapter) {
2455
2470
  const initial = {};
2456
2471
  if (defaultValue) {
2457
2472
  for (const id of defaultValue) {
2458
- initial[id] = true;
2473
+ setOwnDataProperty(initial, id, true);
2459
2474
  }
2460
2475
  }
2461
2476
  const item = createStorageItem({
@@ -2471,7 +2486,7 @@ function createStorageCore(buildAdapter) {
2471
2486
  const next = {
2472
2487
  ...current
2473
2488
  };
2474
- next[id] = true;
2489
+ setOwnDataProperty(next, id, true);
2475
2490
  item.set(next);
2476
2491
  };
2477
2492
  const deleteId = id => {
@@ -2496,7 +2511,7 @@ function createStorageCore(buildAdapter) {
2496
2511
  const getTyped = () => {
2497
2512
  const typed = {};
2498
2513
  for (const id of Object.keys(item.get())) {
2499
- typed[id] = true;
2514
+ setOwnDataProperty(typed, id, true);
2500
2515
  }
2501
2516
  return typed;
2502
2517
  };