diff --git a/include/wolfram/identity.h b/include/wolfram/identity.h index 7f57a00..7e9f247 100644 --- a/include/wolfram/identity.h +++ b/include/wolfram/identity.h @@ -81,6 +81,21 @@ void wf_did_cache_clear(void); wf_status wf_did_resolve(wf_xrpc_client *client, const char *did, wf_did_document *out); +/** + * Resolve a DID the same way as wf_did_resolve (same cache, same did:plc / + * did:web dispatch), but return the full, untrimmed DID document as raw + * JSON instead of the fields wf_did_document keeps. Use this when a caller + * needs alsoKnownAs, the full verificationMethod/service arrays, or any + * other field wf_did_document does not carry. + * + * `client` is used purely as an HTTP transport; see wf_did_resolve. + * + * On WF_OK, *out_json is heap-allocated and owned by the caller; free with + * plain free(). + */ +wf_status wf_did_resolve_raw(wf_xrpc_client *client, const char *did, + char **out_json); + /** * Resolve a known atproto service by its canonical ID and expected type. * Unknown service types return WF_ERR_NOT_FOUND; use the by-ID API below for diff --git a/src/identity/identity.c b/src/identity/identity.c index 83d886d..477a265 100644 --- a/src/identity/identity.c +++ b/src/identity/identity.c @@ -820,6 +820,23 @@ wf_status wf_did_resolve(wf_xrpc_client *client, const char *did, return status; } +wf_status wf_did_resolve_raw(wf_xrpc_client *client, const char *did, + char **out_json) { + if (!client || !did || !out_json) return WF_ERR_INVALID_ARG; + *out_json = NULL; + + cJSON *root = NULL; + wf_status status = did_fetch_document(client, did, &root); + if (status != WF_OK) return status; + + char *json = cJSON_PrintUnformatted(root); + cJSON_Delete(root); + if (!json) return WF_ERR_ALLOC; + + *out_json = json; + return WF_OK; +} + wf_status wf_did_document_parse(const char *json, size_t json_len, wf_did_document *out) { if (!json || !out) return WF_ERR_INVALID_ARG;