Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PCP-299: Add binding to pp-issuer using handlers #81

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lbaquerofierro
Copy link
Contributor

Use RCP-fetch, pp-proxy caller would look something like:

export default {
  async fetch(request: Request, env: Bindings, ctx: ExecutionContext) {
    const router = new Router(VALID_PATHS);

    router
      .get("/.well-known/private-token-issuer-directory", testRCPBinding);

    // Await the response
    let res = await router.handle(
      request as Request<Bindings, IncomingRequestCfProperties<unknown>>,
      env,
      ctx
    );

    return res;
  },
};

async function testRCPBinding(context: Context, request: Request): Promise<Response> {
  const res = await context.env.PRIVACYPASS_ISSUER.tokenDirectory(request, "US-PST");
  const headers = res.responseHeaders;
  const body = JSON.stringify(res.responseBody);
  return new Response(body, { headers });
}

pp-issuer wrangler


[[env.dev.services]]
binding = "PRIVACYPASS_ISSUER"
service = "privacypass-issuer-demo-dev" # change to new mallard issuer
entrypoint = "IssuerHandler"

Note PRIVACYPASS_ISSUER and IssuerHandler are defined in pp-issuer. We can either duplicate the code to define it or add the service as a binding in pp proxy and define the type for IssuerHandler which is basically all the handler functions in pp-issuer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant