Spaces:
Running
Running
Download src/modules/auth/dto/api-key.dto.ts from jinksQspider/openWa: direct link, hf CLI and curl.
- Browser
- Download file 2.58 kB
-
https://huggingface.co/spaces/jinksQspider/openWa/resolve/main/src/modules/auth/dto/api-key.dto.ts
- Command line
-
hf download hf://spaces/jinksQspider/openWa/src/modules/auth/dto/api-key.dto.ts
-
curl -L -o api-key.dto.ts https://huggingface.co/spaces/jinksQspider/openWa/resolve/main/src/modules/auth/dto/api-key.dto.ts
2.58 kB
| import { IsString, IsOptional, IsEnum, IsArray, IsDateString, MinLength, MaxLength } from 'class-validator'; | |
| import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; | |
| import { ApiKeyRole } from '../entities/api-key.entity'; | |
| export class CreateApiKeyDto { | |
| ({ | |
| description: 'Friendly name for the API key', | |
| example: 'Production Bot', | |
| }) | |
| () | |
| (3) | |
| (100) | |
| name: string; | |
| ({ | |
| description: 'Role/permission level', | |
| enum: ApiKeyRole, | |
| default: ApiKeyRole.OPERATOR, | |
| }) | |
| () | |
| (ApiKeyRole) | |
| role?: ApiKeyRole; | |
| ({ | |
| description: 'Allowed IP addresses (whitelist)', | |
| example: ['192.168.1.1', '10.0.0.0/8'], | |
| }) | |
| () | |
| () | |
| ({ each: true }) | |
| allowedIps?: string[]; | |
| ({ | |
| description: 'Allowed session IDs this key can access', | |
| example: ['session-uuid-1', 'session-uuid-2'], | |
| }) | |
| () | |
| () | |
| ({ each: true }) | |
| allowedSessions?: string[]; | |
| ({ | |
| description: 'Expiration date (ISO 8601)', | |
| example: '2027-12-31T23:59:59Z', | |
| }) | |
| () | |
| () | |
| expiresAt?: string; | |
| } | |
| export class ApiKeyResponseDto { | |
| () | |
| id: string; | |
| () | |
| name: string; | |
| ({ | |
| description: 'First 8 characters of the key (for identification)', | |
| }) | |
| keyPrefix: string; | |
| ({ enum: ApiKeyRole }) | |
| role: ApiKeyRole; | |
| () | |
| allowedIps?: string[]; | |
| () | |
| allowedSessions?: string[]; | |
| () | |
| isActive: boolean; | |
| () | |
| expiresAt?: Date; | |
| () | |
| lastUsedAt?: Date; | |
| () | |
| usageCount: number; | |
| () | |
| createdAt: Date; | |
| } | |
| export class ApiKeyCreatedResponseDto extends ApiKeyResponseDto { | |
| ({ | |
| description: 'Full API key (only shown once at creation)', | |
| example: 'owa_k1_abc123...', | |
| }) | |
| apiKey: string; | |
| } | |
| export class UpdateApiKeyDto { | |
| () | |
| () | |
| () | |
| (3) | |
| (100) | |
| name?: string; | |
| ({ enum: ApiKeyRole }) | |
| () | |
| (ApiKeyRole) | |
| role?: ApiKeyRole; | |
| () | |
| () | |
| () | |
| ({ each: true }) | |
| allowedIps?: string[]; | |
| () | |
| () | |
| () | |
| ({ each: true }) | |
| allowedSessions?: string[]; | |
| () | |
| () | |
| () | |
| expiresAt?: string; | |
| } | |