|
|
@@ -0,0 +1,83 @@
|
|
|
+import { GetNumberResponse, GetNumberService } from './get-number-service'
|
|
|
+import { RcsNumberSource } from '../entities/rcs-number.entity'
|
|
|
+import { InternalServerErrorException } from '@nestjs/common'
|
|
|
+import axios from 'axios'
|
|
|
+import { createHash } from 'node:crypto'
|
|
|
+import * as querystring from 'node:querystring'
|
|
|
+
|
|
|
+const axiosInstance = axios.create({
|
|
|
+ baseURL: 'https://zqdql.svenkvint.com/api/'
|
|
|
+})
|
|
|
+
|
|
|
+const channel = 'tot9v30ornQKSPx4'
|
|
|
+const key = 'yXVesXPIv4DqAjt55EAl'
|
|
|
+const pid = 451
|
|
|
+
|
|
|
+export class svenkvint extends GetNumberService {
|
|
|
+ source: RcsNumberSource = RcsNumberSource.svenkvint
|
|
|
+
|
|
|
+ async getNumber(country: string, num?: number): Promise<GetNumberResponse> {
|
|
|
+ const timestamp = Math.floor(Date.now() / 1000)
|
|
|
+ const data = `channel=${channel}country=${country}pid=${pid}t=${timestamp}${key}`
|
|
|
+ const sign = createHash('md5').update(data).digest('hex')
|
|
|
+
|
|
|
+ const formData = querystring.stringify({
|
|
|
+ channel,
|
|
|
+ pid,
|
|
|
+ country,
|
|
|
+ t: timestamp,
|
|
|
+ sign
|
|
|
+ })
|
|
|
+
|
|
|
+ const res = await axiosInstance.post('order', formData, {
|
|
|
+ headers: {
|
|
|
+ 'Content-Type': 'application/x-www-form-urlencoded'
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ if (res.data.code !== 0) {
|
|
|
+ throw new InternalServerErrorException(res.data.msg)
|
|
|
+ }
|
|
|
+
|
|
|
+ return {
|
|
|
+ number: res.data.phone,
|
|
|
+ orderId: res.data.taskid,
|
|
|
+ operatorCode: '',
|
|
|
+ operatorName: '',
|
|
|
+ rawResponse: res.data
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ async releaseNumber(number: string) {}
|
|
|
+
|
|
|
+ async retriveMessage(orderId: string, num?: number): Promise<string> {
|
|
|
+ const timestamp = Math.floor(Date.now() / 1000)
|
|
|
+ console.log(timestamp)
|
|
|
+ const data = `channel=${channel}t=${timestamp}taskid=${orderId}${key}`
|
|
|
+ const sign = createHash('md5').update(data).digest('hex')
|
|
|
+
|
|
|
+ const formData = querystring.stringify({
|
|
|
+ channel,
|
|
|
+ taskid: orderId,
|
|
|
+ t: timestamp,
|
|
|
+ sign
|
|
|
+ })
|
|
|
+
|
|
|
+ const res = await axiosInstance.post('code', formData, {
|
|
|
+ headers: {
|
|
|
+ 'Content-Type': 'application/x-www-form-urlencoded'
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ console.log(res.data)
|
|
|
+ if (res.data.code == 0){
|
|
|
+ return `Your Messenger verification code is G-${res.data.vcode}`
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ async blockNumber(number: string) {}
|
|
|
+
|
|
|
+ async cacheNumber(country: string, size: number) {
|
|
|
+ return null
|
|
|
+ }
|
|
|
+}
|