Microsoft

@crvouga/mockingbird-service-microsoft

Stateful Microsoft public vendor API emulator with native namespaces, checkpoints and test controls.

Parity: Vendor API workflows compared with the pinned Emulate package oracleIdentity12 of 12 operationsIn-process fetchNode servermockingbird-microsoft
$
npm install -D @crvouga/mockingbird-service-microsoft

Playground

Requests go to the real emulator running in this tab. State persists across requests, and the journal shows what it received. A green dot marks operations whose sample succeeds as-is; others need ids from earlier responses.

Loads the real @crvouga/mockingbird-service-microsoft into this tab on first send
https://login.microsoftonline.com

Send a request to see the emulator's response.

Operations

12 of 12 operations in the vendored contract are emulated.

MethodPathOperationStatus
GET/.well-known/openid-configurationGET /.well-known/openid-configurationGET /.well-known/openid-configuration
GET/{tenant}/v2.0/.well-known/openid-configurationGET /:tenant/v2.0/.well-known/openid-configurationGET /:tenant/v2.0/.well-known/openid-configuration
GET/discovery/v2.0/keysGET /discovery/v2.0/keysGET /discovery/v2.0/keys
GET/oauth2/v2.0/authorizeGET /oauth2/v2.0/authorizeGET /oauth2/v2.0/authorize
GET/oauth2/v2.0/logoutGET /oauth2/v2.0/logoutGET /oauth2/v2.0/logout
GET/oidc/userinfoGET /oidc/userinfoGET /oidc/userinfo
GET/v1.0/meGET /v1.0/meGET /v1.0/me
GET/v1.0/users/{id}GET /v1.0/users/:idGET /v1.0/users/:id
POST/{tenant}/oauth2/tokenPOST /:tenant/oauth2/tokenPOST /:tenant/oauth2/token
POST/oauth2/v2.0/authorize/callbackPOST /oauth2/v2.0/authorize/callbackPOST /oauth2/v2.0/authorize/callback
POST/oauth2/v2.0/revokePOST /oauth2/v2.0/revokePOST /oauth2/v2.0/revoke
POST/oauth2/v2.0/tokenPOST /oauth2/v2.0/tokenPOST /oauth2/v2.0/token

Documentation

The package README, the same file that ships in the npm tarball.Edit on GitHub

Local emulators. Real API contracts. Part of Mockingbird.

OAuth authorize, token exchange, userinfo, OIDC discovery, Graph /me, logout, token revocation. Runs through Mockingbird's portable Fetch runtime with SQLite persistence, namespaces, checkpoints, faults and admin controls.

Install

Shell
npm install @crvouga/mockingbird-service-microsoft

Usage

TypeScript
import { AuthenticationHandler, Client, type Context } from "@microsoft/microsoft-graph-client"
import { createRuntime } from "@crvouga/mockingbird-service-microsoft"

// The Microsoft Graph SDK your application already uses. Only the last middleware changes:
// requests reach the emulator in this process instead of graph.microsoft.com.
const emulator = createRuntime({ seed: 1 })
const graph = Client.initWithMiddleware({
  middleware: [
    new AuthenticationHandler({ getAccessToken: async () => "mock_access_token" }),
    {
      execute: async (context: Context) => {
        context.response = await emulator.fetch(new Request(context.request, context.options))
      },
    },
  ],
})

const me = await graph.api("/me").get()
console.log(me.displayName, me.mail) // Test User testuser@outlook.com

For sign-in, serve the emulator (createServer from /server) and give your OpenID Connect client the issuer <server.url>/9188040d-6c67-4c5b-b112-36a304b66dad/v2.0 (the default tenant).

API

  • MicrosoftAPI: portable provider instance; accepts SQLite, namespace, clock, fixtures and baseUrl.
  • createRuntime: shared runtime, including native namespace and checkpoint controls.
  • MICROSOFT_NAMESPACE: default storage namespace.
  • document, operationIds, supportedOperationIds: registered provider route inventory.
  • createServer, DEFAULT_PORT, serveTarget from /server: loopback listener and CLI configuration.

fixtures accepts synthetic provider seed records. reset() restores defaults. Emulate 0.12.1 is a test oracle only, never a runtime dependency. Vendor handlers ported under Apache-2.0 retain their license and attribution; see LICENSE_EMULATE and THIRD_PARTY_NOTICES.md.

See SUPPORT.md for coverage and limits and API_EVIDENCE.md for validation status.

↑↓ to navigate↵ to open