Add identity endpoint

This commit is contained in:
Jon Staab
2026-03-26 16:10:24 -07:00
parent 9da5e027a7
commit a2f9ca9688
9 changed files with 129 additions and 38 deletions
+6
View File
@@ -16,6 +16,12 @@ The api allows the frontend to access the database. Most endpoints are authentic
- Uses `makeAuth` to obtain a NIP 98 authorization header.
- Calls the backend api and returns the decoded json or throws an `ApiError`.
## `function getIdentity()`
- Calls `GET /identity`
- Requires authentication
- Returns `{ pubkey, is_admin, is_tenant }` for the authorized user
## Plan methods
## `function listPlans()`
+10 -10
View File
@@ -1,18 +1,24 @@
Hooks wrap data access and mutations so pages/components do not call API methods directly.
## `function useIdentity(source)`
- Calls `getIdentity()` for the active pubkey
- Caches identity in module memory (not localStorage)
- Returns a Solid `createResource` tuple
## `function useTenant()`
- Uses `createTenant()` then `getTenant(pubkey)` for the active account
- Uses `getTenant(pubkey)` for the active account
- Returns a Solid `createResource` tuple
## `function useTenantRelays()`
- Uses `createTenant()` then `listTenantRelays(pubkey)` for the active account
- Uses `listTenantRelays(pubkey)` for the active account
- Returns a Solid `createResource` tuple
## `function useTenantInvoices()`
- Uses `createTenant()` then `listTenantInvoices(pubkey)` for the active account
- Uses `listTenantInvoices(pubkey)` for the active account
- Returns a Solid `createResource` tuple
## `function useRelay(relayId)`
@@ -35,15 +41,9 @@ Hooks wrap data access and mutations so pages/components do not call API methods
- Uses `getTenant(pubkey)` and `listTenantRelays(pubkey)`
- Returns a Solid `createResource` tuple with `{ tenant, relays }`
## `function useAdminCheck(source)`
- Uses `listTenants()` as an admin capability check
- Returns `{ is_admin: true }` on success
- Returns `{ is_admin: false }` on `403`
## `function createRelayForActiveTenant(input)`
- Uses `createTenant()` then `createRelay({ tenant: activePubkey, ...input })`
- Uses `createRelay({ tenant: activePubkey, ...input })`
## `function updateActiveTenantBilling(nwc_url)`