Use uuidv4 for serialNumber instead of uvci

This commit is contained in:
Hauke Tönjes 2021-07-01 14:05:09 +02:00
parent 98b01068d2
commit 5054e4da54
No known key found for this signature in database
GPG Key ID: 0BF2BC96C9FAAE9E
3 changed files with 19 additions and 3 deletions

14
package-lock.json generated
View File

@ -22,6 +22,7 @@
"pngjs": "^6.0.0", "pngjs": "^6.0.0",
"react": "^17.0.2", "react": "^17.0.2",
"react-dom": "^17.0.2", "react-dom": "^17.0.2",
"uuid": "^8.3.2",
"webpack": "^5.0.0", "webpack": "^5.0.0",
"worker-loader": "^3.0.7" "worker-loader": "^3.0.7"
}, },
@ -4213,6 +4214,14 @@
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
}, },
"node_modules/uuid": {
"version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
"bin": {
"uuid": "dist/bin/uuid"
}
},
"node_modules/vm-browserify": { "node_modules/vm-browserify": {
"version": "1.1.2", "version": "1.1.2",
"resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.2.tgz", "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.2.tgz",
@ -7725,6 +7734,11 @@
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
}, },
"uuid": {
"version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg=="
},
"vm-browserify": { "vm-browserify": {
"version": "1.1.2", "version": "1.1.2",
"resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.2.tgz", "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.2.tgz",

View File

@ -24,6 +24,7 @@
"pngjs": "^6.0.0", "pngjs": "^6.0.0",
"react": "^17.0.2", "react": "^17.0.2",
"react-dom": "^17.0.2", "react-dom": "^17.0.2",
"uuid": "^8.3.2",
"webpack": "^5.0.0", "webpack": "^5.0.0",
"worker-loader": "^3.0.7" "worker-loader": "^3.0.7"
}, },

View File

@ -2,6 +2,7 @@ import {Constants} from "./constants";
import {Payload, PayloadBody} from "./payload"; import {Payload, PayloadBody} from "./payload";
import {ValueSets} from "./value_sets"; import {ValueSets} from "./value_sets";
import {toBuffer as createZip} from 'do-not-zip'; import {toBuffer as createZip} from 'do-not-zip';
import {v4 as uuid4} from 'uuid';
const crypto = require('crypto') const crypto = require('crypto')
@ -26,7 +27,7 @@ interface Field {
textAlignment?: string; textAlignment?: string;
} }
interface GenericFields { interface PassStructureDictionary {
headerFields: Array<Field>; headerFields: Array<Field>;
primaryFields: Array<Field>; primaryFields: Array<Field>;
secondaryFields: Array<Field>; secondaryFields: Array<Field>;
@ -54,7 +55,7 @@ export class PassData {
serialNumber: string; serialNumber: string;
barcodes: Array<QrCode>; barcodes: Array<QrCode>;
barcode: QrCode; barcode: QrCode;
generic: GenericFields; generic: PassStructureDictionary;
// Generates a sha1 hash from a given buffer // Generates a sha1 hash from a given buffer
private static getBufferHash(buffer: Buffer | string): string { private static getBufferHash(buffer: Buffer | string): string {
@ -152,7 +153,7 @@ export class PassData {
this.labelColor = payload.labelColor; this.labelColor = payload.labelColor;
this.foregroundColor = payload.foregroundColor; this.foregroundColor = payload.foregroundColor;
this.backgroundColor = payload.backgroundColor; this.backgroundColor = payload.backgroundColor;
this.serialNumber = payload.uvci; this.serialNumber = uuid4(); // Generate random UUID v4
this.barcodes = [qrCode]; this.barcodes = [qrCode];
this.barcode = qrCode; this.barcode = qrCode;
this.generic = { this.generic = {