Jose Olarte III
9e6597638e
chore(db): rename SQLite database file to notify.sqlite
...
Use a generic database filename for future notification-related storage, and update docs and env comments to match.
2026-07-27 16:53:53 +08:00
Jose Olarte III
06ec0f63e4
docs: document SQLite storage for FCM registrations
...
Update README and .env.example for the SQLite database location, schema overview, backup/WAL notes, and clarify that JSON data is not migrated.
2026-07-24 20:52:38 +08:00
Jose Olarte III
ddb969c26d
chore(db): remove obsolete JSON FCM token repository
...
Delete the unused JSON storage implementation now that SQLite is the sole persistence backend.
2026-07-24 17:57:44 +08:00
Jose Olarte III
e79d55fac6
perf(db): tighten SQLite FCM registration queries
...
Drop the upsert pre-read, project only needed columns, and add a (user_id, fcm_token) index for token lookups and dedupe deletes.
2026-07-24 17:31:23 +08:00
Jose Olarte III
11bd45b460
feat(db): switch runtime storage to SQLite repository
...
Point routes, scheduler, and push service at fcmTokensSqlite so the service no longer reads or writes the JSON store.
2026-07-23 18:55:17 +08:00
Jose Olarte III
5a3c22a4e3
feat(db): add SQLite FCM registration repository
...
Mirror the JSON repository API on SQLite without switching callers; clarify that SQLite is the storage backend and there is no JSON data migration.
2026-07-23 18:36:10 +08:00
Jose Olarte III
fa8ab86cdb
feat(db): add SQLite foundation for FCM registration storage
...
Introduce better-sqlite3 and a schema-init module so we can migrate off JSON storage without changing runtime behavior yet.
2026-07-23 17:44:27 +08:00
55d43a1a20
bump version to 0.1.2
2026-07-16 22:46:09 -06:00
c4f34c8882
Merge pull request 'endorser-authentication' ( #2 ) from endorser-authentication into master
...
Reviewed-on: #2
2026-07-16 12:32:40 +00:00
Jose Olarte III
9634c3422e
docs: document Endorser auth flow and ENDORSER_URL
...
Describe when register/refresh verify with Endorser, keep the testMode bypass notes, and list ENDORSER_URL in the env table.
2026-07-10 21:09:22 +08:00
Jose Olarte III
2343cece5c
fix(auth): distinguish Endorser unavailability from auth rejection
...
Return 503 when Endorser cannot be reached and keep 401 for rejected JWTs, with clearer server-side diagnostics and generic client messages.
2026-07-10 19:06:40 +08:00
Jose Olarte III
f2f0732ef5
feat(auth): share Endorser verification across register and refresh
...
Extract requireEndorserAuth middleware and apply it to /notifications/refresh so both endpoints use the same check while keeping the local test bypass.
2026-07-10 18:58:52 +08:00
Jose Olarte III
764c89c071
feat(auth): require Endorser verification on device registration
...
Gate /notifications/register on Endorser JWT acceptance while leaving the local testMode bypass unchanged.
2026-07-10 18:44:35 +08:00
Jose Olarte III
e5415280bd
feat(endorser): add client helper to check JWT via rateLimits
...
Introduce checkAuth so callers can verify Endorser acceptance of a JWT without dealing with HTTP details.
2026-07-10 18:05:16 +08:00
Jose Olarte III
0758c4192f
feat(config): add ENDORSER_URL for upcoming Endorser auth
...
Expose the Endorser API base URL from the environment (defaulting to production) so later auth work can call it without hardcoding.
2026-07-10 16:09:57 +08:00
Jose Olarte III
fcf3fb9aa0
chore: ignore .DS_Store files
2026-07-02 17:14:11 +08:00
a99117dc98
bump to v 0.1.1, change default port to 3003, fix Dockerfile to build & run separately
2026-06-28 17:29:21 -06:00
85301135c7
fix type errors
2026-06-28 17:28:54 -06:00
Jose Olarte III
7a2bb88207
feat(config): load .env and log Firebase credential source at startup
...
Add dotenv via src/env.ts so dev/start read .env before Firebase init,
and log whether credentials come from FIREBASE_SERVICE_ACCOUNT_JSON or ADC.
2026-06-11 17:50:16 +08:00
Jose Olarte III
6261f1baa0
feat(debug): allow local testMode auth on send-wakeup
...
Move requireAuthOrNotificationLocalTest into shared auth middleware and
apply it only to POST /debug/send-wakeup so local testing matches
register/refresh without changing JWT-authenticated behavior.
2026-06-11 17:24:06 +08:00
bb0927ad92
Merge pull request 'Dockerize' ( #1 ) from docker into master
...
Reviewed-on: #1
2026-06-06 01:31:52 +00:00
2dba6c3597
Merge branch 'master' into docker
2026-06-05 19:30:50 -06:00
Jose Olarte III
6ba7d678c6
feat(notifications): allow local debug register/refresh without JWT
...
When the Notification Debug Panel sends testMode: true and omits
Authorization, skip requireAuth on /notifications/register and /refresh
and scope devices under a synthetic local-test user id. Requests with
a Bearer token or without testMode still use full JWT auth unchanged.
2026-06-04 20:32:18 +08:00
Jose Olarte III
dffb86007e
fix(cors): enable preflight for Capacitor WebView requests
...
Add express cors middleware with reflected origin so Android clients
from https://localhost receive Access-Control-Allow-* headers on
OPTIONS and can proceed with POST requests.
2026-06-04 18:26:22 +08:00
a2e5fa0ab9
fix the pnpm build -- 'docker build' now works
2026-06-02 20:37:29 -06:00
c010c861b4
attempt a Docker file but it fails on step 5
2026-05-27 20:37:33 -06:00
df442df869
add a README.md with basics, and target pnpm instead of npm
2026-05-27 20:02:24 -06:00
Jose Olarte III
03ebe03021
chore: add .env.example for local setup
...
Document PORT, Firebase credentials, FCM token data dir, and test-local
NODE_ENV so developers can copy the file to .env without guessing vars.
2026-05-24 10:25:45 +08:00
Jose Olarte III
f12dd03725
chore(logging): normalize wakeup flow observability with timings and summaries
...
Standardize console prefixes across scheduler, push, refresh, register,
auth, and debug endpoints. Add pass-level scheduler summaries, elapsed-time
logs, and masked-token-only push failure messages while reducing per-device
noise in scheduler loops.
2026-05-21 19:18:28 +08:00
Jose Olarte III
e82c3ae5bc
feat(debug): expose nextEligibleAt and structured send-wakeup results
...
Extend authenticated debug endpoints for local iOS notification testing:
add nextEligibleAt (23h prod / 10m test) to device lookup, return success
and failureReason from send-wakeup with masked tokens only, reuse
resolveOwnedDevice for ownership checks, and standardize [DebugEndpoint] logs.
2026-05-21 18:23:50 +08:00
Jose Olarte III
9764b30aed
fix(auth): harden refresh ownership and scheduler after auth migration
...
Restore /health to { ok: true }. Scope refresh to owned devices via
deviceId/fcmToken, improve register upsert logging, skip legacy rows in
the scheduler with per-token dedupe, and prefer non-legacy rows for push.
2026-05-19 19:53:21 +08:00
Jose Olarte III
afbc2e9a57
feat(debug): harden debug routes with auth and user-scoped token access
...
Add GET /debug/device/:token and POST /debug/send-wakeup behind requireAuth,
scope lookups to the authenticated user (404 otherwise), and mask FCM tokens
in logs via maskToken. Mark routes for further restriction before production.
2026-05-19 19:42:22 +08:00
Jose Olarte III
8e502a2335
feat(notifications): bind device registrations to authenticated user DID
...
Scope register and refresh to verified JWT identity (req.did). Persist
devices under userId::deviceId, reject client-supplied userId, and dedupe
FCM tokens per user.
2026-05-19 19:02:42 +08:00
Jose Olarte III
4bf57d26fd
Add Bearer JWT auth middleware for notification routes
...
Mirror image-api’s DID JWT verification (src/vc + requireAuth) so
/notifications/* require a valid Authorization header while /health
stays public. Attach req.did, req.jwt, and req.auth for downstream use.
2026-05-19 18:23:41 +08:00
Jose Olarte III
fc0cad4f2e
feat(register): key devices by deviceId and replace FCM tokens in place
...
Require deviceId on POST /notifications/register, upsert by deviceId
while preserving lastNotifiedAt and internal id, prune duplicate token
rows, migrate legacy fcmToken-keyed JSON, and add register logs.
Extend StoredRow and Device with deviceId; resolve pushes by scanning
fcmToken.
2026-05-12 21:44:59 +08:00
Jose Olarte III
e92ddb7da9
chore(obs): add lightweight console logs for scheduler and push
...
Log scheduler ticks, refresh requests, dedupe skips by device id,
push attempt/success with token hints, and push failures without
extra sensitive fields.
2026-05-12 18:41:41 +08:00
Jose Olarte III
86d589d0e8
feat(db): track last push time by device id with numeric timestamps
...
Assign stable ids to stored tokens, migrate legacy ISO lastNotifiedAt
to epoch ms, replace setLastNotifiedAt with db.update, and persist
lastNotifiedAt only after a successful FCM send. Extend Device with
optional lastNotifiedAt (ms).
2026-05-11 21:23:10 +08:00
Jose Olarte III
096f393df9
feat(scheduler): run wake pushes every five minutes
...
Add db.getAll for registered tokens and tick the interval with
sendPushToDevice per device, with error logging on tick failure.
2026-05-11 18:35:45 +08:00
Jose Olarte III
a5266615eb
feat(push): send silent iOS wakeups via FCM APNs background
...
Use apns-push-type background, priority 5, contentAvailable-only aps
payload, and WAKEUP_PING data without alert or sound.
2026-05-11 17:09:01 +08:00
Jose Olarte III
1115929437
feat(push): dedupe FCM sends with 23h / 10m windows
...
Track lastNotifiedAt on stored tokens, preserve it on register upsert,
and skip messaging.send when inside the production or test-mode window.
2026-05-11 16:56:07 +08:00
Jose Olarte III
2b57ec0e1c
feat(notifications): add POST /refresh schedule response
...
Return shouldNotify and nextNotifications with a 10-minute lookahead
timestamp for the app schedule API.
2026-05-11 15:59:26 +08:00
Jose Olarte III
64ea7d2f98
feat(notifications): persist FCM tokens on POST /register
...
Add JSON-backed upsert store (data/fcm-tokens.json, optional
FCM_TOKEN_DATA_DIR), validate body fields, and gitignore data/.
2026-05-11 14:52:09 +08:00
Jose Olarte III
d311b6a504
feat(fcm): add Firebase Admin SDK and messaging export
...
Wire firebase-admin with ADC or FIREBASE_SERVICE_ACCOUNT_JSON,
export messaging from src/services/firebase.ts, and load it at
server startup.
2026-05-11 14:47:05 +08:00
Jose Olarte III
94c38bac74
feat(backend): scaffold Express API with health and module layout
...
Add src/routes/notifications, services/pushService, models/device,
scheduler stubs, and entrypoint with GET /health and startup log.
2026-05-11 14:33:32 +08:00