Auth API
mero.auth (AuthApi) is the node’s authentication surface — token issuance and
the management of root keys and client keys. It’s a Sendable struct over
the shared HttpClient; methods are
async throws unless noted.
Tokens & session
Section titled “Tokens & session”| Method | Endpoint |
|---|---|
getHealth() -> HealthResponse |
GET /auth/health |
getIdentity() -> IdentityResponse |
GET /admin/identity |
getProviders() -> ProvidersResponse |
GET /auth/providers |
generateTokens(_ request: TokenRequest) -> TokenResponse |
POST /auth/token |
refreshToken(_ request: RefreshTokenRequest) -> TokenResponse |
POST /auth/refresh |
generateMockTokens(_ request: MockTokenRequest) -> TokenResponse |
POST /auth/mock-token (dev) |
validateToken(_ token: String) -> TokenValidation |
HEAD /auth/validate — async, not throws |
revokeTokens(_ request: RevokeTokenRequest) -> RevokeTokenResponse |
POST /admin/revoke |
logout(_ request: LogoutRequest) -> LogoutResponse |
POST /auth/logout (core rc.83) |
await mero.logout() calls logout with the stored refresh token, then clears
the session locally. The server half is best-effort: an unreachable node, an
older node without the route, or a 401 for a token the node already refuses
never keeps the caller logged in.
Root keys
Section titled “Root keys”| Method | Endpoint |
|---|---|
listRootKeys() -> [RootKey] |
GET /admin/keys |
createRootKey(_ request: CreateKeyRequest) -> CreateKeyResponse |
POST /admin/keys |
deleteRootKey(_ keyId: String) -> DeleteKeyResponse |
DELETE /admin/keys/{keyId} |
getKeyPermissions(_ keyId: String) -> PermissionResponse |
GET /admin/keys/{keyId}/permissions |
updateKeyPermissions(_ keyId: String, changes: UpdateKeyPermissionsRequest) -> PermissionResponse |
PUT /admin/keys/{keyId}/permissions |
updateKeyPermissions sends an { add, remove } delta of permission strings, not
a replacement.
Client keys
Section titled “Client keys”| Method | Endpoint |
|---|---|
listClientKeys() -> [ClientKey] |
GET /admin/keys/clients |
generateClientKey(_ request: GenerateClientKeyRequest) -> TokenResponse |
POST /admin/client-key |
deleteClientKey(keyId: String, clientId: String) -> DeleteClientResponse |
DELETE /admin/keys/{keyId}/clients/{clientId} |
GenerateClientKeyRequest takes applicationId (binds the key to one app) and
ttlSecs since rc.83. A client key is narrower than the session that mints it:
- It expires.
ttlSecsdefaults to 30 days and there is no non-expiring key. Its access token lives 15 minutes and its refresh token 7 days. keys:*permissions are never grantable to it, andadminonly when it binds no context (nocontextId, nocontextIdentity). Anything else is a400.- It acts only on the contexts and groups it is bound to. Elsewhere it gets a
403, including on JSON-RPC and SSE subscribe.
Key types
Section titled “Key types”struct TokenResponse: Codable, Sendable { let data: Payload // { accessToken, refreshToken, error? } let error: String?}
struct IdentityResponse: Codable, Sendable { let service: String let version: String let authenticationMode: String // wire: authentication_mode let providers: [String]}
struct RootKey: Codable, Sendable { let keyId, publicKey, authMethod: String let createdAt: Int let revokedAt: Int? let permissions: [String]}
struct ClientKey: Codable, Sendable { let clientId, rootKeyId, name: String let permissions: [String] let createdAt: Int let revokedAt: Int? let isValid: Bool}
struct TokenRequest: Codable, Sendable { // built for you by mero.authenticate() let authMethod, publicKey, clientName: String let permissions: [String]? let timestamp: Int let providerData: [String: JSONValue]}See AuthTypes.swift
for the complete set.