@hot-updater/supabase 0.36.0 → 0.36.1

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.
package/dist/edge.cjs CHANGED
@@ -1,4 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_supabaseEdgeFunctionStorage = require("./supabaseEdgeFunctionStorage-CRgm-8_T.cjs");
2
+ const require_supabaseEdgeFunctionStorage = require("./supabaseEdgeFunctionStorage-DczYIzj_.cjs");
3
3
  exports.supabaseEdgeFunctionDatabase = require_supabaseEdgeFunctionStorage.supabaseEdgeFunctionDatabase;
4
4
  exports.supabaseEdgeFunctionStorage = require_supabaseEdgeFunctionStorage.supabaseEdgeFunctionStorage;
package/dist/edge.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { r as supabaseEdgeFunctionDatabase, t as supabaseEdgeFunctionStorage } from "./supabaseEdgeFunctionStorage-DaRCRhn-.mjs";
1
+ import { i as supabaseEdgeFunctionDatabase, t as supabaseEdgeFunctionStorage } from "./supabaseEdgeFunctionStorage-B3yJ5yys.mjs";
2
2
  export { supabaseEdgeFunctionDatabase, supabaseEdgeFunctionStorage };
@@ -6909,7 +6909,7 @@ const SOURCE_TEMPLATE = `// add this to your App.tsx
6909
6909
  import { HotUpdater } from "@hot-updater/react-native";
6910
6910
 
6911
6911
  function App() {
6912
- return ...
6912
+ return null; // Replace with your app root
6913
6913
  }
6914
6914
 
6915
6915
  export default HotUpdater.wrap({
@@ -6904,7 +6904,7 @@ const SOURCE_TEMPLATE = `// add this to your App.tsx
6904
6904
  import { HotUpdater } from "@hot-updater/react-native";
6905
6905
 
6906
6906
  function App() {
6907
- return ...
6907
+ return null; // Replace with your app root
6908
6908
  }
6909
6909
 
6910
6910
  export default HotUpdater.wrap({
package/dist/index.cjs CHANGED
@@ -21,7 +21,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
21
21
  enumerable: true
22
22
  }) : target, mod));
23
23
  //#endregion
24
- const require_supabaseEdgeFunctionStorage = require("./supabaseEdgeFunctionStorage-CRgm-8_T.cjs");
24
+ const require_supabaseEdgeFunctionStorage = require("./supabaseEdgeFunctionStorage-DczYIzj_.cjs");
25
25
  let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
26
26
  let _supabase_supabase_js = require("@supabase/supabase-js");
27
27
  let fs_promises = require("fs/promises");
@@ -54,6 +54,13 @@ async function verifyObjectCanBeSignedForRuntime({ bucket, key }) {
54
54
  expiresIn: 3600
55
55
  });
56
56
  }
57
+ const parseSupabaseStorageUri = (storageUri) => {
58
+ const { bucket, key } = (0, _hot_updater_plugin_core.parseStorageUri)(storageUri, "supabase-storage");
59
+ return {
60
+ bucket,
61
+ key: require_supabaseEdgeFunctionStorage.decodeStorageObjectKey(key)
62
+ };
63
+ };
57
64
  const supabaseStorage = (0, _hot_updater_plugin_core.createUniversalStoragePlugin)({
58
65
  name: "supabaseStorage",
59
66
  supportedProtocol: "supabase-storage",
@@ -68,7 +75,7 @@ const supabaseStorage = (0, _hot_updater_plugin_core.createUniversalStoragePlugi
68
75
  return {
69
76
  node: {
70
77
  async delete(storageUri) {
71
- const { key, bucket: bucketName } = (0, _hot_updater_plugin_core.parseStorageUri)(storageUri, "supabase-storage");
78
+ const { key, bucket: bucketName } = parseSupabaseStorageUri(storageUri);
72
79
  if (bucketName !== config.bucketName) throw new Error(`Bucket name mismatch: expected "${config.bucketName}", but found "${bucketName}".`);
73
80
  const { error } = await bucket.remove([key]);
74
81
  if (error) {
@@ -93,7 +100,7 @@ const supabaseStorage = (0, _hot_updater_plugin_core.createUniversalStoragePlugi
93
100
  return { storageUri: `supabase-storage://${upload.data.fullPath}` };
94
101
  },
95
102
  async exists(storageUri) {
96
- const { key, bucket: bucketName } = (0, _hot_updater_plugin_core.parseStorageUri)(storageUri, "supabase-storage");
103
+ const { key, bucket: bucketName } = parseSupabaseStorageUri(storageUri);
97
104
  if (bucketName !== config.bucketName) throw new Error(`Bucket name mismatch: expected "${config.bucketName}", but found "${bucketName}".`);
98
105
  const { data, error } = await bucket.exists(key);
99
106
  if (data === false) return false;
@@ -105,7 +112,7 @@ const supabaseStorage = (0, _hot_updater_plugin_core.createUniversalStoragePlugi
105
112
  return data;
106
113
  },
107
114
  async downloadFile(storageUri, filePath) {
108
- const { key, bucket: bucketName } = (0, _hot_updater_plugin_core.parseStorageUri)(storageUri, "supabase-storage");
115
+ const { key, bucket: bucketName } = parseSupabaseStorageUri(storageUri);
109
116
  if (bucketName !== config.bucketName) throw new Error(`Bucket name mismatch: expected "${config.bucketName}", but found "${bucketName}".`);
110
117
  const { data, error } = await bucket.download(key);
111
118
  if (error) throw new Error(`Failed to download bundle: ${error.message}`);
@@ -116,7 +123,7 @@ const supabaseStorage = (0, _hot_updater_plugin_core.createUniversalStoragePlugi
116
123
  },
117
124
  runtime: {
118
125
  async readText(storageUri) {
119
- const { key, bucket: bucketName } = (0, _hot_updater_plugin_core.parseStorageUri)(storageUri, "supabase-storage");
126
+ const { key, bucket: bucketName } = parseSupabaseStorageUri(storageUri);
120
127
  if (bucketName !== config.bucketName) throw new Error(`Bucket name mismatch: expected "${config.bucketName}", but found "${bucketName}".`);
121
128
  const { data, error } = await bucket.download(key);
122
129
  if (error) {
@@ -129,7 +136,7 @@ const supabaseStorage = (0, _hot_updater_plugin_core.createUniversalStoragePlugi
129
136
  async getDownloadUrl(storageUri) {
130
137
  const u = new URL(storageUri);
131
138
  if (u.protocol.replace(":", "") !== "supabase-storage") throw new Error("Invalid Supabase storage URI protocol");
132
- let key = `${u.host}${u.pathname}`.replace(/^\//, "");
139
+ let key = require_supabaseEdgeFunctionStorage.decodeStorageObjectKey(`${u.host}${u.pathname}`.replace(/^\//, ""));
133
140
  if (!key) throw new Error("Invalid Supabase storage URI: missing key");
134
141
  if (key.startsWith(`${config.bucketName}/`)) key = key.substring(`${config.bucketName}/`.length);
135
142
  return { fileUrl: await resolveSignedUrl(config.bucketName, key) };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as resolveSupabaseServiceRoleKey, i as supabaseDatabase, n as createSupabaseSignedUrlBatcher, r as supabaseEdgeFunctionDatabase, t as supabaseEdgeFunctionStorage } from "./supabaseEdgeFunctionStorage-DaRCRhn-.mjs";
1
+ import { a as supabaseDatabase, i as supabaseEdgeFunctionDatabase, n as decodeStorageObjectKey, o as resolveSupabaseServiceRoleKey, r as createSupabaseSignedUrlBatcher, t as supabaseEdgeFunctionStorage } from "./supabaseEdgeFunctionStorage-B3yJ5yys.mjs";
2
2
  import { createStorageKeyBuilder, createUniversalStoragePlugin, getContentType, parseStorageUri } from "@hot-updater/plugin-core";
3
3
  import { createClient } from "@supabase/supabase-js";
4
4
  import fs from "fs/promises";
@@ -29,6 +29,13 @@ async function verifyObjectCanBeSignedForRuntime({ bucket, key }) {
29
29
  expiresIn: 3600
30
30
  });
31
31
  }
32
+ const parseSupabaseStorageUri = (storageUri) => {
33
+ const { bucket, key } = parseStorageUri(storageUri, "supabase-storage");
34
+ return {
35
+ bucket,
36
+ key: decodeStorageObjectKey(key)
37
+ };
38
+ };
32
39
  const supabaseStorage = createUniversalStoragePlugin({
33
40
  name: "supabaseStorage",
34
41
  supportedProtocol: "supabase-storage",
@@ -43,7 +50,7 @@ const supabaseStorage = createUniversalStoragePlugin({
43
50
  return {
44
51
  node: {
45
52
  async delete(storageUri) {
46
- const { key, bucket: bucketName } = parseStorageUri(storageUri, "supabase-storage");
53
+ const { key, bucket: bucketName } = parseSupabaseStorageUri(storageUri);
47
54
  if (bucketName !== config.bucketName) throw new Error(`Bucket name mismatch: expected "${config.bucketName}", but found "${bucketName}".`);
48
55
  const { error } = await bucket.remove([key]);
49
56
  if (error) {
@@ -68,7 +75,7 @@ const supabaseStorage = createUniversalStoragePlugin({
68
75
  return { storageUri: `supabase-storage://${upload.data.fullPath}` };
69
76
  },
70
77
  async exists(storageUri) {
71
- const { key, bucket: bucketName } = parseStorageUri(storageUri, "supabase-storage");
78
+ const { key, bucket: bucketName } = parseSupabaseStorageUri(storageUri);
72
79
  if (bucketName !== config.bucketName) throw new Error(`Bucket name mismatch: expected "${config.bucketName}", but found "${bucketName}".`);
73
80
  const { data, error } = await bucket.exists(key);
74
81
  if (data === false) return false;
@@ -80,7 +87,7 @@ const supabaseStorage = createUniversalStoragePlugin({
80
87
  return data;
81
88
  },
82
89
  async downloadFile(storageUri, filePath) {
83
- const { key, bucket: bucketName } = parseStorageUri(storageUri, "supabase-storage");
90
+ const { key, bucket: bucketName } = parseSupabaseStorageUri(storageUri);
84
91
  if (bucketName !== config.bucketName) throw new Error(`Bucket name mismatch: expected "${config.bucketName}", but found "${bucketName}".`);
85
92
  const { data, error } = await bucket.download(key);
86
93
  if (error) throw new Error(`Failed to download bundle: ${error.message}`);
@@ -91,7 +98,7 @@ const supabaseStorage = createUniversalStoragePlugin({
91
98
  },
92
99
  runtime: {
93
100
  async readText(storageUri) {
94
- const { key, bucket: bucketName } = parseStorageUri(storageUri, "supabase-storage");
101
+ const { key, bucket: bucketName } = parseSupabaseStorageUri(storageUri);
95
102
  if (bucketName !== config.bucketName) throw new Error(`Bucket name mismatch: expected "${config.bucketName}", but found "${bucketName}".`);
96
103
  const { data, error } = await bucket.download(key);
97
104
  if (error) {
@@ -104,7 +111,7 @@ const supabaseStorage = createUniversalStoragePlugin({
104
111
  async getDownloadUrl(storageUri) {
105
112
  const u = new URL(storageUri);
106
113
  if (u.protocol.replace(":", "") !== "supabase-storage") throw new Error("Invalid Supabase storage URI protocol");
107
- let key = `${u.host}${u.pathname}`.replace(/^\//, "");
114
+ let key = decodeStorageObjectKey(`${u.host}${u.pathname}`.replace(/^\//, ""));
108
115
  if (!key) throw new Error("Invalid Supabase storage URI: missing key");
109
116
  if (key.startsWith(`${config.bucketName}/`)) key = key.substring(`${config.bucketName}/`.length);
110
117
  return { fileUrl: await resolveSignedUrl(config.bucketName, key) };
@@ -315,12 +315,34 @@ const createSupabaseSignedUrlBatcher = ({ createSignedUrls, expiresIn, formatObj
315
315
  });
316
316
  };
317
317
  //#endregion
318
+ //#region src/supabaseStorageKey.ts
319
+ /**
320
+ * Supabase upload responses echo a percent-encoded object key (`data.Key`),
321
+ * so the `supabase-storage://` URIs built from them keep that encoding.
322
+ *
323
+ * Storage API endpoints that carry the key in the request path
324
+ * (`createSignedUrl`, `download`, `exists`) decode it server side, but the
325
+ * ones that carry keys in the JSON body (`createSignedUrls`, `remove`) do
326
+ * not, and look up an object whose name literally contains `%40`.
327
+ *
328
+ * Decoding when the URI is parsed keeps both request shapes pointing at the
329
+ * same object. Keys that are not valid percent-encoded sequences are left
330
+ * untouched.
331
+ */
332
+ const decodeStorageObjectKey = (key) => {
333
+ try {
334
+ return decodeURIComponent(key);
335
+ } catch {
336
+ return key;
337
+ }
338
+ };
339
+ //#endregion
318
340
  //#region src/supabaseEdgeFunctionStorage.ts
319
341
  const parseSupabaseStorageUri = (storageUri) => {
320
342
  const storageUrl = new URL(storageUri);
321
343
  if (storageUrl.protocol !== "supabase-storage:") throw new Error("Invalid Supabase storage URI protocol");
322
344
  const bucketName = storageUrl.host;
323
- const key = storageUrl.pathname.replace(/^\/+/, "");
345
+ const key = decodeStorageObjectKey(storageUrl.pathname.replace(/^\/+/, ""));
324
346
  if (!bucketName || !key) throw new Error("Invalid Supabase storage URI");
325
347
  return {
326
348
  bucketName,
@@ -356,4 +378,4 @@ const supabaseEdgeFunctionStorage = createRuntimeStoragePlugin({
356
378
  }
357
379
  });
358
380
  //#endregion
359
- export { resolveSupabaseServiceRoleKey as a, supabaseDatabase as i, createSupabaseSignedUrlBatcher as n, supabaseEdgeFunctionDatabase as r, supabaseEdgeFunctionStorage as t };
381
+ export { supabaseDatabase as a, supabaseEdgeFunctionDatabase as i, decodeStorageObjectKey as n, resolveSupabaseServiceRoleKey as o, createSupabaseSignedUrlBatcher as r, supabaseEdgeFunctionStorage as t };
@@ -316,12 +316,34 @@ const createSupabaseSignedUrlBatcher = ({ createSignedUrls, expiresIn, formatObj
316
316
  });
317
317
  };
318
318
  //#endregion
319
+ //#region src/supabaseStorageKey.ts
320
+ /**
321
+ * Supabase upload responses echo a percent-encoded object key (`data.Key`),
322
+ * so the `supabase-storage://` URIs built from them keep that encoding.
323
+ *
324
+ * Storage API endpoints that carry the key in the request path
325
+ * (`createSignedUrl`, `download`, `exists`) decode it server side, but the
326
+ * ones that carry keys in the JSON body (`createSignedUrls`, `remove`) do
327
+ * not, and look up an object whose name literally contains `%40`.
328
+ *
329
+ * Decoding when the URI is parsed keeps both request shapes pointing at the
330
+ * same object. Keys that are not valid percent-encoded sequences are left
331
+ * untouched.
332
+ */
333
+ const decodeStorageObjectKey = (key) => {
334
+ try {
335
+ return decodeURIComponent(key);
336
+ } catch {
337
+ return key;
338
+ }
339
+ };
340
+ //#endregion
319
341
  //#region src/supabaseEdgeFunctionStorage.ts
320
342
  const parseSupabaseStorageUri = (storageUri) => {
321
343
  const storageUrl = new URL(storageUri);
322
344
  if (storageUrl.protocol !== "supabase-storage:") throw new Error("Invalid Supabase storage URI protocol");
323
345
  const bucketName = storageUrl.host;
324
- const key = storageUrl.pathname.replace(/^\/+/, "");
346
+ const key = decodeStorageObjectKey(storageUrl.pathname.replace(/^\/+/, ""));
325
347
  if (!bucketName || !key) throw new Error("Invalid Supabase storage URI");
326
348
  return {
327
349
  bucketName,
@@ -363,6 +385,12 @@ Object.defineProperty(exports, "createSupabaseSignedUrlBatcher", {
363
385
  return createSupabaseSignedUrlBatcher;
364
386
  }
365
387
  });
388
+ Object.defineProperty(exports, "decodeStorageObjectKey", {
389
+ enumerable: true,
390
+ get: function() {
391
+ return decodeStorageObjectKey;
392
+ }
393
+ });
366
394
  Object.defineProperty(exports, "resolveSupabaseServiceRoleKey", {
367
395
  enumerable: true,
368
396
  get: function() {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hot-updater/supabase",
3
3
  "type": "module",
4
- "version": "0.36.0",
4
+ "version": "0.36.1",
5
5
  "description": "React Native OTA solution for self-hosted",
6
6
  "main": "dist/index.cjs",
7
7
  "module": "dist/index.mjs",
@@ -55,10 +55,10 @@
55
55
  "@supabase/supabase-js": "2.76.1",
56
56
  "hono": "4.12.9",
57
57
  "uuidv7": "^1.0.2",
58
- "@hot-updater/core": "0.36.0",
59
- "@hot-updater/cli-tools": "0.36.0",
60
- "@hot-updater/server": "0.36.0",
61
- "@hot-updater/plugin-core": "0.36.0"
58
+ "@hot-updater/core": "0.36.1",
59
+ "@hot-updater/plugin-core": "0.36.1",
60
+ "@hot-updater/cli-tools": "0.36.1",
61
+ "@hot-updater/server": "0.36.1"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@electric-sql/pglite": "0.4.1",
@@ -68,10 +68,10 @@
68
68
  "execa": "9.5.2",
69
69
  "@types/node": "^20",
70
70
  "mime": "^4.0.4",
71
- "@hot-updater/js": "0.36.0",
72
- "@hot-updater/mock": "0.36.0",
73
- "@hot-updater/test-utils": "0.36.0",
74
- "@hot-updater/postgres": "0.36.0"
71
+ "@hot-updater/js": "0.36.1",
72
+ "@hot-updater/test-utils": "0.36.1",
73
+ "@hot-updater/postgres": "0.36.1",
74
+ "@hot-updater/mock": "0.36.1"
75
75
  },
76
76
  "scripts": {
77
77
  "build": "tsdown",