Skip to content

Commit 70aff4f

Browse files
authored
fix: signed storage URLs avoid adding expiresInSecs to query params (#734)
I noticed that we also add `expiresInSecs` to query params when we generate signed URL, we want to avoid adding it. This is not critical, can be released in the next release
1 parent 0f18b49 commit 70aff4f

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/resource_clients/dataset.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,18 +197,20 @@ export class DatasetClient<
197197

198198
const dataset = await this.get();
199199

200+
const { expiresInSecs, ...queryOptions } = options;
201+
200202
let createdItemsPublicUrl = new URL(this._url('items'));
201203

202204
if (dataset?.urlSigningSecretKey) {
203205
const signature = createStorageContentSignature({
204206
resourceId: dataset.id,
205207
urlSigningSecretKey: dataset.urlSigningSecretKey,
206-
expiresInMillis: options.expiresInSecs ? options.expiresInSecs * 1000 : undefined,
208+
expiresInMillis: expiresInSecs ? expiresInSecs * 1000 : undefined,
207209
});
208210
createdItemsPublicUrl.searchParams.set('signature', signature);
209211
}
210212

211-
createdItemsPublicUrl = applyQueryParamsToUrl(createdItemsPublicUrl, options);
213+
createdItemsPublicUrl = applyQueryParamsToUrl(createdItemsPublicUrl, queryOptions);
212214

213215
return createdItemsPublicUrl.toString();
214216
}

src/resource_clients/key_value_store.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,18 +132,20 @@ export class KeyValueStoreClient extends ResourceClient {
132132

133133
const store = await this.get();
134134

135+
const { expiresInSecs, ...queryOptions } = options;
136+
135137
let createdPublicKeysUrl = new URL(this._url('keys'));
136138

137139
if (store?.urlSigningSecretKey) {
138140
const signature = createStorageContentSignature({
139141
resourceId: store.id,
140142
urlSigningSecretKey: store.urlSigningSecretKey,
141-
expiresInMillis: options.expiresInSecs ? options.expiresInSecs * 1000 : undefined,
143+
expiresInMillis: expiresInSecs ? expiresInSecs * 1000 : undefined,
142144
});
143145
createdPublicKeysUrl.searchParams.set('signature', signature);
144146
}
145147

146-
createdPublicKeysUrl = applyQueryParamsToUrl(createdPublicKeysUrl, options);
148+
createdPublicKeysUrl = applyQueryParamsToUrl(createdPublicKeysUrl, queryOptions);
147149

148150
return createdPublicKeysUrl.toString();
149151
}

0 commit comments

Comments
 (0)