Skip to content

feat: machine-agent-identity grants and admin surface - #38

Merged
lakhansamani merged 2 commits into
mainfrom
feat/mai-token-grants-admin
Jul 9, 2026
Merged

lakhansamani merged 2 commits into
mainfrom
feat/mai-token-grants-admin

Conversation

@lakhansamani

Copy link
Copy Markdown
Contributor

What

Brings the SDK up to date with the server's machine-agent-identity program.

getToken

  • client_credentials grant: client_secret, scope, secretless client_assertion(_type)
  • RFC 8693 token exchange: subject_token(_type), actor_token(_type), resource
  • Only set params are serialized; code/code_verifier only sent for authorization_code
  • JSDoc warning: machine grants are server-side-only — never ship client_secret in a browser bundle
  • New exported constants: GRANT_TYPE_*, TOKEN_TYPE_*, CLIENT_ASSERTION_TYPE_JWT_BEARER

AuthorizerAdmin — 27 new methods

  • Clients + trusted issuers: graphql + rest (grpc-gateway routes verified against server admin.proto)
  • Organizations / org members / org OIDC + SAML connections / SCIM: graphql-only (no proto RPCs server-side), erroring clearly over rest — same pattern as adminSignup/generateJWTKeys
  • Full request/response types mirroring schema.graphqls; secret-shown-once semantics documented on CreateClientResponse / SCIM token rotation

Testing

  • npm run build (tsup ESM/CJS/DTS) + npm run lint pass
  • New __test__/tokenGrants.test.ts: 11 unit tests (mocked fetch) asserting exact /oauth/token bodies for both grants, secretless assertion, subject_token validation, refresh regression, OAuth error surfacing, admin graphql/REST dispatch + unwrap, graphql-only rejection over rest
  • Docker integration suites unchanged (need a published server image with the MAI surface)

- getToken: client_credentials (secret or RFC 7523 client_assertion)
  and RFC 8693 token exchange (subject/actor token, RFC 8707 resource);
  only set params are sent. Server-side-only warning in JSDoc.
- AuthorizerAdmin: clients, trusted issuers (graphql + rest), and
  graphql-only organizations, org members, org OIDC/SAML connections,
  SCIM endpoints — no grpc-gateway routes exist for those yet.
- export grant-type / token-type / client-assertion-type constants
- unit tests assert exact request bodies with mocked fetch
RFC 6749 token requests must be form-encoded. The server binds most
params from JSON too, but reads the RFC 8707 resource param only via
PostForm, so token exchange silently failed with a JSON body. Security
review caught this; mocked tests now assert the content type.
@lakhansamani
lakhansamani merged commit cacf75c into main Jul 9, 2026
2 checks passed
@lakhansamani
lakhansamani deleted the feat/mai-token-grants-admin branch July 9, 2026 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant