Skip to content

Commit

Permalink
add types for totp methods
Browse files Browse the repository at this point in the history
  • Loading branch information
BatuAksoy committed Dec 14, 2020
1 parent edb9420 commit 6f7dab0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
IPutioAPIClientOptions,
IPutioAPIClientResponse,
} from './types'
import Auth from '../resources/Auth'
import Auth from '../resources/Auth/Auth'
import Config from '../resources/Config'
import Events from '../resources/Events/Events'
import Family from '../resources/Family'
Expand Down
11 changes: 6 additions & 5 deletions src/resources/Auth.ts → src/resources/Auth/Auth.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Base64 } from 'js-base64'
import URI from 'urijs'
import { PutioAPIClient } from '../client'
import { PutioAPIClient } from '../../client'
import { IGenerateTOTPResponse, IVerifyTOTPResponse } from './types'

export default class Auth {
private client: PutioAPIClient
Expand Down Expand Up @@ -148,12 +149,12 @@ export default class Auth {
return this.client.get('/oauth2/validate')
}

public GenerateTotp() {
return this.client.post('/two_factor/generate/totp')
public GenerateTOTP() {
return this.client.post<IGenerateTOTPResponse>('/two_factor/generate/totp')
}

public VerifyTotp(totp: string) {
return this.client.post('/two_factor/verify/totp', {
public VerifyTOTP(totp: string) {
return this.client.post<IVerifyTOTPResponse>('/two_factor/verify/totp', {
data: {
totp,
},
Expand Down
9 changes: 9 additions & 0 deletions src/resources/Auth/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export interface IGenerateTOTPResponse {
secret: string
uri: string
}

export interface IVerifyTOTPResponse {
token: string
user_id: number
}

0 comments on commit 6f7dab0

Please sign in to comment.