diff --git a/functions/package-lock.json b/functions/package-lock.json index 9970fa71..c1340be2 100644 --- a/functions/package-lock.json +++ b/functions/package-lock.json @@ -373,101 +373,11 @@ "node": ">=6" } }, - "node_modules/@isaacs/cliui": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", - "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", - "license": "ISC", - "dependencies": { - "string-width": "^5.1.2", - "string-width-cjs": "npm:string-width@^4.2.0", - "strip-ansi": "^7.0.1", - "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", - "wrap-ansi": "^8.1.0", - "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/@isaacs/cliui/node_modules/ansi-regex": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.4.0.tgz", - "integrity": "sha512-KzTVk2tCWAHtYrvvvaP8bJKJq2pVinhLcGEQdtLIYPbmNGNyYe8QwNaTUYQp2J7/vIsUKt5QCqAfUkYyG9DkOw==", - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-regex?sponsor=1" - } - }, - "node_modules/@isaacs/cliui/node_modules/ansi-styles": { - "version": "6.2.3", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.3.tgz", - "integrity": "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==", - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/@isaacs/cliui/node_modules/emoji-regex": { - "version": "9.2.2", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", - "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", - "license": "MIT" - }, - "node_modules/@isaacs/cliui/node_modules/string-width": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", - "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", - "license": "MIT", - "dependencies": { - "eastasianwidth": "^0.2.0", - "emoji-regex": "^9.2.2", - "strip-ansi": "^7.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/@isaacs/cliui/node_modules/strip-ansi": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz", - "integrity": "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==", - "license": "MIT", - "dependencies": { - "ansi-regex": "^6.2.2" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/strip-ansi?sponsor=1" - } - }, - "node_modules/@isaacs/cliui/node_modules/wrap-ansi": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", - "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", - "license": "MIT", - "dependencies": { - "ansi-styles": "^6.1.0", - "string-width": "^5.0.1", - "strip-ansi": "^7.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } + "node_modules/@isaacs/nonrecursive-glob-match": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@isaacs/nonrecursive-glob-match/-/nonrecursive-glob-match-1.1.0.tgz", + "integrity": "sha512-GPm/Dbvk5RLmhRnxXIa7nTpK0xtl4E0wj0MslsuNiJ1FIROU+2+9lgUC/dgF7Ey4QCWhfEsgxilMRMCdHPfDfw==", + "license": "BlueOak-1.0.0" }, "node_modules/@js-sdsl/ordered-map": { "version": "4.4.2", @@ -501,16 +411,6 @@ "node": ">=8.0.0" } }, - "node_modules/@pkgjs/parseargs": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", - "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", - "license": "MIT", - "optional": true, - "engines": { - "node": ">=14" - } - }, "node_modules/@protobufjs/aspromise": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz", @@ -764,10 +664,13 @@ } }, "node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "license": "MIT" + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", + "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", + "license": "MIT", + "engines": { + "node": "18 || 20 || >=22" + } }, "node_modules/base64-js": { "version": "1.5.1", @@ -823,12 +726,15 @@ } }, "node_modules/brace-expansion": { - "version": "2.1.7", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.7.tgz", - "integrity": "sha512-uZbew1NqdmPDTMJ8ah1y+b+9QEJrfkXFk3RcTQw3X0jW/xRUvFKsg1CfQdSYGdTbXZWExtU3J3ccxtnfw1Fi0g==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.1.0.tgz", + "integrity": "sha512-aa11Dv491GKnYqxaul3aRJ0szew7yMJMfZPnqD44NjGrZXoj62l41OEDDpdpC4eE2P88vBFfLuSyRhpG91NUvg==", "license": "MIT", "dependencies": { - "balanced-match": "^1.0.0" + "balanced-match": "^4.0.2" + }, + "engines": { + "node": "20 || >=22" } }, "node_modules/buffer-equal-constant-time": { @@ -968,20 +874,6 @@ "url": "https://opencollective.com/express" } }, - "node_modules/cross-spawn": { - "version": "7.0.6", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", - "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", - "license": "MIT", - "dependencies": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - }, - "engines": { - "node": ">= 8" - } - }, "node_modules/data-uri-to-buffer": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", @@ -1043,12 +935,6 @@ "stream-shift": "^1.0.2" } }, - "node_modules/eastasianwidth": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", - "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", - "license": "MIT" - }, "node_modules/ecdsa-sig-formatter": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", @@ -1208,9 +1094,9 @@ "license": "MIT" }, "node_modules/fast-xml-builder": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/fast-xml-builder/-/fast-xml-builder-1.3.1.tgz", - "integrity": "sha512-pIM/1n3ntFXKYrUZwW7QCK0gAW7XY+wzj1YMIV3tLDvPj/V+zTGJK5e3/4WJfwj0qWw2ElNXiTixda/R+3YSug==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/fast-xml-builder/-/fast-xml-builder-1.3.2.tgz", + "integrity": "sha512-OX91VSlShLPDgRZV7tk/YQ4l8tT75QziF5Ixg8g4PFbCVPjuTWwN+yQfAxLJ0dufJpprdOd6HlM74Jhd39TcBQ==", "funding": [ { "type": "github", @@ -1225,9 +1111,9 @@ } }, "node_modules/fast-xml-parser": { - "version": "5.11.2", - "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-5.11.2.tgz", - "integrity": "sha512-R9iDuNrQYeQut46cn2r2wHKn4HYzVDvDm5J1wW+koZewykv0yuO2HChTYeZtrULyHIDM9cj9TUXloCsueCQUog==", + "version": "5.12.1", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-5.12.1.tgz", + "integrity": "sha512-wR8dO/fx+z8C5exuem1e7BKOWvjsuzvjS/tvA/Xu3Z1zQqJGcXrPzXbcAiaMgp2KjreEROcTkmnnisrcmJ2hYQ==", "funding": [ { "type": "github", @@ -1237,11 +1123,11 @@ "license": "MIT", "optional": true, "dependencies": { - "@nodable/entities": "^3.0.1", - "fast-xml-builder": "^1.2.0", - "is-unsafe": "^2.0.0", + "@nodable/entities": "^3.1.0", + "fast-xml-builder": "^1.3.2", + "is-unsafe": "^2.0.3", "path-expression-matcher": "^1.6.2", - "strnum": "^2.4.2", + "strnum": "^2.5.1", "xml-naming": "^0.3.0" }, "bin": { @@ -1362,22 +1248,6 @@ } } }, - "node_modules/foreground-child": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.1.tgz", - "integrity": "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==", - "license": "ISC", - "dependencies": { - "cross-spawn": "^7.0.6", - "signal-exit": "^4.0.1" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/formdata-polyfill": { "version": "4.0.10", "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", @@ -1498,21 +1368,17 @@ } }, "node_modules/glob": { - "version": "10.5.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.5.0.tgz", - "integrity": "sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==", - "deprecated": "Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me", - "license": "ISC", + "version": "14.0.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-14.0.6.tgz", + "integrity": "sha512-OwXjVP2svY5EyLY75Vek96C8qK43gqrt4xsZ+qSILdnaEiJPXkd62mcfUSNx/TQErQRdu5uM5kF67sfONragKw==", + "license": "BlueOak-1.0.0", "dependencies": { - "foreground-child": "^3.1.0", - "jackspeak": "^3.1.2", - "minimatch": "^9.0.4", - "minipass": "^7.1.2", - "package-json-from-dist": "^1.0.0", - "path-scurry": "^1.11.1" + "minimatch": "^11.0.5", + "minipass": "^7.1.3", + "path-scurry": "^3.0.0" }, - "bin": { - "glob": "dist/esm/bin.mjs" + "engines": { + "node": "18 || 20 || >=22" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -1731,9 +1597,9 @@ "license": "MIT" }, "node_modules/is-unsafe": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/is-unsafe/-/is-unsafe-2.0.2.tgz", - "integrity": "sha512-HgbIHPBH0KHHCcjLfGsCvhtPTVxjaAZlXjwdz7/GQC40SjSe4sfQsar8J5VFo8JOSbarkpV0OLG95bbaNd9aAQ==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-unsafe/-/is-unsafe-2.0.3.tgz", + "integrity": "sha512-ZBllczCCO267vgdFb6Tq3pv+LhHaCiGMdr+ZsuL+OopruAg7S+3ZDs1vD0RPC0uSrkjzbraxaGjtX1YBxjPeFQ==", "funding": [ { "type": "github", @@ -1743,27 +1609,6 @@ "license": "MIT", "optional": true }, - "node_modules/isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", - "license": "ISC" - }, - "node_modules/jackspeak": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz", - "integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==", - "license": "BlueOak-1.0.0", - "dependencies": { - "@isaacs/cliui": "^8.0.2" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - }, - "optionalDependencies": { - "@pkgjs/parseargs": "^0.11.0" - } - }, "node_modules/jose": { "version": "6.2.12", "resolved": "https://registry.npmjs.org/jose/-/jose-6.2.12.tgz", @@ -1999,15 +1844,16 @@ } }, "node_modules/minimatch": { - "version": "9.0.9", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.9.tgz", - "integrity": "sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg==", - "license": "ISC", + "version": "11.0.9", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-11.0.9.tgz", + "integrity": "sha512-KCFkfyjqerNlSstjlhIGNXIKZGA/6O4V4RlhZ+Dsr621SPPw0mzlypE9D9ZOoPiVefHID+j7/XuMMlqfD/F60Q==", + "license": "BlueOak-1.0.0", "dependencies": { - "brace-expansion": "^2.0.2" + "@isaacs/nonrecursive-glob-match": "^1.1.0", + "brace-expansion": "^5.0.12" }, "engines": { - "node": ">=16 || 14 >=14.17" + "node": "20 || >=22" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -2149,12 +1995,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/package-json-from-dist": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", - "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==", - "license": "BlueOak-1.0.0" - }, "node_modules/parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", @@ -2180,37 +2020,22 @@ "node": ">=14.0.0" } }, - "node_modules/path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "license": "MIT", - "engines": { - "node": ">=8" - } - }, "node_modules/path-scurry": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", - "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-3.0.0.tgz", + "integrity": "sha512-1pTbQqH1wIwMi/eleQ5leFTTCkzFsPcgXNjwOA8YGGW/W4/kHT3dssE7Z6NH+zuqNLOzOB0uaD61yl7cAcVhgg==", "license": "BlueOak-1.0.0", "dependencies": { - "lru-cache": "^10.2.0", - "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" + "lru-cache": "^11.0.0", + "minipass": "^7.1.2" }, "engines": { - "node": ">=16 || 14 >=14.18" + "node": "18 || 20 || >=22" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/path-scurry/node_modules/lru-cache": { - "version": "10.4.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", - "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", - "license": "ISC" - }, "node_modules/path-to-regexp": { "version": "8.4.2", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.4.2.tgz", @@ -2482,27 +2307,6 @@ "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", "license": "ISC" }, - "node_modules/shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "license": "MIT", - "dependencies": { - "shebang-regex": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "license": "MIT", - "engines": { - "node": ">=8" - } - }, "node_modules/side-channel": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.1.tgz", @@ -2575,18 +2379,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/signal-exit": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", - "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", - "license": "ISC", - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/statuses": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", @@ -2634,21 +2426,6 @@ "node": ">=8" } }, - "node_modules/string-width-cjs": { - "name": "string-width", - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "license": "MIT", - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", @@ -2661,19 +2438,6 @@ "node": ">=8" } }, - "node_modules/strip-ansi-cjs": { - "name": "strip-ansi", - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "license": "MIT", - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/strnum": { "version": "2.5.1", "resolved": "https://registry.npmjs.org/strnum/-/strnum-2.5.1.tgz", @@ -2807,21 +2571,6 @@ "node": ">=0.8.0" } }, - "node_modules/which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "license": "ISC", - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "node-which": "bin/node-which" - }, - "engines": { - "node": ">= 8" - } - }, "node_modules/wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", @@ -2839,24 +2588,6 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, - "node_modules/wrap-ansi-cjs": { - "name": "wrap-ansi", - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "license": "MIT", - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", @@ -2864,9 +2595,9 @@ "license": "ISC" }, "node_modules/xml-naming": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/xml-naming/-/xml-naming-0.3.0.tgz", - "integrity": "sha512-ghig2TBE/H11aOVgmahA3MhimvkBr6JIYknH/Dhdk10nXwdbIqBJsbfMxpvFPG8bAw77gN29aQWvKpmVoPlvPQ==", + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/xml-naming/-/xml-naming-0.3.1.tgz", + "integrity": "sha512-EJ9yNAfjrIz2z7chbVlj4CD3HkPxXNPD6U6LzhKEfIFlRmEHtl7CN6C0qdPGL4hplTuj2wePPgIZN8aklE/2Og==", "funding": [ { "type": "github", diff --git a/functions/package.json b/functions/package.json index fb97cf5e..ea103741 100644 --- a/functions/package.json +++ b/functions/package.json @@ -8,5 +8,9 @@ "@google-cloud/firestore": "^9.3.1", "firebase-admin": "^14.5.0", "firebase-functions": "^7.4.0" + }, + "overrides": { + "glob": "^14.0.2", + "fast-xml-parser": "^5.12.0" } } diff --git a/public/js/admin.js b/public/js/admin.js index 06a66141..80452815 100644 --- a/public/js/admin.js +++ b/public/js/admin.js @@ -107,6 +107,12 @@ export async function renderAdmin(main, user) {

Requests from the Deck's Plans page. Granting sets the user's plan tier.

Loading requests…

+
+

Account deletion requests

+
+

Filed before users could delete their own account. Delete runs the same full deletion a user starts in Settings; only accounts that asked are listed.

+

Loading requests…

+

Feedback & bug reports

@@ -483,6 +489,36 @@ export async function renderAdmin(main, user) { }; loadUpgradeRequests(); + // ---- account deletion requests (Worker /api/admin/deletions, service account) ---- + async function loadDeletionRequests() { + const host = $("#delReqList"); if (!host) return; + try { + const { api } = await import("/js/core/api.js"); + const r = await api("/api/admin/deletions"); + const items = (r && r.requests) || []; + if (!items.length) { host.innerHTML = `

No pending deletion requests.

`; return; } + host.innerHTML = items.map((x) => ` +
+
${esc(x.email || x.uid)} + ${x.requestedAt ? esc(new Date(x.requestedAt).toLocaleString()) : ""} +
+
`).join(""); + } catch (e) { host.innerHTML = `

Couldn't load deletion requests: ${esc(e.message)}

`; } + } + $("#delReqRefresh").onclick = loadDeletionRequests; + $("#delReqList").onclick = async (e) => { + const btn = e.target.closest(".dr-del"); if (!btn) return; + const row = btn.closest(".fb-row"), uid = row.dataset.uid, who = row.dataset.email || uid; + if (!(await window.dnConfirm("Delete " + who + "?", "This permanently deletes the account and everything stored with it, as the user asked. It cannot be undone.", { submitText: "Delete account", danger: true }))) return; + btn.disabled = true; + try { + const { api } = await import("/js/core/api.js"); + await api("/api/admin/deletions", { method: "POST", body: { uid } }); + window.showToast("Deleted " + who, "success"); row.remove(); + } catch (err) { btn.disabled = false; window.showToast(err.message || "Delete failed", "error"); } + }; + loadDeletionRequests(); + // ---- client error log ---- async function loadErrors() { const host = $("#errAdminList"); if (!host) return; diff --git a/public/js/deck-ui.js b/public/js/deck-ui.js index 2a9aac08..83f2f52f 100644 --- a/public/js/deck-ui.js +++ b/public/js/deck-ui.js @@ -4544,6 +4544,10 @@ export function renderDeck(host, opts) {

${IC.folder} Data

+ ${noAccount ? "" : `
+
Your account data
Everything Darknode's servers hold about you: account, settings, notifications, requests you sent, workspaces, monitors and API keys (secrets left out), as one JSON file.
+ +
`}
Deck state
Connections, pinned tools and notes (no API keys), as a JSON file you can re-import.
@@ -4599,6 +4603,20 @@ export function renderDeck(host, opts) { el.querySelector("#dkSetPlans").onclick = () => go("plans"); const setSu = el.querySelector("#dkSetSignup"); if (setSu) setSu.onclick = toSignup; el.querySelector("#dkSetExport").onclick = () => exportDeckState(); + const acctExp = el.querySelector("#dkSetAcctExp"); + if (acctExp) acctExp.onclick = async () => { + acctExp.disabled = true; const was = acctExp.textContent; acctExp.textContent = "Preparing…"; + try { + const { api } = await import("/js/core/api.js"); + const data = await api("/api/account/export"); + const a = document.createElement("a"); + a.href = URL.createObjectURL(new Blob([JSON.stringify(data, null, 2)], { type: "application/json" })); + a.download = "darknode-account-" + new Date().toISOString().slice(0, 10) + ".json"; + document.body.appendChild(a); a.click(); setTimeout(() => { URL.revokeObjectURL(a.href); a.remove(); }, 1000); + toast("Account data downloaded"); + } catch (e) { toast((e && e.message) || "Couldn't export your account data.", "error"); } + finally { acctExp.disabled = false; acctExp.textContent = was; } + }; el.querySelector("#dkSetImport").onclick = () => importDeckState(); const syncPlanBtn = el.querySelector("#dkSetSyncPlan"); if (syncPlanBtn) syncPlanBtn.onclick = () => { toast("Cloud sync is part of the Pro plan"); go("plans"); }; diff --git a/public/js/legal.js b/public/js/legal.js index 075997be..019d3fe8 100644 --- a/public/js/legal.js +++ b/public/js/legal.js @@ -85,7 +85,7 @@ export const TOS_HTML = `
  • Cookies: we use only essential cookies and localStorage for session management and user preferences. We do not use tracking cookies or third-party analytics.
  • International transfers: data is processed and stored in Google Cloud data centers. By using the Platform, you consent to transfer of data to servers that may be outside your country of residence.
  • -

    Your rights (GDPR, CCPA, and similar laws): depending on your jurisdiction, you may have the right to access, correct, delete, or export your personal data, restrict processing, object to processing, or withdraw consent. You can export your Deck state and security graph and delete your account yourself in the Deck under Settings, Data. To exercise any other right, email contact@darknode.ai. We will respond within 30 days. You also have the right to lodge a complaint with your local data protection authority.

    +

    Your rights (GDPR, CCPA, and similar laws): depending on your jurisdiction, you may have the right to access, correct, delete, or export your personal data, restrict processing, object to processing, or withdraw consent. You can download everything our servers hold about you, export your Deck state and security graph, and delete your account yourself in the Deck under Settings, Data. To exercise any other right, email contact@darknode.ai. We will respond within 30 days. You also have the right to lodge a complaint with your local data protection authority.

    15. Account Termination

    By you: you may stop using the Platform and delete your account at any time in the Deck under Settings, Data, Delete account (or by emailing contact@darknode.ai). Deletion removes your account and its stored data at once, including any team workspace you hold alone; while a team workspace you created still has other members, remove them first. Data is otherwise removed in accordance with Section 14.

    diff --git a/test/worker/account-delete.test.mjs b/test/worker/account-delete.test.mjs index 423c3052..92435514 100644 --- a/test/worker/account-delete.test.mjs +++ b/test/worker/account-delete.test.mjs @@ -1,7 +1,7 @@ // Unit tests for worker/account-delete.js: self-service account deletion. Firestore REST and // Firebase Auth are an in-memory stand-in behind a fake fetch; Durable Objects are stubs. import { test, group, assert } from "../harness.mjs"; -import { handleAccountDelete, recentEnough, maybeWipe, RECENT_S } from "../../worker/account-delete.js"; +import { handleAccountDelete, handleAccountExport, handleAdminDeletions, recentEnough, maybeWipe, plain, RECENT_S } from "../../worker/account-delete.js"; import { matchRoute, authorize } from "../../worker/auth.js"; const json = (body, status = 200) => ({ status, body }); @@ -16,7 +16,8 @@ function fakeCloud(docs) { const doc = (path) => ({ name: "projects/p/databases/(default)/documents/" + path, fields: db.get(path) }); const fetch = async (url, init = {}) => { const m = init.method || "GET"; - if (url.endsWith("/accounts:delete")) { authDeleted.push(JSON.parse(init.body).localId); return res(200, {}); } + if (url.endsWith("/accounts:delete")) { if (cloud.authFails) return res(500, {}); authDeleted.push(JSON.parse(init.body).localId); return res(200, {}); } + if (url.endsWith("/accounts:lookup")) return res(200, { users: [{ localId: "u1", email: "test@darknode.ai", emailVerified: true, providerUserInfo: [{ providerId: "password" }], createdAt: "1793404800000" }] }); if (url === ROOT + ":runQuery") { const q = JSON.parse(init.body).structuredQuery, from = q.from[0], ff = q.where.fieldFilter; const hits = [...db.keys()].filter((p) => { @@ -40,12 +41,15 @@ function fakeCloud(docs) { } return db.has(path) ? res(200, doc(path)) : res(404, {}); }; - return { db, fetch, authDeleted }; + const cloud = { db, fetch, authDeleted, authFails: false }; + return cloud; } function fakeDOs() { const wiped = []; - const ns = (kind) => ({ idFromName: (n) => n, get: (id) => ({ fetch: async (u, init) => { assert.equal(u, "https://do/__wipe"); assert.equal(init.headers["x-dn-wipe"], "1"); wiped.push(kind + ":" + id); return { ok: true, status: 200 }; } }) }); + const ns = (kind) => ({ idFromName: (n) => n, get: (id) => ({ fetch: async (u, init) => { + if (u === "https://do/") { const op = JSON.parse(init.body).op; return { ok: true, status: 200, json: async () => kind === "monitor" ? (op === "list" ? { monitors: [{ id: "m1", target: "example.com", wid: id }], history: [] } : { deadlines: [] }) : { keys: [{ keyId: "k1", prefix: "dk_ab", scopes: ["ingest:write"] }] } }; } + assert.equal(u, "https://do/__wipe"); assert.equal(init.headers["x-dn-wipe"], "1"); wiped.push(kind + ":" + id); return { ok: true, status: 200 }; } }) }); return { wiped, env: { FIREBASE_PROJECT_ID: "p", GRAPH: ns("graph"), MONITOR: ns("monitor"), INGEST: ns("ingest"), VAULT: ns("vault") } }; } @@ -143,4 +147,52 @@ group("account-delete", () => { const r = await maybeWipe(mk("/__wipe", { "x-dn-wipe": "1" }), storage); assert.equal(r.status, 200); assert.deepEqual(calls, ["alarm", "all"]); }); + + test("export: the caller's own records, secrets redacted, other people's left out", async () => { + const cloud = fakeCloud({ + "users/u1": { email: "test@darknode.ai", tier: "free" }, "users/u1/notifications/n1": { text: "hi" }, + "users/u2": { email: "other@darknode.ai" }, "pairings/c1": { uid: "u1", apiKey: "dk_secret" }, "pairings/c2": { uid: "u2" }, + "feedback/f1": { uid: "u1", message: "nice" }, "waitlist/w1": { email: "test@darknode.ai" }, + "workspaces/team0000000000000000": { createdBy: "u2", name: "Team" }, "workspaces/team0000000000000000/members/u1": { uid: "u1", role: "analyst" }, + }), dos = fakeDOs(); + const r = await handleAccountExport({ method: "GET" }, dos.env, json, me(), { fetch: cloud.fetch, token: async () => "t" }); + assert.equal(r.status, 200, JSON.stringify(r.body)); + const b = r.body; + assert.equal(b.account.email, "test@darknode.ai"); assert.deepEqual(b.account.signInMethods, ["password"]); + assert.equal(b.profile.tier, "free"); + assert.deepEqual(b.profileCollections.notifications, [{ id: "n1", text: "hi" }]); + assert.deepEqual(b.records.pairings, [{ id: "c1", uid: "u1", apiKey: "[redacted]" }]); + assert.equal(b.records.feedback.length, 1); assert.equal(b.records.waitlist.length, 1); + assert.deepEqual(b.memberships, [{ kind: "workspace", id: "team0000000000000000", name: "Team", role: "analyst", createdByYou: false }]); + assert.equal(b.personalWorkspace.monitors[0].target, "example.com"); assert.equal(b.personalWorkspace.apiKeys[0].keyId, "k1"); + assert.ok(!JSON.stringify(b).includes("other@darknode.ai")); + assert.equal(cloud.db.size, 9); // nothing was changed + }); + + test("export decodes every Firestore value type", () => { + assert.deepEqual(plain({ mapValue: { fields: { a: { integerValue: "3" }, b: { arrayValue: { values: [{ booleanValue: true }, { nullValue: null }] } }, t: { timestampValue: "2026-11-27T00:00:00Z" } } } }), + { a: 3, b: [true, null], t: "2026-11-27T00:00:00Z" }); + }); + + test("admin deletions: owner only; lists requests; deletes only accounts that asked", async () => { + const route = matchRoute("/api/admin/deletions", "POST").route; + assert.equal(authorize(route, { kind: "user", claims: {} }).status, 403); + assert.equal(authorize(route, { kind: "user", claims: { admin: true } }), null); + const cloud = fakeCloud({ "deletionRequests/u1": { uid: "u1", email: "test@darknode.ai" }, "users/u1": {}, "users/u2": {}, "waitlist/w1": { email: "test@darknode.ai" } }), dos = fakeDOs(); + const o = { fetch: cloud.fetch, token: async () => "t" }; + const list = await handleAdminDeletions({ method: "GET" }, dos.env, json, o); + assert.deepEqual(list.body.requests.map((x) => [x.uid, x.email]), [["u1", "test@darknode.ai"]]); + const no = await handleAdminDeletions(req({ uid: "u2" }), dos.env, json, o); + assert.equal(no.status, 404); assert.ok(cloud.db.has("users/u2")); + const yes = await handleAdminDeletions(req({ uid: "u1" }), dos.env, json, o); + assert.equal(yes.status, 200); + assert.deepEqual([...cloud.db.keys()], ["users/u2"]); assert.deepEqual(cloud.authDeleted, ["u1"]); + }); + + test("admin deletions: if the sign-in delete fails the request stays, so it can be retried", async () => { + const cloud = fakeCloud({ "deletionRequests/u1": { uid: "u1", email: "" }, "users/u1": {} }), dos = fakeDOs(); + cloud.authFails = true; + const r = await handleAdminDeletions(req({ uid: "u1" }), dos.env, json, { fetch: cloud.fetch, token: async () => "t" }); + assert.equal(r.status, 502); assert.ok(cloud.db.has("deletionRequests/u1")); + }); }); diff --git a/worker/account-delete.js b/worker/account-delete.js index 01f52afb..ebe20c85 100644 --- a/worker/account-delete.js +++ b/worker/account-delete.js @@ -24,7 +24,7 @@ export const OWNED_BY_FIELD = [ ["feedback", "uid"], ["errors", "uid"], ["ip_reports", "reporter_uid"], ]; // Docs keyed by the user's uid. -export const KEYED_BY_UID = ["usage", "deletionRequests"]; +export const KEYED_BY_UID = ["usage"]; // deletionRequests/{uid} goes last, after the sign-in export function recentEnough(claims, now = Math.floor(Date.now() / 1000)) { const t = Number(claims && claims.auth_time); @@ -120,6 +120,42 @@ export async function maybeWipe(request, storage) { return new Response('{"ok":true}', { headers: { "Content-Type": "application/json" } }); } +// Delete one account everywhere. -> { ok: true } | { blocking: [...] }; throws on a failed step. +export async function deleteAccountData(env, fs, token, uid, email, doFetch = fetch) { + const mine = await memberships(fs, uid); + const blocking = mine.filter((m) => m.founder && m.others > 0); + if (blocking.length) return { blocking: blocking.map((b) => ({ kind: b.kind === "vaults" ? "vault" : "workspace", id: b.id, name: b.name, members: b.others })) }; + // personal workspace (wid === uid) and every space they hold alone + await wipeDO(env.GRAPH, uid); await wipeDO(env.MONITOR, uid); await wipeDO(env.INGEST, uid); + for (const m of mine) { + const alone = m.role !== "removed" && m.others === 0 && (m.founder || m.role === "owner"); + if (alone && m.kind === "workspaces") { await wipeDO(env.GRAPH, m.id); await wipeDO(env.MONITOR, m.id); await wipeDO(env.INGEST, m.id); await deleteTree(fs, "workspaces/" + m.id); } + else if (alone && m.kind === "vaults") { await wipeDO(env.VAULT, m.id); await deleteTree(fs, "vaults/" + m.id); } + else await fs.del(m.memberPath); + } + for (const [c, field] of OWNED_BY_FIELD) for (const d of await fs.where(c, field, uid)) await fs.del(d.path); + if (email) for (const d of await fs.where("waitlist", "email", email)) await fs.del(d.path); + for (const c of KEYED_BY_UID) await fs.del(c + "/" + uid); + await deleteTree(fs, "users/" + uid); + const r = await doFetch("https://identitytoolkit.googleapis.com/v1/projects/" + env.FIREBASE_PROJECT_ID + "/accounts:delete", { + method: "POST", headers: { Authorization: "Bearer " + token, "Content-Type": "application/json" }, body: JSON.stringify({ localId: uid }), + }); + if (!r.ok) { + const d = await r.json().catch(() => ({})); + if (!(d && d.error && /USER_NOT_FOUND/.test(d.error.message || ""))) throw new Error("Deleting the sign-in failed (HTTP " + r.status + ")"); + } + await fs.del("deletionRequests/" + uid); + return { ok: true }; +} + +const blockedMsg = (who, blocking) => who + " created " + blocking.map((b) => '"' + b.name + '"').join(", ") + ", which still " + (blocking.length > 1 ? "have" : "has") + " other members. Remove them first, then delete the account."; +const failedMsg = (e) => (e && e.message ? e.message : "Deletion failed") + ". Part of the account may already be deleted; try again to finish."; + +async function serviceFs(env, opts) { + const token = await (opts.token || googleToken)(env); + return { token, fs: firestore(env, token, opts.fetch || fetch) }; +} + export async function handleAccountDelete(request, env, json, principal, opts = {}) { if (request.method !== "POST") return json({ error: "POST only" }, 405); if (!env.FIREBASE_PROJECT_ID) return json({ error: "FIREBASE_PROJECT_ID is not set" }, 503); @@ -128,44 +164,98 @@ export async function handleAccountDelete(request, env, json, principal, opts = let body = {}; try { body = await request.json(); } catch (_) {} if (!body || body.confirm !== "DELETE") return json({ error: 'Send {"confirm":"DELETE"} to delete the account.' }, 400); if (!recentEnough(principal.claims, opts.now)) return json({ error: "Sign in again to confirm it's you, then delete.", reauth: true }, 401); - - const doFetch = opts.fetch || fetch; - let token; - try { token = await (opts.token || googleToken)(env); } - catch (e) { return json({ error: "Server credentials unavailable: " + e.message }, 503); } - const fs = firestore(env, token, doFetch); - + let c; try { c = await serviceFs(env, opts); } catch (e) { return json({ error: "Server credentials unavailable: " + e.message }, 503); } try { - const mine = await memberships(fs, uid); - const blocking = mine.filter((m) => m.founder && m.others > 0); - if (blocking.length) { - return json({ - error: "You created " + blocking.map((b) => '"' + b.name + '"').join(", ") + ", which still " + (blocking.length > 1 ? "have" : "has") + " other members. Remove them first, then delete your account.", - blocking: blocking.map((b) => ({ kind: b.kind === "vaults" ? "vault" : "workspace", id: b.id, name: b.name, members: b.others })), - }, 409); - } - // personal workspace (wid === uid) and every space they hold alone - await wipeDO(env.GRAPH, uid); await wipeDO(env.MONITOR, uid); await wipeDO(env.INGEST, uid); - for (const m of mine) { - const alone = m.role !== "removed" && m.others === 0 && (m.founder || m.role === "owner"); - if (alone && m.kind === "workspaces") { await wipeDO(env.GRAPH, m.id); await wipeDO(env.MONITOR, m.id); await wipeDO(env.INGEST, m.id); await deleteTree(fs, "workspaces/" + m.id); } - else if (alone && m.kind === "vaults") { await wipeDO(env.VAULT, m.id); await deleteTree(fs, "vaults/" + m.id); } - else await fs.del(m.memberPath); - } - for (const [c, field] of OWNED_BY_FIELD) for (const d of await fs.where(c, field, uid)) await fs.del(d.path); - if (principal.email) for (const d of await fs.where("waitlist", "email", principal.email)) await fs.del(d.path); - for (const c of KEYED_BY_UID) await fs.del(c + "/" + uid); - await deleteTree(fs, "users/" + uid); + const r = await deleteAccountData(env, c.fs, c.token, uid, principal.email, opts.fetch || fetch); + if (r.blocking) return json({ error: blockedMsg("You", r.blocking), blocking: r.blocking }, 409); + } catch (e) { return json({ error: failedMsg(e) }, 502); } + return json({ ok: true }); +} - const r = await doFetch("https://identitytoolkit.googleapis.com/v1/projects/" + env.FIREBASE_PROJECT_ID + "/accounts:delete", { - method: "POST", headers: { Authorization: "Bearer " + token, "Content-Type": "application/json" }, body: JSON.stringify({ localId: uid }), - }); - if (!r.ok) { - const d = await r.json().catch(() => ({})); - if (!(d && d.error && /USER_NOT_FOUND/.test(d.error.message || ""))) throw new Error("Deleting the sign-in failed (HTTP " + r.status + ")"); - } - } catch (e) { - return json({ error: (e && e.message ? e.message : "Deletion failed") + ". Part of the account may already be deleted; try again to finish." }, 502); +// GET /api/admin/deletions (owner) pending deletion requests filed before self-service existed +// POST /api/admin/deletions {uid} (owner) carry one out. Only an account that asked (it has a +// deletionRequests/{uid} doc) can be deleted this way. +export async function handleAdminDeletions(request, env, json, opts = {}) { + if (!env.FIREBASE_PROJECT_ID) return json({ error: "FIREBASE_PROJECT_ID is not set" }, 503); + let c; try { c = await serviceFs(env, opts); } catch (e) { return json({ error: "Server credentials unavailable: " + e.message }, 503); } + const { fs, token } = c; + if (request.method === "GET") { + let rows; try { rows = await fs.list("deletionRequests"); } catch (e) { return json({ error: e.message }, 502); } + return json({ requests: rows.map((d) => ({ uid: d.path.split("/")[1], email: fs.val(d.fields.email) || "", requestedAt: (d.fields.requestedAt && d.fields.requestedAt.timestampValue) || "" })) }); } + if (request.method !== "POST") return json({ error: "GET or POST only" }, 405); + let body = {}; try { body = await request.json(); } catch (_) {} + const uid = String((body && body.uid) || ""); + if (!/^[A-Za-z0-9_-]{1,128}$/.test(uid)) return json({ error: "Invalid uid" }, 400); + const req = await fs.get("deletionRequests/" + uid); + if (!req) return json({ error: "This account has not asked to be deleted." }, 404); + try { + const r = await deleteAccountData(env, fs, token, uid, fs.val((req.fields || {}).email) || "", opts.fetch || fetch); + if (r.blocking) return json({ error: blockedMsg("This user", r.blocking), blocking: r.blocking }, 409); + } catch (e) { return json({ error: failedMsg(e) }, 502); } return json({ ok: true }); } + +// ---- export: GET /api/account/export (signed in) ----------------------------------------------- +// Everything the server holds about the caller, as plain JSON (GDPR access/portability). The +// security graph has its own export in the Deck (Settings > Data), so it is pointed to, not copied. +export function plain(v) { + if (!v || typeof v !== "object") return v ?? null; + if ("stringValue" in v) return v.stringValue; + if ("integerValue" in v) return Number(v.integerValue); + if ("doubleValue" in v) return v.doubleValue; + if ("booleanValue" in v) return v.booleanValue; + if ("timestampValue" in v) return v.timestampValue; + if ("nullValue" in v) return null; + if ("referenceValue" in v) return v.referenceValue; + if ("geoPointValue" in v) return v.geoPointValue; + if ("bytesValue" in v) return "[bytes]"; + if ("arrayValue" in v) return (v.arrayValue.values || []).map(plain); + if ("mapValue" in v) return plainFields(v.mapValue.fields || {}); + return null; +} +export const plainFields = (f) => Object.fromEntries(Object.entries(f || {}).map(([k, x]) => [k, plain(x)])); +const SECRET_FIELDS = new Set(["apiKey", "keyHash", "hash", "secret", "token"]); +const redact = (o) => Object.fromEntries(Object.entries(o).map(([k, v]) => [k, SECRET_FIELDS.has(k) ? "[redacted]" : v])); + +async function doList(ns, id, headers, body = { op: "list" }) { + if (!ns) return null; + const r = await ns.get(ns.idFromName(id)).fetch("https://do/", { method: "POST", headers: { "Content-Type": "application/json", ...headers }, body: JSON.stringify(body) }); + return r.ok ? r.json() : null; +} + +export async function handleAccountExport(request, env, json, principal, opts = {}) { + if (request.method !== "GET") return json({ error: "GET only" }, 405); + if (!env.FIREBASE_PROJECT_ID) return json({ error: "FIREBASE_PROJECT_ID is not set" }, 503); + const uid = principal && principal.uid; + if (!uid || principal.kind !== "user") return json({ error: "Sign in required" }, 401); + let c; try { c = await serviceFs(env, opts); } catch (e) { return json({ error: "Server credentials unavailable: " + e.message }, 503); } + const { fs, token } = c, doFetch = opts.fetch || fetch; + try { + const out = { exportedAt: new Date(opts.nowMs || Date.now()).toISOString(), uid }; + const lr = await doFetch("https://identitytoolkit.googleapis.com/v1/projects/" + env.FIREBASE_PROJECT_ID + "/accounts:lookup", { + method: "POST", headers: { Authorization: "Bearer " + token, "Content-Type": "application/json" }, body: JSON.stringify({ localId: [uid] }), + }); + const a = ((lr.ok ? await lr.json().catch(() => ({})) : {}).users || [])[0] || {}; + out.account = { email: a.email || principal.email || "", emailVerified: !!a.emailVerified, name: a.displayName || "", + signInMethods: (a.providerUserInfo || []).map((p) => p.providerId), createdAt: a.createdAt ? new Date(Number(a.createdAt)).toISOString() : null, + lastSignInAt: a.lastLoginAt ? new Date(Number(a.lastLoginAt)).toISOString() : null }; + const prof = await fs.get("users/" + uid); + out.profile = prof ? redact(plainFields(prof.fields)) : null; + out.profileCollections = {}; + for (const col of await fs.subcollections("users/" + uid)) out.profileCollections[col] = (await fs.list("users/" + uid + "/" + col)).map((d) => ({ id: d.path.split("/").pop(), ...redact(plainFields(d.fields)) })); + for (const col of KEYED_BY_UID.concat("deletionRequests")) { const d = await fs.get(col + "/" + uid); out[col] = d ? plainFields(d.fields) : null; } + out.records = {}; + for (const [col, field] of OWNED_BY_FIELD) out.records[col] = (await fs.where(col, field, uid)).map((d) => ({ id: d.path.split("/").pop(), ...redact(plainFields(d.fields)) })); + out.records.waitlist = out.account.email ? (await fs.where("waitlist", "email", out.account.email)).map((d) => ({ id: d.path.split("/").pop(), ...plainFields(d.fields) })) : []; + out.memberships = (await memberships(fs, uid)).map((m) => ({ kind: m.kind === "vaults" ? "vault" : "workspace", id: m.id, name: m.name, role: m.role, createdByYou: m.founder })); + const mon = await doList(env.MONITOR, uid, { "x-mon-uid": uid, "x-mon-role": "owner", "x-mon-wid": uid }); + const dl = await doList(env.MONITOR, uid, { "x-mon-uid": uid, "x-mon-role": "owner", "x-mon-wid": uid }, { op: "deadlines" }); + out.personalWorkspace = { + monitors: mon ? mon.monitors || [] : [], monitorHistory: mon ? mon.history || [] : [], deadlines: dl || null, + apiKeys: ((await doList(env.INGEST, uid, { "x-ing-uid": uid, "x-ing-role": "owner" })) || {}).keys || [], + securityGraph: "Export it in the Deck under Settings, Data, Security graph.", + }; + return json(out); + } catch (e) { return json({ error: "Export failed: " + (e && e.message ? e.message : "unknown error") }, 502); } +} diff --git a/worker/auth.js b/worker/auth.js index 7a3b5f1c..559962b9 100644 --- a/worker/auth.js +++ b/worker/auth.js @@ -31,6 +31,8 @@ export const ROUTES = [ { id: "digest", prefix: "/api/digest/", auth: "user" }, { id: "usage", path: "/api/v1/usage", methods: ["POST"], auth: "user" }, { id: "account-delete", path: "/api/account/delete", methods: ["POST"], auth: "user" }, + { id: "account-export", path: "/api/account/export", methods: ["GET"], auth: "user" }, + { id: "admin-deletions", path: "/api/admin/deletions", methods: ["GET", "POST"], auth: "user", role: "admin" }, { id: "admin-users", path: "/api/admin/users", methods: ["GET"], auth: "user", role: "admin" }, { id: "ingest", prefix: "/api/v1/ingest/", auth: "key", scope: "ingest:write" }, { id: "findings", prefix: "/api/v1/findings/", auth: "key", scope: "findings:read" }, diff --git a/worker/worker.js b/worker/worker.js index d221208e..930c2797 100644 --- a/worker/worker.js +++ b/worker/worker.js @@ -30,7 +30,7 @@ import { GEMINI_MODELS, CLAUDE_PLAN, userTier, planDenied } from "./plan.js"; import { chargeQuota, refundQuota, quotaMessage } from "./quota.js"; import { handleDigest, handleUnsubscribe, runDigest } from "./digest.js"; import { handleAdminUsers } from "./admin-users.js"; -import { handleAccountDelete } from "./account-delete.js"; +import { handleAccountDelete, handleAccountExport, handleAdminDeletions } from "./account-delete.js"; import { handleUsage } from "./usage.js"; export { VaultDO } from "./vault.js"; export { GraphDO } from "./graph.js"; @@ -824,6 +824,8 @@ async function route(request, env, rid) { case "admin-users": return handleAdminUsers(env, json); case "usage": return handleUsage(request, env, json, principal); case "account-delete": return handleAccountDelete(request, env, json, principal); + case "account-export": return handleAccountExport(request, env, json, principal); + case "admin-deletions": return handleAdminDeletions(request, env, json); case "ingest": return handleIngest(request, env, rest, json, "ingest"); case "findings": return handleIngest(request, env, rest, json, "findings"); }