vidspotai-shared 1.0.138 → 1.0.139
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/lib/globals/creditUnit.d.ts +15 -8
- package/lib/globals/creditUnit.d.ts.map +1 -1
- package/lib/globals/creditUnit.js +16 -8
- package/lib/libs/storage/MediaStorage.d.ts +6 -0
- package/lib/libs/storage/MediaStorage.d.ts.map +1 -1
- package/lib/libs/storage/MediaStorage.js +10 -0
- package/lib/libs/storage/R2Backend.d.ts +8 -0
- package/lib/libs/storage/R2Backend.d.ts.map +1 -1
- package/lib/libs/storage/R2Backend.js +26 -0
- package/lib/libs/storage/StorageBackend.d.ts +6 -0
- package/lib/libs/storage/StorageBackend.d.ts.map +1 -1
- package/lib/libs/storage/cdnUrl.d.ts +7 -0
- package/lib/libs/storage/cdnUrl.d.ts.map +1 -1
- package/lib/libs/storage/cdnUrl.js +46 -0
- package/package.json +1 -1
|
@@ -51,13 +51,19 @@ export declare const MIN_CREDITS_PER_IMAGE_OP = 2;
|
|
|
51
51
|
*/
|
|
52
52
|
export declare const MIN_CREDITS_PER_UTILITY_OP = 1;
|
|
53
53
|
/**
|
|
54
|
-
* Credits granted on SIGNUP —
|
|
55
|
-
*
|
|
56
|
-
* the
|
|
54
|
+
* Credits granted on SIGNUP — ZERO since 2026-11-06. Free (no-card) accounts get
|
|
55
|
+
* nothing; the only free credits are TRIAL_GRANT_CREDITS, granted once Stripe
|
|
56
|
+
* confirms a card for the free trial. After that it's a subscription/package.
|
|
57
57
|
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
58
|
+
* History: 10 until 2026-07-22, briefly 0, restored to 10 on 2026-07-24,
|
|
59
|
+
* then set to 0 again on 2026-11-06 because provider spend kept climbing
|
|
60
|
+
* (BytePlus alone: $1,170 in Oct 2026) while signup-grant users almost never
|
|
61
|
+
* convert. The original reasoning for 10 is kept below for reference.
|
|
62
|
+
*
|
|
63
|
+
* REMOVED FOR v1 — kept for reference (the pre-2026-11-06 rationale):
|
|
64
|
+
* one full floored generation ($1.00 of provider cost), no card required. This
|
|
65
|
+
* is the top of the funnel: a new account can try the product once before
|
|
66
|
+
* being asked for anything.
|
|
61
67
|
*
|
|
62
68
|
* Read this before raising it, because the give-away is real and measured:
|
|
63
69
|
* 23,962 users, 15,021 of whom consumed credits, and only 88 who ever spent
|
|
@@ -73,7 +79,7 @@ export declare const MIN_CREDITS_PER_UTILITY_OP = 1;
|
|
|
73
79
|
* Anything ABOVE 10 needs an anti-abuse gate first (verified email + App Check
|
|
74
80
|
* at minimum).
|
|
75
81
|
*/
|
|
76
|
-
export declare const SIGNUP_GRANT_CREDITS =
|
|
82
|
+
export declare const SIGNUP_GRANT_CREDITS = 0;
|
|
77
83
|
/**
|
|
78
84
|
* Credits granted when a card-backed free trial actually starts (the
|
|
79
85
|
* `isTrialInvoice` branch in payment.service.handleInvoiceSucceeded).
|
|
@@ -81,7 +87,8 @@ export declare const SIGNUP_GRANT_CREDITS = 10;
|
|
|
81
87
|
* ADDITIVE since 2026-07-24: that branch applies `FieldValue.increment` to
|
|
82
88
|
* `credits.total` and leaves `consumed` alone, so starting the trial always
|
|
83
89
|
* moves available credits by exactly +10 on top of whatever is left of the
|
|
84
|
-
* signup grant.
|
|
90
|
+
* signup grant. Since the signup grant is 0 (2026-11-06), a new trial user
|
|
91
|
+
* starts with exactly 10 available.
|
|
85
92
|
*
|
|
86
93
|
* It used to overwrite (`total: 10, consumed: 0`), which was invisible while
|
|
87
94
|
* SIGNUP_GRANT_CREDITS was 0 but became a silent no-op for users who added a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"creditUnit.d.ts","sourceRoot":"","sources":["../../src/globals/creditUnit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,iDAAiD;AACjD,eAAO,MAAM,cAAc,MAAM,CAAC;AAElC,0EAA0E;AAC1E,eAAO,MAAM,eAAe,QAAqB,CAAC;AAElD;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAE1C;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAE5C
|
|
1
|
+
{"version":3,"file":"creditUnit.d.ts","sourceRoot":"","sources":["../../src/globals/creditUnit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,iDAAiD;AACjD,eAAO,MAAM,cAAc,MAAM,CAAC;AAElC,0EAA0E;AAC1E,eAAO,MAAM,eAAe,QAAqB,CAAC;AAElD;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAE1C;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,eAAO,MAAM,oBAAoB,IAAI,CAAC;AAEtC;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,mBAAmB,KAA0B,CAAC"}
|
|
@@ -54,13 +54,19 @@ exports.MIN_CREDITS_PER_IMAGE_OP = 2;
|
|
|
54
54
|
*/
|
|
55
55
|
exports.MIN_CREDITS_PER_UTILITY_OP = 1;
|
|
56
56
|
/**
|
|
57
|
-
* Credits granted on SIGNUP —
|
|
58
|
-
*
|
|
59
|
-
* the
|
|
57
|
+
* Credits granted on SIGNUP — ZERO since 2026-11-06. Free (no-card) accounts get
|
|
58
|
+
* nothing; the only free credits are TRIAL_GRANT_CREDITS, granted once Stripe
|
|
59
|
+
* confirms a card for the free trial. After that it's a subscription/package.
|
|
60
60
|
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
61
|
+
* History: 10 until 2026-07-22, briefly 0, restored to 10 on 2026-07-24,
|
|
62
|
+
* then set to 0 again on 2026-11-06 because provider spend kept climbing
|
|
63
|
+
* (BytePlus alone: $1,170 in Oct 2026) while signup-grant users almost never
|
|
64
|
+
* convert. The original reasoning for 10 is kept below for reference.
|
|
65
|
+
*
|
|
66
|
+
* REMOVED FOR v1 — kept for reference (the pre-2026-11-06 rationale):
|
|
67
|
+
* one full floored generation ($1.00 of provider cost), no card required. This
|
|
68
|
+
* is the top of the funnel: a new account can try the product once before
|
|
69
|
+
* being asked for anything.
|
|
64
70
|
*
|
|
65
71
|
* Read this before raising it, because the give-away is real and measured:
|
|
66
72
|
* 23,962 users, 15,021 of whom consumed credits, and only 88 who ever spent
|
|
@@ -76,7 +82,8 @@ exports.MIN_CREDITS_PER_UTILITY_OP = 1;
|
|
|
76
82
|
* Anything ABOVE 10 needs an anti-abuse gate first (verified email + App Check
|
|
77
83
|
* at minimum).
|
|
78
84
|
*/
|
|
79
|
-
|
|
85
|
+
// REMOVED FOR v1 — kept for reference: export const SIGNUP_GRANT_CREDITS = 10;
|
|
86
|
+
exports.SIGNUP_GRANT_CREDITS = 0;
|
|
80
87
|
/**
|
|
81
88
|
* Credits granted when a card-backed free trial actually starts (the
|
|
82
89
|
* `isTrialInvoice` branch in payment.service.handleInvoiceSucceeded).
|
|
@@ -84,7 +91,8 @@ exports.SIGNUP_GRANT_CREDITS = 10;
|
|
|
84
91
|
* ADDITIVE since 2026-07-24: that branch applies `FieldValue.increment` to
|
|
85
92
|
* `credits.total` and leaves `consumed` alone, so starting the trial always
|
|
86
93
|
* moves available credits by exactly +10 on top of whatever is left of the
|
|
87
|
-
* signup grant.
|
|
94
|
+
* signup grant. Since the signup grant is 0 (2026-11-06), a new trial user
|
|
95
|
+
* starts with exactly 10 available.
|
|
88
96
|
*
|
|
89
97
|
* It used to overwrite (`total: 10, consumed: 0`), which was invisible while
|
|
90
98
|
* SIGNUP_GRANT_CREDITS was 0 but became a silent no-op for users who added a
|
|
@@ -125,6 +125,12 @@ export declare class MediaStorage {
|
|
|
125
125
|
* consumer-side rewrites stay as idempotent no-ops for the URLs already
|
|
126
126
|
* stored between 2026-09-22 and this change.
|
|
127
127
|
*/
|
|
128
|
+
/**
|
|
129
|
+
* Read an object's bytes straight from the byte store into `destPath`.
|
|
130
|
+
* False when the store can't serve it (not there, or no direct read) — the
|
|
131
|
+
* caller falls back to fetching the delivery URL.
|
|
132
|
+
*/
|
|
133
|
+
readToFile(objectPath: string, destPath: string, signal?: AbortSignal): Promise<boolean>;
|
|
128
134
|
signedReadUrl(objectPath: string): Promise<string>;
|
|
129
135
|
/**
|
|
130
136
|
* Delete the object's bytes from R2. Does NOT touch GCS — since 2026-09-22
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MediaStorage.d.ts","sourceRoot":"","sources":["../../../src/libs/storage/MediaStorage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAGvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAIxD;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,CAE1C;AAED,qBAAa,YAAY;IACvB,iEAAiE;IACjE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAkB;IACxC,0EAA0E;IAC1E,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAkB;gBAEhC,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,eAAe;IAK9D;;;;;;OAMG;IACG,GAAG,CACP,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC;IAKlB;;;;;OAKG;IACG,WAAW,CACf,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,I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* consumer-side rewrites stay as idempotent no-ops for the URLs already
|
|
95
95
|
* stored between 2026-09-22 and this change.
|
|
96
96
|
*/
|
|
97
|
+
/**
|
|
98
|
+
* Read an object's bytes straight from the byte store into `destPath`.
|
|
99
|
+
* False when the store can't serve it (not there, or no direct read) — the
|
|
100
|
+
* caller falls back to fetching the delivery URL.
|
|
101
|
+
*/
|
|
102
|
+
async readToFile(objectPath, destPath, signal) {
|
|
103
|
+
if (!this.bytes.readToFile)
|
|
104
|
+
return false;
|
|
105
|
+
return this.bytes.readToFile(objectPath, destPath, signal);
|
|
106
|
+
}
|
|
97
107
|
async signedReadUrl(objectPath) {
|
|
98
108
|
return (0, cdnUrl_1.toCdnUrl)(await this.urlMinter.signedReadUrl(objectPath), { visibility: "private" });
|
|
99
109
|
}
|
|
@@ -37,6 +37,14 @@ export declare class R2Backend implements IStorageBackend {
|
|
|
37
37
|
* future use once a real signed-URL scheme exists for this shape.
|
|
38
38
|
*/
|
|
39
39
|
signedReadUrl(key: string): Promise<string>;
|
|
40
|
+
/**
|
|
41
|
+
* Direct S3 read, bypassing the cdn.vidspotai.com Worker. The worker reads
|
|
42
|
+
* its own freshly-written media (posters, watermark, stitch, renders) and
|
|
43
|
+
* the Worker path has stalled for minutes on exactly those objects
|
|
44
|
+
* (2026-11-02/03: poster + watermark of a new scene, a render's
|
|
45
|
+
* <OffthreadVideo> fetch past the 90s delayRender budget).
|
|
46
|
+
*/
|
|
47
|
+
readToFile(key: string, destPath: string, signal?: AbortSignal): Promise<boolean>;
|
|
40
48
|
delete(key: string): Promise<void>;
|
|
41
49
|
}
|
|
42
50
|
//# sourceMappingURL=R2Backend.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"R2Backend.d.ts","sourceRoot":"","sources":["../../../src/libs/storage/R2Backend.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"R2Backend.d.ts","sourceRoot":"","sources":["../../../src/libs/storage/R2Backend.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAIvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAyBxD,qBAAa,SAAU,YAAW,eAAe;IAC/C,QAAQ,CAAC,IAAI,QAAQ;IAGrB,OAAO,CAAC,MAAM,CAAyB;IACvC,OAAO,CAAC,IAAI,CAAyC;IAErD;;;;;;;;;;;OAWG;YACW,SAAS;YAoBT,aAAa;IAQrB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAepE,aAAa,CACjB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC;IAQlB;;;;;;OAMG;IACG,iBAAiB,CACrB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,QAAQ,EAChB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,IAAI,CAAC;IAgBhB;;;;;;;OAOG;IACG,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIjD;;;;;;OAMG;IACG,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;IAkBjF,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAOzC"}
|
|
@@ -51,7 +51,9 @@ exports.R2Backend = void 0;
|
|
|
51
51
|
* package's module import graph — that package is already heavy at import time
|
|
52
52
|
* and this must not add to Cloud Function cold start (memory/project_shared_lazy_load).
|
|
53
53
|
*/
|
|
54
|
+
const fs_1 = require("fs");
|
|
54
55
|
const promises_1 = require("fs/promises");
|
|
56
|
+
const promises_2 = require("stream/promises");
|
|
55
57
|
const r2KeyMap_1 = require("../r2KeyMap");
|
|
56
58
|
const logger_1 = require("../../utils/logger");
|
|
57
59
|
const R2_BUCKET = process.env.R2_BUCKET || "vidspot-media";
|
|
@@ -166,6 +168,30 @@ class R2Backend {
|
|
|
166
168
|
async signedReadUrl(key) {
|
|
167
169
|
return `${cdnBase()}/${(0, r2KeyMap_1.toR2Key)(key)}`;
|
|
168
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Direct S3 read, bypassing the cdn.vidspotai.com Worker. The worker reads
|
|
173
|
+
* its own freshly-written media (posters, watermark, stitch, renders) and
|
|
174
|
+
* the Worker path has stalled for minutes on exactly those objects
|
|
175
|
+
* (2026-11-02/03: poster + watermark of a new scene, a render's
|
|
176
|
+
* <OffthreadVideo> fetch past the 90s delayRender budget).
|
|
177
|
+
*/
|
|
178
|
+
async readToFile(key, destPath, signal) {
|
|
179
|
+
const client = await this.requireClient();
|
|
180
|
+
const { GetObjectCommand } = await Promise.resolve().then(() => __importStar(require("@aws-sdk/client-s3")));
|
|
181
|
+
try {
|
|
182
|
+
const res = await client.send(new GetObjectCommand({ Bucket: R2_BUCKET, Key: (0, r2KeyMap_1.toR2Key)(key) }), { abortSignal: signal });
|
|
183
|
+
if (!res.Body)
|
|
184
|
+
return false;
|
|
185
|
+
await (0, promises_2.pipeline)(res.Body, (0, fs_1.createWriteStream)(destPath), { signal });
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
188
|
+
catch (err) {
|
|
189
|
+
const name = err?.name;
|
|
190
|
+
if (name === "NoSuchKey" || name === "NotFound")
|
|
191
|
+
return false;
|
|
192
|
+
throw err;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
169
195
|
async delete(key) {
|
|
170
196
|
const client = await this.requireClient();
|
|
171
197
|
const { DeleteObjectCommand } = await Promise.resolve().then(() => __importStar(require("@aws-sdk/client-s3")));
|
|
@@ -29,6 +29,12 @@ export interface IStorageBackend {
|
|
|
29
29
|
signedReadUrl(key: string): Promise<string>;
|
|
30
30
|
/** Delete `key`. Best-effort; implementations may no-op on "not found". */
|
|
31
31
|
delete(key: string): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Stream `key`'s bytes into `destPath`. Resolves false when the object
|
|
34
|
+
* doesn't exist in this store (caller falls back to another read path).
|
|
35
|
+
* Optional: only byte stores the worker reads directly implement it.
|
|
36
|
+
*/
|
|
37
|
+
readToFile?(key: string, destPath: string, signal?: AbortSignal): Promise<boolean>;
|
|
32
38
|
/**
|
|
33
39
|
* Stream an already-open Readable (e.g. another backend's read stream)
|
|
34
40
|
* straight to `key`, without buffering it whole. Optional — only backends
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StorageBackend.d.ts","sourceRoot":"","sources":["../../../src/libs/storage/StorageBackend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAEvC,MAAM,WAAW,eAAe;IAC9B,8CAA8C;IAC9C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,sCAAsC;IACtC,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAErE;;;;OAIG;IACH,aAAa,CACX,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC,CAAC;IAEnB,yEAAyE;IACzE,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE5C,2EAA2E;IAC3E,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnC;;;;;;OAMG;IACH,iBAAiB,CAAC,CAChB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,QAAQ,EAChB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,IAAI,CAAC,CAAC;CAClB"}
|
|
1
|
+
{"version":3,"file":"StorageBackend.d.ts","sourceRoot":"","sources":["../../../src/libs/storage/StorageBackend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAEvC,MAAM,WAAW,eAAe;IAC9B,8CAA8C;IAC9C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,sCAAsC;IACtC,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAErE;;;;OAIG;IACH,aAAa,CACX,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC,CAAC;IAEnB,yEAAyE;IACzE,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE5C,2EAA2E;IAC3E,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnC;;;;OAIG;IACH,UAAU,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEnF;;;;;;OAMG;IACH,iBAAiB,CAAC,CAChB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,QAAQ,EAChB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,IAAI,CAAC,CAAC;CAClB"}
|
|
@@ -70,6 +70,13 @@ export declare function toCdnUrlsInText(text: string, opts?: {
|
|
|
70
70
|
* but via `toCdnUrl()` directly on the string embedded in the request, since
|
|
71
71
|
* there's no local `fetch()` call to wrap.
|
|
72
72
|
*/
|
|
73
|
+
/**
|
|
74
|
+
* Canonical object path (e.g. "videos/<id>_scene0.mp4") for one of OUR
|
|
75
|
+
* storage URLs — Firebase download URL, GCS signed URL, or their CDN forms
|
|
76
|
+
* (`/v0/b/<bucket>/o/<enc>` and `/gcs-pub|gcs-priv/<bucket>/<obj>`). Null for
|
|
77
|
+
* anything else, including bare R2-key CDN URLs and other buckets.
|
|
78
|
+
*/
|
|
79
|
+
export declare function ownMediaObjectPath(url: string): string | null;
|
|
73
80
|
export declare function fetchOwnMedia(url: string, init?: RequestInit): Promise<Response>;
|
|
74
81
|
/**
|
|
75
82
|
* Permanent public CDN URL for an object `put`/`putFromFile` wrote to R2 —
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cdnUrl.d.ts","sourceRoot":"","sources":["../../../src/libs/storage/cdnUrl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAmBH,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEnD;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CACtB,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE;IAAE,UAAU,CAAC,EAAE,eAAe,CAAA;CAAE,GACtC,MAAM,CAeR;AAQD;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,KAAK,EAAE,CAAC,EACR,IAAI,GAAE;IAAE,UAAU,CAAC,EAAE,eAAe,CAAA;CAA8B,GACjE,CAAC,CASH;AAQD;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE;IAAE,UAAU,CAAC,EAAE,eAAe,CAAA;CAA8B,GACjE,MAAM,CAER;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAEhF;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAGvD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAalD"}
|
|
1
|
+
{"version":3,"file":"cdnUrl.d.ts","sourceRoot":"","sources":["../../../src/libs/storage/cdnUrl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAmBH,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEnD;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CACtB,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE;IAAE,UAAU,CAAC,EAAE,eAAe,CAAA;CAAE,GACtC,MAAM,CAeR;AAQD;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,KAAK,EAAE,CAAC,EACR,IAAI,GAAE;IAAE,UAAU,CAAC,EAAE,eAAe,CAAA;CAA8B,GACjE,CAAC,CASH;AAQD;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE;IAAE,UAAU,CAAC,EAAE,eAAe,CAAA;CAA8B,GACjE,MAAM,CAER;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAmC7D;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAEhF;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAGvD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAalD"}
|
|
@@ -16,6 +16,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
16
16
|
exports.toCdnUrl = toCdnUrl;
|
|
17
17
|
exports.toCdnUrlsDeep = toCdnUrlsDeep;
|
|
18
18
|
exports.toCdnUrlsInText = toCdnUrlsInText;
|
|
19
|
+
exports.ownMediaObjectPath = ownMediaObjectPath;
|
|
19
20
|
exports.fetchOwnMedia = fetchOwnMedia;
|
|
20
21
|
exports.publicCdnUrl = publicCdnUrl;
|
|
21
22
|
exports.isOwnMediaUrl = isOwnMediaUrl;
|
|
@@ -119,6 +120,51 @@ function toCdnUrlsInText(text, opts = { visibility: "private" }) {
|
|
|
119
120
|
* but via `toCdnUrl()` directly on the string embedded in the request, since
|
|
120
121
|
* there's no local `fetch()` call to wrap.
|
|
121
122
|
*/
|
|
123
|
+
/**
|
|
124
|
+
* Canonical object path (e.g. "videos/<id>_scene0.mp4") for one of OUR
|
|
125
|
+
* storage URLs — Firebase download URL, GCS signed URL, or their CDN forms
|
|
126
|
+
* (`/v0/b/<bucket>/o/<enc>` and `/gcs-pub|gcs-priv/<bucket>/<obj>`). Null for
|
|
127
|
+
* anything else, including bare R2-key CDN URLs and other buckets.
|
|
128
|
+
*/
|
|
129
|
+
function ownMediaObjectPath(url) {
|
|
130
|
+
let u;
|
|
131
|
+
try {
|
|
132
|
+
u = new URL(url);
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
const origin = u.origin;
|
|
138
|
+
const isCdn = origin === new URL(cdnBase()).origin;
|
|
139
|
+
const p = u.pathname;
|
|
140
|
+
const decode = (raw) => {
|
|
141
|
+
try {
|
|
142
|
+
const out = decodeURIComponent(raw);
|
|
143
|
+
return out ? out : null;
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
if (origin === FIREBASE_STORAGE_HOST || isCdn) {
|
|
150
|
+
for (const bucket of SIGNED_BUCKETS) {
|
|
151
|
+
const prefix = `/v0/b/${bucket}/o/`;
|
|
152
|
+
if (p.startsWith(prefix))
|
|
153
|
+
return decode(p.slice(prefix.length));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (origin === GCS_HOST || isCdn) {
|
|
157
|
+
const families = origin === GCS_HOST ? [""] : ["/gcs-pub", "/gcs-priv"];
|
|
158
|
+
for (const family of families) {
|
|
159
|
+
for (const bucket of SIGNED_BUCKETS) {
|
|
160
|
+
const prefix = `${family}/${bucket}/`;
|
|
161
|
+
if (p.startsWith(prefix))
|
|
162
|
+
return decode(p.slice(prefix.length));
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
122
168
|
function fetchOwnMedia(url, init) {
|
|
123
169
|
return fetch(toCdnUrl(url, { visibility: "private" }), init);
|
|
124
170
|
}
|