MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / makeLocalIdentityLayer

Function makeLocalIdentityLayer

apps/local/src/identity.ts:74–85  ·  view source on GitHub ↗
(token: string)

Source from the content-addressed store, hash-verified

72 * it once at boot like self-host's.
73 */
74export const makeLocalIdentityLayer = (token: string): Layer.Layer<IdentityProvider> =>
75 Layer.succeed(IdentityProvider)(
76 IdentityProvider.of({
77 authenticate: (request) => {
78 if (isUnauthenticatedCallback(request)) return Effect.succeed(LOCAL_PRINCIPAL);
79 const presented = bearerToken(request.headers);
80 return presented !== undefined && safeEqual(presented, token)
81 ? Effect.succeed(LOCAL_PRINCIPAL)
82 : Effect.fail(new Unauthorized());
83 },
84 }),
85 );

Callers 2

authenticateFunction · 0.90
makeLocalApiHandlerFunction · 0.90

Calls 3

safeEqualFunction · 0.90
bearerTokenFunction · 0.70

Tested by 1

authenticateFunction · 0.72