Skip to content
This repository has been archived by the owner on Dec 23, 2024. It is now read-only.

Commit

Permalink
v1.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
EdamAme-x committed Jan 20, 2024
1 parent 03ba5fe commit 6aa55ed
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 17 deletions.
17 changes: 9 additions & 8 deletions deno_dist/base/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
parseRecoveryCode,
unparseRecoveryCode,
} from '../utils/parse.ts'
import { randomUUID } from '../utils/uuid.ts'

export class PayPay {
public phone: string = ''
Expand Down Expand Up @@ -87,7 +88,7 @@ export class PayPay {
throw new PayPayError('UUID is not valid', 0).fire()
}
} else {
this.uuid = crypto.randomUUID()
this.uuid = randomUUID()
}

const ctx = {
Expand Down Expand Up @@ -274,7 +275,7 @@ export class PayPay {

const ctx: CreateLinkContext = {
androidMinimumVersion: '3.45.0',
requestId: crypto.randomUUID(),
requestId: randomUUID(),
requestAt: new Date().toISOString(),
theme: 'default-sendmoney',
amount: amount,
Expand Down Expand Up @@ -343,7 +344,7 @@ export class PayPay {

const ctx: ReceiveLinkContext = {
verificationCode: link.split('/').pop() ?? '',
client_uuid: this.uuid ?? crypto.randomUUID(),
client_uuid: this.uuid ?? randomUUID(),
passcode: passcode ?? '2189',
requestAt: new Date().toISOString(),
requestId: info.raw.payload.message.data.requestId,
Expand Down Expand Up @@ -390,8 +391,8 @@ export class PayPay {
method: 'POST',
body: JSON.stringify({
verificationCode: code,
client_uuid: this.uuid ?? crypto.randomUUID(),
requestId: crypto.randomUUID(),
client_uuid: this.uuid ?? randomUUID(),
requestId: randomUUID(),
requestAt: new Date().toISOString(),
iosMinimumVersion: '3.45.0',
androidMinimumVersion: '3.45.0',
Expand Down Expand Up @@ -427,7 +428,7 @@ export class PayPay {
theme: 'default-sendmoney',
externalReceiverId: external_id,
amount: amount,
requestId: crypto.randomUUID(),
requestId: randomUUID(),
requestAt: new Date().toISOString(),
iosMinimumVersion: '3.45.0',
androidMinimumVersion: '3.45.0',
Expand Down Expand Up @@ -493,7 +494,7 @@ export class PayPay {
this.password = object.password

return await this.login({
uuid: this.uuid ?? crypto.randomUUID(),
uuid: this.uuid ?? randomUUID(),
})
}
}
Expand All @@ -509,7 +510,7 @@ export class PayPayRecovery {
const object = unparseRecoveryCode(code)
this.phone = object.phone
this.password = object.password
this.uuid = object.uuid ?? crypto.randomUUID()
this.uuid = object.uuid ?? randomUUID()
}

async recovery(): Promise<PayPay> {
Expand Down
9 changes: 9 additions & 0 deletions deno_dist/utils/uuid.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { isUuid } from './is.ts'
import { randomUUID } from './uuid.ts'

describe('UUIDError', () => {

test('UUID', async () => {
expect(isUuid(randomUUID())).toBeTruthy()
})
})
6 changes: 6 additions & 0 deletions deno_dist/utils/uuid.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export function randomUUID() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (a) => {
const r = (new Date().getTime() + Math.random() * 16) % 16 | 0, v = a == 'x' ? r : (r & 0x3 | 0x8)
return v.toString(16)
})
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "paypax",
"version": "1.6.0",
"version": "1.6.1",
"description": "Library for automate PayPay operations",
"scripts": {
"format": "prettier --write ./src/*.{ts,tsx} ./src/**/*.{ts,tsx}",
Expand Down
17 changes: 9 additions & 8 deletions src/base/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
parseRecoveryCode,
unparseRecoveryCode,
} from '../utils/parse'
import { randomUUID } from '../utils/uuid'

export class PayPay {
public phone: string = ''
Expand Down Expand Up @@ -87,7 +88,7 @@ export class PayPay {
throw new PayPayError('UUID is not valid', 0).fire()
}
} else {
this.uuid = crypto.randomUUID()
this.uuid = randomUUID()
}

const ctx = {
Expand Down Expand Up @@ -274,7 +275,7 @@ export class PayPay {

const ctx: CreateLinkContext = {
androidMinimumVersion: '3.45.0',
requestId: crypto.randomUUID(),
requestId: randomUUID(),
requestAt: new Date().toISOString(),
theme: 'default-sendmoney',
amount: amount,
Expand Down Expand Up @@ -343,7 +344,7 @@ export class PayPay {

const ctx: ReceiveLinkContext = {
verificationCode: link.split('/').pop() ?? '',
client_uuid: this.uuid ?? crypto.randomUUID(),
client_uuid: this.uuid ?? randomUUID(),
passcode: passcode ?? '2189',
requestAt: new Date().toISOString(),
requestId: info.raw.payload.message.data.requestId,
Expand Down Expand Up @@ -390,8 +391,8 @@ export class PayPay {
method: 'POST',
body: JSON.stringify({
verificationCode: code,
client_uuid: this.uuid ?? crypto.randomUUID(),
requestId: crypto.randomUUID(),
client_uuid: this.uuid ?? randomUUID(),
requestId: randomUUID(),
requestAt: new Date().toISOString(),
iosMinimumVersion: '3.45.0',
androidMinimumVersion: '3.45.0',
Expand Down Expand Up @@ -427,7 +428,7 @@ export class PayPay {
theme: 'default-sendmoney',
externalReceiverId: external_id,
amount: amount,
requestId: crypto.randomUUID(),
requestId: randomUUID(),
requestAt: new Date().toISOString(),
iosMinimumVersion: '3.45.0',
androidMinimumVersion: '3.45.0',
Expand Down Expand Up @@ -493,7 +494,7 @@ export class PayPay {
this.password = object.password

return await this.login({
uuid: this.uuid ?? crypto.randomUUID(),
uuid: this.uuid ?? randomUUID(),
})
}
}
Expand All @@ -509,7 +510,7 @@ export class PayPayRecovery {
const object = unparseRecoveryCode(code)
this.phone = object.phone
this.password = object.password
this.uuid = object.uuid ?? crypto.randomUUID()
this.uuid = object.uuid ?? randomUUID()
}

async recovery(): Promise<PayPay> {
Expand Down
9 changes: 9 additions & 0 deletions src/utils/uuid.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { isUuid } from './is'
import { randomUUID } from './uuid'

describe('UUIDError', () => {

test('UUID', async () => {
expect(isUuid(randomUUID())).toBeTruthy()
})
})
6 changes: 6 additions & 0 deletions src/utils/uuid.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export function randomUUID() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (a) => {
const r = (new Date().getTime() + Math.random() * 16) % 16 | 0, v = a == 'x' ? r : (r & 0x3 | 0x8)
return v.toString(16)
})
}

0 comments on commit 6aa55ed

Please sign in to comment.