Skip to content

Commit

Permalink
refactor: use internal crypto module instead of uuid
Browse files Browse the repository at this point in the history
  • Loading branch information
Scrip7 committed Apr 1, 2022
1 parent b5e5dc0 commit ce0408f
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/driver.ts
@@ -1,8 +1,8 @@
import { str as crc32Encode } from 'crc-32';
import { randomUUID } from 'crypto';
import { isLeft } from 'fp-ts/lib/Either';
import * as t from 'io-ts';
import reporter from 'io-ts-reporters';
import { v4 as uuidv4 } from 'uuid';
import { BadConfigException } from './exceptions';
import { PaymentInfo } from './payment-info';
import { BaseReceipt, LinksObject } from './types';
Expand Down Expand Up @@ -38,11 +38,11 @@ export abstract class Driver<Config = any> {
referenceId: ConstructorParameters<typeof PaymentInfo>[0],
method: ConstructorParameters<typeof PaymentInfo>[1],
url: ConstructorParameters<typeof PaymentInfo>[2],
params: ConstructorParameters<typeof PaymentInfo>[3] = {}
params: ConstructorParameters<typeof PaymentInfo>[3] = {},
) => new PaymentInfo(referenceId, method, url, params);

protected generateUuid() {
return uuidv4();
return randomUUID();
}

protected generateId() {
Expand All @@ -54,10 +54,7 @@ export abstract class Driver<Config = any> {
*
* @throws BadConfigException
*/
protected getParsedData = <TData extends any = any, O = TData, I = unknown>(
rawData: I,
codec: t.Type<TData, O, I>
): TData => {
protected getParsedData = <TData = any, O = TData, I = unknown>(rawData: I, codec: t.Type<TData, O, I>): TData => {
const result = codec.decode(rawData);
if (isLeft(result)) {
// Use a reporter to throw an error if validation fails
Expand Down

0 comments on commit ce0408f

Please sign in to comment.