-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth.dto.ts
More file actions
56 lines (50 loc) · 1.21 KB
/
auth.dto.ts
File metadata and controls
56 lines (50 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import {
IsNotEmpty,
IsOptional,
IsString,
IsEnum,
ValidateNested,
} from 'class-validator'
import {
MiniAppWalletAuthSuccessPayload,
ISuccessResult,
VerificationLevel,
} from '@worldcoin/minikit-js'
import { Transform, Type } from 'class-transformer'
export class UserDetailsDto {
@IsString()
username: string
@IsOptional()
@IsString()
profilePictureUrl: string
}
export class VerifyWorldIdDto {
@IsNotEmpty()
@ValidateNested()
@Type(() => Object)
walletPayload: MiniAppWalletAuthSuccessPayload
@IsNotEmpty()
@ValidateNested()
@Type(() => Object)
worldIdProof: ISuccessResult
@IsNotEmpty()
@ValidateNested()
@Type(() => Object)
userDetails: UserDetailsDto
@IsNotEmpty()
@IsString()
nonce: string
@IsOptional()
@Transform(({ value }) => {
if (typeof value === 'string') {
value = value.toLowerCase()
}
return Object.values(VerificationLevel).includes(value as VerificationLevel)
? (value as VerificationLevel)
: VerificationLevel.Device
})
@IsEnum(VerificationLevel, {
message: `Verification level must be one of: ${Object.values(VerificationLevel).join(', ')}`,
})
verificationLevel: VerificationLevel = VerificationLevel.Device
}