@sanvika/cloudinary 0.2.0 → 0.2.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/index.js +10 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -110,14 +110,14 @@ var TRANSFORM_PRESETS = {
|
|
|
110
110
|
|
|
111
111
|
// src/gatewayClient.js
|
|
112
112
|
function isProxyMode() {
|
|
113
|
-
return Boolean(process.env.
|
|
113
|
+
return Boolean(process.env.CLOUDINARY_GATEWAY_URL && process.env.CLOUDINARY_TOKEN);
|
|
114
114
|
}
|
|
115
115
|
function requireProxyEnv() {
|
|
116
|
-
const base = process.env.
|
|
117
|
-
const token = process.env.
|
|
116
|
+
const base = process.env.CLOUDINARY_GATEWAY_URL;
|
|
117
|
+
const token = process.env.CLOUDINARY_TOKEN;
|
|
118
118
|
if (!base || !token) {
|
|
119
119
|
throw new CloudinaryError(
|
|
120
|
-
"Proxy gateway env missing. Set
|
|
120
|
+
"Proxy gateway env missing. Set CLOUDINARY_GATEWAY_URL and CLOUDINARY_TOKEN.",
|
|
121
121
|
"gateway_env"
|
|
122
122
|
);
|
|
123
123
|
}
|
|
@@ -192,7 +192,7 @@ async function loadLegacyCloudinary() {
|
|
|
192
192
|
return _cloudinary;
|
|
193
193
|
}
|
|
194
194
|
async function configureSanvikaCloudinary({ appName, cloudName, apiKey, apiSecret } = {}) {
|
|
195
|
-
const resolvedApp = appName || process.env.
|
|
195
|
+
const resolvedApp = appName || process.env.CLOUDINARY_APP_NAME;
|
|
196
196
|
if (!resolvedApp) throw new Error("appName is required for configureSanvikaCloudinary");
|
|
197
197
|
_appName = resolvedApp;
|
|
198
198
|
if (isProxyMode()) {
|
|
@@ -204,7 +204,7 @@ async function configureSanvikaCloudinary({ appName, cloudName, apiKey, apiSecre
|
|
|
204
204
|
const as = apiSecret || process.env.CLOUDINARY_API_SECRET;
|
|
205
205
|
if (!cn || !ak || !as) {
|
|
206
206
|
throw new Error(
|
|
207
|
-
"Cloudinary credentials missing. Either use proxy mode (
|
|
207
|
+
"Cloudinary credentials missing. Either use proxy mode (CLOUDINARY_GATEWAY_URL + CLOUDINARY_TOKEN) or legacy env (CLOUDINARY_CLOUD_NAME, CLOUDINARY_API_KEY, CLOUDINARY_API_SECRET)."
|
|
208
208
|
);
|
|
209
209
|
}
|
|
210
210
|
const cloudinary = await loadLegacyCloudinary();
|
|
@@ -214,12 +214,12 @@ async function configureSanvikaCloudinary({ appName, cloudName, apiKey, apiSecre
|
|
|
214
214
|
async function ensureConfigured() {
|
|
215
215
|
if (_configured) return;
|
|
216
216
|
if (isProxyMode()) {
|
|
217
|
-
_appName = _appName || process.env.
|
|
217
|
+
_appName = _appName || process.env.CLOUDINARY_APP_NAME || "sanvika-app";
|
|
218
218
|
_configured = true;
|
|
219
219
|
return;
|
|
220
220
|
}
|
|
221
|
-
if (process.env.
|
|
222
|
-
await configureSanvikaCloudinary({ appName: process.env.
|
|
221
|
+
if (process.env.CLOUDINARY_APP_NAME) {
|
|
222
|
+
await configureSanvikaCloudinary({ appName: process.env.CLOUDINARY_APP_NAME });
|
|
223
223
|
return;
|
|
224
224
|
}
|
|
225
225
|
throw new Error("Call configureSanvikaCloudinary({ appName }) before using SDK operations.");
|
|
@@ -496,7 +496,7 @@ function verifySanvikaWebhookSignature({ headers, rawBody, secret, toleranceSec
|
|
|
496
496
|
};
|
|
497
497
|
const sig = String(getHeader("x-sanvika-signature") || "").trim();
|
|
498
498
|
const ts = String(getHeader("x-sanvika-timestamp") || "").trim();
|
|
499
|
-
const token = secret || process.env.
|
|
499
|
+
const token = secret || process.env.CLOUDINARY_TOKEN;
|
|
500
500
|
if (!token) return { valid: false, reason: "missing_secret" };
|
|
501
501
|
if (!sig) return { valid: false, reason: "missing_signature" };
|
|
502
502
|
if (!ts) return { valid: false, reason: "missing_timestamp" };
|
package/package.json
CHANGED