Title: Spec: did:nostr to WebID Resolution · Issue #42 · JavaScriptSolidServer/JavaScriptSolidServer · GitHub
Open Graph Title: Spec: did:nostr to WebID Resolution · Issue #42 · JavaScriptSolidServer/JavaScriptSolidServer
X Title: Spec: did:nostr to WebID Resolution · Issue #42 · JavaScriptSolidServer/JavaScriptSolidServer
Description: Overview This document specifies how JSS resolves did:nostr:
Open Graph Description: Overview This document specifies how JSS resolves did:nostr:
X Description: Overview This document specifies how JSS resolves did:nostr:<pubkey> identities to Solid WebIDs, enabling Nostr users to authenticate as their linked WebID. Specification Identity Linking A b...
Opengraph URL: https://github.com/JavaScriptSolidServer/JavaScriptSolidServer/issues/42
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Spec: did:nostr to WebID Resolution","articleBody":"## Overview\n\nThis document specifies how JSS resolves `did:nostr:\u003cpubkey>` identities to Solid WebIDs, enabling Nostr users to authenticate as their linked WebID.\n\n## Specification\n\n### Identity Linking\n\nA bidirectional link between Nostr and Solid identities:\n\n```\n┌─────────────────┐ alsoKnownAs ┌─────────────────┐\n│ Nostr Profile │ ──────────────────────────► │ Solid WebID │\n│ (kind 0) │ │ (profile/card)│\n│ │ ◄────────────────────────── │ │\n└─────────────────┘ owl:sameAs └─────────────────┘\n```\n\n### DID Document Structure\n\nThe DID resolver at `nostr.social/.well-known/did/nostr/\u003cpubkey>.json` returns:\n\n```json\n{\n \"@context\": [\"https://www.w3.org/ns/did/v1\", \"...\"],\n \"id\": \"did:nostr:\u003cpubkey>\",\n \"alsoKnownAs\": [\"https://solid.social/alice/profile/card#me\"],\n \"verificationMethod\": [...],\n \"profile\": { \"name\": \"alice\", ... }\n}\n```\n\n### WebID Profile Structure\n\nThe WebID at `https://solid.social/alice/profile/card#me` contains:\n\n```json\n{\n \"@context\": { \"owl\": \"http://www.w3.org/2002/07/owl#\", ... },\n \"@id\": \"#me\",\n \"@type\": \"foaf:Person\",\n \"foaf:name\": \"alice\",\n \"owl:sameAs\": \"did:nostr:\u003cpubkey>\"\n}\n```\n\n### Resolution Algorithm\n\n```\n1. Extract pubkey from NIP-98 event\n2. Verify Schnorr signature\n3. Fetch DID document:\n GET https://nostr.social/.well-known/did/nostr/\u003cpubkey>.json\n4. Extract WebID from:\n - alsoKnownAs[0] (preferred)\n - profile.webid\n - profile.sameAs\n5. Fetch WebID profile:\n GET \u003cwebid> Accept: application/ld+json\n6. Check for backlink:\n - owl:sameAs === did:nostr:\u003cpubkey>\n - sameAs === did:nostr:\u003cpubkey>\n7. If bidirectional: return WebID\n Else: return did:nostr:\u003cpubkey>\n```\n\n### Authentication Flow\n\n```\n┌────────┐ NIP-98 ┌────────┐ Fetch DID ┌─────────────┐\n│ Client │ ──────────────► │ JSS │ ──────────────► │ nostr.social│\n└────────┘ └────────┘ └─────────────┘\n │ │\n │ ◄──────────────────────────┘\n │ DID Doc + alsoKnownAs\n ▼\n ┌────────┐\n │ Fetch │\n │ WebID │\n └────────┘\n │\n ▼\n ┌────────────────────┐\n │ Verify owl:sameAs │\n │ matches did:nostr │\n └────────────────────┘\n │\n ┌────┴────┐\n │ Match? │\n └────┬────┘\n Yes │ No\n ▼ │ ▼\n Return │ Return\n WebID │ did:nostr\n```\n\n---\n\n## Implementation Recipe\n\n### Step 1: Create Nostr Keypair\n\n```javascript\nimport { generateSecretKey, getPublicKey } from 'nostr-tools';\n\nconst sk = generateSecretKey();\nconst pubkey = getPublicKey(sk);\nconsole.log('Pubkey:', pubkey);\n// e.g., 3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d\n```\n\n### Step 2: Create Solid Pod\n\n```bash\ncurl -X POST https://solid.social/.pods \\\n -H \"Content-Type: application/json\" \\\n -d '{\"name\": \"alice\", \"email\": \"alice@example.com\", \"password\": \"secret\"}'\n```\n\nResponse:\n```json\n{\n \"webId\": \"https://alice.solid.social/profile/card#me\",\n \"podUri\": \"https://alice.solid.social/\"\n}\n```\n\n### Step 3: Add alsoKnownAs to Nostr Profile\n\nPublish a kind 0 event with your WebID:\n\n```javascript\nimport { finalizeEvent, Relay } from 'nostr-tools';\n\nconst event = finalizeEvent({\n kind: 0,\n created_at: Math.floor(Date.now() / 1000),\n tags: [],\n content: JSON.stringify({\n name: 'alice',\n about: 'Solid + Nostr user',\n alsoKnownAs: ['https://alice.solid.social/profile/card#me']\n })\n}, sk);\n\n// Publish to relays\nconst relay = await Relay.connect('wss://relay.damus.io');\nawait relay.publish(event);\n```\n\n### Step 4: Add owl:sameAs to WebID Profile\n\nPATCH the WebID profile:\n\n```bash\ncurl -X PATCH https://alice.solid.social/profile/card \\\n -H \"Authorization: Bearer \u003ctoken>\" \\\n -H \"Content-Type: text/n3\" \\\n -d '@prefix solid: \u003chttp://www.w3.org/ns/solid/terms#>.\n @prefix owl: \u003chttp://www.w3.org/2002/07/owl#>.\n _:patch a solid:InsertDeletePatch;\n solid:inserts { \n \u003c#me> owl:sameAs \u003cdid:nostr:YOUR_PUBKEY_HERE> .\n }.'\n```\n\n### Step 5: Wait for DID Indexing\n\nnostr.social indexes Nostr profiles periodically. Check:\n\n```bash\ncurl https://nostr.social/.well-known/did/nostr/\u003cpubkey>.json | jq .alsoKnownAs\n```\n\n### Step 6: Authenticate with NIP-98\n\n```javascript\nimport { finalizeEvent } from 'nostr-tools';\n\n// Create NIP-98 auth event\nconst authEvent = finalizeEvent({\n kind: 27235,\n created_at: Math.floor(Date.now() / 1000),\n tags: [\n ['u', 'https://alice.solid.social/private/data.json'],\n ['method', 'GET']\n ],\n content: ''\n}, sk);\n\n// Make authenticated request\nconst token = btoa(JSON.stringify(authEvent));\nconst res = await fetch('https://alice.solid.social/private/data.json', {\n headers: { 'Authorization': `Nostr ${token}` }\n});\n\n// JSS resolves did:nostr → WebID automatically\n// You're now authenticated as https://alice.solid.social/profile/card#me\n```\n\n---\n\n## Caching\n\n- DID resolution results are cached for 5 minutes\n- Cache key: lowercase pubkey\n- Failed lookups are also cached to prevent hammering\n\n## Error Handling\n\n| Scenario | Result |\n|----------|--------|\n| Invalid pubkey | Return null |\n| DID doc not found | Return null, cache miss |\n| No alsoKnownAs | Return null |\n| WebID fetch fails | Return null |\n| No owl:sameAs backlink | Return null |\n| Bidirectional link valid | Return WebID |\n\nWhen resolution returns null, authentication falls back to `did:nostr:\u003cpubkey>`.\n\n## Security Considerations\n\n1. **Bidirectional proof required** - Prevents claiming arbitrary WebIDs\n2. **Signature verification first** - DID resolution only after valid NIP-98\n3. **HTTPS only** - WebID must be HTTPS\n4. **Cache prevents abuse** - Rate limits external fetches\n\n## Related\n\n- [NIP-98](https://github.com/nostr-protocol/nips/blob/master/98.md) - HTTP Auth\n- [nostr-beacon](https://github.com/nostr-labs/nostr-beacon) - DID resolver\n- [DID Core](https://www.w3.org/TR/did-core/) - W3C DID specification\n- `src/auth/did-nostr.js` - JSS implementation\n- `src/auth/nostr.js` - NIP-98 verification","author":{"url":"https://github.com/melvincarvalho","@type":"Person","name":"melvincarvalho"},"datePublished":"2026-01-03T23:52:07Z","url":"https://github.com/JavaScriptSolidServer/JavaScriptSolidServer/issues/42"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:336485f4-f6f6-87fa-d996-f78b607288f9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9288:3A1AD5:29C991C:37422A5:6B038BC7 |
| html-safe-nonce | 23cb440c79771f5d5b5c38fa211c8eab8e9bde96675cf272892863e1e338a89c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5Mjg4OjNBMUFENToyOUM5OTFDOjM3NDIyQTU6NkIwMzhCQzciLCJ2aXNpdG9yX2lkIjoiNDM0Mjc0ODU4MTMzMDEyNzgxNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 481bda83ddc48a2c70a67dc52c2168d8205074aee49a2f7f77c63fdc09bb8bb3 |
| hovercard-subject-tag | issue:3778602930 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/JavaScriptSolidServer/JavaScriptSolidServer/42/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3237ebd8e6a7241368ae6cfd96f64e4cef828d2015891e7fac09c21120ef9cdf/JavaScriptSolidServer/JavaScriptSolidServer/issues/42 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3237ebd8e6a7241368ae6cfd96f64e4cef828d2015891e7fac09c21120ef9cdf/JavaScriptSolidServer/JavaScriptSolidServer/issues/42 |
| og:image:alt | Overview This document specifies how JSS resolves did:nostr: |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | melvincarvalho |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/JavaScriptSolidServer/JavaScriptSolidServer git https://github.com/JavaScriptSolidServer/JavaScriptSolidServer.git |
| octolytics-dimension-user_id | 205442424 |
| octolytics-dimension-user_login | JavaScriptSolidServer |
| octolytics-dimension-repository_id | 958025407 |
| octolytics-dimension-repository_nwo | JavaScriptSolidServer/JavaScriptSolidServer |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 958025407 |
| octolytics-dimension-repository_network_root_nwo | JavaScriptSolidServer/JavaScriptSolidServer |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width