@@ -5,10 +5,10 @@ import { SHARED_SALT } from '../shared/encryption/constants';
5
5
import type { Env } from '../shared/env' ;
6
6
import { getEnvUrls } from '../shared/env' ;
7
7
import type {
8
- UserStorageFeatureKeys ,
9
- UserStorageFeatureNames ,
10
- UserStoragePathWithFeatureAndKey ,
11
- UserStoragePathWithFeatureOnly ,
8
+ UserStorageGenericFeatureKey ,
9
+ UserStorageGenericFeatureName ,
10
+ UserStorageGenericPathWithFeatureAndKey ,
11
+ UserStorageGenericPathWithFeatureOnly ,
12
12
} from '../shared/storage-schema' ;
13
13
import { createEntryPath } from '../shared/storage-schema' ;
14
14
@@ -54,42 +54,46 @@ export class UserStorage {
54
54
}
55
55
56
56
async setItem (
57
- path : UserStoragePathWithFeatureAndKey ,
57
+ path : UserStorageGenericPathWithFeatureAndKey ,
58
58
value : string ,
59
59
) : Promise < void > {
60
60
await this . #upsertUserStorage( path , value ) ;
61
61
}
62
62
63
- async batchSetItems < FeatureName extends UserStorageFeatureNames > (
64
- path : FeatureName ,
65
- values : [ UserStorageFeatureKeys < FeatureName > , string ] [ ] ,
63
+ async batchSetItems (
64
+ path : UserStorageGenericFeatureName ,
65
+ values : [ UserStorageGenericFeatureKey , string ] [ ] ,
66
66
) {
67
67
await this . #batchUpsertUserStorage( path , values ) ;
68
68
}
69
69
70
- async getItem ( path : UserStoragePathWithFeatureAndKey ) : Promise < string > {
70
+ async getItem (
71
+ path : UserStorageGenericPathWithFeatureAndKey ,
72
+ ) : Promise < string > {
71
73
return this . #getUserStorage( path ) ;
72
74
}
73
75
74
76
async getAllFeatureItems (
75
- path : UserStoragePathWithFeatureOnly ,
77
+ path : UserStorageGenericFeatureName ,
76
78
) : Promise < string [ ] | null > {
77
79
return this . #getUserStorageAllFeatureEntries( path ) ;
78
80
}
79
81
80
- async deleteItem ( path : UserStoragePathWithFeatureAndKey ) : Promise < void > {
82
+ async deleteItem (
83
+ path : UserStorageGenericPathWithFeatureAndKey ,
84
+ ) : Promise < void > {
81
85
return this . #deleteUserStorage( path ) ;
82
86
}
83
87
84
88
async deleteAllFeatureItems (
85
- path : UserStoragePathWithFeatureOnly ,
89
+ path : UserStorageGenericFeatureName ,
86
90
) : Promise < void > {
87
91
return this . #deleteUserStorageAllFeatureEntries( path ) ;
88
92
}
89
93
90
94
async batchDeleteItems (
91
- path : UserStoragePathWithFeatureOnly ,
92
- values : string [ ] ,
95
+ path : UserStorageGenericFeatureName ,
96
+ values : UserStorageGenericFeatureKey [ ] ,
93
97
) {
94
98
return this . #batchDeleteUserStorage( path , values ) ;
95
99
}
@@ -110,14 +114,16 @@ export class UserStorage {
110
114
}
111
115
112
116
async #upsertUserStorage(
113
- path : UserStoragePathWithFeatureAndKey ,
117
+ path : UserStorageGenericPathWithFeatureAndKey ,
114
118
data : string ,
115
119
) : Promise < void > {
116
120
try {
117
121
const headers = await this . #getAuthorizationHeader( ) ;
118
122
const storageKey = await this . getStorageKey ( ) ;
119
123
const encryptedData = await encryption . encryptString ( data , storageKey ) ;
120
- const encryptedPath = createEntryPath ( path , storageKey ) ;
124
+ const encryptedPath = createEntryPath ( path , storageKey , {
125
+ validateAgainstSchema : false ,
126
+ } ) ;
121
127
122
128
const url = new URL ( STORAGE_URL ( this . env , encryptedPath ) ) ;
123
129
@@ -150,7 +156,7 @@ export class UserStorage {
150
156
}
151
157
152
158
async #batchUpsertUserStorage(
153
- path : UserStoragePathWithFeatureOnly ,
159
+ path : UserStorageGenericPathWithFeatureOnly ,
154
160
data : [ string , string ] [ ] ,
155
161
) : Promise < void > {
156
162
try {
@@ -201,7 +207,7 @@ export class UserStorage {
201
207
}
202
208
203
209
async #batchUpsertUserStorageWithAlreadyHashedAndEncryptedEntries(
204
- path : UserStoragePathWithFeatureOnly ,
210
+ path : UserStorageGenericPathWithFeatureOnly ,
205
211
encryptedData : [ string , string ] [ ] ,
206
212
) : Promise < void > {
207
213
try {
@@ -242,12 +248,14 @@ export class UserStorage {
242
248
}
243
249
244
250
async #getUserStorage(
245
- path : UserStoragePathWithFeatureAndKey ,
251
+ path : UserStorageGenericPathWithFeatureAndKey ,
246
252
) : Promise < string > {
247
253
try {
248
254
const headers = await this . #getAuthorizationHeader( ) ;
249
255
const storageKey = await this . getStorageKey ( ) ;
250
- const encryptedPath = createEntryPath ( path , storageKey ) ;
256
+ const encryptedPath = createEntryPath ( path , storageKey , {
257
+ validateAgainstSchema : false ,
258
+ } ) ;
251
259
252
260
const url = new URL ( STORAGE_URL ( this . env , encryptedPath ) ) ;
253
261
@@ -300,7 +308,7 @@ export class UserStorage {
300
308
}
301
309
302
310
async #getUserStorageAllFeatureEntries(
303
- path : UserStoragePathWithFeatureOnly ,
311
+ path : UserStorageGenericPathWithFeatureOnly ,
304
312
) : Promise < string [ ] | null > {
305
313
try {
306
314
const headers = await this . #getAuthorizationHeader( ) ;
@@ -383,12 +391,14 @@ export class UserStorage {
383
391
}
384
392
385
393
async #deleteUserStorage(
386
- path : UserStoragePathWithFeatureAndKey ,
394
+ path : UserStorageGenericPathWithFeatureAndKey ,
387
395
) : Promise < void > {
388
396
try {
389
397
const headers = await this . #getAuthorizationHeader( ) ;
390
398
const storageKey = await this . getStorageKey ( ) ;
391
- const encryptedPath = createEntryPath ( path , storageKey ) ;
399
+ const encryptedPath = createEntryPath ( path , storageKey , {
400
+ validateAgainstSchema : false ,
401
+ } ) ;
392
402
393
403
const url = new URL ( STORAGE_URL ( this . env , encryptedPath ) ) ;
394
404
@@ -428,7 +438,7 @@ export class UserStorage {
428
438
}
429
439
430
440
async #deleteUserStorageAllFeatureEntries(
431
- path : UserStoragePathWithFeatureOnly ,
441
+ path : UserStorageGenericPathWithFeatureOnly ,
432
442
) : Promise < void > {
433
443
try {
434
444
const headers = await this . #getAuthorizationHeader( ) ;
@@ -469,7 +479,7 @@ export class UserStorage {
469
479
}
470
480
471
481
async #batchDeleteUserStorage(
472
- path : UserStoragePathWithFeatureOnly ,
482
+ path : UserStorageGenericPathWithFeatureOnly ,
473
483
data : string [ ] ,
474
484
) : Promise < void > {
475
485
try {
0 commit comments