fiber-firebase-functions 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ Copyright (C) 2025 Fiber
2
+
3
+ All rights reserved. This script, including its code and logic, is the
4
+ exclusive property of Fiber. Redistribution, reproduction,
5
+ or modification of any part of this script is strictly prohibited
6
+ without prior written permission from Fiber.
7
+
8
+ Conditions of use:
9
+ - The code may not be copied, duplicated, or used, in whole or in part,
10
+ for any purpose without explicit authorization.
11
+ - Redistribution of this code, with or without modification, is not
12
+ permitted unless expressly agreed upon by Fiber.
13
+ - The name "Fiber" and any associated branding, logos, or
14
+ trademarks may not be used to endorse or promote derived products
15
+ or services without prior written approval.
16
+
17
+ Disclaimer:
18
+ THIS SCRIPT AND ITS CODE ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
19
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL
21
+ FIBER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING BUT NOT LIMITED TO LOSS OF USE,
23
+ DATA, PROFITS, OR BUSINESS INTERRUPTION) ARISING OUT OF OR RELATED TO THE USE
24
+ OR INABILITY TO USE THIS SCRIPT, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
+
26
+ Unauthorized copying or reproduction of this script, in whole or in part,
27
+ is a violation of applicable intellectual property laws and will result
28
+ in legal action.
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (C) 2025 Fiber
4
+ *
5
+ * All rights reserved. This script, including its code and logic, is the
6
+ * exclusive property of Fiber. Redistribution, reproduction,
7
+ * or modification of any part of this script is strictly prohibited
8
+ * without prior written permission from Fiber.
9
+ *
10
+ * Conditions of use:
11
+ * - The code may not be copied, duplicated, or used, in whole or in part,
12
+ * for any purpose without explicit authorization.
13
+ * - Redistribution of this code, with or without modification, is not
14
+ * permitted unless expressly agreed upon by Fiber.
15
+ * - The name "Fiber" and any associated branding, logos, or
16
+ * trademarks may not be used to endorse or promote derived products
17
+ * or services without prior written approval.
18
+ *
19
+ * Disclaimer:
20
+ * THIS SCRIPT AND ITS CODE ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
21
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY,
22
+ * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL
23
+ * FIBER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING BUT NOT LIMITED TO LOSS OF USE,
25
+ * DATA, PROFITS, OR BUSINESS INTERRUPTION) ARISING OUT OF OR RELATED TO THE USE
26
+ * OR INABILITY TO USE THIS SCRIPT, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+ *
28
+ * Unauthorized copying or reproduction of this script, in whole or in part,
29
+ * is a violation of applicable intellectual property laws and will result
30
+ * in legal action.
31
+ */
32
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
33
+ if (k2 === undefined) k2 = k;
34
+ var desc = Object.getOwnPropertyDescriptor(m, k);
35
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
36
+ desc = { enumerable: true, get: function() { return m[k]; } };
37
+ }
38
+ Object.defineProperty(o, k2, desc);
39
+ }) : (function(o, m, k, k2) {
40
+ if (k2 === undefined) k2 = k;
41
+ o[k2] = m[k];
42
+ }));
43
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
44
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
45
+ }) : function(o, v) {
46
+ o["default"] = v;
47
+ });
48
+ var __importStar = (this && this.__importStar) || (function () {
49
+ var ownKeys = function(o) {
50
+ ownKeys = Object.getOwnPropertyNames || function (o) {
51
+ var ar = [];
52
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
53
+ return ar;
54
+ };
55
+ return ownKeys(o);
56
+ };
57
+ return function (mod) {
58
+ if (mod && mod.__esModule) return mod;
59
+ var result = {};
60
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
61
+ __setModuleDefault(result, mod);
62
+ return result;
63
+ };
64
+ })();
65
+ Object.defineProperty(exports, "__esModule", { value: true });
66
+ exports.isUserDisabled = exports.UserDisabledStatus = void 0;
67
+ const admin = __importStar(require("firebase-admin"));
68
+ const https_1 = require("firebase-functions/v2/https");
69
+ if (admin.apps.length === 0) {
70
+ admin.initializeApp();
71
+ }
72
+ var UserDisabledStatus;
73
+ (function (UserDisabledStatus) {
74
+ UserDisabledStatus["MISSING_UUID"] = "MISSING_UUID";
75
+ UserDisabledStatus["ENABLED"] = "ENABLED";
76
+ UserDisabledStatus["DISABLED"] = "DISABLED";
77
+ UserDisabledStatus["NOT_FOUND"] = "NOT_FOUND";
78
+ UserDisabledStatus["INTERNAL_ERROR"] = "INTERNAL_ERROR";
79
+ })(UserDisabledStatus || (exports.UserDisabledStatus = UserDisabledStatus = {}));
80
+ exports.isUserDisabled = (0, https_1.onCall)(async (request) => {
81
+ const uid = request.data?.uid;
82
+ if (!uid)
83
+ return UserDisabledStatus.MISSING_UUID;
84
+ try {
85
+ const user = await admin.auth().getUser(uid);
86
+ const isUserDisabled = user.disabled;
87
+ return isUserDisabled
88
+ ? UserDisabledStatus.DISABLED
89
+ : UserDisabledStatus.ENABLED;
90
+ }
91
+ catch (error) {
92
+ return UserDisabledStatus.INTERNAL_ERROR;
93
+ }
94
+ });
95
+ //# sourceMappingURL=is_user_disabled.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is_user_disabled.js","sourceRoot":"","sources":["../../src/auth/is_user_disabled.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,sDAAwC;AACxC,uDAAqD;AAErD,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;IAC1B,KAAK,CAAC,aAAa,EAAE,CAAC;AAC1B,CAAC;AAED,IAAY,kBAMX;AAND,WAAY,kBAAkB;IAC1B,mDAA6B,CAAA;IAC7B,yCAAmB,CAAA;IACnB,2CAAqB,CAAA;IACrB,6CAAuB,CAAA;IACvB,uDAAiC,CAAA;AACrC,CAAC,EANW,kBAAkB,kCAAlB,kBAAkB,QAM7B;AAEY,QAAA,cAAc,GAAG,IAAA,cAAM,EAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACnD,MAAM,GAAG,GAAuB,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC;IAElD,IAAI,CAAC,GAAG;QAAE,OAAO,kBAAkB,CAAC,YAAY,CAAC;IAEjD,IAAI,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC7C,MAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC;QAErC,OAAO,cAAc;YACjB,CAAC,CAAC,kBAAkB,CAAC,QAAQ;YAC7B,CAAC,CAAC,kBAAkB,CAAC,OAAO,CAAC;IACrC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,kBAAkB,CAAC,cAAc,CAAC;IAC7C,CAAC;AACL,CAAC,CAAC,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (C) 2025 Fiber
4
+ *
5
+ * All rights reserved. This script, including its code and logic, is the
6
+ * exclusive property of Fiber. Redistribution, reproduction,
7
+ * or modification of any part of this script is strictly prohibited
8
+ * without prior written permission from Fiber.
9
+ *
10
+ * Conditions of use:
11
+ * - The code may not be copied, duplicated, or used, in whole or in part,
12
+ * for any purpose without explicit authorization.
13
+ * - Redistribution of this code, with or without modification, is not
14
+ * permitted unless expressly agreed upon by Fiber.
15
+ * - The name "Fiber" and any associated branding, logos, or
16
+ * trademarks may not be used to endorse or promote derived products
17
+ * or services without prior written approval.
18
+ *
19
+ * Disclaimer:
20
+ * THIS SCRIPT AND ITS CODE ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
21
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY,
22
+ * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL
23
+ * FIBER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING BUT NOT LIMITED TO LOSS OF USE,
25
+ * DATA, PROFITS, OR BUSINESS INTERRUPTION) ARISING OUT OF OR RELATED TO THE USE
26
+ * OR INABILITY TO USE THIS SCRIPT, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+ *
28
+ * Unauthorized copying or reproduction of this script, in whole or in part,
29
+ * is a violation of applicable intellectual property laws and will result
30
+ * in legal action.
31
+ */
32
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
33
+ if (k2 === undefined) k2 = k;
34
+ var desc = Object.getOwnPropertyDescriptor(m, k);
35
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
36
+ desc = { enumerable: true, get: function() { return m[k]; } };
37
+ }
38
+ Object.defineProperty(o, k2, desc);
39
+ }) : (function(o, m, k, k2) {
40
+ if (k2 === undefined) k2 = k;
41
+ o[k2] = m[k];
42
+ }));
43
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
44
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
45
+ };
46
+ Object.defineProperty(exports, "__esModule", { value: true });
47
+ __exportStar(require("./auth/is_user_disabled"), exports);
48
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;;;;;;;;;;;;;;;AAEH,0DAAwC"}
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "fiber-firebase-functions",
3
+ "version": "1.0.0",
4
+ "description": "A collection of ready-to-use Firebase Cloud Functions utilities and wrappers designed for any application built by Fiber. Provides reusable helpers, common patterns, and production-grade modules to streamline backend development across all Fiber projects.",
5
+ "author": "Fiber",
6
+ "license": "FIBER-PROPRIETARY",
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "scripts": {
10
+ "build": "tsc",
11
+ "watch": "tsc --watch",
12
+ "publish:public": "npm run build && npm publish --access public",
13
+ "publish:private": "npm run build && npm publish --access restricted"
14
+ },
15
+ "keywords": [
16
+ "firebase",
17
+ "cloud-functions",
18
+ "typescript",
19
+ "utils"
20
+ ],
21
+ "dependencies": {
22
+ "firebase-admin": "^13.6.0",
23
+ "firebase-functions": "^7.0.0"
24
+ },
25
+ "devDependencies": {
26
+ "typescript": "^5.9.3",
27
+ "ts-node": "^10.9.2"
28
+ }
29
+ }
@@ -0,0 +1,62 @@
1
+ /*
2
+ * Copyright (C) 2025 Fiber
3
+ *
4
+ * All rights reserved. This script, including its code and logic, is the
5
+ * exclusive property of Fiber. Redistribution, reproduction,
6
+ * or modification of any part of this script is strictly prohibited
7
+ * without prior written permission from Fiber.
8
+ *
9
+ * Conditions of use:
10
+ * - The code may not be copied, duplicated, or used, in whole or in part,
11
+ * for any purpose without explicit authorization.
12
+ * - Redistribution of this code, with or without modification, is not
13
+ * permitted unless expressly agreed upon by Fiber.
14
+ * - The name "Fiber" and any associated branding, logos, or
15
+ * trademarks may not be used to endorse or promote derived products
16
+ * or services without prior written approval.
17
+ *
18
+ * Disclaimer:
19
+ * THIS SCRIPT AND ITS CODE ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
20
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL
22
+ * FIBER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING BUT NOT LIMITED TO LOSS OF USE,
24
+ * DATA, PROFITS, OR BUSINESS INTERRUPTION) ARISING OUT OF OR RELATED TO THE USE
25
+ * OR INABILITY TO USE THIS SCRIPT, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
+ *
27
+ * Unauthorized copying or reproduction of this script, in whole or in part,
28
+ * is a violation of applicable intellectual property laws and will result
29
+ * in legal action.
30
+ */
31
+
32
+ import * as admin from "firebase-admin";
33
+ import { onCall } from "firebase-functions/v2/https";
34
+
35
+ if (admin.apps.length === 0) {
36
+ admin.initializeApp();
37
+ }
38
+
39
+ export enum UserDisabledStatus {
40
+ MISSING_UUID = "MISSING_UUID",
41
+ ENABLED = "ENABLED",
42
+ DISABLED = "DISABLED",
43
+ NOT_FOUND = "NOT_FOUND",
44
+ INTERNAL_ERROR = "INTERNAL_ERROR",
45
+ }
46
+
47
+ export const isUserDisabled = onCall(async (request) => {
48
+ const uid: string | undefined = request.data?.uid;
49
+
50
+ if (!uid) return UserDisabledStatus.MISSING_UUID;
51
+
52
+ try {
53
+ const user = await admin.auth().getUser(uid);
54
+ const isUserDisabled = user.disabled;
55
+
56
+ return isUserDisabled
57
+ ? UserDisabledStatus.DISABLED
58
+ : UserDisabledStatus.ENABLED;
59
+ } catch (error) {
60
+ return UserDisabledStatus.INTERNAL_ERROR;
61
+ }
62
+ });
package/src/index.ts ADDED
@@ -0,0 +1,32 @@
1
+ /*
2
+ * Copyright (C) 2025 Fiber
3
+ *
4
+ * All rights reserved. This script, including its code and logic, is the
5
+ * exclusive property of Fiber. Redistribution, reproduction,
6
+ * or modification of any part of this script is strictly prohibited
7
+ * without prior written permission from Fiber.
8
+ *
9
+ * Conditions of use:
10
+ * - The code may not be copied, duplicated, or used, in whole or in part,
11
+ * for any purpose without explicit authorization.
12
+ * - Redistribution of this code, with or without modification, is not
13
+ * permitted unless expressly agreed upon by Fiber.
14
+ * - The name "Fiber" and any associated branding, logos, or
15
+ * trademarks may not be used to endorse or promote derived products
16
+ * or services without prior written approval.
17
+ *
18
+ * Disclaimer:
19
+ * THIS SCRIPT AND ITS CODE ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
20
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL
22
+ * FIBER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING BUT NOT LIMITED TO LOSS OF USE,
24
+ * DATA, PROFITS, OR BUSINESS INTERRUPTION) ARISING OUT OF OR RELATED TO THE USE
25
+ * OR INABILITY TO USE THIS SCRIPT, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
+ *
27
+ * Unauthorized copying or reproduction of this script, in whole or in part,
28
+ * is a violation of applicable intellectual property laws and will result
29
+ * in legal action.
30
+ */
31
+
32
+ export * from "./auth/is_user_disabled";
package/tsconfig.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "NodeNext",
5
+ "lib": [
6
+ "ES2020"
7
+ ],
8
+ "moduleResolution": "NodeNext",
9
+ "rootDir": "src",
10
+ "outDir": "lib",
11
+ "sourceMap": true,
12
+ "declaration": false,
13
+ "declarationMap": false,
14
+ "strict": true,
15
+ "esModuleInterop": true,
16
+ "forceConsistentCasingInFileNames": true,
17
+ "skipLibCheck": true,
18
+ "isolatedModules": false,
19
+ "noUncheckedIndexedAccess": true,
20
+ "exactOptionalPropertyTypes": true,
21
+ "allowJs": true,
22
+ "checkJs": false
23
+ },
24
+ "compileOnSave": true,
25
+ "include": [
26
+ "src"
27
+ ],
28
+ "exclude": [
29
+ "node_modules",
30
+ "lib"
31
+ ]
32
+ }