MCPcopy Create free account
hub / github.com/cloudflare/serverless-registry / encodeState

Function encodeState

src/registry/r2.ts:186–198  ·  view source on GitHub ↗
(state: State, env: Env)

Source from the content-addressed store, hash-verified

184}
185
186export async function encodeState(state: State, env: Env): Promise<{ jwt: string; hash: string }> {
187 const jwtSignature = await jwt.sign(
188 { ...state, exp: Math.floor(Date.now() / 1000) + 60 * 60 * 2 },
189 // TODO: Remove JWT encoding and use something faster like just plain bas64
190 "secret-doesnt-matter-anymore-we-are-using-jwt-for-encoding-state",
191 {
192 algorithm: "HS256",
193 },
194 );
195
196 await env.REGISTRY.put(getRegistryUploadsPath(state), JSON.stringify({ jwt: jwtSignature }));
197 return { jwt: jwtSignature, hash: await getSHA256(jwtSignature, "") };
198}
199
200export const symlinkHeader = "X-Serverless-Registry-Symlink";
201

Callers 2

startUploadMethod · 0.85
uploadChunkMethod · 0.85

Calls 2

getSHA256Function · 0.90
getRegistryUploadsPathFunction · 0.85

Tested by

no test coverage detected