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

πŸ› Bug Report β€” Runtime APIs: Node Crypto X509Certificate Support #1304

Closed
robertlong opened this issue Oct 12, 2023 · 2 comments
Closed

Comments

@robertlong
Copy link

I'm currently using Cloudflare Workers with the Apple App Store Server API. This api uses JWS with X509 verification. In order to parse and verify responses from the server we need to be able to use the nodejs X509Certificate class.

Here's an example of it in use in the app-store-server-api nodejs library: https://github.com/agisboye/app-store-server-api/blob/main/src/Decoding.ts#L79

@fhanau
Copy link
Collaborator

fhanau commented Aug 19, 2024

This was implemented in #2335 and should work now. Feel free to reopen if you encounter any issues.

@fhanau fhanau closed this as completed Aug 19, 2024
@imWildCat
Copy link

imWildCat commented Oct 27, 2024

sorry, we're still using this error on latest runtime node-compact

Is import ... from 'crypto' support or it must be prefixed with node:?

import { NextRequest, NextResponse } from 'next/server';
import { 
  decodeNotificationPayload, 
  isDecodedNotificationDataPayload, 
  isDecodedNotificationSummaryPayload 
} from 'app-store-server-api';
import { appStoreNotifications } from '@/db/schema';
import { drizzleOnWorkers } from '@/db/drizzle_from_env';
import crypto from 'node:crypto';

const APP_BUNDLE_ID = process.env.APP_BUNDLE_ID!;

export const runtime = 'edge';

export async function POST(request: NextRequest) {
  try {
    const { signedPayload } = await request.json() as { signedPayload: string };
    console.log("πŸš€ ~ POST ~ signedPayload:", signedPayload, 'crypto:', crypto, crypto.X509Certificate) // the last element is undefined.


    
    // Decode and verify the notification payload
    const payload = await decodeNotificationPayload(signedPayload); // error here
    console.log("πŸš€ ~ POST ~ payload:", payload)
compatibility_date = "2024-10-22"
compatibility_flags = ["nodejs_compat"]
pages_build_output_dir = ".vercel/output/static"

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

No branches or pull requests

4 participants