@openjiuwen/relay-api-server-contracts
v0.1.6
Published
Plugin contracts for OfficeClaw extensions: auth, storage, identity.
Readme
@openjiuwen/relay-api-server-contracts
Plugin contracts for OfficeClaw extensions. Auth is the first extension point.
Install
pnpm add @openjiuwen/relay-api-server-contractsAuth Provider Contract
import type { AuthProvider } from '@openjiuwen/relay-api-server-contracts/auth';
const myProvider: AuthProvider = {
id: 'my-provider',
displayName: 'My Provider',
presentation: {
mode: 'form',
fields: [
{ name: 'username', label: 'Username', type: 'text', required: true },
{ name: 'password', label: 'Password', type: 'password', required: true },
],
submitLabel: 'Sign In',
},
async authenticate(input) {
// Your authentication logic
return {
success: true,
principal: {
userId: input.credentials.username as string,
displayName: 'User',
expiresAt: null,
},
};
},
};
export default myProvider;Runtime Wiring
Install your auth provider package into the app, then point the auth runtime at it:
CAT_CAFE_AUTH_PROVIDER=my-provider
CAT_CAFE_AUTH_PROVIDER_MODULES=@examples/my-auth-providerThe platform will:
- import the module listed in
CAT_CAFE_AUTH_PROVIDER_MODULES - collect exported auth providers
- activate the provider whose
idmatchesCAT_CAFE_AUTH_PROVIDER
See Build an Auth Provider for the full walkthrough.
