MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / checkAppBoot

Method checkAppBoot

kms/auth-simple/index.ts:152–196  ·  view source on GitHub ↗
(bootInfo: BootInfo, config: AuthConfig, deviceId: string)

Source from the content-addressed store, hash-verified

150 }
151
152 private checkAppBoot(bootInfo: BootInfo, config: AuthConfig, deviceId: string): BootResponse {
153 const appId = normalizeHex(bootInfo.appId);
154 const composeHash = normalizeHex(bootInfo.composeHash);
155
156 // check app exists
157 const appConfig = Object.entries(config.apps).find(
158 ([id]) => normalizeHex(id) === appId
159 )?.[1];
160
161 if (!appConfig) {
162 return {
163 isAllowed: false,
164 reason: 'app not registered',
165 gatewayAppId: config.gatewayAppId
166 };
167 }
168
169 // check compose hash
170 const allowedHashes = appConfig.composeHashes.map(normalizeHex);
171 if (!allowedHashes.includes(composeHash)) {
172 return {
173 isAllowed: false,
174 reason: 'compose hash not allowed',
175 gatewayAppId: config.gatewayAppId
176 };
177 }
178
179 // check device ID
180 if (!appConfig.allowAnyDevice) {
181 const allowedDevices = appConfig.devices.map(normalizeHex);
182 if (allowedDevices.length > 0 && !allowedDevices.includes(deviceId)) {
183 return {
184 isAllowed: false,
185 reason: 'app is not allowed to boot on this device',
186 gatewayAppId: config.gatewayAppId
187 };
188 }
189 }
190
191 return {
192 isAllowed: true,
193 reason: '',
194 gatewayAppId: config.gatewayAppId
195 };
196 }
197
198 async getGatewayAppId(): Promise<string> {
199 return this.loadConfig().gatewayAppId;

Callers 1

checkBootMethod · 0.95

Calls 1

normalizeHexFunction · 0.85

Tested by

no test coverage detected