Skip to content

Commit

Permalink
closes #741; closes #742
Browse files Browse the repository at this point in the history
  • Loading branch information
benkeen committed Mar 8, 2022
1 parent 9beab26 commit f1c7381
Show file tree
Hide file tree
Showing 16 changed files with 137 additions and 360 deletions.
2 changes: 1 addition & 1 deletion client/_localeFileMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { GDLocaleMap } from '~types/general';
export const localeFileMap: GDLocaleMap = {
"ar": "ar-531cbf91.js",
"de": "de-08061372.js",
"en": "en-c03675c1.js",
"en": "en-275f4d17.js",
"es": "es-9e326cfd.js",
"fr": "fr-9e525864.js",
"hi": "hi-50946462.js",
Expand Down
14 changes: 7 additions & 7 deletions client/_pluginWebWorkers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@ export default {
"coreWorker": "",
"coreDataTypeWorker": "dataTypes.worker-66b442524f84509e3a98b84cffeafdb8.js",
"coreExportTypeWorker": "exportTypes.worker-9b546d7c7909e02146fafee124180d37.js",
"workerUtils": "workerUtils-78f34cab796da4086a9250dab0e9f2e4.js",
"workerUtils": "workerUtils-95d23a18b0b0b50d72d6ba0e501b3f14.js",
"dataTypes": {
"Alphanumeric": "DT-Alphanumeric.generator-0185a235eabc5b0a7ba6afdbb2af8676.js",
"AutoIncrement": "DT-AutoIncrement.generator-eccb050ece38a91e2a849d125e417298.js",
"BitcoinAddress": "DT-BitcoinAddress.generator-02bf8166cf988fda63bc859c57fc58e6.js",
"AutoIncrement": "DT-AutoIncrement.generator-86980afec62b375f50bee9949bc4ae10.js",
"BitcoinAddress": "DT-BitcoinAddress.generator-9842a8a9076ec8040bf40f8d8e51523a.js",
"Boolean": "DT-Boolean.generator-7f17cf17c450482e71f66b8ccec1530a.js",
"CVV": "DT-CVV.generator-c21d2fbc402d72056955f30db7831267.js",
"City": "DT-City.generator-169323d47645d9e1ab6254eff6ba6b7a.js",
"City": "DT-City.generator-e2164864b5d453430a9931c989242521.js",
"Colour": "DT-Colour.generator-db77c6f8b622fcac974e40561e905414.js",
"Company": "DT-Company.generator-b7bd7c08c48f94fb2c88412cc82fcef4.js",
"Computed": "DT-Computed.generator-51452612f3dcfd6bae1a695081e53a36.js",
"Constant": "DT-Constant.generator-ca9cf12d5f32cc92c9158072a5231bd9.js",
"Country": "DT-Country.generator-04d825eed1ef0c5dea5addfabfe442bc.js",
"Country": "DT-Country.generator-a76bcf6ce202d7ed3902c67b26a566f6.js",
"Currency": "DT-Currency.generator-a5a862ac03206548ee1458fcf6a958a2.js",
"Date": "DT-Date.generator-f6604b2cd22cdcc0b4339b3a55cdc719.js",
"Email": "DT-Email.generator-51b7a552887bb25b88f15633805b48f1.js",
"GUID": "DT-GUID.generator-54966dabad4987a193e4cf4a467d4d93.js",
"IBAN": "DT-IBAN.generator-b92eaa02e83c98a15767dfd6866d8bd1.js",
"LatLng": "DT-LatLng.generator-e54a6ba6fdf1679297e01d8729131379.js",
"List": "DT-List.generator-b4257616edb0642d4e3cd012009e385f.js",
"List": "DT-List.generator-e37ce48cda8b003ddba3ef1cafe34346.js",
"Names": "DT-Names.generator-1196b22273319c62350d579ca42b926f.js",
"NormalDistribution": "DT-NormalDistribution.generator-adbc977198013088e21d0c3ad5a62e7e.js",
"NumberRange": "DT-NumberRange.generator-057ed424452f4e991ebc399c615ae34c.js",
Expand All @@ -31,7 +31,7 @@ export default {
"PersonalNumber": "DT-PersonalNumber.generator-68b329da9893e34099c7d8ad5cb9c940.js",
"Phone": "DT-Phone.generator-ca7bb8282784726ece5e8ced1ccfd964.js",
"PostalZip": "DT-PostalZip.generator-cb358d5ab424dd19fde4b694e4e591c4.js",
"Region": "DT-Region.generator-0023f303e736310d27968e3cdf8826dc.js",
"Region": "DT-Region.generator-13c509fcd5339090bdfb938671eb7fba.js",
"Rut": "DT-Rut.generator-9b365251acec194f57b64031c112bfbc.js",
"SIRET": "DT-SIRET.generator-853bfefc8d3f8a2a9d055de5f7c6a1f7.js",
"StreetAddress": "DT-StreetAddress.generator-562c2395fbd1e5308000516909d2a3b6.js",
Expand Down
2 changes: 1 addition & 1 deletion client/_plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const dataTypes = {

export type DataTypeFolder = keyof typeof dataTypes;

export const blacklistedDataTypeFolders = ['BitcoinAddress','_PhoneRegional','OrganizationNumber','PersonalNumber','SIRET'];
export const blacklistedDataTypeFolders = ['_PhoneRegional','OrganizationNumber','PersonalNumber','SIRET'];

import CSV from './src/plugins/exportTypes/CSV/config';
import CSharp from './src/plugins/exportTypes/CSharp/config';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
import utils from '../../../utils';
import { BitcoinAddressFormat, BitcoinAddressState } from './BitcoinAddress';
import { DTOnMessage } from '~types/dataTypes';
import { BitcoinAddressFormat } from './BitcoinAddress';
// import ECPairFactory from 'ecpair';
// import * as ecc from 'tiny-secp256k1';
// import { payments } from 'bitcoinjs-lib';

let utilsLoaded = false;

const placeholders = {
x: 'abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ123456789',
y: 'acdefghjklmnpqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
};

export const onmessage = (e: DTOnMessage) => {
if (!utilsLoaded) {
importScripts(e.data.workerResources.workerUtils);
utilsLoaded = true;
}
const rowState = e.data.rowState;
// const ECPair = ECPairFactory(ecc);

export const generate = (rowState: BitcoinAddressState) => {
const formats: any = {};
if (rowState[BitcoinAddressFormat.Legacy].enabled && rowState[BitcoinAddressFormat.Legacy].weight) {
formats[BitcoinAddressFormat.Legacy] = rowState[BitcoinAddressFormat.Legacy].weight;
Expand All @@ -30,26 +24,39 @@ export const onmessage = (e: DTOnMessage) => {
// get a random format
const format = utils.randomUtils.getRandomWeightedValue(formats);

let display;
switch (format) {
// Nope! actual generation needs to be better than this. Will put this on hold.

// case BitcoinAddressFormat.Legacy: {
// const length = utils.randomUtils.getRandomNum(25, 35);
// display = utils.randomUtils.generateRandomAlphanumericStr('1' + ('x'.repeat(length)), placeholders);
// break;
// }
// case BitcoinAddressFormat.Compatibility: {
// const length = utils.randomUtils.getRandomNum(25, 35);
// display = utils.randomUtils.generateRandomAlphanumericStr('3' + ('x'.repeat(length)), placeholders);
// break;
// }
// case BitcoinAddressFormat.Segwit:
// display = utils.randomUtils.generateRandomAlphanumericStr('bc1' + ('y'.repeat(39)), placeholders);
// break;
// let display;
// switch (format) {
// // Nope! actual generation needs to be better than this. Will put this on hold.
//
// // case BitcoinAddressFormat.Legacy: {
// // const length = utils.randomUtils.getRandomNum(25, 35);
// // display = utils.randomUtils.generateRandomAlphanumericStr('1' + ('x'.repeat(length)), placeholders);
// // break;
// // }
// // case BitcoinAddressFormat.Compatibility: {
// // const length = utils.randomUtils.getRandomNum(25, 35);
// // display = utils.randomUtils.generateRandomAlphanumericStr('3' + ('x'.repeat(length)), placeholders);
// // break;
// // }
// // case BitcoinAddressFormat.Segwit:
// // display = utils.randomUtils.generateRandomAlphanumericStr('bc1' + ('y'.repeat(39)), placeholders);
// // break;
// }

return "";
// const keyPair = ECPair.makeRandom();
// const { address } = bitcoin.payments.p2pkh({ pubkey: keyPair.publicKey });
// return address;
};


self.onmessage = (e: DTOnMessage) => {
if (!utilsLoaded) {
importScripts(e.data.workerResources.workerUtils);
utilsLoaded = true;
}

postMessage({
display
display: generate(e.data.rowState)
});
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { generate } from '../BitcoinAddress.generator';
import { BitcoinAddressFormat, BitcoinAddressState } from '../BitcoinAddress';

describe('generate', () => {
it('generates', () => {
const state: BitcoinAddressState = {
[BitcoinAddressFormat.Legacy]: {
enabled: true,
weight: 1
},
[BitcoinAddressFormat.Compatibility]: {
enabled: false,
weight: 1
},
[BitcoinAddressFormat.Segwit]: {
enabled: false,
weight: 1
},
};
expect(generate(state)).toEqual('123'); // won't work yet. Just testing
});
});
2 changes: 1 addition & 1 deletion client/src/plugins/dataTypes/CVV/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DTDefinition } from '~types/dataTypes';

const definition: DTDefinition = {
fieldGroup: 'financial',
fieldGroupOrder: 30
fieldGroupOrder: 50
};

export default definition;
4 changes: 2 additions & 2 deletions client/src/plugins/dataTypes/Currency/config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { DTDefinition } from '~types/dataTypes';

const definition: DTDefinition = {
fieldGroup: 'numeric',
fieldGroupOrder: 60,
fieldGroup: 'financial',
fieldGroupOrder: 10,
schema: {
$schema: 'http://json-schema.org/draft-04/schema#',
type: 'object',
Expand Down
2 changes: 1 addition & 1 deletion client/src/plugins/dataTypes/IBAN/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DTDefinition } from '~types/dataTypes';

const definition: DTDefinition = {
fieldGroup: 'financial',
fieldGroupOrder: 5
fieldGroupOrder: 25
};

export default definition;
5 changes: 4 additions & 1 deletion client/src/plugins/dataTypes/List/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ export const Example = ({ data, onUpdate, i18n }: DTExampleProps): JSX.Element =
{ value: i18n.companies, label: i18n.example9 },
{ value: i18n.drugNames, label: i18n.example10 },
{ value: i18n.foodTypes, label: i18n.example11 },
{ value: i18n.carBrands, label: i18n.example12 }
{ value: i18n.carBrands, label: i18n.example12 },
{ value: 'ALL|DZD|AOA|ARS|AMD|AUD|EUR|AZN|BHD|BBD|BYN|EUR|BMD|BOB|BAM|BWP|BRL|BGN|CVE|KHR|XAF|CAD|KYD|XAF|CLP|CNY|COP|CDF|XAF|CRC|HRK|EUR|\'CZK|DKK|DOP|USD|EGP|USD|XAF|EUR|FJD|EUR|EUR|XAF|GEL|EUR|GHS|GIP|\'EUR|DKK|GTQ|GBP|GYD|HNL|HKD|HUF|ISK|INR|IDR|IQD|EUR|IMP|ILS|EUR|\'XOF|JMD|JPY|GBP|JOD|KZT|KES|KRW|EUR|KWD|KGS|LAK|EUR|LBP|LYD|CHF|\'EUR|EUR|MOP|MGA|MWK|MYR|MVR|EUR|MRU|MUR|MXN|MDL|MNT|EUR|MAD|MZN|\'MMK|NAD|EUR|NZD|NIO|NGN|MKD|NOK|OMR|PKR|PGK|PYG|PEN|PHP|PLN|EUR|USD|QAR|RON|RUB|RWF|XCD|SAR|XOF|RSD|SGD|EUR|EUR|ZAR|EUR|LKR|SZL|SEK|CHF|TWD|TJS|TZS|THB|USD|TTD|TND|TRY|TMT|UGX|UAH|AED|GBP|USD|UYU|UZS|VEF|VND|ZMW|ZWD', label: i18n.currencyCode },
{ value: 'lek|dinar|kwanza|peso|dram|dollar|euro|manat|rouble|boliviano|konvertibilna marka|pula|real|lev|escudo|riel|yuan|franc|colon|kuna|koruna|kroner|pound|lari|cedi|Danish krone|quetzal|lempira|forint|krona|rupee|rupiah|shekel|yen|tenge|shilling|won|som|kip|pound|pataca|ariary|kwacha|ringgit|rufiyaa|ouguiya|leu|tugrik|dirham|metical|kyat|cordoba oro|naira|denar|rial|kina|guarani|nuevo sol|zloty|riyal|ruble|rand|lilangeni|somoni|baht|lira|hryvnia|sterling|sum|bolivar|dong', label: i18n.currencyName }

];

return (
Expand Down
4 changes: 3 additions & 1 deletion client/src/plugins/dataTypes/List/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,7 @@
"noRangeEntered": "No range entered",
"between": "Between",
"and": "and",
"items": "items"
"items": "items",
"currencyCode": "Currency code",
"currencyName": "Currency name"
}
2 changes: 1 addition & 1 deletion client/src/plugins/dataTypes/PAN/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DTDefinition } from '~types/dataTypes';

const definition: DTDefinition = {
fieldGroup: 'financial',
fieldGroupOrder: 10,
fieldGroupOrder: 30,
schema: {
properties: {
brand: {
Expand Down
2 changes: 1 addition & 1 deletion client/src/plugins/dataTypes/PIN/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DTDefinition } from '~types/dataTypes';

const definition: DTDefinition = {
fieldGroup: 'financial',
fieldGroupOrder: 20
fieldGroupOrder: 50
};

export default definition;
2 changes: 1 addition & 1 deletion client/src/plugins/dataTypes/Track1/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DTDefinition } from '~types/dataTypes';

const definition: DTDefinition = {
fieldGroup: 'financial',
fieldGroupOrder: 40,
fieldGroupOrder: 70,
dependencies: ['PAN', 'Names']
};

Expand Down
2 changes: 1 addition & 1 deletion client/src/plugins/dataTypes/Track2/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DTDefinition } from '~types/dataTypes';

const definition: DTDefinition = {
fieldGroup: 'financial',
fieldGroupOrder: 50,
fieldGroupOrder: 80,
dependencies: ['PAN']
};

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
"redux-persist": "^6.0.0",
"redux-thunk": "^2.3.0",
"rollup": "^2.31.0",
"sass": "^1.49.9",
"sequelize": "^6.3.5",
"styled-components": "^4.0.0",
"terser-webpack-plugin": "^3.0.3",
Expand Down Expand Up @@ -184,7 +185,6 @@
"json-loader": "0.5.4",
"md5-file": "^5.0.0",
"mini-css-extract-plugin": "^0.8.0",
"node-sass": "^7.0.0",
"nodemon": "^2.0.6",
"postcss-loader": "1.2.2",
"promise": "7.1.1",
Expand Down
Loading

0 comments on commit f1c7381

Please sign in to comment.