Skip to content

Commit 353007b

Browse files
authored
Allow all origins for Cross-Origin Storage (#1716)
* Allow all `origins` for cross-origin storage * fix(cos): add missing origins field to CrossOriginStorageRequestFileHandleOptions type
1 parent 6cc0630 commit 353007b

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

packages/transformers/src/utils/cache/CrossOriginStorageCache.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ export class CrossOriginStorage {
112112
_storeBlobInCOS = async (blob, hashHex) => {
113113
const handle = await navigator.crossOriginStorage.requestFileHandle(makeHashDescriptor(hashHex), {
114114
create: true,
115+
origins: '*',
115116
});
116117
const writableStream = await handle.createWritable();
117118
await writableStream.write(blob);

packages/transformers/src/utils/cache/cross-origin-storage.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ interface CrossOriginStorageRequestFileHandleHash {
1717
*/
1818
interface CrossOriginStorageRequestFileHandleOptions {
1919
create?: boolean;
20+
/**
21+
* Restricts (or opens up) which origins may later read the stored file.
22+
* `'*'` makes the resource available to all origins; an array of origin
23+
* strings restricts it to that set; omitting the field keeps the
24+
* default (same-site only). Visibility can be upgraded but never
25+
* downgraded.
26+
* @see https://github.com/WICG/cross-origin-storage#example-restricting-resources-to-specific-origins
27+
*/
28+
origins?: '*' | string[];
2029
}
2130

2231
/**

0 commit comments

Comments
 (0)