@donotdev/functions 0.0.20 → 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 (270) hide show
  1. package/LICENSE.md +3 -3
  2. package/lib/firebase/auth/getCustomClaims.d.ts +2 -2
  3. package/lib/firebase/auth/getUserAuthStatus.d.ts +2 -2
  4. package/lib/firebase/auth/index.d.ts +1 -1
  5. package/lib/firebase/auth/removeCustomClaims.d.ts +2 -2
  6. package/lib/firebase/auth/setCustomClaims.d.ts +2 -2
  7. package/lib/firebase/baseFunction.d.ts +1 -1
  8. package/lib/firebase/billing/cancelSubscription.d.ts +1 -1
  9. package/lib/firebase/billing/changePlan.d.ts +1 -1
  10. package/lib/firebase/billing/createCustomerPortal.d.ts +1 -1
  11. package/lib/firebase/billing/index.d.ts +1 -1
  12. package/lib/firebase/billing/refreshSubscriptionStatus.d.ts +2 -2
  13. package/lib/firebase/config/constants.d.ts +4 -4
  14. package/lib/firebase/config/index.d.ts +1 -1
  15. package/lib/firebase/crud/aggregate.d.ts +2 -2
  16. package/lib/firebase/crud/delete.d.ts +1 -1
  17. package/lib/firebase/crud/get.d.ts +1 -1
  18. package/lib/firebase/crud/index.d.ts +1 -1
  19. package/lib/firebase/crud/update.d.ts +1 -1
  20. package/lib/firebase/helpers/githubAccessHelper.d.ts +3 -3
  21. package/lib/firebase/helpers/githubTeamAccessHelper.d.ts +2 -2
  22. package/lib/firebase/helpers/index.d.ts +1 -1
  23. package/lib/firebase/index.d.ts +1 -1
  24. package/lib/firebase/index.js +3 -3
  25. package/lib/firebase/index.js.map +2 -2
  26. package/lib/firebase/oauth/disconnect.d.ts +1 -1
  27. package/lib/firebase/oauth/exchangeToken.d.ts +1 -1
  28. package/lib/firebase/oauth/getConnections.d.ts +1 -1
  29. package/lib/firebase/oauth/githubAccess.d.ts +6 -6
  30. package/lib/firebase/oauth/index.d.ts +1 -1
  31. package/lib/firebase/oauth/refreshToken.d.ts +1 -1
  32. package/lib/firebase/scheduled/index.d.ts +1 -1
  33. package/lib/shared/billing/createCheckout.d.ts +4 -4
  34. package/lib/shared/billing/helpers/index.d.ts +1 -1
  35. package/lib/shared/billing/helpers/subscriptionManagement.d.ts +3 -3
  36. package/lib/shared/billing/helpers/updateUserSubscription.d.ts +4 -4
  37. package/lib/shared/billing/idempotency.d.ts +2 -2
  38. package/lib/shared/billing/index.d.ts +1 -1
  39. package/lib/shared/billing/webhookHandler.d.ts +1 -1
  40. package/lib/shared/errorHandling.d.ts +1 -1
  41. package/lib/shared/firebase.d.ts +7 -7
  42. package/lib/shared/github.d.ts +11 -11
  43. package/lib/shared/index.d.ts +1 -1
  44. package/lib/shared/index.js +3 -3
  45. package/lib/shared/index.js.map +2 -2
  46. package/lib/shared/logger.d.ts +6 -6
  47. package/lib/shared/metadata.d.ts +3 -3
  48. package/lib/shared/oauth/exchangeToken.d.ts +2 -2
  49. package/lib/shared/oauth/grantAccess.d.ts +2 -2
  50. package/lib/shared/oauth/index.d.ts +1 -1
  51. package/lib/shared/schema.d.ts +2 -2
  52. package/lib/shared/utils/detectFirestore.d.ts +3 -3
  53. package/lib/shared/utils/external/date.d.ts +2 -2
  54. package/lib/shared/utils/external/index.d.ts +1 -1
  55. package/lib/shared/utils/external/references.d.ts +1 -1
  56. package/lib/shared/utils/external/subscription.d.ts +5 -5
  57. package/lib/shared/utils/firebaseHelpers.d.ts +2 -2
  58. package/lib/shared/utils/functionWrapper.d.ts +4 -4
  59. package/lib/shared/utils/index.d.ts +1 -1
  60. package/lib/shared/utils/internal/auth.d.ts +4 -4
  61. package/lib/shared/utils/internal/idempotency.d.ts +2 -2
  62. package/lib/shared/utils/internal/index.d.ts +1 -1
  63. package/lib/shared/utils/internal/monitoring.d.ts +7 -7
  64. package/lib/shared/utils/internal/rateLimiter.d.ts +5 -5
  65. package/lib/shared/utils/internal/validation.d.ts +4 -4
  66. package/lib/shared/utils/schemaValidation.d.ts +6 -6
  67. package/lib/shared/utils/validation.d.ts +9 -9
  68. package/lib/shared/utils/vercelHelpers.d.ts +2 -2
  69. package/lib/shared/utils.d.ts +19 -19
  70. package/lib/shared/validation.d.ts +2 -2
  71. package/lib/supabase/auth/deleteAccount.d.ts +1 -1
  72. package/lib/supabase/auth/getCustomClaims.d.ts +1 -1
  73. package/lib/supabase/auth/getUserAuthStatus.d.ts +1 -1
  74. package/lib/supabase/auth/removeCustomClaims.d.ts +1 -1
  75. package/lib/supabase/auth/setCustomClaims.d.ts +1 -1
  76. package/lib/supabase/baseFunction.d.ts +2 -2
  77. package/lib/supabase/billing/cancelSubscription.d.ts +1 -1
  78. package/lib/supabase/billing/changePlan.d.ts +1 -1
  79. package/lib/supabase/billing/createCheckoutSession.d.ts +1 -1
  80. package/lib/supabase/billing/createCustomerPortal.d.ts +1 -1
  81. package/lib/supabase/billing/refreshSubscriptionStatus.d.ts +1 -1
  82. package/lib/supabase/crud/aggregate.d.ts +1 -1
  83. package/lib/supabase/crud/create.d.ts +1 -1
  84. package/lib/supabase/crud/get.d.ts +1 -1
  85. package/lib/supabase/crud/index.d.ts +1 -1
  86. package/lib/supabase/crud/list.d.ts +1 -1
  87. package/lib/supabase/crud/update.d.ts +1 -1
  88. package/lib/supabase/helpers/authProvider.d.ts +2 -2
  89. package/lib/supabase/index.d.ts +3 -2
  90. package/lib/supabase/index.js +2 -2
  91. package/lib/supabase/index.js.map +4 -4
  92. package/lib/supabase/oauth/disconnect.d.ts +13 -0
  93. package/lib/supabase/oauth/exchangeToken.d.ts +13 -0
  94. package/lib/supabase/oauth/getConnections.d.ts +13 -0
  95. package/lib/supabase/oauth/index.d.ts +12 -0
  96. package/lib/supabase/oauth/refreshToken.d.ts +13 -0
  97. package/lib/supabase/utils/idempotency.d.ts +1 -1
  98. package/lib/supabase/utils/monitoring.d.ts +1 -1
  99. package/lib/supabase/utils/rateLimiter.d.ts +1 -1
  100. package/lib/vercel/api/auth/index.d.ts +1 -1
  101. package/lib/vercel/api/billing/cancel.d.ts +1 -1
  102. package/lib/vercel/api/billing/change-plan.d.ts +1 -1
  103. package/lib/vercel/api/billing/create-checkout-session.d.ts +1 -1
  104. package/lib/vercel/api/billing/index.d.ts +1 -1
  105. package/lib/vercel/api/billing/refresh-subscription-status.d.ts +1 -1
  106. package/lib/vercel/api/billing/webhook-handler.d.ts +2 -2
  107. package/lib/vercel/api/config/constants.d.ts +9 -9
  108. package/lib/vercel/api/config/firebase-admin.d.ts +2 -2
  109. package/lib/vercel/api/config/index.d.ts +1 -1
  110. package/lib/vercel/api/crud/index.d.ts +1 -1
  111. package/lib/vercel/api/index.d.ts +1 -1
  112. package/lib/vercel/api/index.js +2 -2
  113. package/lib/vercel/api/index.js.map +2 -2
  114. package/lib/vercel/api/oauth/check-github-access.d.ts +1 -1
  115. package/lib/vercel/api/oauth/grant-github-access.d.ts +1 -1
  116. package/lib/vercel/api/oauth/index.d.ts +1 -1
  117. package/lib/vercel/api/oauth/revoke-github-access.d.ts +1 -1
  118. package/lib/vercel/api/utils/cors.d.ts +4 -4
  119. package/lib/vercel/baseFunction.d.ts +2 -2
  120. package/package.json +4 -4
  121. package/src/firebase/auth/getCustomClaims.ts +3 -3
  122. package/src/firebase/auth/getUserAuthStatus.ts +3 -3
  123. package/src/firebase/auth/index.ts +1 -1
  124. package/src/firebase/auth/removeCustomClaims.ts +3 -3
  125. package/src/firebase/auth/setCustomClaims.ts +70 -69
  126. package/src/firebase/baseFunction.ts +2 -2
  127. package/src/firebase/billing/cancelSubscription.ts +3 -3
  128. package/src/firebase/billing/changePlan.ts +3 -3
  129. package/src/firebase/billing/createCheckoutSession.ts +1 -1
  130. package/src/firebase/billing/createCustomerPortal.ts +1 -1
  131. package/src/firebase/billing/healthCheck.ts +1 -1
  132. package/src/firebase/billing/index.d.ts +11 -11
  133. package/src/firebase/billing/index.ts +1 -1
  134. package/src/firebase/billing/refreshSubscriptionStatus.ts +3 -3
  135. package/src/firebase/billing/webhookHandler.ts +1 -1
  136. package/src/firebase/config/constants.ts +4 -4
  137. package/src/firebase/config/index.ts +1 -1
  138. package/src/firebase/config/secrets.ts +1 -1
  139. package/src/firebase/crud/aggregate.ts +2 -2
  140. package/src/firebase/crud/create.ts +2 -2
  141. package/src/firebase/crud/delete.ts +3 -3
  142. package/src/firebase/crud/get.ts +1 -1
  143. package/src/firebase/crud/index.ts +1 -1
  144. package/src/firebase/crud/list.ts +1 -1
  145. package/src/firebase/crud/update.ts +2 -2
  146. package/src/firebase/helpers/githubAccessHelper.ts +4 -4
  147. package/src/firebase/helpers/githubTeamAccessHelper.ts +3 -3
  148. package/src/firebase/helpers/index.ts +1 -1
  149. package/src/firebase/index.d.ts +9 -9
  150. package/src/firebase/index.ts +1 -1
  151. package/src/firebase/oauth/disconnect.ts +2 -2
  152. package/src/firebase/oauth/exchangeToken.ts +2 -2
  153. package/src/firebase/oauth/getConnections.ts +2 -2
  154. package/src/firebase/oauth/githubAccess.ts +10 -10
  155. package/src/firebase/oauth/index.ts +1 -1
  156. package/src/firebase/oauth/refreshToken.ts +2 -2
  157. package/src/firebase/registerCrudFunctions.ts +1 -1
  158. package/src/firebase/scheduled/checkExpiredSubscriptions.ts +1 -1
  159. package/src/firebase/scheduled/index.ts +1 -1
  160. package/src/shared/__tests__/auth.test.ts +46 -0
  161. package/src/shared/__tests__/errorHandling.test.ts +66 -1
  162. package/src/shared/__tests__/firebase.test.ts +293 -0
  163. package/src/shared/__tests__/internalValidation.test.ts +190 -0
  164. package/src/shared/__tests__/metadata.test.ts +66 -0
  165. package/src/shared/__tests__/schema.test.ts +219 -0
  166. package/src/shared/__tests__/schemaValidation.test.ts +72 -0
  167. package/src/shared/__tests__/subscription.test.ts +45 -0
  168. package/src/shared/__tests__/utils.test.ts +281 -0
  169. package/src/shared/__tests__/validation-env.test.ts +73 -0
  170. package/src/shared/billing/__tests__/createCheckout.test.ts +1 -1
  171. package/src/shared/billing/__tests__/webhookHandler.test.ts +1 -1
  172. package/src/shared/billing/createCheckout.ts +4 -4
  173. package/src/shared/billing/helpers/index.ts +1 -1
  174. package/src/shared/billing/helpers/subscriptionManagement.ts +4 -4
  175. package/src/shared/billing/helpers/updateUserSubscription.ts +4 -4
  176. package/src/shared/billing/idempotency.ts +4 -4
  177. package/src/shared/billing/index.ts +1 -1
  178. package/src/shared/billing/webhookHandler.ts +7 -7
  179. package/src/shared/errorHandling.ts +2 -2
  180. package/src/shared/firebase.ts +7 -7
  181. package/src/shared/github.ts +11 -11
  182. package/src/shared/index.d.ts +9 -9
  183. package/src/shared/index.ts +1 -1
  184. package/src/shared/logger.ts +8 -8
  185. package/src/shared/metadata.ts +3 -3
  186. package/src/shared/oauth/__tests__/exchangeToken.test.ts +1 -1
  187. package/src/shared/oauth/exchangeToken.ts +2 -2
  188. package/src/shared/oauth/grantAccess.ts +2 -2
  189. package/src/shared/oauth/index.ts +1 -1
  190. package/src/shared/schema.ts +4 -4
  191. package/src/shared/utils/__tests__/functionWrapper.test.ts +1 -1
  192. package/src/shared/utils/detectFirestore.ts +3 -3
  193. package/src/shared/utils/external/date.ts +5 -5
  194. package/src/shared/utils/external/index.ts +1 -1
  195. package/src/shared/utils/external/references.ts +2 -2
  196. package/src/shared/utils/external/subscription.ts +5 -5
  197. package/src/shared/utils/firebaseHelpers.ts +3 -3
  198. package/src/shared/utils/functionWrapper.ts +4 -4
  199. package/src/shared/utils/index.ts +1 -1
  200. package/src/shared/utils/internal/auth.ts +7 -7
  201. package/src/shared/utils/internal/firebase.ts +1 -1
  202. package/src/shared/utils/internal/idempotency.ts +3 -3
  203. package/src/shared/utils/internal/index.ts +1 -1
  204. package/src/shared/utils/internal/monitoring.ts +8 -8
  205. package/src/shared/utils/internal/rateLimiter.ts +6 -6
  206. package/src/shared/utils/internal/validation.ts +5 -5
  207. package/src/shared/utils/schemaValidation.ts +6 -6
  208. package/src/shared/utils/validation.ts +10 -10
  209. package/src/shared/utils/vercelHelpers.ts +3 -3
  210. package/src/shared/utils.ts +19 -19
  211. package/src/shared/validation.ts +2 -2
  212. package/src/supabase/auth/deleteAccount.ts +2 -2
  213. package/src/supabase/auth/getCustomClaims.ts +2 -2
  214. package/src/supabase/auth/getUserAuthStatus.ts +2 -2
  215. package/src/supabase/auth/removeCustomClaims.ts +2 -2
  216. package/src/supabase/auth/setCustomClaims.ts +2 -2
  217. package/src/supabase/baseFunction.ts +3 -3
  218. package/src/supabase/billing/cancelSubscription.ts +2 -2
  219. package/src/supabase/billing/changePlan.ts +2 -2
  220. package/src/supabase/billing/createCheckoutSession.ts +2 -2
  221. package/src/supabase/billing/createCustomerPortal.ts +2 -2
  222. package/src/supabase/billing/refreshSubscriptionStatus.ts +2 -2
  223. package/src/supabase/crud/aggregate.ts +1 -1
  224. package/src/supabase/crud/create.ts +1 -1
  225. package/src/supabase/crud/delete.ts +1 -1
  226. package/src/supabase/crud/get.ts +1 -1
  227. package/src/supabase/crud/index.ts +1 -1
  228. package/src/supabase/crud/list.ts +1 -1
  229. package/src/supabase/crud/update.ts +1 -1
  230. package/src/supabase/helpers/authProvider.ts +2 -2
  231. package/src/supabase/index.ts +10 -2
  232. package/src/supabase/oauth/disconnect.ts +104 -0
  233. package/src/supabase/oauth/exchangeToken.ts +152 -0
  234. package/src/supabase/oauth/getConnections.ts +85 -0
  235. package/src/supabase/oauth/index.ts +15 -0
  236. package/src/supabase/oauth/refreshToken.ts +131 -0
  237. package/src/supabase/registerCrudFunctions.ts +1 -1
  238. package/src/supabase/utils/idempotency.ts +1 -1
  239. package/src/supabase/utils/monitoring.ts +1 -1
  240. package/src/supabase/utils/rateLimiter.ts +1 -1
  241. package/src/vercel/api/auth/get-custom-claims.ts +1 -1
  242. package/src/vercel/api/auth/get-user-auth-status.ts +1 -1
  243. package/src/vercel/api/auth/index.ts +1 -1
  244. package/src/vercel/api/auth/remove-custom-claims.ts +1 -1
  245. package/src/vercel/api/auth/set-custom-claims.ts +2 -4
  246. package/src/vercel/api/billing/cancel.ts +3 -3
  247. package/src/vercel/api/billing/change-plan.ts +3 -3
  248. package/src/vercel/api/billing/create-checkout-session.ts +3 -3
  249. package/src/vercel/api/billing/customer-portal.ts +1 -1
  250. package/src/vercel/api/billing/index.ts +1 -1
  251. package/src/vercel/api/billing/refresh-subscription-status.ts +1 -1
  252. package/src/vercel/api/billing/webhook-handler.ts +3 -3
  253. package/src/vercel/api/config/constants.ts +9 -9
  254. package/src/vercel/api/config/firebase-admin.ts +3 -3
  255. package/src/vercel/api/config/index.ts +1 -1
  256. package/src/vercel/api/crud/create.ts +1 -1
  257. package/src/vercel/api/crud/delete.ts +1 -1
  258. package/src/vercel/api/crud/get.ts +1 -1
  259. package/src/vercel/api/crud/index.ts +1 -1
  260. package/src/vercel/api/crud/list.ts +1 -1
  261. package/src/vercel/api/crud/update.ts +1 -1
  262. package/src/vercel/api/index.d.ts +1 -1
  263. package/src/vercel/api/index.ts +1 -1
  264. package/src/vercel/api/oauth/check-github-access.ts +3 -3
  265. package/src/vercel/api/oauth/exchange-token.ts +1 -1
  266. package/src/vercel/api/oauth/grant-github-access.ts +3 -3
  267. package/src/vercel/api/oauth/index.ts +1 -1
  268. package/src/vercel/api/oauth/revoke-github-access.ts +1 -1
  269. package/src/vercel/api/utils/cors.ts +4 -4
  270. package/src/vercel/baseFunction.ts +2 -2
@@ -4,7 +4,7 @@ import type * as v from 'valibot';
4
4
  * Vercel API handler for checking GitHub access
5
5
  * Base function handles all common concerns automatically
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 @@ import type * as v from 'valibot';
4
4
  * Vercel API handler for granting GitHub access
5
5
  * Base function handles all common concerns automatically
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
  */
@@ -2,7 +2,7 @@
2
2
  * @fileoverview Vercel API OAuth barrel exports
3
3
  * @description Centralized exports for Vercel API OAuth functions
4
4
  *
5
- * @version 0.0.1
5
+ * @version 0.1.0
6
6
  * @since 0.0.1
7
7
  * @author AMBROISE PARK Consulting
8
8
  */
@@ -2,7 +2,7 @@
2
2
  * @fileoverview Revoke GitHub access API handler
3
3
  * @description Vercel API route for revoking GitHub access
4
4
  *
5
- * @version 0.0.1
5
+ * @version 0.1.0
6
6
  * @since 0.0.1
7
7
  * @author AMBROISE PARK Consulting
8
8
  */
@@ -2,7 +2,7 @@
2
2
  * @fileoverview CORS utilities for Vercel API
3
3
  * @description CORS configuration and handling for Vercel functions
4
4
  *
5
- * @version 0.0.1
5
+ * @version 0.1.0
6
6
  * @since 0.0.1
7
7
  * @author AMBROISE PARK Consulting
8
8
  */
@@ -21,7 +21,7 @@ import type { NextApiRequest, NextApiResponse } from 'next';
21
21
  * the wildcard origin remains valid. Consumers that need credentialed cross-origin requests
22
22
  * must replace '*' with their specific origin and re-add Allow-Credentials:true.
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
  */
@@ -34,7 +34,7 @@ export declare const corsHeaders: {
34
34
  /**
35
35
  * Handle CORS preflight requests
36
36
  *
37
- * @version 0.0.1
37
+ * @version 0.1.0
38
38
  * @since 0.0.1
39
39
  * @author AMBROISE PARK Consulting
40
40
  */
@@ -42,7 +42,7 @@ export declare function handleCors(req: NextApiRequest, res: NextApiResponse): b
42
42
  /**
43
43
  * Wrapper for Vercel API functions to automatically handle CORS
44
44
  *
45
- * @version 0.0.1
45
+ * @version 0.1.0
46
46
  * @since 0.0.1
47
47
  * @author AMBROISE PARK Consulting
48
48
  */
@@ -2,7 +2,7 @@
2
2
  * @fileoverview Base Vercel function that handles all common concerns
3
3
  * @description Rate limiting, monitoring, authentication, validation - all in one place
4
4
  *
5
- * @version 0.0.1
5
+ * @version 0.1.0
6
6
  * @since 0.0.1
7
7
  * @author AMBROISE PARK Consulting
8
8
  */
@@ -14,7 +14,7 @@ import type { NextApiRequest, NextApiResponse } from 'next';
14
14
  * Base Vercel function that handles all common concerns
15
15
  * Users just provide their business logic
16
16
  *
17
- * @version 0.0.1
17
+ * @version 0.1.0
18
18
  * @since 0.0.1
19
19
  * @author AMBROISE PARK Consulting
20
20
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@donotdev/functions",
3
- "version": "0.0.20",
3
+ "version": "0.1.0",
4
4
  "private": false,
5
5
  "description": "Backend functions for DoNotDev Framework - Firebase, Vercel, and platform-agnostic implementations for auth, billing, CRUD, and OAuth",
6
6
  "main": "./lib/firebase/index.js",
@@ -47,9 +47,9 @@
47
47
  "serve": "firebase emulators:start --only functions"
48
48
  },
49
49
  "dependencies": {
50
- "@donotdev/core": "^0.0.38",
51
- "@donotdev/firebase": "^0.0.22",
52
- "@donotdev/supabase": "^0.0.12"
50
+ "@donotdev/core": "^0.1.0",
51
+ "@donotdev/firebase": "^0.1.0",
52
+ "@donotdev/supabase": "^0.1.0"
53
53
  },
54
54
  "peerDependencies": {
55
55
  "@sentry/node": "^10.39.0",
@@ -4,7 +4,7 @@
4
4
  * @fileoverview Get custom claims Firebase function
5
5
  * @description Firebase callable function for retrieving custom user claims
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 @@ type GetCustomClaimsResponse = { customClaims: Record<string, any> };
30
30
  * Business logic for getting custom claims
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
  */
@@ -49,7 +49,7 @@ async function getCustomClaimsLogic(
49
49
  * Gets user's custom claims
50
50
  * Base function handles all common concerns automatically
51
51
  *
52
- * @version 0.0.1
52
+ * @version 0.1.0
53
53
  * @since 0.0.1
54
54
  * @author AMBROISE PARK Consulting
55
55
  */
@@ -4,7 +4,7 @@
4
4
  * @fileoverview Get user auth status Firebase function
5
5
  * @description Firebase callable function for retrieving user authentication 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
  */
@@ -38,7 +38,7 @@ export type GetUserAuthStatusResponse = {
38
38
  * Business logic for getting user auth status
39
39
  * Base function handles: validation, auth, rate limiting, monitoring
40
40
  *
41
- * @version 0.0.1
41
+ * @version 0.1.0
42
42
  * @since 0.0.1
43
43
  * @author AMBROISE PARK Consulting
44
44
  */
@@ -64,7 +64,7 @@ async function getUserAuthStatusLogic(
64
64
  * Gets user authentication status
65
65
  * Base function handles all common concerns automatically
66
66
  *
67
- * @version 0.0.1
67
+ * @version 0.1.0
68
68
  * @since 0.0.1
69
69
  * @author AMBROISE PARK Consulting
70
70
  */
@@ -4,7 +4,7 @@
4
4
  * @fileoverview Firebase auth functions barrel exports
5
5
  * @description Centralized exports for Firebase authentication 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 Remove custom claims Firebase function
5
5
  * @description Firebase callable function for removing custom user claims
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
  */
@@ -40,7 +40,7 @@ export type RemoveCustomClaimsResponse = {
40
40
  * Business logic for removing custom claims
41
41
  * Base function handles: validation, auth, rate limiting, monitoring
42
42
  *
43
- * @version 0.0.1
43
+ * @version 0.1.0
44
44
  * @since 0.0.1
45
45
  * @author AMBROISE PARK Consulting
46
46
  */
@@ -71,7 +71,7 @@ async function removeCustomClaimsLogic(
71
71
  * Removes user's custom claims
72
72
  * Base function handles all common concerns automatically
73
73
  *
74
- * @version 0.0.1
74
+ * @version 0.1.0
75
75
  * @since 0.0.1
76
76
  * @author AMBROISE PARK Consulting
77
77
  */
@@ -4,7 +4,7 @@
4
4
  * @fileoverview Set custom claims Firebase function
5
5
  * @description Firebase callable function for setting custom user claims
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
  */
@@ -64,7 +64,7 @@ export interface SetCustomClaimsOptions {
64
64
  * Business logic for setting custom claims
65
65
  * Base function handles: validation, auth, rate limiting, monitoring
66
66
  *
67
- * @version 0.0.1
67
+ * @version 0.1.0
68
68
  * @since 0.0.1
69
69
  * @author AMBROISE PARK Consulting
70
70
  */
@@ -86,84 +86,85 @@ function createSetCustomClaimsLogic(allowedKeys: Set<string>) {
86
86
  (k) => !allowedKeys.has(k)
87
87
  );
88
88
  if (disallowedKeys.length > 0) {
89
- throw new Error(
90
- `Claim keys not allowed: ${disallowedKeys.join(', ')}`
91
- );
89
+ throw new Error(`Claim keys not allowed: ${disallowedKeys.join(', ')}`);
92
90
  }
93
91
 
94
- // W17: Validate idempotency key to prevent oversized or malformed inputs.
95
- if (idempotencyKey !== undefined) {
96
- if (
97
- typeof idempotencyKey !== 'string' ||
98
- idempotencyKey.length === 0 ||
99
- idempotencyKey.length > 256
100
- ) {
101
- throw new Error(
102
- 'idempotencyKey must be a non-empty string of at most 256 characters'
103
- );
104
- }
105
- if (!/^[\w\-.:@]+$/.test(idempotencyKey)) {
106
- throw new Error(
107
- 'idempotencyKey contains invalid characters (allowed: alphanumeric, -, _, ., :, @)'
108
- );
92
+ // W17: Validate idempotency key to prevent oversized or malformed inputs.
93
+ if (idempotencyKey !== undefined) {
94
+ if (
95
+ typeof idempotencyKey !== 'string' ||
96
+ idempotencyKey.length === 0 ||
97
+ idempotencyKey.length > 256
98
+ ) {
99
+ throw new Error(
100
+ 'idempotencyKey must be a non-empty string of at most 256 characters'
101
+ );
102
+ }
103
+ if (!/^[\w\-.:@]+$/.test(idempotencyKey)) {
104
+ throw new Error(
105
+ 'idempotencyKey contains invalid characters (allowed: alphanumeric, -, _, ., :, @)'
106
+ );
107
+ }
109
108
  }
110
- }
111
109
 
112
- // C9: Atomic idempotency check — reserve key in a transaction to eliminate TOCTOU race.
113
- if (idempotencyKey) {
114
- const db = getFirebaseAdminFirestore();
115
- const idempotencyRef = db
116
- .collection('idempotency')
117
- .doc(`claims_${idempotencyKey}`);
118
-
119
- let existingResult: unknown = undefined;
120
- let alreadyProcessed = false;
121
-
122
- await db.runTransaction(async (tx) => {
123
- const idempotencyDoc = await tx.get(idempotencyRef);
124
- if (idempotencyDoc.exists) {
125
- existingResult = idempotencyDoc.data()?.result;
126
- alreadyProcessed = true;
127
- return;
128
- }
129
- tx.set(idempotencyRef, {
130
- processing: true,
131
- reservedAt: new Date().toISOString(),
110
+ // C9: Atomic idempotency check — reserve key in a transaction to eliminate TOCTOU race.
111
+ if (idempotencyKey) {
112
+ const db = getFirebaseAdminFirestore();
113
+ const idempotencyRef = db
114
+ .collection('idempotency')
115
+ .doc(`claims_${idempotencyKey}`);
116
+
117
+ let existingResult: unknown = undefined;
118
+ let alreadyProcessed = false;
119
+
120
+ await db.runTransaction(async (tx) => {
121
+ const idempotencyDoc = await tx.get(idempotencyRef);
122
+ if (idempotencyDoc.exists) {
123
+ existingResult = idempotencyDoc.data()?.result;
124
+ alreadyProcessed = true;
125
+ return;
126
+ }
127
+ tx.set(idempotencyRef, {
128
+ processing: true,
129
+ reservedAt: new Date().toISOString(),
130
+ });
132
131
  });
133
- });
134
132
 
135
- if (alreadyProcessed) {
136
- return existingResult as {
137
- success: boolean;
138
- customClaims: Record<string, any>;
139
- };
133
+ if (alreadyProcessed) {
134
+ return existingResult as {
135
+ success: boolean;
136
+ customClaims: Record<string, any>;
137
+ };
138
+ }
140
139
  }
141
- }
142
-
143
- const user = await getFirebaseAdminAuth().getUser(context.uid);
144
- const currentClaims = user.customClaims || {};
145
140
 
146
- // Merge with existing claims
147
- const updatedClaims = { ...currentClaims, ...customClaims };
141
+ const user = await getFirebaseAdminAuth().getUser(context.uid);
142
+ const currentClaims = user.customClaims || {};
148
143
 
149
- await getFirebaseAdminAuth().setCustomUserClaims(context.uid, updatedClaims);
144
+ // Merge with existing claims
145
+ const updatedClaims = { ...currentClaims, ...customClaims };
150
146
 
151
- const result = { success: true, customClaims: updatedClaims };
147
+ await getFirebaseAdminAuth().setCustomUserClaims(
148
+ context.uid,
149
+ updatedClaims
150
+ );
152
151
 
153
- // Store result for idempotency if key provided
154
- if (idempotencyKey) {
155
- const db = getFirebaseAdminFirestore();
156
- const idempotencyRef = db
157
- .collection('idempotency')
158
- .doc(`claims_${idempotencyKey}`);
159
- await idempotencyRef.set({
160
- result,
161
- processedAt: new Date().toISOString(),
162
- processedBy: context.uid,
163
- });
164
- }
152
+ const result = { success: true, customClaims: updatedClaims };
153
+
154
+ // Store result for idempotency if key provided
155
+ if (idempotencyKey) {
156
+ const db = getFirebaseAdminFirestore();
157
+ const idempotencyRef = db
158
+ .collection('idempotency')
159
+ .doc(`claims_${idempotencyKey}`);
160
+ await idempotencyRef.set({
161
+ result,
162
+ processedAt: new Date().toISOString(),
163
+ processedBy: context.uid,
164
+ });
165
+ }
165
166
 
166
- return result;
167
+ return result;
167
168
  };
168
169
  }
169
170
 
@@ -171,7 +172,7 @@ function createSetCustomClaimsLogic(allowedKeys: Set<string>) {
171
172
  * Sets custom claims for a user, restricted to allowed keys.
172
173
  * Consumers MUST specify which claim keys are self-assignable.
173
174
  *
174
- * @version 0.0.1
175
+ * @version 0.1.0
175
176
  * @since 0.0.1
176
177
  * @author AMBROISE PARK Consulting
177
178
  */
@@ -4,7 +4,7 @@
4
4
  * @fileoverview Base Firebase function that handles all common concerns
5
5
  * @description Rate limiting, monitoring, authentication, validation - all in one place
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
  */
@@ -111,7 +111,7 @@ function getClientIp(request: CallableRequest<unknown>): string {
111
111
  * @param businessLogic - The actual business logic to execute
112
112
  * @param requiredRole - Minimum role required (default: 'user' for backwards compatibility)
113
113
  *
114
- * @version 0.0.3
114
+ * @version 0.1.0
115
115
  * @since 0.0.1
116
116
  * @author AMBROISE PARK Consulting
117
117
  */
@@ -4,7 +4,7 @@
4
4
  * @fileoverview Cancel Subscription Function
5
5
  * @description Cancels user's subscription at period end (doesn't delete immediately)
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
  */
@@ -29,7 +29,7 @@ const cancelSubscriptionSchema = v.object({
29
29
  * Business logic for canceling subscription
30
30
  * Base function handles: validation, auth, rate limiting, monitoring
31
31
  *
32
- * @version 0.0.1
32
+ * @version 0.1.0
33
33
  * @since 0.0.1
34
34
  * @author AMBROISE PARK Consulting
35
35
  */
@@ -60,7 +60,7 @@ async function cancelSubscriptionLogic(
60
60
  /**
61
61
  * Cancel subscription function
62
62
  *
63
- * @version 0.0.1
63
+ * @version 0.1.0
64
64
  * @since 0.0.1
65
65
  * @author AMBROISE PARK Consulting
66
66
  */
@@ -4,7 +4,7 @@
4
4
  * @fileoverview Change Subscription Plan Function
5
5
  * @description Upgrades or downgrades user's subscription plan with prorated billing
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
  */
@@ -38,7 +38,7 @@ const changePlanSchema = v.object({
38
38
  * Business logic for changing subscription plan
39
39
  * Base function handles: validation, auth, rate limiting, monitoring
40
40
  *
41
- * @version 0.0.1
41
+ * @version 0.1.0
42
42
  * @since 0.0.1
43
43
  * @author AMBROISE PARK Consulting
44
44
  */
@@ -140,7 +140,7 @@ async function changePlanLogic(
140
140
  /**
141
141
  * Change subscription plan function
142
142
  *
143
- * @version 0.0.1
143
+ * @version 0.1.0
144
144
  * @since 0.0.1
145
145
  * @author AMBROISE PARK Consulting
146
146
  */
@@ -4,7 +4,7 @@
4
4
  * @fileoverview Create checkout session Firebase function
5
5
  * @description Firebase callable function for creating Stripe checkout sessions
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 Create Customer Portal Function
5
5
  * @description Generates Stripe Customer Portal URL for payment method 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
  */
@@ -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
  */
@@ -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
  */
@@ -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
  */