{"_id":"@aiwa/firekit","_rev":"4-563e4c2d003a05614504dd6b08410c0e","name":"@aiwa/firekit","dist-tags":{"latest":"1.3.0"},"versions":{"1.0.0":{"name":"@aiwa/firekit","version":"1.0.0","keywords":["firebase","firestore","auth","aiwa","database","multi-tenant","realtime"],"author":{"name":"AIWA Cloud"},"license":"MIT","_id":"@aiwa/firekit@1.0.0","maintainers":[{"name":"alabs02","email":"alabson.inc@gmail.com"}],"homepage":"https://aiwa.codes","bugs":{"url":"https://github.com/Alabs02/aiwa-v0-sdk/issues"},"dist":{"shasum":"6d997d4f755b439b50384a33248ce4d2a5cd6955","tarball":"https://registry.npmjs.org/@aiwa/firekit/-/firekit-1.0.0.tgz","fileCount":7,"integrity":"sha512-tda8HTUOuEXul46DVRchzO4SoWglCj0pR0xuXxXfHmnZ+kxuO8c0Gnl4wSYEQd4z+/mn7IDAbUR5HX/f4yl76Q==","signatures":[{"sig":"MEUCIQC7X6H5Nl/5Rl0eoNuoSSrAFXr+tBwFI9z0jSm7jfhc3gIgDGI1n6qrn1mhv+H4U2w7xgQ0CpxLBx6fbEbVV5aCpGg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":60995},"main":"./dist/index.cjs","type":"module","_from":"file:aiwa-firekit-1.0.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"dev":"tsup src/index.ts --format cjs,esm --dts --watch","test":"echo \"No tests yet\" && exit 0","build":"tsup src/index.ts --format cjs,esm --dts --clean"},"_npmUser":{"name":"alabs02","email":"alabson.inc@gmail.com"},"_resolved":"C:\\Users\\alabs\\AppData\\Local\\Temp\\eeb1ad7eec562cbc685859d250905e16\\aiwa-firekit-1.0.0.tgz","_integrity":"sha512-tda8HTUOuEXul46DVRchzO4SoWglCj0pR0xuXxXfHmnZ+kxuO8c0Gnl4wSYEQd4z+/mn7IDAbUR5HX/f4yl76Q==","repository":{"url":"git+https://github.com/Alabs02/aiwa-v0-sdk.git","type":"git"},"_npmVersion":"10.9.4","description":"AIWA's managed Firebase SDK for multi-tenant applications","directories":{},"_nodeVersion":"22.21.0","dependencies":{"firebase":"^12.7.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.7.3","@types/node":"^22.12.0"},"_npmOperationalInternal":{"tmp":"tmp/firekit_1.0.0_1766975103536_0.5652508239009932","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@aiwa/firekit","version":"1.1.0","keywords":["firebase","firestore","auth","aiwa","database","multi-tenant","realtime"],"author":{"name":"AIWA Cloud"},"license":"MIT","_id":"@aiwa/firekit@1.1.0","maintainers":[{"name":"alabs02","email":"alabson.inc@gmail.com"}],"homepage":"https://aiwa.codes","bugs":{"url":"https://github.com/Alabs02/aiwa-v0-sdk/issues"},"dist":{"shasum":"603bc93139d31c19fb3f9f99c4058135bdc32416","tarball":"https://registry.npmjs.org/@aiwa/firekit/-/firekit-1.1.0.tgz","fileCount":7,"integrity":"sha512-3aSxC1ccKesT44nTs/HQ4aX7dHBiXtyID3X/bWG8kBSBvQ29MHncLkvvsZPpzKX34U0UMseSdH0WkF/D9Ly1ew==","signatures":[{"sig":"MEYCIQD8RvmguJgq5NSoDQT/KuS8Z87UI/WPY4GWGpJqpKr6SgIhAP530jiN8pS5zOZxm7lqRacup1lDb7uX/eKv53pUDS58","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":59190},"main":"./dist/index.cjs","type":"module","_from":"file:aiwa-firekit-1.1.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"dev":"tsup src/index.ts --format cjs,esm --dts --watch","test":"echo \"No tests yet\" && exit 0","build":"tsup src/index.ts --format cjs,esm --dts --clean"},"_npmUser":{"name":"alabs02","email":"alabson.inc@gmail.com"},"_resolved":"C:\\Users\\alabs\\AppData\\Local\\Temp\\efd21558af231b5629a069dd90bd89bf\\aiwa-firekit-1.1.0.tgz","_integrity":"sha512-3aSxC1ccKesT44nTs/HQ4aX7dHBiXtyID3X/bWG8kBSBvQ29MHncLkvvsZPpzKX34U0UMseSdH0WkF/D9Ly1ew==","repository":{"url":"git+https://github.com/Alabs02/aiwa-v0-sdk.git","type":"git"},"_npmVersion":"10.9.4","description":"AIWA's managed Firebase SDK for multi-tenant applications","directories":{},"_nodeVersion":"22.21.0","dependencies":{"firebase":"^12.7.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.7.3","@types/node":"^22.12.0"},"_npmOperationalInternal":{"tmp":"tmp/firekit_1.1.0_1766978125455_0.612714363469139","host":"s3://npm-registry-packages-npm-production"}},"1.2.0":{"name":"@aiwa/firekit","version":"1.2.0","keywords":["firebase","firestore","auth","aiwa","database","multi-tenant","realtime"],"author":{"name":"AIWA Cloud"},"license":"MIT","_id":"@aiwa/firekit@1.2.0","maintainers":[{"name":"alabs02","email":"alabson.inc@gmail.com"}],"homepage":"https://aiwa.codes","bugs":{"url":"https://github.com/Alabs02/aiwa-v0-sdk/issues"},"dist":{"shasum":"3925c0dc1857870edea879ee025fa77e21841953","tarball":"https://registry.npmjs.org/@aiwa/firekit/-/firekit-1.2.0.tgz","fileCount":7,"integrity":"sha512-BuCOAo6MWqfCtsDBhxLMPCN8h4RVXOuXMh3cd1TJeHptXkZtqup4UNCRtigjhOa46FekgQYAEFN+AtG8YQNamQ==","signatures":[{"sig":"MEQCIE02v4zLX1aJBcXiEtQ9MN5z75hksC04fut6LWFoT4ZiAiBfk96XhbQGNuJGu33fVyUy5WWbVhPo9SCO7C7TdJgAZQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":55740},"main":"./dist/index.cjs","type":"module","_from":"file:aiwa-firekit-1.2.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"dev":"tsup src/index.ts --format cjs,esm --dts --watch","test":"echo \"No tests yet\" && exit 0","build":"tsup src/index.ts --format cjs,esm --dts --clean"},"_npmUser":{"name":"alabs02","email":"alabson.inc@gmail.com"},"_resolved":"C:\\Users\\alabs\\AppData\\Local\\Temp\\c0aa852a98dbb8cdcbc08e399eb21280\\aiwa-firekit-1.2.0.tgz","_integrity":"sha512-BuCOAo6MWqfCtsDBhxLMPCN8h4RVXOuXMh3cd1TJeHptXkZtqup4UNCRtigjhOa46FekgQYAEFN+AtG8YQNamQ==","repository":{"url":"git+https://github.com/Alabs02/aiwa-v0-sdk.git","type":"git"},"_npmVersion":"10.9.4","description":"AIWA's managed Firebase SDK for multi-tenant applications","directories":{},"_nodeVersion":"22.21.0","dependencies":{"firebase":"^12.7.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.7.3","@types/node":"^22.12.0"},"_npmOperationalInternal":{"tmp":"tmp/firekit_1.2.0_1767021717952_0.7887082526821223","host":"s3://npm-registry-packages-npm-production"}},"1.3.0":{"name":"@aiwa/firekit","version":"1.3.0","description":"AIWA's managed Firebase SDK for multi-tenant applications","type":"module","main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"keywords":["firebase","firestore","auth","aiwa","database","multi-tenant","realtime"],"author":{"name":"AIWA Cloud"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/Alabs02/aiwa-v0-sdk.git"},"bugs":{"url":"https://github.com/Alabs02/aiwa-v0-sdk/issues"},"homepage":"https://aiwa.codes","dependencies":{"firebase":"^12.7.0"},"devDependencies":{"@types/node":"^22.12.0","tsup":"^8.0.0","typescript":"^5.7.3"},"engines":{"node":">=18"},"scripts":{"build":"tsup src/index.ts --format cjs,esm --dts --clean","dev":"tsup src/index.ts --format cjs,esm --dts --watch","test":"echo \"No tests yet\" && exit 0"},"_id":"@aiwa/firekit@1.3.0","_integrity":"sha512-O6x575ype+d4ZAcP7OR293SMu+iU82EQ4j/VL8coqfQrvw/SVwNSgL6uBnrbUuYXWko7OCPwvlWQvQ4tgDV5KQ==","_resolved":"C:\\Users\\alabs\\AppData\\Local\\Temp\\3407000ce66e0b61d8ac4bb4fc8780a1\\aiwa-firekit-1.3.0.tgz","_from":"file:aiwa-firekit-1.3.0.tgz","_nodeVersion":"22.21.0","_npmVersion":"10.9.4","dist":{"integrity":"sha512-O6x575ype+d4ZAcP7OR293SMu+iU82EQ4j/VL8coqfQrvw/SVwNSgL6uBnrbUuYXWko7OCPwvlWQvQ4tgDV5KQ==","shasum":"e5fb1b1a508138f6f0f5fbe2ad02724affb7883c","tarball":"https://registry.npmjs.org/@aiwa/firekit/-/firekit-1.3.0.tgz","fileCount":7,"unpackedSize":58710,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIGxG280xADnhnWFcea5c9UgTYWQHdYQJB/Y1wbCqY9iNAiEA3yR9fS/QEhWymzCve9LTSN0DDjh8F3oLj3BYmkO4Wds="}]},"_npmUser":{"name":"alabs02","email":"alabson.inc@gmail.com"},"directories":{},"maintainers":[{"name":"alabs02","email":"alabson.inc@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/firekit_1.3.0_1767072725321_0.5172951459001769"},"_hasShrinkwrap":false}},"time":{"created":"2025-12-29T02:25:03.445Z","modified":"2025-12-30T05:32:05.657Z","1.0.0":"2025-12-29T02:25:03.683Z","1.1.0":"2025-12-29T03:15:25.596Z","1.2.0":"2025-12-29T15:21:58.096Z","1.3.0":"2025-12-30T05:32:05.473Z"},"bugs":{"url":"https://github.com/Alabs02/aiwa-v0-sdk/issues"},"author":{"name":"AIWA Cloud"},"license":"MIT","homepage":"https://aiwa.codes","keywords":["firebase","firestore","auth","aiwa","database","multi-tenant","realtime"],"repository":{"type":"git","url":"git+https://github.com/Alabs02/aiwa-v0-sdk.git"},"description":"AIWA's managed Firebase SDK for multi-tenant applications","maintainers":[{"name":"alabs02","email":"alabson.inc@gmail.com"}],"readme":"# Firekit 🔥\n\nAIWA's managed Firebase SDK for multi-tenant applications. Zero configuration, complete isolation.\n\n## Features\n\n- ✅ **Zero Config** - Automatic Firebase initialization from AIWA backend\n- 🔒 **Multi-Tenant Isolation** - Each app is completely isolated via collection paths\n- 🔐 **Built-in Auth** - Email/password authentication with custom claims\n- ⚡ **Real-time Updates** - Live data subscriptions\n- 🎯 **Type-Safe** - Full TypeScript support\n- 🚀 **Edge-Ready** - Works with Vercel Edge Functions\n- 🔐 **Secure** - Firebase credentials managed server-side, never exposed to users\n\n## How It Works\n\n1. Your app calls `createDatabase({ projectId })`\n2. Firekit validates projectId with AIWA backend\n3. Backend returns userId, appId, and Firebase credentials\n4. Firekit initializes with returned credentials\n5. All data isolated to `/users/{userId}/apps/{appId}/data/`\n\n**Security**: Firebase credentials stay on AIWA's servers. User apps never see them.\n\n## Installation\n\n```bash\nnpm install @aiwa/firekit\n# or\npnpm add @aiwa/firekit\n# or\nyarn add @aiwa/firekit\n```\n\n## Environment Variables\n\nAdd to your `.env.local`:\n\n```env\nNEXT_PUBLIC_PROJECT_ID=your-project-id\n```\n\nThat's it. Firebase credentials are automatically retrieved from AIWA's secure backend.\n\n## Quick Start\n\n```typescript\nimport { createDatabase, createAuth } from '@aiwa/firekit'\n\n// Initialize database (multi-tenant isolated)\nconst db = await createDatabase({\n  projectId: process.env.NEXT_PUBLIC_PROJECT_ID!,\n})\n\n// Initialize auth\nconst auth = await createAuth({\n  projectId: process.env.NEXT_PUBLIC_PROJECT_ID!,\n})\n```\n\n## Database Operations\n\n### Create\n\n```typescript\nconst post = await db.create('posts', {\n  title: 'Hello World',\n  content: 'My first post',\n  published: true,\n})\n```\n\n### Read\n\n```typescript\n// Get single document\nconst post = await db.read('posts', 'post-id')\n\n// Get all documents\nconst posts = await db.getAll('posts')\n\n// Query with filters\nconst publishedPosts = await db.query('posts', {\n  where: [{ field: 'published', operator: '==', value: true }],\n  orderBy: { field: 'createdAt', direction: 'desc' },\n  limit: 10,\n})\n```\n\n### Update\n\n```typescript\nawait db.update('posts', 'post-id', {\n  title: 'Updated Title',\n})\n```\n\n### Delete\n\n```typescript\nawait db.delete('posts', 'post-id')\n```\n\n### Real-time Subscriptions\n\n```typescript\nconst unsubscribe = db.subscribe('posts', (posts) => {\n  console.log('Posts updated:', posts)\n})\n\n// Clean up when done\nunsubscribe()\n```\n\n## Authentication\n\n### Sign Up\n\n```typescript\nconst { user, token } = await auth.signUp(\n  'user@example.com',\n  'password123',\n  'John Doe', // optional display name\n)\n```\n\n### Sign In\n\n```typescript\nconst { user, token } = await auth.signIn('user@example.com', 'password123')\n```\n\n### Sign Out\n\n```typescript\nawait auth.signOut()\n```\n\n### Auth State Listener\n\n```typescript\nconst unsubscribe = auth.onAuthStateChanged((user) => {\n  if (user) {\n    console.log('Signed in:', user.email)\n  } else {\n    console.log('Signed out')\n  }\n})\n```\n\n### Password Reset\n\n```typescript\nawait auth.resetPassword('user@example.com')\n```\n\n## React Example\n\n```typescript\n'use client'\n\nimport { createDatabase, createAuth } from 'firekit'\nimport { useEffect, useState } from 'react'\n\nconst db = createDatabase({\n  userId: process.env.NEXT_PUBLIC_AIWA_USER_ID!,\n  appId: process.env.NEXT_PUBLIC_AIWA_APP_ID!,\n})\n\nconst auth = createAuth({\n  appId: process.env.NEXT_PUBLIC_AIWA_APP_ID!,\n})\n\nexport default function TodoApp() {\n  const [user, setUser] = useState(null)\n  const [todos, setTodos] = useState([])\n\n  // Auth listener\n  useEffect(() => {\n    return auth.onAuthStateChanged(setUser)\n  }, [])\n\n  // Real-time todos subscription\n  useEffect(() => {\n    if (!user) return\n\n    return db.subscribe(\n      'todos',\n      setTodos,\n      {\n        where: [{ field: 'userId', operator: '==', value: user.uid }],\n        orderBy: { field: '_createdAt', direction: 'desc' },\n      },\n    )\n  }, [user])\n\n  const addTodo = async (title: string) => {\n    await db.create('todos', {\n      title,\n      completed: false,\n      userId: user.uid,\n    })\n  }\n\n  const toggleTodo = async (id: string, completed: boolean) => {\n    await db.update('todos', id, { completed })\n  }\n\n  if (!user) return <SignInForm />\n\n  return <TodoList todos={todos} onAdd={addTodo} onToggle={toggleTodo} />\n}\n```\n\n## Multi-Tenant Isolation\n\nFirekit automatically isolates data using collection paths:\n\n```\n/users/{userId}/apps/{appId}/data/{collection}/{docId}\n```\n\nExample:\n\n- User A's app: `/users/user-a/apps/app-123/data/posts/post-1`\n- User B's app: `/users/user-b/apps/app-456/data/posts/post-1`\n\n**Complete isolation** - User A's app users cannot access User B's app data.\n\n## Security Rules\n\nFirekit enforces security via Firebase Security Rules with custom claims:\n\n```javascript\nrules_version = '2';\nservice cloud.firestore {\n  match /databases/{database}/documents {\n    match /users/{userId}/apps/{appId}/data/{collection}/{document=**} {\n      // AIWA user (app owner) has full access\n      allow read, write: if request.auth.token.userId == userId;\n\n      // App end-users have access based on appId\n      allow read, write: if request.auth.token.appId == appId\n                         && request.auth != null;\n    }\n  }\n}\n```\n\n## Error Handling\n\n```typescript\nimport { FirekitDatabaseError, FirekitAuthError } from 'firekit'\n\ntry {\n  await db.create('posts', { title: 'Hello' })\n} catch (error) {\n  if (error instanceof FirekitDatabaseError) {\n    console.error('Database error:', error.message, error.code)\n  }\n}\n\ntry {\n  await auth.signIn('email', 'password')\n} catch (error) {\n  if (error instanceof FirekitAuthError) {\n    console.error('Auth error:', error.message, error.code)\n  }\n}\n```\n\n## API Reference\n\n### Database Methods\n\n- `create(collection, data)` - Create document\n- `set(collection, id, data, merge?)` - Set document with ID\n- `read(collection, id)` - Read single document\n- `query(collection, options?)` - Query documents\n- `getAll(collection)` - Get all documents\n- `update(collection, id, data)` - Update document\n- `delete(collection, id)` - Delete document\n- `subscribe(collection, callback, options?)` - Real-time subscription\n- `subscribeToDoc(collection, id, callback)` - Single document subscription\n- `batchCreate(collection, items)` - Batch create\n- `count(collection, options?)` - Count documents\n\n### Auth Methods\n\n- `signUp(email, password, displayName?)` - Register user\n- `signIn(email, password)` - Sign in user\n- `signOut()` - Sign out\n- `resetPassword(email)` - Send reset email\n- `updateProfile(data)` - Update profile\n- `updateEmail(email)` - Update email\n- `updatePassword(password)` - Update password\n- `onAuthStateChanged(callback)` - Listen to auth changes\n- `getIdToken(forceRefresh?)` - Get ID token\n- `isAuthenticated()` - Check auth status\n\n## License\n\nApache-2.0\n","readmeFilename":"README.md"}