@umituz/react-native-firebase 1.13.36 → 1.13.38

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.
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ /**
3
+ * Firebase Admin Initialization
4
+ * Dynamic configuration - no hardcoded values
5
+ */
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
19
+ }) : function(o, v) {
20
+ o["default"] = v;
21
+ });
22
+ var __importStar = (this && this.__importStar) || (function () {
23
+ var ownKeys = function(o) {
24
+ ownKeys = Object.getOwnPropertyNames || function (o) {
25
+ var ar = [];
26
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
27
+ return ar;
28
+ };
29
+ return ownKeys(o);
30
+ };
31
+ return function (mod) {
32
+ if (mod && mod.__esModule) return mod;
33
+ var result = {};
34
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
35
+ __setModuleDefault(result, mod);
36
+ return result;
37
+ };
38
+ })();
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.initFirebaseAdmin = initFirebaseAdmin;
41
+ exports.getFirestoreAdmin = getFirestoreAdmin;
42
+ exports.getAuthAdmin = getAuthAdmin;
43
+ exports.getStorageAdmin = getStorageAdmin;
44
+ exports.resetFirebaseAdmin = resetFirebaseAdmin;
45
+ const admin = __importStar(require("firebase-admin"));
46
+ let initializedApp = null;
47
+ /**
48
+ * Initialize Firebase Admin SDK with config
49
+ * @param config - Firebase Admin configuration
50
+ * @returns Initialized Firebase Admin app
51
+ */
52
+ function initFirebaseAdmin(config) {
53
+ if (initializedApp) {
54
+ return initializedApp;
55
+ }
56
+ if (admin.apps.length > 0) {
57
+ initializedApp = admin.apps[0];
58
+ return initializedApp;
59
+ }
60
+ initializedApp = admin.initializeApp({
61
+ credential: admin.credential.cert(config.serviceAccountPath),
62
+ projectId: config.projectId,
63
+ storageBucket: config.storageBucket,
64
+ });
65
+ return initializedApp;
66
+ }
67
+ /**
68
+ * Get Firestore instance
69
+ */
70
+ function getFirestoreAdmin(app) {
71
+ return admin.firestore(app);
72
+ }
73
+ /**
74
+ * Get Auth instance
75
+ */
76
+ function getAuthAdmin(app) {
77
+ return admin.auth(app);
78
+ }
79
+ /**
80
+ * Get Storage bucket
81
+ */
82
+ function getStorageAdmin(app) {
83
+ return admin.storage(app);
84
+ }
85
+ /**
86
+ * Reset initialized app (for testing)
87
+ */
88
+ function resetFirebaseAdmin() {
89
+ initializedApp = null;
90
+ }
91
+ //# sourceMappingURL=init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../../scripts/init.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYH,8CAiBC;AAKD,8CAEC;AAKD,oCAEC;AAKD,0CAEC;AAKD,gDAEC;AAvDD,sDAAwC;AAGxC,IAAI,cAAc,GAAyB,IAAI,CAAC;AAEhD;;;;GAIG;AACH,SAAgB,iBAAiB,CAAC,MAA2B;IAC3D,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1B,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAE,CAAC;QAChC,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,cAAc,GAAG,KAAK,CAAC,aAAa,CAAC;QACnC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC;QAC5D,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,aAAa,EAAE,MAAM,CAAC,aAAa;KACpC,CAAC,CAAC;IAEH,OAAO,cAAc,CAAC;AACxB,CAAC;AAED;;GAEG;AACH,SAAgB,iBAAiB,CAAC,GAAkB;IAClD,OAAO,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;AAC9B,CAAC;AAED;;GAEG;AACH,SAAgB,YAAY,CAAC,GAAkB;IAC7C,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC;AAED;;GAEG;AACH,SAAgB,eAAe,CAAC,GAAkB;IAChD,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AAC5B,CAAC;AAED;;GAEG;AACH,SAAgB,kBAAkB;IAChC,cAAc,GAAG,IAAI,CAAC;AACxB,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Firebase Admin Storage Utilities
3
+ * Generic Storage operations for admin scripts
4
+ */
5
+ import * as admin from "firebase-admin";
6
+ import type { StorageFileInfo, CleanupResult } from "./types";
7
+ /**
8
+ * List all files in storage bucket
9
+ */
10
+ export declare function listFiles(storage: admin.storage.Storage, prefix?: string): Promise<StorageFileInfo[]>;
11
+ /**
12
+ * Delete all files in storage
13
+ */
14
+ export declare function deleteAllFiles(storage: admin.storage.Storage, onProgress?: (deleted: number, total: number) => void): Promise<CleanupResult>;
15
+ /**
16
+ * Delete files by prefix (folder)
17
+ */
18
+ export declare function deleteFilesByPrefix(storage: admin.storage.Storage, prefix: string, onProgress?: (deleted: number, total: number) => void): Promise<CleanupResult>;
19
+ /**
20
+ * Get storage statistics
21
+ */
22
+ export declare function getStorageStats(storage: admin.storage.Storage): Promise<{
23
+ totalFiles: number;
24
+ totalSizeBytes: number;
25
+ totalSizeMB: number;
26
+ }>;
27
+ /**
28
+ * Delete user files (files in users/{userId}/ folder)
29
+ */
30
+ export declare function deleteUserFiles(storage: admin.storage.Storage, userId: string, onProgress?: (deleted: number, total: number) => void): Promise<CleanupResult>;
31
+ //# sourceMappingURL=storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../scripts/storage.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE9D;;GAEG;AACH,wBAAsB,SAAS,CAC7B,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,EAC9B,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,eAAe,EAAE,CAAC,CAY5B;AAED;;GAEG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,EAC9B,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,GACpD,OAAO,CAAC,aAAa,CAAC,CAsBxB;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,EAC9B,MAAM,EAAE,MAAM,EACd,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,GACpD,OAAO,CAAC,aAAa,CAAC,CAsBxB;AAED;;GAEG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,GAC7B,OAAO,CAAC;IACT,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC,CASD;AAED;;GAEG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,EAC9B,MAAM,EAAE,MAAM,EACd,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,GACpD,OAAO,CAAC,aAAa,CAAC,CAExB"}
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ /**
3
+ * Firebase Admin Storage Utilities
4
+ * Generic Storage operations for admin scripts
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.listFiles = listFiles;
8
+ exports.deleteAllFiles = deleteAllFiles;
9
+ exports.deleteFilesByPrefix = deleteFilesByPrefix;
10
+ exports.getStorageStats = getStorageStats;
11
+ exports.deleteUserFiles = deleteUserFiles;
12
+ /**
13
+ * List all files in storage bucket
14
+ */
15
+ async function listFiles(storage, prefix) {
16
+ const bucket = storage.bucket();
17
+ const [files] = await bucket.getFiles({ prefix });
18
+ return files.map((file) => ({
19
+ name: file.name,
20
+ size: parseInt(file.metadata.size, 10) || 0,
21
+ contentType: file.metadata.contentType,
22
+ createdAt: file.metadata.timeCreated
23
+ ? new Date(file.metadata.timeCreated)
24
+ : undefined,
25
+ }));
26
+ }
27
+ /**
28
+ * Delete all files in storage
29
+ */
30
+ async function deleteAllFiles(storage, onProgress) {
31
+ const bucket = storage.bucket();
32
+ const [files] = await bucket.getFiles();
33
+ const result = {
34
+ totalProcessed: files.length,
35
+ deleted: 0,
36
+ preserved: 0,
37
+ errors: [],
38
+ };
39
+ for (const file of files) {
40
+ try {
41
+ await file.delete();
42
+ result.deleted++;
43
+ onProgress?.(result.deleted, files.length);
44
+ }
45
+ catch (error) {
46
+ result.errors.push(`Failed to delete ${file.name}: ${error}`);
47
+ }
48
+ }
49
+ return result;
50
+ }
51
+ /**
52
+ * Delete files by prefix (folder)
53
+ */
54
+ async function deleteFilesByPrefix(storage, prefix, onProgress) {
55
+ const bucket = storage.bucket();
56
+ const [files] = await bucket.getFiles({ prefix });
57
+ const result = {
58
+ totalProcessed: files.length,
59
+ deleted: 0,
60
+ preserved: 0,
61
+ errors: [],
62
+ };
63
+ for (const file of files) {
64
+ try {
65
+ await file.delete();
66
+ result.deleted++;
67
+ onProgress?.(result.deleted, files.length);
68
+ }
69
+ catch (error) {
70
+ result.errors.push(`Failed to delete ${file.name}: ${error}`);
71
+ }
72
+ }
73
+ return result;
74
+ }
75
+ /**
76
+ * Get storage statistics
77
+ */
78
+ async function getStorageStats(storage) {
79
+ const files = await listFiles(storage);
80
+ const totalSizeBytes = files.reduce((sum, file) => sum + file.size, 0);
81
+ return {
82
+ totalFiles: files.length,
83
+ totalSizeBytes,
84
+ totalSizeMB: Math.round((totalSizeBytes / (1024 * 1024)) * 100) / 100,
85
+ };
86
+ }
87
+ /**
88
+ * Delete user files (files in users/{userId}/ folder)
89
+ */
90
+ async function deleteUserFiles(storage, userId, onProgress) {
91
+ return deleteFilesByPrefix(storage, `users/${userId}/`, onProgress);
92
+ }
93
+ //# sourceMappingURL=storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.js","sourceRoot":"","sources":["../../scripts/storage.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAQH,8BAeC;AAKD,wCAyBC;AAKD,kDA0BC;AAKD,0CAeC;AAKD,0CAMC;AA9GD;;GAEG;AACI,KAAK,UAAU,SAAS,CAC7B,OAA8B,EAC9B,MAAe;IAEf,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAChC,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IAElD,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC1B,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,I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1
+ /**
2
+ * Firebase Admin Scripts - Shared Types
3
+ * Generic types for Firebase Admin operations
4
+ */
5
+ export interface FirebaseAdminConfig {
6
+ /** Path to service account JSON file */
7
+ serviceAccountPath: string;
8
+ /** Firebase project ID */
9
+ projectId: string;
10
+ /** Storage bucket name (optional) */
11
+ storageBucket?: string;
12
+ }
13
+ export interface CollectionInfo {
14
+ name: string;
15
+ documentCount: number;
16
+ sampleDocumentId?: string;
17
+ hasSubcollections?: boolean;
18
+ }
19
+ export interface UserInfo {
20
+ uid: string;
21
+ email?: string;
22
+ displayName?: string;
23
+ isAnonymous: boolean;
24
+ createdAt?: Date;
25
+ providerCount: number;
26
+ }
27
+ export interface CleanupResult {
28
+ totalProcessed: number;
29
+ deleted: number;
30
+ preserved: number;
31
+ errors: string[];
32
+ }
33
+ export interface BatchResult {
34
+ success: boolean;
35
+ processed: number;
36
+ errors: string[];
37
+ }
38
+ export interface StorageFileInfo {
39
+ name: string;
40
+ size: number;
41
+ contentType?: string;
42
+ createdAt?: Date;
43
+ }
44
+ export interface ResetSummary {
45
+ authUsersDeleted: number;
46
+ firestoreDocsDeleted: number;
47
+ storageFilesDeleted: number;
48
+ }
49
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../scripts/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,mBAAmB;IAClC,wCAAwC;IACxC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,0BAA0B;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,qCAAqC;IACrC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,aAAa;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,IAAI,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,gBAAgB,EAAE,MAAM,CAAC;IACzB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,mBAAmB,EAAE,MAAM,CAAC;CAC7B"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * Firebase Admin Scripts - Shared Types
4
+ * Generic types for Firebase Admin operations
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../scripts/types.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Firebase Admin Scripts - Utility Functions
3
+ * Generic helpers for seeding and testing
4
+ */
5
+ /**
6
+ * Generate random ID
7
+ */
8
+ export declare function randomId(): string;
9
+ /**
10
+ * Generate random date within the past N days
11
+ */
12
+ export declare function randomDate(daysAgo: number): Date;
13
+ /**
14
+ * Get random item from array
15
+ */
16
+ export declare function randomItem<T>(arr: T[]): T;
17
+ /**
18
+ * Generate random number in range
19
+ */
20
+ export declare function randomNumber(min: number, max: number): number;
21
+ /**
22
+ * Generate random boolean
23
+ */
24
+ export declare function randomBoolean(): boolean;
25
+ /**
26
+ * Sleep for specified milliseconds
27
+ */
28
+ export declare function sleep(ms: number): Promise<void>;
29
+ /**
30
+ * Format bytes to human readable string
31
+ */
32
+ export declare function formatBytes(bytes: number): string;
33
+ /**
34
+ * Create a confirmation prompt (for CLI scripts)
35
+ */
36
+ export declare function createConfirmationTimer(seconds: number, warningMessage: string): Promise<void>;
37
+ /**
38
+ * Print separator line
39
+ */
40
+ export declare function printSeparator(char?: string, length?: number): void;
41
+ /**
42
+ * Print header with separators
43
+ */
44
+ export declare function printHeader(title: string): void;
45
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../scripts/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,wBAAgB,QAAQ,IAAI,MAAM,CAKjC;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAMhD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,CAEzC;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAEvC;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMjD;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,IAAI,CAAC,CAMf;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,SAAM,EAAE,MAAM,SAAK,GAAG,IAAI,CAE5D;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAK/C"}
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ /**
3
+ * Firebase Admin Scripts - Utility Functions
4
+ * Generic helpers for seeding and testing
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.randomId = randomId;
8
+ exports.randomDate = randomDate;
9
+ exports.randomItem = randomItem;
10
+ exports.randomNumber = randomNumber;
11
+ exports.randomBoolean = randomBoolean;
12
+ exports.sleep = sleep;
13
+ exports.formatBytes = formatBytes;
14
+ exports.createConfirmationTimer = createConfirmationTimer;
15
+ exports.printSeparator = printSeparator;
16
+ exports.printHeader = printHeader;
17
+ /**
18
+ * Generate random ID
19
+ */
20
+ function randomId() {
21
+ return (Math.random().toString(36).substring(2, 15) +
22
+ Math.random().toString(36).substring(2, 15));
23
+ }
24
+ /**
25
+ * Generate random date within the past N days
26
+ */
27
+ function randomDate(daysAgo) {
28
+ const now = new Date();
29
+ const pastDate = new Date(now.getTime() - daysAgo * 24 * 60 * 60 * 1000);
30
+ const randomTime = pastDate.getTime() + Math.random() * (now.getTime() - pastDate.getTime());
31
+ return new Date(randomTime);
32
+ }
33
+ /**
34
+ * Get random item from array
35
+ */
36
+ function randomItem(arr) {
37
+ return arr[Math.floor(Math.random() * arr.length)];
38
+ }
39
+ /**
40
+ * Generate random number in range
41
+ */
42
+ function randomNumber(min, max) {
43
+ return Math.floor(Math.random() * (max - min + 1)) + min;
44
+ }
45
+ /**
46
+ * Generate random boolean
47
+ */
48
+ function randomBoolean() {
49
+ return Math.random() > 0.5;
50
+ }
51
+ /**
52
+ * Sleep for specified milliseconds
53
+ */
54
+ function sleep(ms) {
55
+ return new Promise((resolve) => setTimeout(resolve, ms));
56
+ }
57
+ /**
58
+ * Format bytes to human readable string
59
+ */
60
+ function formatBytes(bytes) {
61
+ if (bytes === 0)
62
+ return "0 Bytes";
63
+ const k = 1024;
64
+ const sizes = ["Bytes", "KB", "MB", "GB"];
65
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
66
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + " " + sizes[i];
67
+ }
68
+ /**
69
+ * Create a confirmation prompt (for CLI scripts)
70
+ */
71
+ function createConfirmationTimer(seconds, warningMessage) {
72
+ return new Promise((resolve) => {
73
+ console.log(warningMessage);
74
+ console.log(`\nPress Ctrl+C to cancel, or wait ${seconds} seconds to continue...\n`);
75
+ setTimeout(resolve, seconds * 1000);
76
+ });
77
+ }
78
+ /**
79
+ * Print separator line
80
+ */
81
+ function printSeparator(char = "=", length = 70) {
82
+ console.log(char.repeat(length));
83
+ }
84
+ /**
85
+ * Print header with separators
86
+ */
87
+ function printHeader(title) {
88
+ printSeparator();
89
+ console.log(title);
90
+ printSeparator();
91
+ console.log();
92
+ }
93
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../scripts/utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAKH,4BAKC;AAKD,gCAMC;AAKD,gCAEC;AAKD,oCAEC;AAKD,sCAEC;AAKD,sBAEC;AAKD,kCAMC;AAKD,0DASC;AAKD,wCAEC;AAKD,kCAKC;AAzFD;;GAEG;AACH,SAAgB,QAAQ;IACtB,OAAO,CACL,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC;QAC3C,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAC5C,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,S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EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC1C,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACpD,OAAO,UAAU,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;AAC1E,CAAC;AAED;;GAEG;AACH,SAAgB,uBAAuB,CACrC,OAAe,EACf,cAAsB;IAEtB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QAC5B,OAAO,CAAC,GAAG,CAAC,qCAAqC,OAAO,2BAA2B,CAAC,CAAC;QACrF,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,SAAgB,cAAc,CAAC,IAAI,GAAG,GAAG,EAAE,MAAM,GAAG,EAAE;IACpD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;AACnC,CAAC;AAED;;GAEG;AACH,SAAgB,WAAW,CAAC,KAAa;IACvC,cAAc,EAAE,CAAC;IACjB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACnB,cAAc,EAAE,CAAC;IACjB,OAAO,CAAC,GAAG,EAAE,CAAC;AAChB,CAAC"}
package/package.json CHANGED
@@ -1,10 +1,12 @@
1
1
  {
2
2
  "name": "@umituz/react-native-firebase",
3
- "version": "1.13.36",
3
+ "version": "1.13.38",
4
4
  "description": "Unified Firebase package for React Native apps - Auth and Firestore services using Firebase JS SDK (no native modules).",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
7
7
  "scripts": {
8
+ "build:scripts": "tsc -p tsconfig.scripts.json",
9
+ "prepublishOnly": "npm run build:scripts",
8
10
  "typecheck": "echo 'TypeScript validation passed'",
9
11
  "lint": "echo 'Lint passed'",
10
12
  "version:patch": "npm version patch -m 'chore: release v%s'",
@@ -49,16 +51,30 @@
49
51
  "expo-apple-authentication": "^8.0.8",
50
52
  "expo-crypto": "^15.0.8",
51
53
  "firebase": "^12.6.0",
54
+ "firebase-admin": "^13.6.0",
52
55
  "react": "19.1.0",
53
56
  "react-native": "0.81.5",
54
57
  "typescript": "~5.9.2"
55
58
  },
59
+ "optionalDependencies": {
60
+ "firebase-admin": "^13.0.2"
61
+ },
56
62
  "publishConfig": {
57
63
  "access": "public"
58
64
  },
59
65
  "files": [
60
66
  "src",
67
+ "scripts",
68
+ "dist/scripts",
61
69
  "README.md",
62
70
  "LICENSE"
63
- ]
71
+ ],
72
+ "exports": {
73
+ ".": "./src/index.ts",
74
+ "./scripts": {
75
+ "require": "./dist/scripts/index.js",
76
+ "import": "./dist/scripts/index.js",
77
+ "types": "./dist/scripts/index.d.ts"
78
+ }
79
+ }
64
80
  }
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Firebase Admin Auth Utilities
3
+ * Generic auth operations for admin scripts
4
+ */
5
+
6
+ import * as admin from "firebase-admin";
7
+ import type { UserInfo, CleanupResult } from "./types";
8
+
9
+ /**
10
+ * List all users from Firebase Auth
11
+ */
12
+ export async function listAllUsers(auth: admin.auth.Auth): Promise<UserInfo[]> {
13
+ const users: UserInfo[] = [];
14
+ let nextPageToken: string | undefined;
15
+
16
+ do {
17
+ const result = await auth.listUsers(1000, nextPageToken);
18
+
19
+ result.users.forEach((user) => {
20
+ users.push({
21
+ uid: user.uid,
22
+ email: user.email,
23
+ displayName: user.displayName,
24
+ isAnonymous: !user.providerData || user.providerData.length === 0,
25
+ createdAt: user.metadata.creationTime
26
+ ? new Date(user.metadata.creationTime)
27
+ : undefined,
28
+ providerCount: user.providerData?.length ?? 0,
29
+ });
30
+ });
31
+
32
+ nextPageToken = result.pageToken;
33
+ } while (nextPageToken);
34
+
35
+ return users;
36
+ }
37
+
38
+ /**
39
+ * List only authenticated users (with email/providers)
40
+ */
41
+ export async function listAuthenticatedUsers(
42
+ auth: admin.auth.Auth
43
+ ): Promise<UserInfo[]> {
44
+ const allUsers = await listAllUsers(auth);
45
+ return allUsers.filter((user) => !user.isAnonymous && user.email);
46
+ }
47
+
48
+ /**
49
+ * List only anonymous users
50
+ */
51
+ export async function listAnonymousUsers(
52
+ auth: admin.auth.Auth
53
+ ): Promise<UserInfo[]> {
54
+ const allUsers = await listAllUsers(auth);
55
+ return allUsers.filter((user) => user.isAnonymous);
56
+ }
57
+
58
+ /**
59
+ * Delete users by UIDs
60
+ */
61
+ export async function deleteUsers(
62
+ auth: admin.auth.Auth,
63
+ uids: string[],
64
+ onProgress?: (deleted: number, total: number) => void
65
+ ): Promise<CleanupResult> {
66
+ const result: CleanupResult = {
67
+ totalProcessed: uids.length,
68
+ deleted: 0,
69
+ preserved: 0,
70
+ errors: [],
71
+ };
72
+
73
+ for (const uid of uids) {
74
+ try {
75
+ await auth.deleteUser(uid);
76
+ result.deleted++;
77
+ onProgress?.(result.deleted, uids.length);
78
+ } catch (error) {
79
+ result.errors.push(`Failed to delete ${uid}: ${error}`);
80
+ }
81
+ }
82
+
83
+ return result;
84
+ }
85
+
86
+ /**
87
+ * Cleanup anonymous users - delete all users without providers
88
+ */
89
+ export async function cleanupAnonymousUsers(
90
+ auth: admin.auth.Auth,
91
+ onProgress?: (deleted: number, total: number) => void
92
+ ): Promise<CleanupResult> {
93
+ const anonymousUsers = await listAnonymousUsers(auth);
94
+ const uids = anonymousUsers.map((u) => u.uid);
95
+
96
+ if (uids.length === 0) {
97
+ return {
98
+ totalProcessed: 0,
99
+ deleted: 0,
100
+ preserved: 0,
101
+ errors: [],
102
+ };
103
+ }
104
+
105
+ const deleteResult = await deleteUsers(auth, uids, onProgress);
106
+
107
+ // Count preserved (authenticated) users
108
+ const authenticatedUsers = await listAuthenticatedUsers(auth);
109
+ deleteResult.preserved = authenticatedUsers.length;
110
+
111
+ return deleteResult;
112
+ }
113
+
114
+ /**
115
+ * Delete all users from Firebase Auth
116
+ */
117
+ export async function deleteAllUsers(
118
+ auth: admin.auth.Auth,
119
+ onProgress?: (deleted: number, total: number) => void
120
+ ): Promise<CleanupResult> {
121
+ const allUsers = await listAllUsers(auth);
122
+ const uids = allUsers.map((u) => u.uid);
123
+ return deleteUsers(auth, uids, onProgress);
124
+ }
125
+
126
+ /**
127
+ * Get user statistics
128
+ */
129
+ export async function getUserStats(auth: admin.auth.Auth): Promise<{
130
+ total: number;
131
+ anonymous: number;
132
+ authenticated: number;
133
+ }> {
134
+ const allUsers = await listAllUsers(auth);
135
+ const anonymous = allUsers.filter((u) => u.isAnonymous).length;
136
+
137
+ return {
138
+ total: allUsers.length,
139
+ anonymous,
140
+ authenticated: allUsers.length - anonymous,
141
+ };
142
+ }