franchising 0.6.0 → 0.8.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 (110) hide show
  1. package/README.md +13 -72
  2. package/dist/{accounts-TyMPSHM0.cjs → accounts-BscmRiXc.cjs} +26 -1
  3. package/dist/{accounts-TyMPSHM0.cjs.map → accounts-BscmRiXc.cjs.map} +1 -1
  4. package/dist/{accounts-B4bnTXUd.js → accounts-DJRg4gXj.js} +26 -1
  5. package/dist/{accounts-B4bnTXUd.js.map → accounts-DJRg4gXj.js.map} +1 -1
  6. package/dist/cli/template-assets/api/src/main.ts +13 -11
  7. package/dist/cli/template-assets/api/src/modules/health/controller.ts +25 -4
  8. package/dist/cli/template-assets/api/src/shared/http/errors.ts +17 -0
  9. package/dist/cli/template-assets/cloudflare/cache.service.ts +1 -0
  10. package/dist/cli/template-assets/cloudflare/queue.service.ts +1 -0
  11. package/dist/cli/template-assets/cloudflare/worker.ts +4 -0
  12. package/dist/cli/template-assets/github/PULL_REQUEST_TEMPLATE.md +37 -0
  13. package/dist/cli/template-assets/observability/adapters.ts +37 -0
  14. package/dist/cli/template-assets/observability/bootstrap.ts +48 -0
  15. package/dist/cli/template-assets/observability/env.ts +21 -0
  16. package/dist/cli/template-assets/observability/index.ts +10 -0
  17. package/dist/cli/template-assets/observability/lifecycle.ts +97 -0
  18. package/dist/cli/template-assets/observability/local-index.ts +9 -0
  19. package/dist/cli/template-assets/observability/register.ts +12 -0
  20. package/dist/cli/template-assets/packages/jobs/src/index.ts +4 -40
  21. package/dist/cli/template-assets/packages/jobs/src/shared/queue/job-id.ts +9 -0
  22. package/dist/cli/template-assets/packages/jobs/src/shared/queue/options.ts +7 -0
  23. package/dist/cli/template-assets/packages/jobs/src/shared/queue/prefix.ts +18 -0
  24. package/dist/cli/template-assets/packages/queue/src/index.ts +4 -0
  25. package/dist/cli/template-assets/packages/queue/src/shared/errors/failure-reason.ts +7 -0
  26. package/dist/cli/template-assets/packages/{queue-runtime/src/index.ts → queue/src/shared/redis/connection.ts} +2 -15
  27. package/dist/cli/template-assets/packages/queue/src/types/redis/connection.ts +6 -0
  28. package/dist/cli/template-assets/packages/webhooks/src/index.ts +11 -0
  29. package/dist/cli/template-assets/packages/webhooks/src/shared/crypto/secret.ts +81 -0
  30. package/dist/cli/template-assets/packages/webhooks/src/shared/signing/headers.ts +43 -0
  31. package/dist/cli/template-assets/packages/webhooks/src/shared/url/deliverable.ts +58 -0
  32. package/dist/cli/template-assets/packages/webhooks/src/types/webhooks/job.ts +18 -0
  33. package/dist/cli/template-assets/packages/webhooks/test/webhooks.test.ts.tpl +69 -0
  34. package/dist/cli/template-assets/root/dot-dockerignore +88 -8
  35. package/dist/cli/template-assets/root/dot-oxlintrc.json +22 -0
  36. package/dist/cli/template-assets/root/lefthook.yml +32 -8
  37. package/dist/cli/template-assets/web/src/app/(app)/layout.tsx +2 -3
  38. package/dist/cli/template-assets/web/src/app/(auth)/login/page.tsx +1 -1
  39. package/dist/cli/template-assets/web/src/app/page.tsx +1 -0
  40. package/dist/cli/template-assets/web/src/{lib/api-client.ts → shared/api/client.ts} +11 -8
  41. package/dist/cli/template-assets/web/src/{lib/server-auth.ts → shared/auth/server.ts} +1 -2
  42. package/dist/cli/template-assets/web/src/types/api.ts +0 -15
  43. package/dist/cli/template-assets/webhooks/api/src/modules/webhooks/controller.ts +81 -0
  44. package/dist/cli/template-assets/webhooks/api/src/modules/webhooks/dto/create-endpoint.dto.ts +25 -0
  45. package/dist/cli/template-assets/webhooks/api/src/modules/webhooks/dto/endpoint.dto.ts +28 -0
  46. package/dist/cli/template-assets/webhooks/api/src/modules/webhooks/module.ts +27 -0
  47. package/dist/cli/template-assets/webhooks/api/src/modules/webhooks/repository.ts +147 -0
  48. package/dist/cli/template-assets/webhooks/api/src/modules/webhooks/service.ts +119 -0
  49. package/dist/cli/template-assets/webhooks/api/src/types/webhooks/endpoint.ts +26 -0
  50. package/dist/cli/template-assets/webhooks/worker/src/env.ts +18 -0
  51. package/dist/cli/template-assets/webhooks/worker/src/modules/queue/dispatcher.ts +119 -0
  52. package/dist/cli/template-assets/webhooks/worker/src/modules/queue/module.ts +16 -0
  53. package/dist/cli/template-assets/webhooks/worker/src/modules/queue/processor.ts +176 -0
  54. package/dist/cli/template-assets/webhooks/worker/src/modules/queue/repository.ts +187 -0
  55. package/dist/cli/template-assets/webhooks/worker/src/shared/http/deliver.ts +41 -0
  56. package/dist/cli/template-assets/webhooks/worker/src/types/webhooks/dispatch.ts +26 -0
  57. package/dist/cli/template-assets/worker/src/app.module.ts +14 -0
  58. package/dist/cli/template-assets/worker/src/main.ts +24 -0
  59. package/dist/cli/template-assets/worker/src/modules/queue/processor.ts +26 -3
  60. package/dist/cli/template-assets/worker/src/modules/queue/retry.ts +22 -7
  61. package/dist/cli/template-assets/worker/test/retry.test.ts.tpl +13 -1
  62. package/dist/cli/template-assets/worker-messaging/messaging-api-service.ts +6 -6
  63. package/dist/cli/template-assets/worker-messaging/src/env.ts +1 -1
  64. package/dist/cli/template-assets/worker-messaging/src/modules/messaging/service.ts +2 -4
  65. package/dist/cli/template-assets/worker-messaging/src/modules/queue/module.ts +1 -1
  66. package/dist/cli/template-assets/worker-messaging/src/modules/queue/processor.ts +32 -10
  67. package/dist/cli.js +631 -314
  68. package/dist/{index-CNlb6WNr.d.ts → index-Bl4Ka1Wr.d.ts} +2 -2
  69. package/dist/{index-I_Nx5SsQ.d.cts → index-CBue43h0.d.cts} +2 -2
  70. package/dist/{index-B_byXBRW.d.ts → index-cKCKFKLi.d.cts} +181 -5
  71. package/dist/{index-B_byXBRW.d.cts → index-cKCKFKLi.d.ts} +181 -5
  72. package/dist/index.cjs +1 -1
  73. package/dist/index.d.cts +1 -1
  74. package/dist/index.d.ts +1 -1
  75. package/dist/index.js +1 -1
  76. package/dist/messaging/index.cjs +1 -1
  77. package/dist/messaging/index.d.cts +1 -1
  78. package/dist/messaging/index.d.ts +1 -1
  79. package/dist/messaging/index.js +1 -1
  80. package/dist/sso/client.d.cts +2 -2
  81. package/dist/sso/client.d.ts +2 -2
  82. package/dist/sso/index.cjs +72 -1
  83. package/dist/sso/index.cjs.map +1 -1
  84. package/dist/sso/index.d.cts +2 -2
  85. package/dist/sso/index.d.ts +2 -2
  86. package/dist/sso/index.js +72 -1
  87. package/dist/sso/index.js.map +1 -1
  88. package/dist/sso/nestjs.cjs +2 -2
  89. package/dist/sso/nestjs.d.cts +2 -2
  90. package/dist/sso/nestjs.d.ts +2 -2
  91. package/dist/sso/nestjs.js +2 -2
  92. package/dist/sso/resource.cjs +2 -2
  93. package/dist/sso/resource.d.cts +3 -3
  94. package/dist/sso/resource.d.ts +3 -3
  95. package/dist/sso/resource.js +2 -2
  96. package/dist/{verifier-BIBtPCVi.cjs → verifier-BYrFb8tg.cjs} +2 -2
  97. package/dist/{verifier-BIBtPCVi.cjs.map → verifier-BYrFb8tg.cjs.map} +1 -1
  98. package/dist/{verifier-DNdy5Ynw.js → verifier-DSvtdWuY.js} +2 -2
  99. package/dist/{verifier-DNdy5Ynw.js.map → verifier-DSvtdWuY.js.map} +1 -1
  100. package/dist/version-8Zc_uUvG.js +1 -0
  101. package/dist/{version-DDLRsahz.cjs → version-BMXokpna.cjs} +1 -1
  102. package/package.json +1 -1
  103. package/dist/cli/template-assets/api/src/errors/codes.ts +0 -17
  104. package/dist/cli/template-assets/api/src/errors/index.ts +0 -16
  105. package/dist/cli/template-assets/api/src/filters/exception.ts +0 -53
  106. package/dist/cli/template-assets/api/src/shared/exceptions.ts +0 -40
  107. package/dist/cli/template-assets/api/src/shared/response.ts +0 -31
  108. package/dist/cli/template-assets/api/src/telemetry.ts +0 -59
  109. package/dist/version-DHlIo_M1.js +0 -1
  110. /package/dist/cli/template-assets/web/src/{lib/auth-client.ts → shared/auth/client.ts} +0 -0
@@ -1,5 +1,5 @@
1
- import { y as SchoolPermissions } from "../index-B_byXBRW.cjs";
2
- import { d as Authorization, h as VerifiedToken, p as TokenVerifier } from "../index-I_Nx5SsQ.cjs";
1
+ import { T as SchoolPermissions } from "../index-cKCKFKLi.cjs";
2
+ import { d as Authorization, h as VerifiedToken, p as TokenVerifier } from "../index-CBue43h0.cjs";
3
3
  import { CanActivate, DynamicModule, ExecutionContext, ModuleMetadata } from "@nestjs/common";
4
4
  import { Reflector } from "@nestjs/core";
5
5
  /** Libera a rota do guard (health check, webhooks...). */
@@ -1,5 +1,5 @@
1
- import { y as SchoolPermissions } from "../index-B_byXBRW.js";
2
- import { d as Authorization, h as VerifiedToken, p as TokenVerifier } from "../index-CNlb6WNr.js";
1
+ import { T as SchoolPermissions } from "../index-cKCKFKLi.js";
2
+ import { d as Authorization, h as VerifiedToken, p as TokenVerifier } from "../index-Bl4Ka1Wr.js";
3
3
  import { CanActivate, DynamicModule, ExecutionContext, ModuleMetadata } from "@nestjs/common";
4
4
  import { Reflector } from "@nestjs/core";
5
5
  /** Libera a rota do guard (health check, webhooks...). */
@@ -1,7 +1,7 @@
1
- import { r as RockfellerError } from "../accounts-B4bnTXUd.js";
1
+ import { r as RockfellerError } from "../accounts-DJRg4gXj.js";
2
2
  import { n as __decorateMetadata, t as __decorate } from "../decorate-BR5FVX5x.js";
3
3
  import { t as __decorateParam } from "../decorateParam-CKE7_J1s.js";
4
- import { a as createAuthorization, r as createTokenVerifier } from "../verifier-DNdy5Ynw.js";
4
+ import { a as createAuthorization, r as createTokenVerifier } from "../verifier-DSvtdWuY.js";
5
5
  import { ForbiddenException, HttpException, Inject, Injectable, Module, SetMetadata, UnauthorizedException, createParamDecorator } from "@nestjs/common";
6
6
  import { APP_GUARD, Reflector } from "@nestjs/core";
7
7
 
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_verifier = require("../verifier-BIBtPCVi.cjs");
3
- const require_accounts = require("../accounts-TyMPSHM0.cjs");
2
+ const require_verifier = require("../verifier-BYrFb8tg.cjs");
3
+ const require_accounts = require("../accounts-BscmRiXc.cjs");
4
4
  const require_constants = require("../constants-rCR-LNSN.cjs");
5
5
  let zod = require("zod");
6
6
 
@@ -1,3 +1,3 @@
1
- import { A as isRockfellerError, C as HourCycle, D as Theme, E as ReducedMotion, O as Timezone, S as Contrast, T as PreferencesPatch, _ as SchoolList, b as SchoolRef, c as TeamInvitation, d as TeamMembersQuery, f as TeamRole, g as School, h as Permission, j as RockfellerErrorCode, k as RockfellerError, l as TeamInvitationInput, m as TeamRoleOrigin, p as TeamRoleKey, s as Page, u as TeamMember, v as SchoolMembership, w as Preferences, x as SchoolType, y as SchoolPermissions } from "../index-B_byXBRW.cjs";
2
- import { _ as assertWritable, a as TokenExchangerOptions, c as Preferences$1, d as Authorization, f as AuthorizationOptions, g as InvalidTokenError, h as VerifiedToken, i as TokenExchanger, l as PreferencesOptions, m as TokenVerifierOptions, n as ExchangedToken, o as TokenExchangeError, p as TokenVerifier, r as TokenExchangeInput, s as createPreferences, t as createTokenExchanger, u as createAuthorization, v as createTokenVerifier } from "../index-I_Nx5SsQ.cjs";
3
- export { type Authorization, type AuthorizationOptions, type Contrast, type ExchangedToken, type HourCycle, InvalidTokenError, type Page, type Permission, type Preferences, type Preferences$1 as PreferencesClient, type PreferencesOptions, type PreferencesPatch, type ReducedMotion, RockfellerError, RockfellerErrorCode, type School, type SchoolList, type SchoolMembership, type SchoolPermissions, type SchoolRef, type SchoolType, type TeamInvitation, type TeamInvitationInput, type TeamMember, type TeamMembersQuery, type TeamRole, type TeamRoleKey, type TeamRoleOrigin, type Theme, type Timezone, TokenExchangeError, type TokenExchangeInput, type TokenExchanger, type TokenExchangerOptions, type TokenVerifier, type TokenVerifierOptions, type VerifiedToken, assertWritable, createAuthorization, createPreferences, createTokenExchanger, createTokenVerifier, isRockfellerError };
1
+ import { A as Preferences, C as SchoolList, D as SchoolType, E as SchoolRef, F as RockfellerError, I as isRockfellerError, L as RockfellerErrorCode, M as ReducedMotion, N as Theme, O as Contrast, P as Timezone, S as School, T as SchoolPermissions, _ as TeamMembersQuery, b as TeamRoleOrigin, c as AppRoleGrant, d as AppRoleMember, f as AppRoleMembersQuery, g as TeamMember, h as TeamInvitationInput, j as PreferencesPatch, k as HourCycle, l as AppRoleInvitationInput, m as TeamInvitation, p as Page, s as AppRole, u as AppRoleList, v as TeamRole, w as SchoolMembership, x as Permission, y as TeamRoleKey } from "../index-cKCKFKLi.cjs";
2
+ import { _ as assertWritable, a as TokenExchangerOptions, c as Preferences$1, d as Authorization, f as AuthorizationOptions, g as InvalidTokenError, h as VerifiedToken, i as TokenExchanger, l as PreferencesOptions, m as TokenVerifierOptions, n as ExchangedToken, o as TokenExchangeError, p as TokenVerifier, r as TokenExchangeInput, s as createPreferences, t as createTokenExchanger, u as createAuthorization, v as createTokenVerifier } from "../index-CBue43h0.cjs";
3
+ export { type AppRole, type AppRoleGrant, type AppRoleInvitationInput, type AppRoleList, type AppRoleMember, type AppRoleMembersQuery, type Authorization, type AuthorizationOptions, type Contrast, type ExchangedToken, type HourCycle, InvalidTokenError, type Page, type Permission, type Preferences, type Preferences$1 as PreferencesClient, type PreferencesOptions, type PreferencesPatch, type ReducedMotion, RockfellerError, RockfellerErrorCode, type School, type SchoolList, type SchoolMembership, type SchoolPermissions, type SchoolRef, type SchoolType, type TeamInvitation, type TeamInvitationInput, type TeamMember, type TeamMembersQuery, type TeamRole, type TeamRoleKey, type TeamRoleOrigin, type Theme, type Timezone, TokenExchangeError, type TokenExchangeInput, type TokenExchanger, type TokenExchangerOptions, type TokenVerifier, type TokenVerifierOptions, type VerifiedToken, assertWritable, createAuthorization, createPreferences, createTokenExchanger, createTokenVerifier, isRockfellerError };
@@ -1,3 +1,3 @@
1
- import { A as isRockfellerError, C as HourCycle, D as Theme, E as ReducedMotion, O as Timezone, S as Contrast, T as PreferencesPatch, _ as SchoolList, b as SchoolRef, c as TeamInvitation, d as TeamMembersQuery, f as TeamRole, g as School, h as Permission, j as RockfellerErrorCode, k as RockfellerError, l as TeamInvitationInput, m as TeamRoleOrigin, p as TeamRoleKey, s as Page, u as TeamMember, v as SchoolMembership, w as Preferences, x as SchoolType, y as SchoolPermissions } from "../index-B_byXBRW.js";
2
- import { _ as assertWritable, a as TokenExchangerOptions, c as Preferences$1, d as Authorization, f as AuthorizationOptions, g as InvalidTokenError, h as VerifiedToken, i as TokenExchanger, l as PreferencesOptions, m as TokenVerifierOptions, n as ExchangedToken, o as TokenExchangeError, p as TokenVerifier, r as TokenExchangeInput, s as createPreferences, t as createTokenExchanger, u as createAuthorization, v as createTokenVerifier } from "../index-CNlb6WNr.js";
3
- export { type Authorization, type AuthorizationOptions, type Contrast, type ExchangedToken, type HourCycle, InvalidTokenError, type Page, type Permission, type Preferences, type Preferences$1 as PreferencesClient, type PreferencesOptions, type PreferencesPatch, type ReducedMotion, RockfellerError, RockfellerErrorCode, type School, type SchoolList, type SchoolMembership, type SchoolPermissions, type SchoolRef, type SchoolType, type TeamInvitation, type TeamInvitationInput, type TeamMember, type TeamMembersQuery, type TeamRole, type TeamRoleKey, type TeamRoleOrigin, type Theme, type Timezone, TokenExchangeError, type TokenExchangeInput, type TokenExchanger, type TokenExchangerOptions, type TokenVerifier, type TokenVerifierOptions, type VerifiedToken, assertWritable, createAuthorization, createPreferences, createTokenExchanger, createTokenVerifier, isRockfellerError };
1
+ import { A as Preferences, C as SchoolList, D as SchoolType, E as SchoolRef, F as RockfellerError, I as isRockfellerError, L as RockfellerErrorCode, M as ReducedMotion, N as Theme, O as Contrast, P as Timezone, S as School, T as SchoolPermissions, _ as TeamMembersQuery, b as TeamRoleOrigin, c as AppRoleGrant, d as AppRoleMember, f as AppRoleMembersQuery, g as TeamMember, h as TeamInvitationInput, j as PreferencesPatch, k as HourCycle, l as AppRoleInvitationInput, m as TeamInvitation, p as Page, s as AppRole, u as AppRoleList, v as TeamRole, w as SchoolMembership, x as Permission, y as TeamRoleKey } from "../index-cKCKFKLi.js";
2
+ import { _ as assertWritable, a as TokenExchangerOptions, c as Preferences$1, d as Authorization, f as AuthorizationOptions, g as InvalidTokenError, h as VerifiedToken, i as TokenExchanger, l as PreferencesOptions, m as TokenVerifierOptions, n as ExchangedToken, o as TokenExchangeError, p as TokenVerifier, r as TokenExchangeInput, s as createPreferences, t as createTokenExchanger, u as createAuthorization, v as createTokenVerifier } from "../index-Bl4Ka1Wr.js";
3
+ export { type AppRole, type AppRoleGrant, type AppRoleInvitationInput, type AppRoleList, type AppRoleMember, type AppRoleMembersQuery, type Authorization, type AuthorizationOptions, type Contrast, type ExchangedToken, type HourCycle, InvalidTokenError, type Page, type Permission, type Preferences, type Preferences$1 as PreferencesClient, type PreferencesOptions, type PreferencesPatch, type ReducedMotion, RockfellerError, RockfellerErrorCode, type School, type SchoolList, type SchoolMembership, type SchoolPermissions, type SchoolRef, type SchoolType, type TeamInvitation, type TeamInvitationInput, type TeamMember, type TeamMembersQuery, type TeamRole, type TeamRoleKey, type TeamRoleOrigin, type Theme, type Timezone, TokenExchangeError, type TokenExchangeInput, type TokenExchanger, type TokenExchangerOptions, type TokenVerifier, type TokenVerifierOptions, type VerifiedToken, assertWritable, createAuthorization, createPreferences, createTokenExchanger, createTokenVerifier, isRockfellerError };
@@ -1,5 +1,5 @@
1
- import { a as createAuthorization, i as bearerToken, n as assertWritable, r as createTokenVerifier, t as InvalidTokenError } from "../verifier-DNdy5Ynw.js";
2
- import { f as RockfellerErrorCode, i as isRockfellerError, r as RockfellerError, t as createAccountsApi } from "../accounts-B4bnTXUd.js";
1
+ import { a as createAuthorization, i as bearerToken, n as assertWritable, r as createTokenVerifier, t as InvalidTokenError } from "../verifier-DSvtdWuY.js";
2
+ import { f as RockfellerErrorCode, i as isRockfellerError, r as RockfellerError, t as createAccountsApi } from "../accounts-DJRg4gXj.js";
3
3
  import { c as accountsUrls, l as normalizeIssuer } from "../constants-C4iP0--i.js";
4
4
  import { z } from "zod";
5
5
 
@@ -1,4 +1,4 @@
1
- const require_accounts = require("./accounts-TyMPSHM0.cjs");
1
+ const require_accounts = require("./accounts-BscmRiXc.cjs");
2
2
  const require_constants = require("./constants-rCR-LNSN.cjs");
3
3
  let jose = require("jose");
4
4
 
@@ -116,4 +116,4 @@ Object.defineProperty(exports, "createTokenVerifier", {
116
116
  return createTokenVerifier;
117
117
  }
118
118
  });
119
- //# sourceMappingURL=verifier-BIBtPCVi.cjs.map
119
+ //# sourceMappingURL=verifier-BYrFb8tg.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"verifier-BIBtPCVi.cjs","names":["createAccountsApi","grants","RockfellerError","RockfellerErrorCode","RockfellerError","RockfellerErrorCode","normalizeIssuer","jwtVerify","accountsKeys","joseErrors"],"sources":["../src/modules/sso/resource/authorization.ts","../src/modules/sso/core/bearer.ts","../src/modules/sso/resource/verifier.ts"],"mappings":";;;;;AAiBA,SAAgB,oBAAoB,SAA+B;CAClE,MAAM,WAAWA,mCAAkB,OAAO;CAE1C,OAAO;EAEN,QAAQ,KAAkC;GACzC,OAAO,SAAS,QAAQ,GAAG;EAC5B;EAGA,YACC,KACA,QAC6B;GAC7B,OAAO,SAAS,YAAY,KAAK,MAAM;EACxC;EAGA,MAAM,IACL,KACA,QACA,YACmB;GACnB,OAAOC,wBAAO,MAAM,SAAS,YAAY,KAAK,MAAM,GAAG,UAAU;EAClE;EAGA,MAAM,QACL,KACA,QACA,YAC6B;GAC7B,MAAM,SAAS,MAAM,SAAS,YAAY,KAAK,MAAM;GAErD,IAAI,CAACA,wBAAO,QAAQ,UAAU,GAC7B,MAAM,IAAIC,iCACTC,qCAAoB,WACpB,KACA,mBAAmB,WAAW,eAC/B;GAED,OAAO;EACR;CACD;AACD;;;AC5DA,SAAgB,YACf,OACqB;CACrB,OAAO,OAAO,QAAQ,eAAe,EAAE,CAAC,CAAC,KAAK,KAAK,KAAK;AACzD;;;ACSA,SAAgB,eAAe,OAA8C;CAC5E,IAAI,MAAM,UACT,MAAM,IAAIC,iCACTC,qCAAoB,yBACpB,KACA,+CACD;AACF;AAGA,IAAa,oBAAb,cAAuCD,iCAAgB;CACtD,YAAY,UAAU,mBAAmB;EAC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IAAID,iCACTC,qCAAoB,iBACpB,KACA,yDACD;EAED,MAAM,SACL,OAAO,QAAQ,UAAU,WACtB,QAAQ,MAAM,MAAM,GAAG,IACvB,CAAC;EACL,MAAM,UAAU,QAAQ,gBAAgB,QACtC,UAAU,CAAC,OAAO,SAAS,KAAK,CAClC;EAEA,IAAI,SAAS,QACZ,MAAM,IAAID,iCACT,sBACA,KACA,mBAAmB,QAAQ,KAAK,IAAI,EAAE,EACvC;EAED,OAAO;GACN,KAAK,QAAQ;GACb;GACA,UACC,OAAO,QAAQ,cAAc,WAC1B,QAAQ,YACR,OAAO,QAAQ,QAAQ,WACtB,QAAQ,MACR;GACL,KAAK,OAAO,QAAQ,QAAQ,WAAW,QAAQ,MAAM;GACrD,UACC,OAAO,QAAQ,cAAc,2BAC1B,IAAI,KAAK,QAAQ,YAAY,GAAI,IACjC;GACJ;GACA;GACA,UAAU,mBAAmB,KAAK;GAClC;EACD;CACD,EACD;AACD"}
1
+ {"version":3,"file":"verifier-BYrFb8tg.cjs","names":["createAccountsApi","grants","RockfellerError","RockfellerErrorCode","RockfellerError","RockfellerErrorCode","normalizeIssuer","jwtVerify","accountsKeys","joseErrors"],"sources":["../src/modules/sso/resource/authorization.ts","../src/modules/sso/core/bearer.ts","../src/modules/sso/resource/verifier.ts"],"mappings":";;;;;AAiBA,SAAgB,oBAAoB,SAA+B;CAClE,MAAM,WAAWA,mCAAkB,OAAO;CAE1C,OAAO;EAEN,QAAQ,KAAkC;GACzC,OAAO,SAAS,QAAQ,GAAG;EAC5B;EAGA,YACC,KACA,QAC6B;GAC7B,OAAO,SAAS,YAAY,KAAK,MAAM;EACxC;EAGA,MAAM,IACL,KACA,QACA,YACmB;GACnB,OAAOC,wBAAO,MAAM,SAAS,YAAY,KAAK,MAAM,GAAG,UAAU;EAClE;EAGA,MAAM,QACL,KACA,QACA,YAC6B;GAC7B,MAAM,SAAS,MAAM,SAAS,YAAY,KAAK,MAAM;GAErD,IAAI,CAACA,wBAAO,QAAQ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;EACD;EAEA,IAAI,CAAC,QAAQ,KACZ,MAAM,IAAI,kBAAkB,2BAA2B;EAExD,MAAM,QAAQ,UAAU,OAAO;EAC/B,MAAM,iBAAiB,gBAAgB,OAAO,IAAI,QAAQ,KAAK;EAC/D,MAAM,EAAE,kBAAkB;EAE1B,IAAI,mBAAmB,KAAK,KAAK,CAAC,QAAQ,oBACzC,MAAM,IAAIL,iCACTC,qCAAoB,2BACpB,KACA,8CACD;EAED,IACC,UAAU,KAAK,KACf,mBAAmB,KAAK,KACxB,iBACA,CAAC,cAAc,SAAS,KAAK,GAE7B,MAAM,IAAID,iCACTC,qCAAoB,iBACpB,KACA,yDACD;EAED,MAAM,SACL,OAAO,QAAQ,UAAU,WACtB,QAAQ,MAAM,MAAM,GAAG,IACvB,CAAC;EACL,MAAM,UAAU,QAAQ,gBAAgB,QACtC,UAAU,CAAC,OAAO,SAAS,KAAK,CAClC;EAEA,IAAI,SAAS,QACZ,MAAM,IAAID,iCACT,sBACA,KACA,mBAAmB,QAAQ,KAAK,IAAI,EAAE,EACvC;EAED,OAAO;GACN,KAAK,QAAQ;GACb;GACA,UACC,OAAO,QAAQ,cAAc,WAC1B,QAAQ,YACR,OAAO,QAAQ,QAAQ,WACtB,QAAQ,MACR;GACL,KAAK,OAAO,QAAQ,QAAQ,WAAW,QAAQ,MAAM;GACrD,UACC,OAAO,QAAQ,cAAc,2BAC1B,IAAI,KAAK,QAAQ,YAAY,GAAI,IACjC;GACJ;GACA;GACA,UAAU,mBAAmB,KAAK;GAClC;EACD;CACD,EACD;AACD"}
@@ -1,4 +1,4 @@
1
- import { a as accountsKeys, f as RockfellerErrorCode, n as grants, r as RockfellerError, t as createAccountsApi } from "./accounts-B4bnTXUd.js";
1
+ import { a as accountsKeys, f as RockfellerErrorCode, n as grants, r as RockfellerError, t as createAccountsApi } from "./accounts-DJRg4gXj.js";
2
2
  import { l as normalizeIssuer } from "./constants-C4iP0--i.js";
3
3
  import { errors, jwtVerify } from "jose";
4
4
 
@@ -87,4 +87,4 @@ function createTokenVerifier(options) {
87
87
  }
88
88
 
89
89
  export { createAuthorization as a, bearerToken as i, assertWritable as n, createTokenVerifier as r, InvalidTokenError as t };
90
- //# sourceMappingURL=verifier-DNdy5Ynw.js.map
90
+ //# sourceMappingURL=verifier-DSvtdWuY.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"verifier-DNdy5Ynw.js","names":["joseErrors"],"sources":["../src/modules/sso/resource/authorization.ts","../src/modules/sso/core/bearer.ts","../src/modules/sso/resource/verifier.ts"],"mappings":";;;;;AAiBA,SAAgB,oBAAoB,SAA+B;CAClE,MAAM,WAAW,kBAAkB,OAAO;CAE1C,OAAO;EAEN,QAAQ,KAAkC;GACzC,OAAO,SAAS,QAAQ,GAAG;EAC5B;EAGA,YACC,KACA,QAC6B;GAC7B,OAAO,SAAS,YAAY,KAAK,MAAM;EACxC;EAGA,MAAM,IACL,KACA,QACA,YACmB;GACnB,OAAO,OAAO,MAAM,SAAS,YAAY,KAAK,MAAM,GAAG,UAAU;EAClE;EAGA,MAAM,QACL,KACA,QACA,YAC6B;GAC7B,MAAM,SAAS,MAAM,SAAS,YAAY,KAAK,MAAM;GAErD,IAAI,CAAC,OAAO,QAAQ,UAAU,GAC7B,MAAM,IAAI,gBACT,oBAAoB,WACpB,KACA,mBAAmB,WAAW,eAC/B;GAED,OAAO;EACR;CACD;AACD;;;AC5DA,SAAgB,YACf,OACqB;CACrB,OAAO,OAAO,QAAQ,eAAe,EAAE,CAAC,CAAC,KAAK,KAAK,KAAK;AACzD;;;ACSA,SAAgB,eAAe,OAA8C;CAC5E,IAAI,MAAM,UACT,MAAM,IAAI,gBACT,oBAAoB,yBACpB,KACA,+CACD;AACF;AAGA,IAAa,oBAAb,cAAuC,gBAAgB;CACtD,YAAY,UAAU,mBAAmB;EACxC,MAAM,oBAAoB,eAAe,KAAK,OAAO;CACtD;AACD;AAEA,SAAS,aAAa,OAA0C;CAC/D,OACC,OAAO,UAAU,YACjB,UAAU,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EACL,MAAM,UAAU,QAAQ,gBAAgB,QACtC,UAAU,CAAC,OAAO,SAAS,KAAK,CAClC;EAEA,IAAI,SAAS,QACZ,MAAM,IAAI,gBACT,sBACA,KACA,mBAAmB,QAAQ,KAAK,IAAI,EAAE,EACvC;EAED,OAAO;GACN,KAAK,QAAQ;GACb;GACA,UACC,OAAO,QAAQ,cAAc,WAC1B,QAAQ,YACR,OAAO,QAAQ,QAAQ,WACtB,QAAQ,MACR;GACL,KAAK,OAAO,QAAQ,QAAQ,WAAW,QAAQ,MAAM;GACrD,UACC,OAAO,QAAQ,cAAc,2BAC1B,IAAI,KAAK,QAAQ,YAAY,GAAI,IACjC;GACJ;GACA;GACA,UAAU,mBAAmB,KAAK;GAClC;EACD;CACD,EACD;AACD"}
1
+ {"version":3,"file":"verifier-DSvtdWuY.js","names":["joseErrors"],"sources":["../src/modules/sso/resource/authorization.ts","../src/modules/sso/core/bearer.ts","../src/modules/sso/resource/verifier.ts"],"mappings":";;;;;AAiBA,SAAgB,oBAAoB,SAA+B;CAClE,MAAM,WAAW,kBAAkB,OAAO;CAE1C,OAAO;EAEN,QAAQ,KAAkC;GACzC,OAAO,SAAS,QAAQ,GAAG;EAC5B;EAGA,YACC,KACA,QAC6B;GAC7B,OAAO,SAAS,YAAY,KAAK,MAAM;EACxC;EAGA,MAAM,IACL,KACA,QACA,YACmB;GACnB,OAAO,OAAO,MAAM,SAAS,YAAY,KAAK,MAAM,GAAG,UAAU;EAClE;EAGA,MAAM,QACL,KACA,QACA,YAC6B;GAC7B,MAAM,SAAS,MAAM,SAAS,YAAY,KAAK,MAAM;GAErD,IAAI,CAAC,OAAO,QAAQ,UAAU,GAC7B,MAAM,IAAI,gBACT,oBAAoB,WACpB,KACA,mBAAmB,WAAW,eAC/B;GAED,OAAO;EACR;CACD;AACD;;;AC5DA,SAAgB,YACf,OACqB;CACrB,OAAO,OAAO,QAAQ,eAAe,EAAE,CAAC,CAAC,KAAK,KAAK,KAAK;AACzD;;;ACSA,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QAAQ,oBACzC,MAAM,IAAI,gBACT,oBAAoB,2BACpB,KACA,8CACD;EAED,IACC,UAAU,KAAK,KACf,mBAAmB,KAAK,KACxB,iBACA,CAAC,cAAc,SAAS,KAAK,GAE7B,MAAM,IAAI,gBACT,oBAAoB,iBACpB,KACA,yDACD;EAED,MAAM,SACL,OAAO,QAAQ,UAAU,WACtB,QAAQ,MAAM,MAAM,GAAG,IACvB,CAAC;EACL,MAAM,UAAU,QAAQ,gBAAgB,QACtC,UAAU,CAAC,OAAO,SAAS,KAAK,CAClC;EAEA,IAAI,SAAS,QACZ,MAAM,IAAI,gBACT,sBACA,KACA,mBAAmB,QAAQ,KAAK,IAAI,EAAE,EACvC;EAED,OAAO;GACN,KAAK,QAAQ;GACb;GACA,UACC,OAAO,QAAQ,cAAc,WAC1B,QAAQ,YACR,OAAO,QAAQ,QAAQ,WACtB,QAAQ,MACR;GACL,KAAK,OAAO,QAAQ,QAAQ,WAAW,QAAQ,MAAM;GACrD,UACC,OAAO,QAAQ,cAAc,2BAC1B,IAAI,KAAK,QAAQ,YAAY,GAAI,IACjC;GACJ;GACA;GACA,UAAU,mBAAmB,KAAK;GAClC;EACD;CACD,EACD;AACD"}
@@ -0,0 +1 @@
1
+ const e=`0.8.0`;export{e as t};
@@ -1 +1 @@
1
- Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return`0.6.0`}});
1
+ Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return`0.8.0`}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "franchising",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "description": "Rockfeller franchising library.",
5
5
  "keywords": [
6
6
  "franchising",
@@ -1,17 +0,0 @@
1
- /**
2
- * Codigos de erro da API.
3
- *
4
- * @remarks
5
- * O cliente decide o que fazer pelo codigo, nunca pela mensagem: mensagem e
6
- * texto de interface e muda sem aviso.
7
- */
8
- export const ErrorCodes = {
9
- BAD_REQUEST: 'BAD_REQUEST',
10
- UNAUTHORIZED: 'UNAUTHORIZED',
11
- FORBIDDEN: 'FORBIDDEN',
12
- NOT_FOUND: 'NOT_FOUND',
13
- CONFLICT: 'CONFLICT',
14
- VALIDATION_FAILED: 'VALIDATION_FAILED',
15
- UPSTREAM_FAILED: 'UPSTREAM_FAILED',
16
- INTERNAL_ERROR: 'INTERNAL_ERROR',
17
- } as const;
@@ -1,16 +0,0 @@
1
- import { ErrorCodes } from './codes';
2
-
3
- export { ErrorCodes };
4
-
5
- export type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
6
-
7
- export const ErrorMessages: Record<ErrorCode, string> = {
8
- [ErrorCodes.BAD_REQUEST]: 'Invalid request.',
9
- [ErrorCodes.UNAUTHORIZED]: 'Authentication required.',
10
- [ErrorCodes.FORBIDDEN]: 'Access denied.',
11
- [ErrorCodes.NOT_FOUND]: 'Resource not found.',
12
- [ErrorCodes.CONFLICT]: 'Conflict with the current state.',
13
- [ErrorCodes.VALIDATION_FAILED]: 'Invalid data.',
14
- [ErrorCodes.UPSTREAM_FAILED]: 'External service unavailable.',
15
- [ErrorCodes.INTERNAL_ERROR]: 'Internal error.',
16
- };
@@ -1,53 +0,0 @@
1
- import {
2
- type ArgumentsHost,
3
- Catch,
4
- type ExceptionFilter,
5
- HttpException,
6
- HttpStatus,
7
- Logger,
8
- } from '@nestjs/common';
9
- import { ErrorCodes } from '../errors';
10
- import { error } from '../shared/response';
11
-
12
- /**
13
- * Traduz qualquer excecao para o envelope de erro da API.
14
- *
15
- * @remarks
16
- * Sem o filtro, uma falha inesperada sai no formato padrao do Nest — outro
17
- * contrato, e com a mensagem original do stack. Aqui ela vira
18
- * `INTERNAL_ERROR`, e o detalhe fica so no log do servidor.
19
- */
20
- @Catch()
21
- export class ApiExceptionFilter implements ExceptionFilter {
22
- private readonly logger = new Logger(ApiExceptionFilter.name);
23
-
24
- catch(exception: unknown, host: ArgumentsHost) {
25
- const response = host.switchToHttp().getResponse();
26
-
27
- if (exception instanceof HttpException) {
28
- const payload = exception.getResponse();
29
-
30
- /*
31
- * Os atalhos de `shared/exceptions` ja entregam o envelope pronto. O
32
- * que chega fora dele vem do proprio Nest — o ValidationPipe, por
33
- * exemplo — e precisa ser reembalado.
34
- */
35
- const body =
36
- typeof payload === 'object' &&
37
- payload !== null &&
38
- 'ok' in payload
39
- ? payload
40
- : error(ErrorCodes.VALIDATION_FAILED, payload);
41
-
42
- return response.status(exception.getStatus()).send(body);
43
- }
44
-
45
- this.logger.error(
46
- exception instanceof Error ? exception.stack : String(exception),
47
- );
48
-
49
- return response
50
- .status(HttpStatus.INTERNAL_SERVER_ERROR)
51
- .send(error(ErrorCodes.INTERNAL_ERROR));
52
- }
53
- }
@@ -1,40 +0,0 @@
1
- import {
2
- BadGatewayException,
3
- BadRequestException,
4
- ConflictException,
5
- ForbiddenException,
6
- InternalServerErrorException,
7
- NotFoundException,
8
- UnauthorizedException,
9
- } from '@nestjs/common';
10
- import type { ErrorCode } from '../errors';
11
- import { error } from './response';
12
-
13
- export function badRequest(code: ErrorCode, errors?: unknown) {
14
- return new BadRequestException(error(code, errors));
15
- }
16
-
17
- export function unauthorized(code: ErrorCode) {
18
- return new UnauthorizedException(error(code));
19
- }
20
-
21
- export function forbidden(code: ErrorCode) {
22
- return new ForbiddenException(error(code));
23
- }
24
-
25
- export function notFound(code: ErrorCode) {
26
- return new NotFoundException(error(code));
27
- }
28
-
29
- export function conflict(code: ErrorCode, errors?: unknown) {
30
- return new ConflictException(error(code, errors));
31
- }
32
-
33
- /** Falha de um servico externo, e nao da requisicao de quem chamou. */
34
- export function upstreamFailed(code: ErrorCode) {
35
- return new BadGatewayException(error(code));
36
- }
37
-
38
- export function internalError(code: ErrorCode) {
39
- return new InternalServerErrorException(error(code));
40
- }
@@ -1,31 +0,0 @@
1
- import { type ErrorCode, ErrorMessages } from '../errors';
2
-
3
- /**
4
- * Envelope de sucesso.
5
- *
6
- * @remarks
7
- * Toda resposta sai como `{ ok, ... }` para o cliente distinguir sucesso de
8
- * erro por um campo so, sem depender do status HTTP — que se perde em proxy,
9
- * retentativa e log.
10
- */
11
- export function ok<Data>(data: Data) {
12
- return { ok: true as const, data };
13
- }
14
-
15
- /**
16
- * Envelope de erro.
17
- *
18
- * @remarks
19
- * Unico lugar que monta corpo de erro. Os atalhos de `shared/exceptions` e o
20
- * filtro global chamam esta funcao: se cada um montasse o objeto na mao, o
21
- * formato divergiria entre a excecao lancada por uma regra e a resposta de uma
22
- * falha inesperada, e o cliente precisaria tratar dois contratos.
23
- */
24
- export function error(code: ErrorCode, errors?: unknown) {
25
- return {
26
- ok: false as const,
27
- code,
28
- message: ErrorMessages[code],
29
- ...(errors === undefined ? {} : { errors }),
30
- };
31
- }
@@ -1,59 +0,0 @@
1
- // #if posthog
2
- import { posthog } from 'franchising/telemetry/posthog';
3
- // #endif
4
- // #if betterstack
5
- import { betterstack } from 'franchising/telemetry/betterstack';
6
- // #endif
7
- import { registerTelemetry } from 'franchising/telemetry/register';
8
- import { env } from './env';
9
-
10
- /**
11
- * Destinos externos dos sinais de telemetria.
12
- *
13
- * @remarks
14
- * Sem credencial a lista fica vazia e a biblioteca vira no-op: os logs seguem
15
- * saindo em JSON no stdout, e tracing, metricas e error tracking se desligam
16
- * sozinhos. E o que faz o ambiente de desenvolvimento nao precisar de conta em
17
- * provedor nenhum.
18
- */
19
- export const adapters = [
20
- // #if posthog
21
- /*
22
- * O PostHog recebe evento de produto (`telemetry.event`) e excecao. Log
23
- * tecnico — debug, info, warn e error — nao vai para ele de proposito:
24
- * analytics e diagnostico operacional sao coisas diferentes.
25
- */
26
- ...(env.POSTHOG_API_KEY
27
- ? [
28
- posthog({
29
- apiKey: env.POSTHOG_API_KEY,
30
- host: env.POSTHOG_HOST,
31
- }),
32
- ]
33
- : []),
34
- // #endif
35
- // #if betterstack
36
- /*
37
- * O Better Stack recebe os cinco sinais. O token da source fica no
38
- * Collector, nunca no repositorio: aqui so entra o endereco dele.
39
- */
40
- ...(env.BETTERSTACK_OTLP_ENDPOINT
41
- ? [
42
- betterstack({
43
- otlp: { endpoint: env.BETTERSTACK_OTLP_ENDPOINT },
44
- ...(env.BETTERSTACK_ERRORS_DSN
45
- ? { errors: { dsn: env.BETTERSTACK_ERRORS_DSN } }
46
- : {}),
47
- }),
48
- ]
49
- : []),
50
- // #endif
51
- ];
52
-
53
- /*
54
- * Roda no import, e nao numa funcao chamada depois: a auto-instrumentacao so
55
- * consegue interceptar o Nest, o driver do banco e os clients HTTP se for
56
- * registrada antes de esses modulos serem avaliados. Por isso `main.ts` importa
57
- * este arquivo antes de qualquer `@nestjs/*`.
58
- */
59
- registerTelemetry({ adapters });
@@ -1 +0,0 @@
1
- const e=`0.6.0`;export{e as t};