opf-validator-beta 0.0.16 → 0.0.17

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 (188) hide show
  1. package/dist/consent/index.d.ts +4 -4
  2. package/dist/consent/index.d.ts.map +1 -1
  3. package/dist/consent/index.js +2 -2
  4. package/dist/consent/index.js.map +1 -1
  5. package/dist/consent/interfaces/createConsent.d.ts +23 -0
  6. package/dist/consent/interfaces/createConsent.d.ts.map +1 -0
  7. package/dist/consent/interfaces/createConsent.js +3 -0
  8. package/dist/consent/interfaces/createConsent.js.map +1 -0
  9. package/dist/consent/interfaces/createConsentExtensions.d.ts +23 -0
  10. package/dist/consent/interfaces/createConsentExtensions.d.ts.map +1 -0
  11. package/dist/consent/interfaces/createConsentExtensions.js +3 -0
  12. package/dist/consent/interfaces/createConsentExtensions.js.map +1 -0
  13. package/dist/consent/{successResponses/index.d.ts → interfaces/successResponses.d.ts} +1 -1
  14. package/dist/consent/interfaces/successResponses.d.ts.map +1 -0
  15. package/dist/consent/{successResponses/index.js → interfaces/successResponses.js} +1 -1
  16. package/dist/consent/interfaces/successResponses.js.map +1 -0
  17. package/dist/consent/validators/createConsent.d.ts +2 -24
  18. package/dist/consent/validators/createConsent.d.ts.map +1 -1
  19. package/dist/consent/validators/createConsent.js +15 -137
  20. package/dist/consent/validators/createConsent.js.map +1 -1
  21. package/dist/consent/validators/createConsentExtensions.d.ts +2 -24
  22. package/dist/consent/validators/createConsentExtensions.d.ts.map +1 -1
  23. package/dist/consent/validators/createConsentExtensions.js +17 -165
  24. package/dist/consent/validators/createConsentExtensions.js.map +1 -1
  25. package/dist/index.d.ts +0 -1
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +50 -52
  28. package/dist/index.js.map +1 -7
  29. package/dist/payments/index.d.ts +7 -6
  30. package/dist/payments/index.d.ts.map +1 -1
  31. package/dist/payments/index.js +9 -9
  32. package/dist/payments/index.js.map +1 -1
  33. package/dist/payments/interfaces/createPaymentConsent.d.ts +56 -0
  34. package/dist/payments/interfaces/createPaymentConsent.d.ts.map +1 -0
  35. package/dist/payments/interfaces/createPaymentConsent.js +3 -0
  36. package/dist/payments/interfaces/createPaymentConsent.js.map +1 -0
  37. package/dist/payments/interfaces/createPixPayment.d.ts +25 -0
  38. package/dist/payments/interfaces/createPixPayment.d.ts.map +1 -0
  39. package/dist/payments/interfaces/createPixPayment.js +3 -0
  40. package/dist/payments/interfaces/createPixPayment.js.map +1 -0
  41. package/dist/payments/interfaces/patchPixPayment.d.ts +18 -0
  42. package/dist/payments/interfaces/patchPixPayment.d.ts.map +1 -0
  43. package/dist/payments/interfaces/patchPixPayment.js +3 -0
  44. package/dist/payments/interfaces/patchPixPayment.js.map +1 -0
  45. package/dist/payments/{successResponses/index.d.ts → interfaces/successResponses.d.ts} +1 -1
  46. package/dist/payments/interfaces/successResponses.d.ts.map +1 -0
  47. package/dist/payments/{successResponses/index.js → interfaces/successResponses.js} +1 -1
  48. package/dist/payments/interfaces/successResponses.js.map +1 -0
  49. package/dist/payments/validators/createPaymentConsent.d.ts +2 -57
  50. package/dist/payments/validators/createPaymentConsent.d.ts.map +1 -1
  51. package/dist/payments/validators/createPaymentConsent.js +82 -369
  52. package/dist/payments/validators/createPaymentConsent.js.map +1 -1
  53. package/dist/payments/validators/createPixPayment.d.ts +2 -26
  54. package/dist/payments/validators/createPixPayment.d.ts.map +1 -1
  55. package/dist/payments/validators/createPixPayment.js +199 -198
  56. package/dist/payments/validators/createPixPayment.js.map +1 -1
  57. package/dist/payments/validators/patchPixPayment.d.ts +2 -19
  58. package/dist/payments/validators/patchPixPayment.d.ts.map +1 -1
  59. package/dist/payments/validators/patchPixPayment.js +30 -52
  60. package/dist/payments/validators/patchPixPayment.js.map +1 -1
  61. package/dist/payments/validators/validateConsentAgainstPayment.d.ts +32 -0
  62. package/dist/payments/validators/validateConsentAgainstPayment.d.ts.map +1 -0
  63. package/dist/payments/validators/validateConsentAgainstPayment.js +174 -0
  64. package/dist/payments/validators/validateConsentAgainstPayment.js.map +1 -0
  65. package/dist/recurring-payments/index.d.ts +8 -7
  66. package/dist/recurring-payments/index.d.ts.map +1 -1
  67. package/dist/recurring-payments/index.js +9 -6
  68. package/dist/recurring-payments/index.js.map +1 -1
  69. package/dist/recurring-payments/interfaces/createRecurringConsent.d.ts +86 -0
  70. package/dist/recurring-payments/interfaces/createRecurringConsent.d.ts.map +1 -0
  71. package/dist/recurring-payments/interfaces/createRecurringConsent.js +3 -0
  72. package/dist/recurring-payments/interfaces/createRecurringConsent.js.map +1 -0
  73. package/dist/recurring-payments/interfaces/createRecurringRetryPixPayment.d.ts +10 -0
  74. package/dist/recurring-payments/interfaces/createRecurringRetryPixPayment.d.ts.map +1 -0
  75. package/dist/recurring-payments/interfaces/createRecurringRetryPixPayment.js +3 -0
  76. package/dist/recurring-payments/interfaces/createRecurringRetryPixPayment.js.map +1 -0
  77. package/dist/recurring-payments/{validators → interfaces}/patchPixPayment.d.ts +12 -10
  78. package/dist/recurring-payments/interfaces/patchPixPayment.d.ts.map +1 -0
  79. package/dist/recurring-payments/interfaces/patchPixPayment.js +3 -0
  80. package/dist/recurring-payments/interfaces/patchPixPayment.js.map +1 -0
  81. package/dist/recurring-payments/interfaces/patchRecurringConsent.d.ts +72 -0
  82. package/dist/recurring-payments/interfaces/patchRecurringConsent.d.ts.map +1 -0
  83. package/dist/recurring-payments/interfaces/patchRecurringConsent.js +3 -0
  84. package/dist/recurring-payments/interfaces/patchRecurringConsent.js.map +1 -0
  85. package/dist/recurring-payments/{successResponses/index.d.ts → interfaces/successResponses.d.ts} +1 -1
  86. package/dist/recurring-payments/interfaces/successResponses.d.ts.map +1 -0
  87. package/dist/recurring-payments/{successResponses/index.js → interfaces/successResponses.js} +1 -1
  88. package/dist/recurring-payments/interfaces/successResponses.js.map +1 -0
  89. package/dist/recurring-payments/validators/createRecurringConsent.d.ts +2 -87
  90. package/dist/recurring-payments/validators/createRecurringConsent.d.ts.map +1 -1
  91. package/dist/recurring-payments/validators/createRecurringConsent.js +88 -400
  92. package/dist/recurring-payments/validators/createRecurringConsent.js.map +1 -1
  93. package/dist/recurring-payments/validators/createRecurringRetryPixPayment.d.ts +2 -11
  94. package/dist/recurring-payments/validators/createRecurringRetryPixPayment.d.ts.map +1 -1
  95. package/dist/recurring-payments/validators/createRecurringRetryPixPayment.js.map +1 -1
  96. package/dist/recurring-payments/validators/patchRecurringConsent.d.ts +3 -73
  97. package/dist/recurring-payments/validators/patchRecurringConsent.d.ts.map +1 -1
  98. package/dist/recurring-payments/validators/patchRecurringConsent.js +36 -267
  99. package/dist/recurring-payments/validators/patchRecurringConsent.js.map +1 -1
  100. package/dist/recurring-payments/validators/patchRecurringPixPayment.d.ts +7 -0
  101. package/dist/recurring-payments/validators/patchRecurringPixPayment.d.ts.map +1 -0
  102. package/dist/recurring-payments/validators/{patchPixPayment.js → patchRecurringPixPayment.js} +32 -15
  103. package/dist/recurring-payments/validators/patchRecurringPixPayment.js.map +1 -0
  104. package/dist/recurring-payments/validators/validateRecurringConsentAgainstPayment.d.ts +36 -0
  105. package/dist/recurring-payments/validators/validateRecurringConsentAgainstPayment.d.ts.map +1 -0
  106. package/dist/recurring-payments/validators/validateRecurringConsentAgainstPayment.js +349 -0
  107. package/dist/recurring-payments/validators/validateRecurringConsentAgainstPayment.js.map +1 -0
  108. package/dist/utils/openFinanceErrors.d.ts +9 -1
  109. package/dist/utils/openFinanceErrors.d.ts.map +1 -1
  110. package/dist/utils/openFinanceErrors.js +29 -5
  111. package/dist/utils/openFinanceErrors.js.map +1 -1
  112. package/dist/utils/paymentErrors.d.ts +4 -0
  113. package/dist/utils/paymentErrors.d.ts.map +1 -1
  114. package/dist/utils/paymentErrors.js +4 -0
  115. package/dist/utils/paymentErrors.js.map +1 -1
  116. package/dist/utils/types/types.consent.d.ts +25 -0
  117. package/dist/utils/types/types.consent.d.ts.map +1 -0
  118. package/dist/utils/types/types.consent.js +78 -0
  119. package/dist/utils/types/types.consent.js.map +1 -0
  120. package/dist/utils/types/types.d.ts +8 -0
  121. package/dist/utils/types/types.d.ts.map +1 -0
  122. package/dist/utils/types/types.js +11 -0
  123. package/dist/utils/types/types.js.map +1 -0
  124. package/dist/utils/types/types.payment.d.ts +32 -0
  125. package/dist/utils/types/types.payment.d.ts.map +1 -0
  126. package/dist/utils/types/types.payment.js +46 -0
  127. package/dist/utils/types/types.payment.js.map +1 -0
  128. package/dist/utils/types/types.recurring.d.ts +37 -0
  129. package/dist/utils/types/types.recurring.d.ts.map +1 -0
  130. package/dist/utils/types/types.recurring.js +56 -0
  131. package/dist/utils/types/types.recurring.js.map +1 -0
  132. package/dist/utils/validateHeaderParameters.d.ts +6 -2
  133. package/dist/utils/validateHeaderParameters.d.ts.map +1 -1
  134. package/dist/utils/validateHeaderParameters.js +19 -57
  135. package/dist/utils/validateHeaderParameters.js.map +1 -1
  136. package/dist/utils/validationHelpers.d.ts +4 -85
  137. package/dist/utils/validationHelpers.d.ts.map +1 -1
  138. package/dist/utils/validationHelpers.js +20 -370
  139. package/dist/utils/validationHelpers.js.map +1 -1
  140. package/dist/utils/validators/accountValidators.d.ts +48 -0
  141. package/dist/utils/validators/accountValidators.d.ts.map +1 -0
  142. package/dist/utils/validators/accountValidators.js +244 -0
  143. package/dist/utils/validators/accountValidators.js.map +1 -0
  144. package/dist/utils/validators/amountValidators.d.ts +14 -0
  145. package/dist/utils/validators/amountValidators.d.ts.map +1 -0
  146. package/dist/utils/validators/amountValidators.js +48 -0
  147. package/dist/utils/validators/amountValidators.js.map +1 -0
  148. package/dist/utils/validators/consentValidationHelpers.d.ts +32 -0
  149. package/dist/utils/validators/consentValidationHelpers.d.ts.map +1 -0
  150. package/dist/utils/validators/consentValidationHelpers.js +51 -0
  151. package/dist/utils/validators/consentValidationHelpers.js.map +1 -0
  152. package/dist/utils/validators/credentialsValidators.d.ts +22 -0
  153. package/dist/utils/validators/credentialsValidators.d.ts.map +1 -0
  154. package/dist/utils/validators/credentialsValidators.js +177 -0
  155. package/dist/utils/validators/credentialsValidators.js.map +1 -0
  156. package/dist/utils/validators/dateTimeValidators.d.ts +18 -0
  157. package/dist/utils/validators/dateTimeValidators.d.ts.map +1 -0
  158. package/dist/utils/validators/dateTimeValidators.js +68 -0
  159. package/dist/utils/validators/dateTimeValidators.js.map +1 -0
  160. package/dist/utils/validators/documentValidators.d.ts +27 -0
  161. package/dist/utils/validators/documentValidators.d.ts.map +1 -0
  162. package/dist/utils/validators/documentValidators.js +114 -0
  163. package/dist/utils/validators/documentValidators.js.map +1 -0
  164. package/dist/utils/validators/index.d.ts +33 -0
  165. package/dist/utils/validators/index.d.ts.map +1 -0
  166. package/dist/utils/validators/index.js +49 -0
  167. package/dist/utils/validators/index.js.map +1 -0
  168. package/dist/utils/validators/locationValidators.d.ts +7 -0
  169. package/dist/utils/validators/locationValidators.d.ts.map +1 -0
  170. package/dist/utils/validators/locationValidators.js +22 -0
  171. package/dist/utils/validators/locationValidators.js.map +1 -0
  172. package/dist/utils/validators/stringValidators.d.ts +35 -0
  173. package/dist/utils/validators/stringValidators.d.ts.map +1 -0
  174. package/dist/utils/validators/stringValidators.js +167 -0
  175. package/dist/utils/validators/stringValidators.js.map +1 -0
  176. package/package.json +2 -4
  177. package/dist/consent/package.json +0 -6
  178. package/dist/consent/successResponses/index.d.ts.map +0 -1
  179. package/dist/consent/successResponses/index.js.map +0 -1
  180. package/dist/payments/package.json +0 -6
  181. package/dist/payments/successResponses/index.d.ts.map +0 -1
  182. package/dist/payments/successResponses/index.js.map +0 -1
  183. package/dist/recurring-payments/package.json +0 -6
  184. package/dist/recurring-payments/successResponses/index.d.ts.map +0 -1
  185. package/dist/recurring-payments/successResponses/index.js.map +0 -1
  186. package/dist/recurring-payments/validators/patchPixPayment.d.ts.map +0 -1
  187. package/dist/recurring-payments/validators/patchPixPayment.js.map +0 -1
  188. package/dist/utils/package.json +0 -6
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Consent Module - Exports all validators and success responses
2
+ * Consent Module - Exports validators
3
3
  */
4
4
  export { validateCreateConsent } from "./validators/createConsent";
5
- export type { CreateConsentPayload, CreateConsentData } from "./validators/createConsent";
5
+ export type { CreateConsentPayload, CreateConsentData } from "./interfaces/createConsent";
6
6
  export { validateCreateConsentExtensions } from "./validators/createConsentExtensions";
7
- export type { CreateConsentExtensionsPayload, CreateConsentExtensionsData, LoggedUserExtensions, BusinessEntityExtensions, } from "./validators/createConsentExtensions";
8
- export type { CreateConsentSuccessResponse, GetConsentSuccessResponse, CreateConsentExtensionsSuccessResponse, } from "./successResponses";
7
+ export type { CreateConsentExtensionsPayload, } from "./interfaces/createConsentExtensions";
8
+ export type { GetConsentSuccessResponse, } from "./interfaces/successResponses";
9
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/consent/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,YAAY,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE1F,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AACvF,YAAY,EACV,8BAA8B,EAC9B,2BAA2B,EAC3B,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,sCAAsC,CAAC;AAG9C,YAAY,EACV,4BAA4B,EAC5B,yBAAyB,EACzB,sCAAsC,GACvC,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/consent/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,YAAY,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE1F,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AACvF,YAAY,EACV,8BAA8B,GAC/B,MAAM,sCAAsC,CAAC;AAG9C,YAAY,EACV,yBAAyB,GAC1B,MAAM,+BAA+B,CAAC"}
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  /**
3
- * Consent Module - Exports all validators and success responses
3
+ * Consent Module - Exports validators
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.validateCreateConsentExtensions = exports.validateCreateConsent = void 0;
7
- // Validators
7
+ // Main Validators
8
8
  var createConsent_1 = require("./validators/createConsent");
9
9
  Object.defineProperty(exports, "validateCreateConsent", { enumerable: true, get: function () { return createConsent_1.validateCreateConsent; } });
10
10
  var createConsentExtensions_1 = require("./validators/createConsentExtensions");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/consent/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,aAAa;AACb,4DAAmE;AAA1D,sHAAA,qBAAqB,OAAA;AAG9B,gFAAuF;AAA9E,0IAAA,+BAA+B,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/consent/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,kBAAkB;AAClB,4DAAmE;AAA1D,sHAAA,qBAAqB,OAAA;AAG9B,gFAAuF;AAA9E,0IAAA,+BAA+B,OAAA"}
@@ -0,0 +1,23 @@
1
+ export interface LoggedUser {
2
+ document: {
3
+ identification: string;
4
+ rel: string;
5
+ };
6
+ }
7
+ export interface BusinessEntity {
8
+ document: {
9
+ identification: string;
10
+ rel: string;
11
+ };
12
+ }
13
+ export interface CreateConsentData {
14
+ permissions: string[];
15
+ loggedUser: LoggedUser;
16
+ businessEntity?: BusinessEntity;
17
+ expirationDateTime?: string;
18
+ isLinked?: boolean;
19
+ }
20
+ export interface CreateConsentPayload {
21
+ data: CreateConsentData;
22
+ }
23
+ //# sourceMappingURL=createConsent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createConsent.d.ts","sourceRoot":"","sources":["../../../src/consent/interfaces/createConsent.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE;QACR,cAAc,EAAE,MAAM,CAAC;QACvB,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;CACH;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE;QACR,cAAc,EAAE,MAAM,CAAC;QACvB,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;CACH;AAED,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,UAAU,EAAE,UAAU,CAAC;IACvB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,iBAAiB,CAAC;CACzB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=createConsent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createConsent.js","sourceRoot":"","sources":["../../../src/consent/interfaces/createConsent.ts"],"names":[],"mappings":""}
@@ -0,0 +1,23 @@
1
+ export interface LoggedUserDocumentExtensions {
2
+ identification: string;
3
+ rel: string;
4
+ }
5
+ export interface LoggedUserExtensions {
6
+ document: LoggedUserDocumentExtensions;
7
+ }
8
+ export interface BusinessEntityDocumentExtensions {
9
+ identification: string;
10
+ rel: string;
11
+ }
12
+ export interface BusinessEntityExtensions {
13
+ document: BusinessEntityDocumentExtensions;
14
+ }
15
+ export interface CreateConsentExtensionsData {
16
+ expirationDateTime?: string;
17
+ loggedUser: LoggedUserExtensions;
18
+ businessEntity?: BusinessEntityExtensions;
19
+ }
20
+ export interface CreateConsentExtensionsPayload {
21
+ data: CreateConsentExtensionsData;
22
+ }
23
+ //# sourceMappingURL=createConsentExtensions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createConsentExtensions.d.ts","sourceRoot":"","sources":["../../../src/consent/interfaces/createConsentExtensions.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,4BAA4B;IAC3C,cAAc,EAAE,MAAM,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,4BAA4B,CAAC;CACxC;AAED,MAAM,WAAW,gCAAgC;IAC/C,cAAc,EAAE,MAAM,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,gCAAgC,CAAC;CAC5C;AAED,MAAM,WAAW,2BAA2B;IAC1C,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,UAAU,EAAE,oBAAoB,CAAC;IACjC,cAAc,CAAC,EAAE,wBAAwB,CAAC;CAC3C;AAED,MAAM,WAAW,8BAA8B;IAC7C,IAAI,EAAE,2BAA2B,CAAC;CACnC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=createConsentExtensions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createConsentExtensions.js","sourceRoot":"","sources":["../../../src/consent/interfaces/createConsentExtensions.ts"],"names":[],"mappings":""}
@@ -86,4 +86,4 @@ export interface CreateConsentExtensionsSuccessResponse {
86
86
  requestDateTime: string;
87
87
  };
88
88
  }
89
- //# sourceMappingURL=index.d.ts.map
89
+ //# sourceMappingURL=successResponses.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"successResponses.d.ts","sourceRoot":"","sources":["../../../src/consent/interfaces/successResponses.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE;QACJ,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;QACf,oBAAoB,EAAE,MAAM,CAAC;QAC7B,WAAW,EAAE,MAAM,EAAE,CAAC;QAC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MAAM,CAAC;QAC3B,UAAU,CAAC,EAAE;YACX,QAAQ,EAAE;gBACR,cAAc,EAAE,MAAM,CAAC;gBACvB,GAAG,EAAE,MAAM,CAAC;aACb,CAAC;SACH,CAAC;QACF,cAAc,CAAC,EAAE;YACf,QAAQ,EAAE;gBACR,cAAc,EAAE,MAAM,CAAC;gBACvB,GAAG,EAAE,MAAM,CAAC;aACb,CAAC;SACH,CAAC;KACH,CAAC;IACF,KAAK,CAAC,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,IAAI,CAAC,EAAE;QACL,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC;CACH"}
@@ -3,4 +3,4 @@
3
3
  * Interfaces de Sucesso para Respostas de Consent
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- //# sourceMappingURL=index.js.map
6
+ //# sourceMappingURL=successResponses.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"successResponses.js","sourceRoot":"","sources":["../../../src/consent/interfaces/successResponses.ts"],"names":[],"mappings":";AAAA;;GAEG"}
@@ -3,31 +3,9 @@
3
3
  * Segue as regras especificadas no Open Finance Brasil
4
4
  */
5
5
  import { ValidationResult } from "../../utils/openFinanceErrors";
6
- type LoggedUser = {
7
- document: {
8
- identification: string;
9
- rel: string;
10
- };
11
- };
12
- type BusinessEntity = {
13
- document: {
14
- identification: string;
15
- rel: string;
16
- };
17
- };
18
- type CreateConsentData = {
19
- permissions: string[];
20
- loggedUser: LoggedUser;
21
- businessEntity?: BusinessEntity;
22
- expirationDateTime?: string;
23
- isLinked?: boolean;
24
- };
25
- type CreateConsentPayload = {
26
- data: CreateConsentData;
27
- };
6
+ import { CreateConsentPayload } from "../interfaces/createConsent";
28
7
  /**
29
8
  * Valida o payload de criação de consentimento
30
9
  */
31
- export declare function validateCreateConsent(payload: any): ValidationResult;
32
- export { CreateConsentPayload, CreateConsentData };
10
+ export declare function validateCreateConsent(payload: CreateConsentPayload): ValidationResult;
33
11
  //# sourceMappingURL=createConsent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createConsent.d.ts","sourceRoot":"","sources":["../../../src/consent/validators/createConsent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEL,gBAAgB,EAIjB,MAAM,+BAA+B,CAAC;AAEvC,KAAK,UAAU,GAAG;IAChB,QAAQ,EAAE;QACR,cAAc,EAAE,MAAM,CAAC;QACvB,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;CACH,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,QAAQ,EAAE;QACR,cAAc,EAAE,MAAM,CAAC;QACvB,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;CACH,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,UAAU,EAAE,UAAU,CAAC;IACvB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,KAAK,oBAAoB,GAAG;IAC1B,IAAI,EAAE,iBAAiB,CAAC;CACzB,CAAC;AAyCF;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,GAAG,GAAG,gBAAgB,CAwDpE;AA0MD,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,CAAC"}
1
+ {"version":3,"file":"createConsent.d.ts","sourceRoot":"","sources":["../../../src/consent/validators/createConsent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEL,gBAAgB,EAGjB,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,oBAAoB,GAAG,gBAAgB,CA2DrF"}
@@ -6,44 +6,8 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.validateCreateConsent = validateCreateConsent;
8
8
  const openFinanceErrors_1 = require("../../utils/openFinanceErrors");
9
- const VALID_PERMISSIONS = [
10
- "ACCOUNTS_READ",
11
- "ACCOUNTS_BALANCES_READ",
12
- "ACCOUNTS_TRANSACTIONS_READ",
13
- "ACCOUNTS_OVERDRAFT_LIMITS_READ",
14
- "CREDIT_CARDS_ACCOUNTS_READ",
15
- "CREDIT_CARDS_ACCOUNTS_BILLS_READ",
16
- "CREDIT_CARDS_ACCOUNTS_BILLS_TRANSACTIONS_READ",
17
- "CREDIT_CARDS_ACCOUNTS_LIMITS_READ",
18
- "CREDIT_CARDS_ACCOUNTS_TRANSACTIONS_READ",
19
- "CUSTOMERS_PERSONAL_IDENTIFICATIONS_READ",
20
- "CUSTOMERS_PERSONAL_ADITTIONALINFO_READ",
21
- "CUSTOMERS_BUSINESS_IDENTIFICATIONS_READ",
22
- "CUSTOMERS_BUSINESS_ADITTIONALINFO_READ",
23
- "FINANCINGS_READ",
24
- "FINANCINGS_SCHEDULED_INSTALMENTS_READ",
25
- "FINANCINGS_PAYMENTS_READ",
26
- "FINANCINGS_WARRANTIES_READ",
27
- "INVOICE_FINANCINGS_READ",
28
- "INVOICE_FINANCINGS_SCHEDULED_INSTALMENTS_READ",
29
- "INVOICE_FINANCINGS_PAYMENTS_READ",
30
- "INVOICE_FINANCINGS_WARRANTIES_READ",
31
- "LOANS_READ",
32
- "LOANS_SCHEDULED_INSTALMENTS_READ",
33
- "LOANS_PAYMENTS_READ",
34
- "LOANS_WARRANTIES_READ",
35
- "UNARRANGED_ACCOUNTS_OVERDRAFT_READ",
36
- "UNARRANGED_ACCOUNTS_OVERDRAFT_SCHEDULED_INSTALMENTS_READ",
37
- "UNARRANGED_ACCOUNTS_OVERDRAFT_PAYMENTS_READ",
38
- "UNARRANGED_ACCOUNTS_OVERDRAFT_WARRANTIES_READ",
39
- "RESOURCES_READ",
40
- "BANK_FIXED_INCOMES_READ",
41
- "CREDIT_FIXED_INCOMES_READ",
42
- "FUNDS_READ",
43
- "VARIABLE_INCOMES_READ",
44
- "TREASURE_TITLES_READ",
45
- "EXCHANGES_READ",
46
- ];
9
+ const types_consent_1 = require("../../utils/types/types.consent");
10
+ const validationHelpers_1 = require("../../utils/validationHelpers");
47
11
  /**
48
12
  * Valida o payload de criação de consentimento
49
13
  */
@@ -63,28 +27,29 @@ function validateCreateConsent(payload) {
63
27
  const permissionErrors = validatePermissions(data.permissions);
64
28
  errors.push(...permissionErrors);
65
29
  }
66
- // Validação: loggedUser é obrigatório
67
- if (!data.loggedUser) {
68
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("loggedUser"));
30
+ // Validação: loggedUser ou businessEntity (pelo menos um obrigatório)
31
+ if (!data.loggedUser && !data.businessEntity) {
32
+ errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("loggedUser or businessEntity"));
69
33
  }
70
34
  else {
71
- const loggedUserErrors = validateLoggedUser(data.loggedUser);
72
- errors.push(...loggedUserErrors);
35
+ if (data.loggedUser) {
36
+ const loggedUserErrors = (0, validationHelpers_1.validateLoggedUser)(data.loggedUser);
37
+ errors.push(...loggedUserErrors);
38
+ }
39
+ if (data.businessEntity) {
40
+ const businessEntityErrors = (0, validationHelpers_1.validateBusinessEntity)(data.businessEntity);
41
+ errors.push(...businessEntityErrors);
42
+ }
73
43
  }
74
44
  // Validação: expirationDateTime (regulatory-required)
75
45
  if (data.expirationDateTime) {
76
- const expirationErrors = validateExpirationDateTime(data.expirationDateTime);
46
+ const expirationErrors = (0, validationHelpers_1.validateRfc3339DateTime)(data.expirationDateTime);
77
47
  errors.push(...expirationErrors);
78
48
  }
79
49
  // Validação: isLinked
80
50
  if (data.isLinked !== undefined && typeof data.isLinked !== "boolean") {
81
51
  errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("isLinked", "Deve ser um valor booleano"));
82
52
  }
83
- // Validação: businessEntity (opcional)
84
- if (data.businessEntity) {
85
- const businessEntityErrors = validateBusinessEntity(data.businessEntity);
86
- errors.push(...businessEntityErrors);
87
- }
88
53
  return {
89
54
  isValid: errors.length === 0,
90
55
  statusCode: (0, openFinanceErrors_1.getStatusCode)(errors),
@@ -110,97 +75,10 @@ function validatePermissions(permissions) {
110
75
  errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("permissions", "Array não deve ter duplicidade de itens"));
111
76
  }
112
77
  // Validar permissões conhecidas
113
- const invalidPermissions = permissions.filter((permission) => !VALID_PERMISSIONS.includes(permission));
78
+ const invalidPermissions = permissions.filter((permission) => !types_consent_1.VALID_PERMISSIONS.includes(permission));
114
79
  if (invalidPermissions.length > 0) {
115
80
  errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("permissions", `Permissões inválidas encontradas: ${invalidPermissions.join(", ")}`));
116
81
  }
117
82
  return errors;
118
83
  }
119
- /**
120
- * Valida LoggedUser
121
- */
122
- function validateLoggedUser(loggedUser) {
123
- const errors = [];
124
- if (typeof loggedUser !== "object" || loggedUser === null) {
125
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("loggedUser", "Deve ser um objeto"));
126
- return errors;
127
- }
128
- // document é obrigatório
129
- if (!loggedUser.document) {
130
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("loggedUser.document"));
131
- }
132
- else {
133
- const documentErrors = validateDocument(loggedUser.document);
134
- errors.push(...documentErrors);
135
- }
136
- return errors;
137
- }
138
- /**
139
- * Valida expirationDateTime
140
- * RFC-3339 format: YYYY-MM-DDTHH:mm:ssZ
141
- * maxLength: 20
142
- */
143
- function validateExpirationDateTime(expirationDateTime) {
144
- const errors = [];
145
- if (typeof expirationDateTime !== "string") {
146
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("expirationDateTime", "Deve ser uma string em formato RFC-3339"));
147
- return errors;
148
- }
149
- if (expirationDateTime.length > 20) {
150
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("expirationDateTime", "Deve ter no máximo 20 caracteres"));
151
- }
152
- // Validar formato RFC-3339 (UTC)
153
- const rfc3339Pattern = /^(\d{4})-(1[0-2]|0?[1-9])-(3[01]|[12][0-9]|0?[1-9])T(?:[01]\d|2[0123]):(?:[012345]\d):(?:[012345]\d)Z$/;
154
- if (!rfc3339Pattern.test(expirationDateTime)) {
155
- errors.push((0, openFinanceErrors_1.createError)("DATA_EXPIRACAO_INVALIDA", "Nova data para expiração do consentimento é inválida.", "A data de expiração deve estar no formato RFC-3339 com timezone UTC (YYYY-MM-DDTHH:mm:ssZ)"));
156
- }
157
- return errors;
158
- }
159
- /**
160
- * Valida BusinessEntity
161
- */
162
- function validateBusinessEntity(businessEntity) {
163
- const errors = [];
164
- if (typeof businessEntity !== "object" || businessEntity === null) {
165
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("businessEntity", "Deve ser um objeto"));
166
- return errors;
167
- }
168
- if (!businessEntity.document) {
169
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("businessEntity.document"));
170
- }
171
- else {
172
- const documentErrors = validateDocument(businessEntity.document);
173
- errors.push(...documentErrors);
174
- }
175
- return errors;
176
- }
177
- /**
178
- * Valida Document
179
- */
180
- function validateDocument(document) {
181
- const errors = [];
182
- if (typeof document !== "object" || document === null) {
183
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("document", "Deve ser um objeto"));
184
- return errors;
185
- }
186
- if (!document.identification) {
187
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("document.identification"));
188
- }
189
- else if (typeof document.identification !== "string") {
190
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("document.identification", "Deve ser uma string"));
191
- }
192
- else if (!/^(\d{11}|\d{14})$/.test(document.identification)) {
193
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("document.identification", "Deve conter exatamente 11 dígitos (CPF) ou 14 dígitos (CNPJ)"));
194
- }
195
- if (!document.rel) {
196
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("document.rel"));
197
- }
198
- else if (typeof document.rel !== "string") {
199
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("document.rel", "Deve ser uma string"));
200
- }
201
- else if (!/^[A-Z]{3,4}$/.test(document.rel)) {
202
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("document.rel", "Deve conter entre 3 e 4 letras maiúsculas (exemplo: CPF ou CNPJ)"));
203
- }
204
- return errors;
205
- }
206
84
  //# sourceMappingURL=createConsent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createConsent.js","sourceRoot":"","sources":["../../../src/consent/validators/createConsent.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AA8EH,sDAwDC;AApID,qEAMuC;AA4BvC,MAAM,iBAAiB,GAAG;IACxB,eAAe;IACf,wBAAwB;IACxB,4BAA4B;IAC5B,gCAAgC;IAChC,4BAA4B;IAC5B,kCAAkC;IAClC,+CAA+C;IAC/C,mCAAmC;IACnC,yCAAyC;IACzC,yCAAyC;IACzC,wCAAwC;IACxC,yCAAyC;IACzC,wCAAwC;IACxC,iBAAiB;IACjB,uCAAuC;IACvC,0BAA0B;IAC1B,4BAA4B;IAC5B,yBAAyB;IACzB,+CAA+C;IAC/C,kCAAkC;IAClC,oCAAoC;IACpC,YAAY;IACZ,kCAAkC;IAClC,qBAAqB;IACrB,uBAAuB;IACvB,oCAAoC;IACpC,0DAA0D;IAC1D,6CAA6C;IAC7C,+CAA+C;IAC/C,gBAAgB;IAChB,yBAAyB;IACzB,2BAA2B;IAC3B,YAAY;IACZ,uBAAuB;IACvB,sBAAsB;IACtB,gBAAgB;CACjB,CAAC;AAEF;;GAEG;AACH,SAAgB,qBAAqB,CAAC,OAAY;IAChD,MAAM,MAAM,GAAkB,EAAE,CAAC;IAEjC,+BAA+B;IAC/B,IAAI,CAA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/C,IAAI,iBAAiB,CAAC,IAAI,KAAK,WAAW,CAAC,MAAM,EAAE,CAAC;QAClD,MAAM,CAAC,IAAI,CACT,gCAAY,CAAC,kBAAkB,CAC7B,aAAa,EACb,yCAAyC,CAC1C,CACF,CAAC;IACJ,CAAC;IAED,gCAAgC;IAChC,MAAM,kBAAkB,GAAG,WAAW,CAAC,MAAM,CAC3C,CAAC,UAAkB,EAAE,EAAE,CAAC,CAAC,iCAAiB,CAAC,QAAQ,CAAC,UAAU,CAAC,CAChE,CAAC;IACF,IAAI,kBAAkB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClC,MAAM,CAAC,IAAI,CACT,gCAAY,CAAC,kBAAkB,CAC7B,aAAa,EACb,qCAAqC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACrE,CACF,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -3,31 +3,9 @@
3
3
  * Segue as regras especificadas no Open Finance Brasil para renovação de consentimento
4
4
  */
5
5
  import { ValidationResult } from "../../utils/openFinanceErrors";
6
- interface LoggedUserDocumentExtensions {
7
- identification: string;
8
- rel: string;
9
- }
10
- interface LoggedUserExtensions {
11
- document: LoggedUserDocumentExtensions;
12
- }
13
- interface BusinessEntityDocumentExtensions {
14
- identification: string;
15
- rel: string;
16
- }
17
- interface BusinessEntityExtensions {
18
- document: BusinessEntityDocumentExtensions;
19
- }
20
- interface CreateConsentExtensionsData {
21
- expirationDateTime?: string;
22
- loggedUser: LoggedUserExtensions;
23
- businessEntity?: BusinessEntityExtensions;
24
- }
25
- interface CreateConsentExtensionsPayload {
26
- data: CreateConsentExtensionsData;
27
- }
6
+ import { CreateConsentExtensionsPayload } from "../interfaces/createConsentExtensions";
28
7
  /**
29
8
  * Valida o payload de renovação de consentimento
30
9
  */
31
- export declare function validateCreateConsentExtensions(payload: any): ValidationResult;
32
- export { CreateConsentExtensionsPayload, CreateConsentExtensionsData, LoggedUserExtensions, BusinessEntityExtensions, };
10
+ export declare function validateCreateConsentExtensions(payload: CreateConsentExtensionsPayload): ValidationResult;
33
11
  //# sourceMappingURL=createConsentExtensions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createConsentExtensions.d.ts","sourceRoot":"","sources":["../../../src/consent/validators/createConsentExtensions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEL,gBAAgB,EAIjB,MAAM,+BAA+B,CAAC;AAEvC,UAAU,4BAA4B;IACpC,cAAc,EAAE,MAAM,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,UAAU,oBAAoB;IAC5B,QAAQ,EAAE,4BAA4B,CAAC;CACxC;AAED,UAAU,gCAAgC;IACxC,cAAc,EAAE,MAAM,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,UAAU,wBAAwB;IAChC,QAAQ,EAAE,gCAAgC,CAAC;CAC5C;AAED,UAAU,2BAA2B;IACnC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,UAAU,EAAE,oBAAoB,CAAC;IACjC,cAAc,CAAC,EAAE,wBAAwB,CAAC;CAC3C;AAED,UAAU,8BAA8B;IACtC,IAAI,EAAE,2BAA2B,CAAC;CACnC;AAED;;GAEG;AACH,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,GAAG,GAAG,gBAAgB,CAwC9E;AA0RD,OAAO,EACL,8BAA8B,EAC9B,2BAA2B,EAC3B,oBAAoB,EACpB,wBAAwB,GACzB,CAAC"}
1
+ {"version":3,"file":"createConsentExtensions.d.ts","sourceRoot":"","sources":["../../../src/consent/validators/createConsentExtensions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEL,gBAAgB,EAGjB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,8BAA8B,EAAE,MAAM,uCAAuC,CAAC;AAGvF;;GAEG;AACH,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,8BAA8B,GAAG,gBAAgB,CAyCzG"}
@@ -6,6 +6,7 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.validateCreateConsentExtensions = validateCreateConsentExtensions;
8
8
  const openFinanceErrors_1 = require("../../utils/openFinanceErrors");
9
+ const validationHelpers_1 = require("../../utils/validationHelpers");
9
10
  /**
10
11
  * Valida o payload de renovação de consentimento
11
12
  */
@@ -17,23 +18,24 @@ function validateCreateConsentExtensions(payload) {
17
18
  return { isValid: false, statusCode: (0, openFinanceErrors_1.getStatusCode)(errors), errors };
18
19
  }
19
20
  const data = payload.data;
20
- // Validação: loggedUser é obrigatório
21
- if (!data.loggedUser) {
22
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("loggedUser"));
21
+ // Validação: loggedUser ou businessEntity (pelo menos um obrigatório)
22
+ if (!data.loggedUser && !data.businessEntity) {
23
+ errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("loggedUser or businessEntity"));
23
24
  }
24
25
  else {
25
- const loggedUserErrors = validateLoggedUserExtensions(data.loggedUser);
26
- errors.push(...loggedUserErrors);
27
- }
28
- // Validação: expirationDateTime (opcional)
29
- if (data.expirationDateTime) {
30
- const expirationErrors = validateExpirationDateTime(data.expirationDateTime);
31
- errors.push(...expirationErrors);
32
- }
33
- // Validação: businessEntity (opcional)
34
- if (data.businessEntity) {
35
- const businessEntityErrors = validateBusinessEntityExtensions(data.businessEntity);
36
- errors.push(...businessEntityErrors);
26
+ if (data.loggedUser) {
27
+ const loggedUserErrors = (0, validationHelpers_1.validateLoggedUser)(data.loggedUser);
28
+ errors.push(...loggedUserErrors);
29
+ }
30
+ // Validação: expirationDateTime (opcional)
31
+ if (data.expirationDateTime) {
32
+ const expirationErrors = (0, validationHelpers_1.validateRfc3339DateTime)(data.expirationDateTime);
33
+ errors.push(...expirationErrors);
34
+ }
35
+ if (data.businessEntity) {
36
+ const businessEntityErrors = (0, validationHelpers_1.validateBusinessEntity)(data.businessEntity);
37
+ errors.push(...businessEntityErrors);
38
+ }
37
39
  }
38
40
  return {
39
41
  isValid: errors.length === 0,
@@ -41,154 +43,4 @@ function validateCreateConsentExtensions(payload) {
41
43
  errors,
42
44
  };
43
45
  }
44
- /**
45
- * Valida LoggedUserExtensions
46
- * Estrutura alterada: usa 'document' em vez de 'documentType' e 'documentNumber'
47
- */
48
- function validateLoggedUserExtensions(loggedUser) {
49
- const errors = [];
50
- if (typeof loggedUser !== "object" || loggedUser === null) {
51
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("loggedUser", "Deve ser um objeto"));
52
- return errors;
53
- }
54
- // document é obrigatório
55
- if (!loggedUser.document) {
56
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("loggedUser.document"));
57
- }
58
- else {
59
- const documentErrors = validateLoggedUserDocumentExtensions(loggedUser.document);
60
- errors.push(...documentErrors);
61
- }
62
- return errors;
63
- }
64
- /**
65
- * Valida LoggedUserDocumentExtensions
66
- */
67
- function validateLoggedUserDocumentExtensions(document) {
68
- const errors = [];
69
- if (typeof document !== "object" || document === null) {
70
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("loggedUser.document", "Deve ser um objeto"));
71
- return errors;
72
- }
73
- // identification é obrigatório
74
- if (!document.identification) {
75
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("loggedUser.document.identification"));
76
- }
77
- else if (typeof document.identification !== "string") {
78
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("loggedUser.document.identification", "Deve ser uma string"));
79
- }
80
- else {
81
- // Validar maxLength: 11
82
- if (document.identification.length > 11) {
83
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("loggedUser.document.identification", "Deve ter no máximo 11 caracteres"));
84
- }
85
- // Validar padrão: ^\d{11}$ (apenas dígitos)
86
- if (!/^\d{11}$/.test(document.identification)) {
87
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("loggedUser.document.identification", "Deve conter apenas 11 dígitos"));
88
- }
89
- }
90
- // rel é obrigatório
91
- if (!document.rel) {
92
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("loggedUser.document.rel"));
93
- }
94
- else if (typeof document.rel !== "string") {
95
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("loggedUser.document.rel", "Deve ser uma string"));
96
- }
97
- else {
98
- // Validar maxLength: 3
99
- if (document.rel.length > 3) {
100
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("loggedUser.document.rel", "Deve ter no máximo 3 caracteres"));
101
- }
102
- // Validar padrão: ^[A-Z]{3}$ (3 letras maiúsculas)
103
- if (!/^[A-Z]{3}$/.test(document.rel)) {
104
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("loggedUser.document.rel", "Deve conter 3 letras maiúsculas (ex: CPF)"));
105
- }
106
- }
107
- return errors;
108
- }
109
- /**
110
- * Valida expirationDateTime
111
- * RFC-3339 format: YYYY-MM-DDTHH:mm:ssZ
112
- * maxLength: 20
113
- */
114
- function validateExpirationDateTime(expirationDateTime) {
115
- const errors = [];
116
- if (typeof expirationDateTime !== "string") {
117
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("expirationDateTime", "Deve ser uma string em formato RFC-3339"));
118
- return errors;
119
- }
120
- if (expirationDateTime.length > 20) {
121
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("expirationDateTime", "Deve ter no máximo 20 caracteres"));
122
- }
123
- // Validar formato RFC-3339 (UTC)
124
- const rfc3339Pattern = /^(\d{4})-(1[0-2]|0?[1-9])-(3[01]|[12][0-9]|0?[1-9])T(?:[01]\d|2[0123]):(?:[012345]\d):(?:[012345]\d)Z$/;
125
- if (!rfc3339Pattern.test(expirationDateTime)) {
126
- errors.push((0, openFinanceErrors_1.createError)("DATA_EXPIRACAO_INVALIDA", "Nova data para expiração do consentimento é inválida.", "A data de expiração deve estar no formato RFC-3339 com timezone UTC (YYYY-MM-DDTHH:mm:ssZ)"));
127
- }
128
- return errors;
129
- }
130
- /**
131
- * Valida BusinessEntityExtensions
132
- */
133
- function validateBusinessEntityExtensions(businessEntity) {
134
- const errors = [];
135
- if (typeof businessEntity !== "object" || businessEntity === null) {
136
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("businessEntity", "Deve ser um objeto"));
137
- return errors;
138
- }
139
- if (!businessEntity.document) {
140
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("businessEntity.document"));
141
- }
142
- else {
143
- const documentErrors = validateBusinessEntityDocumentExtensions(businessEntity.document);
144
- errors.push(...documentErrors);
145
- }
146
- return errors;
147
- }
148
- /**
149
- * Valida BusinessEntityDocumentExtensions
150
- * Formato esperado para CNPJ: ^[0-9A-Z]{12}[0-9]{2}$
151
- */
152
- function validateBusinessEntityDocumentExtensions(document) {
153
- const errors = [];
154
- if (typeof document !== "object" || document === null) {
155
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("businessEntity.document", "Deve ser um objeto"));
156
- return errors;
157
- }
158
- // identification é obrigatório
159
- if (!document.identification) {
160
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("businessEntity.document.identification"));
161
- }
162
- else if (typeof document.identification !== "string") {
163
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("businessEntity.document.identification", "Deve ser uma string"));
164
- }
165
- else {
166
- // Validar maxLength: 14
167
- if (document.identification.length > 14) {
168
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("businessEntity.document.identification", "Deve ter no máximo 14 caracteres"));
169
- }
170
- // Validar padrão: ^[0-9A-Z]{12}[0-9]{2}$
171
- if (!/^[0-9A-Z]{12}[0-9]{2}$/.test(document.identification)) {
172
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("businessEntity.document.identification", "Deve estar no formato CNPJ válido"));
173
- }
174
- }
175
- // rel é obrigatório
176
- if (!document.rel) {
177
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("businessEntity.document.rel"));
178
- }
179
- else if (typeof document.rel !== "string") {
180
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("businessEntity.document.rel", "Deve ser uma string"));
181
- }
182
- else {
183
- // Validar maxLength: 4
184
- if (document.rel.length > 4) {
185
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("businessEntity.document.rel", "Deve ter no máximo 4 caracteres"));
186
- }
187
- // Validar padrão: ^[A-Z]{4}$ (4 letras maiúsculas)
188
- if (!/^[A-Z]{4}$/.test(document.rel)) {
189
- errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("businessEntity.document.rel", "Deve conter 4 letras maiúsculas (ex: CNPJ)"));
190
- }
191
- }
192
- return errors;
193
- }
194
46
  //# sourceMappingURL=createConsentExtensions.js.map