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

Function makeLocalIdentityLayer

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

Source from the content-addressed store, hash-verified

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

Callers 2

authenticateFunction · 0.90
makeLocalApiHandlerFunction · 0.90

Calls 3

safeEqualFunction · 0.90
bearerTokenFunction · 0.70

Tested by 1

authenticateFunction · 0.72