@edgedev/firebase 2.1.75 → 2.1.78
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/edgeFirebase.ts +18 -2
- package/package.json +1 -1
package/edgeFirebase.ts
CHANGED
|
@@ -184,6 +184,7 @@ interface firebaseConfig {
|
|
|
184
184
|
emulatorFirestore?: string;
|
|
185
185
|
emulatorFunctions?: string;
|
|
186
186
|
emulatorStorage?: string;
|
|
187
|
+
functionsRegion?: string;
|
|
187
188
|
}
|
|
188
189
|
|
|
189
190
|
interface actionResponse {
|
|
@@ -206,10 +207,12 @@ interface Meta {
|
|
|
206
207
|
[key: string]: unknown;
|
|
207
208
|
}
|
|
208
209
|
|
|
210
|
+
const DEFAULT_FUNCTIONS_REGION = "us-central1";
|
|
211
|
+
|
|
209
212
|
export const EdgeFirebase = class {
|
|
210
213
|
constructor(
|
|
211
214
|
firebaseConfig: firebaseConfig = {
|
|
212
|
-
|
|
215
|
+
apiKey: "",
|
|
213
216
|
authDomain: "",
|
|
214
217
|
projectId: "",
|
|
215
218
|
storageBucket: "",
|
|
@@ -220,10 +223,10 @@ export const EdgeFirebase = class {
|
|
|
220
223
|
emulatorFirestore: "",
|
|
221
224
|
emulatorFunctions: "",
|
|
222
225
|
emulatorStorage: "",
|
|
226
|
+
functionsRegion: ""
|
|
223
227
|
},
|
|
224
228
|
isPersistant: false,
|
|
225
229
|
enablePopupRedirect: false,
|
|
226
|
-
functionsRegion: "us-central1",
|
|
227
230
|
) {
|
|
228
231
|
this.firebaseConfig = firebaseConfig;
|
|
229
232
|
this.app = initializeApp(this.firebaseConfig);
|
|
@@ -252,7 +255,12 @@ export const EdgeFirebase = class {
|
|
|
252
255
|
if (this.firebaseConfig.storageBucket) {
|
|
253
256
|
this.storage = getStorage(this.app);
|
|
254
257
|
}
|
|
258
|
+
|
|
259
|
+
const functionsRegion =
|
|
260
|
+
this.firebaseConfig.functionsRegion || DEFAULT_FUNCTIONS_REGION;
|
|
261
|
+
|
|
255
262
|
this.functions = getFunctions(this.app, functionsRegion);
|
|
263
|
+
|
|
256
264
|
if (this.firebaseConfig.emulatorFunctions) {
|
|
257
265
|
connectFunctionsEmulator(this.functions, "127.0.0.1", this.firebaseConfig.emulatorFunctions)
|
|
258
266
|
}
|
|
@@ -2127,6 +2135,14 @@ export const EdgeFirebase = class {
|
|
|
2127
2135
|
cloneItem.doc_created_at = currentTime;
|
|
2128
2136
|
}
|
|
2129
2137
|
if (Object.prototype.hasOwnProperty.call(cloneItem, "docId")) {
|
|
2138
|
+
const canWriteCollection = await this.permissionCheck("write", collectionPath);
|
|
2139
|
+
if (!canWriteCollection) {
|
|
2140
|
+
return this.sendResponse({
|
|
2141
|
+
success: false,
|
|
2142
|
+
message: `You do not have permission to write to "${collectionPath}"`,
|
|
2143
|
+
meta: {}
|
|
2144
|
+
});
|
|
2145
|
+
}
|
|
2130
2146
|
const canWrite = await this.permissionCheck("write", collectionPath + "/" + cloneItem.docId);
|
|
2131
2147
|
if (!canWrite) {
|
|
2132
2148
|
return this.sendResponse({
|