@infrab4a/connect 4.25.0-beta.3 → 4.25.0-beta.4

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.
package/index.cjs.js CHANGED
@@ -11,33 +11,14 @@ var debug = require('debug');
11
11
  var tsCustomError = require('ts-custom-error');
12
12
  var axios = require('axios');
13
13
  var auth = require('firebase/auth');
14
- var crypto = require('crypto');
14
+ var tsMd5 = require('ts-md5');
15
15
  var firestore = require('firebase/firestore');
16
16
  var storage = require('firebase/storage');
17
17
  var gqlQueryBuilder = require('gql-query-builder');
18
18
 
19
19
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
20
20
 
21
- function _interopNamespace(e) {
22
- if (e && e.__esModule) return e;
23
- var n = Object.create(null);
24
- if (e) {
25
- Object.keys(e).forEach(function (k) {
26
- if (k !== 'default') {
27
- var d = Object.getOwnPropertyDescriptor(e, k);
28
- Object.defineProperty(n, k, d.get ? d : {
29
- enumerable: true,
30
- get: function () { return e[k]; }
31
- });
32
- }
33
- });
34
- }
35
- n["default"] = e;
36
- return Object.freeze(n);
37
- }
38
-
39
21
  var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
40
- var crypto__namespace = /*#__PURE__*/_interopNamespace(crypto);
41
22
 
42
23
  exports.AntifraudProviders = void 0;
43
24
  (function (AntifraudProviders) {
@@ -3591,46 +3572,28 @@ GraphQLFieldHelper.ConvertNestedFieldsToGraphQLFields = (fieldName, fieldValue)
3591
3572
  };
3592
3573
 
3593
3574
  class MD5GeneratorHelper {
3594
- /**
3595
- * Gera um hash MD5 para um objeto de qualquer estrutura
3596
- * Garante que o mesmo objeto sempre gerará o mesmo hash, independentemente da ordem das chaves
3597
- */
3598
3575
  static generateMD5(data) {
3599
- // Null ou undefined geram um hash fixo
3600
- if (data === null || data === undefined) {
3601
- return crypto__namespace.createHash('md5').update('null').digest('hex');
3602
- }
3576
+ if (data === null || data === undefined)
3577
+ return tsMd5.Md5.hashStr('null');
3603
3578
  const normalizedData = this.normalizeData(data);
3604
3579
  const jsonString = JSON.stringify(normalizedData);
3605
- return crypto__namespace.createHash('md5').update(jsonString).digest('hex');
3580
+ return tsMd5.Md5.hashStr(jsonString);
3606
3581
  }
3607
- /**
3608
- * Normaliza os dados para garantir que a ordem das chaves não afete o resultado
3609
- */
3610
3582
  static normalizeData(data, depth = 0, maxDepth = 100) {
3611
- // Proteção contra recursão infinita
3612
- if (depth > maxDepth) {
3583
+ if (depth > maxDepth)
3613
3584
  return '[MAX_DEPTH_REACHED]';
3614
- }
3615
- // Tipos primitivos retornam diretamente
3616
- if (data === null || data === undefined) {
3585
+ if (data === null || data === undefined)
3617
3586
  return null;
3618
- }
3619
- if (typeof data !== 'object') {
3587
+ if (typeof data !== 'object')
3620
3588
  return data;
3621
- }
3622
- // Arrays são normalizados e ordenados
3623
- if (Array.isArray(data)) {
3589
+ if (Array.isArray(data))
3624
3590
  return data
3625
3591
  .map((item) => this.normalizeData(item, depth + 1, maxDepth))
3626
3592
  .sort((a, b) => {
3627
- // Converte para string para comparação determinística
3628
3593
  const strA = typeof a === 'object' && a !== null ? JSON.stringify(a) : String(a);
3629
3594
  const strB = typeof b === 'object' && b !== null ? JSON.stringify(b) : String(b);
3630
3595
  return strA.localeCompare(strB);
3631
3596
  });
3632
- }
3633
- // Objetos: ordena as chaves
3634
3597
  const sortedObj = {};
3635
3598
  const keys = Object.keys(data).sort();
3636
3599
  keys.forEach((key) => {
package/index.esm.js CHANGED
@@ -9,7 +9,7 @@ import { debug } from 'debug';
9
9
  import { CustomError } from 'ts-custom-error';
10
10
  import axios, { AxiosError } from 'axios';
11
11
  import { signInWithEmailAndPassword, signInWithPopup, GoogleAuthProvider, signInAnonymously, sendPasswordResetEmail, createUserWithEmailAndPassword, sendEmailVerification } from 'firebase/auth';
12
- import * as crypto from 'crypto';
12
+ import { Md5 } from 'ts-md5';
13
13
  import { deleteField, arrayUnion, arrayRemove, Timestamp, doc, getDoc, updateDoc, setDoc, deleteDoc, collection, limit, getDocs, query, where, orderBy, startAfter, addDoc } from 'firebase/firestore';
14
14
  import { ref, uploadBytes } from 'firebase/storage';
15
15
  import { mutation, query as query$1 } from 'gql-query-builder';
@@ -3566,46 +3566,28 @@ GraphQLFieldHelper.ConvertNestedFieldsToGraphQLFields = (fieldName, fieldValue)
3566
3566
  };
3567
3567
 
3568
3568
  class MD5GeneratorHelper {
3569
- /**
3570
- * Gera um hash MD5 para um objeto de qualquer estrutura
3571
- * Garante que o mesmo objeto sempre gerará o mesmo hash, independentemente da ordem das chaves
3572
- */
3573
3569
  static generateMD5(data) {
3574
- // Null ou undefined geram um hash fixo
3575
- if (data === null || data === undefined) {
3576
- return crypto.createHash('md5').update('null').digest('hex');
3577
- }
3570
+ if (data === null || data === undefined)
3571
+ return Md5.hashStr('null');
3578
3572
  const normalizedData = this.normalizeData(data);
3579
3573
  const jsonString = JSON.stringify(normalizedData);
3580
- return crypto.createHash('md5').update(jsonString).digest('hex');
3574
+ return Md5.hashStr(jsonString);
3581
3575
  }
3582
- /**
3583
- * Normaliza os dados para garantir que a ordem das chaves não afete o resultado
3584
- */
3585
3576
  static normalizeData(data, depth = 0, maxDepth = 100) {
3586
- // Proteção contra recursão infinita
3587
- if (depth > maxDepth) {
3577
+ if (depth > maxDepth)
3588
3578
  return '[MAX_DEPTH_REACHED]';
3589
- }
3590
- // Tipos primitivos retornam diretamente
3591
- if (data === null || data === undefined) {
3579
+ if (data === null || data === undefined)
3592
3580
  return null;
3593
- }
3594
- if (typeof data !== 'object') {
3581
+ if (typeof data !== 'object')
3595
3582
  return data;
3596
- }
3597
- // Arrays são normalizados e ordenados
3598
- if (Array.isArray(data)) {
3583
+ if (Array.isArray(data))
3599
3584
  return data
3600
3585
  .map((item) => this.normalizeData(item, depth + 1, maxDepth))
3601
3586
  .sort((a, b) => {
3602
- // Converte para string para comparação determinística
3603
3587
  const strA = typeof a === 'object' && a !== null ? JSON.stringify(a) : String(a);
3604
3588
  const strB = typeof b === 'object' && b !== null ? JSON.stringify(b) : String(b);
3605
3589
  return strA.localeCompare(strB);
3606
3590
  });
3607
- }
3608
- // Objetos: ordena as chaves
3609
3591
  const sortedObj = {};
3610
3592
  const keys = Object.keys(data).sort();
3611
3593
  keys.forEach((key) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "4.25.0-beta.3",
3
+ "version": "4.25.0-beta.4",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -1,11 +1,4 @@
1
1
  export declare class MD5GeneratorHelper {
2
- /**
3
- * Gera um hash MD5 para um objeto de qualquer estrutura
4
- * Garante que o mesmo objeto sempre gerará o mesmo hash, independentemente da ordem das chaves
5
- */
6
2
  static generateMD5(data: any): string;
7
- /**
8
- * Normaliza os dados para garantir que a ordem das chaves não afete o resultado
9
- */
10
3
  private static normalizeData;
11
4
  }