pix-utils-js 1.0.7 → 1.0.8
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/.github/workflows/test.yml +25 -25
- package/README.md +71 -73
- package/index.d.ts +26 -26
- package/index.js +70 -70
- package/package.json +23 -23
- package/tests/generator.js +106 -106
- package/tests/index.js +109 -109
- package/utils/validator.js +37 -34
- package/yarn-error.log +0 -59
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
name: Node.js CI
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: [ "main" ]
|
|
6
|
-
pull_request:
|
|
7
|
-
branches: [ "main" ]
|
|
8
|
-
|
|
9
|
-
jobs:
|
|
10
|
-
build:
|
|
11
|
-
|
|
12
|
-
runs-on: ubuntu-latest
|
|
13
|
-
|
|
14
|
-
strategy:
|
|
15
|
-
matrix:
|
|
16
|
-
node-version: [18.x]
|
|
17
|
-
|
|
18
|
-
steps:
|
|
19
|
-
- uses: actions/checkout@v3
|
|
20
|
-
- name: Use Node.js ${{ matrix.node-version }}
|
|
21
|
-
uses: actions/setup-node@v3
|
|
22
|
-
with:
|
|
23
|
-
node-version: ${{ matrix.node-version }}
|
|
24
|
-
- run: yarn
|
|
25
|
-
- run: yarn test
|
|
1
|
+
name: Node.js CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ "main" ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ "main" ]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
build:
|
|
11
|
+
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
|
|
14
|
+
strategy:
|
|
15
|
+
matrix:
|
|
16
|
+
node-version: [18.x]
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v3
|
|
20
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
21
|
+
uses: actions/setup-node@v3
|
|
22
|
+
with:
|
|
23
|
+
node-version: ${{ matrix.node-version }}
|
|
24
|
+
- run: yarn
|
|
25
|
+
- run: yarn test
|
package/README.md
CHANGED
|
@@ -1,73 +1,71 @@
|
|
|
1
|
-
|
|
2
|
-
# 💸 pix-utils-js
|
|
3
|
-
|
|
4
|
-

|
|
5
|
-

|
|
6
|
-

|
|
7
|
-

|
|
8
|
-
|
|
9
|
-
Uma pequena biblioteca que irá te ajudar a lidar com chaves pix
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
console.log(validate({pix: 'test@gmail.com'})) //
|
|
41
|
-
console.log(validate({pix: '
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
console.log(normalize({pix: '
|
|
55
|
-
console.log(normalize({pix: '
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
```
|
|
73
|
-
|
|
1
|
+
|
|
2
|
+
# 💸 pix-utils-js
|
|
3
|
+
|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
Uma pequena biblioteca que irá te ajudar a lidar com chaves pix
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
## Instalação
|
|
13
|
+
|
|
14
|
+
Instale pix-utils-js com npm ou yarn
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install pix-utils-js
|
|
18
|
+
yarn add pix-utils-js
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Documentação
|
|
22
|
+
|
|
23
|
+
#### Identifique uma chave pix
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
import { identify } from 'pix-utils-js'
|
|
27
|
+
const { pix, type } = identify({pix: 'test@gmail.com'}) // {pix: 'test@gmail.com', type: 'email'}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
| Função | Parametro | Retorno |
|
|
31
|
+
| :---------- | :--------- | :---------------------------------- |
|
|
32
|
+
| `identify` | `input: {pix: string}` | Pix `{ pix: string, type: 'email' \| 'cpf' \| 'cnpj' \| 'random' \|'phone' \| 'qrcode' }` |
|
|
33
|
+
|
|
34
|
+
#### Validar uma chave pix
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
import { validate } from 'pix-utils-js'
|
|
38
|
+
console.log(validate({pix: 'test@gmail.com'})) // true
|
|
39
|
+
console.log(validate({pix: 'test'})) // false
|
|
40
|
+
console.log(validate({pix: 'test@gmail.com', type : 'cpf'})) // false
|
|
41
|
+
console.log(validate({pix: '00020126360014BR.GOV...', type : 'qrcode'})) // true
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
| Função | Parametro | Retorno |
|
|
45
|
+
| :---------- | :--------- | :---------------------------------- |
|
|
46
|
+
| `validate` | `input: {pix: string}` | boolean |
|
|
47
|
+
|
|
48
|
+
#### Normalizar uma chave pix
|
|
49
|
+
|
|
50
|
+
```js
|
|
51
|
+
import { normalize } from 'pix-utils-js'
|
|
52
|
+
console.log(normalize({pix: '000.000.000-00'})) // {pix: '00000000000', type: 'cpf'}
|
|
53
|
+
console.log(normalize({pix: '00.000.000/0000-00'})) // {pix: '00000000000000', type: 'cnpj'}
|
|
54
|
+
console.log(normalize({pix: '(11) 98888-8888'})) // {pix: '11988888888', type: 'phone'}
|
|
55
|
+
console.log(normalize({pix: '00020126360014BR.GOV...'})) // {pix: '00020126360014BR.GOV...', type: 'qrcode'}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
| Função | Parametro | Retorno |
|
|
59
|
+
| :---------- | :--------- | :---------------------------------- |
|
|
60
|
+
| `normalize` | `input: {pix: string}` | Pix `{ pix: string, type: 'email' \| 'cpf' \| 'cnpj' \| 'random' \|'phone' \| 'qrcode' }` |
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
## Rodando os testes
|
|
65
|
+
|
|
66
|
+
Para rodar os testes, rode o seguinte comando
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npm run test
|
|
70
|
+
```
|
|
71
|
+
|
package/index.d.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
export type PixType = "email" | "cpf" | "cnpj" | "random" | "phone" | "qrcode"
|
|
2
|
-
|
|
3
|
-
export interface InvalidPix extends Error {
|
|
4
|
-
message: "chave pix invalida."
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export type Pix = {
|
|
8
|
-
type: PixType,
|
|
9
|
-
pix: string,
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface IdentifyDto {
|
|
13
|
-
pix: string
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface NormalizeDto {
|
|
17
|
-
pix: string
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface ValidateDto {
|
|
21
|
-
type?: PixType,
|
|
22
|
-
pix: string
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function identify(input: IdentifyDto): Pix | InvalidPix
|
|
26
|
-
export function normalize(input: NormalizeDto): Pix | InvalidPix
|
|
1
|
+
export type PixType = "email" | "cpf" | "cnpj" | "random" | "phone" | "qrcode"
|
|
2
|
+
|
|
3
|
+
export interface InvalidPix extends Error {
|
|
4
|
+
message: "chave pix invalida."
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export type Pix = {
|
|
8
|
+
type: PixType,
|
|
9
|
+
pix: string,
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface IdentifyDto {
|
|
13
|
+
pix: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface NormalizeDto {
|
|
17
|
+
pix: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface ValidateDto {
|
|
21
|
+
type?: PixType,
|
|
22
|
+
pix: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function identify(input: IdentifyDto): Pix | InvalidPix
|
|
26
|
+
export function normalize(input: NormalizeDto): Pix | InvalidPix
|
|
27
27
|
export function validate(input: ValidateDto): Boolean | InvalidPix
|
package/index.js
CHANGED
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
const { Validator } = require('./utils/validator')
|
|
2
|
-
|
|
3
|
-
const validator = new Validator();
|
|
4
|
-
|
|
5
|
-
const validationPixMap = {
|
|
6
|
-
email: validator.isEmail,
|
|
7
|
-
random: validator.isUUID,
|
|
8
|
-
phone: validator.isPhoneNumber,
|
|
9
|
-
cnpj: validator.isCNPJ,
|
|
10
|
-
cpf: validator.isCPF,
|
|
11
|
-
qrcode: validator.isQRCode
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const validate = (input) => {
|
|
16
|
-
const { pix } = input
|
|
17
|
-
let { type } = input
|
|
18
|
-
|
|
19
|
-
if(!pix) {
|
|
20
|
-
throw new Error("chave pix invalida.")
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if(!type) {
|
|
24
|
-
try {
|
|
25
|
-
let identifiedPix = identify({ pix })
|
|
26
|
-
type = identifiedPix.type
|
|
27
|
-
}catch {
|
|
28
|
-
return false
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return validationPixMap[type](pix)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const identify = (input) => {
|
|
36
|
-
const { pix } = input
|
|
37
|
-
|
|
38
|
-
if(!pix) {
|
|
39
|
-
throw new Error("chave pix invalida.")
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
for (const type in validationPixMap) {
|
|
43
|
-
if (validationPixMap[type](pix)) {
|
|
44
|
-
return { type, pix };
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
throw new Error("chave pix invalida.")
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const normalize = (input) => {
|
|
52
|
-
let { pix } = input
|
|
53
|
-
|
|
54
|
-
if(!pix || !validate({ pix})) {
|
|
55
|
-
throw new Error("chave pix invalida.")
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const { type } = identify({ pix })
|
|
59
|
-
|
|
60
|
-
if(type === 'cpf' || type === 'cnpj' || type === 'phone') {
|
|
61
|
-
pix = pix.replace(/[^0-9]/g, '')
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return { pix, type }
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
module.exports = {
|
|
68
|
-
identify,
|
|
69
|
-
validate,
|
|
70
|
-
normalize
|
|
1
|
+
const { Validator } = require('./utils/validator')
|
|
2
|
+
|
|
3
|
+
const validator = new Validator();
|
|
4
|
+
|
|
5
|
+
const validationPixMap = {
|
|
6
|
+
email: validator.isEmail,
|
|
7
|
+
random: validator.isUUID,
|
|
8
|
+
phone: validator.isPhoneNumber,
|
|
9
|
+
cnpj: validator.isCNPJ,
|
|
10
|
+
cpf: validator.isCPF,
|
|
11
|
+
qrcode: validator.isQRCode
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
const validate = (input) => {
|
|
16
|
+
const { pix } = input
|
|
17
|
+
let { type } = input
|
|
18
|
+
|
|
19
|
+
if(!pix) {
|
|
20
|
+
throw new Error("chave pix invalida.")
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if(!type) {
|
|
24
|
+
try {
|
|
25
|
+
let identifiedPix = identify({ pix })
|
|
26
|
+
type = identifiedPix.type
|
|
27
|
+
}catch {
|
|
28
|
+
return false
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return validationPixMap[type](pix)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const identify = (input) => {
|
|
36
|
+
const { pix } = input
|
|
37
|
+
|
|
38
|
+
if(!pix) {
|
|
39
|
+
throw new Error("chave pix invalida.")
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
for (const type in validationPixMap) {
|
|
43
|
+
if (validationPixMap[type](pix)) {
|
|
44
|
+
return { type, pix };
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
throw new Error("chave pix invalida.")
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const normalize = (input) => {
|
|
52
|
+
let { pix } = input
|
|
53
|
+
|
|
54
|
+
if(!pix || !validate({ pix})) {
|
|
55
|
+
throw new Error("chave pix invalida.")
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const { type } = identify({ pix })
|
|
59
|
+
|
|
60
|
+
if(type === 'cpf' || type === 'cnpj' || type === 'phone') {
|
|
61
|
+
pix = pix.replace(/[^0-9]/g, '')
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return { pix, type }
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
module.exports = {
|
|
68
|
+
identify,
|
|
69
|
+
validate,
|
|
70
|
+
normalize
|
|
71
71
|
}
|
package/package.json
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "pix-utils-js",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"author": "Paulo Henrique",
|
|
5
|
-
"description": "Um pacote para fornecer utilidades e validações para chaves pix.",
|
|
6
|
-
"main": "index.js",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "https://github.com/paulohenriquesn/pix-utils-js.git"
|
|
10
|
-
},
|
|
11
|
-
"bugs": {
|
|
12
|
-
"url": "https://github.com/paulohenriquesn/pix-utils-js/issues"
|
|
13
|
-
},
|
|
14
|
-
"homepage": "https://github.com/paulohenriquesn/pix-utils-js#readme",
|
|
15
|
-
"scripts": {
|
|
16
|
-
"test": "node tests/index.js"
|
|
17
|
-
},
|
|
18
|
-
"keywords": [
|
|
19
|
-
"pix",
|
|
20
|
-
"chave pix"
|
|
21
|
-
],
|
|
22
|
-
"license": "MIT"
|
|
23
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "pix-utils-js",
|
|
3
|
+
"version": "1.0.8",
|
|
4
|
+
"author": "Paulo Henrique",
|
|
5
|
+
"description": "Um pacote para fornecer utilidades e validações para chaves pix.",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/paulohenriquesn/pix-utils-js.git"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/paulohenriquesn/pix-utils-js/issues"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/paulohenriquesn/pix-utils-js#readme",
|
|
15
|
+
"scripts": {
|
|
16
|
+
"test": "node tests/index.js"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"pix",
|
|
20
|
+
"chave pix"
|
|
21
|
+
],
|
|
22
|
+
"license": "MIT"
|
|
23
|
+
}
|
package/tests/generator.js
CHANGED
|
@@ -1,107 +1,107 @@
|
|
|
1
|
-
class Generator {
|
|
2
|
-
static generateValidPhoneNumber() {
|
|
3
|
-
const dddList = ['11', '21', '31', '41', '51', '61', '71', '81', '91'];
|
|
4
|
-
const selectedDDD = dddList[Math.floor(Math.random() * dddList.length)];
|
|
5
|
-
|
|
6
|
-
const phoneNumber = `${selectedDDD}
|
|
7
|
-
return phoneNumber;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
static generateRandomNumber(length) {
|
|
11
|
-
let randomNumber = '';
|
|
12
|
-
for (let i = 0; i < length; i++) {
|
|
13
|
-
randomNumber += Math.floor(Math.random() * 10);
|
|
14
|
-
}
|
|
15
|
-
return randomNumber;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
static generateRandomCPF() {
|
|
19
|
-
function randomDigit() {
|
|
20
|
-
return Math.floor(Math.random() * 10);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const cpfDigits = [];
|
|
24
|
-
for (let i = 0; i < 9; i++) {
|
|
25
|
-
cpfDigits.push(randomDigit());
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const firstVerifierDigit = Generator.calculateCPFVerifierDigit(cpfDigits);
|
|
29
|
-
cpfDigits.push(firstVerifierDigit);
|
|
30
|
-
|
|
31
|
-
const secondVerifierDigit = Generator.calculateCPFVerifierDigit(cpfDigits);
|
|
32
|
-
cpfDigits.push(secondVerifierDigit);
|
|
33
|
-
|
|
34
|
-
return cpfDigits.join('');
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
static calculateCPFVerifierDigit(digits) {
|
|
38
|
-
const sum = digits.reduce((acc, digit, index) => {
|
|
39
|
-
const multiplier = digits.length + 1 - index;
|
|
40
|
-
return acc + digit * multiplier;
|
|
41
|
-
}, 0);
|
|
42
|
-
|
|
43
|
-
const remainder = sum % 11;
|
|
44
|
-
return remainder < 2 ? 0 : 11 - remainder;
|
|
45
|
-
}
|
|
46
|
-
static generateValidCNPJ() {
|
|
47
|
-
function randomDigit() {
|
|
48
|
-
return Math.floor(Math.random() * 10);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const cnpjBase = [];
|
|
52
|
-
for (let i = 0; i < 12; i++) {
|
|
53
|
-
cnpjBase.push(randomDigit());
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const verifierDigits = Generator.calculateCNPJVerifierDigits(cnpjBase);
|
|
57
|
-
cnpjBase.push(verifierDigits[0], verifierDigits[1]);
|
|
58
|
-
|
|
59
|
-
const formattedCNPJ = cnpjBase.join('');
|
|
60
|
-
|
|
61
|
-
return formattedCNPJ.replace(/(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})/, '$1.$2.$3/$4-$5');
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
static calculateCNPJVerifierDigits(digits) {
|
|
65
|
-
const multipliers1 = [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];
|
|
66
|
-
const multipliers2 = [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3];
|
|
67
|
-
|
|
68
|
-
function calculateDigit(multipliers) {
|
|
69
|
-
const sum = digits.reduce((acc, digit, index) => acc + digit * multipliers[index], 0);
|
|
70
|
-
const remainder = sum % 11;
|
|
71
|
-
return remainder < 2 ? 0 : 11 - remainder;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const firstDigit = calculateDigit(multipliers1);
|
|
75
|
-
const secondDigit = calculateDigit(multipliers2);
|
|
76
|
-
|
|
77
|
-
return [firstDigit, secondDigit];
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
static generateRandomUUID() {
|
|
81
|
-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
|
82
|
-
const r = Math.random() * 16 | 0;
|
|
83
|
-
const v = c === 'x' ? r : (r & 0x3 | 0x8);
|
|
84
|
-
return v.toString(16);
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
static generateRandomEmail() {
|
|
89
|
-
const domains = ['gmail.com', 'yahoo.com', 'hotmail.com', 'outlook.com', 'example.com'];
|
|
90
|
-
const username = Generator.generateRandomString(8);
|
|
91
|
-
const domain = domains[Math.floor(Math.random() * domains.length)];
|
|
92
|
-
return `${username}@${domain}`;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
static generateRandomString(length) {
|
|
96
|
-
const characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
|
97
|
-
let randomString = '';
|
|
98
|
-
for (let i = 0; i < length; i++) {
|
|
99
|
-
const randomIndex = Math.floor(Math.random() * characters.length);
|
|
100
|
-
randomString += characters.charAt(randomIndex);
|
|
101
|
-
}
|
|
102
|
-
return randomString;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
1
|
+
class Generator {
|
|
2
|
+
static generateValidPhoneNumber() {
|
|
3
|
+
const dddList = ['11', '21', '31', '41', '51', '61', '71', '81', '91'];
|
|
4
|
+
const selectedDDD = dddList[Math.floor(Math.random() * dddList.length)];
|
|
5
|
+
const firstDigit = Math.random() < 0.5 ? '8' : '9';
|
|
6
|
+
const phoneNumber = `${selectedDDD}${firstDigit}${Generator.generateRandomNumber(8)}`;
|
|
7
|
+
return phoneNumber;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
static generateRandomNumber(length) {
|
|
11
|
+
let randomNumber = '';
|
|
12
|
+
for (let i = 0; i < length; i++) {
|
|
13
|
+
randomNumber += Math.floor(Math.random() * 10);
|
|
14
|
+
}
|
|
15
|
+
return randomNumber;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static generateRandomCPF() {
|
|
19
|
+
function randomDigit() {
|
|
20
|
+
return Math.floor(Math.random() * 10);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const cpfDigits = [];
|
|
24
|
+
for (let i = 0; i < 9; i++) {
|
|
25
|
+
cpfDigits.push(randomDigit());
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const firstVerifierDigit = Generator.calculateCPFVerifierDigit(cpfDigits);
|
|
29
|
+
cpfDigits.push(firstVerifierDigit);
|
|
30
|
+
|
|
31
|
+
const secondVerifierDigit = Generator.calculateCPFVerifierDigit(cpfDigits);
|
|
32
|
+
cpfDigits.push(secondVerifierDigit);
|
|
33
|
+
|
|
34
|
+
return cpfDigits.join('');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static calculateCPFVerifierDigit(digits) {
|
|
38
|
+
const sum = digits.reduce((acc, digit, index) => {
|
|
39
|
+
const multiplier = digits.length + 1 - index;
|
|
40
|
+
return acc + digit * multiplier;
|
|
41
|
+
}, 0);
|
|
42
|
+
|
|
43
|
+
const remainder = sum % 11;
|
|
44
|
+
return remainder < 2 ? 0 : 11 - remainder;
|
|
45
|
+
}
|
|
46
|
+
static generateValidCNPJ() {
|
|
47
|
+
function randomDigit() {
|
|
48
|
+
return Math.floor(Math.random() * 10);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const cnpjBase = [];
|
|
52
|
+
for (let i = 0; i < 12; i++) {
|
|
53
|
+
cnpjBase.push(randomDigit());
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const verifierDigits = Generator.calculateCNPJVerifierDigits(cnpjBase);
|
|
57
|
+
cnpjBase.push(verifierDigits[0], verifierDigits[1]);
|
|
58
|
+
|
|
59
|
+
const formattedCNPJ = cnpjBase.join('');
|
|
60
|
+
|
|
61
|
+
return formattedCNPJ.replace(/(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})/, '$1.$2.$3/$4-$5');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
static calculateCNPJVerifierDigits(digits) {
|
|
65
|
+
const multipliers1 = [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];
|
|
66
|
+
const multipliers2 = [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3];
|
|
67
|
+
|
|
68
|
+
function calculateDigit(multipliers) {
|
|
69
|
+
const sum = digits.reduce((acc, digit, index) => acc + digit * multipliers[index], 0);
|
|
70
|
+
const remainder = sum % 11;
|
|
71
|
+
return remainder < 2 ? 0 : 11 - remainder;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const firstDigit = calculateDigit(multipliers1);
|
|
75
|
+
const secondDigit = calculateDigit(multipliers2);
|
|
76
|
+
|
|
77
|
+
return [firstDigit, secondDigit];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
static generateRandomUUID() {
|
|
81
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
|
82
|
+
const r = Math.random() * 16 | 0;
|
|
83
|
+
const v = c === 'x' ? r : (r & 0x3 | 0x8);
|
|
84
|
+
return v.toString(16);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
static generateRandomEmail() {
|
|
89
|
+
const domains = ['gmail.com', 'yahoo.com', 'hotmail.com', 'outlook.com', 'example.com'];
|
|
90
|
+
const username = Generator.generateRandomString(8);
|
|
91
|
+
const domain = domains[Math.floor(Math.random() * domains.length)];
|
|
92
|
+
return `${username}@${domain}`;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
static generateRandomString(length) {
|
|
96
|
+
const characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
|
97
|
+
let randomString = '';
|
|
98
|
+
for (let i = 0; i < length; i++) {
|
|
99
|
+
const randomIndex = Math.floor(Math.random() * characters.length);
|
|
100
|
+
randomString += characters.charAt(randomIndex);
|
|
101
|
+
}
|
|
102
|
+
return randomString;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
|
|
107
107
|
module.exports = { Generator }
|
package/tests/index.js
CHANGED
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
const assert = require('assert');
|
|
2
|
-
const { describe, it } = require('node:test')
|
|
3
|
-
const { identify, normalize, validate } = require('../index')
|
|
4
|
-
const { Generator } = require('./generator')
|
|
5
|
-
|
|
6
|
-
describe('validate', () => {
|
|
7
|
-
it('should returns false if no pix key is provided', (t) => {
|
|
8
|
-
const sut = validate({pix: 'invalid'})
|
|
9
|
-
assert.strictEqual(sut, false);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('should returns false if qr pix key is provided', (t) => {
|
|
13
|
-
const sut = validate({pix: 'invalid', type: 'qrcode'})
|
|
14
|
-
assert.strictEqual(sut, false);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('should returns true if email key is provided and is valid', (t) => {
|
|
18
|
-
const sut = validate({pix: Generator.generateRandomEmail()})
|
|
19
|
-
assert.strictEqual(sut, true);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('should returns true if phone number key is provided and is valid', (t) => {
|
|
23
|
-
const sut = validate({pix: Generator.generateValidPhoneNumber()})
|
|
24
|
-
assert.strictEqual(sut, true);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('should returns true if random key is provided and is valid', (t) => {
|
|
28
|
-
const sut = validate({pix: Generator.generateRandomUUID()})
|
|
29
|
-
assert.strictEqual(sut, true);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('should returns true qrcode if qrcode pix is provided and is valid', (t) => {
|
|
33
|
-
const qrCode = '00020126360014BR.GOV.BCB.PIX0114+5511999226498520400005303986540813213.005802BR5904test6004test62070503***630450CF'
|
|
34
|
-
const sut = validate({ pix: qrCode })
|
|
35
|
-
assert.strictEqual(sut, true);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('should returns false qrcode if qrcode pix is provided and is invalid', (t) => {
|
|
39
|
-
const qrCode = '/INVALID/00020126360014BR.GOV.BCB.PIX0114+5511999226498520400005303986540813213.005802BR5904test6004test62070503***630450CF'
|
|
40
|
-
const sut = validate({ pix: qrCode })
|
|
41
|
-
assert.strictEqual(sut, false);
|
|
42
|
-
});
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
describe('identify', () => {
|
|
46
|
-
it('should returns email if email pix is provided', (t) => {
|
|
47
|
-
const sut = identify({ pix: 'test@gmail.com'})
|
|
48
|
-
assert.notStrictEqual(sut, { pix: 'test@gmail.com', type: 'email' });
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('should returns cpf if cpf pix is provided', (t) => {
|
|
52
|
-
const cpf = Generator.generateRandomCPF()
|
|
53
|
-
const sut = identify({ pix: cpf})
|
|
54
|
-
assert.notStrictEqual(sut, { pix: cpf, type: 'cpf' });
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
it('should returns cnpj if cnpj pix is provided', (t) => {
|
|
59
|
-
const cnpj = Generator.generateValidCNPJ()
|
|
60
|
-
const sut = identify({ pix: cnpj})
|
|
61
|
-
assert.notStrictEqual(sut, { pix: cnpj, type: 'cnpj' });
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('should returns random if random pix is provided', (t) => {
|
|
65
|
-
const random = Generator.generateRandomUUID()
|
|
66
|
-
const sut = identify({ pix: random })
|
|
67
|
-
assert.notStrictEqual(sut, { pix: random, type: 'random' });
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('should returns phone if random pix is provided', (t) => {
|
|
71
|
-
const phone = Generator.generateValidPhoneNumber()
|
|
72
|
-
const sut = identify({ pix: phone })
|
|
73
|
-
assert.notStrictEqual(sut, { pix: phone, type: 'phone' });
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('should returns qrcode if qrcode pix is provided', (t) => {
|
|
77
|
-
const qrCode = '00020126360014BR.GOV.BCB.PIX0114+5511999226498520400005303986540813213.005802BR5904test6004test62070503***630450CF'
|
|
78
|
-
const sut = identify({ pix: qrCode })
|
|
79
|
-
assert.notStrictEqual(sut, { pix: qrCode, type: 'qrcode' });
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it('should throws if invalid pix is provided', (t) => {
|
|
83
|
-
let sut;
|
|
84
|
-
try {
|
|
85
|
-
sut = identify({ pix: 'abc' })
|
|
86
|
-
}catch (err) {
|
|
87
|
-
sut = err;
|
|
88
|
-
}
|
|
89
|
-
assert.notStrictEqual(sut, Error);
|
|
90
|
-
});
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
describe("normalize", () => {
|
|
94
|
-
it('should normalize cpf key', (t) => {
|
|
95
|
-
assert.deepEqual(normalize({ pix: "000.000.000-00"}), { pix: '00000000000', type: 'cpf'});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it('should normalize cnpj key', (t) => {
|
|
99
|
-
assert.deepEqual(normalize({ pix: "00.000.000/0000-00"}), { pix: '00000000000000', type: 'cnpj'});
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it('should normalize phone key', (t) => {
|
|
103
|
-
assert.deepEqual(normalize({ pix: "
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it('should normalize qrcode key', (t) => {
|
|
107
|
-
assert.deepEqual(normalize({ pix: "00020126360014BR.GOV.BCB.PIX0114+5511999226498520400005303986540813213.005802BR5904test6004test62070503***630450CF"}), { pix: '00020126360014BR.GOV.BCB.PIX0114+5511999226498520400005303986540813213.005802BR5904test6004test62070503***630450CF', type: 'qrcode'});
|
|
108
|
-
});
|
|
109
|
-
})
|
|
1
|
+
const assert = require('assert');
|
|
2
|
+
const { describe, it } = require('node:test')
|
|
3
|
+
const { identify, normalize, validate } = require('../index')
|
|
4
|
+
const { Generator } = require('./generator')
|
|
5
|
+
|
|
6
|
+
describe('validate', () => {
|
|
7
|
+
it('should returns false if no pix key is provided', (t) => {
|
|
8
|
+
const sut = validate({pix: 'invalid'})
|
|
9
|
+
assert.strictEqual(sut, false);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('should returns false if qr pix key is provided', (t) => {
|
|
13
|
+
const sut = validate({pix: 'invalid', type: 'qrcode'})
|
|
14
|
+
assert.strictEqual(sut, false);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('should returns true if email key is provided and is valid', (t) => {
|
|
18
|
+
const sut = validate({pix: Generator.generateRandomEmail()})
|
|
19
|
+
assert.strictEqual(sut, true);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should returns true if phone number key is provided and is valid', (t) => {
|
|
23
|
+
const sut = validate({pix: Generator.generateValidPhoneNumber()})
|
|
24
|
+
assert.strictEqual(sut, true);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('should returns true if random key is provided and is valid', (t) => {
|
|
28
|
+
const sut = validate({pix: Generator.generateRandomUUID()})
|
|
29
|
+
assert.strictEqual(sut, true);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should returns true qrcode if qrcode pix is provided and is valid', (t) => {
|
|
33
|
+
const qrCode = '00020126360014BR.GOV.BCB.PIX0114+5511999226498520400005303986540813213.005802BR5904test6004test62070503***630450CF'
|
|
34
|
+
const sut = validate({ pix: qrCode })
|
|
35
|
+
assert.strictEqual(sut, true);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('should returns false qrcode if qrcode pix is provided and is invalid', (t) => {
|
|
39
|
+
const qrCode = '/INVALID/00020126360014BR.GOV.BCB.PIX0114+5511999226498520400005303986540813213.005802BR5904test6004test62070503***630450CF'
|
|
40
|
+
const sut = validate({ pix: qrCode })
|
|
41
|
+
assert.strictEqual(sut, false);
|
|
42
|
+
});
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
describe('identify', () => {
|
|
46
|
+
it('should returns email if email pix is provided', (t) => {
|
|
47
|
+
const sut = identify({ pix: 'test@gmail.com'})
|
|
48
|
+
assert.notStrictEqual(sut, { pix: 'test@gmail.com', type: 'email' });
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should returns cpf if cpf pix is provided', (t) => {
|
|
52
|
+
const cpf = Generator.generateRandomCPF()
|
|
53
|
+
const sut = identify({ pix: cpf})
|
|
54
|
+
assert.notStrictEqual(sut, { pix: cpf, type: 'cpf' });
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
it('should returns cnpj if cnpj pix is provided', (t) => {
|
|
59
|
+
const cnpj = Generator.generateValidCNPJ()
|
|
60
|
+
const sut = identify({ pix: cnpj})
|
|
61
|
+
assert.notStrictEqual(sut, { pix: cnpj, type: 'cnpj' });
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('should returns random if random pix is provided', (t) => {
|
|
65
|
+
const random = Generator.generateRandomUUID()
|
|
66
|
+
const sut = identify({ pix: random })
|
|
67
|
+
assert.notStrictEqual(sut, { pix: random, type: 'random' });
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('should returns phone if random pix is provided', (t) => {
|
|
71
|
+
const phone = Generator.generateValidPhoneNumber()
|
|
72
|
+
const sut = identify({ pix: phone })
|
|
73
|
+
assert.notStrictEqual(sut, { pix: phone, type: 'phone' });
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('should returns qrcode if qrcode pix is provided', (t) => {
|
|
77
|
+
const qrCode = '00020126360014BR.GOV.BCB.PIX0114+5511999226498520400005303986540813213.005802BR5904test6004test62070503***630450CF'
|
|
78
|
+
const sut = identify({ pix: qrCode })
|
|
79
|
+
assert.notStrictEqual(sut, { pix: qrCode, type: 'qrcode' });
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('should throws if invalid pix is provided', (t) => {
|
|
83
|
+
let sut;
|
|
84
|
+
try {
|
|
85
|
+
sut = identify({ pix: 'abc' })
|
|
86
|
+
}catch (err) {
|
|
87
|
+
sut = err;
|
|
88
|
+
}
|
|
89
|
+
assert.notStrictEqual(sut, Error);
|
|
90
|
+
});
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
describe("normalize", () => {
|
|
94
|
+
it('should normalize cpf key', (t) => {
|
|
95
|
+
assert.deepEqual(normalize({ pix: "000.000.000-00"}), { pix: '00000000000', type: 'cpf'});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('should normalize cnpj key', (t) => {
|
|
99
|
+
assert.deepEqual(normalize({ pix: "00.000.000/0000-00"}), { pix: '00000000000000', type: 'cnpj'});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('should normalize phone key', (t) => {
|
|
103
|
+
assert.deepEqual(normalize({ pix: "(11) 98888-8888"}), { pix: '11988888888', type: 'phone'});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('should normalize qrcode key', (t) => {
|
|
107
|
+
assert.deepEqual(normalize({ pix: "00020126360014BR.GOV.BCB.PIX0114+5511999226498520400005303986540813213.005802BR5904test6004test62070503***630450CF"}), { pix: '00020126360014BR.GOV.BCB.PIX0114+5511999226498520400005303986540813213.005802BR5904test6004test62070503***630450CF', type: 'qrcode'});
|
|
108
|
+
});
|
|
109
|
+
})
|
package/utils/validator.js
CHANGED
|
@@ -1,35 +1,38 @@
|
|
|
1
|
-
class Validator {
|
|
2
|
-
isEmail(email) {
|
|
3
|
-
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/
|
|
4
|
-
return emailRegex.test(email)
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
isUUID(uuid) {
|
|
8
|
-
const uuidRegex = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/
|
|
9
|
-
return uuidRegex.test(uuid)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
isPhoneNumber(phoneNumber) {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
1
|
+
class Validator {
|
|
2
|
+
isEmail(email) {
|
|
3
|
+
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/
|
|
4
|
+
return emailRegex.test(email)
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
isUUID(uuid) {
|
|
8
|
+
const uuidRegex = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/
|
|
9
|
+
return uuidRegex.test(uuid)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
isPhoneNumber(phoneNumber) {
|
|
13
|
+
const normalized = phoneNumber.replace(/[^0-9]/g, '');
|
|
14
|
+
|
|
15
|
+
const phoneNumberRegex = /^\d{2}[89]\d{8}$/;
|
|
16
|
+
|
|
17
|
+
return phoneNumberRegex.test(normalized);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
isCPF(cpf) {
|
|
21
|
+
const cpfRegex = /^(\d{3}\.\d{3}\.\d{3}-\d{2}|\d{11})$/;
|
|
22
|
+
return cpfRegex.test(cpf)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
isCNPJ(cnpj) {
|
|
26
|
+
const cnpjRegex = /^(\d{2}\.\d{3}\.\d{3}\/\d{4}-\d{2}|\d{14})$/;
|
|
27
|
+
return cnpjRegex.test(cnpj)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
isQRCode(pixKeyCopyPaste) {
|
|
31
|
+
const qrCodeRegex = /^(000201|01|2636)/
|
|
32
|
+
return qrCodeRegex.test(pixKeyCopyPaste)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
module.exports = {
|
|
37
|
+
Validator
|
|
35
38
|
}
|
package/yarn-error.log
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
Arguments:
|
|
2
|
-
C:\Program Files\nodejs\node.exe C:\Users\Paulo\AppData\Roaming\npm\node_modules\yarn\bin\yarn.js publish
|
|
3
|
-
|
|
4
|
-
PATH:
|
|
5
|
-
C:\Program Files\PowerShell\7;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Git\cmd;C:\Program Files\Docker\Docker\resources\bin;C:\Program Files\Amazon\AWSCLIV2\;C:\Program Files\nodejs\;C:\Program Files\PowerShell\7\;C:\Program Files\dotnet\;C:\Users\Paulo\AppData\Local\Microsoft\WindowsApps;;C:\Users\Paulo\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Paulo\AppData\Roaming\npm;C:\Users\Paulo\.dotnet\tools
|
|
6
|
-
|
|
7
|
-
Yarn version:
|
|
8
|
-
1.22.19
|
|
9
|
-
|
|
10
|
-
Node version:
|
|
11
|
-
20.9.0
|
|
12
|
-
|
|
13
|
-
Platform:
|
|
14
|
-
win32 x64
|
|
15
|
-
|
|
16
|
-
Trace:
|
|
17
|
-
Error: canceled
|
|
18
|
-
at Interface.<anonymous> (C:\Users\Paulo\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:137150:13)
|
|
19
|
-
at Interface.emit (node:events:514:28)
|
|
20
|
-
at [_ttyWrite] [as _ttyWrite] (node:internal/readline/interface:1125:18)
|
|
21
|
-
at ReadStream.onkeypress (node:internal/readline/interface:264:20)
|
|
22
|
-
at ReadStream.emit (node:events:514:28)
|
|
23
|
-
at emitKeys (node:internal/readline/utils:371:14)
|
|
24
|
-
at emitKeys.next (<anonymous>)
|
|
25
|
-
at ReadStream.onData (node:internal/readline/emitKeypressEvents:64:36)
|
|
26
|
-
at ReadStream.emit (node:events:514:28)
|
|
27
|
-
at addChunk (node:internal/streams/readable:376:12)
|
|
28
|
-
|
|
29
|
-
npm manifest:
|
|
30
|
-
{
|
|
31
|
-
"name": "pix-utils-js",
|
|
32
|
-
"version": "1.0.7",
|
|
33
|
-
"author": "Paulo Henrique",
|
|
34
|
-
"description": "Um pacote para fornecer utilidades e validações para chaves pix.",
|
|
35
|
-
"main": "index.js",
|
|
36
|
-
"repository": {
|
|
37
|
-
"type": "git",
|
|
38
|
-
"url": "https://github.com/paulohenriquesn/pix-utils-js.git"
|
|
39
|
-
},
|
|
40
|
-
"bugs": {
|
|
41
|
-
"url": "https://github.com/paulohenriquesn/pix-utils-js/issues"
|
|
42
|
-
},
|
|
43
|
-
"homepage": "https://github.com/paulohenriquesn/pix-utils-js#readme",
|
|
44
|
-
"scripts": {
|
|
45
|
-
"test": "node tests/index.js"
|
|
46
|
-
},
|
|
47
|
-
"keywords": [
|
|
48
|
-
"pix",
|
|
49
|
-
"chave pix"
|
|
50
|
-
],
|
|
51
|
-
"license": "MIT"
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
yarn manifest:
|
|
55
|
-
No manifest
|
|
56
|
-
|
|
57
|
-
Lockfile:
|
|
58
|
-
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
59
|
-
# yarn lockfile v1
|