Fix World ID simulator sandbox: identity selector, verifier config, staging credentials - #14
Fix World ID simulator sandbox: identity selector, verifier config, staging credentials#14juguelio wants to merge 1 commit into
Conversation
…taging credentials Enrollment could not be completed against the World ID simulator. Reproduced locally end to end; three independent defects: 1. The simulator-link rewrite never ran. `rewriteSimulatorLinks` queries only `document`, but the IDKit widget renders its "Testing in staging?" callout inside a shadow root, so the selector matched nothing and the rewrite to `/select-id` silently did nothing. The callout therefore opened the simulator's *default* identity instead of its identity selector, which surfaces as "it returns a different user" and as spurious nullifier-already-used (409) errors, because that default identity has already opened a policy. Fixed by walking open shadow roots as well. 2. Env-configured deployments omitted `policyHumanVerifier`. `RiskaEnrollmentHome` discards a policy-human authorization whose verifier does not match the configured one, and a missing verifier is falsy, so it counts as a mismatch: every verified user is bounced back to the identity step. `readDeploymentEnv` now also reads `RISKA_WORLDCHAIN[_SEPOLIA]_POLICY_HUMAN_VERIFIER`. Deployments configured from the committed JSON are unaffected. 3. World ID apps are registered per environment, and the simulator only accepts requests from a staging app; a production app id yields a production request regardless of the `environment` flag passed to IDKit. Allow a staging app id, RP id and RP signing key selected by deployment (`NEXT_PUBLIC_WORLD_APP_ID_STAGING`, `WORLD_ID_RP_ID_STAGING`, `RP_SIGNING_KEY_STAGING`), each falling back to the existing single value, so current setups are unchanged. `/api/identity/rp-signature` now receives the deployment so it can sign with the matching RP. Verified: with (1) applied, the callout resolves to `simulator.worldcoin.org/select-id?connect_url=...` and the identity selector appears. Server-side the flow reaches `policy human authorization issued` (HTTP 200) with a v3 Orb proof on the testnet deployment. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Someone is attempting to deploy a commit to the p2pdevmedia's projects Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9adb2d18ce
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const env = stagingEnv | ||
| ? { WORLD_ID_RP_ID: stagingEnv.WORLD_ID_RP_ID_STAGING, RP_SIGNING_KEY: stagingEnv.RP_SIGNING_KEY_STAGING } | ||
| : requiredEnvironment(["WORLD_ID_RP_ID", "RP_SIGNING_KEY"]); |
There was a problem hiding this comment.
Keep staging RP ID consistent through verification
When TEST passes deployment: "testnet" and these new staging env vars are configured, this route now returns rp_context.rp_id from WORLD_ID_RP_ID_STAGING, but /api/identity/verify-policy-human still builds policyHumanEnvironment() with only WORLD_ID_RP_ID and posts the proof to https://developer.world.org/api/v4/verify/${serverEnvironment.rpId}. That means the simulator proof is issued for the staging RP but verified against the production RP, so the World ID verification step fails for the exact staging-credential setup this change introduces; the verification env needs the same staging RP selection/fallback.
Useful? React with 👍 / 👎.
Debuggeando por qué no se podía completar el alta contra el simulador de World ID, encontré tres problemas independientes. Reproduje el flujo completo en local sobre
a5b0b13.Tu commit
6d38d7a(protocolo v3 para testnet) era correcto y necesario — con eso el server ya llega apolicy human authorization issued(HTTP 200) con una prueba v3 Orb. Lo que sigue abajo es lo que quedaba después de eso.1. El rewrite del link al simulador nunca corría
rewriteSimulatorLinksconsulta solodocument, pero el widget de IDKit renderiza su callout "Testing in staging?" dentro de un shadow root. El selector no matcheaba nada y la reescritura a/select-idno hacía nada, en silencio.Consecuencia: el callout abre la identidad por defecto del simulador en vez del selector de identidades. Eso se manifiesta como "me devuelve otro usuario" y como errores 409 de nullifier ya usado — porque esa identidad por defecto ya abrió una póliza.
Verificado: antes el href quedaba en
simulator.worldcoin.org/, ahora resuelve asimulator.worldcoin.org/select-id?connect_url=...y aparece el selector.2. Los deployments configurados por env no exponían
policyHumanVerifierRiskaEnrollmentHomedescarta la autorización si el verifier no coincide con el configurado:readDeploymentEnvno devolvíapolicyHumanVerifier, yundefinedes falsy → cuenta como mismatch → todo usuario verificado vuelve al paso de identidad. Ahora leeRISKA_WORLDCHAIN[_SEPOLIA]_POLICY_HUMAN_VERIFIER.Los deployments que salen del JSON committeado no se ven afectados (ese camino ya lo exponía). Dejé la precedencia
file ?? envintacta.3. Credenciales de World ID por entorno
Los apps de World ID se registran por entorno, y el simulador solo acepta requests de un app de staging: un app id de producción produce un request de producción sin importar el
environmentque se le pase a IDKit.Agregué
NEXT_PUBLIC_WORLD_APP_ID_STAGING,WORLD_ID_RP_ID_STAGINGyRP_SIGNING_KEY_STAGING, seleccionados por deployment, cada uno con fallback al valor único actual — así nada cambia si no se configuran./api/identity/rp-signatureahora recibe eldeploymentpara firmar con el RP correspondiente.Dos cosas que no pude verificar y necesito de tu lado
rp_06de503e374550e8ya cubre staging, quizá alcance con lo demás.POLICY_HUMAN_SIGNING_KEYque corresponde al verifier desplegado (0xDbe839…). Firmando con una clave de prueba, la app descarta la autorización por el chequeo del punto 2 — que es el comportamiento correcto.Fuera de este PR, a propósito
verify-policy-human-handler: hoy el mensaje "World ID proof of human is missing or is not bound to the connected wallet" mezcla tres fallas distintas (protocolo equivocado, signal que no coincide, identidad ya usada). Fue lo que más tiempo hizo perder acá. La tengo escrita si te sirve.