Skip to content

Commit 38074f8

Browse files
Adding the inference grant (#512)
1 parent 7b6808a commit 38074f8

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

packages/livekit-server-sdk/src/AccessToken.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// SPDX-License-Identifier: Apache-2.0
44
import type { RoomConfiguration } from '@livekit/protocol';
55
import * as jose from 'jose';
6-
import type { ClaimGrants, SIPGrant, VideoGrant } from './grants.js';
6+
import type { ClaimGrants, InferenceGrant, SIPGrant, VideoGrant } from './grants.js';
77
import { claimsToJwtPayload } from './grants.js';
88

99
// 6 hours
@@ -102,6 +102,14 @@ export class AccessToken {
102102
this.grants.video = { ...(this.grants.video ?? {}), ...grant };
103103
}
104104

105+
/**
106+
* Adds an inference grant to this token.
107+
* @param grant -
108+
*/
109+
addInferenceGrant(grant: InferenceGrant) {
110+
this.grants.inference = { ...(this.grants.inference ?? {}), ...grant };
111+
}
112+
105113
/**
106114
* Adds a SIP grant to this token.
107115
* @param grant -

packages/livekit-server-sdk/src/grants.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,17 @@ export interface SIPGrant {
103103
call?: boolean;
104104
}
105105

106+
export interface InferenceGrant {
107+
/** perform inference */
108+
perform?: boolean;
109+
}
110+
106111
/** @internal */
107112
export interface ClaimGrants extends JWTPayload {
108113
name?: string;
109114
video?: VideoGrant;
110115
sip?: SIPGrant;
116+
inference?: InferenceGrant;
111117
kind?: string;
112118
metadata?: string;
113119
attributes?: Record<string, string>;

0 commit comments

Comments
 (0)