Skip to content

Commit 9763948

Browse files
committed
[KEYCLOAK-13841] Update typescript declarations for keycloak-nodejs-connect
1 parent 14420c0 commit 9763948

File tree

1 file changed

+37
-6
lines changed

1 file changed

+37
-6
lines changed

keycloak.d.ts

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,38 @@ declare namespace KeycloakConnect {
3232
cookies?: boolean
3333
}
3434

35+
interface Claims {
36+
// In the future it may make sense to populate this with some known claims
37+
[key: string]: any
38+
}
39+
40+
interface EnforcerOptions {
41+
response_mode?: 'permissions' | 'token'
42+
resource_server_id?: string
43+
claims?: Claims
44+
}
45+
46+
interface Permission {
47+
id: string
48+
scopes?: string[]
49+
}
50+
51+
interface TokenContent {
52+
exp: number
53+
}
54+
3555
interface GrantProperties {
3656
access_token?: Token
3757
refresh_token?: Token
3858
id_token?: Token
39-
expires_in?: string
59+
expires_in?: number
4060
token_type?: string
4161
}
4262

4363
interface Token {
64+
clientId?: string
65+
token?: string
66+
content?: TokenContent
4467
isExpired(): boolean
4568
hasRole(roleName: string): boolean
4669
hasApplicationRole(appName: string, roleName: string): boolean
@@ -201,12 +224,19 @@ declare namespace KeycloakConnect {
201224
}
202225

203226
interface AuthZRequest {
204-
audience?: string,
205-
response_mode?: string,
206-
claim_token?: string,
207-
claim_token_format?: string,
227+
audience?: string
228+
claim_token?: string
229+
claim_token_format?: string
208230
permissions: {id: string, scopes: string[]}[]
209231
}
232+
233+
interface AuthZRequestGrant extends AuthZRequest {
234+
response_mode: undefined
235+
}
236+
237+
interface AuthZRequestOther extends AuthZRequest {
238+
response_mode: 'decision' | 'permissions'
239+
}
210240

211241

212242
interface Keycloak {
@@ -409,7 +439,8 @@ declare namespace KeycloakConnect {
409439

410440
getGrantFromCode(code: string, req: express.Request, res: express.Response): Promise<Grant>
411441

412-
checkPermissions(authzRequest: AuthZRequest, request: express.Request, callback?: (json: any) => any): Promise<Grant>
442+
checkPermissions(authzRequest: AuthZRequestGrant, request: express.Request, callback?: (grant: Grant) => void): Promise<Grant>
443+
checkPermissions(authzRequest: AuthZRequestOther, request: express.Request, callback?: (json: any) => void): Promise<Object>
413444

414445
loginUrl(uuid: string, redirectUrl: string): string
415446

0 commit comments

Comments
 (0)