forked from clerk/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAPIKey.ts
More file actions
43 lines (41 loc) · 1.03 KB
/
Copy pathAPIKey.ts
File metadata and controls
43 lines (41 loc) · 1.03 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
import type { APIKeyJSON } from './JSON';
export class APIKey {
constructor(
readonly id: string,
readonly type: string,
readonly name: string,
readonly subject: string,
readonly scopes: string[],
readonly claims: Record<string, any> | null,
readonly revoked: boolean,
readonly revocationReason: string | null,
readonly expired: boolean,
readonly expiration: number | null,
readonly createdBy: string | null,
readonly description: string | null,
readonly lastUsedAt: number | null,
readonly createdAt: number,
readonly updatedAt: number,
readonly secret?: string,
) {}
static fromJSON(data: APIKeyJSON) {
return new APIKey(
data.id,
data.type,
data.name,
data.subject,
data.scopes,
data.claims,
data.revoked,
data.revocation_reason,
data.expired,
data.expiration,
data.created_by,
data.description,
data.last_used_at,
data.created_at,
data.updated_at,
data.secret,
);
}
}