diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3993718..249e0db 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -91,6 +91,22 @@ jobs: set -o pipefail npm run test:run 2>&1 | tee test.log + - name: Setup Java + uses: actions/setup-java@v6 + with: + distribution: temurin + java-version: 21 + + - name: Install Firebase CLI + run: npm install --global firebase-tools@15.24.0 + + - name: Test Firestore rules + shell: bash + working-directory: functions + run: | + set -o pipefail + npm run test:rules 2>&1 | tee -a test.log + - name: Upload test log if: always() uses: actions/upload-artifact@v6 diff --git a/README.md b/README.md index a4981c0..8e814a7 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ DevLog의 Firebase Cloud Functions와 Firestore index 설정을 관리하는 저 ```mermaid flowchart LR Client["API Client"] --> Hosting["Firebase Hosting"] - Hosting -->|"/api/todos/**
/api/web-pages/**
/api/push-notifications/**
/api/auth/google/**
/api/auth/apple/**
/api/auth/github/**"| CloudRun["Cloud Run
api-v2"] + Hosting -->|"/api/todos/**
/api/push-notifications/**
/api/auth/google/**
/api/auth/apple/**
/api/auth/github/**"| CloudRun["Cloud Run
api-v2"] Hosting -->|"나머지 /api/**"| Functions["Cloud Functions
api"] CloudRun --> Auth["Firebase Auth"] Functions --> Auth @@ -28,13 +28,13 @@ flowchart LR | 실행 구성 | 소스 | 책임 | | --- | --- | --- | | Firebase Hosting | `firebase.json` | 공개 요청 진입점과 경로별 rewrite 순서 관리 | -| Cloud Run `api-v2` | `nestjs-api` | Todo, WebPage, PushNotification 요청의 Firebase ID Token 검증과 삭제, Google·Apple·GitHub 인증 관리 | +| Cloud Run `api-v2` | `nestjs-api` | Todo, PushNotification 요청의 Firebase ID Token 검증과 삭제, Google·Apple·GitHub 인증 관리 | | Cloud Functions `api` | `functions` | Staging의 나머지 `/api/**` 요청에 대한 `404` 응답 경계 유지 | | Cloud Functions 개별 함수 | `functions` | trigger, Scheduler, Cloud Tasks, FCM 처리 | | Firebase Auth | — | 인증이 필요한 경로에 전달된 Bearer token 검증 | | Firestore | — | 검증된 사용자 UID 범위의 공통 데이터 저장 | -Staging Hosting에서는 `/api/todos/**`, `/api/web-pages/**`, `/api/push-notifications/**`, `/api/auth/google/**`, `/api/auth/apple/**`, `/api/auth/github/**`를 Cloud Run `api-v2`가 우선 처리합니다. 나머지 `/api/**`는 Functions `api`가 `404` 응답 경계를 유지합니다. +Staging Hosting에서는 `/api/todos/**`, `/api/push-notifications/**`, `/api/auth/google/**`, `/api/auth/apple/**`, `/api/auth/github/**`를 Cloud Run `api-v2`가 우선 처리합니다. 나머지 `/api/**`는 Functions `api`가 `404` 응답 경계를 유지합니다. 기존 Functions를 한 번에 교체하지 않고 요청 계약을 유지하면서 경로 단위로 NestJS API에 이전하는 구조입니다. 최종적으로 Cloud Functions `api`가 담당하는 HTTP API 전체를 Cloud Run 기반 `api-v2`로 이전하는 것을 목표로 합니다. @@ -124,8 +124,11 @@ cd functions npm ci npm run build npm run test:run +npm run test:rules ``` +`npm run test:rules`는 `firebase.test.json`의 Firestore emulator를 `demo-devlog` project로 띄워 `firestore.rules`의 허용·거부를 확인합니다. Firebase CLI와 Java가 필요합니다. + ### NestJS API ```bash @@ -151,8 +154,11 @@ cd functions npm ci npm run build npm run test:run +npm run test:rules ``` +`test` job은 `npm run test:rules` 실행 전에 Java 21과 버전을 고정한 Firebase CLI를 설치합니다. + `nestjs-api` job은 다음 명령을 확인하고 실행 로그를 artifact로 보관합니다. ```bash @@ -192,4 +198,11 @@ firebase deploy --project --only functions: 여러 함수를 배포해야 할 때도 전체 일괄 배포보다 필요한 함수 단위로 나누어 배포합니다. +소스에서 제거한 함수는 `functions:` 배포로 삭제되지 않습니다. 각 project에서 명시적으로 삭제하고, 삭제한 함수가 사용하던 색인 설정 변경은 함수 삭제 뒤에 배포합니다. + +```bash +firebase functions:delete --project --region asia-northeast3 +firebase deploy --project --only firestore:indexes +``` + GitHub OAuth 전환 배포 전에는 staging과 prod 모두 `oauthSessions.expiresAt`, `oauthTickets.expiresAt` TTL 설정을 먼저 반영합니다. diff --git a/docs/cloud-run-staging.md b/docs/cloud-run-staging.md index b5f27f2..68b203a 100644 --- a/docs/cloud-run-staging.md +++ b/docs/cloud-run-staging.md @@ -164,11 +164,10 @@ region, runtime 및 build service account, Secret 연결 이름과 version 참 ## 직접 호출 검증 -검증 뒤 폐기할 수 있는 Staging Todo, WebPage와 PushNotification ID를 준비합니다. 각 문서는 삭제 요청 전 활성 상태여야 합니다. Firebase ID Token은 화면, shell history, 명령 인자에 남기지 않습니다. +검증 뒤 폐기할 수 있는 Staging Todo와 PushNotification ID를 준비합니다. 각 문서는 삭제 요청 전 활성 상태여야 합니다. Firebase ID Token은 화면, shell history, 명령 인자에 남기지 않습니다. ```bash read -r -p "Staging Todo ID: " TODO_ID -read -r -p "Staging WebPage ID: " WEB_PAGE_ID read -r -p "Staging PushNotification ID: " PUSH_NOTIFICATION_ID read -r -s -p "Firebase ID Token: " FIREBASE_ID_TOKEN printf '\n' @@ -257,16 +256,6 @@ curl -i -X DELETE \ "${SERVICE_URL}/api/todos/${TODO_ID}/deletion-request" \ <<<"Authorization: Bearer ${FIREBASE_ID_TOKEN}" -curl -i -X POST \ - -H @- \ - "${SERVICE_URL}/api/web-pages/${WEB_PAGE_ID}/deletion-request" \ - <<<"Authorization: Bearer ${FIREBASE_ID_TOKEN}" - -curl -i -X DELETE \ - -H @- \ - "${SERVICE_URL}/api/web-pages/${WEB_PAGE_ID}/deletion-request" \ - <<<"Authorization: Bearer ${FIREBASE_ID_TOKEN}" - curl -i -X POST \ -H @- \ "${SERVICE_URL}/api/push-notifications/${PUSH_NOTIFICATION_ID}/deletion-request" \ @@ -277,7 +266,7 @@ curl -i -X DELETE \ "${SERVICE_URL}/api/push-notifications/${PUSH_NOTIFICATION_ID}/deletion-request" \ <<<"Authorization: Bearer ${FIREBASE_ID_TOKEN}" -unset FIREBASE_ID_TOKEN TODO_ID WEB_PAGE_ID PUSH_NOTIFICATION_ID SERVICE_URL +unset FIREBASE_ID_TOKEN TODO_ID PUSH_NOTIFICATION_ID SERVICE_URL ``` 응답을 다음 순서로 확인합니다. @@ -297,9 +286,8 @@ unset FIREBASE_ID_TOKEN TODO_ID WEB_PAGE_ID PUSH_NOTIFICATION_ID SERVICE_URL 13. Token이 없는 GitHub access-token `DELETE`: `401`, `unauthenticated` 14. Token이 없는 Todo `POST`: `401` 15. Token이 있는 Todo `POST`와 `DELETE`: 각각 `200`, `{"success":true}` -16. Token이 있는 WebPage `POST`와 `DELETE`: 각각 `200`, `{"success":true}` -17. Token이 있는 PushNotification `POST`와 `DELETE`: 각각 `200`, `{"success":true}` -18. 각 `DELETE` 뒤 Todo와 연결 알림, WebPage 및 PushNotification의 삭제 상태 복구 +16. Token이 있는 PushNotification `POST`와 `DELETE`: 각각 `200`, `{"success":true}` +17. 각 `DELETE` 뒤 Todo와 연결 알림 및 PushNotification의 삭제 상태 복구 유효한 Firebase ID Token과 일회용 인증 값이 필요한 Google custom token, account-link, account-link 해제, access-token 폐기와 Apple challenge, custom token, account-link, account-link 해제, access-token 갱신·폐기 및 refresh-token 성공 경로, GitHub 로그인·계정 연결·연결 해제·grant 폐기 성공 경로는 Staging 앱에서 별도로 확인합니다. Token과 인증 코드는 로그와 shell history에 남기지 않습니다. @@ -344,7 +332,7 @@ gcloud run services update api-v2 \ --invoker-iam-check ``` -Token이 없는 요청이 `403`이면 Cloud Run 공개 설정이 적용되지 않은 상태입니다. 원인을 수정한 뒤 배포 명령을 다시 실행해 공개 설정을 적용하고 직접 호출 검증 전체를 반복합니다. 인증된 `POST` 성공 뒤 `DELETE`가 실패한 첫 배포는 수정본을 다시 배포한 뒤 실패한 경로의 `DELETE`부터 실행합니다. 이후 배포에서는 해당 API를 지원하는 이전 revision으로 복구한 뒤 같은 `DELETE`를 실행합니다. Todo와 연결 알림, WebPage 및 PushNotification의 삭제 상태가 복구됐는지 확인한 뒤 직접 호출 검증을 다시 수행합니다. +Token이 없는 요청이 `403`이면 Cloud Run 공개 설정이 적용되지 않은 상태입니다. 원인을 수정한 뒤 배포 명령을 다시 실행해 공개 설정을 적용하고 직접 호출 검증 전체를 반복합니다. 인증된 `POST` 성공 뒤 `DELETE`가 실패한 첫 배포는 수정본을 다시 배포한 뒤 실패한 경로의 `DELETE`부터 실행합니다. 이후 배포에서는 해당 API를 지원하는 이전 revision으로 복구한 뒤 같은 `DELETE`를 실행합니다. Todo와 연결 알림 및 PushNotification의 삭제 상태가 복구됐는지 확인한 뒤 직접 호출 검증을 다시 수행합니다. ## revision 복구 diff --git a/docs/firebase-hosting-staging.md b/docs/firebase-hosting-staging.md index 1201ce2..2a8e8ad 100644 --- a/docs/firebase-hosting-staging.md +++ b/docs/firebase-hosting-staging.md @@ -6,7 +6,6 @@ - Cloud Run 서비스: `api-v2` - region: `asia-northeast3` - Todo 경로: `/api/todos/**` -- WebPage 경로: `/api/web-pages/**` - PushNotification 경로: `/api/push-notifications/**` - Google 인증 경로: `/api/auth/google/**` - Apple 인증 경로: `/api/auth/apple/**` @@ -45,9 +44,8 @@ gcloud run services describe api-v2 \ 13. Token이 없는 GitHub access-token `DELETE`: `401`, `unauthenticated` 14. Token이 없는 Todo `POST`: `401` 15. Token이 있는 Todo `POST`와 `DELETE`: 각각 `200`, `{"success":true}` -16. Token이 있는 WebPage `POST`와 `DELETE`: 각각 `200`, `{"success":true}` -17. Token이 있는 PushNotification `POST`와 `DELETE`: 각각 `200`, `{"success":true}` -18. 각 `DELETE` 뒤 Todo와 연결 알림, WebPage 및 PushNotification의 삭제 상태 복구 +16. Token이 있는 PushNotification `POST`와 `DELETE`: 각각 `200`, `{"success":true}` +17. 각 `DELETE` 뒤 Todo와 연결 알림 및 PushNotification의 삭제 상태 복구 하나라도 확인되지 않으면 Hosting 라우팅을 배포하지 않습니다. @@ -65,12 +63,11 @@ cd .. `firebase.json`의 `devlog-staging` rewrite가 다음 순서인지 확인합니다. 1. `/api/todos/**` → Cloud Run `api-v2` -2. `/api/web-pages/**` → Cloud Run `api-v2` -3. `/api/push-notifications/**` → Cloud Run `api-v2` -4. `/api/auth/google/**` → Cloud Run `api-v2` -5. `/api/auth/apple/**` → Cloud Run `api-v2` -6. `/api/auth/github/**` → Cloud Run `api-v2` -7. `/api/**` → Functions `api` +2. `/api/push-notifications/**` → Cloud Run `api-v2` +3. `/api/auth/google/**` → Cloud Run `api-v2` +4. `/api/auth/apple/**` → Cloud Run `api-v2` +5. `/api/auth/github/**` → Cloud Run `api-v2` +6. `/api/**` → Functions `api` Cloud Run rewrite에는 `pinTag`가 없어야 합니다. `devlog-auth-prod` 블록은 변경하지 않습니다. @@ -100,11 +97,10 @@ Functions, Firestore rules, index, Cloud Run은 이 명령의 배포 대상이 ## 배포 후 요청 검증 -Staging 검증용 Todo, WebPage와 PushNotification 및 Firebase ID Token을 준비합니다. 각 문서는 삭제 요청 전 활성 상태여야 합니다. Header는 표준 입력으로 전달해 Token이 process 목록에 남지 않게 합니다. +Staging 검증용 Todo와 PushNotification 및 Firebase ID Token을 준비합니다. 각 문서는 삭제 요청 전 활성 상태여야 합니다. Header는 표준 입력으로 전달해 Token이 process 목록에 남지 않게 합니다. ```bash read -r -p "Staging Todo ID: " TODO_ID -read -r -p "Staging WebPage ID: " WEB_PAGE_ID read -r -p "Staging PushNotification ID: " PUSH_NOTIFICATION_ID read -r -s -p "Firebase ID Token: " FIREBASE_ID_TOKEN printf '\n' @@ -124,19 +120,6 @@ curl -i -X DELETE \ "${HOSTING_URL}/api/todos/${TODO_ID}/deletion-request" \ <<<"Authorization: Bearer ${FIREBASE_ID_TOKEN}" -curl -i -X POST \ - "${HOSTING_URL}/api/web-pages/route-check/deletion-request" - -curl -i -X POST \ - -H @- \ - "${HOSTING_URL}/api/web-pages/${WEB_PAGE_ID}/deletion-request" \ - <<<"Authorization: Bearer ${FIREBASE_ID_TOKEN}" - -curl -i -X DELETE \ - -H @- \ - "${HOSTING_URL}/api/web-pages/${WEB_PAGE_ID}/deletion-request" \ - <<<"Authorization: Bearer ${FIREBASE_ID_TOKEN}" - curl -i -X POST \ "${HOSTING_URL}/api/push-notifications/route-check/deletion-request" @@ -216,7 +199,7 @@ curl -i -X DELETE \ curl -i -X DELETE \ "${HOSTING_URL}/api/auth/github/access-token" -unset FIREBASE_ID_TOKEN TODO_ID WEB_PAGE_ID PUSH_NOTIFICATION_ID HOSTING_URL +unset FIREBASE_ID_TOKEN TODO_ID PUSH_NOTIFICATION_ID HOSTING_URL ``` 응답을 다음 순서로 확인합니다. @@ -224,24 +207,22 @@ unset FIREBASE_ID_TOKEN TODO_ID WEB_PAGE_ID PUSH_NOTIFICATION_ID HOSTING_URL 1. Token이 없는 Todo `POST`: `401` 2. Token이 있는 Todo `POST`: `200`, `{"success":true}` 3. Token이 있는 Todo `DELETE`: `200`, `{"success":true}` -4. Token이 없는 WebPage `POST`: Cloud Run `api-v2`의 `401` -5. Token이 있는 WebPage `POST`와 `DELETE`: 각각 `200`, `{"success":true}` -6. Token이 없는 PushNotification `POST`: Cloud Run `api-v2`의 `401` -7. Token이 있는 PushNotification `POST`와 `DELETE`: 각각 `200`, `{"success":true}` -8. `/api/auth/apple/challenges` `POST`: Cloud Run `api-v2`의 `200`, `challengeId`, `hashedNonce`, `expiresAt` 필드가 존재 -9. `/api/auth/apple/custom-token` `POST`: Cloud Run `api-v2`의 `400`, `invalid-argument` -10. body가 빈 Google custom token `POST`: Cloud Run `api-v2`의 `400`, `invalid-argument` -11. 잘못된 `serverAuthCode`를 전달한 Google custom token `POST`: Cloud Run `api-v2`의 `401`, `invalid-google-proof` -12. Token이 없는 Google account-link와 access-token `DELETE`: Cloud Run `api-v2`의 `401` -13. Token이 없는 Apple account-link `PUT`/`DELETE`, access-token `POST`/`DELETE`, refresh-token `POST`: Cloud Run `api-v2`의 `401` -14. body가 빈 GitHub 로그인 session `POST`: Cloud Run `api-v2`의 `400`, `invalid-argument` -15. query가 빈 GitHub callback `GET`: Cloud Run `api-v2`의 `302`, `devlog://oauth-callback?error=oauth-failed` -16. body가 빈 GitHub custom token `POST`: Cloud Run `api-v2`의 `400`, `invalid-argument` -17. Token이 없는 GitHub 계정 연결 session `POST`: Cloud Run `api-v2`의 `401`, `unauthenticated` -18. Token이 없는 GitHub account-link `PUT`: Cloud Run `api-v2`의 `401`, `unauthenticated` -19. Token이 없는 GitHub account-link `DELETE`: Cloud Run `api-v2`의 `401`, `unauthenticated` -20. Token이 없는 GitHub access-token `DELETE`: Cloud Run `api-v2`의 `401`, `unauthenticated` -21. 각 `DELETE` 뒤 Todo와 연결 알림, WebPage 및 PushNotification의 삭제 상태 복구 +4. Token이 없는 PushNotification `POST`: Cloud Run `api-v2`의 `401` +5. Token이 있는 PushNotification `POST`와 `DELETE`: 각각 `200`, `{"success":true}` +6. `/api/auth/apple/challenges` `POST`: Cloud Run `api-v2`의 `200`, `challengeId`, `hashedNonce`, `expiresAt` 필드가 존재 +7. `/api/auth/apple/custom-token` `POST`: Cloud Run `api-v2`의 `400`, `invalid-argument` +8. body가 빈 Google custom token `POST`: Cloud Run `api-v2`의 `400`, `invalid-argument` +9. 잘못된 `serverAuthCode`를 전달한 Google custom token `POST`: Cloud Run `api-v2`의 `401`, `invalid-google-proof` +10. Token이 없는 Google account-link와 access-token `DELETE`: Cloud Run `api-v2`의 `401` +11. Token이 없는 Apple account-link `PUT`/`DELETE`, access-token `POST`/`DELETE`, refresh-token `POST`: Cloud Run `api-v2`의 `401` +12. body가 빈 GitHub 로그인 session `POST`: Cloud Run `api-v2`의 `400`, `invalid-argument` +13. query가 빈 GitHub callback `GET`: Cloud Run `api-v2`의 `302`, `devlog://oauth-callback?error=oauth-failed` +14. body가 빈 GitHub custom token `POST`: Cloud Run `api-v2`의 `400`, `invalid-argument` +15. Token이 없는 GitHub 계정 연결 session `POST`: Cloud Run `api-v2`의 `401`, `unauthenticated` +16. Token이 없는 GitHub account-link `PUT`: Cloud Run `api-v2`의 `401`, `unauthenticated` +17. Token이 없는 GitHub account-link `DELETE`: Cloud Run `api-v2`의 `401`, `unauthenticated` +18. Token이 없는 GitHub access-token `DELETE`: Cloud Run `api-v2`의 `401`, `unauthenticated` +19. 각 `DELETE` 뒤 Todo와 연결 알림 및 PushNotification의 삭제 상태 복구 유효한 일회용 인증 값이 필요한 Apple challenge, custom token, account-link, account-link 해제, access-token 갱신·폐기 및 refresh-token 성공 경로와 GitHub 로그인·계정 연결·연결 해제·grant 폐기 성공 경로는 Staging 앱에서 확인합니다. 성공 응답과 최신 `api-v2` revision 로그를 함께 확인하며 Token과 인증 코드는 로그와 shell history에 남기지 않습니다. @@ -268,12 +249,12 @@ firebase functions:log \ unset LATEST_REVISION ``` -Todo, WebPage, PushNotification과 Google·Apple·GitHub 인증 요청은 최신 `api-v2` revision에서 확인되어야 합니다. 알려지지 않은 나머지 `/api/**` 요청은 Functions `api`의 `404` 응답으로 확인되어야 합니다. +Todo, PushNotification과 Google·Apple·GitHub 인증 요청은 최신 `api-v2` revision에서 확인되어야 합니다. 알려지지 않은 나머지 `/api/**` 요청은 Functions `api`의 `404` 응답으로 확인되어야 합니다. ## `api-v2` revision 복구 Hosting 전환 이후 `api-v2` 요청 검증이 실패하면 [`cloud-run-staging.md`](./cloud-run-staging.md#revision-복구)에 따라 이전 정상 revision으로 트래픽을 되돌립니다. 첫 revision이라 이전 정상 revision이 없으면 수정본을 배포합니다. `firebase.json`과 Hosting rewrite는 변경하지 않습니다. -복구 뒤 앞 절의 Hosting 요청을 다시 실행하고 Todo, WebPage, PushNotification과 Google·Apple·GitHub 인증 요청이 선택한 `api-v2` revision에 기록되는지 확인합니다. 알려지지 않은 나머지 `/api/**` 요청은 Functions `api`의 `404` 응답과 로그로 확인합니다. +복구 뒤 앞 절의 Hosting 요청을 다시 실행하고 Todo, PushNotification과 Google·Apple·GitHub 인증 요청이 선택한 `api-v2` revision에 기록되는지 확인합니다. 알려지지 않은 나머지 `/api/**` 요청은 Functions `api`의 `404` 응답과 로그로 확인합니다. 복구 과정에서는 Functions, Firestore, Secret과 Production 자원을 삭제하거나 변경하지 않습니다. 원인을 수정한 뒤에는 `api-v2` 직접 호출 검증 전체를 다시 통과하고 이 문서의 정상 전환 절차를 처음부터 수행합니다. diff --git a/firebase.json b/firebase.json index 807d066..454478c 100644 --- a/firebase.json +++ b/firebase.json @@ -37,13 +37,6 @@ "region": "asia-northeast3" } }, - { - "source": "/api/web-pages/**", - "run": { - "serviceId": "api-v2", - "region": "asia-northeast3" - } - }, { "source": "/api/push-notifications/**", "run": { diff --git a/firestore.index.json b/firestore.index.json index 92d80dc..fca02cc 100644 --- a/firestore.index.json +++ b/firestore.index.json @@ -748,28 +748,6 @@ } ] }, - { - "collectionGroup": "webPages", - "fieldPath": "isDeleted", - "indexes": [ - { - "order": "ASCENDING", - "queryScope": "COLLECTION" - }, - { - "order": "DESCENDING", - "queryScope": "COLLECTION" - }, - { - "order": "ASCENDING", - "queryScope": "COLLECTION_GROUP" - }, - { - "order": "DESCENDING", - "queryScope": "COLLECTION_GROUP" - } - ] - }, { "collectionGroup": "authChallenges", "fieldPath": "expiresAt", diff --git a/firestore.rules b/firestore.rules index 1925eb3..b446b16 100644 --- a/firestore.rules +++ b/firestore.rules @@ -13,11 +13,34 @@ service cloud.firestore { allow write: if request.auth != null && request.auth.uid == userId && userDataWriteAllowed(userId); - // 서브 컬렉션까지 모두 적용 - match /{document=**} { + // 개발 목표를 제외한 서브 컬렉션까지 모두 적용 + match /{collectionId}/{document=**} { + allow read: if collectionId != 'developmentGoals' && + request.auth != null && request.auth.uid == userId; + allow write, delete: if collectionId != 'developmentGoals' && + request.auth != null && request.auth.uid == userId && + userDataWriteAllowed(userId); + } + + // 개발 목표의 생성과 상태 전환 + match /developmentGoals/{goalId} { allow read: if request.auth != null && request.auth.uid == userId; - allow write, delete: if request.auth != null && request.auth.uid == userId && + allow create, update: if request.auth != null && request.auth.uid == userId && userDataWriteAllowed(userId); + + // 개발 기록의 생성과 초안, 현재 확정 버전 참조 갱신 + match /records/{recordId} { + allow read: if request.auth != null && request.auth.uid == userId; + allow create, update: if request.auth != null && request.auth.uid == userId && + userDataWriteAllowed(userId); + + // 확정 버전은 생성만 허용하고 갱신과 삭제는 항상 거부 + match /versions/{versionId} { + allow read: if request.auth != null && request.auth.uid == userId; + allow create: if request.auth != null && request.auth.uid == userId && + userDataWriteAllowed(userId); + } + } } } diff --git a/functions/package-lock.json b/functions/package-lock.json index 035b63e..3b4b3f6 100644 --- a/functions/package-lock.json +++ b/functions/package-lock.json @@ -14,7 +14,9 @@ "firebase-functions": "^7.2.2" }, "devDependencies": { + "@firebase/rules-unit-testing": "^5.0.2", "@types/node": "^25.5.0", + "firebase": "^12.19.0", "firebase-functions-test": "^3.1.0", "typescript": "^4.9.5" }, @@ -617,80 +619,1522 @@ "integrity": "sha512-5DGmA8FTdB2XbDeEwc/5ZXBl6UbBAyBOOLlPuBnZ/N1SwdH9Ii+cOX3tBROlDgcTXxjOYnLMVoKk9+FXAw0CJw==", "license": "MIT" }, + "node_modules/@firebase/ai": { + "version": "2.16.0", + "resolved": "https://registry.npmjs.org/@firebase/ai/-/ai-2.16.0.tgz", + "integrity": "sha512-WRVxl58B61Orwf7st7949ZIW2L4huV80Gpaum1z8v2eH+m2xaxWtC8mOjQyVAOirr6O/yf89cBjlPvoyBpBfTg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/app-check-interop-types": "0.3.5", + "@firebase/component": "0.7.5", + "@firebase/logger": "0.5.2", + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "@firebase/app": "0.x", + "@firebase/app-types": "0.x" + } + }, + "node_modules/@firebase/ai/node_modules/@firebase/app-check-interop-types": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/@firebase/app-check-interop-types/-/app-check-interop-types-0.3.5.tgz", + "integrity": "sha512-qId34pVZ2CXTmtu4ofW5leiI93DvnOvIcr/5GT7MZPw5WXAi6nZoU+g9cNRgl7K90UJSbK0cXxten4meYMPyZg==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/@firebase/ai/node_modules/@firebase/component": { + "version": "0.7.5", + "resolved": "https://registry.npmjs.org/@firebase/component/-/component-0.7.5.tgz", + "integrity": "sha512-vuFDcL91Q+2ZuBJkyOh86T4q0B4ffNTDjc/A38tybO56odQABxRTFLTIowCWqAKeIcgo37GowWMVgFF73gD8Qw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/ai/node_modules/@firebase/logger": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/@firebase/logger/-/logger-0.5.2.tgz", + "integrity": "sha512-J2VO4NFTc0xQFrxV1B/lm5balicm9cwuX2acR9Yn41fN8KgUeQFo+VJV222IqW2FPSXKDu9uo5WdQFWf9TPbYg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/ai/node_modules/@firebase/util": { + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/@firebase/util/-/util-1.15.3.tgz", + "integrity": "sha512-c/z/gaIlaaLZEuGbE6sLUuJ61tskg1JghvhcNQzW948ASBinbVBBRnZTC4b4yt4LaEtJQkYlyzqLHcutFwEIvA==", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/analytics": { + "version": "0.10.25", + "resolved": "https://registry.npmjs.org/@firebase/analytics/-/analytics-0.10.25.tgz", + "integrity": "sha512-oDagV3PHeNXBdxemksZCdj+GmUT19eCnTOcLdQePIIovFXlm3zWy3Gjeaokt9Nqx24kc4ljK8lU0XGcGmmKZ1A==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/component": "0.7.5", + "@firebase/installations": "0.6.24", + "@firebase/logger": "0.5.2", + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "peerDependencies": { + "@firebase/app": "0.x" + } + }, + "node_modules/@firebase/analytics-compat": { + "version": "0.2.31", + "resolved": "https://registry.npmjs.org/@firebase/analytics-compat/-/analytics-compat-0.2.31.tgz", + "integrity": "sha512-msTlG9REujk5rjtOHNLngiuPmvaWGQte8ugL4/F6ZCMb+92Ue7SgjSEpNxINkM8ZtTrbGS83j5SZkt0r+M1Tjw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/analytics": "0.10.25", + "@firebase/analytics-types": "0.8.5", + "@firebase/component": "0.7.5", + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "peerDependencies": { + "@firebase/app": "0.x", + "@firebase/app-compat": "0.x" + } + }, + "node_modules/@firebase/analytics-compat/node_modules/@firebase/component": { + "version": "0.7.5", + "resolved": "https://registry.npmjs.org/@firebase/component/-/component-0.7.5.tgz", + "integrity": "sha512-vuFDcL91Q+2ZuBJkyOh86T4q0B4ffNTDjc/A38tybO56odQABxRTFLTIowCWqAKeIcgo37GowWMVgFF73gD8Qw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/analytics-compat/node_modules/@firebase/util": { + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/@firebase/util/-/util-1.15.3.tgz", + "integrity": "sha512-c/z/gaIlaaLZEuGbE6sLUuJ61tskg1JghvhcNQzW948ASBinbVBBRnZTC4b4yt4LaEtJQkYlyzqLHcutFwEIvA==", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/analytics-types": { + "version": "0.8.5", + "resolved": "https://registry.npmjs.org/@firebase/analytics-types/-/analytics-types-0.8.5.tgz", + "integrity": "sha512-kdnooE7Bis2jEnsqcerRwn/UQpH5D3uvHpku7OdUM9TJN3omlu6iYtbyAQ6XkAJRgJtO0aNf9OOkW8J6D59oCA==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/@firebase/analytics/node_modules/@firebase/component": { + "version": "0.7.5", + "resolved": "https://registry.npmjs.org/@firebase/component/-/component-0.7.5.tgz", + "integrity": "sha512-vuFDcL91Q+2ZuBJkyOh86T4q0B4ffNTDjc/A38tybO56odQABxRTFLTIowCWqAKeIcgo37GowWMVgFF73gD8Qw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/analytics/node_modules/@firebase/logger": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/@firebase/logger/-/logger-0.5.2.tgz", + "integrity": "sha512-J2VO4NFTc0xQFrxV1B/lm5balicm9cwuX2acR9Yn41fN8KgUeQFo+VJV222IqW2FPSXKDu9uo5WdQFWf9TPbYg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/analytics/node_modules/@firebase/util": { + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/@firebase/util/-/util-1.15.3.tgz", + "integrity": "sha512-c/z/gaIlaaLZEuGbE6sLUuJ61tskg1JghvhcNQzW948ASBinbVBBRnZTC4b4yt4LaEtJQkYlyzqLHcutFwEIvA==", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/app": { + "version": "0.16.2", + "resolved": "https://registry.npmjs.org/@firebase/app/-/app-0.16.2.tgz", + "integrity": "sha512-fyCLPahl3r0Zb7Wzm+JLWcOOH3SaDgAyJzJ8EWIDiv51aNiv+2Pjbpa6myEuP7iXxjmJqrcbVm0GUF7h229T1Q==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/component": "0.7.5", + "@firebase/logger": "0.5.2", + "@firebase/util": "1.15.3", + "idb": "7.1.1", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/app-check": { + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/@firebase/app-check/-/app-check-0.13.1.tgz", + "integrity": "sha512-l8y3dmnhodXks/APAwx4tWqRl3tk8b9874KF1FJyKg1DIU+kMD0l52iz7S9/MW+eK8k6cjJg0G0iJ5KQAsQpow==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/component": "0.7.5", + "@firebase/logger": "0.5.2", + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "@firebase/app": "0.x" + } + }, + "node_modules/@firebase/app-check-compat": { + "version": "0.4.7", + "resolved": "https://registry.npmjs.org/@firebase/app-check-compat/-/app-check-compat-0.4.7.tgz", + "integrity": "sha512-fBb/xSMyIKv1nDmccfzz3IAGBzx/cQOxmZai66rJzifb1hMMkztf824Xx7LhpTUe7HNUbXwY90IvJ66fi8q6yg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/app-check": "0.13.1", + "@firebase/app-check-types": "0.5.5", + "@firebase/component": "0.7.5", + "@firebase/logger": "0.5.2", + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "@firebase/app": "0.x", + "@firebase/app-compat": "0.x" + } + }, + "node_modules/@firebase/app-check-compat/node_modules/@firebase/component": { + "version": "0.7.5", + "resolved": "https://registry.npmjs.org/@firebase/component/-/component-0.7.5.tgz", + "integrity": "sha512-vuFDcL91Q+2ZuBJkyOh86T4q0B4ffNTDjc/A38tybO56odQABxRTFLTIowCWqAKeIcgo37GowWMVgFF73gD8Qw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/app-check-compat/node_modules/@firebase/logger": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/@firebase/logger/-/logger-0.5.2.tgz", + "integrity": "sha512-J2VO4NFTc0xQFrxV1B/lm5balicm9cwuX2acR9Yn41fN8KgUeQFo+VJV222IqW2FPSXKDu9uo5WdQFWf9TPbYg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/app-check-compat/node_modules/@firebase/util": { + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/@firebase/util/-/util-1.15.3.tgz", + "integrity": "sha512-c/z/gaIlaaLZEuGbE6sLUuJ61tskg1JghvhcNQzW948ASBinbVBBRnZTC4b4yt4LaEtJQkYlyzqLHcutFwEIvA==", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, "node_modules/@firebase/app-check-interop-types": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/@firebase/app-check-interop-types/-/app-check-interop-types-0.3.2.tgz", "integrity": "sha512-LMs47Vinv2HBMZi49C09dJxp0QT5LwDzFaVGf/+ITHe3BlIhUiLNttkATSXplc89A2lAaeTqjgqVkiRfUGyQiQ==", "license": "Apache-2.0" }, - "node_modules/@firebase/app-types": { + "node_modules/@firebase/app-check-types": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/@firebase/app-check-types/-/app-check-types-0.5.5.tgz", + "integrity": "sha512-+DF4gzFrlwGFyky38o4T/YN/r51l70yCtJ2HTkwmRj8FCMwPjm4hLH4fQbj6BUvzkiFqliBkitFsRpf1/YZkWA==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/@firebase/app-check/node_modules/@firebase/component": { + "version": "0.7.5", + "resolved": "https://registry.npmjs.org/@firebase/component/-/component-0.7.5.tgz", + "integrity": "sha512-vuFDcL91Q+2ZuBJkyOh86T4q0B4ffNTDjc/A38tybO56odQABxRTFLTIowCWqAKeIcgo37GowWMVgFF73gD8Qw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/app-check/node_modules/@firebase/logger": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/@firebase/logger/-/logger-0.5.2.tgz", + "integrity": "sha512-J2VO4NFTc0xQFrxV1B/lm5balicm9cwuX2acR9Yn41fN8KgUeQFo+VJV222IqW2FPSXKDu9uo5WdQFWf9TPbYg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/app-check/node_modules/@firebase/util": { + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/@firebase/util/-/util-1.15.3.tgz", + "integrity": "sha512-c/z/gaIlaaLZEuGbE6sLUuJ61tskg1JghvhcNQzW948ASBinbVBBRnZTC4b4yt4LaEtJQkYlyzqLHcutFwEIvA==", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/app-compat": { + "version": "0.5.18", + "resolved": "https://registry.npmjs.org/@firebase/app-compat/-/app-compat-0.5.18.tgz", + "integrity": "sha512-77H57WuGEsgrv59HdtuhHG+eQdP8di6myz7O93yW6yTZlR/tLSmsCxCq5vHp6AWWDwSV0EVtKUvizXQiQZVBWA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/app": "0.16.2", + "@firebase/component": "0.7.5", + "@firebase/logger": "0.5.2", + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/app-compat/node_modules/@firebase/component": { + "version": "0.7.5", + "resolved": "https://registry.npmjs.org/@firebase/component/-/component-0.7.5.tgz", + "integrity": "sha512-vuFDcL91Q+2ZuBJkyOh86T4q0B4ffNTDjc/A38tybO56odQABxRTFLTIowCWqAKeIcgo37GowWMVgFF73gD8Qw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/app-compat/node_modules/@firebase/logger": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/@firebase/logger/-/logger-0.5.2.tgz", + "integrity": "sha512-J2VO4NFTc0xQFrxV1B/lm5balicm9cwuX2acR9Yn41fN8KgUeQFo+VJV222IqW2FPSXKDu9uo5WdQFWf9TPbYg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/app-compat/node_modules/@firebase/util": { + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/@firebase/util/-/util-1.15.3.tgz", + "integrity": "sha512-c/z/gaIlaaLZEuGbE6sLUuJ61tskg1JghvhcNQzW948ASBinbVBBRnZTC4b4yt4LaEtJQkYlyzqLHcutFwEIvA==", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/app-types": { + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/@firebase/app-types/-/app-types-0.9.2.tgz", + "integrity": "sha512-oMEZ1TDlBz479lmABwWsWjzHwheQKiAgnuKxE0pz0IXCVx7/rtlkx1fQ6GfgK24WCrxDKMplZrT50Kh04iMbXQ==", + "license": "Apache-2.0" + }, + "node_modules/@firebase/app/node_modules/@firebase/component": { + "version": "0.7.5", + "resolved": "https://registry.npmjs.org/@firebase/component/-/component-0.7.5.tgz", + "integrity": "sha512-vuFDcL91Q+2ZuBJkyOh86T4q0B4ffNTDjc/A38tybO56odQABxRTFLTIowCWqAKeIcgo37GowWMVgFF73gD8Qw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/app/node_modules/@firebase/logger": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/@firebase/logger/-/logger-0.5.2.tgz", + "integrity": "sha512-J2VO4NFTc0xQFrxV1B/lm5balicm9cwuX2acR9Yn41fN8KgUeQFo+VJV222IqW2FPSXKDu9uo5WdQFWf9TPbYg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/app/node_modules/@firebase/util": { + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/@firebase/util/-/util-1.15.3.tgz", + "integrity": "sha512-c/z/gaIlaaLZEuGbE6sLUuJ61tskg1JghvhcNQzW948ASBinbVBBRnZTC4b4yt4LaEtJQkYlyzqLHcutFwEIvA==", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/auth": { + "version": "1.13.6", + "resolved": "https://registry.npmjs.org/@firebase/auth/-/auth-1.13.6.tgz", + "integrity": "sha512-MKRLvF72HJ/irNn2fJR0Gv5FOZNtqv1IBeJHRwK8l8pZ/wi9vuUw8ecyCMvQDDNxfS6uW0MWACL5KC4Y8Pp+fA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/component": "0.7.5", + "@firebase/logger": "0.5.2", + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "@firebase/app": "0.x", + "@react-native-async-storage/async-storage": "^2.2.0 || ^3.0.0" + }, + "peerDependenciesMeta": { + "@react-native-async-storage/async-storage": { + "optional": true + } + } + }, + "node_modules/@firebase/auth-compat": { + "version": "0.6.11", + "resolved": "https://registry.npmjs.org/@firebase/auth-compat/-/auth-compat-0.6.11.tgz", + "integrity": "sha512-L+xp3DTJQrBV08Vt0UhcL/ofUOSjXom7JOJfbT6oas4o7gCrQnTYFKs8wfiuKLmHoo8BxMr5LdgjAs7o6aAsqQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/auth": "1.13.6", + "@firebase/auth-types": "0.13.2", + "@firebase/component": "0.7.5", + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "@firebase/app": "0.x", + "@firebase/app-compat": "0.x" + } + }, + "node_modules/@firebase/auth-compat/node_modules/@firebase/component": { + "version": "0.7.5", + "resolved": "https://registry.npmjs.org/@firebase/component/-/component-0.7.5.tgz", + "integrity": "sha512-vuFDcL91Q+2ZuBJkyOh86T4q0B4ffNTDjc/A38tybO56odQABxRTFLTIowCWqAKeIcgo37GowWMVgFF73gD8Qw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/auth-compat/node_modules/@firebase/util": { + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/@firebase/util/-/util-1.15.3.tgz", + "integrity": "sha512-c/z/gaIlaaLZEuGbE6sLUuJ61tskg1JghvhcNQzW948ASBinbVBBRnZTC4b4yt4LaEtJQkYlyzqLHcutFwEIvA==", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/auth-interop-types": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@firebase/auth-interop-types/-/auth-interop-types-0.2.3.tgz", + "integrity": "sha512-Fc9wuJGgxoxQeavybiuwgyi+0rssr76b+nHpj+eGhXFYAdudMWyfBHvFL/I5fEHniUM/UQdFzi9VXJK2iZF7FQ==", + "license": "Apache-2.0" + }, + "node_modules/@firebase/auth-types": { + "version": "0.13.2", + "resolved": "https://registry.npmjs.org/@firebase/auth-types/-/auth-types-0.13.2.tgz", + "integrity": "sha512-OU+miuoSxIWYN7GT291d2ylVJBL3k/OePo7/JDSoQtkFQoEiGBc4AHuMjj/seqFIsHrqnjrAfRCk4pfufoJolQ==", + "dev": true, + "license": "Apache-2.0", + "peerDependencies": { + "@firebase/app-types": "0.x", + "@firebase/util": "1.x" + } + }, + "node_modules/@firebase/auth/node_modules/@firebase/component": { + "version": "0.7.5", + "resolved": "https://registry.npmjs.org/@firebase/component/-/component-0.7.5.tgz", + "integrity": "sha512-vuFDcL91Q+2ZuBJkyOh86T4q0B4ffNTDjc/A38tybO56odQABxRTFLTIowCWqAKeIcgo37GowWMVgFF73gD8Qw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/auth/node_modules/@firebase/logger": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/@firebase/logger/-/logger-0.5.2.tgz", + "integrity": "sha512-J2VO4NFTc0xQFrxV1B/lm5balicm9cwuX2acR9Yn41fN8KgUeQFo+VJV222IqW2FPSXKDu9uo5WdQFWf9TPbYg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/auth/node_modules/@firebase/util": { + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/@firebase/util/-/util-1.15.3.tgz", + "integrity": "sha512-c/z/gaIlaaLZEuGbE6sLUuJ61tskg1JghvhcNQzW948ASBinbVBBRnZTC4b4yt4LaEtJQkYlyzqLHcutFwEIvA==", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/component": { + "version": "0.6.9", + "resolved": "https://registry.npmjs.org/@firebase/component/-/component-0.6.9.tgz", + "integrity": "sha512-gm8EUEJE/fEac86AvHn8Z/QW8BvR56TBw3hMW0O838J/1mThYQXAIQBgUv75EqlCZfdawpWLrKt1uXvp9ciK3Q==", + "license": "Apache-2.0", + "dependencies": { + "@firebase/util": "1.10.0", + "tslib": "^2.1.0" + } + }, + "node_modules/@firebase/data-connect": { + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/@firebase/data-connect/-/data-connect-0.7.4.tgz", + "integrity": "sha512-su1aGWlzhxb+xtggCUSsufJn1FDa06SBDK71y+fpQ+g2zMhMExik6FUv/odkKzOF/xfWVjabCbWBcjJY3MceDA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/auth-interop-types": "0.2.6", + "@firebase/component": "0.7.5", + "@firebase/logger": "0.5.2", + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "peerDependencies": { + "@firebase/app": "0.x" + } + }, + "node_modules/@firebase/data-connect/node_modules/@firebase/auth-interop-types": { + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/@firebase/auth-interop-types/-/auth-interop-types-0.2.6.tgz", + "integrity": "sha512-FgwZqDrBqgK0BHI70QTv1v/5wmuDF9f8fsJFvKSxoRlK2PPfSQtZAk2jhXu4pe9BZzFi/e4UYusU/bEQHdf6Qg==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/@firebase/data-connect/node_modules/@firebase/component": { + "version": "0.7.5", + "resolved": "https://registry.npmjs.org/@firebase/component/-/component-0.7.5.tgz", + "integrity": "sha512-vuFDcL91Q+2ZuBJkyOh86T4q0B4ffNTDjc/A38tybO56odQABxRTFLTIowCWqAKeIcgo37GowWMVgFF73gD8Qw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/data-connect/node_modules/@firebase/logger": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/@firebase/logger/-/logger-0.5.2.tgz", + "integrity": "sha512-J2VO4NFTc0xQFrxV1B/lm5balicm9cwuX2acR9Yn41fN8KgUeQFo+VJV222IqW2FPSXKDu9uo5WdQFWf9TPbYg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/data-connect/node_modules/@firebase/util": { + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/@firebase/util/-/util-1.15.3.tgz", + "integrity": "sha512-c/z/gaIlaaLZEuGbE6sLUuJ61tskg1JghvhcNQzW948ASBinbVBBRnZTC4b4yt4LaEtJQkYlyzqLHcutFwEIvA==", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/database": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@firebase/database/-/database-1.0.8.tgz", + "integrity": "sha512-dzXALZeBI1U5TXt6619cv0+tgEhJiwlUtQ55WNZY7vGAjv7Q1QioV969iYwt1AQQ0ovHnEW0YW9TiBfefLvErg==", + "license": "Apache-2.0", + "dependencies": { + "@firebase/app-check-interop-types": "0.3.2", + "@firebase/auth-interop-types": "0.2.3", + "@firebase/component": "0.6.9", + "@firebase/logger": "0.4.2", + "@firebase/util": "1.10.0", + "faye-websocket": "0.11.4", + "tslib": "^2.1.0" + } + }, + "node_modules/@firebase/database-compat": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@firebase/database-compat/-/database-compat-1.0.8.tgz", + "integrity": "sha512-OpeWZoPE3sGIRPBKYnW9wLad25RaWbGyk7fFQe4xnJQKRzlynWeFBSRRAoLE2Old01WXwskUiucNqUUVlFsceg==", + "license": "Apache-2.0", + "dependencies": { + "@firebase/component": "0.6.9", + "@firebase/database": "1.0.8", + "@firebase/database-types": "1.0.5", + "@firebase/logger": "0.4.2", + "@firebase/util": "1.10.0", + "tslib": "^2.1.0" + } + }, + "node_modules/@firebase/database-types": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@firebase/database-types/-/database-types-1.0.5.tgz", + "integrity": "sha512-fTlqCNwFYyq/C6W7AJ5OCuq5CeZuBEsEwptnVxlNPkWCo5cTTyukzAHRSO/jaQcItz33FfYrrFk1SJofcu2AaQ==", + "license": "Apache-2.0", + "dependencies": { + "@firebase/app-types": "0.9.2", + "@firebase/util": "1.10.0" + } + }, + "node_modules/@firebase/firestore": { + "version": "4.17.2", + "resolved": "https://registry.npmjs.org/@firebase/firestore/-/firestore-4.17.2.tgz", + "integrity": "sha512-SiyQEK1dYPOjItFVA+kZGdvOoRAtMebDBvUaSxJPNZMkKcRwYYK2kzWo5UXTZZj523uMxJnkr+KKVySEMme3kQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/component": "0.7.5", + "@firebase/logger": "0.5.2", + "@firebase/util": "1.15.3", + "@firebase/webchannel-wrapper": "1.0.7", + "@grpc/grpc-js": "~1.9.0", + "@grpc/proto-loader": "^0.7.8", + "re2js": "^2.8.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "@firebase/app": "0.x" + } + }, + "node_modules/@firebase/firestore-compat": { + "version": "0.4.14", + "resolved": "https://registry.npmjs.org/@firebase/firestore-compat/-/firestore-compat-0.4.14.tgz", + "integrity": "sha512-HJ2HBNgNPrRsWIJ4E+Kc0u0h1U7HlF7If8AtYjie9HZXlMUmwYSJaXBj9VFm6gkSj5dlKZNcOQ0Ou25CVVG6rA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/component": "0.7.5", + "@firebase/firestore": "4.17.2", + "@firebase/firestore-types": "3.0.5", + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "@firebase/app": "0.x", + "@firebase/app-compat": "0.x" + } + }, + "node_modules/@firebase/firestore-compat/node_modules/@firebase/component": { + "version": "0.7.5", + "resolved": "https://registry.npmjs.org/@firebase/component/-/component-0.7.5.tgz", + "integrity": "sha512-vuFDcL91Q+2ZuBJkyOh86T4q0B4ffNTDjc/A38tybO56odQABxRTFLTIowCWqAKeIcgo37GowWMVgFF73gD8Qw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/firestore-compat/node_modules/@firebase/util": { + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/@firebase/util/-/util-1.15.3.tgz", + "integrity": "sha512-c/z/gaIlaaLZEuGbE6sLUuJ61tskg1JghvhcNQzW948ASBinbVBBRnZTC4b4yt4LaEtJQkYlyzqLHcutFwEIvA==", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/firestore-types": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/@firebase/firestore-types/-/firestore-types-3.0.5.tgz", + "integrity": "sha512-dbdMAQkMd5dwWc48eupz/Y6/E9ruat3+gY5lhVKscvvT/HnDBEEMzJW38zdKhgdnglZHGk2vUsJMOHAphMHGMA==", + "dev": true, + "license": "Apache-2.0", + "peerDependencies": { + "@firebase/app-types": "0.x", + "@firebase/util": "1.x" + } + }, + "node_modules/@firebase/firestore/node_modules/@firebase/component": { + "version": "0.7.5", + "resolved": "https://registry.npmjs.org/@firebase/component/-/component-0.7.5.tgz", + "integrity": "sha512-vuFDcL91Q+2ZuBJkyOh86T4q0B4ffNTDjc/A38tybO56odQABxRTFLTIowCWqAKeIcgo37GowWMVgFF73gD8Qw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/firestore/node_modules/@firebase/logger": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/@firebase/logger/-/logger-0.5.2.tgz", + "integrity": "sha512-J2VO4NFTc0xQFrxV1B/lm5balicm9cwuX2acR9Yn41fN8KgUeQFo+VJV222IqW2FPSXKDu9uo5WdQFWf9TPbYg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/firestore/node_modules/@firebase/util": { + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/@firebase/util/-/util-1.15.3.tgz", + "integrity": "sha512-c/z/gaIlaaLZEuGbE6sLUuJ61tskg1JghvhcNQzW948ASBinbVBBRnZTC4b4yt4LaEtJQkYlyzqLHcutFwEIvA==", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/firestore/node_modules/@grpc/grpc-js": { + "version": "1.9.16", + "resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.9.16.tgz", + "integrity": "sha512-wE4Ut/olIzfKqp631XrG+wbF0v1vWFN4YL9FyXC2LJiG33DsV7PLzURjrCvY/6je2ntdRkeLpPDluzSRGaVltQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@grpc/proto-loader": "^0.7.8", + "@types/node": ">=12.12.47" + }, + "engines": { + "node": "^8.13.0 || >=10.10.0" + } + }, + "node_modules/@firebase/functions": { + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/@firebase/functions/-/functions-0.14.0.tgz", + "integrity": "sha512-DhuYFr0eMhp+s/PNEk6SiMsYkc00+XVOUeKbrl8MOzQNZI3SKQpqoDR1d+keNDAutwmHRWTUAdXBoVPD+xxVUw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/app-check-interop-types": "0.3.5", + "@firebase/auth-interop-types": "0.2.6", + "@firebase/component": "0.7.5", + "@firebase/messaging-interop-types": "0.2.6", + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "@firebase/app": "0.x" + } + }, + "node_modules/@firebase/functions-compat": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/@firebase/functions-compat/-/functions-compat-0.5.0.tgz", + "integrity": "sha512-T3BDIToESZUHt7438wyKYMkRjKg3m1xAIux5fVpNvTRQlDOFLukWniQWBDhJ2znpU9kxMTR6+e31TVo8P15PZw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/component": "0.7.5", + "@firebase/functions": "0.14.0", + "@firebase/functions-types": "0.6.5", + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "@firebase/app": "0.x", + "@firebase/app-compat": "0.x" + } + }, + "node_modules/@firebase/functions-compat/node_modules/@firebase/component": { + "version": "0.7.5", + "resolved": "https://registry.npmjs.org/@firebase/component/-/component-0.7.5.tgz", + "integrity": "sha512-vuFDcL91Q+2ZuBJkyOh86T4q0B4ffNTDjc/A38tybO56odQABxRTFLTIowCWqAKeIcgo37GowWMVgFF73gD8Qw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/functions-compat/node_modules/@firebase/util": { + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/@firebase/util/-/util-1.15.3.tgz", + "integrity": "sha512-c/z/gaIlaaLZEuGbE6sLUuJ61tskg1JghvhcNQzW948ASBinbVBBRnZTC4b4yt4LaEtJQkYlyzqLHcutFwEIvA==", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/functions-types": { + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/@firebase/functions-types/-/functions-types-0.6.5.tgz", + "integrity": "sha512-Zc0pURjthHXzSj54ZivCkzKDSV1r/wIpnmHdhq82q2yFFPVoncG/ZJjnVMiANvQfeww/QnElhzODpfwUucVwdA==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/@firebase/functions/node_modules/@firebase/app-check-interop-types": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/@firebase/app-check-interop-types/-/app-check-interop-types-0.3.5.tgz", + "integrity": "sha512-qId34pVZ2CXTmtu4ofW5leiI93DvnOvIcr/5GT7MZPw5WXAi6nZoU+g9cNRgl7K90UJSbK0cXxten4meYMPyZg==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/@firebase/functions/node_modules/@firebase/auth-interop-types": { + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/@firebase/auth-interop-types/-/auth-interop-types-0.2.6.tgz", + "integrity": "sha512-FgwZqDrBqgK0BHI70QTv1v/5wmuDF9f8fsJFvKSxoRlK2PPfSQtZAk2jhXu4pe9BZzFi/e4UYusU/bEQHdf6Qg==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/@firebase/functions/node_modules/@firebase/component": { + "version": "0.7.5", + "resolved": "https://registry.npmjs.org/@firebase/component/-/component-0.7.5.tgz", + "integrity": "sha512-vuFDcL91Q+2ZuBJkyOh86T4q0B4ffNTDjc/A38tybO56odQABxRTFLTIowCWqAKeIcgo37GowWMVgFF73gD8Qw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/functions/node_modules/@firebase/util": { + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/@firebase/util/-/util-1.15.3.tgz", + "integrity": "sha512-c/z/gaIlaaLZEuGbE6sLUuJ61tskg1JghvhcNQzW948ASBinbVBBRnZTC4b4yt4LaEtJQkYlyzqLHcutFwEIvA==", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/installations": { + "version": "0.6.24", + "resolved": "https://registry.npmjs.org/@firebase/installations/-/installations-0.6.24.tgz", + "integrity": "sha512-Ui52ey8wHoWqkBbXRKJEKYWylI0JZogZmoLS+o8Anh1bxWtK27ZYjLla1UJAAdC5DCKLJ2qAp0VpJOjg8VOX1g==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/component": "0.7.5", + "@firebase/util": "1.15.3", + "idb": "7.1.1", + "tslib": "^2.1.0" + }, + "peerDependencies": { + "@firebase/app": "0.x" + } + }, + "node_modules/@firebase/installations-compat": { + "version": "0.2.24", + "resolved": "https://registry.npmjs.org/@firebase/installations-compat/-/installations-compat-0.2.24.tgz", + "integrity": "sha512-8M5nlcWwYt881x83COP2odq5vgf+NgwJh+RMd4LRSv8JI1pxwDfgrDJOERrjTgfC9J5Z0vnQX4b1pdN914e0Zw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/component": "0.7.5", + "@firebase/installations": "0.6.24", + "@firebase/installations-types": "0.5.5", + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "peerDependencies": { + "@firebase/app": "0.x", + "@firebase/app-compat": "0.x" + } + }, + "node_modules/@firebase/installations-compat/node_modules/@firebase/component": { + "version": "0.7.5", + "resolved": "https://registry.npmjs.org/@firebase/component/-/component-0.7.5.tgz", + "integrity": "sha512-vuFDcL91Q+2ZuBJkyOh86T4q0B4ffNTDjc/A38tybO56odQABxRTFLTIowCWqAKeIcgo37GowWMVgFF73gD8Qw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/installations-compat/node_modules/@firebase/util": { + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/@firebase/util/-/util-1.15.3.tgz", + "integrity": "sha512-c/z/gaIlaaLZEuGbE6sLUuJ61tskg1JghvhcNQzW948ASBinbVBBRnZTC4b4yt4LaEtJQkYlyzqLHcutFwEIvA==", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/installations-types": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/@firebase/installations-types/-/installations-types-0.5.5.tgz", + "integrity": "sha512-e9UYcju3puDl1vdrcKIi5dExzHLameOT/Tc61Q48PYwxtsM1NzZh/ikGbdBQTsbRgg0EMZqdPr0/m5ODUBobrg==", + "dev": true, + "license": "Apache-2.0", + "peerDependencies": { + "@firebase/app-types": "0.x" + } + }, + "node_modules/@firebase/installations/node_modules/@firebase/component": { + "version": "0.7.5", + "resolved": "https://registry.npmjs.org/@firebase/component/-/component-0.7.5.tgz", + "integrity": "sha512-vuFDcL91Q+2ZuBJkyOh86T4q0B4ffNTDjc/A38tybO56odQABxRTFLTIowCWqAKeIcgo37GowWMVgFF73gD8Qw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/installations/node_modules/@firebase/util": { + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/@firebase/util/-/util-1.15.3.tgz", + "integrity": "sha512-c/z/gaIlaaLZEuGbE6sLUuJ61tskg1JghvhcNQzW948ASBinbVBBRnZTC4b4yt4LaEtJQkYlyzqLHcutFwEIvA==", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/logger": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/@firebase/logger/-/logger-0.4.2.tgz", + "integrity": "sha512-Q1VuA5M1Gjqrwom6I6NUU4lQXdo9IAQieXlujeHZWvRt1b7qQ0KwBaNAjgxG27jgF9/mUwsNmO8ptBCGVYhB0A==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + } + }, + "node_modules/@firebase/messaging": { + "version": "0.13.3", + "resolved": "https://registry.npmjs.org/@firebase/messaging/-/messaging-0.13.3.tgz", + "integrity": "sha512-nRXPAp+z0kA3KziJtRY9kktHECvRwaaONzHvislFgllhCwJMscW7icWNQA5IjyP8Uc2+GS/4px8Uz6rx6ftTag==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/component": "0.7.5", + "@firebase/installations": "0.6.24", + "@firebase/messaging-interop-types": "0.2.6", + "@firebase/util": "1.15.3", + "idb": "7.1.1", + "tslib": "^2.1.0" + }, + "peerDependencies": { + "@firebase/app": "0.x" + } + }, + "node_modules/@firebase/messaging-compat": { + "version": "0.2.30", + "resolved": "https://registry.npmjs.org/@firebase/messaging-compat/-/messaging-compat-0.2.30.tgz", + "integrity": "sha512-m1DPT2ET5x0qYqXLoHwKMAyf1mgZZOhuoE6H6/H4OPsp8zSxMIDEFPaW7MaffPJsCA5J7kHzo+BHVNXK4ZoV+w==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/component": "0.7.5", + "@firebase/messaging": "0.13.3", + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "peerDependencies": { + "@firebase/app": "0.x", + "@firebase/app-compat": "0.x" + } + }, + "node_modules/@firebase/messaging-compat/node_modules/@firebase/component": { + "version": "0.7.5", + "resolved": "https://registry.npmjs.org/@firebase/component/-/component-0.7.5.tgz", + "integrity": "sha512-vuFDcL91Q+2ZuBJkyOh86T4q0B4ffNTDjc/A38tybO56odQABxRTFLTIowCWqAKeIcgo37GowWMVgFF73gD8Qw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/messaging-compat/node_modules/@firebase/util": { + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/@firebase/util/-/util-1.15.3.tgz", + "integrity": "sha512-c/z/gaIlaaLZEuGbE6sLUuJ61tskg1JghvhcNQzW948ASBinbVBBRnZTC4b4yt4LaEtJQkYlyzqLHcutFwEIvA==", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/messaging-interop-types": { + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/@firebase/messaging-interop-types/-/messaging-interop-types-0.2.6.tgz", + "integrity": "sha512-MVzvkKe2V4H2dHu5oOxRfeKQcfTwWmCgnzsC4V1q3ixun5iiL8riCZ2qI35rDhCL4glPGiu0jHxDbpVNuTKfow==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/@firebase/messaging/node_modules/@firebase/component": { + "version": "0.7.5", + "resolved": "https://registry.npmjs.org/@firebase/component/-/component-0.7.5.tgz", + "integrity": "sha512-vuFDcL91Q+2ZuBJkyOh86T4q0B4ffNTDjc/A38tybO56odQABxRTFLTIowCWqAKeIcgo37GowWMVgFF73gD8Qw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/messaging/node_modules/@firebase/util": { + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/@firebase/util/-/util-1.15.3.tgz", + "integrity": "sha512-c/z/gaIlaaLZEuGbE6sLUuJ61tskg1JghvhcNQzW948ASBinbVBBRnZTC4b4yt4LaEtJQkYlyzqLHcutFwEIvA==", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/performance": { + "version": "0.7.14", + "resolved": "https://registry.npmjs.org/@firebase/performance/-/performance-0.7.14.tgz", + "integrity": "sha512-9PH1XEZVHErxGdbXluvGz4Uyjw4W955H8v7Mv9rHIybRrg5F2Ac2tvf5+mSf5EtnxWNmxrD2WLnvMFaZP4sMrQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/component": "0.7.5", + "@firebase/installations": "0.6.24", + "@firebase/logger": "0.5.2", + "@firebase/util": "1.15.3", + "tslib": "^2.1.0", + "web-vitals": "^4.2.4" + }, + "peerDependencies": { + "@firebase/app": "0.x" + } + }, + "node_modules/@firebase/performance-compat": { + "version": "0.2.27", + "resolved": "https://registry.npmjs.org/@firebase/performance-compat/-/performance-compat-0.2.27.tgz", + "integrity": "sha512-O/ozTf/EbChN94Pk7bd1eUC0PAC36726AwsaiJyC0bZzSBWfLGSWASGPH5pebUWXQPJtGxIJYRkkbX5l0Qa+Hw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/component": "0.7.5", + "@firebase/logger": "0.5.2", + "@firebase/performance": "0.7.14", + "@firebase/performance-types": "0.2.5", + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "peerDependencies": { + "@firebase/app": "0.x", + "@firebase/app-compat": "0.x" + } + }, + "node_modules/@firebase/performance-compat/node_modules/@firebase/component": { + "version": "0.7.5", + "resolved": "https://registry.npmjs.org/@firebase/component/-/component-0.7.5.tgz", + "integrity": "sha512-vuFDcL91Q+2ZuBJkyOh86T4q0B4ffNTDjc/A38tybO56odQABxRTFLTIowCWqAKeIcgo37GowWMVgFF73gD8Qw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/performance-compat/node_modules/@firebase/logger": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/@firebase/logger/-/logger-0.5.2.tgz", + "integrity": "sha512-J2VO4NFTc0xQFrxV1B/lm5balicm9cwuX2acR9Yn41fN8KgUeQFo+VJV222IqW2FPSXKDu9uo5WdQFWf9TPbYg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/performance-compat/node_modules/@firebase/util": { + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/@firebase/util/-/util-1.15.3.tgz", + "integrity": "sha512-c/z/gaIlaaLZEuGbE6sLUuJ61tskg1JghvhcNQzW948ASBinbVBBRnZTC4b4yt4LaEtJQkYlyzqLHcutFwEIvA==", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/performance-types": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/@firebase/performance-types/-/performance-types-0.2.5.tgz", + "integrity": "sha512-PRzOgB+/M+6AKlEkY8a9xy5Ff5SfZPIh4iShXhn2WAcL/euSbK7bdLqWysHduunNJhGFsXa22Ag3ixqL6rQtYg==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/@firebase/performance/node_modules/@firebase/component": { + "version": "0.7.5", + "resolved": "https://registry.npmjs.org/@firebase/component/-/component-0.7.5.tgz", + "integrity": "sha512-vuFDcL91Q+2ZuBJkyOh86T4q0B4ffNTDjc/A38tybO56odQABxRTFLTIowCWqAKeIcgo37GowWMVgFF73gD8Qw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/performance/node_modules/@firebase/logger": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/@firebase/logger/-/logger-0.5.2.tgz", + "integrity": "sha512-J2VO4NFTc0xQFrxV1B/lm5balicm9cwuX2acR9Yn41fN8KgUeQFo+VJV222IqW2FPSXKDu9uo5WdQFWf9TPbYg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/performance/node_modules/@firebase/util": { + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/@firebase/util/-/util-1.15.3.tgz", + "integrity": "sha512-c/z/gaIlaaLZEuGbE6sLUuJ61tskg1JghvhcNQzW948ASBinbVBBRnZTC4b4yt4LaEtJQkYlyzqLHcutFwEIvA==", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/remote-config": { "version": "0.9.2", - "resolved": "https://registry.npmjs.org/@firebase/app-types/-/app-types-0.9.2.tgz", - "integrity": "sha512-oMEZ1TDlBz479lmABwWsWjzHwheQKiAgnuKxE0pz0IXCVx7/rtlkx1fQ6GfgK24WCrxDKMplZrT50Kh04iMbXQ==", - "license": "Apache-2.0" + "resolved": "https://registry.npmjs.org/@firebase/remote-config/-/remote-config-0.9.2.tgz", + "integrity": "sha512-Rii93DkXjM+RE/ytHdYa7EIiQLJbdBr+W8EEiqd/vbLCOC+1FdkDuRiumJBp6t3yewHGbdqbpjB3fk3z0cZ+8g==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/component": "0.7.5", + "@firebase/installations": "0.6.24", + "@firebase/logger": "0.5.2", + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "peerDependencies": { + "@firebase/app": "0.x" + } }, - "node_modules/@firebase/auth-interop-types": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/@firebase/auth-interop-types/-/auth-interop-types-0.2.3.tgz", - "integrity": "sha512-Fc9wuJGgxoxQeavybiuwgyi+0rssr76b+nHpj+eGhXFYAdudMWyfBHvFL/I5fEHniUM/UQdFzi9VXJK2iZF7FQ==", + "node_modules/@firebase/remote-config-compat": { + "version": "0.2.29", + "resolved": "https://registry.npmjs.org/@firebase/remote-config-compat/-/remote-config-compat-0.2.29.tgz", + "integrity": "sha512-mY7JtTISK6F4g4T0x3kVepr5cp0NXL7f5yjIUXXGaTrg4qUlFBWRbENaHaqZ78dwmNcLm24h/yPsOVRlDXEXhA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/component": "0.7.5", + "@firebase/logger": "0.5.2", + "@firebase/remote-config": "0.9.2", + "@firebase/remote-config-types": "0.5.2", + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "peerDependencies": { + "@firebase/app": "0.x", + "@firebase/app-compat": "0.x" + } + }, + "node_modules/@firebase/remote-config-compat/node_modules/@firebase/component": { + "version": "0.7.5", + "resolved": "https://registry.npmjs.org/@firebase/component/-/component-0.7.5.tgz", + "integrity": "sha512-vuFDcL91Q+2ZuBJkyOh86T4q0B4ffNTDjc/A38tybO56odQABxRTFLTIowCWqAKeIcgo37GowWMVgFF73gD8Qw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/remote-config-compat/node_modules/@firebase/logger": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/@firebase/logger/-/logger-0.5.2.tgz", + "integrity": "sha512-J2VO4NFTc0xQFrxV1B/lm5balicm9cwuX2acR9Yn41fN8KgUeQFo+VJV222IqW2FPSXKDu9uo5WdQFWf9TPbYg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/remote-config-compat/node_modules/@firebase/util": { + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/@firebase/util/-/util-1.15.3.tgz", + "integrity": "sha512-c/z/gaIlaaLZEuGbE6sLUuJ61tskg1JghvhcNQzW948ASBinbVBBRnZTC4b4yt4LaEtJQkYlyzqLHcutFwEIvA==", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/remote-config-types": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/@firebase/remote-config-types/-/remote-config-types-0.5.2.tgz", + "integrity": "sha512-i8k1omVfoAnaT1ZPv2FFjxMZrATYsO/GnFgHEj5+7fAJLzi8wLnGGv1WK06oEAD6ltrWXSO1HzeNyajn/NjMWw==", + "dev": true, "license": "Apache-2.0" }, - "node_modules/@firebase/component": { - "version": "0.6.9", - "resolved": "https://registry.npmjs.org/@firebase/component/-/component-0.6.9.tgz", - "integrity": "sha512-gm8EUEJE/fEac86AvHn8Z/QW8BvR56TBw3hMW0O838J/1mThYQXAIQBgUv75EqlCZfdawpWLrKt1uXvp9ciK3Q==", + "node_modules/@firebase/remote-config/node_modules/@firebase/component": { + "version": "0.7.5", + "resolved": "https://registry.npmjs.org/@firebase/component/-/component-0.7.5.tgz", + "integrity": "sha512-vuFDcL91Q+2ZuBJkyOh86T4q0B4ffNTDjc/A38tybO56odQABxRTFLTIowCWqAKeIcgo37GowWMVgFF73gD8Qw==", + "dev": true, "license": "Apache-2.0", "dependencies": { - "@firebase/util": "1.10.0", + "@firebase/util": "1.15.3", "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" } }, - "node_modules/@firebase/database": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/@firebase/database/-/database-1.0.8.tgz", - "integrity": "sha512-dzXALZeBI1U5TXt6619cv0+tgEhJiwlUtQ55WNZY7vGAjv7Q1QioV969iYwt1AQQ0ovHnEW0YW9TiBfefLvErg==", + "node_modules/@firebase/remote-config/node_modules/@firebase/logger": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/@firebase/logger/-/logger-0.5.2.tgz", + "integrity": "sha512-J2VO4NFTc0xQFrxV1B/lm5balicm9cwuX2acR9Yn41fN8KgUeQFo+VJV222IqW2FPSXKDu9uo5WdQFWf9TPbYg==", + "dev": true, "license": "Apache-2.0", "dependencies": { - "@firebase/app-check-interop-types": "0.3.2", - "@firebase/auth-interop-types": "0.2.3", - "@firebase/component": "0.6.9", - "@firebase/logger": "0.4.2", - "@firebase/util": "1.10.0", - "faye-websocket": "0.11.4", "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" } }, - "node_modules/@firebase/database-compat": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/@firebase/database-compat/-/database-compat-1.0.8.tgz", - "integrity": "sha512-OpeWZoPE3sGIRPBKYnW9wLad25RaWbGyk7fFQe4xnJQKRzlynWeFBSRRAoLE2Old01WXwskUiucNqUUVlFsceg==", + "node_modules/@firebase/remote-config/node_modules/@firebase/util": { + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/@firebase/util/-/util-1.15.3.tgz", + "integrity": "sha512-c/z/gaIlaaLZEuGbE6sLUuJ61tskg1JghvhcNQzW948ASBinbVBBRnZTC4b4yt4LaEtJQkYlyzqLHcutFwEIvA==", + "dev": true, + "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { - "@firebase/component": "0.6.9", - "@firebase/database": "1.0.8", - "@firebase/database-types": "1.0.5", - "@firebase/logger": "0.4.2", - "@firebase/util": "1.10.0", "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" } }, - "node_modules/@firebase/database-types": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/@firebase/database-types/-/database-types-1.0.5.tgz", - "integrity": "sha512-fTlqCNwFYyq/C6W7AJ5OCuq5CeZuBEsEwptnVxlNPkWCo5cTTyukzAHRSO/jaQcItz33FfYrrFk1SJofcu2AaQ==", + "node_modules/@firebase/rules-unit-testing": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@firebase/rules-unit-testing/-/rules-unit-testing-5.0.2.tgz", + "integrity": "sha512-g053AaFcuf4gpAQbwRK/GIIGfPHhpomW3qkIYLi4xnaTUrf65yGP+0TPdojoXfB/ejrfevkXmMs5qXOTSwdN6A==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "firebase": "^12.0.0" + } + }, + "node_modules/@firebase/storage": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/@firebase/storage/-/storage-0.14.5.tgz", + "integrity": "sha512-r2tozN/BlEewLi70tJNUQPzWwbex9GM7NgXZsamHKQrjKEfcR0i4jGgHBKAKA4hbwiPE9eNMb3hcxWnDpeJZwg==", + "dev": true, "license": "Apache-2.0", "dependencies": { - "@firebase/app-types": "0.9.2", - "@firebase/util": "1.10.0" + "@firebase/component": "0.7.5", + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "@firebase/app": "0.x" } }, - "node_modules/@firebase/logger": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/@firebase/logger/-/logger-0.4.2.tgz", - "integrity": "sha512-Q1VuA5M1Gjqrwom6I6NUU4lQXdo9IAQieXlujeHZWvRt1b7qQ0KwBaNAjgxG27jgF9/mUwsNmO8ptBCGVYhB0A==", + "node_modules/@firebase/storage-compat": { + "version": "0.4.5", + "resolved": "https://registry.npmjs.org/@firebase/storage-compat/-/storage-compat-0.4.5.tgz", + "integrity": "sha512-vO0tFPxXbKDKdlTu8tYT08S9t9ezUTJYEdLCULpWxWq2aq6zojwN1QmAB+1a50AI/g47GlWUJn1XPncm/PDZsw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/component": "0.7.5", + "@firebase/storage": "0.14.5", + "@firebase/storage-types": "0.8.5", + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "@firebase/app": "0.x", + "@firebase/app-compat": "0.x" + } + }, + "node_modules/@firebase/storage-compat/node_modules/@firebase/component": { + "version": "0.7.5", + "resolved": "https://registry.npmjs.org/@firebase/component/-/component-0.7.5.tgz", + "integrity": "sha512-vuFDcL91Q+2ZuBJkyOh86T4q0B4ffNTDjc/A38tybO56odQABxRTFLTIowCWqAKeIcgo37GowWMVgFF73gD8Qw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/storage-compat/node_modules/@firebase/util": { + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/@firebase/util/-/util-1.15.3.tgz", + "integrity": "sha512-c/z/gaIlaaLZEuGbE6sLUuJ61tskg1JghvhcNQzW948ASBinbVBBRnZTC4b4yt4LaEtJQkYlyzqLHcutFwEIvA==", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/storage-types": { + "version": "0.8.5", + "resolved": "https://registry.npmjs.org/@firebase/storage-types/-/storage-types-0.8.5.tgz", + "integrity": "sha512-GEDs5P+rNUfNcS+wxIdOLAHficife2YXtvTJnyi3ssrX11AAtBg+nDUdbYh8vuBzWehVQZPmztGUUnud4L+4yg==", + "dev": true, + "license": "Apache-2.0", + "peerDependencies": { + "@firebase/app-types": "0.x", + "@firebase/util": "1.x" + } + }, + "node_modules/@firebase/storage/node_modules/@firebase/component": { + "version": "0.7.5", + "resolved": "https://registry.npmjs.org/@firebase/component/-/component-0.7.5.tgz", + "integrity": "sha512-vuFDcL91Q+2ZuBJkyOh86T4q0B4ffNTDjc/A38tybO56odQABxRTFLTIowCWqAKeIcgo37GowWMVgFF73gD8Qw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@firebase/storage/node_modules/@firebase/util": { + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/@firebase/util/-/util-1.15.3.tgz", + "integrity": "sha512-c/z/gaIlaaLZEuGbE6sLUuJ61tskg1JghvhcNQzW948ASBinbVBBRnZTC4b4yt4LaEtJQkYlyzqLHcutFwEIvA==", + "dev": true, + "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" } }, "node_modules/@firebase/util": { @@ -702,6 +2146,13 @@ "tslib": "^2.1.0" } }, + "node_modules/@firebase/webchannel-wrapper": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/@firebase/webchannel-wrapper/-/webchannel-wrapper-1.0.7.tgz", + "integrity": "sha512-phBFwieDLvkZGYN9CE9ZFNEIoBVksprzsnCzQejCmCHtgwCXReeuRpoEGN9C4EbhONztv8NRV1tau6Rb9pONwQ==", + "dev": true, + "license": "Apache-2.0" + }, "node_modules/@google-cloud/bigquery": { "version": "9.5.0", "resolved": "https://registry.npmjs.org/@google-cloud/bigquery/-/bigquery-9.5.0.tgz", @@ -3791,6 +5242,43 @@ "node": ">=8" } }, + "node_modules/firebase": { + "version": "12.19.0", + "resolved": "https://registry.npmjs.org/firebase/-/firebase-12.19.0.tgz", + "integrity": "sha512-kwXCLcI0ly2lkwygkbuRx6SsX3DSO96355YrWh9SWZ5ncsxK/y5cirn3sY6nZVSiBVE++2nL6Hchzu1EB8uohQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/ai": "2.16.0", + "@firebase/analytics": "0.10.25", + "@firebase/analytics-compat": "0.2.31", + "@firebase/app": "0.16.2", + "@firebase/app-check": "0.13.1", + "@firebase/app-check-compat": "0.4.7", + "@firebase/app-compat": "0.5.18", + "@firebase/app-types": "0.9.6", + "@firebase/auth": "1.13.6", + "@firebase/auth-compat": "0.6.11", + "@firebase/data-connect": "0.7.4", + "@firebase/database": "1.1.5", + "@firebase/database-compat": "2.1.7", + "@firebase/firestore": "4.17.2", + "@firebase/firestore-compat": "0.4.14", + "@firebase/functions": "0.14.0", + "@firebase/functions-compat": "0.5.0", + "@firebase/installations": "0.6.24", + "@firebase/installations-compat": "0.2.24", + "@firebase/messaging": "0.13.3", + "@firebase/messaging-compat": "0.2.30", + "@firebase/performance": "0.7.14", + "@firebase/performance-compat": "0.2.27", + "@firebase/remote-config": "0.9.2", + "@firebase/remote-config-compat": "0.2.29", + "@firebase/storage": "0.14.5", + "@firebase/storage-compat": "0.4.5", + "@firebase/util": "1.15.3" + } + }, "node_modules/firebase-admin": { "version": "12.7.0", "resolved": "https://registry.npmjs.org/firebase-admin/-/firebase-admin-12.7.0.tgz", @@ -3886,6 +5374,131 @@ "jest": ">=28.0.0" } }, + "node_modules/firebase/node_modules/@firebase/app-check-interop-types": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/@firebase/app-check-interop-types/-/app-check-interop-types-0.3.5.tgz", + "integrity": "sha512-qId34pVZ2CXTmtu4ofW5leiI93DvnOvIcr/5GT7MZPw5WXAi6nZoU+g9cNRgl7K90UJSbK0cXxten4meYMPyZg==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/firebase/node_modules/@firebase/app-types": { + "version": "0.9.6", + "resolved": "https://registry.npmjs.org/@firebase/app-types/-/app-types-0.9.6.tgz", + "integrity": "sha512-yPLahy7Esfu2w/yme3msVK4xTkDXQqq6szfQn8yVOQpCKiT5GVFjqNpLbuz6NkX0WuTwUidkmPewW3r4xkvpeg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/logger": "0.5.2" + } + }, + "node_modules/firebase/node_modules/@firebase/auth-interop-types": { + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/@firebase/auth-interop-types/-/auth-interop-types-0.2.6.tgz", + "integrity": "sha512-FgwZqDrBqgK0BHI70QTv1v/5wmuDF9f8fsJFvKSxoRlK2PPfSQtZAk2jhXu4pe9BZzFi/e4UYusU/bEQHdf6Qg==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/firebase/node_modules/@firebase/component": { + "version": "0.7.5", + "resolved": "https://registry.npmjs.org/@firebase/component/-/component-0.7.5.tgz", + "integrity": "sha512-vuFDcL91Q+2ZuBJkyOh86T4q0B4ffNTDjc/A38tybO56odQABxRTFLTIowCWqAKeIcgo37GowWMVgFF73gD8Qw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/firebase/node_modules/@firebase/database": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@firebase/database/-/database-1.1.5.tgz", + "integrity": "sha512-/JGpvszLoNXNgzilRXocigGfFF4hbcPA9wN1i1kjJx6oKkXgkHteZYl3lQs1lJX3ETDf6bv7zI15lPMVUp4sAQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/app-check-interop-types": "0.3.5", + "@firebase/auth-interop-types": "0.2.6", + "@firebase/component": "0.7.5", + "@firebase/logger": "0.5.2", + "@firebase/util": "1.15.3", + "faye-websocket": "0.11.4", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/firebase/node_modules/@firebase/database-compat": { + "version": "2.1.7", + "resolved": "https://registry.npmjs.org/@firebase/database-compat/-/database-compat-2.1.7.tgz", + "integrity": "sha512-lBq9sJm8MnJINKJnkAKSOj2MbC66xGoSVCcGkPtstl+lkoKEBtD46qHLbuDgW/WbLPoKVm17RIN8BxHj+Z2F2w==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/component": "0.7.5", + "@firebase/database": "1.1.5", + "@firebase/database-types": "1.0.22", + "@firebase/logger": "0.5.2", + "@firebase/util": "1.15.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "@firebase/app": "0.x", + "@firebase/app-compat": "0.x" + }, + "peerDependenciesMeta": { + "@firebase/app": { + "optional": true + }, + "@firebase/app-compat": { + "optional": true + } + } + }, + "node_modules/firebase/node_modules/@firebase/database-types": { + "version": "1.0.22", + "resolved": "https://registry.npmjs.org/@firebase/database-types/-/database-types-1.0.22.tgz", + "integrity": "sha512-YAZNXsjY9EQQ+pKw/3ax8n5FgolHC7Qew7EY5RceYdl0R2ZP+kCv1O0DkKlcceue8uQCOreHCNN7PWVFpY1Nug==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@firebase/app-types": "0.9.6", + "@firebase/util": "1.15.3" + } + }, + "node_modules/firebase/node_modules/@firebase/logger": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/@firebase/logger/-/logger-0.5.2.tgz", + "integrity": "sha512-J2VO4NFTc0xQFrxV1B/lm5balicm9cwuX2acR9Yn41fN8KgUeQFo+VJV222IqW2FPSXKDu9uo5WdQFWf9TPbYg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/firebase/node_modules/@firebase/util": { + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/@firebase/util/-/util-1.15.3.tgz", + "integrity": "sha512-c/z/gaIlaaLZEuGbE6sLUuJ61tskg1JghvhcNQzW948ASBinbVBBRnZTC4b4yt4LaEtJQkYlyzqLHcutFwEIvA==", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, "node_modules/flatbuffers": { "version": "25.9.23", "resolved": "https://registry.npmjs.org/flatbuffers/-/flatbuffers-25.9.23.tgz", @@ -4464,6 +6077,13 @@ "node": ">=0.10.0" } }, + "node_modules/idb": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/idb/-/idb-7.1.1.tgz", + "integrity": "sha512-gchesWBzyvGHRO9W8tzUWFDycow5gwjvFKfyV9FF32Y7F50yZMp7mP+T2mJIWFx49zicqyC4uefHM17o6xKIVQ==", + "dev": true, + "license": "ISC" + }, "node_modules/import-local": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.2.0.tgz", @@ -6392,6 +8012,16 @@ "node": ">= 0.8" } }, + "node_modules/re2js": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/re2js/-/re2js-2.10.0.tgz", + "integrity": "sha512-/P6FNnLbHjXJMRF1dPoZoVTyHvFcuVhbDpzml9DPMlbeErYlZ18GueAaG9GhYhAm/9AN7i7Y6crmDrLX0DeJ4Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20.0.0" + } + }, "node_modules/react-is": { "version": "18.3.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.3.1.tgz", @@ -7263,6 +8893,13 @@ "node": ">= 8" } }, + "node_modules/web-vitals": { + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/web-vitals/-/web-vitals-4.2.4.tgz", + "integrity": "sha512-r4DIlprAGwJ7YM11VZp4R884m0Vmgr6EAKe3P+kO0PPj3Unqyvv59rczf6UiGcb9Z8QxZVcqKNwv/g0WNdWwsw==", + "dev": true, + "license": "Apache-2.0" + }, "node_modules/webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", diff --git a/functions/package.json b/functions/package.json index 97bc0cc..7f4bcac 100644 --- a/functions/package.json +++ b/functions/package.json @@ -5,6 +5,7 @@ "build:watch": "tsc --watch", "test": "npm run build && npm run test:run", "test:run": "node test/firebase-hosting.test.js && node test/rest-router.test.js && node test/rest-api.test.js && node test/function-secrets.test.js && node test/firestore-rules.test.js && node test/oauth-session.test.js && node test/oauth-cleanup.test.js && node test/github-auth.test.js && node test/github-configuration.test.js && node test/github-credential.test.js && node test/google-client.test.js && node test/google-credential.test.js && node test/todo-category-update.test.js && node test/scheduled-cleanup.test.js && node test/todo-reminder-schedule.test.js && node test/push-notification.test.js && node test/user-delete.test.js && node test/incident-risk.test.js && node test/incident-discord.test.js && node test/incident-mask.test.js && node test/incident-analyze.test.js && node test/incident-classify.test.js && node test/incident-code.test.js && node test/incident-context.test.js && node test/incident-github.test.js && node test/incident-daily.test.js", + "test:rules": "firebase emulators:exec --config ../firebase.test.json --project demo-devlog --only firestore \"node test/firestore-rules.emulator.test.js\"", "serve": "npm run build && firebase emulators:start --only functions", "shell": "npm run build && firebase functions:shell", "start": "npm run shell", @@ -23,7 +24,9 @@ "firebase-functions": "^7.2.2" }, "devDependencies": { + "@firebase/rules-unit-testing": "^5.0.2", "@types/node": "^25.5.0", + "firebase": "^12.19.0", "firebase-functions-test": "^3.1.0", "typescript": "^4.9.5" }, diff --git a/functions/src/common/firestorePath.ts b/functions/src/common/firestorePath.ts index 25c07f9..5f771c6 100644 --- a/functions/src/common/firestorePath.ts +++ b/functions/src/common/firestorePath.ts @@ -5,7 +5,6 @@ export namespace FirestorePath { todoLists = "todoLists", notifications = "notifications", notificationDispatches = "notificationDispatches", - webPages = "webPages", authCredentials = "authCredentials", providers = "providers", oauthSessions = "oauthSessions", @@ -56,14 +55,6 @@ export namespace FirestorePath { return `${notificationDispatches(userId)}/${dispatchId}`; } - export function webPages(userId: string): string { - return `${user(userId)}/${Collection.webPages}`; - } - - export function webPage(userId: string, documentId: string): string { - return `${webPages(userId)}/${documentId}`; - } - // 지정한 사용자의 서버 전용 인증 자격 증명 루트 경로를 반환합니다. export function authCredential(userId: string): string { return `${Collection.authCredentials}/${userId}`; diff --git a/functions/src/index.ts b/functions/src/index.ts index 1dfddaa..14e5a50 100644 --- a/functions/src/index.ts +++ b/functions/src/index.ts @@ -32,10 +32,6 @@ import { cleanupSoftDeletedNotifications } from "./notification/cleanup"; -import { - cleanupSoftDeletedWebPages -} from "./webPage/cleanup"; - import { sendDailyIncidentReport } from "./incident/daily"; @@ -71,7 +67,6 @@ export { removeCompletedTodoNotificationRecords, removeTodoNotificationDocuments, cleanupSoftDeletedNotifications, - cleanupSoftDeletedWebPages, sendDailyIncidentReport, syncTodoNotificationCategory, api diff --git a/functions/src/webPage/cleanup.ts b/functions/src/webPage/cleanup.ts deleted file mode 100644 index 1c40863..0000000 --- a/functions/src/webPage/cleanup.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { onSchedule } from "firebase-functions/v2/scheduler"; -import { FieldPath, getFirestore } from "firebase-admin/firestore"; -import * as logger from "firebase-functions/logger"; -import { toError } from "../common/error"; - -const LOCATION = "asia-northeast3"; -const CLEANUP_BATCH_SIZE = 200; - -export const cleanupSoftDeletedWebPages = onSchedule({ - maxInstances: 1, - region: LOCATION, - schedule: "0 0 * * *", - timeZone: "UTC" - }, - async () => { - try { - await cleanupSoftDeletedWebPagesIn(); - } catch (error) { - logger.error("soft delete WebPage cleanup 실패", toError(error), { - collectionGroup: "webPages", - filter: "isDeleted == true", - orderBy: "documentId", - cleanupBatchSize: CLEANUP_BATCH_SIZE - }); - } - } -); - -// 현재 Firebase project의 기본 Firestore에서 삭제 표시된 웹 페이지 문서를 제거합니다. -async function cleanupSoftDeletedWebPagesIn(): Promise { - const db = getFirestore(); - let lastDocument: - FirebaseFirestore.QueryDocumentSnapshot | undefined; - - while (true) { - let query = db - .collectionGroup("webPages") - .where("isDeleted", "==", true) - .orderBy(FieldPath.documentId()) - .limit(CLEANUP_BATCH_SIZE) - if (lastDocument) { - query = query.startAfter(lastDocument); - } - - const snapshot = await query.get(); - - if (snapshot.empty) { return; } - - const batch = db.batch(); - snapshot.docs.forEach((document) => { - batch.delete(document.ref); - }); - await batch.commit(); - - if (snapshot.size < CLEANUP_BATCH_SIZE) { return; } - lastDocument = snapshot.docs[snapshot.docs.length - 1]; - } -} diff --git a/functions/test/firebase-hosting.test.js b/functions/test/firebase-hosting.test.js index fb66cb4..feeedaa 100644 --- a/functions/test/firebase-hosting.test.js +++ b/functions/test/firebase-hosting.test.js @@ -16,13 +16,6 @@ assert.deepStrictEqual(staging.rewrites, [ region: "asia-northeast3" } }, - { - source: "/api/web-pages/**", - run: { - serviceId: "api-v2", - region: "asia-northeast3" - } - }, { source: "/api/push-notifications/**", run: { diff --git a/functions/test/firestore-rules.emulator.test.js b/functions/test/firestore-rules.emulator.test.js new file mode 100644 index 0000000..ad4af72 --- /dev/null +++ b/functions/test/firestore-rules.emulator.test.js @@ -0,0 +1,341 @@ +const fs = require("fs"); +const path = require("path"); +const { + assertFails, + assertSucceeds, + initializeTestEnvironment +} = require("@firebase/rules-unit-testing"); +const { + collection, + deleteDoc, + deleteField, + doc, + getDoc, + getDocs, + runTransaction, + setDoc, + updateDoc +} = require("firebase/firestore"); + +const projectId = "demo-devlog"; +const ownerId = "owner"; +const otherId = "other"; +const goalPath = `users/${ownerId}/developmentGoals/goal-1`; +const recordPath = `${goalPath}/records/record-1`; +const versionPath = `${recordPath}/versions/version-1`; + +let testEnvironment; + +(async () => { + testEnvironment = await initializeTestEnvironment({ + projectId, + firestore: { + rules: fs.readFileSync(path.resolve(__dirname, "../../firestore.rules"), "utf8") + } + }); + + try { + await assertOwnerCreatesAndTransitionsGoal(); + await assertOwnerCreatesRecordAndSavesDraft(); + await assertOwnerConfirmsDraftWithNewVersion(); + await assertOwnerReadsVersions(); + await assertConfirmedVersionCannotBeOverwritten(); + await assertConfirmedVersionCannotBeDeleted(); + await assertGoalAndRecordCannotBeDeleted(); + await assertUndefinedGoalSubcollectionIsDenied(); + await assertOtherUserCannotAccessDevelopmentData(); + await assertUnauthenticatedUserCannotAccessDevelopmentData(); + await assertDeletingUserCannotWriteDevelopmentData(); + await assertProviderCredentialDoesNotBlockWrites(); + await assertExistingUserDataPermissionsRemain(); + await assertDeletingUserCannotWriteExistingUserData(); + } finally { + await testEnvironment.cleanup(); + } +})().catch((error) => { + console.error(error); + process.exitCode = 1; +}); + +// 소유자의 목표 생성과 상태 전환 허용 검증 +async function assertOwnerCreatesAndTransitionsGoal() { + await testEnvironment.clearFirestore(); + const db = ownerFirestore(); + + await assertSucceeds(setDoc(doc(db, goalPath), goalData())); + await assertSucceeds(updateDoc(doc(db, goalPath), { status: "archived" })); + await assertSucceeds(updateDoc(doc(db, goalPath), { status: "inProgress" })); + await assertSucceeds(getDoc(doc(db, goalPath))); +} + +// 소유자의 기록 생성과 초안 저장 허용 검증 +async function assertOwnerCreatesRecordAndSavesDraft() { + await testEnvironment.clearFirestore(); + await seed({ [goalPath]: goalData() }); + const db = ownerFirestore(); + + await assertSucceeds(runTransaction(db, async (transaction) => { + const record = await transaction.get(doc(db, recordPath)); + if (record.exists()) { + throw new Error("record already exists"); + } + transaction.set(doc(db, recordPath), { createdAt: new Date() }); + })); + await assertSucceeds(runTransaction(db, async (transaction) => { + await transaction.get(doc(db, recordPath)); + transaction.update(doc(db, recordPath), { draft: draftData() }); + })); +} + +// 한 transaction 안의 새 버전 생성과 currentVersionId 갱신, 초안 제거 허용 검증 +async function assertOwnerConfirmsDraftWithNewVersion() { + await testEnvironment.clearFirestore(); + await seed({ + [goalPath]: goalData(), + [recordPath]: { createdAt: new Date(), draft: draftData() } + }); + const db = ownerFirestore(); + + await assertSucceeds(runTransaction(db, async (transaction) => { + await transaction.get(doc(db, recordPath)); + await transaction.get(doc(db, versionPath)); + transaction.set(doc(db, versionPath), versionData(1)); + transaction.update(doc(db, recordPath), { + currentVersionId: "version-1", + currentVersionNumber: 1, + draft: deleteField() + }); + })); + + const nextVersionPath = `${recordPath}/versions/version-2`; + await assertSucceeds(runTransaction(db, async (transaction) => { + await transaction.get(doc(db, recordPath)); + await transaction.get(doc(db, versionPath)); + transaction.set(doc(db, nextVersionPath), { + ...versionData(2), + changeKind: "restore", + sourceVersionId: "version-1" + }); + transaction.update(doc(db, recordPath), { + currentVersionId: "version-2", + currentVersionNumber: 2 + }); + })); +} + +// 소유자의 버전 단건·목록 조회와 없는 버전 조회 허용 검증 +async function assertOwnerReadsVersions() { + await testEnvironment.clearFirestore(); + await seed({ [versionPath]: versionData(1) }); + const db = ownerFirestore(); + + await assertSucceeds(getDoc(doc(db, versionPath))); + await assertSucceeds(getDocs(collection(db, `${recordPath}/versions`))); + await assertSucceeds(getDoc(doc(db, `${recordPath}/versions/missing`))); +} + +// 확정 버전의 갱신과 같은 ID 덮어쓰기 거부 검증 +async function assertConfirmedVersionCannotBeOverwritten() { + await testEnvironment.clearFirestore(); + await seed({ [versionPath]: versionData(1) }); + const db = ownerFirestore(); + + await assertFails(updateDoc(doc(db, versionPath), { title: "changed" })); + await assertFails(setDoc(doc(db, versionPath), versionData(1))); + await assertFails(setDoc(doc(db, versionPath), { title: "merged" }, { merge: true })); + await assertFails(runTransaction(db, async (transaction) => { + await transaction.get(doc(db, versionPath)); + transaction.set(doc(db, versionPath), versionData(2)); + })); +} + +// 확정 버전의 삭제 거부 검증 +async function assertConfirmedVersionCannotBeDeleted() { + await testEnvironment.clearFirestore(); + await seed({ [versionPath]: versionData(1) }); + + await assertFails(deleteDoc(doc(ownerFirestore(), versionPath))); +} + +// 하위 버전이 고아로 남지 않도록 목표와 기록의 삭제 거부 검증 +async function assertGoalAndRecordCannotBeDeleted() { + await testEnvironment.clearFirestore(); + await seed({ + [goalPath]: goalData(), + [recordPath]: { createdAt: new Date() } + }); + const db = ownerFirestore(); + + await assertFails(deleteDoc(doc(db, recordPath))); + await assertFails(deleteDoc(doc(db, goalPath))); +} + +// developmentGoals 하위의 정의되지 않은 경로 거부 검증 +async function assertUndefinedGoalSubcollectionIsDenied() { + await testEnvironment.clearFirestore(); + const db = ownerFirestore(); + const undefinedPaths = [ + `${goalPath}/notes/note-1`, + `${recordPath}/comments/comment-1`, + `${versionPath}/attachments/attachment-1` + ]; + + for (const undefinedPath of undefinedPaths) { + await assertFails(setDoc(doc(db, undefinedPath), { value: 1 })); + await assertFails(getDoc(doc(db, undefinedPath))); + } +} + +// 다른 사용자의 목표·기록·버전 읽기와 쓰기 거부 검증 +async function assertOtherUserCannotAccessDevelopmentData() { + await testEnvironment.clearFirestore(); + await seed({ + [goalPath]: goalData(), + [recordPath]: { createdAt: new Date() }, + [versionPath]: versionData(1) + }); + const db = testEnvironment.authenticatedContext(otherId).firestore(); + + await assertDeniedReadAndWrite(db); +} + +// 비인증 요청의 목표·기록·버전 읽기와 쓰기 거부 검증 +async function assertUnauthenticatedUserCannotAccessDevelopmentData() { + await testEnvironment.clearFirestore(); + await seed({ + [goalPath]: goalData(), + [recordPath]: { createdAt: new Date() }, + [versionPath]: versionData(1) + }); + + await assertDeniedReadAndWrite(testEnvironment.unauthenticatedContext().firestore()); +} + +// 삭제 진행 중인 사용자의 목표·기록·버전 쓰기 거부와 읽기 유지 검증 +async function assertDeletingUserCannotWriteDevelopmentData() { + await testEnvironment.clearFirestore(); + await seed({ + [`authCredentials/${ownerId}`]: { deletionStartedAt: new Date() }, + [goalPath]: goalData(), + [recordPath]: { createdAt: new Date() } + }); + const db = ownerFirestore(); + + await assertFails(setDoc(doc(db, `users/${ownerId}/developmentGoals/goal-2`), goalData())); + await assertFails(updateDoc(doc(db, goalPath), { status: "archived" })); + await assertFails(setDoc(doc(db, `${goalPath}/records/record-2`), { createdAt: new Date() })); + await assertFails(updateDoc(doc(db, recordPath), { draft: draftData() })); + await assertFails(setDoc(doc(db, versionPath), versionData(1))); + await assertSucceeds(getDoc(doc(db, goalPath))); + await assertSucceeds(getDoc(doc(db, recordPath))); +} + +// 루트 삭제 표식 없이 provider 자격 증명만 있는 사용자의 쓰기 허용 검증 +async function assertProviderCredentialDoesNotBlockWrites() { + await testEnvironment.clearFirestore(); + await seed({ [`authCredentials/${ownerId}/providers/github`]: { accessToken: "token" } }); + const db = ownerFirestore(); + + await assertSucceeds(setDoc(doc(db, goalPath), goalData())); + await assertSucceeds(setDoc(doc(db, recordPath), { createdAt: new Date() })); + await assertSucceeds(setDoc(doc(db, versionPath), versionData(1))); + await assertSucceeds(setDoc(doc(db, `users/${ownerId}/todoLists/todo-1`), { title: "todo" })); +} + +// 기존 사용자 하위 데이터의 소유자 읽기·쓰기·삭제 유지 검증 +async function assertExistingUserDataPermissionsRemain() { + await testEnvironment.clearFirestore(); + const db = ownerFirestore(); + const existingPaths = [ + `users/${ownerId}/todoLists/todo-1`, + `users/${ownerId}/userData/settings`, + `users/${ownerId}/counters/todo`, + `users/${ownerId}/notifications/notification-1`, + `users/${ownerId}/webPages/page-1`, + `users/${ownerId}/todoLists/todo-1/items/item-1` + ]; + + await assertSucceeds(setDoc(doc(db, `users/${ownerId}`), { name: "owner" })); + for (const existingPath of existingPaths) { + await assertSucceeds(setDoc(doc(db, existingPath), { value: 1 })); + await assertSucceeds(updateDoc(doc(db, existingPath), { value: 2 })); + await assertSucceeds(getDoc(doc(db, existingPath))); + await assertSucceeds(deleteDoc(doc(db, existingPath))); + } + + const otherDb = testEnvironment.authenticatedContext(otherId).firestore(); + await assertFails(getDoc(doc(otherDb, `users/${ownerId}/todoLists/todo-1`))); + await assertFails(setDoc(doc(otherDb, `users/${ownerId}/todoLists/todo-1`), { value: 1 })); +} + +// 삭제 진행 중인 사용자의 기존 하위 데이터 쓰기 거부 검증 +async function assertDeletingUserCannotWriteExistingUserData() { + await testEnvironment.clearFirestore(); + await seed({ + [`authCredentials/${ownerId}`]: { deletionStartedAt: new Date() }, + [`users/${ownerId}/todoLists/todo-1`]: { value: 1 } + }); + const db = ownerFirestore(); + + await assertFails(setDoc(doc(db, `users/${ownerId}/todoLists/todo-2`), { value: 1 })); + await assertFails(updateDoc(doc(db, `users/${ownerId}/todoLists/todo-1`), { value: 2 })); + await assertFails(deleteDoc(doc(db, `users/${ownerId}/todoLists/todo-1`))); + await assertSucceeds(getDoc(doc(db, `users/${ownerId}/todoLists/todo-1`))); +} + +// 목표·기록·버전 경로 전체의 읽기와 쓰기 거부 확인 +async function assertDeniedReadAndWrite(db) { + for (const documentPath of [goalPath, recordPath, versionPath]) { + await assertFails(getDoc(doc(db, documentPath))); + await assertFails(setDoc(doc(db, documentPath), { value: 1 })); + await assertFails(deleteDoc(doc(db, documentPath))); + } + await assertFails(getDocs(collection(db, `${recordPath}/versions`))); + await assertFails(setDoc(doc(db, `${recordPath}/versions/version-2`), versionData(2))); +} + +// 소유자 인증 컨텍스트의 Firestore 인스턴스 +function ownerFirestore() { + return testEnvironment.authenticatedContext(ownerId).firestore(); +} + +// 규칙을 우회한 초기 문서 기록 +async function seed(documents) { + await testEnvironment.withSecurityRulesDisabled(async (context) => { + const db = context.firestore(); + for (const [documentPath, data] of Object.entries(documents)) { + await setDoc(doc(db, documentPath), data); + } + }); +} + +// 진행 중 상태의 목표 문서 데이터 +function goalData() { + return { + title: "goal", + markdownDescription: "", + status: "inProgress", + createdAt: new Date(), + updatedAt: new Date() + }; +} + +// 기록 문서에 저장하는 초안 데이터 +function draftData() { + return { + title: "draft", + markdownContent: "content", + updatedAt: new Date() + }; +} + +// 지정한 번호의 확정 버전 문서 데이터 +function versionData(versionNumber) { + return { + versionNumber, + title: "record", + markdownContent: "content", + changeKind: "initial", + confirmedAt: new Date() + }; +} diff --git a/functions/test/firestore-rules.test.js b/functions/test/firestore-rules.test.js index b43a4df..0c275f6 100644 --- a/functions/test/firestore-rules.test.js +++ b/functions/test/firestore-rules.test.js @@ -16,3 +16,13 @@ assert.ok(rules.includes("function userDataWriteAllowed(userId)")); assert.ok(rules.includes("documents/authCredentials/$(userId)")); assert.ok(rules.includes("data.deletionStartedAt == null")); assert.ok(rules.includes("userDataWriteAllowed(userId)")); +assert.ok(rules.includes("match /{collectionId}/{document=**} {")); +assert.ok(rules.includes("collectionId != 'developmentGoals'")); +assert.ok(!rules.includes("match /{document=**} {")); +assert.ok(rules.includes("match /developmentGoals/{goalId} {")); +assert.ok(rules.includes("match /records/{recordId} {")); + +const versionBlock = rules.match(/match \/versions\/\{versionId\} \{[\s\S]*?\n\s*\}/)[0]; + +assert.ok(versionBlock.includes("allow create:")); +assert.ok(!/\b(update|delete|write)\b/.test(versionBlock)); diff --git a/functions/test/scheduled-cleanup.test.js b/functions/test/scheduled-cleanup.test.js index 532a558..68a1f9b 100644 --- a/functions/test/scheduled-cleanup.test.js +++ b/functions/test/scheduled-cleanup.test.js @@ -25,14 +25,12 @@ const { cleanupSoftDeletedNotifications } = require("../lib/notification/cleanup"); const { compactSoftDeletedTodos } = require("../lib/todo/cleanup"); -const { cleanupSoftDeletedWebPages } = require("../lib/webPage/cleanup"); (async () => { const schedulers = [ cleanupSoftDeletedNotifications, cleanupNotificationDispatches, - compactSoftDeletedTodos, - cleanupSoftDeletedWebPages + compactSoftDeletedTodos ]; for (const scheduler of schedulers) { diff --git a/nestjs-api/src/app.module.test.ts b/nestjs-api/src/app.module.test.ts index 5d669e7..031d59e 100644 --- a/nestjs-api/src/app.module.test.ts +++ b/nestjs-api/src/app.module.test.ts @@ -22,7 +22,6 @@ import { GitHubAuthenticationModule } from './github/github-authentication.modul import { GoogleAuthenticationModule } from './google/google-authentication.module'; import { PushNotificationsModule } from './push-notifications/push-notifications.module'; import { TodosModule } from './todos/todos.module'; -import { WebPagesModule } from './web-pages/web-pages.module'; jest.mock('firebase-admin/app', () => ({ applicationDefault: jest.fn(), @@ -134,15 +133,6 @@ describe(AppModule.name, () => { expect(imports).toContain(PushNotificationsModule); }); - it('WebPagesModule을 애플리케이션에 연결한다', () => { - const imports = Reflect.getMetadata( - MODULE_METADATA.IMPORTS, - AppModule, - ) as unknown[]; - - expect(imports).toContain(WebPagesModule); - }); - it('Firebase App 초기화 오류가 발생하면 구성을 중단한다', async () => { const credential = {} as Credential; const error = new Error('Firebase App 초기화 실패'); diff --git a/nestjs-api/src/app.module.ts b/nestjs-api/src/app.module.ts index b0693f2..c3a3fef 100644 --- a/nestjs-api/src/app.module.ts +++ b/nestjs-api/src/app.module.ts @@ -9,7 +9,6 @@ import { GitHubAuthenticationModule } from './github/github-authentication.modul import { GoogleAuthenticationModule } from './google/google-authentication.module'; import { PushNotificationsModule } from './push-notifications/push-notifications.module'; import { TodosModule } from './todos/todos.module'; -import { WebPagesModule } from './web-pages/web-pages.module'; /** 애플리케이션의 최상위 의존성 경계를 구성하는 모듈입니다. */ @Module({ @@ -20,7 +19,6 @@ import { WebPagesModule } from './web-pages/web-pages.module'; GoogleAuthenticationModule, PushNotificationsModule, TodosModule, - WebPagesModule, ], providers: [ { provide: APP_GUARD, useClass: FirebaseAuthGuard }, diff --git a/nestjs-api/src/web-pages/web-pages.controller.test.ts b/nestjs-api/src/web-pages/web-pages.controller.test.ts deleted file mode 100644 index 56a4394..0000000 --- a/nestjs-api/src/web-pages/web-pages.controller.test.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { HttpStatus } from '@nestjs/common'; - -import { type FirebaseAuthenticatedRequest } from '../auth/firebase-authenticated-request'; -import { WebPagesController } from './web-pages.controller'; -import { WebPagesService } from './web-pages.service'; - -describe(WebPagesController.name, () => { - const uid = 'user-1'; - const request = { uid } as FirebaseAuthenticatedRequest; - - it('검증된 UID와 공백을 제거한 WebPage ID로 삭제를 요청한다', async () => { - const requestDeletion = jest.fn().mockResolvedValue(undefined); - const service = { - requestDeletion, - } as unknown as WebPagesService; - const controller = new WebPagesController(service); - - await expect( - controller.requestDeletion(request, ' web-page-1 '), - ).resolves.toEqual({ success: true }); - expect(requestDeletion).toHaveBeenCalledWith(uid, 'web-page-1'); - }); - - it('검증된 UID와 공백을 제거한 WebPage ID로 삭제를 취소한다', async () => { - const undoDeletion = jest.fn().mockResolvedValue(undefined); - const service = { undoDeletion } as unknown as WebPagesService; - const controller = new WebPagesController(service); - - await expect( - controller.undoDeletion(request, ' web-page-1 '), - ).resolves.toEqual({ success: true }); - expect(undoDeletion).toHaveBeenCalledWith(uid, 'web-page-1'); - }); - - it('공백인 WebPage ID를 invalid-argument로 거부한다', async () => { - const requestDeletion = jest.fn(); - const service = { - requestDeletion, - } as unknown as WebPagesService; - const controller = new WebPagesController(service); - - await expect( - controller.requestDeletion(request, ' '), - ).rejects.toMatchObject({ - status: HttpStatus.BAD_REQUEST, - response: { - code: 'invalid-argument', - message: 'id가 필요합니다.', - }, - }); - expect(requestDeletion).not.toHaveBeenCalled(); - }); - - it('검증된 UID가 없으면 unauthenticated로 거부한다', async () => { - const requestDeletion = jest.fn(); - const service = { - requestDeletion, - } as unknown as WebPagesService; - const controller = new WebPagesController(service); - - await expect( - controller.requestDeletion( - {} as FirebaseAuthenticatedRequest, - 'web-page-1', - ), - ).rejects.toMatchObject({ - status: HttpStatus.UNAUTHORIZED, - response: { - code: 'unauthenticated', - message: '인증된 사용자가 아닙니다.', - }, - }); - expect(requestDeletion).not.toHaveBeenCalled(); - }); -}); diff --git a/nestjs-api/src/web-pages/web-pages.controller.ts b/nestjs-api/src/web-pages/web-pages.controller.ts deleted file mode 100644 index 0d053f6..0000000 --- a/nestjs-api/src/web-pages/web-pages.controller.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { - Controller, - Delete, - HttpCode, - HttpStatus, - Param, - Post, - Req, -} from '@nestjs/common'; - -import { type FirebaseAuthenticatedRequest } from '../auth/firebase-authenticated-request'; -import { ApiException } from '../common/api.exception'; -import { WebPagesService } from './web-pages.service'; - -// WebPage 삭제 요청과 취소 HTTP 경계를 제공합니다. -@Controller('web-pages') -export class WebPagesController { - // WebPage 삭제 업무 규칙을 제공하는 의존성을 주입받습니다. - constructor(private readonly service: WebPagesService) {} - - // 인증된 사용자의 WebPage 삭제 요청을 처리합니다. - @Post(':id/deletion-request') - @HttpCode(HttpStatus.OK) - async requestDeletion( - @Req() request: FirebaseAuthenticatedRequest, - @Param('id') webPageId: string, - ): Promise<{ success: true }> { - await this.service.requestDeletion( - requiredUid(request), - requiredWebPageId(webPageId), - ); - - return { success: true }; - } - - // 인증된 사용자의 WebPage 삭제 취소 요청을 처리합니다. - @Delete(':id/deletion-request') - async undoDeletion( - @Req() request: FirebaseAuthenticatedRequest, - @Param('id') webPageId: string, - ): Promise<{ success: true }> { - await this.service.undoDeletion( - requiredUid(request), - requiredWebPageId(webPageId), - ); - - return { success: true }; - } -} - -// 인증 Guard가 확인한 사용자 식별자를 반환합니다. -function requiredUid(request: FirebaseAuthenticatedRequest): string { - if (!request.uid) { - throw new ApiException( - HttpStatus.UNAUTHORIZED, - 'unauthenticated', - '인증된 사용자가 아닙니다.', - ); - } - - return request.uid; -} - -// 앞뒤 공백을 제거한 WebPage 식별자를 반환합니다. -function requiredWebPageId(webPageId: string): string { - const trimmedWebPageId = webPageId.trim(); - if (!trimmedWebPageId) { - throw new ApiException( - HttpStatus.BAD_REQUEST, - 'invalid-argument', - 'id가 필요합니다.', - ); - } - - return trimmedWebPageId; -} diff --git a/nestjs-api/src/web-pages/web-pages.module.test.ts b/nestjs-api/src/web-pages/web-pages.module.test.ts deleted file mode 100644 index c52833b..0000000 --- a/nestjs-api/src/web-pages/web-pages.module.test.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { type Provider } from '@nestjs/common'; -import { MODULE_METADATA } from '@nestjs/common/constants'; - -import { FirebaseModule } from '../firebase/firebase.module'; -import { WebPagesController } from './web-pages.controller'; -import { WebPagesModule } from './web-pages.module'; -import { WebPagesRepository } from './web-pages.repository'; -import { WebPagesService } from './web-pages.service'; - -jest.mock('firebase-admin/app', () => ({ - applicationDefault: jest.fn(), - getApps: jest.fn(), - initializeApp: jest.fn(), -})); -jest.mock('firebase-admin/auth', () => ({ - getAuth: jest.fn(), -})); -jest.mock('firebase-admin/firestore', () => ({ - getFirestore: jest.fn(), -})); - -describe(WebPagesModule.name, () => { - it('FirebaseModule과 WebPage provider를 구성한다', () => { - const imports = Reflect.getMetadata( - MODULE_METADATA.IMPORTS, - WebPagesModule, - ) as unknown[]; - const providers = Reflect.getMetadata( - MODULE_METADATA.PROVIDERS, - WebPagesModule, - ) as Provider[]; - const controllers = Reflect.getMetadata( - MODULE_METADATA.CONTROLLERS, - WebPagesModule, - ) as unknown[]; - - expect(imports).toContain(FirebaseModule); - expect(controllers).toContain(WebPagesController); - expect(providers).toEqual( - expect.arrayContaining([WebPagesRepository, WebPagesService]), - ); - }); -}); diff --git a/nestjs-api/src/web-pages/web-pages.module.ts b/nestjs-api/src/web-pages/web-pages.module.ts deleted file mode 100644 index 3f22e78..0000000 --- a/nestjs-api/src/web-pages/web-pages.module.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Module } from '@nestjs/common'; - -import { FirebaseModule } from '../firebase/firebase.module'; -import { WebPagesController } from './web-pages.controller'; -import { WebPagesRepository } from './web-pages.repository'; -import { WebPagesService } from './web-pages.service'; - -// WebPage 업무 규칙과 Firestore 저장 동작의 의존성 경계입니다. -@Module({ - imports: [FirebaseModule], - controllers: [WebPagesController], - providers: [WebPagesRepository, WebPagesService], -}) -export class WebPagesModule {} diff --git a/nestjs-api/src/web-pages/web-pages.repository.test.ts b/nestjs-api/src/web-pages/web-pages.repository.test.ts deleted file mode 100644 index 01b667f..0000000 --- a/nestjs-api/src/web-pages/web-pages.repository.test.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { FieldValue, type Firestore } from 'firebase-admin/firestore'; - -import { WebPagesRepository } from './web-pages.repository'; - -describe(WebPagesRepository.name, () => { - const uid = 'user-1'; - const webPageId = 'web-page-1'; - - it.each([ - { snapshot: { exists: false }, expected: 'missing' }, - { - snapshot: { exists: true, data: () => ({ title: 'WebPage' }) }, - expected: 'active', - }, - { - snapshot: { exists: true, data: () => ({ isDeleted: true }) }, - expected: 'deleted', - }, - ])( - 'WebPage 삭제 상태 $expected를 반환한다', - async ({ snapshot, expected }) => { - const get = jest.fn().mockResolvedValue(snapshot); - const doc = jest.fn().mockReturnValue({ get }); - const repository = new WebPagesRepository({ - doc, - } as unknown as Firestore); - - await expect( - repository.getWebPageDeletionState(uid, webPageId), - ).resolves.toBe(expected); - expect(doc).toHaveBeenCalledWith('users/user-1/webPages/web-page-1'); - }, - ); - - it('WebPage에 삭제 요청 상태를 기록한다', async () => { - const set = jest.fn().mockResolvedValue(undefined); - const doc = jest.fn().mockReturnValue({ set }); - const repository = new WebPagesRepository({ - doc, - } as unknown as Firestore); - - await repository.markWebPageDeletionRequested(uid, webPageId); - - expect(doc).toHaveBeenCalledWith('users/user-1/webPages/web-page-1'); - expect(set).toHaveBeenCalledWith( - { - deletingAt: FieldValue.delete(), - isDeleted: true, - }, - { merge: true }, - ); - }); - - it('WebPage 삭제 상태를 복구한다', async () => { - const update = jest.fn().mockResolvedValue(undefined); - const doc = jest.fn().mockReturnValue({ update }); - const repository = new WebPagesRepository({ - doc, - } as unknown as Firestore); - - await repository.restoreWebPageDeletion(uid, webPageId); - - expect(doc).toHaveBeenCalledWith('users/user-1/webPages/web-page-1'); - expect(update).toHaveBeenCalledWith({ - deletingAt: FieldValue.delete(), - isDeleted: false, - }); - }); -}); diff --git a/nestjs-api/src/web-pages/web-pages.repository.ts b/nestjs-api/src/web-pages/web-pages.repository.ts deleted file mode 100644 index 001c5fa..0000000 --- a/nestjs-api/src/web-pages/web-pages.repository.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { Inject, Injectable } from '@nestjs/common'; -import { - type DocumentReference, - FieldValue, - type Firestore, -} from 'firebase-admin/firestore'; - -import { FIREBASE_FIRESTORE_TOKEN } from '../firebase/firebase.tokens'; - -// WebPage 문서에 저장된 삭제 처리 상태입니다. -export type WebPageDeletionState = 'missing' | 'active' | 'deleted'; - -// WebPage의 Firestore 저장 동작을 담당합니다. -@Injectable() -export class WebPagesRepository { - // Firestore 저장소 의존성을 주입받습니다. - constructor( - @Inject(FIREBASE_FIRESTORE_TOKEN) private readonly firestore: Firestore, - ) {} - - // WebPage 문서의 현재 삭제 처리 상태를 반환합니다. - async getWebPageDeletionState( - uid: string, - webPageId: string, - ): Promise { - const snapshot = await this.webPageDocument(uid, webPageId).get(); - - if (!snapshot.exists) { - return 'missing'; - } - - return snapshot.data()?.isDeleted === true ? 'deleted' : 'active'; - } - - // WebPage 문서에 삭제 요청 상태를 기록합니다. - async markWebPageDeletionRequested( - uid: string, - webPageId: string, - ): Promise { - await this.webPageDocument(uid, webPageId).set( - { - deletingAt: FieldValue.delete(), - isDeleted: true, - }, - { merge: true }, - ); - } - - // WebPage 문서에 기록된 삭제 상태를 복구합니다. - // prettier-ignore - async restoreWebPageDeletion( - uid: string, - webPageId: string, - ): Promise { - await this.webPageDocument(uid, webPageId).update({ - deletingAt: FieldValue.delete(), - isDeleted: false, - }); - } - - // 검증된 사용자 UID 범위에서 WebPage 문서 참조를 생성합니다. - // prettier-ignore - private webPageDocument( - uid: string, - webPageId: string, - ): DocumentReference { - return this.firestore.doc(`users/${uid}/webPages/${webPageId}`); - } -} diff --git a/nestjs-api/src/web-pages/web-pages.service.test.ts b/nestjs-api/src/web-pages/web-pages.service.test.ts deleted file mode 100644 index 416f6b5..0000000 --- a/nestjs-api/src/web-pages/web-pages.service.test.ts +++ /dev/null @@ -1,217 +0,0 @@ -import { HttpStatus, Logger } from '@nestjs/common'; - -import { WebPagesRepository } from './web-pages.repository'; -import { WebPagesService } from './web-pages.service'; - -describe(WebPagesService.name, () => { - const uid = 'user-1'; - const webPageId = 'web-page-1'; - - afterEach(() => { - jest.restoreAllMocks(); - }); - - it('활성 WebPage에 삭제 요청 상태를 기록한다', async () => { - const sequence: string[] = []; - const getWebPageDeletionState = jest.fn().mockImplementation(() => { - sequence.push('WebPage 상태 조회'); - return Promise.resolve('active'); - }); - const markWebPageDeletionRequested = jest.fn().mockImplementation(() => { - sequence.push('WebPage 삭제 요청'); - return Promise.resolve(); - }); - const repository = { - getWebPageDeletionState, - markWebPageDeletionRequested, - } as unknown as WebPagesRepository; - const service = new WebPagesService(repository); - - await expect( - service.requestDeletion(uid, webPageId), - ).resolves.toBeUndefined(); - - expect(sequence).toEqual(['WebPage 상태 조회', 'WebPage 삭제 요청']); - }); - - it.each(['missing', 'deleted'])( - '%s WebPage 삭제 요청을 거부한다', - async (state) => { - const getWebPageDeletionState = jest.fn().mockResolvedValue(state); - const markWebPageDeletionRequested = jest.fn(); - const repository = { - getWebPageDeletionState, - markWebPageDeletionRequested, - } as unknown as WebPagesRepository; - const service = new WebPagesService(repository); - - await expect( - service.requestDeletion(uid, webPageId), - ).rejects.toMatchObject({ - status: HttpStatus.NOT_FOUND, - response: { - code: 'not-found', - message: 'WebPage를 찾을 수 없습니다.', - }, - }); - expect(markWebPageDeletionRequested).not.toHaveBeenCalled(); - }, - ); - - it('삭제 요청 실패 시 WebPage를 재조회하고 복구한다', async () => { - const sequence: string[] = []; - const error = new Error('WebPage 쓰기 실패'); - const getWebPageDeletionState = jest - .fn() - .mockImplementationOnce(() => { - sequence.push('WebPage 상태 조회'); - return Promise.resolve('active'); - }) - .mockImplementationOnce(() => { - sequence.push('WebPage 상태 재조회'); - return Promise.resolve('deleted'); - }); - const markWebPageDeletionRequested = jest.fn().mockImplementation(() => { - sequence.push('WebPage 삭제 요청'); - return Promise.reject(error); - }); - const restoreWebPageDeletion = jest.fn().mockImplementation(() => { - sequence.push('WebPage 복구'); - return Promise.resolve(); - }); - const repository = { - getWebPageDeletionState, - markWebPageDeletionRequested, - restoreWebPageDeletion, - } as unknown as WebPagesRepository; - const loggerError = jest - .spyOn(Logger.prototype, 'error') - .mockImplementation(); - const service = new WebPagesService(repository); - - await expect(service.requestDeletion(uid, webPageId)).rejects.toMatchObject( - { - status: HttpStatus.INTERNAL_SERVER_ERROR, - response: { - code: 'internal', - message: '웹페이지 삭제 요청에 실패했습니다.', - }, - }, - ); - expect(sequence).toEqual([ - 'WebPage 상태 조회', - 'WebPage 삭제 요청', - 'WebPage 상태 재조회', - 'WebPage 복구', - ]); - expect(loggerError).toHaveBeenCalledWith({ - message: '웹페이지 삭제 요청 실패', - errorMessage: error.message, - errorStack: error.stack, - uid, - webPageId, - }); - }); - - it('cleanup 실패를 기록하고 원래 삭제 요청 오류를 반환한다', async () => { - const deletionError = new Error('WebPage 쓰기 실패'); - const cleanupError = new Error('WebPage 복구 실패'); - const getWebPageDeletionState = jest - .fn() - .mockResolvedValueOnce('active') - .mockResolvedValueOnce('deleted'); - const repository = { - getWebPageDeletionState, - markWebPageDeletionRequested: jest.fn().mockRejectedValue(deletionError), - restoreWebPageDeletion: jest.fn().mockRejectedValue(cleanupError), - } as unknown as WebPagesRepository; - const loggerError = jest - .spyOn(Logger.prototype, 'error') - .mockImplementation(); - const service = new WebPagesService(repository); - - await expect(service.requestDeletion(uid, webPageId)).rejects.toMatchObject( - { - status: HttpStatus.INTERNAL_SERVER_ERROR, - response: { - code: 'internal', - message: '웹페이지 삭제 요청에 실패했습니다.', - }, - }, - ); - expect(loggerError).toHaveBeenNthCalledWith(1, { - message: '웹페이지 삭제 요청 cleanup 실패', - errorMessage: cleanupError.message, - errorStack: cleanupError.stack, - uid, - webPageId, - }); - expect(loggerError).toHaveBeenNthCalledWith(2, { - message: '웹페이지 삭제 요청 실패', - errorMessage: deletionError.message, - errorStack: deletionError.stack, - uid, - webPageId, - }); - }); - - it('삭제 상태인 WebPage를 복구한다', async () => { - const getWebPageDeletionState = jest.fn().mockResolvedValue('deleted'); - const restoreWebPageDeletion = jest.fn().mockResolvedValue(undefined); - const repository = { - getWebPageDeletionState, - restoreWebPageDeletion, - } as unknown as WebPagesRepository; - const service = new WebPagesService(repository); - - await expect(service.undoDeletion(uid, webPageId)).resolves.toBeUndefined(); - - expect(restoreWebPageDeletion).toHaveBeenCalledWith(uid, webPageId); - }); - - it.each(['missing', 'active'])( - '%s WebPage 삭제 취소를 성공으로 처리한다', - async (state) => { - const getWebPageDeletionState = jest.fn().mockResolvedValue(state); - const restoreWebPageDeletion = jest.fn(); - const repository = { - getWebPageDeletionState, - restoreWebPageDeletion, - } as unknown as WebPagesRepository; - const service = new WebPagesService(repository); - - await expect( - service.undoDeletion(uid, webPageId), - ).resolves.toBeUndefined(); - - expect(restoreWebPageDeletion).not.toHaveBeenCalled(); - }, - ); - - it('삭제 취소 실패를 internal 오류로 변환한다', async () => { - const error = new Error('WebPage 복구 실패'); - const repository = { - getWebPageDeletionState: jest.fn().mockResolvedValue('deleted'), - restoreWebPageDeletion: jest.fn().mockRejectedValue(error), - } as unknown as WebPagesRepository; - const loggerError = jest - .spyOn(Logger.prototype, 'error') - .mockImplementation(); - const service = new WebPagesService(repository); - - await expect(service.undoDeletion(uid, webPageId)).rejects.toMatchObject({ - status: HttpStatus.INTERNAL_SERVER_ERROR, - response: { - code: 'internal', - message: '웹페이지 삭제 취소에 실패했습니다.', - }, - }); - expect(loggerError).toHaveBeenCalledWith({ - message: '웹페이지 삭제 취소 실패', - errorMessage: error.message, - errorStack: error.stack, - uid, - webPageId, - }); - }); -}); diff --git a/nestjs-api/src/web-pages/web-pages.service.ts b/nestjs-api/src/web-pages/web-pages.service.ts deleted file mode 100644 index ea30ec0..0000000 --- a/nestjs-api/src/web-pages/web-pages.service.ts +++ /dev/null @@ -1,109 +0,0 @@ -// prettier-ignore -import { - HttpStatus, - Injectable, - Logger, -} from '@nestjs/common'; - -import { ApiException } from '../common/api.exception'; -import { WebPagesRepository } from './web-pages.repository'; - -// WebPage 삭제 요청과 취소 업무 규칙을 조정합니다. -@Injectable() -export class WebPagesService { - // WebPage 삭제 처리 실패 원인을 기록하는 로그 기능입니다. - private readonly logger = new Logger(WebPagesService.name); - - // WebPage 저장 동작을 제공하는 의존성을 주입받습니다. - constructor(private readonly repository: WebPagesRepository) {} - - // 유효한 WebPage에 삭제 요청 상태를 기록합니다. - // prettier-ignore - async requestDeletion( - uid: string, - webPageId: string, - ): Promise { - const state = await this.repository.getWebPageDeletionState(uid, webPageId); - if (state !== 'active') { - throw new ApiException( - HttpStatus.NOT_FOUND, - 'not-found', - 'WebPage를 찾을 수 없습니다.', - ); - } - - try { - await this.repository.markWebPageDeletionRequested(uid, webPageId); - } catch (error) { - await this.cleanupDeletionRequest(uid, webPageId); - - this.logger.error({ - message: '웹페이지 삭제 요청 실패', - errorMessage: error instanceof Error ? error.message : '알 수 없는 오류', - errorStack: error instanceof Error ? error.stack : undefined, - uid, - webPageId, - }); - throw new ApiException( - HttpStatus.INTERNAL_SERVER_ERROR, - 'internal', - '웹페이지 삭제 요청에 실패했습니다.', - ); - } - } - - // WebPage가 없거나 활성 상태여도 삭제 취소를 성공으로 처리합니다. - // prettier-ignore - async undoDeletion( - uid: string, - webPageId: string, - ): Promise { - try { - const state = await this.repository.getWebPageDeletionState( - uid, - webPageId, - ); - if (state === 'deleted') { - await this.repository.restoreWebPageDeletion(uid, webPageId); - } - } catch (error) { - this.logger.error({ - message: '웹페이지 삭제 취소 실패', - errorMessage: error instanceof Error ? error.message : '알 수 없는 오류', - errorStack: error instanceof Error ? error.stack : undefined, - uid, - webPageId, - }); - throw new ApiException( - HttpStatus.INTERNAL_SERVER_ERROR, - 'internal', - '웹페이지 삭제 취소에 실패했습니다.', - ); - } - } - - // 삭제 요청 실패 후 현재 문서가 삭제 상태이면 복구합니다. - private async cleanupDeletionRequest( - uid: string, - webPageId: string, - ): Promise { - try { - const state = await this.repository.getWebPageDeletionState( - uid, - webPageId, - ); - if (state === 'deleted') { - await this.repository.restoreWebPageDeletion(uid, webPageId); - } - } catch (error) { - this.logger.error({ - message: '웹페이지 삭제 요청 cleanup 실패', - errorMessage: - error instanceof Error ? error.message : '알 수 없는 오류', - errorStack: error instanceof Error ? error.stack : undefined, - uid, - webPageId, - }); - } - } -} diff --git a/nestjs-api/test/web-pages.e2e.test.ts b/nestjs-api/test/web-pages.e2e.test.ts deleted file mode 100644 index dca8efb..0000000 --- a/nestjs-api/test/web-pages.e2e.test.ts +++ /dev/null @@ -1,223 +0,0 @@ -import { HttpStatus, type INestApplication } from '@nestjs/common'; -import { Test } from '@nestjs/testing'; -import { type Server } from 'node:http'; -import request from 'supertest'; - -import { configureApplication } from '../src/app.config'; -import { AppModule } from '../src/app.module'; -import { ApiException } from '../src/common/api.exception'; -import { - FIREBASE_APP_TOKEN, - FIREBASE_AUTH_TOKEN, - FIREBASE_FIRESTORE_TOKEN, -} from '../src/firebase/firebase.tokens'; -import { WebPagesService } from '../src/web-pages/web-pages.service'; - -jest.mock('firebase-admin/app', () => ({ - applicationDefault: jest.fn(), - getApps: jest.fn(), - initializeApp: jest.fn(), -})); -jest.mock('firebase-admin/auth', () => ({ - getAuth: jest.fn(), -})); -jest.mock('firebase-admin/firestore', () => ({ - FieldPath: { documentId: jest.fn() }, - FieldValue: { - delete: jest.fn(), - serverTimestamp: jest.fn(), - }, - getFirestore: jest.fn(), -})); - -describe('WebPage 삭제 API', () => { - const uid = 'user-1'; - const token = 'Firebase-ID-Token'; - const verifyIdToken = jest.fn(); - const requestDeletion = jest.fn(); - const undoDeletion = jest.fn(); - let app: INestApplication; - - beforeAll(async () => { - const module = await Test.createTestingModule({ - imports: [AppModule], - }) - .overrideProvider(FIREBASE_APP_TOKEN) - .useValue({}) - .overrideProvider(FIREBASE_AUTH_TOKEN) - .useValue({ verifyIdToken }) - .overrideProvider(FIREBASE_FIRESTORE_TOKEN) - .useValue({}) - .overrideProvider(WebPagesService) - .useValue({ requestDeletion, undoDeletion }) - .compile(); - - app = module.createNestApplication(); - configureApplication(app); - await app.init(); - }); - - beforeEach(() => { - verifyIdToken.mockReset().mockResolvedValue({ uid }); - requestDeletion.mockReset().mockResolvedValue(undefined); - undoDeletion.mockReset().mockResolvedValue(undefined); - }); - - afterAll(async () => { - await app.close(); - }); - - it('검증된 UID와 공백을 제거한 WebPage ID로 삭제를 요청한다', async () => { - const server = app.getHttpServer() as Server; - - await request(server) - .post('/api/web-pages/%20web-page-1%20/deletion-request') - .set('Authorization', `Bearer ${token}`) - .expect(HttpStatus.OK) - .expect({ success: true }); - - expect(verifyIdToken).toHaveBeenCalledWith(token); - expect(requestDeletion).toHaveBeenCalledWith(uid, 'web-page-1'); - }); - - it('공백인 WebPage ID를 invalid-argument로 거부한다', async () => { - const server = app.getHttpServer() as Server; - - await request(server) - .post('/api/web-pages/%20/deletion-request') - .set('Authorization', `Bearer ${token}`) - .expect(HttpStatus.BAD_REQUEST) - .expect({ code: 'invalid-argument', message: 'id가 필요합니다.' }); - - expect(requestDeletion).not.toHaveBeenCalled(); - }); - - it('인증 token이 없으면 unauthenticated로 거부한다', async () => { - const server = app.getHttpServer() as Server; - - await request(server) - .post('/api/web-pages/web-page-1/deletion-request') - .expect(HttpStatus.UNAUTHORIZED) - .expect({ - code: 'unauthenticated', - message: '인증 토큰이 필요합니다.', - }); - - expect(requestDeletion).not.toHaveBeenCalled(); - }); - - it('Firebase Auth 오류를 401 응답으로 보존한다', async () => { - const server = app.getHttpServer() as Server; - verifyIdToken.mockRejectedValue({ - code: 'auth/id-token-expired', - message: 'Firebase ID token has expired.', - }); - - await request(server) - .post('/api/web-pages/web-page-1/deletion-request') - .set('Authorization', `Bearer ${token}`) - .expect(HttpStatus.UNAUTHORIZED) - .expect({ - code: 'auth/id-token-expired', - message: 'Firebase ID token has expired.', - }); - - expect(requestDeletion).not.toHaveBeenCalled(); - }); - - it('WebPage가 없으면 Service의 not-found 오류를 반환한다', async () => { - const server = app.getHttpServer() as Server; - requestDeletion.mockRejectedValue( - new ApiException( - HttpStatus.NOT_FOUND, - 'not-found', - 'WebPage를 찾을 수 없습니다.', - ), - ); - - await request(server) - .post('/api/web-pages/web-page-1/deletion-request') - .set('Authorization', `Bearer ${token}`) - .expect(HttpStatus.NOT_FOUND) - .expect({ code: 'not-found', message: 'WebPage를 찾을 수 없습니다.' }); - }); - - it('삭제 요청 실패를 Service의 internal 오류로 반환한다', async () => { - const server = app.getHttpServer() as Server; - requestDeletion.mockRejectedValue( - new ApiException( - HttpStatus.INTERNAL_SERVER_ERROR, - 'internal', - '웹페이지 삭제 요청에 실패했습니다.', - ), - ); - - await request(server) - .post('/api/web-pages/web-page-1/deletion-request') - .set('Authorization', `Bearer ${token}`) - .expect(HttpStatus.INTERNAL_SERVER_ERROR) - .expect({ - code: 'internal', - message: '웹페이지 삭제 요청에 실패했습니다.', - }); - }); - - it('검증된 UID와 공백을 제거한 WebPage ID로 삭제를 취소한다', async () => { - const server = app.getHttpServer() as Server; - - await request(server) - .delete('/api/web-pages/%20web-page-1%20/deletion-request') - .set('Authorization', `Bearer ${token}`) - .expect(HttpStatus.OK) - .expect({ success: true }); - - expect(verifyIdToken).toHaveBeenCalledWith(token); - expect(undoDeletion).toHaveBeenCalledWith(uid, 'web-page-1'); - }); - - it('삭제 취소에서 인증 token이 없으면 unauthenticated로 거부한다', async () => { - const server = app.getHttpServer() as Server; - - await request(server) - .delete('/api/web-pages/web-page-1/deletion-request') - .expect(HttpStatus.UNAUTHORIZED) - .expect({ - code: 'unauthenticated', - message: '인증 토큰이 필요합니다.', - }); - - expect(undoDeletion).not.toHaveBeenCalled(); - }); - - it('삭제 취소에서 공백인 WebPage ID를 invalid-argument로 거부한다', async () => { - const server = app.getHttpServer() as Server; - - await request(server) - .delete('/api/web-pages/%20/deletion-request') - .set('Authorization', `Bearer ${token}`) - .expect(HttpStatus.BAD_REQUEST) - .expect({ code: 'invalid-argument', message: 'id가 필요합니다.' }); - - expect(undoDeletion).not.toHaveBeenCalled(); - }); - - it('삭제 취소 실패를 Service의 internal 오류로 반환한다', async () => { - const server = app.getHttpServer() as Server; - undoDeletion.mockRejectedValue( - new ApiException( - HttpStatus.INTERNAL_SERVER_ERROR, - 'internal', - '웹페이지 삭제 취소에 실패했습니다.', - ), - ); - - await request(server) - .delete('/api/web-pages/web-page-1/deletion-request') - .set('Authorization', `Bearer ${token}`) - .expect(HttpStatus.INTERNAL_SERVER_ERROR) - .expect({ - code: 'internal', - message: '웹페이지 삭제 취소에 실패했습니다.', - }); - }); -});