@crvouga/ mockingbird-service-microsoft (英语)
本地模拟器。 真正的API合同. 部分 嘲笑鸟。 。 。 .
OAuth授权,令牌交换,用户信息,OIDC发现,Graph / me,登录,令牌撤销. 通过Mockingbird的便携式抓取运行时间,并带有SQLite坚持性,命名空间,检查站,断层和管理员控制等功能.
安装
npm install @crvouga/mockingbird-service-microsoft
使用量
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 [email protected]
对于登录者,请为模拟者服务createServer 从 /server)并给出您的 OpenID 连接
客户端 发行者 <server.url>/9188040d-6c67-4c5b-b112-36a304b66dad/v2.0 (默认租户).
API 密码
MicrosoftAPI:便携式提供者实例;接受SQLite,命名空间,时钟,定着和基底Url.createRuntime:共享运行时间,包括本地命名空间和检查站控制.MICROSOFT_NAMESPACE: 默认存储名空间.document, (中文(简体) ),operationIds, (中文(简体) ),supportedOperationIds: 注册供应商路线盘点.createServer, (中文(简体) ),DEFAULT_PORT, (中文(简体) ),serveTarget从/server:回放收听器和CLI配置.
fixtures 接受合成供应商种子记录. reset() 恢复默认值。 模拟0.12.1只是一个测试神谕,从来不是一个运行时间依赖. 在Apache-2.0下移植的供应商操作员保留其许可证和归属;见LICENSE EMULATE和TIII PARTY NOTICES.md.