@crvouga/ mockingbird-service-apple (英语)
本地模拟器。 真正的API合同. 部分 嘲笑鸟。 。 。 .
OAuth授权,令牌交换,JWKS. 通过Mockingbird的便携式抓取运行时间,并带有SQLite坚持性,命名空间,检查站,断层和管理员控制等功能.
安装
npm install @crvouga/mockingbird-service-apple
使用量
import * as oidc from "openid-client"
import { createServer } from "@crvouga/mockingbird-service-apple/server"
const server = await createServer({ seed: 1 })
const redirect_uri = "http://localhost:3000/callback"
// The OpenID Connect client your application already uses. Only the issuer changes: the
// emulator instead of https://appleid.apple.com (allowInsecureRequests permits plain http).
const apple = await oidc.discovery(new URL(server.url), "com.example.web", "mock-client-secret", undefined, {
execute: [oidc.allowInsecureRequests],
})
const signIn = oidc.buildAuthorizationUrl(apple, { redirect_uri, scope: "openid email name" })
// Test setup: stand in for the user choosing an account on the emulator's sign-in page.
const chosen = await fetch(`${server.url}/auth/authorize/callback`, {
method: "POST",
redirect: "manual",
body: new URLSearchParams({ ...Object.fromEntries(signIn.searchParams), email: "[email protected]" }),
})
const tokens = await oidc.authorizationCodeGrant(apple, new URL(chosen.headers.get("location") ?? ""))
console.log(tokens.claims()?.email) // [email protected]
await server.close()
API 密码
AppleAPI:便携式提供者实例;接受SQLite,命名空间,时钟,定着和基底Url.createRuntime:共享运行时间,包括本地命名空间和检查站控制.APPLE_NAMESPACE: 默认存储名空间.document, (中文(简体) ),operationIds, (中文(简体) ),supportedOperationIds: 注册供应商路线盘点.createServer, (中文(简体) ),DEFAULT_PORT, (中文(简体) ),serveTarget从/server:回放收听器和CLI配置.
fixtures 接受合成供应商种子记录. reset() 恢复默认值。 模拟0.12.1只是一个测试神谕,从来不是一个运行时间依赖. 在Apache-2.0下移植的供应商操作员保留其许可证和归属;见LICENSE EMULATE和TIII PARTY NOTICES.md.