@maka/maka-cli 5.122.1 → 5.123.1

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 (366) hide show
  1. package/README.md +64 -64
  2. package/bundle/typescript/package.json +120 -120
  3. package/bundle/typescript/src/README.md +64 -64
  4. package/bundle/typescript/src/commands/aws/aws.command.js +2 -2
  5. package/bundle/typescript/src/commands/aws/ci.sub.cmd.js +5 -5
  6. package/bundle/typescript/src/commands/aws/ckp.sub.cmd.js +12 -12
  7. package/bundle/typescript/src/commands/aws/csg.sub.cmd.js +3 -3
  8. package/bundle/typescript/src/commands/aws/di.sub.cmd.js +8 -8
  9. package/bundle/typescript/src/commands/aws/rkp.sub.cmd.js +5 -5
  10. package/bundle/typescript/src/commands/aws/sth.sub.cmd.js +3 -3
  11. package/bundle/typescript/src/commands/aws/ti.sub.cmd.js +5 -5
  12. package/bundle/typescript/src/commands/build/build.js +16 -16
  13. package/bundle/typescript/src/commands/build/docker.sub.cmd.js +9 -9
  14. package/bundle/typescript/src/commands/create.js +36 -36
  15. package/bundle/typescript/src/commands/debug.js +4 -4
  16. package/bundle/typescript/src/commands/deploy/deploy.command.js +2 -2
  17. package/bundle/typescript/src/commands/deploy/galaxy.sub.cmd.js +2 -2
  18. package/bundle/typescript/src/commands/deploy/github.sub.cmd.js +8 -8
  19. package/bundle/typescript/src/commands/deploy/ubuntu.sub.cmd.js +14 -10
  20. package/bundle/typescript/src/commands/deploy/ubuntu.sub.cmd.js.map +1 -1
  21. package/bundle/typescript/src/commands/env/env.command.js +8 -8
  22. package/bundle/typescript/src/commands/env/set.sub.cmd.js +11 -11
  23. package/bundle/typescript/src/commands/game/sideQuest/adept-powers.d.ts +15 -0
  24. package/bundle/typescript/src/commands/game/sideQuest/adept-powers.js +12 -0
  25. package/bundle/typescript/src/commands/game/sideQuest/adept-powers.js.map +1 -1
  26. package/bundle/typescript/src/commands/game/sideQuest/archetypes.d.ts +10 -0
  27. package/bundle/typescript/src/commands/game/sideQuest/archetypes.js +40 -14
  28. package/bundle/typescript/src/commands/game/sideQuest/archetypes.js.map +1 -1
  29. package/bundle/typescript/src/commands/game/sideQuest/augmentations.d.ts +33 -10
  30. package/bundle/typescript/src/commands/game/sideQuest/augmentations.js +155 -72
  31. package/bundle/typescript/src/commands/game/sideQuest/augmentations.js.map +1 -1
  32. package/bundle/typescript/src/commands/game/sideQuest/commands/advance.js +15 -6
  33. package/bundle/typescript/src/commands/game/sideQuest/commands/advance.js.map +1 -1
  34. package/bundle/typescript/src/commands/game/sideQuest/commands/ask.js +1 -1
  35. package/bundle/typescript/src/commands/game/sideQuest/commands/ask.js.map +1 -1
  36. package/bundle/typescript/src/commands/game/sideQuest/commands/bluff.js +1 -1
  37. package/bundle/typescript/src/commands/game/sideQuest/commands/bluff.js.map +1 -1
  38. package/bundle/typescript/src/commands/game/sideQuest/commands/cast.js +33 -33
  39. package/bundle/typescript/src/commands/game/sideQuest/commands/cast.js.map +1 -1
  40. package/bundle/typescript/src/commands/game/sideQuest/commands/drone.js +1 -1
  41. package/bundle/typescript/src/commands/game/sideQuest/commands/drone.js.map +1 -1
  42. package/bundle/typescript/src/commands/game/sideQuest/commands/go.js +2 -2
  43. package/bundle/typescript/src/commands/game/sideQuest/commands/go.js.map +1 -1
  44. package/bundle/typescript/src/commands/game/sideQuest/commands/grapple.js +5 -1
  45. package/bundle/typescript/src/commands/game/sideQuest/commands/grapple.js.map +1 -1
  46. package/bundle/typescript/src/commands/game/sideQuest/commands/hack.js +6 -6
  47. package/bundle/typescript/src/commands/game/sideQuest/commands/hack.js.map +1 -1
  48. package/bundle/typescript/src/commands/game/sideQuest/commands/haggle.js +4 -4
  49. package/bundle/typescript/src/commands/game/sideQuest/commands/haggle.js.map +1 -1
  50. package/bundle/typescript/src/commands/game/sideQuest/commands/hop.js +1 -1
  51. package/bundle/typescript/src/commands/game/sideQuest/commands/hop.js.map +1 -1
  52. package/bundle/typescript/src/commands/game/sideQuest/commands/initiate.d.ts +20 -0
  53. package/bundle/typescript/src/commands/game/sideQuest/commands/initiate.js +9 -0
  54. package/bundle/typescript/src/commands/game/sideQuest/commands/initiate.js.map +1 -1
  55. package/bundle/typescript/src/commands/game/sideQuest/commands/lead.js +7 -3
  56. package/bundle/typescript/src/commands/game/sideQuest/commands/lead.js.map +1 -1
  57. package/bundle/typescript/src/commands/game/sideQuest/commands/move.js +3 -3
  58. package/bundle/typescript/src/commands/game/sideQuest/commands/move.js.map +1 -1
  59. package/bundle/typescript/src/commands/game/sideQuest/commands/persuade.js +1 -1
  60. package/bundle/typescript/src/commands/game/sideQuest/commands/persuade.js.map +1 -1
  61. package/bundle/typescript/src/commands/game/sideQuest/commands/rest.js +3 -3
  62. package/bundle/typescript/src/commands/game/sideQuest/commands/rest.js.map +1 -1
  63. package/bundle/typescript/src/commands/game/sideQuest/commands/search.js +9 -9
  64. package/bundle/typescript/src/commands/game/sideQuest/commands/sheet.js +10 -10
  65. package/bundle/typescript/src/commands/game/sideQuest/commands/sheet.js.map +1 -1
  66. package/bundle/typescript/src/commands/game/sideQuest/commands/source.js +7 -7
  67. package/bundle/typescript/src/commands/game/sideQuest/commands/tap.js +1 -1
  68. package/bundle/typescript/src/commands/game/sideQuest/commands/tap.js.map +1 -1
  69. package/bundle/typescript/src/commands/game/sideQuest/factories/chargen-factory.d.ts +24 -0
  70. package/bundle/typescript/src/commands/game/sideQuest/factories/chargen-factory.js +95 -0
  71. package/bundle/typescript/src/commands/game/sideQuest/factories/chargen-factory.js.map +1 -1
  72. package/bundle/typescript/src/commands/game/sideQuest/factories/scene-chunks.js +443 -443
  73. package/bundle/typescript/src/commands/game/sideQuest/factories/scene-factory.js +6 -6
  74. package/bundle/typescript/src/commands/game/sideQuest/game.d.ts +45 -1
  75. package/bundle/typescript/src/commands/game/sideQuest/game.js +120 -9
  76. package/bundle/typescript/src/commands/game/sideQuest/game.js.map +1 -1
  77. package/bundle/typescript/src/commands/game/sideQuest/metatypes.d.ts +53 -0
  78. package/bundle/typescript/src/commands/game/sideQuest/metatypes.js +86 -0
  79. package/bundle/typescript/src/commands/game/sideQuest/metatypes.js.map +1 -0
  80. package/bundle/typescript/src/commands/game/sideQuest/models/npc.js +214 -208
  81. package/bundle/typescript/src/commands/game/sideQuest/models/npc.js.map +1 -1
  82. package/bundle/typescript/src/commands/game/sideQuest/models/player.d.ts +215 -18
  83. package/bundle/typescript/src/commands/game/sideQuest/models/player.js +548 -117
  84. package/bundle/typescript/src/commands/game/sideQuest/models/player.js.map +1 -1
  85. package/bundle/typescript/src/commands/game/sideQuest/models/room.js +9 -9
  86. package/bundle/typescript/src/commands/game/sideQuest/models/scene.d.ts +2 -1
  87. package/bundle/typescript/src/commands/game/sideQuest/models/scene.js +3 -2
  88. package/bundle/typescript/src/commands/game/sideQuest/models/scene.js.map +1 -1
  89. package/bundle/typescript/src/commands/game/sideQuest/qualities.d.ts +96 -4
  90. package/bundle/typescript/src/commands/game/sideQuest/qualities.js +290 -11
  91. package/bundle/typescript/src/commands/game/sideQuest/qualities.js.map +1 -1
  92. package/bundle/typescript/src/commands/game/sideQuest/scenes/scene1.json +556 -556
  93. package/bundle/typescript/src/commands/game/sideQuest/scenes/scene2.json +1447 -1447
  94. package/bundle/typescript/src/commands/game/sideQuest/skill-groups.d.ts +11 -1
  95. package/bundle/typescript/src/commands/game/sideQuest/skill-groups.js +13 -1
  96. package/bundle/typescript/src/commands/game/sideQuest/skill-groups.js.map +1 -1
  97. package/bundle/typescript/src/commands/game/sideQuest/skills.d.ts +17 -0
  98. package/bundle/typescript/src/commands/game/sideQuest/skills.js +23 -0
  99. package/bundle/typescript/src/commands/game/sideQuest/skills.js.map +1 -0
  100. package/bundle/typescript/src/commands/game/sideQuest/spells.d.ts +76 -3
  101. package/bundle/typescript/src/commands/game/sideQuest/spells.js +48 -21
  102. package/bundle/typescript/src/commands/game/sideQuest/spells.js.map +1 -1
  103. package/bundle/typescript/src/commands/game/sideQuest/types/save-file.d.ts +8 -0
  104. package/bundle/typescript/src/commands/game/sideQuest/utilities/catalog-data.d.ts +90 -82
  105. package/bundle/typescript/src/commands/game/sideQuest/utilities/catalog-data.js +277 -10
  106. package/bundle/typescript/src/commands/game/sideQuest/utilities/catalog-data.js.map +1 -1
  107. package/bundle/typescript/src/commands/game/sideQuest/utilities/catalog.d.ts +121 -2
  108. package/bundle/typescript/src/commands/game/sideQuest/utilities/catalog.js +342 -18
  109. package/bundle/typescript/src/commands/game/sideQuest/utilities/catalog.js.map +1 -1
  110. package/bundle/typescript/src/commands/game/sideQuest/utilities/cloud-saves.d.ts +65 -2
  111. package/bundle/typescript/src/commands/game/sideQuest/utilities/cloud-saves.js +74 -7
  112. package/bundle/typescript/src/commands/game/sideQuest/utilities/cloud-saves.js.map +1 -1
  113. package/bundle/typescript/src/commands/game/sideQuest/utilities/combat-exchange.js +1 -1
  114. package/bundle/typescript/src/commands/game/sideQuest/utilities/combat-exchange.js.map +1 -1
  115. package/bundle/typescript/src/commands/game/sideQuest/utilities/effects.d.ts +248 -0
  116. package/bundle/typescript/src/commands/game/sideQuest/utilities/effects.js +38 -0
  117. package/bundle/typescript/src/commands/game/sideQuest/utilities/effects.js.map +1 -0
  118. package/bundle/typescript/src/commands/game/sideQuest/utilities/ephemeral.js +14 -14
  119. package/bundle/typescript/src/commands/game/sideQuest/utilities/first-aid.js +1 -2
  120. package/bundle/typescript/src/commands/game/sideQuest/utilities/first-aid.js.map +1 -1
  121. package/bundle/typescript/src/commands/game/sideQuest/utilities/perception.js +1 -2
  122. package/bundle/typescript/src/commands/game/sideQuest/utilities/perception.js.map +1 -1
  123. package/bundle/typescript/src/commands/game/sideQuest/utilities/persistence.js +5 -0
  124. package/bundle/typescript/src/commands/game/sideQuest/utilities/persistence.js.map +1 -1
  125. package/bundle/typescript/src/commands/game/sideQuest/utilities/planes.js +5 -1
  126. package/bundle/typescript/src/commands/game/sideQuest/utilities/planes.js.map +1 -1
  127. package/bundle/typescript/src/commands/game/sideQuest/utilities/pregen-worksheet.js +22 -12
  128. package/bundle/typescript/src/commands/game/sideQuest/utilities/pregen-worksheet.js.map +1 -1
  129. package/bundle/typescript/src/commands/game/sideQuest/utilities/spots.js +1 -2
  130. package/bundle/typescript/src/commands/game/sideQuest/utilities/spots.js.map +1 -1
  131. package/bundle/typescript/src/commands/game/sideQuest/utilities/web-character-generator.d.ts +1 -0
  132. package/bundle/typescript/src/commands/game/sideQuest/utilities/web-character-generator.js +20 -0
  133. package/bundle/typescript/src/commands/game/sideQuest/utilities/web-character-generator.js.map +1 -1
  134. package/bundle/typescript/src/commands/game/sideQuest-backlog.sub.cmd.js +2 -2
  135. package/bundle/typescript/src/commands/game/sideQuest.sub.cmd.js +33 -2
  136. package/bundle/typescript/src/commands/game/sideQuest.sub.cmd.js.map +1 -1
  137. package/bundle/typescript/src/commands/generate.js +2 -2
  138. package/bundle/typescript/src/commands/lint.js +10 -10
  139. package/bundle/typescript/src/commands/login.js +19 -1
  140. package/bundle/typescript/src/commands/login.js.map +1 -1
  141. package/bundle/typescript/src/commands/logout.js +16 -1
  142. package/bundle/typescript/src/commands/logout.js.map +1 -1
  143. package/bundle/typescript/src/commands/maka.cmd.js +26 -26
  144. package/bundle/typescript/src/commands/murder.js +14 -14
  145. package/bundle/typescript/src/commands/proxy.js +13 -13
  146. package/bundle/typescript/src/commands/remote/reconfig.sub.cmd.js +6 -6
  147. package/bundle/typescript/src/commands/run/docker.sub.cmd.js +11 -11
  148. package/bundle/typescript/src/commands/run/run.command.js +24 -24
  149. package/bundle/typescript/src/commands/set/global.sub.cmd.js +8 -8
  150. package/bundle/typescript/src/commands/set/local.sub.cmd.js +2 -2
  151. package/bundle/typescript/src/commands/set/set.command.js +3 -3
  152. package/bundle/typescript/src/commands/testCmd/test.command.js +2 -2
  153. package/bundle/typescript/src/exec.js +0 -0
  154. package/bundle/typescript/src/generators/api.js +11 -11
  155. package/bundle/typescript/src/generators/collection.js +6 -6
  156. package/bundle/typescript/src/generators/hook.js +10 -10
  157. package/bundle/typescript/src/generators/kits/auth/auth.generator.js +2 -2
  158. package/bundle/typescript/src/generators/kits/auth/auth0-meteor.auth.gen.js +612 -612
  159. package/bundle/typescript/src/generators/kits/auth/basic-meteor.auth.gen.js +48 -48
  160. package/bundle/typescript/src/generators/kits/auth/provider.auth.gen.js +12 -12
  161. package/bundle/typescript/src/generators/kits/esri/esri.generator.js +3 -3
  162. package/bundle/typescript/src/generators/kits/esri/map.esri.gen.js +7 -7
  163. package/bundle/typescript/src/generators/kits/frames/frames.generator.js +16 -16
  164. package/bundle/typescript/src/generators/kits/mui/auth.mui.gen.js +2 -2
  165. package/bundle/typescript/src/generators/kits/mui/auth0.mui.gen.js +5 -5
  166. package/bundle/typescript/src/generators/kits/mui/frame.mui.gen.js +4 -4
  167. package/bundle/typescript/src/generators/kits/mui/mui.generator.js +22 -22
  168. package/bundle/typescript/src/generators/services/translation.js +5 -5
  169. package/bundle/typescript/src/templates/aws/cloudformation/create-ec2-instance.template +14 -14
  170. package/bundle/typescript/src/templates/meteor/api/api.js +20 -20
  171. package/bundle/typescript/src/templates/meteor/api/api.js.ts +20 -20
  172. package/bundle/typescript/src/templates/meteor/api/apollo-gateway.js +50 -50
  173. package/bundle/typescript/src/templates/meteor/api/apollo-gateway.js.ts +55 -55
  174. package/bundle/typescript/src/templates/meteor/api/graphql-api.js +63 -63
  175. package/bundle/typescript/src/templates/meteor/api/graphql-api.js.ts +69 -69
  176. package/bundle/typescript/src/templates/meteor/api/methods.js +39 -39
  177. package/bundle/typescript/src/templates/meteor/api/methods.js.ts +40 -40
  178. package/bundle/typescript/src/templates/meteor/api/register-api.js +3 -3
  179. package/bundle/typescript/src/templates/meteor/api/register-api.js.ts +3 -3
  180. package/bundle/typescript/src/templates/meteor/api/resolvers.js +9 -9
  181. package/bundle/typescript/src/templates/meteor/api/resolvers.js.ts +9 -9
  182. package/bundle/typescript/src/templates/meteor/api/typeDefs.js +6 -6
  183. package/bundle/typescript/src/templates/meteor/api/typeDefs.js.ts +6 -6
  184. package/bundle/typescript/src/templates/meteor/app/client/body.html +3 -3
  185. package/bundle/typescript/src/templates/meteor/app/client/head.html +12 -12
  186. package/bundle/typescript/src/templates/meteor/app/client/main.js +15 -15
  187. package/bundle/typescript/src/templates/meteor/app/client/main.js.jsx +15 -15
  188. package/bundle/typescript/src/templates/meteor/app/client/main.js.ts +17 -17
  189. package/bundle/typescript/src/templates/meteor/app/client/main.js.tsx +17 -17
  190. package/bundle/typescript/src/templates/meteor/app/imports/startup/client/index.js +20 -20
  191. package/bundle/typescript/src/templates/meteor/app/imports/startup/client/index.js.jsx +107 -107
  192. package/bundle/typescript/src/templates/meteor/app/imports/startup/client/index.js.ts +20 -20
  193. package/bundle/typescript/src/templates/meteor/app/imports/startup/client/index.js.tsx +108 -108
  194. package/bundle/typescript/src/templates/meteor/app/imports/startup/client/routes.js +39 -39
  195. package/bundle/typescript/src/templates/meteor/app/imports/startup/client/routes.js.jsx +33 -33
  196. package/bundle/typescript/src/templates/meteor/app/imports/startup/client/routes.js.ts +24 -24
  197. package/bundle/typescript/src/templates/meteor/app/imports/startup/client/routes.js.tsx +33 -33
  198. package/bundle/typescript/src/templates/meteor/app/imports/startup/client/templates.js +9 -9
  199. package/bundle/typescript/src/templates/meteor/app/imports/startup/client/templates.js.jsx +9 -9
  200. package/bundle/typescript/src/templates/meteor/app/imports/startup/client/templates.js.ts +9 -9
  201. package/bundle/typescript/src/templates/meteor/app/imports/startup/client/templates.js.tsx +9 -9
  202. package/bundle/typescript/src/templates/meteor/app/imports/startup/lib/index.js +1 -1
  203. package/bundle/typescript/src/templates/meteor/app/imports/startup/lib/index.js.jsx +20 -20
  204. package/bundle/typescript/src/templates/meteor/app/imports/startup/lib/index.js.ts +1 -1
  205. package/bundle/typescript/src/templates/meteor/app/imports/startup/lib/index.js.tsx +20 -20
  206. package/bundle/typescript/src/templates/meteor/app/imports/startup/lib/routes.js.jsx +28 -28
  207. package/bundle/typescript/src/templates/meteor/app/imports/startup/lib/routes.js.tsx +28 -28
  208. package/bundle/typescript/src/templates/meteor/app/imports/startup/server/index.js +1 -1
  209. package/bundle/typescript/src/templates/meteor/app/imports/startup/server/index.js.jsx +95 -95
  210. package/bundle/typescript/src/templates/meteor/app/imports/startup/server/index.js.tsx +98 -98
  211. package/bundle/typescript/src/templates/meteor/app/imports/ui/test-helpers.js +24 -24
  212. package/bundle/typescript/src/templates/meteor/app/imports/ui/test-helpers.js.ts +24 -24
  213. package/bundle/typescript/src/templates/meteor/app/lib/main.js +3 -3
  214. package/bundle/typescript/src/templates/meteor/app/lib/main.js.jsx +3 -3
  215. package/bundle/typescript/src/templates/meteor/app/lib/main.js.ts +3 -3
  216. package/bundle/typescript/src/templates/meteor/app/lib/main.js.tsx +3 -3
  217. package/bundle/typescript/src/templates/meteor/app/maka.d.ts +533 -533
  218. package/bundle/typescript/src/templates/meteor/app/meteor.d.ts +181 -181
  219. package/bundle/typescript/src/templates/meteor/app/public/manifest.json +27 -27
  220. package/bundle/typescript/src/templates/meteor/app/public/sw.js +30 -30
  221. package/bundle/typescript/src/templates/meteor/app/public/sw.js.jsx +30 -30
  222. package/bundle/typescript/src/templates/meteor/app/public/sw.js.ts +30 -30
  223. package/bundle/typescript/src/templates/meteor/app/public/sw.js.tsx +30 -30
  224. package/bundle/typescript/src/templates/meteor/app/server/helmet-csp.js +179 -179
  225. package/bundle/typescript/src/templates/meteor/app/server/helmet-csp.js.jsx +179 -179
  226. package/bundle/typescript/src/templates/meteor/app/server/helmet-csp.js.ts +179 -179
  227. package/bundle/typescript/src/templates/meteor/app/server/helmet-csp.js.tsx +179 -179
  228. package/bundle/typescript/src/templates/meteor/app/server/main.js +13 -13
  229. package/bundle/typescript/src/templates/meteor/app/server/main.js.jsx +13 -13
  230. package/bundle/typescript/src/templates/meteor/app/server/main.js.ts +14 -14
  231. package/bundle/typescript/src/templates/meteor/app/server/main.js.tsx +14 -14
  232. package/bundle/typescript/src/templates/meteor/app/tsconfig.json +42 -42
  233. package/bundle/typescript/src/templates/meteor/collection/collection.js +51 -51
  234. package/bundle/typescript/src/templates/meteor/collection/collection.js.ts +55 -55
  235. package/bundle/typescript/src/templates/meteor/collection/tests.js +27 -27
  236. package/bundle/typescript/src/templates/meteor/collection/tests.js.ts +27 -27
  237. package/bundle/typescript/src/templates/meteor/config/deploy.sh.template +101 -101
  238. package/bundle/typescript/src/templates/meteor/config/docker-compose.yaml +17 -17
  239. package/bundle/typescript/src/templates/meteor/config/nginx.conf.template +31 -31
  240. package/bundle/typescript/src/templates/meteor/config/pm2.config.js +27 -27
  241. package/bundle/typescript/src/templates/meteor/config/process.env +5 -5
  242. package/bundle/typescript/src/templates/meteor/config/settings.json +11 -11
  243. package/bundle/typescript/src/templates/meteor/config/ssh.json +6 -6
  244. package/bundle/typescript/src/templates/meteor/dbc/config.js +70 -70
  245. package/bundle/typescript/src/templates/meteor/dbc/config.js.ts +70 -70
  246. package/bundle/typescript/src/templates/meteor/dbc/conn.js +37 -37
  247. package/bundle/typescript/src/templates/meteor/dbc/conn.js.ts +37 -37
  248. package/bundle/typescript/src/templates/meteor/dbc/register-dbc.js +3 -3
  249. package/bundle/typescript/src/templates/meteor/dbc/register-dbc.js.ts +3 -3
  250. package/bundle/typescript/src/templates/meteor/github/workflows/deploy.yaml +150 -150
  251. package/bundle/typescript/src/templates/meteor/method/method.js +48 -48
  252. package/bundle/typescript/src/templates/meteor/method/method.js.ts +48 -48
  253. package/bundle/typescript/src/templates/meteor/package/package.js +37 -37
  254. package/bundle/typescript/src/templates/meteor/package/package.js.jsx +37 -37
  255. package/bundle/typescript/src/templates/meteor/package/package.js.ts +36 -36
  256. package/bundle/typescript/src/templates/meteor/package/package.js.tsx +37 -37
  257. package/bundle/typescript/src/templates/meteor/package/tests/client/package.js +5 -5
  258. package/bundle/typescript/src/templates/meteor/package/tests/client/package.js.jsx +5 -5
  259. package/bundle/typescript/src/templates/meteor/package/tests/client/package.js.ts +5 -5
  260. package/bundle/typescript/src/templates/meteor/package/tests/client/package.js.tsx +5 -5
  261. package/bundle/typescript/src/templates/meteor/package/tests/server/package.js +5 -5
  262. package/bundle/typescript/src/templates/meteor/package/tests/server/package.js.jsx +5 -5
  263. package/bundle/typescript/src/templates/meteor/package/tests/server/package.js.ts +5 -5
  264. package/bundle/typescript/src/templates/meteor/package/tests/server/package.js.tsx +5 -5
  265. package/bundle/typescript/src/templates/meteor/project/.maka/config.json +29 -29
  266. package/bundle/typescript/src/templates/meteor/project/README.md +33 -33
  267. package/bundle/typescript/src/templates/meteor/project/build/README +4 -4
  268. package/bundle/typescript/src/templates/meteor/project/gitignore +10 -10
  269. package/bundle/typescript/src/templates/meteor/project/package.json +29 -29
  270. package/bundle/typescript/src/templates/meteor/publish/publish.js +7 -7
  271. package/bundle/typescript/src/templates/meteor/publish/publish.js.ts +7 -7
  272. package/bundle/typescript/src/templates/meteor/service/logger/logger.js +27 -27
  273. package/bundle/typescript/src/templates/meteor/service/logger/logger.js.ts +27 -27
  274. package/bundle/typescript/src/templates/meteor/stylesheet/stylesheet.css +5 -5
  275. package/bundle/typescript/src/templates/meteor/stylesheet/stylesheet.css.less +5 -5
  276. package/bundle/typescript/src/templates/meteor/template/template-tests.js +1 -1
  277. package/bundle/typescript/src/templates/meteor/template/template-tests.js.jsx +55 -55
  278. package/bundle/typescript/src/templates/meteor/template/template-tests.js.ts +1 -1
  279. package/bundle/typescript/src/templates/meteor/template/template-tests.js.tsx +55 -55
  280. package/bundle/typescript/src/templates/meteor/template/template.css +3 -3
  281. package/bundle/typescript/src/templates/meteor/template/template.css.less +3 -3
  282. package/bundle/typescript/src/templates/meteor/template/template.css.scss +3 -3
  283. package/bundle/typescript/src/templates/meteor/template/template.html +5 -5
  284. package/bundle/typescript/src/templates/meteor/template/template.js +20 -20
  285. package/bundle/typescript/src/templates/meteor/template/template.js.jsx +77 -77
  286. package/bundle/typescript/src/templates/meteor/template/template.js.ts +1 -1
  287. package/bundle/typescript/src/templates/meteor/template/template.js.tsx +89 -89
  288. package/bundle/typescript/src/templates/react/component/component.css +6 -6
  289. package/bundle/typescript/src/templates/react/component/component.css.less +6 -6
  290. package/bundle/typescript/src/templates/react/component/component.css.scss +3 -3
  291. package/bundle/typescript/src/templates/react/component/component.js.jsx +59 -59
  292. package/bundle/typescript/src/templates/react/component/component.js.tsx +65 -65
  293. package/bundle/typescript/src/templates/react/hook/hook.css +3 -3
  294. package/bundle/typescript/src/templates/react/hook/hook.css.scss +3 -3
  295. package/bundle/typescript/src/templates/react/hook/hook.js.jsx +19 -19
  296. package/bundle/typescript/src/templates/react/hook/hook.js.tsx +19 -19
  297. package/bundle/typescript/src/templates/react/kit/auth/provider/authentication-provider.js.jsx +306 -306
  298. package/bundle/typescript/src/templates/react/kit/auth/provider/authentication-provider.js.tsx +350 -350
  299. package/bundle/typescript/src/templates/react/kit/auth/service/auth0-client.js.jsx +178 -178
  300. package/bundle/typescript/src/templates/react/kit/auth/service/auth0-client.js.tsx +178 -178
  301. package/bundle/typescript/src/templates/react/kit/auth/service/auth0-config.js.jsx +59 -59
  302. package/bundle/typescript/src/templates/react/kit/auth/service/auth0-config.js.tsx +67 -67
  303. package/bundle/typescript/src/templates/react/kit/auth/service/auth0-methods.js.jsx +273 -273
  304. package/bundle/typescript/src/templates/react/kit/auth/service/auth0-methods.js.tsx +275 -275
  305. package/bundle/typescript/src/templates/react/kit/auth/service/auth0-validator.js.jsx +182 -182
  306. package/bundle/typescript/src/templates/react/kit/auth/service/auth0-validator.js.tsx +199 -199
  307. package/bundle/typescript/src/templates/react/kit/auth/service/meteor-auth-service.js.jsx +138 -138
  308. package/bundle/typescript/src/templates/react/kit/auth/service/meteor-auth-service.js.tsx +153 -153
  309. package/bundle/typescript/src/templates/react/kit/esri/map/basic-map.js.jsx +29 -29
  310. package/bundle/typescript/src/templates/react/kit/esri/map/basic-map.js.tsx +32 -32
  311. package/bundle/typescript/src/templates/react/kit/frames/frames-demo.css +63 -63
  312. package/bundle/typescript/src/templates/react/kit/frames/frames-demo.jsx +153 -153
  313. package/bundle/typescript/src/templates/react/kit/frames/frames-demo.tsx +164 -164
  314. package/bundle/typescript/src/templates/react/kit/frames/workspace-manager.css +105 -105
  315. package/bundle/typescript/src/templates/react/kit/frames/workspace-manager.jsx +158 -158
  316. package/bundle/typescript/src/templates/react/kit/frames/workspace-manager.tsx +166 -166
  317. package/bundle/typescript/src/templates/react/kit/mui/auth/forgot-password/basic-forgot-password-page.js.jsx +34 -34
  318. package/bundle/typescript/src/templates/react/kit/mui/auth/forgot-password/basic-forgot-password-page.js.tsx +33 -33
  319. package/bundle/typescript/src/templates/react/kit/mui/auth/login/basic-login-page.js.jsx +53 -53
  320. package/bundle/typescript/src/templates/react/kit/mui/auth/login/basic-login-page.js.tsx +53 -53
  321. package/bundle/typescript/src/templates/react/kit/mui/auth/logout/basic-logout-page.js.jsx +25 -25
  322. package/bundle/typescript/src/templates/react/kit/mui/auth/logout/basic-logout-page.js.tsx +25 -25
  323. package/bundle/typescript/src/templates/react/kit/mui/auth/password-reset/basic-password-reset-page.js.jsx +41 -41
  324. package/bundle/typescript/src/templates/react/kit/mui/auth/password-reset/basic-password-reset-page.js.tsx +34 -34
  325. package/bundle/typescript/src/templates/react/kit/mui/auth/register/basic-register-page.js.jsx +33 -33
  326. package/bundle/typescript/src/templates/react/kit/mui/auth/register/basic-register-page.js.tsx +33 -33
  327. package/bundle/typescript/src/templates/react/kit/mui/auth0/auth-callback.js.jsx +71 -71
  328. package/bundle/typescript/src/templates/react/kit/mui/auth0/auth-callback.js.tsx +71 -71
  329. package/bundle/typescript/src/templates/react/kit/mui/auth0/auth0-account-settings.js.jsx +123 -123
  330. package/bundle/typescript/src/templates/react/kit/mui/auth0/auth0-account-settings.js.tsx +123 -123
  331. package/bundle/typescript/src/templates/react/kit/mui/auth0/auth0-login-button.js.jsx +56 -56
  332. package/bundle/typescript/src/templates/react/kit/mui/auth0/auth0-login-button.js.tsx +74 -74
  333. package/bundle/typescript/src/templates/react/kit/mui/frame/app-bars/basic-app-bar.js.jsx +43 -43
  334. package/bundle/typescript/src/templates/react/kit/mui/frame/app-bars/basic-app-bar.js.tsx +43 -43
  335. package/bundle/typescript/src/templates/react/kit/mui/frame/drawers/basic-drawer.js.jsx +121 -121
  336. package/bundle/typescript/src/templates/react/kit/mui/frame/drawers/basic-drawer.js.tsx +117 -117
  337. package/bundle/typescript/src/templates/react/kit/mui/frame/footers/basic-sticky-footer.js.jsx +41 -41
  338. package/bundle/typescript/src/templates/react/kit/mui/frame/footers/basic-sticky-footer.js.tsx +41 -41
  339. package/bundle/typescript/src/templates/react/route/route.js +8 -8
  340. package/bundle/typescript/src/templates/react/route/route.js.jsx +5 -5
  341. package/bundle/typescript/src/templates/react/route/route.js.ts +8 -8
  342. package/bundle/typescript/src/templates/react/route/route.js.tsx +5 -5
  343. package/bundle/typescript/src/templates/react/test/test.js +1 -1
  344. package/bundle/typescript/src/templates/react/test/test.js.jsx +40 -40
  345. package/bundle/typescript/src/templates/react/test/test.js.ts +1 -1
  346. package/bundle/typescript/src/templates/react/test/test.js.tsx +40 -40
  347. package/bundle/typescript/src/templates/service/docker/Dockerfile +54 -54
  348. package/bundle/typescript/src/templates/service/eslint/babel.config.js +16 -16
  349. package/bundle/typescript/src/templates/service/eslint/config.eslint.js +69 -69
  350. package/bundle/typescript/src/templates/service/i18n/i18n.js +33 -33
  351. package/bundle/typescript/src/templates/service/i18n/i18n.js.ts +33 -33
  352. package/bundle/typescript/src/templates/service/i18n/locales.js +3 -3
  353. package/bundle/typescript/src/templates/service/i18n/locales.js.ts +3 -3
  354. package/bundle/typescript/src/templates/service/openssl/openssl.conf +22 -22
  355. package/bundle/typescript/src/templates/service/test/jest/jest.config.js +24 -24
  356. package/bundle/typescript/src/templates/service/test/jest/jest.setup.js +7 -7
  357. package/bundle/typescript/src/tools/guarded-file/guarded-file.class.d.ts +59 -0
  358. package/bundle/typescript/src/tools/guarded-file/guarded-file.class.js +120 -0
  359. package/bundle/typescript/src/tools/guarded-file/guarded-file.class.js.map +1 -0
  360. package/bundle/typescript/src/tools/mpi/mpi.class.d.ts +16 -0
  361. package/bundle/typescript/src/tools/mpi/mpi.class.js +25 -7
  362. package/bundle/typescript/src/tools/mpi/mpi.class.js.map +1 -1
  363. package/bundle/typescript/src/tools/mpi/sdk-runtime.d.ts +1 -0
  364. package/bundle/typescript/src/tools/mpi/sdk-runtime.js +29 -0
  365. package/bundle/typescript/src/tools/mpi/sdk-runtime.js.map +1 -1
  366. package/package.json +120 -120
@@ -1,350 +1,350 @@
1
- import { Meteor } from 'meteor/meteor';
2
- import React, { createContext, useState, useEffect, ReactNode, useMemo } from 'react';
3
-
4
- // Define types for user and credentials
5
- // These are just placeholders to demonstrate the concept.
6
- // TODO: Define a user for your application
7
- export interface User {
8
- name: string;
9
- id: string;
10
- }
11
-
12
- interface Credentials {
13
- username?: string;
14
- password?: string;
15
- token?: string;
16
- }
17
-
18
- // Define type for the AuthProvider's props
19
- interface AuthProviderProps {
20
- children: ReactNode;
21
- timeoutDuration?: number;
22
- }
23
-
24
- interface AuthContextValue {
25
- currentUser: User | null;
26
- userAuthorizations: string[];
27
- login: (credentials: Credentials) => Promise<User | null>;
28
- logout: () => Promise<void>;
29
- loading: boolean;
30
- forgotPassword: (email: string) => Promise<boolean>;
31
- resetPassword: (token: string, password: string) => Promise<boolean>;
32
- register: (email: string, password: string) => Promise<User | null>;
33
- }
34
-
35
- // Authorization Context
36
- export const AuthContext = createContext<AuthContextValue | null>(null);
37
-
38
- // catch (error) is typed `unknown` under strict mode -- narrow before reading .message.
39
- const getErrorMessage = (error: unknown): string => (error instanceof Error ? error.message : String(error));
40
-
41
- /**
42
- * Maka-CLI will replace the contents of these functions with
43
- * a template that you can customize to fit your application's needs.
44
- */
45
- const authenticateUser = async (username: string, password: string): Promise<User | null> => {
46
- // Replace these with your actual authentication logic
47
- // and define what constitutes as a valid user and permissions.
48
- // These are just placeholders to demonstrate the concept.
49
-
50
- // TODO: Remove this once you've implemented your own authentication logic
51
- if (Meteor.isProduction) {
52
- throw new Error('You must implement your own authentication logic');
53
- }
54
- // Simulated user authentication
55
- // Replace with API call or other logic
56
- if (username === 'test' && password === 'password') {
57
- localStorage.setItem('token', 'valid-token');
58
- return { name: 'Test User', id: '12345' };
59
- }
60
- throw new Error('Invalid credentials');
61
- };
62
-
63
- const authenticateToken = async (): Promise<User | null> => {
64
- // TODO: Remove this once you've implemented your own authentication logic
65
- if (Meteor.isProduction) {
66
- throw new Error('You must implement your own authentication logic');
67
- }
68
-
69
- // A token should either already exist as a result of the login process
70
- // or another sso style login
71
- const token = localStorage.getItem('token');
72
- // Simulated token validation
73
- // Replace with token validation logic
74
- //
75
- // Note: This is a very basic example of token validation.
76
- // You should add additional logic to validate the token
77
- // as well as handle token expiration, renewal, etc.
78
- if (token === 'valid-token') {
79
- return { name: 'Token User', id: '67890' };
80
- }
81
- throw new Error('Invalid token');
82
- };
83
-
84
- const getUserAuthorizations = async (user: User): Promise<string[]> => {
85
- // Placeholder function to simulate fetching user permissions
86
-
87
- // TODO: Remove this once you've implemented your own authentication logic
88
- if (Meteor.isProduction) {
89
- throw new Error('You must implement your own permission logic');
90
- }
91
- // Simulate an API call to fetch permissions, or other logic
92
- // such as parsing a JWT token to retrieve permissions
93
- // Replace with your actual logic
94
- if (user.id === '12345') {
95
- return ['read', 'write', 'edit'];
96
- }
97
- return [];
98
- };
99
-
100
- const deauthenticateUser = async (): Promise<void> => {
101
- // Placeholder function to simulate deauthorizing a user
102
- // TODO: Remove this once you've implemented your own authentication logic
103
- if (Meteor.isProduction) {
104
- throw new Error('You must implement your own deauthorization logic');
105
- }
106
-
107
- // Simulate an API call to deauthorize a user
108
- // Replace with your actual logic
109
- // Note: This is a very basic example of deauthorization.
110
- // You should add additional logic to deauthorize the user
111
- // and handle any errors that may occur.
112
- };
113
-
114
- const sendForgotPasswordEmail = async (email: string) => {
115
- // Placeholder function to simulate sending a password reset email
116
- // TODO: Remove this once you've implemented your own authentication logic
117
- if (Meteor.isProduction) {
118
- throw new Error('You must implement your own send forgot email logic');
119
- }
120
-
121
- // Simulate an API call to send a password reset email
122
- // Replace with your actual logic
123
- // Note: This is a very basic example of sending a password reset email.
124
- // You should add additional logic to send the email
125
- // and handle any errors that may occur.
126
- console.log(`Sending password reset email to ${email}`);
127
- return true;
128
- };
129
-
130
- const registerNewUser = async (email: string, password: string): Promise<User | null> => {
131
- // Placeholder function to simulate registering a new user
132
- // TODO: Remove this once you've implemented your own authentication logic
133
- if (Meteor.isProduction) {
134
- throw new Error('You must implement your own registration logic');
135
- }
136
-
137
- console.log(`Registering new user with email ${email}`);
138
- console.log(`Registering new user with password ${password.length} characters`);
139
- return { name: email, id: 'new-user' };
140
- };
141
-
142
- const resetPasswordWithToken = async (token: string, password: string): Promise<User | null> => {
143
- // Placeholder function to simulate resetting a password with a token
144
- // TODO: Remove this once you've implemented your own authentication logic
145
- if (Meteor.isProduction) {
146
- throw new Error('You must implement your own password reset logic');
147
- }
148
-
149
- console.log(`Resetting password with token ${token}`);
150
- console.log(`Resetting password with password ${password.length} characters`);
151
- return { name: 'Token User', id: 'reset-user' };
152
- };
153
-
154
-
155
- // Authorization Provider
156
- export const AuthProvider = ({ children, timeoutDuration = 3600000 }: AuthProviderProps) => {
157
- const [currentUser, setCurrentUser] = useState<User | null>(null);
158
- const [userAuthorizations, setUserAuthorizations] = useState<string[]>([]);
159
- const [loading, setLoading] = useState<boolean>(true);
160
- const [alert, setAlert] = useState({ show: false, message: '', severity: '' });
161
-
162
- const setAlertMessage = (message: string, severity: string) => {
163
- setAlert({ show: true, message, severity });
164
- setTimeout(() => setAlert({ show: false, message: '', severity: '' }), 5000); // Auto-hide after 5 seconds
165
- };
166
-
167
- const logout = async () => {
168
- try {
169
- if (currentUser) {
170
- await deauthenticateUser();
171
- setCurrentUser(null);
172
- setLoading(false);
173
- setAlertMessage('Logout successful!', 'success');
174
- }
175
- } catch (error) {
176
- setAlertMessage('Logout failed: ' + getErrorMessage(error), 'error');
177
- }
178
- };
179
-
180
- const loginUserWithUsernameAndPassword = async (username: string, password: string) => {
181
- // Add logic for username/password authentication
182
- // E.g., call a backend API and validate the credentials
183
- try {
184
- const user = await authenticateUser(username, password);
185
- setCurrentUser(user);
186
- setLoading(false);
187
- setAlertMessage('Login successful!', 'success');
188
- return user;
189
- } catch (error) {
190
- setLoading(false);
191
- setCurrentUser(null);
192
- setAlertMessage('Login failed: ' + getErrorMessage(error), 'error');
193
- return null;
194
- }
195
- };
196
-
197
- const login = async (credentials: Credentials) => {
198
- // Check the type of credentials provided and call the appropriate method
199
- if (credentials.username && credentials.password) {
200
- // Handle username/password authentication
201
- return loginUserWithUsernameAndPassword(credentials.username, credentials.password);
202
- } else {
203
- setLoading(false);
204
- throw new Error('Invalid login credentials');
205
- }
206
- };
207
-
208
- const loginUserWithToken = async () => {
209
- // Add logic for token-based authentication
210
- // E.g., validate the token with your backend or a third-party service
211
- try {
212
- const user = await authenticateToken();
213
- setCurrentUser(user);
214
- setLoading(false);
215
- return user;
216
- } catch (error) {
217
- setLoading(false);
218
- setCurrentUser(null);
219
- setAlertMessage('Login failed: ' + getErrorMessage(error), 'error');
220
- return null;
221
- }
222
- };
223
-
224
- const fetchUserAuthorizations = async (user: User) => {
225
- // Placeholder function to fetch user permissions
226
- // Replace this with your actual logic to retrieve permissions
227
- const authorizations = await getUserAuthorizations(user);
228
- setUserAuthorizations(authorizations);
229
- };
230
-
231
- const forgotPassword = async (email: string) => {
232
- try {
233
- await sendForgotPasswordEmail(email);
234
- setAlertMessage('Please check your email.', 'success');
235
- return true;
236
- } catch (error) {
237
- setAlertMessage('Error sending email: ' + getErrorMessage(error), 'error');
238
- return false;
239
- }
240
- };
241
-
242
- const register = async (email: string, password: string) => {
243
- try {
244
- const user = await registerNewUser(email, password);
245
- setCurrentUser(user);
246
- if (user) {
247
- fetchUserAuthorizations(user); // Fetch permissions when a user logs in
248
- }
249
- setAlertMessage('Registration sucess, welcome!', 'success');
250
- setLoading(false);
251
- return user;
252
- } catch (error) {
253
- setAlertMessage('Register failed: ' + getErrorMessage(error), 'error');
254
- return null;
255
- }
256
- };
257
-
258
- const resetPassword = async (token: string, password: string) => {
259
- try {
260
- const user = await resetPasswordWithToken(token, password);
261
- setCurrentUser(user);
262
- if (user) {
263
- fetchUserAuthorizations(user); // Fetch permissions when a user logs in
264
- }
265
- setAlertMessage('Password reset!', 'success');
266
- setLoading(false);
267
- return true;
268
- } catch (error) {
269
- setAlertMessage('Password reset failed: ' + getErrorMessage(error), 'error');
270
- return false;
271
- }
272
- };
273
-
274
- useEffect(() => {
275
- let logoutTimer: ReturnType<typeof setTimeout>;
276
-
277
- const setLogoutTimer = () => {
278
- if (logoutTimer) {
279
- clearTimeout(logoutTimer);
280
- }
281
- logoutTimer = setTimeout(logout, timeoutDuration);
282
- };
283
-
284
- const checkUserAndSetData = async () => {
285
- if (currentUser) {
286
- setLogoutTimer();
287
- fetchUserAuthorizations(currentUser);
288
- } else {
289
- setLoading(true);
290
- try {
291
- const renewedUser = await loginUserWithToken();
292
- if (renewedUser) {
293
- setCurrentUser(renewedUser);
294
- setLogoutTimer();
295
- fetchUserAuthorizations(renewedUser);
296
- } else {
297
- setUserAuthorizations([]);
298
- }
299
- } catch (error) {
300
- setUserAuthorizations([]);
301
- } finally {
302
- setLoading(false);
303
- }
304
- }
305
- };
306
-
307
- checkUserAndSetData();
308
-
309
- return () => {
310
- clearTimeout(logoutTimer);
311
- };
312
- }, [currentUser, timeoutDuration]);
313
-
314
- const contextValue = useMemo(() => ({
315
- currentUser,
316
- userAuthorizations,
317
- login,
318
- logout,
319
- loading,
320
- forgotPassword,
321
- resetPassword,
322
- register,
323
- }), [currentUser, userAuthorizations, login, logout, loading, forgotPassword, resetPassword, register]);
324
-
325
- return (
326
- <AuthContext.Provider value={contextValue}>
327
- {alert.show && (
328
- <div
329
- role="alert"
330
- style={{
331
- position: 'fixed',
332
- bottom: 20,
333
- right: 20,
334
- zIndex: 100000,
335
- padding: '12px 16px',
336
- borderRadius: 4,
337
- color: '#fff',
338
- backgroundColor: alert.severity === 'error' ? '#d32f2f' : '#2e7d32',
339
- boxShadow: '0 2px 8px rgba(0,0,0,0.25)',
340
- }}
341
- >
342
- {alert.message}
343
- </div>
344
- )}
345
- {children}
346
- </AuthContext.Provider>
347
- );
348
- };
349
-
350
-
1
+ import { Meteor } from 'meteor/meteor';
2
+ import React, { createContext, useState, useEffect, ReactNode, useMemo } from 'react';
3
+
4
+ // Define types for user and credentials
5
+ // These are just placeholders to demonstrate the concept.
6
+ // TODO: Define a user for your application
7
+ export interface User {
8
+ name: string;
9
+ id: string;
10
+ }
11
+
12
+ interface Credentials {
13
+ username?: string;
14
+ password?: string;
15
+ token?: string;
16
+ }
17
+
18
+ // Define type for the AuthProvider's props
19
+ interface AuthProviderProps {
20
+ children: ReactNode;
21
+ timeoutDuration?: number;
22
+ }
23
+
24
+ interface AuthContextValue {
25
+ currentUser: User | null;
26
+ userAuthorizations: string[];
27
+ login: (credentials: Credentials) => Promise<User | null>;
28
+ logout: () => Promise<void>;
29
+ loading: boolean;
30
+ forgotPassword: (email: string) => Promise<boolean>;
31
+ resetPassword: (token: string, password: string) => Promise<boolean>;
32
+ register: (email: string, password: string) => Promise<User | null>;
33
+ }
34
+
35
+ // Authorization Context
36
+ export const AuthContext = createContext<AuthContextValue | null>(null);
37
+
38
+ // catch (error) is typed `unknown` under strict mode -- narrow before reading .message.
39
+ const getErrorMessage = (error: unknown): string => (error instanceof Error ? error.message : String(error));
40
+
41
+ /**
42
+ * Maka-CLI will replace the contents of these functions with
43
+ * a template that you can customize to fit your application's needs.
44
+ */
45
+ const authenticateUser = async (username: string, password: string): Promise<User | null> => {
46
+ // Replace these with your actual authentication logic
47
+ // and define what constitutes as a valid user and permissions.
48
+ // These are just placeholders to demonstrate the concept.
49
+
50
+ // TODO: Remove this once you've implemented your own authentication logic
51
+ if (Meteor.isProduction) {
52
+ throw new Error('You must implement your own authentication logic');
53
+ }
54
+ // Simulated user authentication
55
+ // Replace with API call or other logic
56
+ if (username === 'test' && password === 'password') {
57
+ localStorage.setItem('token', 'valid-token');
58
+ return { name: 'Test User', id: '12345' };
59
+ }
60
+ throw new Error('Invalid credentials');
61
+ };
62
+
63
+ const authenticateToken = async (): Promise<User | null> => {
64
+ // TODO: Remove this once you've implemented your own authentication logic
65
+ if (Meteor.isProduction) {
66
+ throw new Error('You must implement your own authentication logic');
67
+ }
68
+
69
+ // A token should either already exist as a result of the login process
70
+ // or another sso style login
71
+ const token = localStorage.getItem('token');
72
+ // Simulated token validation
73
+ // Replace with token validation logic
74
+ //
75
+ // Note: This is a very basic example of token validation.
76
+ // You should add additional logic to validate the token
77
+ // as well as handle token expiration, renewal, etc.
78
+ if (token === 'valid-token') {
79
+ return { name: 'Token User', id: '67890' };
80
+ }
81
+ throw new Error('Invalid token');
82
+ };
83
+
84
+ const getUserAuthorizations = async (user: User): Promise<string[]> => {
85
+ // Placeholder function to simulate fetching user permissions
86
+
87
+ // TODO: Remove this once you've implemented your own authentication logic
88
+ if (Meteor.isProduction) {
89
+ throw new Error('You must implement your own permission logic');
90
+ }
91
+ // Simulate an API call to fetch permissions, or other logic
92
+ // such as parsing a JWT token to retrieve permissions
93
+ // Replace with your actual logic
94
+ if (user.id === '12345') {
95
+ return ['read', 'write', 'edit'];
96
+ }
97
+ return [];
98
+ };
99
+
100
+ const deauthenticateUser = async (): Promise<void> => {
101
+ // Placeholder function to simulate deauthorizing a user
102
+ // TODO: Remove this once you've implemented your own authentication logic
103
+ if (Meteor.isProduction) {
104
+ throw new Error('You must implement your own deauthorization logic');
105
+ }
106
+
107
+ // Simulate an API call to deauthorize a user
108
+ // Replace with your actual logic
109
+ // Note: This is a very basic example of deauthorization.
110
+ // You should add additional logic to deauthorize the user
111
+ // and handle any errors that may occur.
112
+ };
113
+
114
+ const sendForgotPasswordEmail = async (email: string) => {
115
+ // Placeholder function to simulate sending a password reset email
116
+ // TODO: Remove this once you've implemented your own authentication logic
117
+ if (Meteor.isProduction) {
118
+ throw new Error('You must implement your own send forgot email logic');
119
+ }
120
+
121
+ // Simulate an API call to send a password reset email
122
+ // Replace with your actual logic
123
+ // Note: This is a very basic example of sending a password reset email.
124
+ // You should add additional logic to send the email
125
+ // and handle any errors that may occur.
126
+ console.log(`Sending password reset email to ${email}`);
127
+ return true;
128
+ };
129
+
130
+ const registerNewUser = async (email: string, password: string): Promise<User | null> => {
131
+ // Placeholder function to simulate registering a new user
132
+ // TODO: Remove this once you've implemented your own authentication logic
133
+ if (Meteor.isProduction) {
134
+ throw new Error('You must implement your own registration logic');
135
+ }
136
+
137
+ console.log(`Registering new user with email ${email}`);
138
+ console.log(`Registering new user with password ${password.length} characters`);
139
+ return { name: email, id: 'new-user' };
140
+ };
141
+
142
+ const resetPasswordWithToken = async (token: string, password: string): Promise<User | null> => {
143
+ // Placeholder function to simulate resetting a password with a token
144
+ // TODO: Remove this once you've implemented your own authentication logic
145
+ if (Meteor.isProduction) {
146
+ throw new Error('You must implement your own password reset logic');
147
+ }
148
+
149
+ console.log(`Resetting password with token ${token}`);
150
+ console.log(`Resetting password with password ${password.length} characters`);
151
+ return { name: 'Token User', id: 'reset-user' };
152
+ };
153
+
154
+
155
+ // Authorization Provider
156
+ export const AuthProvider = ({ children, timeoutDuration = 3600000 }: AuthProviderProps) => {
157
+ const [currentUser, setCurrentUser] = useState<User | null>(null);
158
+ const [userAuthorizations, setUserAuthorizations] = useState<string[]>([]);
159
+ const [loading, setLoading] = useState<boolean>(true);
160
+ const [alert, setAlert] = useState({ show: false, message: '', severity: '' });
161
+
162
+ const setAlertMessage = (message: string, severity: string) => {
163
+ setAlert({ show: true, message, severity });
164
+ setTimeout(() => setAlert({ show: false, message: '', severity: '' }), 5000); // Auto-hide after 5 seconds
165
+ };
166
+
167
+ const logout = async () => {
168
+ try {
169
+ if (currentUser) {
170
+ await deauthenticateUser();
171
+ setCurrentUser(null);
172
+ setLoading(false);
173
+ setAlertMessage('Logout successful!', 'success');
174
+ }
175
+ } catch (error) {
176
+ setAlertMessage('Logout failed: ' + getErrorMessage(error), 'error');
177
+ }
178
+ };
179
+
180
+ const loginUserWithUsernameAndPassword = async (username: string, password: string) => {
181
+ // Add logic for username/password authentication
182
+ // E.g., call a backend API and validate the credentials
183
+ try {
184
+ const user = await authenticateUser(username, password);
185
+ setCurrentUser(user);
186
+ setLoading(false);
187
+ setAlertMessage('Login successful!', 'success');
188
+ return user;
189
+ } catch (error) {
190
+ setLoading(false);
191
+ setCurrentUser(null);
192
+ setAlertMessage('Login failed: ' + getErrorMessage(error), 'error');
193
+ return null;
194
+ }
195
+ };
196
+
197
+ const login = async (credentials: Credentials) => {
198
+ // Check the type of credentials provided and call the appropriate method
199
+ if (credentials.username && credentials.password) {
200
+ // Handle username/password authentication
201
+ return loginUserWithUsernameAndPassword(credentials.username, credentials.password);
202
+ } else {
203
+ setLoading(false);
204
+ throw new Error('Invalid login credentials');
205
+ }
206
+ };
207
+
208
+ const loginUserWithToken = async () => {
209
+ // Add logic for token-based authentication
210
+ // E.g., validate the token with your backend or a third-party service
211
+ try {
212
+ const user = await authenticateToken();
213
+ setCurrentUser(user);
214
+ setLoading(false);
215
+ return user;
216
+ } catch (error) {
217
+ setLoading(false);
218
+ setCurrentUser(null);
219
+ setAlertMessage('Login failed: ' + getErrorMessage(error), 'error');
220
+ return null;
221
+ }
222
+ };
223
+
224
+ const fetchUserAuthorizations = async (user: User) => {
225
+ // Placeholder function to fetch user permissions
226
+ // Replace this with your actual logic to retrieve permissions
227
+ const authorizations = await getUserAuthorizations(user);
228
+ setUserAuthorizations(authorizations);
229
+ };
230
+
231
+ const forgotPassword = async (email: string) => {
232
+ try {
233
+ await sendForgotPasswordEmail(email);
234
+ setAlertMessage('Please check your email.', 'success');
235
+ return true;
236
+ } catch (error) {
237
+ setAlertMessage('Error sending email: ' + getErrorMessage(error), 'error');
238
+ return false;
239
+ }
240
+ };
241
+
242
+ const register = async (email: string, password: string) => {
243
+ try {
244
+ const user = await registerNewUser(email, password);
245
+ setCurrentUser(user);
246
+ if (user) {
247
+ fetchUserAuthorizations(user); // Fetch permissions when a user logs in
248
+ }
249
+ setAlertMessage('Registration sucess, welcome!', 'success');
250
+ setLoading(false);
251
+ return user;
252
+ } catch (error) {
253
+ setAlertMessage('Register failed: ' + getErrorMessage(error), 'error');
254
+ return null;
255
+ }
256
+ };
257
+
258
+ const resetPassword = async (token: string, password: string) => {
259
+ try {
260
+ const user = await resetPasswordWithToken(token, password);
261
+ setCurrentUser(user);
262
+ if (user) {
263
+ fetchUserAuthorizations(user); // Fetch permissions when a user logs in
264
+ }
265
+ setAlertMessage('Password reset!', 'success');
266
+ setLoading(false);
267
+ return true;
268
+ } catch (error) {
269
+ setAlertMessage('Password reset failed: ' + getErrorMessage(error), 'error');
270
+ return false;
271
+ }
272
+ };
273
+
274
+ useEffect(() => {
275
+ let logoutTimer: ReturnType<typeof setTimeout>;
276
+
277
+ const setLogoutTimer = () => {
278
+ if (logoutTimer) {
279
+ clearTimeout(logoutTimer);
280
+ }
281
+ logoutTimer = setTimeout(logout, timeoutDuration);
282
+ };
283
+
284
+ const checkUserAndSetData = async () => {
285
+ if (currentUser) {
286
+ setLogoutTimer();
287
+ fetchUserAuthorizations(currentUser);
288
+ } else {
289
+ setLoading(true);
290
+ try {
291
+ const renewedUser = await loginUserWithToken();
292
+ if (renewedUser) {
293
+ setCurrentUser(renewedUser);
294
+ setLogoutTimer();
295
+ fetchUserAuthorizations(renewedUser);
296
+ } else {
297
+ setUserAuthorizations([]);
298
+ }
299
+ } catch (error) {
300
+ setUserAuthorizations([]);
301
+ } finally {
302
+ setLoading(false);
303
+ }
304
+ }
305
+ };
306
+
307
+ checkUserAndSetData();
308
+
309
+ return () => {
310
+ clearTimeout(logoutTimer);
311
+ };
312
+ }, [currentUser, timeoutDuration]);
313
+
314
+ const contextValue = useMemo(() => ({
315
+ currentUser,
316
+ userAuthorizations,
317
+ login,
318
+ logout,
319
+ loading,
320
+ forgotPassword,
321
+ resetPassword,
322
+ register,
323
+ }), [currentUser, userAuthorizations, login, logout, loading, forgotPassword, resetPassword, register]);
324
+
325
+ return (
326
+ <AuthContext.Provider value={contextValue}>
327
+ {alert.show && (
328
+ <div
329
+ role="alert"
330
+ style={{
331
+ position: 'fixed',
332
+ bottom: 20,
333
+ right: 20,
334
+ zIndex: 100000,
335
+ padding: '12px 16px',
336
+ borderRadius: 4,
337
+ color: '#fff',
338
+ backgroundColor: alert.severity === 'error' ? '#d32f2f' : '#2e7d32',
339
+ boxShadow: '0 2px 8px rgba(0,0,0,0.25)',
340
+ }}
341
+ >
342
+ {alert.message}
343
+ </div>
344
+ )}
345
+ {children}
346
+ </AuthContext.Provider>
347
+ );
348
+ };
349
+
350
+