@edgestore/server 1.0.0-next.5 → 1.0.0-rc.7

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.
Files changed (91) hide show
  1. package/README.md +2 -2
  2. package/agent-docs/README.md +1 -1
  3. package/agent-docs/astro.md +3 -3
  4. package/agent-docs/backend-client.md +5 -8
  5. package/agent-docs/express.md +3 -3
  6. package/agent-docs/fastify.md +3 -3
  7. package/agent-docs/hono.md +3 -3
  8. package/agent-docs/next.md +3 -3
  9. package/agent-docs/provider-azure-blob.md +150 -57
  10. package/agent-docs/provider-custom.md +29 -3
  11. package/agent-docs/provider-edgestore.md +2 -2
  12. package/agent-docs/provider-s3.md +124 -24
  13. package/agent-docs/remix.md +3 -3
  14. package/agent-docs/tanstack-start.md +3 -3
  15. package/dist/adapters/dispatcher.d.ts.map +1 -1
  16. package/dist/adapters/dispatcher.js +10 -1
  17. package/dist/adapters/shared.d.ts +25 -103
  18. package/dist/adapters/shared.d.ts.map +1 -1
  19. package/dist/adapters/shared.js +157 -110
  20. package/dist/core/client/index.d.ts +0 -4
  21. package/dist/core/client/index.d.ts.map +1 -1
  22. package/dist/core/provider.d.ts +0 -1
  23. package/dist/core/provider.d.ts.map +1 -1
  24. package/dist/core/provider.js +1 -4
  25. package/dist/index.d.ts +3 -1
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +2 -1
  28. package/dist/libs/env.d.ts.map +1 -1
  29. package/dist/libs/env.js +3 -0
  30. package/dist/libs/errors/EdgeStoreCredentialsError.js +1 -1
  31. package/dist/providers/azure-blob/blocks.d.ts +48 -0
  32. package/dist/providers/azure-blob/blocks.d.ts.map +1 -0
  33. package/dist/providers/azure-blob/blocks.js +126 -0
  34. package/dist/providers/azure-blob/index.d.ts +76 -51
  35. package/dist/providers/azure-blob/index.d.ts.map +1 -1
  36. package/dist/providers/azure-blob/index.js +189 -107
  37. package/dist/providers/edgestore/index.d.ts +41 -24
  38. package/dist/providers/edgestore/index.d.ts.map +1 -1
  39. package/dist/providers/edgestore/index.js +33 -20
  40. package/dist/providers/s3/backendUpload.d.ts +2 -5
  41. package/dist/providers/s3/backendUpload.d.ts.map +1 -1
  42. package/dist/providers/s3/backendUpload.js +19 -57
  43. package/dist/providers/s3/index.d.ts +3 -12
  44. package/dist/providers/s3/index.d.ts.map +1 -1
  45. package/dist/providers/s3/index.js +24 -45
  46. package/dist/providers/s3/multipart.d.ts +3 -5
  47. package/dist/providers/s3/multipart.d.ts.map +1 -1
  48. package/dist/providers/s3/multipart.js +26 -62
  49. package/dist/providers/s3/options.d.ts +13 -35
  50. package/dist/providers/s3/options.d.ts.map +1 -1
  51. package/dist/providers/storage/multipartSession.d.ts +51 -0
  52. package/dist/providers/storage/multipartSession.d.ts.map +1 -0
  53. package/dist/providers/storage/multipartSession.js +83 -0
  54. package/dist/providers/storage/objectKeys.d.ts +41 -0
  55. package/dist/providers/storage/objectKeys.d.ts.map +1 -0
  56. package/dist/providers/{s3/keys.js → storage/objectKeys.js} +31 -4
  57. package/dist/providers/storage/transfer.d.ts +18 -0
  58. package/dist/providers/storage/transfer.d.ts.map +1 -0
  59. package/dist/providers/storage/transfer.js +69 -0
  60. package/dist/test-utils/edgestoreSmoke.d.ts.map +1 -1
  61. package/dist/version.d.ts +1 -1
  62. package/dist/version.d.ts.map +1 -1
  63. package/package.json +4 -11
  64. package/src/adapters/dispatcher.ts +14 -0
  65. package/src/adapters/shared.ts +179 -127
  66. package/src/core/client/index.ts +0 -4
  67. package/src/core/provider.ts +0 -8
  68. package/src/index.ts +3 -8
  69. package/src/libs/env.ts +9 -0
  70. package/src/libs/errors/EdgeStoreCredentialsError.ts +1 -1
  71. package/src/providers/azure-blob/blocks.ts +201 -0
  72. package/src/providers/azure-blob/index.ts +289 -171
  73. package/src/providers/edgestore/index.ts +30 -26
  74. package/src/providers/s3/backendUpload.ts +20 -55
  75. package/src/providers/s3/index.ts +32 -59
  76. package/src/providers/s3/multipart.ts +36 -94
  77. package/src/providers/s3/options.ts +13 -36
  78. package/src/providers/storage/multipartSession.ts +145 -0
  79. package/src/providers/storage/objectKeys.ts +106 -0
  80. package/src/providers/storage/transfer.ts +105 -0
  81. package/src/test-utils/edgestoreSmoke.ts +3 -5
  82. package/src/version.ts +1 -1
  83. package/core/index.d.ts +0 -1
  84. package/core/index.js +0 -1
  85. package/dist/core/index.d.ts +0 -4
  86. package/dist/core/index.d.ts.map +0 -1
  87. package/dist/core/index.js +0 -3
  88. package/dist/providers/s3/keys.d.ts +0 -10
  89. package/dist/providers/s3/keys.d.ts.map +0 -1
  90. package/src/core/index.ts +0 -9
  91. package/src/providers/s3/keys.ts +0 -59
package/README.md CHANGED
@@ -19,8 +19,8 @@ npm install @edgestore/server @edgestore/react
19
19
  Then go to your [Dashboard](https://dashboard.edgestore.dev), create a new project and copy the keys to your environment variables.
20
20
 
21
21
  ```shell title=".env"
22
- EDGE_STORE_ACCESS_KEY=your-access-key
23
- EDGE_STORE_SECRET_KEY=your-secret-key
22
+ EDGESTORE_ACCESS_KEY=your-access-key
23
+ EDGESTORE_SECRET_KEY=your-secret-key
24
24
  ```
25
25
 
26
26
  ### Backend
@@ -1,4 +1,4 @@
1
- # @edgestore/server 1.0.0-next.5: agent references
1
+ # @edgestore/server 1.0.0-rc.7: agent references
2
2
 
3
3
  These references ship with this exact package version. Prefer them over newer online examples.
4
4
  Generated from the authored documentation; do not edit these files directly.
@@ -12,7 +12,7 @@ React component.
12
12
  Packages to install (use the application’s package manager):
13
13
 
14
14
  ```text
15
- @edgestore/server @edgestore/react
15
+ @edgestore/server@rc @edgestore/react@rc
16
16
  ```
17
17
 
18
18
  ### Environment variables
@@ -22,8 +22,8 @@ Copy your project's keys from the [dashboard](https://dashboard.edgestore.dev/)
22
22
  Example: title=".env"
23
23
 
24
24
  ```sh
25
- EDGE_STORE_ACCESS_KEY=your-access-key
26
- EDGE_STORE_SECRET_KEY=your-secret-key
25
+ EDGESTORE_ACCESS_KEY=your-access-key
26
+ EDGESTORE_SECRET_KEY=your-secret-key
27
27
  ```
28
28
 
29
29
  > WARNING
@@ -54,12 +54,11 @@ export { handler as GET, handler as POST };
54
54
  > `accessControl`, `beforeUpload`, or `beforeDelete`. Perform authorization in
55
55
  > the server code that calls it.
56
56
 
57
- The hosted `edgestore()` provider supports the complete backend client. S3
58
- supports `upload`, `get`, `delete`, `deleteMany`, and private-read
59
- `createSignedUrl` / `createSignedUrls`, accepting key or URL references.
60
- Azure Blob Storage supports lookup, deletion, and private signed reads.
61
- Unsupported operations, such as S3 listing and confirmation or Azure backend
62
- upload, remain absent from each provider's client type.
57
+ The hosted `edgestore()` provider supports the complete backend client. S3 and
58
+ Azure Blob Storage support `upload`, `get`, `delete`, `deleteMany`, and
59
+ private-read `createSignedUrl` / `createSignedUrls`, accepting key or URL
60
+ references. Unsupported operations, such as listing and confirmation, remain
61
+ absent from each provider's client type.
63
62
 
64
63
  ## Backend Upload
65
64
 
@@ -280,5 +279,3 @@ type UploadOutput = BackendOutputs['publicFiles']['upload'];
280
279
  The helpers infer capabilities and provider-specific types directly from the
281
280
  router, including custom providers. Use `EdgeStoreClient<typeof router>` for
282
281
  the complete backend client type.
283
-
284
- `InferClientResponse` remains as a deprecated alias of `InferClientOutputs`.
@@ -9,7 +9,7 @@ Source: https://next.edgestore.dev/docs/adapters/express
9
9
  Packages to install (use the application’s package manager):
10
10
 
11
11
  ```text
12
- @edgestore/server @edgestore/react
12
+ @edgestore/server@rc @edgestore/react@rc
13
13
  ```
14
14
 
15
15
  ### Environment variables
@@ -19,8 +19,8 @@ Copy your project's keys from the [dashboard](https://dashboard.edgestore.dev/)
19
19
  Example: title=".env"
20
20
 
21
21
  ```sh
22
- EDGE_STORE_ACCESS_KEY=your-access-key
23
- EDGE_STORE_SECRET_KEY=your-secret-key
22
+ EDGESTORE_ACCESS_KEY=your-access-key
23
+ EDGESTORE_SECRET_KEY=your-secret-key
24
24
  ```
25
25
 
26
26
  > WARNING
@@ -9,7 +9,7 @@ Source: https://next.edgestore.dev/docs/adapters/fastify
9
9
  Packages to install (use the application’s package manager):
10
10
 
11
11
  ```text
12
- @edgestore/server @edgestore/react
12
+ @edgestore/server@rc @edgestore/react@rc
13
13
  ```
14
14
 
15
15
  ### Environment variables
@@ -19,8 +19,8 @@ Copy your project's keys from the [dashboard](https://dashboard.edgestore.dev/)
19
19
  Example: title=".env"
20
20
 
21
21
  ```sh
22
- EDGE_STORE_ACCESS_KEY=your-access-key
23
- EDGE_STORE_SECRET_KEY=your-secret-key
22
+ EDGESTORE_ACCESS_KEY=your-access-key
23
+ EDGESTORE_SECRET_KEY=your-secret-key
24
24
  ```
25
25
 
26
26
  > WARNING
@@ -11,7 +11,7 @@ Install `@edgestore/server` in the backend and `@edgestore/react` in the fronten
11
11
  Packages to install (use the application’s package manager):
12
12
 
13
13
  ```text
14
- @edgestore/server @edgestore/react
14
+ @edgestore/server@rc @edgestore/react@rc
15
15
  ```
16
16
 
17
17
  ### Environment variables
@@ -21,8 +21,8 @@ Copy your project's keys from the [dashboard](https://dashboard.edgestore.dev/)
21
21
  Example: title=".env.local (backend only)"
22
22
 
23
23
  ```sh
24
- EDGE_STORE_ACCESS_KEY=your-access-key
25
- EDGE_STORE_SECRET_KEY=your-secret-key
24
+ EDGESTORE_ACCESS_KEY=your-access-key
25
+ EDGESTORE_SECRET_KEY=your-secret-key
26
26
  ```
27
27
 
28
28
  > WARNING
@@ -7,7 +7,7 @@ Source: https://next.edgestore.dev/docs/quick-start
7
7
  Packages to install (use the application’s package manager):
8
8
 
9
9
  ```text
10
- @edgestore/server @edgestore/react
10
+ @edgestore/server@rc @edgestore/react@rc
11
11
  ```
12
12
 
13
13
  ### Environment Variables
@@ -17,8 +17,8 @@ Copy your project's keys from the [dashboard](https://dashboard.edgestore.dev/)
17
17
  Example: title=".env.local"
18
18
 
19
19
  ```sh
20
- EDGE_STORE_ACCESS_KEY=your-access-key
21
- EDGE_STORE_SECRET_KEY=your-secret-key
20
+ EDGESTORE_ACCESS_KEY=your-access-key
21
+ EDGESTORE_SECRET_KEY=your-secret-key
22
22
  ```
23
23
 
24
24
  > WARNING
@@ -2,84 +2,177 @@
2
2
 
3
3
  Source: https://next.edgestore.dev/docs/providers/azure-blob
4
4
 
5
- You can also use the EdgeStore package with your own Azure Blob Storage. You might want to do that in case you have strict company policies that require you to have all the data in your own Azure account.
5
+ Use the Azure Blob provider when your files must live in your own Azure
6
+ storage account. It supports direct browser uploads, automatic block uploads
7
+ for large files, backend uploads, private signed reads, and stable key
8
+ references. Your application owns the container's CORS, access, and lifecycle
9
+ configuration.
6
10
 
7
11
  The provider creates short-lived, blob-scoped SAS URLs for browser uploads and
8
- private reads. Permanent file URLs never contain credentials. Advanced hosted
9
- features such as image processing still require separate infrastructure.
12
+ private reads. The account key stays on the server, and permanent file URLs
13
+ never contain credentials. Hosted features such as image processing are not
14
+ available.
10
15
 
11
16
  ## Installation
12
17
 
13
- You need to install some peer dependencies to use this provider.
14
-
15
18
  Packages to install (use the application’s package manager):
16
19
 
17
20
  ```text
18
21
  @azure/storage-blob
19
22
  ```
20
23
 
21
- Chain `.provider()` when defining your router, then pass the router to the adapter.
22
-
23
24
  ```ts
24
25
  import { initEdgeStore } from '@edgestore/server';
25
- import {
26
- createEdgeStoreNextHandler,
27
- type CreateContextOptions,
28
- } from '@edgestore/server/adapters/next/pages';
29
- // [!code ++]
30
26
  import { azureBlob } from '@edgestore/server/providers/azure-blob';
31
- import { z } from 'zod';
32
27
 
33
- // ...
28
+ const es = initEdgeStore.create();
29
+ export const router = es.router({
30
+ documents: es.fileBucket().accessControl('private'),
31
+ }).provider(
32
+ azureBlob({
33
+ storageAccountName: 'myaccount',
34
+ containerName: 'edgestore',
35
+ }),
36
+ );
37
+
38
+ export type EdgeStoreRouter = typeof router;
39
+ ```
40
+
41
+ Pass `router` to your framework adapter as its `router` option. Set
42
+ `ES_AZURE_ACCOUNT_KEY` on the server, and set `EDGESTORE_JWT_SECRET` to a
43
+ stable random secret, for example one generated with `openssl rand -base64 32`.
44
+ All application instances must share it. Credentials are only checked when the
45
+ provider is first used, so defining a router does not require them.
46
+
47
+ | Option | Default / environment variable |
48
+ | ---------------------------- | -------------------------------------------------------------------------------------- |
49
+ | `storageAccountName` | `ES_AZURE_ACCOUNT_NAME` |
50
+ | `storageAccountKey` | `ES_AZURE_ACCOUNT_KEY` |
51
+ | `containerName` | `ES_AZURE_CONTAINER_NAME` |
52
+ | `endpoint` | `ES_AZURE_ENDPOINT`, otherwise `https://<account>.blob.core.windows.net` |
53
+ | `baseUrl` | `EDGESTORE_BASE_URL`, otherwise `<endpoint>/<container>` |
54
+ | `uploadUrlExpiresIn` | 3600 seconds |
55
+ | `signedUrlExpiresIn` | 3600 seconds |
56
+ | `multipart.thresholdBytes` | 100 MiB |
57
+ | `multipart.partSizeBytes` | 16 MiB; minimum 5 MiB, maximum 4000 MiB |
58
+ | `multipart.sessionExpiresIn` | 86400 seconds |
59
+ | `jwtSecret` | Multipart signing override; otherwise `EDGESTORE_JWT_SECRET` or `EDGESTORE_SECRET_KEY` |
60
+
61
+ Signed URL lifetimes must be between 1 and 604800 seconds. Upload URLs grant
62
+ only create/write permission on one blob, and read URLs grant only read
63
+ permission.
64
+
65
+ ## Paths and object settings
66
+
67
+ Blobs are stored as `<router bucket>/<path>`. The default path adds `_public/`
68
+ for public buckets, then the router path values and the file name. Use `path`
69
+ to change everything after the router bucket, which is always kept:
70
+
71
+ ```ts
72
+ azureBlob({
73
+ path: ({ defaultPath }) => `tenants/${defaultPath}`,
74
+ objectOptions: {
75
+ cacheControl: 'private, max-age=3600',
76
+ contentDisposition: 'attachment',
77
+ metadata: { source: 'edgestore' },
78
+ },
79
+ });
80
+ ```
81
+
82
+ `objectOptions` can also be a function that receives the same arguments as
83
+ `path`. The content type comes from the uploaded file. Browser and backend
84
+ uploads apply the same settings.
85
+
86
+ ## Large files and cancellation
87
+
88
+ Files above the threshold are uploaded as blocks, in parallel, with retries.
89
+ The browser requests block upload URLs as it reaches each block, so
90
+ `uploadUrlExpiresIn` only needs to cover one block transfer. A session can
91
+ request URLs and complete until `multipart.sessionExpiresIn` passes. Before
92
+ committing, the provider checks that every block exists with the expected size,
93
+ which catches incomplete uploads.
34
94
 
35
- const es = initEdgeStore.context<Context>().create();
36
- const router = es.router({
37
- publicFiles: es.fileBucket(),
38
- }).provider(azureBlob());
95
+ Azure has no multipart session to cancel. Blocks that are never committed are
96
+ discarded automatically after seven days, so canceled and failed uploads need
97
+ no lifecycle rule.
39
98
 
40
- export default createEdgeStoreNextHandler<Context>({
41
- router,
42
- createContext,
99
+ Backend uploads use the same paths, object settings, and block configuration,
100
+ and send up to four blocks at a time.
101
+
102
+ ## Private files
103
+
104
+ Use `accessControl('private')` for private buckets. Cookie-based access-control
105
+ rules are not supported and fail at initialization. Create read URLs from the
106
+ backend client:
107
+
108
+ ```ts
109
+ const { signedUrl } = await router.client.documents.createSignedUrl({
110
+ url: { key: 'documents/report.pdf' },
111
+ expiresIn: 300,
43
112
  });
44
113
  ```
45
114
 
46
- ## Options
115
+ Add `.autoSignedUrls({ expiresIn: 300 })` to a private router bucket to receive
116
+ a read URL with each upload response.
117
+
118
+ ## Container configuration
119
+
120
+ Keep the container private. Azure grants anonymous read access to a whole
121
+ container, not to a prefix, so public buckets need their own read path.
122
+ Public uploads return an unsigned URL under `_public/`, which a private
123
+ container answers with 403. Either:
124
+
125
+ * serve `_public/` through a CDN or proxy that can read the private container,
126
+ such as Azure Front Door with a private origin, and set `baseUrl` to it; or
127
+ * if the container holds only public buckets, set its public access level to
128
+ **Blob** (anonymous reads of individual blobs, no listing). Every file in
129
+ that container is then readable by URL, so never combine this with private
130
+ buckets.
131
+
132
+ Configure blob service CORS for your application origins so browsers can
133
+ upload:
134
+
135
+ ```json
136
+ [{
137
+ "AllowedOrigins": ["http://localhost:3000", "https://app.example.com"],
138
+ "AllowedMethods": ["PUT", "GET", "HEAD"],
139
+ "AllowedHeaders": ["*"],
140
+ "ExposedHeaders": ["*"],
141
+ "MaxAgeInSeconds": 3600
142
+ }]
143
+ ```
144
+
145
+ ## Local development with Azurite
146
+
147
+ [Azurite](https://learn.microsoft.com/azure/storage/common/storage-use-azurite)
148
+ emulates Blob Storage locally:
149
+
150
+ ```bash
151
+ docker run -p 10000:10000 mcr.microsoft.com/azure-storage/azurite azurite-blob --blobHost 0.0.0.0
152
+ ```
47
153
 
48
154
  ```ts
49
- export type AzureBlobProviderOptions = {
50
- /**
51
- * The storage account name for Azure Blob Storage
52
- * Can also be set via the `ES_AZURE_ACCOUNT_NAME` environment variable.
53
- */
54
- storageAccountName?: string;
55
- /**
56
- * Account key used for server-side requests and signing short-lived URLs.
57
- * Can also be set via the `ES_AZURE_ACCOUNT_KEY` environment variable.
58
- */
59
- storageAccountKey?: string;
60
- /**
61
- * Azure Blob Storage container name
62
- * Can also be set via the `ES_AZURE_CONTAINER_NAME` environment variable.
63
- */
64
- containerName?: string;
65
- /**
66
- * Optional base URL for Azurite or another compatible endpoint.
67
- * Can also be set via the `ES_AZURE_BASE_URL` environment variable.
68
- */
69
- customBaseUrl?: string;
70
- /**
71
- * Lifetime of browser upload URLs in seconds.
72
- * @default 3600
73
- */
74
- uploadUrlExpiresIn?: number;
75
- /**
76
- * Default lifetime of private read URLs in seconds.
77
- * @default 3600
78
- */
79
- signedUrlExpiresIn?: number;
80
- };
155
+ azureBlob({
156
+ storageAccountName: 'devstoreaccount1',
157
+ // Azurite's documented development account key.
158
+ storageAccountKey:
159
+ 'Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==',
160
+ containerName: 'edgestore',
161
+ endpoint: 'http://127.0.0.1:10000/devstoreaccount1',
162
+ });
81
163
  ```
82
164
 
83
- The account key stays on the server. Upload URLs receive only create/write
84
- permissions, while private read URLs receive only read permission and expire
85
- independently.
165
+ ## Limitations
166
+
167
+ * `temporary` and `replaceTargetUrl` are rejected. Track application-owned files
168
+ in your database and delete old files after a successful replacement.
169
+ * Azure SAS URLs grant write access to one blob and cannot limit its size or
170
+ the write operation. A browser holding an upload URL can therefore write
171
+ that blob directly, with any size and blob headers. The router's `maxSize`,
172
+ mime-type checks, and `objectOptions` apply to the declared upload and to
173
+ backend uploads, but are not enforced on bytes a browser sends. If you need
174
+ those guarantees, validate each stored blob after upload from a storage
175
+ event, for example an Event Grid `BlobCreated` subscription that triggers an
176
+ Azure Function, and delete blobs that fail your checks.
177
+ * Confirmation, listing, restore, and generated thumbnails are unsupported.
178
+ * Only account-key authentication is supported.
@@ -40,7 +40,6 @@ const baseUrl = 'https://files.example.com';
40
40
 
41
41
  export const myProvider = defineProvider({
42
42
  name: 'my-storage',
43
- baseUrl,
44
43
  async init() {
45
44
  return {};
46
45
  },
@@ -55,7 +54,7 @@ export const myProvider = defineProvider({
55
54
  const key = storage.createKey({ bucketName, fileInfo });
56
55
  return {
57
56
  uploadUrl: await storage.signUpload(key),
58
- accessUrl: `${baseUrl}/${key}`,
57
+ url: `${baseUrl}/${key}`,
59
58
  };
60
59
  },
61
60
  },
@@ -81,6 +80,22 @@ export const myProvider = defineProvider({
81
80
  The resulting backend client exposes `get`, but not `upload`, `list`, or
82
81
  mutations, because those optional capabilities were not defined.
83
82
 
83
+ `init` runs when the browser initializes EdgeStore. Return `{}` unless the
84
+ browser must prepare access to your file origin before loading protected
85
+ files. In that case, return `clientInit` with the absolute URLs to request and
86
+ any headers to send; the browser calls each URL with credentials:
87
+
88
+ ```ts
89
+ async init({ ctx }) {
90
+ return {
91
+ clientInit: {
92
+ urls: ['https://files.example.com/_init'],
93
+ headers: { 'x-file-token': await createFileToken(ctx) },
94
+ },
95
+ };
96
+ },
97
+ ```
98
+
84
99
  ## Complete provider
85
100
 
86
101
  A complete provider can add direct backend uploads, pagination, mutations, and
@@ -115,7 +130,6 @@ const toFile = (object: Awaited<ReturnType<typeof storage.head>>) => ({
115
130
 
116
131
  export const myProvider = defineProvider({
117
132
  name: 'my-storage',
118
- baseUrl,
119
133
  async init() {
120
134
  return {};
121
135
  },
@@ -251,6 +265,18 @@ A single-part plan can include `uploadHeaders`. The browser sends them with the
251
265
  upload request, which lets a provider sign headers such as `Content-Type` or
252
266
  storage metadata into the URL.
253
267
 
268
+ Return `id` from `uploads.request` when your storage assigns stable file IDs.
269
+ The browser upload result includes it so apps can save it.
270
+
271
+ If your storage processes files after the transfer, return `id` and implement
272
+ `uploads.getStatus({ bucketName, id })`. It returns
273
+ `{ status: 'processing' }`, `{ status: 'canceled' }`, or
274
+ `{ status: 'completed', file }` with the processed `url`, `key`,
275
+ `thumbnailUrl`, and `sizeBytes`. Browser uploads with `waitForProcessing` poll
276
+ it through an encrypted status token that only the uploading browser receives.
277
+ Providers without `getStatus` treat uploads as ready once the transfer
278
+ completes.
279
+
254
280
  Set `uploads.supportedOptions` to reject upload options your storage cannot
255
281
  honor. For example, `supportedOptions: { temporary: false }` removes
256
282
  `temporary` from the browser and backend upload types, and EdgeStore rejects it
@@ -35,14 +35,14 @@ export type EdgeStoreProviderOptions = {
35
35
  * Access key for your EdgeStore project.
36
36
  * Can be found in the EdgeStore dashboard.
37
37
  *
38
- * This can be omitted if the `EDGE_STORE_ACCESS_KEY` environment variable is set.
38
+ * This can be omitted if the `EDGESTORE_ACCESS_KEY` environment variable is set.
39
39
  */
40
40
  accessKey?: string;
41
41
  /**
42
42
  * Secret key for your EdgeStore project.
43
43
  * Can be found in the EdgeStore dashboard.
44
44
  *
45
- * This can be omitted if the `EDGE_STORE_SECRET_KEY` environment variable is set.
45
+ * This can be omitted if the `EDGESTORE_SECRET_KEY` environment variable is set.
46
46
  */
47
47
  secretKey?: string;
48
48
  /**
@@ -36,26 +36,27 @@ export type EdgeStoreRouter = typeof router;
36
36
  ```
37
37
 
38
38
  Pass `router` to your framework adapter as its `router` option.
39
- Set `EDGE_STORE_JWT_SECRET` to a stable random secret, for example one generated
39
+ Set `EDGESTORE_JWT_SECRET` to a stable random secret, for example one generated
40
40
  with `openssl rand -base64 32`. All application instances must share it.
41
41
 
42
- Credentials use the AWS SDK's default provider chain, including environment
43
- variables, shared config, and instance/task roles. You can also pass
44
- `credentials` with an AWS credentials object or provider function.
45
-
46
- | Option | Default / environment variable |
47
- | ---------------------------- | ---------------------------------------------------------------------------------------- |
48
- | `bucketName` | `ES_AWS_BUCKET_NAME` |
49
- | `region` | `ES_AWS_REGION`, then AWS SDK region resolution |
50
- | `endpoint` | `ES_AWS_ENDPOINT` |
51
- | `forcePathStyle` | `ES_AWS_FORCE_PATH_STYLE === 'true'` |
52
- | `baseUrl` | `EDGE_STORE_BASE_URL`, otherwise the storage URL |
53
- | `uploadUrlExpiresIn` | 3600 seconds |
54
- | `signedUrlExpiresIn` | 3600 seconds |
55
- | `multipart.thresholdBytes` | 100 MiB |
56
- | `multipart.partSizeBytes` | 16 MiB; minimum 5 MiB |
57
- | `multipart.sessionExpiresIn` | 86400 seconds |
58
- | `jwtSecret` | Multipart signing override; otherwise `EDGE_STORE_JWT_SECRET` or `EDGE_STORE_SECRET_KEY` |
42
+ Pass `credentials` with an AWS credentials object or provider function. If it
43
+ is unset, `ES_AWS_ACCESS_KEY_ID` and `ES_AWS_SECRET_ACCESS_KEY` are used when
44
+ both are set; otherwise the AWS SDK's default provider chain applies, including
45
+ environment variables, shared config, and instance/task roles.
46
+
47
+ | Option | Default / environment variable |
48
+ | ---------------------------- | -------------------------------------------------------------------------------------- |
49
+ | `bucketName` | `ES_AWS_BUCKET_NAME` |
50
+ | `region` | `ES_AWS_REGION`, then AWS SDK region resolution |
51
+ | `endpoint` | `ES_AWS_ENDPOINT` |
52
+ | `forcePathStyle` | `ES_AWS_FORCE_PATH_STYLE === 'true'` |
53
+ | `baseUrl` | `EDGESTORE_BASE_URL`, otherwise the storage URL |
54
+ | `uploadUrlExpiresIn` | 3600 seconds |
55
+ | `signedUrlExpiresIn` | 3600 seconds |
56
+ | `multipart.thresholdBytes` | 100 MiB |
57
+ | `multipart.partSizeBytes` | 16 MiB; minimum 5 MiB |
58
+ | `multipart.sessionExpiresIn` | 86400 seconds |
59
+ | `jwtSecret` | Multipart signing override; otherwise `EDGESTORE_JWT_SECRET` or `EDGESTORE_SECRET_KEY` |
59
60
 
60
61
  Setting `jwtSecret` does not replace the required environment secret.
61
62
  Signed URL lifetimes must be between 1 and 604800 seconds; temporary AWS
@@ -240,7 +241,111 @@ required for browser multipart completion:
240
241
 
241
242
  ## S3-compatible services
242
243
 
243
- For local MinIO:
244
+ `s3()` works with services that implement the S3 API, including Cloudflare R2,
245
+ Backblaze B2, DigitalOcean Spaces, Google Cloud Storage, Tigris, Supabase
246
+ Storage, and MinIO. Point `endpoint` at the service, pass its access keys as
247
+ `credentials` (or the `ES_AWS_ACCESS_KEY_ID` / `ES_AWS_SECRET_ACCESS_KEY`
248
+ environment variables), and configure bucket CORS as described above, including
249
+ exposing `ETag`.
250
+
251
+ The endpoint must be reachable from both your server and the browser. `baseUrl`
252
+ defaults to `<endpoint>/<bucket>`; set it to the service's public or CDN URL when
253
+ public files are served from a different host. Services differ in support for
254
+ tags, storage classes, and KMS encryption, so only set `objectOptions` your
255
+ service supports. EdgeStore's CI runs against MinIO; the setups below follow each
256
+ service's S3 compatibility documentation.
257
+
258
+ ### Cloudflare R2
259
+
260
+ ```ts
261
+ s3({
262
+ bucketName: 'edgestore',
263
+ region: 'auto',
264
+ endpoint: 'https://<ACCOUNT_ID>.r2.cloudflarestorage.com',
265
+ credentials: { accessKeyId: '...', secretAccessKey: '...' },
266
+ // Public files: an r2.dev subdomain or a custom domain on the bucket.
267
+ baseUrl: 'https://files.example.com',
268
+ });
269
+ ```
270
+
271
+ Create the keys as an R2 API token. R2 does not support object tagging or KMS
272
+ encryption, and supports the `STANDARD` and `STANDARD_IA` storage classes.
273
+
274
+ ### Backblaze B2
275
+
276
+ ```ts
277
+ s3({
278
+ bucketName: 'edgestore',
279
+ region: 'us-west-004',
280
+ endpoint: 'https://s3.us-west-004.backblazeb2.com',
281
+ credentials: { accessKeyId: '<keyID>', secretAccessKey: '<applicationKey>' },
282
+ });
283
+ ```
284
+
285
+ Use the region from your bucket's S3 endpoint and an application key. B2 does
286
+ not support object tagging or KMS encryption.
287
+
288
+ ### DigitalOcean Spaces
289
+
290
+ ```ts
291
+ s3({
292
+ bucketName: 'edgestore',
293
+ region: 'nyc3',
294
+ endpoint: 'https://nyc3.digitaloceanspaces.com',
295
+ credentials: { accessKeyId: '...', secretAccessKey: '...' },
296
+ // Optional: serve public files through the Spaces CDN.
297
+ baseUrl: 'https://edgestore.nyc3.cdn.digitaloceanspaces.com',
298
+ });
299
+ ```
300
+
301
+ Spaces supports customer-provided encryption keys but not KMS encryption.
302
+
303
+ ### Google Cloud Storage
304
+
305
+ ```ts
306
+ s3({
307
+ bucketName: 'edgestore',
308
+ region: 'auto',
309
+ endpoint: 'https://storage.googleapis.com',
310
+ credentials: { accessKeyId: '<HMAC access ID>', secretAccessKey: '<HMAC secret>' },
311
+ });
312
+ ```
313
+
314
+ Cloud Storage's XML API is S3-compatible when you use HMAC keys, including
315
+ signed URLs, multipart uploads, and multi-object delete. Create an HMAC key for a
316
+ service account with access to the bucket. Tagging and KMS headers are not
317
+ supported.
318
+
319
+ ### Tigris
320
+
321
+ ```ts
322
+ s3({
323
+ bucketName: 'edgestore',
324
+ region: 'auto',
325
+ endpoint: 'https://t3.storage.dev',
326
+ credentials: { accessKeyId: '...', secretAccessKey: '...' },
327
+ });
328
+ ```
329
+
330
+ ### Supabase Storage
331
+
332
+ ```ts
333
+ s3({
334
+ bucketName: 'edgestore',
335
+ region: '<project region>',
336
+ endpoint: 'https://<project_ref>.storage.supabase.co/storage/v1/s3',
337
+ forcePathStyle: true,
338
+ credentials: { accessKeyId: '...', secretAccessKey: '...' },
339
+ // Public buckets are served from the object endpoint.
340
+ baseUrl:
341
+ 'https://<project_ref>.supabase.co/storage/v1/object/public/edgestore',
342
+ });
343
+ ```
344
+
345
+ Create S3 access keys in your project's storage settings. Supabase Storage does
346
+ not support object tagging, storage classes, or server-side encryption options.
347
+
348
+ ### MinIO
244
349
 
245
350
  ```ts
246
351
  s3({
@@ -251,11 +356,6 @@ s3({
251
356
  });
252
357
  ```
253
358
 
254
- The endpoint must be reachable from both the application server and browser.
255
- Set `baseUrl` explicitly for custom domains or virtual-hosted endpoint layouts.
256
- S3-compatible services may differ in support for KMS, storage classes, tags,
257
- checksums, and lifecycle policies; only enable settings your service supports.
258
-
259
359
  ## Limitations
260
360
 
261
361
  * `temporary` and `replaceTargetUrl` are rejected. Track application-owned files
@@ -12,7 +12,7 @@ React Router application needs a separate backend; this route runs on the server
12
12
  Packages to install (use the application’s package manager):
13
13
 
14
14
  ```text
15
- @edgestore/server @edgestore/react
15
+ @edgestore/server@rc @edgestore/react@rc
16
16
  ```
17
17
 
18
18
  ### Environment variables
@@ -22,8 +22,8 @@ Copy your project's keys from the [dashboard](https://dashboard.edgestore.dev/)
22
22
  Example: title=".env"
23
23
 
24
24
  ```sh
25
- EDGE_STORE_ACCESS_KEY=your-access-key
26
- EDGE_STORE_SECRET_KEY=your-secret-key
25
+ EDGESTORE_ACCESS_KEY=your-access-key
26
+ EDGESTORE_SECRET_KEY=your-secret-key
27
27
  ```
28
28
 
29
29
  > WARNING