MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / buildAuthHandler

Function buildAuthHandler

packages/kaos/src/ssh.ts:186–211  ·  view source on GitHub ↗
(
  username: string,
  privateKeys: readonly (Buffer | string)[],
  password?: string,
)

Source from the content-addressed store, hash-verified

184}
185
186function buildAuthHandler(
187 username: string,
188 privateKeys: readonly (Buffer | string)[],
189 password?: string,
190): ConnectConfig['authHandler'] {
191 const authQueue: AnyAuthMethod[] = privateKeys.map((key) => ({
192 key,
193 type: 'publickey',
194 username,
195 }));
196 if (password !== undefined) {
197 authQueue.push({
198 password,
199 type: 'password',
200 username,
201 });
202 }
203
204 let index = 0;
205 return (_authsLeft, _partialSuccess, next) => {
206 const nextAuth = authQueue[index];
207 index += 1;
208 const nextWithFalse = next as (auth: AnyAuthMethod | false) => void;
209 nextWithFalse(nextAuth ?? false);
210 };
211}
212
213// ── SSH process ────────────────────────────────────────────────────────
214

Callers 1

createMethod · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected