franchising 0.0.0-stage → 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 (227) hide show
  1. package/LICENSE +61 -0
  2. package/README.md +88 -2
  3. package/dist/accounts-B4bnTXUd.js +242 -0
  4. package/dist/accounts-B4bnTXUd.js.map +1 -0
  5. package/dist/accounts-TyMPSHM0.cjs +313 -0
  6. package/dist/accounts-TyMPSHM0.cjs.map +1 -0
  7. package/dist/adapters-DM59AJfR.d.cts +216 -0
  8. package/dist/adapters-DM59AJfR.d.ts +216 -0
  9. package/dist/cli/template-assets/api/src/errors/codes.ts +17 -0
  10. package/dist/cli/template-assets/api/src/errors/index.ts +16 -0
  11. package/dist/cli/template-assets/api/src/filters/exception.ts +53 -0
  12. package/dist/cli/template-assets/api/src/main.ts +189 -0
  13. package/dist/cli/template-assets/api/src/modules/health/controller.ts +23 -0
  14. package/dist/cli/template-assets/api/src/modules/health/dto/response.dto.ts +23 -0
  15. package/dist/cli/template-assets/api/src/modules/health/module.ts +12 -0
  16. package/dist/cli/template-assets/api/src/modules/health/service.ts +54 -0
  17. package/dist/cli/template-assets/api/src/modules/messaging/module.ts +7 -0
  18. package/dist/cli/template-assets/api/src/modules/messaging/service.ts +74 -0
  19. package/dist/cli/template-assets/api/src/shared/exceptions.ts +40 -0
  20. package/dist/cli/template-assets/api/src/shared/response.ts +31 -0
  21. package/dist/cli/template-assets/api/src/telemetry.ts +59 -0
  22. package/dist/cli/template-assets/api/src/types.ts +8 -0
  23. package/dist/cli/template-assets/cloudflare/cache.service.ts +23 -0
  24. package/dist/cli/template-assets/cloudflare/queue.service.ts +22 -0
  25. package/dist/cli/template-assets/cloudflare/worker.ts +33 -0
  26. package/dist/cli/template-assets/packages/jobs/src/index.ts +49 -0
  27. package/dist/cli/template-assets/packages/queue-runtime/src/index.ts +54 -0
  28. package/dist/cli/template-assets/root/dot-dockerignore +11 -0
  29. package/dist/cli/template-assets/root/dot-editorconfig +13 -0
  30. package/dist/cli/template-assets/root/dot-oxfmtrc.json +9 -0
  31. package/dist/cli/template-assets/root/dot-oxlintrc.json +47 -0
  32. package/dist/cli/template-assets/root/lefthook.yml +18 -0
  33. package/dist/cli/template-assets/web/postcss.config.mjs +9 -0
  34. package/dist/cli/template-assets/web/src/app/(app)/dashboard/page.tsx +5 -0
  35. package/dist/cli/template-assets/web/src/app/(app)/layout.tsx +25 -0
  36. package/dist/cli/template-assets/web/src/app/(auth)/login/page.tsx +75 -0
  37. package/dist/cli/template-assets/web/src/app/globals.css +48 -0
  38. package/dist/cli/template-assets/web/src/app/layout.tsx +30 -0
  39. package/dist/cli/template-assets/web/src/app/page.tsx +20 -0
  40. package/dist/cli/template-assets/web/src/components/overview/overview-panel.tsx +27 -0
  41. package/dist/cli/template-assets/web/src/components/shell/app-shell.tsx +37 -0
  42. package/dist/cli/template-assets/web/src/components/shell/providers.tsx +22 -0
  43. package/dist/cli/template-assets/web/src/lib/api-client.ts +57 -0
  44. package/dist/cli/template-assets/web/src/lib/auth-client.ts +15 -0
  45. package/dist/cli/template-assets/web/src/lib/server-auth.ts +38 -0
  46. package/dist/cli/template-assets/web/src/types/api.ts +18 -0
  47. package/dist/cli/template-assets/worker/src/app.module.ts +5 -0
  48. package/dist/cli/template-assets/worker/src/env.ts +8 -0
  49. package/dist/cli/template-assets/worker/src/main.ts +25 -0
  50. package/dist/cli/template-assets/worker/src/modules/queue/config.ts +16 -0
  51. package/dist/cli/template-assets/worker/src/modules/queue/module.ts +11 -0
  52. package/dist/cli/template-assets/worker/src/modules/queue/processor.ts +105 -0
  53. package/dist/cli/template-assets/worker/src/modules/queue/repository.ts +16 -0
  54. package/dist/cli/template-assets/worker/src/modules/queue/retry.ts +17 -0
  55. package/dist/cli/template-assets/worker/test/retry.test.ts.tpl +12 -0
  56. package/dist/cli/template-assets/worker-messaging/jobs-messaging.ts +12 -0
  57. package/dist/cli/template-assets/worker-messaging/messaging-api-service.ts +39 -0
  58. package/dist/cli/template-assets/worker-messaging/src/env.ts +14 -0
  59. package/dist/cli/template-assets/worker-messaging/src/modules/messaging/service.ts +59 -0
  60. package/dist/cli/template-assets/worker-messaging/src/modules/queue/module.ts +8 -0
  61. package/dist/cli/template-assets/worker-messaging/src/modules/queue/processor.ts +113 -0
  62. package/dist/cli.js +1218 -0
  63. package/dist/cn-BVOnrSza.js +1 -0
  64. package/dist/constants-C4iP0--i.js +38 -0
  65. package/dist/constants-C4iP0--i.js.map +1 -0
  66. package/dist/constants-rCR-LNSN.cjs +91 -0
  67. package/dist/constants-rCR-LNSN.cjs.map +1 -0
  68. package/dist/decorate-BR5FVX5x.js +14 -0
  69. package/dist/decorate-R-oqksAh.cjs +25 -0
  70. package/dist/decorateParam-BFJPEGKJ.cjs +13 -0
  71. package/dist/decorateParam-CKE7_J1s.js +8 -0
  72. package/dist/define-adapter-Cc0QrfKt.cjs +16 -0
  73. package/dist/define-adapter-Cc0QrfKt.cjs.map +1 -0
  74. package/dist/define-adapter-DRcXno3j.js +11 -0
  75. package/dist/define-adapter-DRcXno3j.js.map +1 -0
  76. package/dist/dispatcher-BsD7cO2w.cjs +84 -0
  77. package/dist/dispatcher-BsD7cO2w.cjs.map +1 -0
  78. package/dist/dispatcher-DA_l1Vkv.js +73 -0
  79. package/dist/dispatcher-DA_l1Vkv.js.map +1 -0
  80. package/dist/errors-DxHoXrLd.d.cts +46 -0
  81. package/dist/errors-DxHoXrLd.d.ts +46 -0
  82. package/dist/http/index.cjs +440 -0
  83. package/dist/http/index.cjs.map +1 -0
  84. package/dist/http/index.d.cts +257 -0
  85. package/dist/http/index.d.ts +257 -0
  86. package/dist/http/index.js +400 -0
  87. package/dist/http/index.js.map +1 -0
  88. package/dist/http/swagger.cjs +122 -0
  89. package/dist/http/swagger.cjs.map +1 -0
  90. package/dist/http/swagger.d.cts +59 -0
  91. package/dist/http/swagger.d.ts +59 -0
  92. package/dist/http/swagger.js +117 -0
  93. package/dist/http/swagger.js.map +1 -0
  94. package/dist/index-B3UOHsA9.d.ts +679 -0
  95. package/dist/index-Bdl0AiNM.d.ts +1262 -0
  96. package/dist/index-By8b4ksT.d.ts +25 -0
  97. package/dist/index-C1KmT8dQ.d.ts +174 -0
  98. package/dist/index-CYT1PFzo.d.cts +679 -0
  99. package/dist/index-Cj-10Q5F.d.cts +174 -0
  100. package/dist/index-DDSaLjXV.d.cts +25 -0
  101. package/dist/index-FTrYdHfq.d.cts +1262 -0
  102. package/dist/index.cjs +1 -0
  103. package/dist/index.d.cts +4 -0
  104. package/dist/index.d.ts +4 -0
  105. package/dist/index.js +1 -0
  106. package/dist/label-BqmJoVE-.cjs +1 -0
  107. package/dist/label-XeChe1Bu.js +1 -0
  108. package/dist/messaging/index.cjs +1 -0
  109. package/dist/messaging/index.d.cts +1775 -0
  110. package/dist/messaging/index.d.ts +1775 -0
  111. package/dist/messaging/index.js +1 -0
  112. package/dist/misc-BpM_lMTx.js +1 -0
  113. package/dist/misc-DkqJOm1V.cjs +1 -0
  114. package/dist/operational-CnxdBwVG.d.cts +13 -0
  115. package/dist/operational-CnxdBwVG.d.ts +13 -0
  116. package/dist/redaction-DhuHTlHA.js +124 -0
  117. package/dist/redaction-DhuHTlHA.js.map +1 -0
  118. package/dist/redaction-uRIQbTwZ.cjs +171 -0
  119. package/dist/redaction-uRIQbTwZ.cjs.map +1 -0
  120. package/dist/rolldown-runtime-auK_WOaK.cjs +1 -0
  121. package/dist/rolldown-runtime-xuxB8TGW.cjs +32 -0
  122. package/dist/runtime-C95UYYLb.cjs +111 -0
  123. package/dist/runtime-C95UYYLb.cjs.map +1 -0
  124. package/dist/runtime-DG2oBFYw.js +88 -0
  125. package/dist/runtime-DG2oBFYw.js.map +1 -0
  126. package/dist/skills-C1uwr9Pp.js +4 -0
  127. package/dist/skills-DuE-XnBp.js +1 -0
  128. package/dist/sso/client.cjs +37 -0
  129. package/dist/sso/client.cjs.map +1 -0
  130. package/dist/sso/client.d.cts +90 -0
  131. package/dist/sso/client.d.ts +90 -0
  132. package/dist/sso/client.js +36 -0
  133. package/dist/sso/client.js.map +1 -0
  134. package/dist/sso/index.cjs +833 -0
  135. package/dist/sso/index.cjs.map +1 -0
  136. package/dist/sso/index.d.cts +3 -0
  137. package/dist/sso/index.d.ts +3 -0
  138. package/dist/sso/index.js +821 -0
  139. package/dist/sso/index.js.map +1 -0
  140. package/dist/sso/nestjs.cjs +169 -0
  141. package/dist/sso/nestjs.cjs.map +1 -0
  142. package/dist/sso/nestjs.d.cts +92 -0
  143. package/dist/sso/nestjs.d.ts +92 -0
  144. package/dist/sso/nestjs.js +151 -0
  145. package/dist/sso/nestjs.js.map +1 -0
  146. package/dist/sso/resource.cjs +124 -0
  147. package/dist/sso/resource.cjs.map +1 -0
  148. package/dist/sso/resource.d.cts +3 -0
  149. package/dist/sso/resource.d.ts +3 -0
  150. package/dist/sso/resource.js +114 -0
  151. package/dist/sso/resource.js.map +1 -0
  152. package/dist/status-CRvlFPIs.js +13 -0
  153. package/dist/status-CRvlFPIs.js.map +1 -0
  154. package/dist/status-DtK6OHtj.cjs +24 -0
  155. package/dist/status-DtK6OHtj.cjs.map +1 -0
  156. package/dist/team-CJVAg4HH.d.cts +157 -0
  157. package/dist/team-CJVAg4HH.d.ts +157 -0
  158. package/dist/telemetry/adapters.cjs +6 -0
  159. package/dist/telemetry/adapters.d.cts +3 -0
  160. package/dist/telemetry/adapters.d.ts +3 -0
  161. package/dist/telemetry/adapters.js +4 -0
  162. package/dist/telemetry/betterstack.cjs +74 -0
  163. package/dist/telemetry/betterstack.cjs.map +1 -0
  164. package/dist/telemetry/betterstack.d.cts +12 -0
  165. package/dist/telemetry/betterstack.d.ts +12 -0
  166. package/dist/telemetry/betterstack.js +71 -0
  167. package/dist/telemetry/betterstack.js.map +1 -0
  168. package/dist/telemetry/index.cjs +1237 -0
  169. package/dist/telemetry/index.cjs.map +1 -0
  170. package/dist/telemetry/index.d.cts +114 -0
  171. package/dist/telemetry/index.d.ts +114 -0
  172. package/dist/telemetry/index.js +1205 -0
  173. package/dist/telemetry/index.js.map +1 -0
  174. package/dist/telemetry/posthog.cjs +72 -0
  175. package/dist/telemetry/posthog.cjs.map +1 -0
  176. package/dist/telemetry/posthog.d.cts +10 -0
  177. package/dist/telemetry/posthog.d.ts +10 -0
  178. package/dist/telemetry/posthog.js +71 -0
  179. package/dist/telemetry/posthog.js.map +1 -0
  180. package/dist/telemetry/register.cjs +6 -0
  181. package/dist/telemetry/register.d.cts +14 -0
  182. package/dist/telemetry/register.d.ts +14 -0
  183. package/dist/telemetry/register.js +3 -0
  184. package/dist/telemetry/testing.cjs +54 -0
  185. package/dist/telemetry/testing.cjs.map +1 -0
  186. package/dist/telemetry/testing.d.cts +15 -0
  187. package/dist/telemetry/testing.d.ts +15 -0
  188. package/dist/telemetry/testing.js +52 -0
  189. package/dist/telemetry/testing.js.map +1 -0
  190. package/dist/telemetry.mock-BSsx7L6S.cjs +45 -0
  191. package/dist/telemetry.mock-BSsx7L6S.cjs.map +1 -0
  192. package/dist/telemetry.mock-BZRpy63c.js +40 -0
  193. package/dist/telemetry.mock-BZRpy63c.js.map +1 -0
  194. package/dist/telemetry.mock-C1wXuf-M.d.cts +4 -0
  195. package/dist/telemetry.mock-CdaxofJ7.d.ts +4 -0
  196. package/dist/ui/chart.cjs +6 -0
  197. package/dist/ui/chart.d.cts +34 -0
  198. package/dist/ui/chart.d.ts +34 -0
  199. package/dist/ui/chart.js +6 -0
  200. package/dist/ui/form.cjs +1 -0
  201. package/dist/ui/form.d.cts +23 -0
  202. package/dist/ui/form.d.ts +23 -0
  203. package/dist/ui/form.js +1 -0
  204. package/dist/ui/hooks.cjs +1 -0
  205. package/dist/ui/hooks.d.cts +66 -0
  206. package/dist/ui/hooks.d.ts +66 -0
  207. package/dist/ui/hooks.js +1 -0
  208. package/dist/ui/index.cjs +1 -0
  209. package/dist/ui/index.d.cts +3 -0
  210. package/dist/ui/index.d.ts +3 -0
  211. package/dist/ui/index.js +1 -0
  212. package/dist/ui/styles.css +2 -0
  213. package/dist/ui/utils.cjs +1 -0
  214. package/dist/ui/utils.d.cts +199 -0
  215. package/dist/ui/utils.d.ts +199 -0
  216. package/dist/ui/utils.js +1 -0
  217. package/dist/use-mobile-BbeIMRgE.cjs +1 -0
  218. package/dist/use-mobile-Cdd4Lp7p.js +1 -0
  219. package/dist/use-mobile-ecpyXWz3.d.cts +10 -0
  220. package/dist/use-mobile-ecpyXWz3.d.ts +10 -0
  221. package/dist/verifier-BIBtPCVi.cjs +119 -0
  222. package/dist/verifier-BIBtPCVi.cjs.map +1 -0
  223. package/dist/verifier-DNdy5Ynw.js +90 -0
  224. package/dist/verifier-DNdy5Ynw.js.map +1 -0
  225. package/dist/version-CPunTYCY.js +1 -0
  226. package/dist/version-CfUi3iAV.cjs +1 -0
  227. package/package.json +523 -5
@@ -0,0 +1,679 @@
1
+ import { d as SchoolList, i as TeamMember, n as TeamInvitation, p as SchoolPermissions, t as Page } from "./team-CJVAg4HH.cjs";
2
+ import { decryptOAuthToken } from "better-auth/oauth2";
3
+ /**
4
+ * Contrato público dos webhooks da Conta Rockfeller (ADRs 0029 e 0038).
5
+ *
6
+ * @remarks
7
+ * Espelha `@sso/jobs` (privado ao monorepo do Accounts); um teste garante que
8
+ * as duas listas de eventos não se separam.
9
+ */
10
+ declare const WEBHOOK_EVENT_TYPES: readonly ["user.updated", "user.disabled", "user.enabled", "user.deactivated", "user.deleted", "membership.granted", "membership.revoked", "app.access_revoked", "session.ended"];
11
+ declare class WebhookVerificationError extends Error {}
12
+ /**
13
+ * Valida um webhook no formato Standard Webhooks e devolve o envelope.
14
+ *
15
+ * @remarks
16
+ * HMAC-SHA256 de `id.timestamp.corpo` com a chave do `whsec_…`. Na troca de
17
+ * segredo o cabeçalho traz duas assinaturas; qualquer uma vale. Usa Web
18
+ * Crypto: roda em Node, Bun, Deno e edge.
19
+ */
20
+ declare function verifyWebhook(secret: string, body: string, headers: Headers, now?: number): Promise<{
21
+ id: string;
22
+ type: string;
23
+ createdAt: string;
24
+ data: unknown;
25
+ }>;
26
+ type WebhookEventType = (typeof WEBHOOK_EVENT_TYPES)[number];
27
+ type WebhookUserField = 'name' | 'email' | 'emailVerified' | 'picture' | 'birthdate' | 'phoneNumber' | 'theme' | 'timezone' | 'displayName' | 'reducedMotion' | 'contrast' | 'hourCycle';
28
+ /** A pessoa como o app pode vê-la: os campos dependem dos escopos concedidos. */
29
+ interface WebhookUser {
30
+ sub: string;
31
+ /** Escopo `profile`. */
32
+ name?: string;
33
+ /** Escopo `profile`; `null` sem foto. */
34
+ picture?: string | null;
35
+ /** Escopo `email`. */
36
+ email?: string;
37
+ emailVerified?: boolean;
38
+ /** Escopo `birthdate`: `AAAA-MM-DD`, ou `null` sem data. */
39
+ birthdate?: string | null;
40
+ /** Escopo `phone`: WhatsApp verificado em E.164, ou `null` sem número. */
41
+ phoneNumber?: string | null;
42
+ /** Escopo `preferences`: `light`, `dark` ou `system` (o padrão de quem nunca escolheu). */
43
+ theme?: 'light' | 'dark' | 'system';
44
+ /** Escopo `preferences`: fuso do Brasil (IANA), `America/Sao_Paulo` por padrão. */
45
+ timezone?: 'America/Noronha' | 'America/Sao_Paulo' | 'America/Manaus' | 'America/Rio_Branco';
46
+ /** Escopo `preferences`: nome de exibição, ou `null` (use o `name`). */
47
+ displayName?: string | null;
48
+ /** Escopo `preferences`: reduzir animações (`system` segue o aparelho). */
49
+ reducedMotion?: 'system' | 'reduce' | 'no-preference';
50
+ /** Escopo `preferences`: contraste (`system` segue o aparelho). */
51
+ contrast?: 'system' | 'more' | 'default';
52
+ /** Escopo `preferences`: relógio de 12 h, 24 h ou o do aparelho. */
53
+ hourCycle?: 'auto' | '12' | '24';
54
+ /** Versão do retrato: descarte evento com `updatedAt` mais antigo que o último. */
55
+ updatedAt: string;
56
+ }
57
+ interface WebhookMembershipData {
58
+ user: {
59
+ sub: string;
60
+ };
61
+ school: {
62
+ id: string;
63
+ name: string;
64
+ type: string;
65
+ joyUnitId: string | null;
66
+ };
67
+ roles: string[];
68
+ /** Só as permissões do seu app. */
69
+ permissions: string[];
70
+ }
71
+ /** O `data` de cada evento. */
72
+ interface WebhookEventData {
73
+ 'user.updated': {
74
+ user: WebhookUser;
75
+ changes: WebhookUserField[];
76
+ };
77
+ 'user.disabled': {
78
+ user: {
79
+ sub: string;
80
+ };
81
+ };
82
+ 'user.enabled': {
83
+ user: {
84
+ sub: string;
85
+ };
86
+ };
87
+ 'user.deactivated': {
88
+ user: {
89
+ sub: string;
90
+ };
91
+ /** Quando a conta será anonimizada (ISO 8601). */
92
+ deletionScheduledFor: string;
93
+ };
94
+ 'user.deleted': {
95
+ user: {
96
+ sub: string;
97
+ };
98
+ };
99
+ 'membership.granted': WebhookMembershipData;
100
+ 'membership.revoked': WebhookMembershipData;
101
+ 'app.access_revoked': {
102
+ user: {
103
+ sub: string;
104
+ };
105
+ };
106
+ 'session.ended': {
107
+ user: {
108
+ sub: string;
109
+ };
110
+ /** Sessão no Accounts: o mesmo `sid` do ID token. */
111
+ sid: string;
112
+ endedAt: string;
113
+ };
114
+ }
115
+ /** Envelope: o corpo do POST. */
116
+ type WebhookEvent<Type extends WebhookEventType = WebhookEventType> = { [K in Type]: {
117
+ /** `evt_…`, igual ao cabeçalho `webhook-id` e entre retentativas. */
118
+ id: string;
119
+ type: K;
120
+ createdAt: string;
121
+ data: WebhookEventData[K];
122
+ }; }[Type];
123
+ /** Conta Rockfeller em produção: o issuer padrão. */
124
+ declare const DEFAULT_ISSUER = "https://accounts.rockfeller.com.br";
125
+ /** Provedor do login no Better Auth do app (`account.providerId`). */
126
+ declare const PROVIDER_ID = "rockfeller";
127
+ /** Provedor que guarda o token de gestão de equipe, vinculado à parte. */
128
+ declare const TEAM_PROVIDER_ID = "rockfeller-team";
129
+ /** Abas de Minha conta no Accounts. */
130
+ declare const PROFILE_TABS: {
131
+ readonly profile: "";
132
+ readonly security: "/security";
133
+ readonly sessions: "/sessions";
134
+ readonly apps: "/apps";
135
+ };
136
+ type ProfileTab = keyof typeof PROFILE_TABS;
137
+ interface RockfellerOptions {
138
+ /** Client ID do app, cadastrado em Admin → Aplicativos. */
139
+ clientId: string;
140
+ /** Segredo do cliente. Só no servidor. */
141
+ clientSecret: string;
142
+ /**
143
+ * Endereço da Conta Rockfeller.
144
+ * @default 'https://accounts.rockfeller.com.br'
145
+ */
146
+ issuer?: string | undefined;
147
+ /**
148
+ * URL da API própria do app, cadastrada como recurso protegido. O access
149
+ * token sai com ela no `aud`, e `auth.api.getApiToken` passa a funcionar.
150
+ */
151
+ api?: string | undefined;
152
+ /**
153
+ * Liga a gestão de equipe: um segundo provedor com o escopo de gestão,
154
+ * vinculado quando o gestor abre a tela (`authClient.rockfeller.team.connect`).
155
+ */
156
+ team?: boolean | undefined;
157
+ /**
158
+ * Mantém o login por e-mail e senha do próprio app. Por padrão, só a
159
+ * Conta Rockfeller entra.
160
+ * @default false
161
+ */
162
+ allowLocalSignIn?: boolean | undefined;
163
+ /** Escopos além de `openid profile email offline_access`. */
164
+ scopes?: string[] | undefined;
165
+ /**
166
+ * Para onde o Accounts volta depois do logout central. Precisa estar
167
+ * cadastrada no cliente.
168
+ * @default a origem do `baseURL` do app
169
+ */
170
+ postLogoutRedirect?: string | undefined;
171
+ /**
172
+ * Por quanto tempo guardar as permissões de uma pessoa numa escola. Usa o
173
+ * `secondaryStorage` do app quando houver. `0` desliga.
174
+ * @default 60
175
+ */
176
+ permissionsCacheSeconds?: number | undefined;
177
+ /**
178
+ * Chamado depois que o back-channel derrubou as sessões da pessoa.
179
+ * @deprecated Use `webhooks.hooks.onSessionEnded`, que recebe o fim de
180
+ * sessão tanto pelo back-channel quanto pelo webhook `session.ended`.
181
+ */
182
+ onBackchannelLogout?: ((event: {
183
+ sub: string;
184
+ userId: string | null;
185
+ }) => void | Promise<void>) | undefined;
186
+ /**
187
+ * Webhooks da Conta Rockfeller, o jeito recomendado de saber o que mudou
188
+ * (ADR 0038). Cadastre `{baseURL}/webhooks/sso` (ou o `webhooks.path`) em
189
+ * Admin → Aplicativos → Webhooks e guarde o segredo `whsec_…`.
190
+ */
191
+ webhooks?: RockfellerWebhookOptions | undefined;
192
+ }
193
+ /** O que todo hook de webhook recebe. */
194
+ interface RockfellerWebhookInput<Type extends WebhookEventType> {
195
+ /** A pessoa no Accounts. */
196
+ sub: string;
197
+ /** O usuário local ligado a ela, ou `null` se ela nunca entrou no app. */
198
+ userId: string | null;
199
+ event: WebhookEvent<Type>;
200
+ }
201
+ /** Fim de uma sessão no Accounts, pelo webhook ou pelo back-channel. */
202
+ interface RockfellerSessionEndedInput {
203
+ sub: string;
204
+ userId: string | null;
205
+ /** Sessão no Accounts (`sid` do ID token); `null` se o back-channel não mandou. */
206
+ sid: string | null;
207
+ source: 'webhook' | 'backchannel';
208
+ /** O evento `session.ended`; `null` quando veio pelo back-channel. */
209
+ event: WebhookEvent<'session.ended'> | null;
210
+ }
211
+ type Hook<Input> = ((input: Input) => void | Promise<void>) | undefined;
212
+ /**
213
+ * Um hook por evento. Rodam depois das ações padrão; se um deles lançar, o
214
+ * plugin responde 500 e o Accounts tenta de novo (o mesmo `event.id`): os
215
+ * hooks precisam aguentar o mesmo evento mais de uma vez.
216
+ */
217
+ interface RockfellerWebhookHooks {
218
+ onSessionEnded?: Hook<RockfellerSessionEndedInput>;
219
+ onUserUpdated?: Hook<RockfellerWebhookInput<'user.updated'>>;
220
+ onUserDisabled?: Hook<RockfellerWebhookInput<'user.disabled'>>;
221
+ onUserEnabled?: Hook<RockfellerWebhookInput<'user.enabled'>>;
222
+ onUserDeactivated?: Hook<RockfellerWebhookInput<'user.deactivated'>>;
223
+ onUserDeleted?: Hook<RockfellerWebhookInput<'user.deleted'>>;
224
+ onMembershipGranted?: Hook<RockfellerWebhookInput<'membership.granted'>>;
225
+ onMembershipRevoked?: Hook<RockfellerWebhookInput<'membership.revoked'>>;
226
+ onAppAccessRevoked?: Hook<RockfellerWebhookInput<'app.access_revoked'>>;
227
+ }
228
+ interface RockfellerWebhookOptions {
229
+ /** Segredo do webhook (`whsec_…`), mostrado uma vez no painel. */
230
+ secret: string;
231
+ /**
232
+ * Rota do endpoint, relativa ao `basePath` do Better Auth.
233
+ * @default '/webhooks/sso'
234
+ */
235
+ path?: string | undefined;
236
+ /**
237
+ * Ações padrão antes dos hooks: `session.ended` derruba a sessão daquele
238
+ * `sid`; `user.disabled`, `user.deactivated`, `user.deleted` e
239
+ * `app.access_revoked` derrubam todas as sessões da pessoa;
240
+ * `membership.*` limpa o cache de permissões; `user.updated` atualiza
241
+ * nome, e-mail e foto do usuário local. `false` só chama os hooks.
242
+ * @default true
243
+ */
244
+ defaultActions?: boolean | undefined;
245
+ hooks?: RockfellerWebhookHooks | undefined;
246
+ }
247
+ type AuthContext = Parameters<typeof decryptOAuthToken>[1];
248
+ /**
249
+ * Login com a Conta Rockfeller no Better Auth do app.
250
+ *
251
+ * @example
252
+ * betterAuth({
253
+ * plugins: [
254
+ * rockfeller({
255
+ * clientId: process.env.ROCKFELLER_CLIENT_ID!,
256
+ * clientSecret: process.env.ROCKFELLER_CLIENT_SECRET!,
257
+ * }),
258
+ * ],
259
+ * });
260
+ */
261
+ declare function rockfeller(options: RockfellerOptions): {
262
+ id: "rockfeller";
263
+ init: (ctx: AuthContext) => {
264
+ context: {
265
+ socialProviders: import("better-auth").OAuthProvider<object, Partial<import("better-auth").ProviderOptions<object>>>[];
266
+ };
267
+ options: {
268
+ databaseHooks: {
269
+ session: {
270
+ create: {
271
+ before(session: {
272
+ userId: string;
273
+ } & Record<string, unknown>, hookCtx: unknown): Promise<{
274
+ data: {
275
+ rockfellerSid: string;
276
+ userId: string;
277
+ };
278
+ } | undefined>;
279
+ };
280
+ };
281
+ };
282
+ account: {
283
+ accountLinking: {
284
+ trustedProviders: import("better-auth").LiteralString[];
285
+ };
286
+ };
287
+ };
288
+ };
289
+ hooks: {
290
+ before: {
291
+ matcher: (ctx: import("better-auth").HookEndpointContext) => boolean;
292
+ handler: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
293
+ context: {
294
+ body: any;
295
+ };
296
+ }>>;
297
+ }[];
298
+ };
299
+ endpoints: {
300
+ getRockfellerAccount: import("better-call").StrictEndpoint<"/rockfeller/account", {
301
+ method: "GET";
302
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
303
+ session: {
304
+ session: Record<string, any> & {
305
+ id: string;
306
+ createdAt: Date;
307
+ updatedAt: Date;
308
+ userId: string;
309
+ expiresAt: Date;
310
+ token: string;
311
+ ipAddress?: string | null | undefined;
312
+ userAgent?: string | null | undefined;
313
+ };
314
+ user: Record<string, any> & {
315
+ id: string;
316
+ createdAt: Date;
317
+ updatedAt: Date;
318
+ email: string;
319
+ emailVerified: boolean;
320
+ name: string;
321
+ image?: string | null | undefined;
322
+ };
323
+ };
324
+ }>>[];
325
+ }, {
326
+ sub: string;
327
+ accountId: string;
328
+ authTime: string | null;
329
+ impersonatedBy: string | null;
330
+ }>;
331
+ getApiToken: import("better-call").StrictEndpoint<"/rockfeller/api-token", {
332
+ method: "GET";
333
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
334
+ session: {
335
+ session: Record<string, any> & {
336
+ id: string;
337
+ createdAt: Date;
338
+ updatedAt: Date;
339
+ userId: string;
340
+ expiresAt: Date;
341
+ token: string;
342
+ ipAddress?: string | null | undefined;
343
+ userAgent?: string | null | undefined;
344
+ };
345
+ user: Record<string, any> & {
346
+ id: string;
347
+ createdAt: Date;
348
+ updatedAt: Date;
349
+ email: string;
350
+ emailVerified: boolean;
351
+ name: string;
352
+ image?: string | null | undefined;
353
+ };
354
+ };
355
+ }>>[];
356
+ metadata: {
357
+ SERVER_ONLY: true;
358
+ };
359
+ }, {
360
+ accessToken: string;
361
+ }>;
362
+ refreshProfile: import("better-call").StrictEndpoint<"/rockfeller/profile/refresh", {
363
+ method: "POST";
364
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
365
+ session: {
366
+ session: Record<string, any> & {
367
+ id: string;
368
+ createdAt: Date;
369
+ updatedAt: Date;
370
+ userId: string;
371
+ expiresAt: Date;
372
+ token: string;
373
+ ipAddress?: string | null | undefined;
374
+ userAgent?: string | null | undefined;
375
+ };
376
+ user: Record<string, any> & {
377
+ id: string;
378
+ createdAt: Date;
379
+ updatedAt: Date;
380
+ email: string;
381
+ emailVerified: boolean;
382
+ name: string;
383
+ image?: string | null | undefined;
384
+ };
385
+ };
386
+ }>>[];
387
+ }, {
388
+ name: string;
389
+ image: string | null;
390
+ }>;
391
+ getProfileUrl: import("better-call").StrictEndpoint<"/rockfeller/profile/url", {
392
+ method: "GET";
393
+ query: import("zod").ZodObject<{
394
+ returnTo: import("zod").ZodString;
395
+ tab: import("zod").ZodOptional<import("zod").ZodEnum<{
396
+ profile: "profile";
397
+ security: "security";
398
+ sessions: "sessions";
399
+ apps: "apps";
400
+ }>>;
401
+ }, import("zod/v4/core").$strip>;
402
+ }, {
403
+ url: string;
404
+ }>;
405
+ listSchools: import("better-call").StrictEndpoint<"/rockfeller/schools", {
406
+ method: "GET";
407
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
408
+ session: {
409
+ session: Record<string, any> & {
410
+ id: string;
411
+ createdAt: Date;
412
+ updatedAt: Date;
413
+ userId: string;
414
+ expiresAt: Date;
415
+ token: string;
416
+ ipAddress?: string | null | undefined;
417
+ userAgent?: string | null | undefined;
418
+ };
419
+ user: Record<string, any> & {
420
+ id: string;
421
+ createdAt: Date;
422
+ updatedAt: Date;
423
+ email: string;
424
+ emailVerified: boolean;
425
+ name: string;
426
+ image?: string | null | undefined;
427
+ };
428
+ };
429
+ }>>[];
430
+ }, SchoolList>;
431
+ getSchoolPermissions: import("better-call").StrictEndpoint<"/rockfeller/schools/permissions", {
432
+ method: "GET";
433
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
434
+ session: {
435
+ session: Record<string, any> & {
436
+ id: string;
437
+ createdAt: Date;
438
+ updatedAt: Date;
439
+ userId: string;
440
+ expiresAt: Date;
441
+ token: string;
442
+ ipAddress?: string | null | undefined;
443
+ userAgent?: string | null | undefined;
444
+ };
445
+ user: Record<string, any> & {
446
+ id: string;
447
+ createdAt: Date;
448
+ updatedAt: Date;
449
+ email: string;
450
+ emailVerified: boolean;
451
+ name: string;
452
+ image?: string | null | undefined;
453
+ };
454
+ };
455
+ }>>[];
456
+ query: import("zod").ZodObject<{
457
+ school: import("zod").ZodOptional<import("zod").ZodString>;
458
+ joyUnit: import("zod").ZodOptional<import("zod").ZodString>;
459
+ }, import("zod/v4/core").$strip>;
460
+ }, SchoolPermissions>;
461
+ hasPermission: import("better-call").StrictEndpoint<"/rockfeller/permissions/check", {
462
+ method: "POST";
463
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
464
+ session: {
465
+ session: Record<string, any> & {
466
+ id: string;
467
+ createdAt: Date;
468
+ updatedAt: Date;
469
+ userId: string;
470
+ expiresAt: Date;
471
+ token: string;
472
+ ipAddress?: string | null | undefined;
473
+ userAgent?: string | null | undefined;
474
+ };
475
+ user: Record<string, any> & {
476
+ id: string;
477
+ createdAt: Date;
478
+ updatedAt: Date;
479
+ email: string;
480
+ emailVerified: boolean;
481
+ name: string;
482
+ image?: string | null | undefined;
483
+ };
484
+ };
485
+ }>>[];
486
+ body: import("zod").ZodObject<{
487
+ permission: import("zod").ZodString;
488
+ school: import("zod").ZodOptional<import("zod").ZodString>;
489
+ joyUnit: import("zod").ZodOptional<import("zod").ZodString>;
490
+ }, import("zod/v4/core").$strip>;
491
+ metadata: {
492
+ SERVER_ONLY: true;
493
+ };
494
+ }, boolean>;
495
+ requirePermission: import("better-call").StrictEndpoint<"/rockfeller/permissions/require", {
496
+ method: "POST";
497
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
498
+ session: {
499
+ session: Record<string, any> & {
500
+ id: string;
501
+ createdAt: Date;
502
+ updatedAt: Date;
503
+ userId: string;
504
+ expiresAt: Date;
505
+ token: string;
506
+ ipAddress?: string | null | undefined;
507
+ userAgent?: string | null | undefined;
508
+ };
509
+ user: Record<string, any> & {
510
+ id: string;
511
+ createdAt: Date;
512
+ updatedAt: Date;
513
+ email: string;
514
+ emailVerified: boolean;
515
+ name: string;
516
+ image?: string | null | undefined;
517
+ };
518
+ };
519
+ }>>[];
520
+ body: import("zod").ZodObject<{
521
+ permission: import("zod").ZodString;
522
+ school: import("zod").ZodOptional<import("zod").ZodString>;
523
+ joyUnit: import("zod").ZodOptional<import("zod").ZodString>;
524
+ }, import("zod/v4/core").$strip>;
525
+ metadata: {
526
+ SERVER_ONLY: true;
527
+ };
528
+ }, SchoolPermissions>;
529
+ listTeamMembers: import("better-call").StrictEndpoint<"/rockfeller/team/members", {
530
+ method: "GET";
531
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
532
+ session: {
533
+ session: Record<string, any> & {
534
+ id: string;
535
+ createdAt: Date;
536
+ updatedAt: Date;
537
+ userId: string;
538
+ expiresAt: Date;
539
+ token: string;
540
+ ipAddress?: string | null | undefined;
541
+ userAgent?: string | null | undefined;
542
+ };
543
+ user: Record<string, any> & {
544
+ id: string;
545
+ createdAt: Date;
546
+ updatedAt: Date;
547
+ email: string;
548
+ emailVerified: boolean;
549
+ name: string;
550
+ image?: string | null | undefined;
551
+ };
552
+ };
553
+ }>>[];
554
+ query: import("zod").ZodObject<{
555
+ school: import("zod").ZodString;
556
+ q: import("zod").ZodOptional<import("zod").ZodString>;
557
+ role: import("zod").ZodOptional<import("zod").ZodString>;
558
+ origin: import("zod").ZodOptional<import("zod").ZodEnum<{
559
+ joy: "joy";
560
+ invite: "invite";
561
+ franchisor: "franchisor";
562
+ }>>;
563
+ cursor: import("zod").ZodOptional<import("zod").ZodString>;
564
+ limit: import("zod").ZodOptional<import("zod").ZodCoercedNumber<unknown>>;
565
+ }, import("zod/v4/core").$strip>;
566
+ }, Page<TeamMember>>;
567
+ inviteTeamMember: import("better-call").StrictEndpoint<"/rockfeller/team/invite", {
568
+ method: "POST";
569
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
570
+ session: {
571
+ session: Record<string, any> & {
572
+ id: string;
573
+ createdAt: Date;
574
+ updatedAt: Date;
575
+ userId: string;
576
+ expiresAt: Date;
577
+ token: string;
578
+ ipAddress?: string | null | undefined;
579
+ userAgent?: string | null | undefined;
580
+ };
581
+ user: Record<string, any> & {
582
+ id: string;
583
+ createdAt: Date;
584
+ updatedAt: Date;
585
+ email: string;
586
+ emailVerified: boolean;
587
+ name: string;
588
+ image?: string | null | undefined;
589
+ };
590
+ };
591
+ }>>[];
592
+ body: import("zod").ZodObject<{
593
+ school: import("zod").ZodString;
594
+ email: import("zod").ZodString;
595
+ name: import("zod").ZodString;
596
+ roles: import("zod").ZodArray<import("zod").ZodEnum<{
597
+ coordenador: "coordenador";
598
+ secretaria: "secretaria";
599
+ financeiro: "financeiro";
600
+ gestor_unidade: "gestor_unidade";
601
+ franqueado: "franqueado";
602
+ afiliado: "afiliado";
603
+ }>>;
604
+ }, import("zod/v4/core").$strip>;
605
+ }, TeamInvitation>;
606
+ revokeTeamRoles: import("better-call").StrictEndpoint<"/rockfeller/team/revoke", {
607
+ method: "POST";
608
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
609
+ session: {
610
+ session: Record<string, any> & {
611
+ id: string;
612
+ createdAt: Date;
613
+ updatedAt: Date;
614
+ userId: string;
615
+ expiresAt: Date;
616
+ token: string;
617
+ ipAddress?: string | null | undefined;
618
+ userAgent?: string | null | undefined;
619
+ };
620
+ user: Record<string, any> & {
621
+ id: string;
622
+ createdAt: Date;
623
+ updatedAt: Date;
624
+ email: string;
625
+ emailVerified: boolean;
626
+ name: string;
627
+ image?: string | null | undefined;
628
+ };
629
+ };
630
+ }>>[];
631
+ body: import("zod").ZodObject<{
632
+ school: import("zod").ZodString;
633
+ userId: import("zod").ZodString;
634
+ roles: import("zod").ZodArray<import("zod").ZodString>;
635
+ }, import("zod/v4/core").$strip>;
636
+ }, {
637
+ revoked: string[];
638
+ }>;
639
+ rockfellerBackchannelLogout: import("better-call").StrictEndpoint<"/rockfeller/backchannel-logout", {
640
+ method: "POST";
641
+ body: import("zod").ZodObject<{
642
+ logout_token: import("zod").ZodString;
643
+ }, import("zod/v4/core").$strip>;
644
+ metadata: {
645
+ isAction: false;
646
+ allowedMediaTypes: string[];
647
+ };
648
+ }, {
649
+ ok: boolean;
650
+ }>;
651
+ rockfellerWebhooks: import("better-call").StrictEndpoint<`/${string}`, {
652
+ method: "POST";
653
+ disableBody: true;
654
+ metadata: {
655
+ isAction: false;
656
+ };
657
+ }, {
658
+ ok: boolean;
659
+ }>;
660
+ };
661
+ schema: {
662
+ session: {
663
+ fields: {
664
+ rockfellerSid: {
665
+ type: "string";
666
+ required: false;
667
+ input: false;
668
+ };
669
+ };
670
+ };
671
+ };
672
+ rateLimit: {
673
+ pathMatcher: (path: string) => boolean;
674
+ window: number;
675
+ max: number;
676
+ }[];
677
+ };
678
+ export { WEBHOOK_EVENT_TYPES as _, RockfellerWebhookInput as a, DEFAULT_ISSUER as c, WebhookEvent as d, WebhookEventData as f, WebhookUserField as g, WebhookUser as h, RockfellerWebhookHooks as i, PROVIDER_ID as l, WebhookMembershipData as m, RockfellerOptions as n, RockfellerWebhookOptions as o, WebhookEventType as p, RockfellerSessionEndedInput as r, ProfileTab as s, rockfeller as t, TEAM_PROVIDER_ID as u, WebhookVerificationError as v, verifyWebhook as y };
679
+ //# sourceMappingURL=index-CYT1PFzo.d.cts.map