@donotdev/functions 0.0.19 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (292) hide show
  1. package/LICENSE.md +3 -3
  2. package/lib/firebase/auth/getCustomClaims.d.ts +25 -0
  3. package/lib/firebase/auth/getUserAuthStatus.d.ts +29 -0
  4. package/lib/firebase/auth/index.d.ts +12 -0
  5. package/lib/firebase/auth/removeCustomClaims.d.ts +28 -0
  6. package/lib/firebase/auth/setCustomClaims.d.ts +34 -0
  7. package/lib/firebase/baseFunction.d.ts +26 -0
  8. package/lib/firebase/billing/cancelSubscription.d.ts +10 -0
  9. package/lib/firebase/billing/changePlan.d.ts +13 -0
  10. package/lib/firebase/billing/createCheckoutSession.d.ts +21 -0
  11. package/lib/firebase/billing/createCustomerPortal.d.ts +19 -0
  12. package/lib/firebase/billing/healthCheck.d.ts +5 -0
  13. package/lib/firebase/billing/index.d.ts +18 -0
  14. package/lib/firebase/billing/refreshSubscriptionStatus.d.ts +19 -0
  15. package/lib/firebase/billing/webhookHandler.d.ts +6 -0
  16. package/lib/firebase/config/constants.d.ts +89 -0
  17. package/lib/firebase/config/index.d.ts +9 -0
  18. package/lib/firebase/config/secrets.d.ts +15 -0
  19. package/lib/firebase/crud/aggregate.d.ts +98 -0
  20. package/lib/firebase/crud/create.d.ts +16 -0
  21. package/lib/firebase/crud/delete.d.ts +20 -0
  22. package/lib/firebase/crud/get.d.ts +24 -0
  23. package/lib/firebase/crud/index.d.ts +14 -0
  24. package/lib/firebase/crud/list.d.ts +25 -0
  25. package/lib/firebase/crud/update.d.ts +25 -0
  26. package/lib/firebase/helpers/githubAccessHelper.d.ts +30 -0
  27. package/lib/firebase/helpers/githubTeamAccessHelper.d.ts +36 -0
  28. package/lib/firebase/helpers/index.d.ts +10 -0
  29. package/lib/firebase/index.d.ts +17 -0
  30. package/lib/firebase/index.js +25 -9110
  31. package/lib/firebase/index.js.map +4 -4
  32. package/lib/firebase/oauth/disconnect.d.ts +12 -0
  33. package/lib/firebase/oauth/exchangeToken.d.ts +9 -0
  34. package/lib/firebase/oauth/getConnections.d.ts +11 -0
  35. package/lib/firebase/oauth/githubAccess.d.ts +83 -0
  36. package/lib/firebase/oauth/index.d.ts +13 -0
  37. package/lib/firebase/oauth/refreshToken.d.ts +9 -0
  38. package/lib/firebase/registerCrudFunctions.d.ts +32 -0
  39. package/lib/firebase/scheduled/checkExpiredSubscriptions.d.ts +14 -0
  40. package/lib/firebase/scheduled/index.d.ts +9 -0
  41. package/lib/shared/billing/createCheckout.d.ts +50 -0
  42. package/lib/shared/billing/helpers/index.d.ts +10 -0
  43. package/lib/shared/billing/helpers/subscriptionManagement.d.ts +34 -0
  44. package/lib/shared/billing/helpers/updateUserSubscription.d.ts +45 -0
  45. package/lib/shared/billing/idempotency.d.ts +22 -0
  46. package/lib/shared/billing/index.d.ts +11 -0
  47. package/lib/shared/billing/webhookHandler.d.ts +37 -0
  48. package/lib/shared/errorHandling.d.ts +14 -0
  49. package/lib/shared/firebase.d.ts +73 -0
  50. package/lib/shared/github.d.ts +128 -0
  51. package/lib/shared/index.d.ts +16 -0
  52. package/lib/shared/index.js +25 -6927
  53. package/lib/shared/index.js.map +4 -4
  54. package/lib/shared/logger.d.ts +133 -0
  55. package/lib/shared/metadata.d.ts +36 -0
  56. package/lib/shared/oauth/exchangeToken.d.ts +24 -0
  57. package/lib/shared/oauth/grantAccess.d.ts +30 -0
  58. package/lib/shared/oauth/index.d.ts +10 -0
  59. package/lib/shared/schema.d.ts +56 -0
  60. package/lib/shared/utils/detectFirestore.d.ts +31 -0
  61. package/lib/shared/utils/external/date.d.ts +36 -0
  62. package/lib/shared/utils/external/index.d.ts +11 -0
  63. package/lib/shared/utils/external/references.d.ts +12 -0
  64. package/lib/shared/utils/external/subscription.d.ts +41 -0
  65. package/lib/shared/utils/firebaseHelpers.d.ts +23 -0
  66. package/lib/shared/utils/functionWrapper.d.ts +36 -0
  67. package/lib/shared/utils/index.d.ts +14 -0
  68. package/lib/shared/utils/internal/auth.d.ts +57 -0
  69. package/lib/shared/utils/internal/firebase.d.ts +5 -0
  70. package/lib/shared/utils/internal/idempotency.d.ts +21 -0
  71. package/lib/shared/utils/internal/index.d.ts +14 -0
  72. package/lib/shared/utils/internal/monitoring.d.ts +80 -0
  73. package/lib/shared/utils/internal/rateLimiter.d.ts +82 -0
  74. package/lib/shared/utils/internal/validation.d.ts +43 -0
  75. package/lib/shared/utils/schemaValidation.d.ts +60 -0
  76. package/lib/shared/utils/validation.d.ts +98 -0
  77. package/lib/shared/utils/vercelHelpers.d.ts +18 -0
  78. package/lib/shared/utils.d.ts +234 -0
  79. package/lib/shared/validation.d.ts +16 -0
  80. package/lib/supabase/auth/deleteAccount.d.ts +16 -0
  81. package/lib/supabase/auth/getCustomClaims.d.ts +16 -0
  82. package/lib/supabase/auth/getUserAuthStatus.d.ts +18 -0
  83. package/lib/supabase/auth/removeCustomClaims.d.ts +16 -0
  84. package/lib/supabase/auth/setCustomClaims.d.ts +18 -0
  85. package/lib/supabase/baseFunction.d.ts +43 -0
  86. package/lib/supabase/billing/cancelSubscription.d.ts +9 -0
  87. package/lib/supabase/billing/changePlan.d.ts +11 -0
  88. package/lib/supabase/billing/createCheckoutSession.d.ts +11 -0
  89. package/lib/supabase/billing/createCustomerPortal.d.ts +9 -0
  90. package/lib/supabase/billing/refreshSubscriptionStatus.d.ts +9 -0
  91. package/lib/supabase/crud/aggregate.d.ts +27 -0
  92. package/lib/supabase/crud/create.d.ts +23 -0
  93. package/lib/supabase/crud/delete.d.ts +30 -0
  94. package/lib/supabase/crud/get.d.ts +23 -0
  95. package/lib/supabase/crud/index.d.ts +20 -0
  96. package/lib/supabase/crud/list.d.ts +33 -0
  97. package/lib/supabase/crud/update.d.ts +24 -0
  98. package/lib/supabase/helpers/authProvider.d.ts +22 -0
  99. package/lib/supabase/index.d.ts +30 -0
  100. package/lib/supabase/index.js +23 -0
  101. package/lib/supabase/index.js.map +7 -0
  102. package/lib/supabase/oauth/disconnect.d.ts +13 -0
  103. package/lib/supabase/oauth/exchangeToken.d.ts +13 -0
  104. package/lib/supabase/oauth/getConnections.d.ts +13 -0
  105. package/lib/supabase/oauth/index.d.ts +12 -0
  106. package/lib/supabase/oauth/refreshToken.d.ts +13 -0
  107. package/lib/supabase/registerCrudFunctions.d.ts +24 -0
  108. package/lib/supabase/utils/idempotency.d.ts +36 -0
  109. package/lib/supabase/utils/monitoring.d.ts +59 -0
  110. package/lib/supabase/utils/rateLimiter.d.ts +56 -0
  111. package/lib/vercel/api/auth/get-custom-claims.d.ts +2 -0
  112. package/lib/vercel/api/auth/get-user-auth-status.d.ts +2 -0
  113. package/lib/vercel/api/auth/index.d.ts +12 -0
  114. package/lib/vercel/api/auth/remove-custom-claims.d.ts +2 -0
  115. package/lib/vercel/api/auth/set-custom-claims.d.ts +10 -0
  116. package/lib/vercel/api/billing/cancel.d.ts +10 -0
  117. package/lib/vercel/api/billing/change-plan.d.ts +11 -0
  118. package/lib/vercel/api/billing/create-checkout-session.d.ts +13 -0
  119. package/lib/vercel/api/billing/customer-portal.d.ts +3 -0
  120. package/lib/vercel/api/billing/index.d.ts +14 -0
  121. package/lib/vercel/api/billing/refresh-subscription-status.d.ts +31 -0
  122. package/lib/vercel/api/billing/webhook-handler.d.ts +22 -0
  123. package/lib/vercel/api/config/constants.d.ts +103 -0
  124. package/lib/vercel/api/config/firebase-admin.d.ts +19 -0
  125. package/lib/vercel/api/config/index.d.ts +10 -0
  126. package/lib/vercel/api/crud/create.d.ts +2 -0
  127. package/lib/vercel/api/crud/delete.d.ts +2 -0
  128. package/lib/vercel/api/crud/get.d.ts +2 -0
  129. package/lib/vercel/api/crud/index.d.ts +13 -0
  130. package/lib/vercel/api/crud/list.d.ts +2 -0
  131. package/lib/vercel/api/crud/update.d.ts +2 -0
  132. package/lib/vercel/api/index.d.ts +13 -0
  133. package/lib/vercel/api/index.js +22 -4790
  134. package/lib/vercel/api/index.js.map +4 -4
  135. package/lib/vercel/api/oauth/check-github-access.d.ts +12 -0
  136. package/lib/vercel/api/oauth/exchange-token.d.ts +8 -0
  137. package/lib/vercel/api/oauth/grant-github-access.d.ts +12 -0
  138. package/lib/vercel/api/oauth/index.d.ts +12 -0
  139. package/lib/vercel/api/oauth/revoke-github-access.d.ts +11 -0
  140. package/lib/vercel/api/utils/cors.d.ts +49 -0
  141. package/lib/vercel/baseFunction.d.ts +25 -0
  142. package/package.json +4 -4
  143. package/src/firebase/auth/getCustomClaims.ts +3 -3
  144. package/src/firebase/auth/getUserAuthStatus.ts +3 -3
  145. package/src/firebase/auth/index.ts +1 -1
  146. package/src/firebase/auth/removeCustomClaims.ts +3 -3
  147. package/src/firebase/auth/setCustomClaims.ts +130 -84
  148. package/src/firebase/baseFunction.ts +2 -2
  149. package/src/firebase/billing/cancelSubscription.ts +3 -3
  150. package/src/firebase/billing/changePlan.ts +3 -3
  151. package/src/firebase/billing/createCheckoutSession.ts +1 -1
  152. package/src/firebase/billing/createCustomerPortal.ts +1 -1
  153. package/src/firebase/billing/healthCheck.ts +8 -24
  154. package/src/firebase/billing/index.d.ts +11 -11
  155. package/src/firebase/billing/index.ts +1 -1
  156. package/src/firebase/billing/refreshSubscriptionStatus.ts +3 -3
  157. package/src/firebase/billing/webhookHandler.ts +1 -2
  158. package/src/firebase/config/constants.ts +4 -4
  159. package/src/firebase/config/index.ts +1 -1
  160. package/src/firebase/config/secrets.ts +1 -1
  161. package/src/firebase/crud/aggregate.ts +2 -2
  162. package/src/firebase/crud/create.ts +19 -4
  163. package/src/firebase/crud/delete.ts +3 -3
  164. package/src/firebase/crud/get.ts +1 -1
  165. package/src/firebase/crud/index.ts +1 -1
  166. package/src/firebase/crud/list.ts +1 -1
  167. package/src/firebase/crud/update.ts +2 -2
  168. package/src/firebase/helpers/githubAccessHelper.ts +4 -4
  169. package/src/firebase/helpers/githubTeamAccessHelper.ts +3 -3
  170. package/src/firebase/helpers/index.ts +1 -1
  171. package/src/firebase/index.d.ts +9 -9
  172. package/src/firebase/index.ts +1 -1
  173. package/src/firebase/oauth/disconnect.ts +2 -2
  174. package/src/firebase/oauth/exchangeToken.ts +7 -7
  175. package/src/firebase/oauth/getConnections.ts +2 -2
  176. package/src/firebase/oauth/githubAccess.ts +10 -10
  177. package/src/firebase/oauth/index.ts +1 -1
  178. package/src/firebase/oauth/refreshToken.ts +2 -2
  179. package/src/firebase/registerCrudFunctions.ts +1 -1
  180. package/src/firebase/scheduled/checkExpiredSubscriptions.ts +1 -1
  181. package/src/firebase/scheduled/index.ts +1 -1
  182. package/src/shared/__tests__/auth.test.ts +46 -0
  183. package/src/shared/__tests__/errorHandling.test.ts +66 -1
  184. package/src/shared/__tests__/firebase.test.ts +293 -0
  185. package/src/shared/__tests__/internalValidation.test.ts +190 -0
  186. package/src/shared/__tests__/metadata.test.ts +66 -0
  187. package/src/shared/__tests__/schema.test.ts +219 -0
  188. package/src/shared/__tests__/schemaValidation.test.ts +72 -0
  189. package/src/shared/__tests__/subscription.test.ts +45 -0
  190. package/src/shared/__tests__/utils.test.ts +281 -0
  191. package/src/shared/__tests__/validation-env.test.ts +73 -0
  192. package/src/shared/billing/__tests__/createCheckout.test.ts +1 -1
  193. package/src/shared/billing/__tests__/webhookHandler.test.ts +1 -1
  194. package/src/shared/billing/createCheckout.ts +10 -5
  195. package/src/shared/billing/helpers/index.ts +1 -1
  196. package/src/shared/billing/helpers/subscriptionManagement.ts +4 -4
  197. package/src/shared/billing/helpers/updateUserSubscription.ts +4 -4
  198. package/src/shared/billing/idempotency.ts +4 -4
  199. package/src/shared/billing/index.ts +1 -1
  200. package/src/shared/billing/webhookHandler.ts +7 -7
  201. package/src/shared/errorHandling.ts +2 -2
  202. package/src/shared/firebase.ts +7 -7
  203. package/src/shared/github.ts +11 -11
  204. package/src/shared/index.d.ts +9 -9
  205. package/src/shared/index.ts +1 -1
  206. package/src/shared/logger.ts +8 -8
  207. package/src/shared/metadata.ts +3 -3
  208. package/src/shared/oauth/__tests__/exchangeToken.test.ts +1 -1
  209. package/src/shared/oauth/exchangeToken.ts +2 -2
  210. package/src/shared/oauth/grantAccess.ts +2 -2
  211. package/src/shared/oauth/index.ts +1 -1
  212. package/src/shared/schema.ts +4 -4
  213. package/src/shared/utils/__tests__/functionWrapper.test.ts +1 -1
  214. package/src/shared/utils/detectFirestore.ts +3 -3
  215. package/src/shared/utils/external/date.ts +5 -5
  216. package/src/shared/utils/external/index.ts +1 -1
  217. package/src/shared/utils/external/references.ts +2 -2
  218. package/src/shared/utils/external/subscription.ts +5 -5
  219. package/src/shared/utils/firebaseHelpers.ts +3 -3
  220. package/src/shared/utils/functionWrapper.ts +4 -4
  221. package/src/shared/utils/index.ts +1 -1
  222. package/src/shared/utils/internal/auth.ts +7 -7
  223. package/src/shared/utils/internal/firebase.ts +1 -1
  224. package/src/shared/utils/internal/idempotency.ts +3 -3
  225. package/src/shared/utils/internal/index.ts +1 -1
  226. package/src/shared/utils/internal/monitoring.ts +8 -8
  227. package/src/shared/utils/internal/rateLimiter.ts +6 -6
  228. package/src/shared/utils/internal/validation.ts +6 -6
  229. package/src/shared/utils/schemaValidation.ts +6 -6
  230. package/src/shared/utils/validation.ts +10 -10
  231. package/src/shared/utils/vercelHelpers.ts +3 -3
  232. package/src/shared/utils.ts +19 -19
  233. package/src/shared/validation.ts +2 -2
  234. package/src/supabase/auth/deleteAccount.ts +2 -2
  235. package/src/supabase/auth/getCustomClaims.ts +2 -2
  236. package/src/supabase/auth/getUserAuthStatus.ts +2 -2
  237. package/src/supabase/auth/removeCustomClaims.ts +2 -2
  238. package/src/supabase/auth/setCustomClaims.ts +2 -2
  239. package/src/supabase/baseFunction.ts +3 -3
  240. package/src/supabase/billing/cancelSubscription.ts +2 -2
  241. package/src/supabase/billing/changePlan.ts +2 -2
  242. package/src/supabase/billing/createCheckoutSession.ts +2 -2
  243. package/src/supabase/billing/createCustomerPortal.ts +2 -2
  244. package/src/supabase/billing/refreshSubscriptionStatus.ts +2 -2
  245. package/src/supabase/crud/aggregate.ts +11 -8
  246. package/src/supabase/crud/create.ts +2 -2
  247. package/src/supabase/crud/delete.ts +1 -1
  248. package/src/supabase/crud/get.ts +2 -2
  249. package/src/supabase/crud/index.ts +1 -1
  250. package/src/supabase/crud/list.ts +2 -2
  251. package/src/supabase/crud/update.ts +2 -2
  252. package/src/supabase/helpers/authProvider.ts +2 -2
  253. package/src/supabase/index.ts +10 -2
  254. package/src/supabase/oauth/disconnect.ts +104 -0
  255. package/src/supabase/oauth/exchangeToken.ts +152 -0
  256. package/src/supabase/oauth/getConnections.ts +85 -0
  257. package/src/supabase/oauth/index.ts +15 -0
  258. package/src/supabase/oauth/refreshToken.ts +131 -0
  259. package/src/supabase/registerCrudFunctions.ts +1 -1
  260. package/src/supabase/utils/idempotency.ts +1 -1
  261. package/src/supabase/utils/monitoring.ts +1 -1
  262. package/src/supabase/utils/rateLimiter.ts +1 -1
  263. package/src/vercel/api/auth/get-custom-claims.ts +1 -1
  264. package/src/vercel/api/auth/get-user-auth-status.ts +1 -1
  265. package/src/vercel/api/auth/index.ts +1 -1
  266. package/src/vercel/api/auth/remove-custom-claims.ts +1 -1
  267. package/src/vercel/api/auth/set-custom-claims.ts +69 -24
  268. package/src/vercel/api/billing/cancel.ts +3 -3
  269. package/src/vercel/api/billing/change-plan.ts +3 -3
  270. package/src/vercel/api/billing/create-checkout-session.ts +3 -3
  271. package/src/vercel/api/billing/customer-portal.ts +1 -1
  272. package/src/vercel/api/billing/index.ts +1 -1
  273. package/src/vercel/api/billing/refresh-subscription-status.ts +1 -1
  274. package/src/vercel/api/billing/webhook-handler.ts +3 -3
  275. package/src/vercel/api/config/constants.ts +9 -9
  276. package/src/vercel/api/config/firebase-admin.ts +3 -3
  277. package/src/vercel/api/config/index.ts +1 -1
  278. package/src/vercel/api/crud/create.ts +1 -1
  279. package/src/vercel/api/crud/delete.ts +1 -1
  280. package/src/vercel/api/crud/get.ts +1 -1
  281. package/src/vercel/api/crud/index.ts +1 -1
  282. package/src/vercel/api/crud/list.ts +1 -1
  283. package/src/vercel/api/crud/update.ts +1 -1
  284. package/src/vercel/api/index.d.ts +1 -1
  285. package/src/vercel/api/index.ts +1 -1
  286. package/src/vercel/api/oauth/check-github-access.ts +3 -3
  287. package/src/vercel/api/oauth/exchange-token.ts +1 -1
  288. package/src/vercel/api/oauth/grant-github-access.ts +3 -3
  289. package/src/vercel/api/oauth/index.ts +1 -1
  290. package/src/vercel/api/oauth/revoke-github-access.ts +1 -1
  291. package/src/vercel/api/utils/cors.ts +4 -4
  292. package/src/vercel/baseFunction.ts +2 -2
@@ -4,7 +4,7 @@
4
4
  * @fileoverview Billing Health Check
5
5
  * @description Comprehensive health check for billing system
6
6
  *
7
- * @version 0.0.1
7
+ * @version 0.1.0
8
8
  * @since 0.0.1
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
@@ -20,49 +20,33 @@ import { STRIPE_CONFIG } from '../config/constants.js';
20
20
  * GET /billingHealth
21
21
  */
22
22
  export const billingHealth = onRequest(STRIPE_CONFIG, async (req, res) => {
23
- const checks: Record<string, string> = {};
24
23
  let overallStatus: 'healthy' | 'degraded' | 'unhealthy' = 'healthy';
25
24
 
26
25
  // Check Stripe connection
27
26
  try {
28
27
  await stripe.products.list({ limit: 1 });
29
- checks.stripe = 'connected';
30
- } catch (error) {
31
- checks.stripe = 'error';
28
+ } catch {
32
29
  overallStatus = 'unhealthy';
33
30
  }
34
31
 
35
32
  // Check idempotency storage
36
- checks.idempotency = isFirestoreConfigured() ? 'firestore' : 'in-memory';
37
- if (checks.idempotency === 'in-memory') {
33
+ if (!isFirestoreConfigured()) {
38
34
  overallStatus = overallStatus === 'healthy' ? 'degraded' : overallStatus;
39
35
  }
40
36
 
41
- // Check environment variables
37
+ // Check environment variables (don't expose which ones)
42
38
  const requiredEnvVars = [
43
39
  'STRIPE_SECRET_KEY',
44
40
  'STRIPE_WEBHOOK_SECRET',
45
41
  'STRIPE_API_VERSION',
46
42
  ];
47
- const missingEnvVars = requiredEnvVars.filter((v) => !process.env[v]);
48
- checks.environment = missingEnvVars.length === 0 ? 'configured' : 'missing';
49
- if (missingEnvVars.length > 0) {
50
- checks.missingEnvVars = missingEnvVars.join(', ');
43
+ if (requiredEnvVars.some((v) => !process.env[v])) {
51
44
  overallStatus = 'unhealthy';
52
45
  }
53
46
 
54
- const health = {
47
+ const statusCode = overallStatus === 'unhealthy' ? 503 : 200;
48
+ res.status(statusCode).json({
55
49
  status: overallStatus,
56
50
  timestamp: Date.now(),
57
- checks,
58
- version: process.env.STRIPE_API_VERSION || 'unknown',
59
- };
60
-
61
- const statusCode =
62
- overallStatus === 'healthy'
63
- ? 200
64
- : overallStatus === 'degraded'
65
- ? 200
66
- : 503;
67
- res.status(statusCode).json(health);
51
+ });
68
52
  });
@@ -4,7 +4,7 @@
4
4
  * @fileoverview Firebase Billing Functions
5
5
  * @description Type definitions for Firebase Cloud Functions related to billing, payment processing, and subscription management.
6
6
  *
7
- * @version 0.0.1
7
+ * @version 0.1.0
8
8
  * @since 0.0.1
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
@@ -12,7 +12,7 @@
12
12
  /**
13
13
  * Creates a Stripe checkout session
14
14
  *
15
- * @version 0.0.1
15
+ * @version 0.1.0
16
16
  * @since 0.0.1
17
17
  * @author AMBROISE PARK Consulting
18
18
  */
@@ -21,7 +21,7 @@ export { createCheckoutSession } from './createCheckoutSession.js';
21
21
  /**
22
22
  * Handles Stripe webhook events
23
23
  *
24
- * @version 0.0.1
24
+ * @version 0.1.0
25
25
  * @since 0.0.1
26
26
  * @author AMBROISE PARK Consulting
27
27
  */
@@ -30,7 +30,7 @@ export { createStripeWebhook } from './webhookHandler.js';
30
30
  /**
31
31
  * Billing helper functions (via shared)
32
32
  *
33
- * @version 0.0.1
33
+ * @version 0.1.0
34
34
  * @since 0.0.1
35
35
  * @author AMBROISE PARK Consulting
36
36
  */
@@ -39,7 +39,7 @@ export * from '../../shared/billing/helpers/index.js';
39
39
  /**
40
40
  * Idempotency utilities for advanced users
41
41
  *
42
- * @version 0.0.1
42
+ * @version 0.1.0
43
43
  * @since 0.0.1
44
44
  * @author AMBROISE PARK Consulting
45
45
  */
@@ -51,7 +51,7 @@ export {
51
51
  /**
52
52
  * Firestore detection utilities
53
53
  *
54
- * @version 0.0.1
54
+ * @version 0.1.0
55
55
  * @since 0.0.1
56
56
  * @author AMBROISE PARK Consulting
57
57
  */
@@ -63,7 +63,7 @@ export {
63
63
  /**
64
64
  * Billing health check function
65
65
  *
66
- * @version 0.0.1
66
+ * @version 0.1.0
67
67
  * @since 0.0.1
68
68
  * @author AMBROISE PARK Consulting
69
69
  */
@@ -72,7 +72,7 @@ export { billingHealth } from './healthCheck.js';
72
72
  /**
73
73
  * Payment processing functions
74
74
  *
75
- * @version 0.0.1
75
+ * @version 0.1.0
76
76
  * @since 0.0.1
77
77
  * @author AMBROISE PARK Consulting
78
78
  */
@@ -81,7 +81,7 @@ export * from './refreshSubscriptionStatus.js';
81
81
  /**
82
82
  * Cancels a subscription
83
83
  *
84
- * @version 0.0.1
84
+ * @version 0.1.0
85
85
  * @since 0.0.1
86
86
  * @author AMBROISE PARK Consulting
87
87
  */
@@ -90,7 +90,7 @@ export { cancelSubscription } from './cancelSubscription.js';
90
90
  /**
91
91
  * Changes a subscription plan
92
92
  *
93
- * @version 0.0.1
93
+ * @version 0.1.0
94
94
  * @since 0.0.1
95
95
  * @author AMBROISE PARK Consulting
96
96
  */
@@ -99,7 +99,7 @@ export { changePlan } from './changePlan.js';
99
99
  /**
100
100
  * Creates a Stripe customer portal session
101
101
  *
102
- * @version 0.0.1
102
+ * @version 0.1.0
103
103
  * @since 0.0.1
104
104
  * @author AMBROISE PARK Consulting
105
105
  */
@@ -4,7 +4,7 @@
4
4
  * @fileoverview Firebase billing functions barrel exports
5
5
  * @description Centralized exports for Firebase billing functions
6
6
  *
7
- * @version 0.0.1
7
+ * @version 0.1.0
8
8
  * @since 0.0.1
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
@@ -4,7 +4,7 @@
4
4
  * @fileoverview Refresh subscription status Firebase function
5
5
  * @description Firebase callable function for refreshing user subscription status
6
6
  *
7
- * @version 0.0.1
7
+ * @version 0.1.0
8
8
  * @since 0.0.1
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
@@ -32,7 +32,7 @@ const refreshSubscriptionStatusSchema = v.object({
32
32
  * Business logic for refreshing subscription status
33
33
  * Base function handles: validation, auth, rate limiting, monitoring
34
34
  *
35
- * @version 0.0.1
35
+ * @version 0.1.0
36
36
  * @since 0.0.1
37
37
  * @author AMBROISE PARK Consulting
38
38
  */
@@ -97,7 +97,7 @@ async function refreshSubscriptionStatusLogic(
97
97
  * Refreshes user's subscription status from Stripe
98
98
  * Base function handles all common concerns automatically
99
99
  *
100
- * @version 0.0.1
100
+ * @version 0.1.0
101
101
  * @since 0.0.1
102
102
  * @author AMBROISE PARK Consulting
103
103
  */
@@ -4,7 +4,7 @@
4
4
  * @fileoverview Stripe webhook handler Firebase function
5
5
  * @description Firebase HTTP function for handling Stripe webhook events
6
6
  *
7
- * @version 0.0.1
7
+ * @version 0.1.0
8
8
  * @since 0.0.1
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
@@ -65,7 +65,6 @@ export function createStripeWebhook(
65
65
  const error = new Error('No Stripe signature found');
66
66
  logger.error('[Webhook] Missing signature', {
67
67
  error,
68
- headers: req.headers,
69
68
  operation: 'webhook_signature_validation',
70
69
  });
71
70
  throw handleError(error);
@@ -4,7 +4,7 @@
4
4
  * @fileoverview Firebase Functions configuration constants
5
5
  * @description DRY configuration for regions, timeouts, and other function settings
6
6
  *
7
- * @version 0.0.1
7
+ * @version 0.1.0
8
8
  * @since 0.0.1
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
@@ -66,7 +66,7 @@ export const CRUD_READ_CONFIG = {
66
66
  /**
67
67
  * Available Firebase regions for reference
68
68
  *
69
- * @version 0.0.1
69
+ * @version 0.1.0
70
70
  * @since 0.0.1
71
71
  * @author AMBROISE PARK Consulting
72
72
  */
@@ -93,7 +93,7 @@ export const AVAILABLE_REGIONS = {
93
93
  /**
94
94
  * Environment validation
95
95
  *
96
- * @version 0.0.1
96
+ * @version 0.1.0
97
97
  * @since 0.0.1
98
98
  * @author AMBROISE PARK Consulting
99
99
  */
@@ -115,7 +115,7 @@ export const validateEnvironment = () => {
115
115
  /**
116
116
  * Type for Firebase region keys
117
117
  *
118
- * @version 0.0.1
118
+ * @version 0.1.0
119
119
  * @since 0.0.1
120
120
  * @author AMBROISE PARK Consulting
121
121
  */
@@ -4,7 +4,7 @@
4
4
  * @fileoverview Firebase config barrel exports
5
5
  * @description Centralized exports for Firebase configuration
6
6
  *
7
- * @version 0.0.1
7
+ * @version 0.1.0
8
8
  * @since 0.0.1
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
@@ -4,7 +4,7 @@
4
4
  * @fileoverview Firebase Functions V2 Secrets
5
5
  * @description Definition of secrets using the modern defineSecret API
6
6
  *
7
- * @version 0.0.1
7
+ * @version 0.1.0
8
8
  * @since 0.0.1
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
@@ -5,7 +5,7 @@
5
5
  * @description Provides a reusable implementation for computing aggregations on Firestore collections.
6
6
  * Returns only computed metrics, never raw data - optimized for analytics dashboards.
7
7
  *
8
- * @version 0.0.1
8
+ * @version 0.1.0
9
9
  * @since 0.0.1
10
10
  * @author AMBROISE PARK Consulting
11
11
  */
@@ -385,7 +385,7 @@ function aggregateEntitiesLogicFactory(
385
385
  * // }
386
386
  * ```
387
387
  *
388
- * @version 0.0.1
388
+ * @version 0.1.0
389
389
  * @since 0.0.1
390
390
  * @author AMBROISE PARK Consulting
391
391
  */
@@ -4,7 +4,7 @@
4
4
  * @fileoverview Generic function to create an entity.
5
5
  * @description Provides a reusable implementation for creating documents in Firestore with validation.
6
6
  *
7
- * @version 0.0.2
7
+ * @version 0.1.0
8
8
  * @since 0.0.1
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
@@ -144,7 +144,7 @@ async function checkUniqueKeys(
144
144
  * Generic business logic for creating entities
145
145
  * Base function handles: validation, auth, rate limiting, monitoring
146
146
  *
147
- * @version 0.0.2
147
+ * @version 0.1.0
148
148
  * @since 0.0.1
149
149
  * @author AMBROISE PARK Consulting
150
150
  */
@@ -256,8 +256,23 @@ function createEntityLogicFactory(
256
256
  // For drafts: validate field types that ARE present, but allow missing required fields
257
257
  try {
258
258
  validateDocument(normalizedPayload, documentSchema);
259
- } catch {
260
- // Swallow required-field errors for drafts — type errors would still throw from Valibot
259
+ } catch (error: any) {
260
+ // Only swallow required-field errors; re-throw type mismatches
261
+ const issues = error?.issues ?? error?.cause?.issues;
262
+ if (issues && Array.isArray(issues)) {
263
+ const nonRequiredIssues = issues.filter(
264
+ (issue: any) =>
265
+ issue.type !== 'non_optional' &&
266
+ issue.type !== 'non_nullish' &&
267
+ issue.type !== 'non_nullable'
268
+ );
269
+ if (nonRequiredIssues.length > 0) {
270
+ throw error;
271
+ }
272
+ } else {
273
+ // Not a Valibot error — re-throw
274
+ throw error;
275
+ }
261
276
  }
262
277
  }
263
278
 
@@ -4,7 +4,7 @@
4
4
  * @fileoverview Generic function to delete an entity.
5
5
  * @description Provides a reusable implementation for deleting documents in Firestore with reference checking.
6
6
  *
7
- * @version 0.0.1
7
+ * @version 0.1.0
8
8
  * @since 0.0.1
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
@@ -30,7 +30,7 @@ export type DeleteEntityRequest = { id: string };
30
30
  * Generic business logic for deleting entities
31
31
  * Base function handles: validation, auth, rate limiting, monitoring
32
32
  *
33
- * @version 0.0.1
33
+ * @version 0.1.0
34
34
  * @since 0.0.1
35
35
  * @author AMBROISE PARK Consulting
36
36
  */
@@ -68,7 +68,7 @@ function deleteEntityLogicFactory(collection: string) {
68
68
  * @param customSchema - Optional custom request schema
69
69
  * @returns Firebase callable function
70
70
  *
71
- * @version 0.0.1
71
+ * @version 0.1.0
72
72
  * @since 0.0.1
73
73
  * @author AMBROISE PARK Consulting
74
74
  */
@@ -4,7 +4,7 @@
4
4
  * @fileoverview Generic function to retrieve a single entity.
5
5
  * @description Provides a reusable implementation for retrieving documents from Firestore with visibility filtering.
6
6
  *
7
- * @version 0.0.1
7
+ * @version 0.1.0
8
8
  * @since 0.0.1
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
@@ -4,7 +4,7 @@
4
4
  * @fileoverview Firebase CRUD functions barrel exports
5
5
  * @description Centralized exports for Firebase CRUD functions
6
6
  *
7
- * @version 0.0.1
7
+ * @version 0.1.0
8
8
  * @since 0.0.1
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
@@ -4,7 +4,7 @@
4
4
  * @fileoverview Generic function to list entities with pagination, filtering, and sorting.
5
5
  * @description Provides a reusable implementation for listing documents from Firestore with advanced query capabilities.
6
6
  *
7
- * @version 0.0.1
7
+ * @version 0.1.0
8
8
  * @since 0.0.1
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
@@ -4,7 +4,7 @@
4
4
  * @fileoverview Generic function to update an entity.
5
5
  * @description Provides a reusable implementation for updating documents in Firestore with validation.
6
6
  *
7
- * @version 0.0.1
7
+ * @version 0.1.0
8
8
  * @since 0.0.1
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
@@ -136,7 +136,7 @@ async function checkUniqueKeysForUpdate(
136
136
  * Generic business logic for updating entities
137
137
  * Base function handles: validation, auth, rate limiting, monitoring
138
138
  *
139
- * @version 0.0.2
139
+ * @version 0.1.0
140
140
  * @since 0.0.1
141
141
  * @author AMBROISE PARK Consulting
142
142
  */
@@ -4,7 +4,7 @@
4
4
  * @fileoverview GitHub Access Helper Functions
5
5
  * @description Helper functions that can be called directly without Firebase Function wrapper
6
6
  *
7
- * @version 0.0.1
7
+ * @version 0.1.0
8
8
  * @since 0.0.1
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
@@ -23,7 +23,7 @@ import { GitHubApiService } from '../../shared/index.js';
23
23
  * Grant GitHub repository access to a user (helper function)
24
24
  * Can be called directly from other functions
25
25
  *
26
- * @version 0.0.1
26
+ * @version 0.1.0
27
27
  * @since 0.0.1
28
28
  * @author AMBROISE PARK Consulting
29
29
  */
@@ -106,7 +106,7 @@ export async function grantGitHubAccessHelper(
106
106
  * Get custom claims for a user (helper function)
107
107
  * Can be called directly from other functions
108
108
  *
109
- * @version 0.0.1
109
+ * @version 0.1.0
110
110
  * @since 0.0.1
111
111
  * @author AMBROISE PARK Consulting
112
112
  */
@@ -134,7 +134,7 @@ export async function getCustomClaimsHelper(
134
134
  * Set custom claims for a user (helper function)
135
135
  * Can be called directly from other functions
136
136
  *
137
- * @version 0.0.1
137
+ * @version 0.1.0
138
138
  * @since 0.0.1
139
139
  * @author AMBROISE PARK Consulting
140
140
  */
@@ -4,7 +4,7 @@
4
4
  * @fileoverview GitHub Team Access Helper Functions
5
5
  * @description Helper functions for managing GitHub team memberships
6
6
  *
7
- * @version 0.0.1
7
+ * @version 0.1.0
8
8
  * @since 0.0.1
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
@@ -20,7 +20,7 @@ import { GitHubApiService } from '../../shared/index.js';
20
20
  * Grant GitHub team access to a user (helper function)
21
21
  * Can be called directly from other functions
22
22
  *
23
- * @version 0.0.1
23
+ * @version 0.1.0
24
24
  * @since 0.0.1
25
25
  * @author AMBROISE PARK Consulting
26
26
  */
@@ -105,7 +105,7 @@ export async function grantGitHubTeamAccessHelper(
105
105
  * Revoke GitHub team access from a user (helper function)
106
106
  * Can be called directly from other functions
107
107
  *
108
- * @version 0.0.1
108
+ * @version 0.1.0
109
109
  * @since 0.0.1
110
110
  * @author AMBROISE PARK Consulting
111
111
  */
@@ -4,7 +4,7 @@
4
4
  * @fileoverview Firebase helpers barrel exports
5
5
  * @description Centralized exports for Firebase helper functions
6
6
  *
7
- * @version 0.0.1
7
+ * @version 0.1.0
8
8
  * @since 0.0.1
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
@@ -4,7 +4,7 @@
4
4
  * @fileoverview Firebase Functions
5
5
  * @description Barrel exports for Firebase Cloud Functions. Provides centralized access to all Firebase function modules.
6
6
  *
7
- * @version 0.0.1
7
+ * @version 0.1.0
8
8
  * @since 0.0.1
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
@@ -12,7 +12,7 @@
12
12
  /**
13
13
  * Authentication functions
14
14
  *
15
- * @version 0.0.1
15
+ * @version 0.1.0
16
16
  * @since 0.0.1
17
17
  * @author AMBROISE PARK Consulting
18
18
  */
@@ -21,7 +21,7 @@ export * from './auth/index.js';
21
21
  /**
22
22
  * Billing and payment functions
23
23
  *
24
- * @version 0.0.1
24
+ * @version 0.1.0
25
25
  * @since 0.0.1
26
26
  * @author AMBROISE PARK Consulting
27
27
  */
@@ -30,7 +30,7 @@ export * from './billing/index.js';
30
30
  /**
31
31
  * Configuration functions
32
32
  *
33
- * @version 0.0.1
33
+ * @version 0.1.0
34
34
  * @since 0.0.1
35
35
  * @author AMBROISE PARK Consulting
36
36
  */
@@ -39,7 +39,7 @@ export * from './config/index.js';
39
39
  /**
40
40
  * CRUD operation functions
41
41
  *
42
- * @version 0.0.1
42
+ * @version 0.1.0
43
43
  * @since 0.0.1
44
44
  * @author AMBROISE PARK Consulting
45
45
  */
@@ -48,7 +48,7 @@ export * from './crud/index.js';
48
48
  /**
49
49
  * Helper utility functions
50
50
  *
51
- * @version 0.0.1
51
+ * @version 0.1.0
52
52
  * @since 0.0.1
53
53
  * @author AMBROISE PARK Consulting
54
54
  */
@@ -57,7 +57,7 @@ export * from './helpers/index.js';
57
57
  /**
58
58
  * OAuth authentication functions
59
59
  *
60
- * @version 0.0.1
60
+ * @version 0.1.0
61
61
  * @since 0.0.1
62
62
  * @author AMBROISE PARK Consulting
63
63
  */
@@ -66,7 +66,7 @@ export * from './oauth/index.js';
66
66
  /**
67
67
  * Scheduled task functions
68
68
  *
69
- * @version 0.0.1
69
+ * @version 0.1.0
70
70
  * @since 0.0.1
71
71
  * @author AMBROISE PARK Consulting
72
72
  */
@@ -75,7 +75,7 @@ export * from './scheduled/index.js';
75
75
  /**
76
76
  * Base function factory for creating Firebase functions
77
77
  *
78
- * @version 0.0.1
78
+ * @version 0.1.0
79
79
  * @since 0.0.1
80
80
  * @author AMBROISE PARK Consulting
81
81
  */
@@ -4,7 +4,7 @@
4
4
  * @fileoverview Firebase functions barrel exports
5
5
  * @description Centralized exports for Firebase function implementations
6
6
  *
7
- * @version 0.0.1
7
+ * @version 0.1.0
8
8
  * @since 0.0.1
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
@@ -4,7 +4,7 @@
4
4
  * @fileoverview OAuth disconnect Firebase function
5
5
  * @description Firebase callable function for disconnecting OAuth providers
6
6
  *
7
- * @version 0.0.1
7
+ * @version 0.1.0
8
8
  * @since 0.0.1
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
@@ -20,7 +20,7 @@ import { assertAuthenticated } from '../../shared/utils.js';
20
20
  /**
21
21
  * Disconnect a provider
22
22
  *
23
- * @version 0.0.1
23
+ * @version 0.1.0
24
24
  * @since 0.0.1
25
25
  * @author AMBROISE PARK Consulting
26
26
  */
@@ -4,7 +4,7 @@
4
4
  * @fileoverview OAuth token exchange Firebase function
5
5
  * @description Firebase callable function for exchanging OAuth codes for tokens
6
6
  *
7
- * @version 0.0.1
7
+ * @version 0.1.0
8
8
  * @since 0.0.1
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
@@ -26,7 +26,7 @@ import { assertAuthenticated } from '../../shared/utils.js';
26
26
  /**
27
27
  * Exchange OAuth authorization code for access token
28
28
  *
29
- * @version 0.0.1
29
+ * @version 0.1.0
30
30
  * @since 0.0.1
31
31
  * @author AMBROISE PARK Consulting
32
32
  */
@@ -57,6 +57,11 @@ export const exchangeToken = onCall<ExchangeTokenRequest>(async (request) => {
57
57
  }
58
58
  }
59
59
 
60
+ // Validate required parameters BEFORE reserving idempotency key
61
+ if (!provider || !purpose || !code || !redirectUri) {
62
+ throw new HttpsError('invalid-argument', 'Missing required parameters');
63
+ }
64
+
60
65
  // C9: Atomic idempotency check using Firestore transaction to prevent TOCTOU race.
61
66
  // A concurrent request with the same key would see the 'pending' sentinel and wait
62
67
  // or return early instead of executing duplicate business logic.
@@ -88,11 +93,6 @@ export const exchangeToken = onCall<ExchangeTokenRequest>(async (request) => {
88
93
  }
89
94
  }
90
95
 
91
- // Validate required parameters
92
- if (!provider || !purpose || !code || !redirectUri) {
93
- throw new HttpsError('invalid-argument', 'Missing required parameters');
94
- }
95
-
96
96
  try {
97
97
  // Get provider endpoints
98
98
  const endpoints = OAUTH_PARTNERS[provider];
@@ -4,7 +4,7 @@
4
4
  * @fileoverview Get OAuth connections Firebase function
5
5
  * @description Firebase callable function for retrieving user OAuth connections
6
6
  *
7
- * @version 0.0.1
7
+ * @version 0.1.0
8
8
  * @since 0.0.1
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
@@ -19,7 +19,7 @@ import { assertAuthenticated } from '../../shared/utils.js';
19
19
  /**
20
20
  * Get a user's OAuth connections
21
21
  *
22
- * @version 0.0.1
22
+ * @version 0.1.0
23
23
  * @since 0.0.1
24
24
  * @author AMBROISE PARK Consulting
25
25
  */