MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / loadCredentials

Method loadCredentials

packages/cloud/src/WebAuthService.ts:218–242  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

216 }
217
218 private async loadCredentials(): Promise<AuthCredentials | null> {
219 const credentialsJson = await this.context.secrets.get(this.authCredentialsKey)
220 if (!credentialsJson) return null
221
222 try {
223 const parsedJson = JSON.parse(credentialsJson)
224 const credentials = authCredentialsSchema.parse(parsedJson)
225
226 // Migration: If no organizationId but we have userInfo, add it
227 if (credentials.organizationId === undefined && this.userInfo?.organizationId) {
228 credentials.organizationId = this.userInfo.organizationId
229 await this.storeCredentials(credentials)
230 this.log("[auth] Migrated credentials with organizationId")
231 }
232
233 return credentials
234 } catch (error) {
235 if (error instanceof z.ZodError) {
236 this.log("[auth] Invalid credentials format:", error.errors)
237 } else {
238 this.log("[auth] Failed to parse stored credentials:", error)
239 }
240 return null
241 }
242 }
243
244 private async clearCredentials(): Promise<void> {
245 await this.context.secrets.delete(this.authCredentialsKey)

Callers 1

Calls 4

storeCredentialsMethod · 0.95
parseMethod · 0.80
getMethod · 0.65
logMethod · 0.65

Tested by

no test coverage detected