Capacitor
@capgo/capacitor-人格 认证 & 安全 开源

人格 Capacitor 插件

使用原生 iOS 和 Android SDK 运行 Persona 身份验证

安装

bun add @capgo/capacitor-persona bunx cap sync
npm、pnpm 或 yarn
  • npm install @capgo/capacitor-persona
  • pnpm add @capgo/capacitor-persona
  • yarn add @capgo/capacitor-persona

Guide

使用@Capacitor/__CAPGO_KEEP_1__-intune

使用@capgo/capacitor-intune

Capacitor plugin for Microsoft Intune MAM enrollment, app protection policies, app config, and MSAL authentication.

Install

bun add @capgo/capacitor-intune
bunx cap sync

bunx cap sync 查看code

导入

import { IntuneMAM } from '@capgo/capacitor-intune';

API概览

方法 描述
acquireToken 呈现 Microsoft 登录流程并返回访问令牌及帐户元数据。
acquireTokenSilent 从 MSAL 缓存中获取之前登录用户的令牌。
registerAndEnrollAccount 将之前已验证的帐户注册到 Intune 并开始注册。
loginAndEnrollAccount 要求 Intune 在未先请求应用令牌的情况下对用户进行身份验证和注册。
enrolledAccount 上下文:Capgo 营销网站。角色:呼吁动作按钮或链接标签。见于组件 AskAiSection.astro。消息键 `ask_ai_button` (Ask Ai Button)。
deRegisterAndUnenrollAccount 返回当前已注册的 Intune 帐户,如果有的话。
logoutOfAccount 从 Intune 中注销帐户并触发选择性擦除时适用。
appConfig 从 MSAL 中注销用户而不注销 Intune 帐户时签出用户。
getPolicy 获取当前有效的 Intune 应用保护策略。
groupName 便捷工具,用于解析 Intune 应用配置值。 GroupName 获取应用配置值时使用此工具。
sdkVersion 返回本地 Intune 和 MSAL SDK 版本,通过此插件打包。
displayDiagnosticConsole 显示 native Intune 诊断 UI。

示例

acquireToken()

在 Microsoft 登录流程中呈现并返回访问令牌及帐户元数据。

import { IntuneMAM } from '@capgo/capacitor-intune';

const result = await IntuneMAM.acquireToken({ scopes: ['openid'] });
// The result holds sensitive values: use it without logging it.

acquireTokenSilent()

呈现 Microsoft 登录流程并返回访问令牌及帐户元数据。

import { IntuneMAM } from '@capgo/capacitor-intune';

const result = await IntuneMAM.acquireTokenSilent({
  scopes: ['openid'],
  accountId: 'acquireToken',
});
// The result holds sensitive values: use it without logging it.

registerAndEnrollAccount()

从 MSAL 缓存中获取之前登录用户的令牌。

import { IntuneMAM } from '@capgo/capacitor-intune';

await IntuneMAM.registerAndEnrollAccount({ accountId: 'account-id-123' });

loginAndEnrollAccount()

将已验证的帐户注册到 Intune 并开始注册流程。

import { IntuneMAM } from '@capgo/capacitor-intune';

await IntuneMAM.loginAndEnrollAccount();

enrolledAccount()

在 Intune 中验证并注册用户,且不需要先获取应用令牌。

import { IntuneMAM } from '@capgo/capacitor-intune';

const result = await IntuneMAM.enrolledAccount();
console.log(result);

deRegisterAndUnenrollAccount()

从 Intune 中注销账户并在适用时触发选择性擦除。

import { IntuneMAM } from '@capgo/capacitor-intune';

await IntuneMAM.deRegisterAndUnenrollAccount({ accountId: 'account-id-123' });

上表列出了 12 个核心方法。监听器和版本助手,以及每个方法的完整契约,均在以下仓库中进行了文档记录。 GitHub 仓库.

监听事件

addListener 返回一个句柄。调用 handle.remove() 当屏幕卸载时,或者 IntuneMAM.removeAllListeners() 以清除所有监听器。

完整参考

继续使用 @capgo/capacitor-intune

如果您正在使用 使用@capgo/capacitor-intune 规划身份验证和帐户流程,连接它与 @capgo/capacitor-intune 查看@capgo/capacitor-intune中的实现细节 开始使用 查看开始使用中的实现细节 @capgo/capacitor-社交登录 查看@capgo/capacitor-social-login中的实现细节 @capgo/capacitor-passkey 查看@capgo/capacitor-passkey中的实现细节,并 @capgo/capacitor-native-biometric 查看@capgo/capacitor-native-biometric中的实现细节

常见问题

Capacitor Persona插件常见问题

如何在Capacitor应用中安装Persona插件?

Run "bun add @capgo/capacitor-persona" (or "npm install @capgo/capacitor-persona"), then run "bunx cap sync" so the iOS and Android projects pick up the native code. Import it from "@capgo/capacitor-persona" in your app code.

@capgo/capacitor-persona works with React, Vue and Angular?

Yes. Persona is a Capacitor package, so it works with any web framework that runs inside Capacitor, including Ionic, React, Vue, Angular, Svelte and plain JavaScript.

Which Capacitor version does @capgo/capacitor-persona support?

Capgo plugins follow Capacitor's major version: use the plugin major version that matches your Capacitor major version (for example plugin v8 with Capacitor 8). The compatibility table in the GitHub README lists the maintained versions.

@capgo/capacitor-persona is free and open source?

Yes. The source code is public on GitHub at https://github.com/Cap-go/capacitor-persona/ and the package is free to install from npm. Bug reports and pull requests are welcome.

可以在不需要 App Store 审核的情况下更新使用 Persona 的 code?

Installing or upgrading the plugin changes native code, so it needs a new store build. After that, JavaScript, HTML and CSS changes that call the plugin can ship instantly with Capgo live updates.

无需等待应用程序审查即可将 Persona 变更部署

一旦插件在您的商店构建中,Capgo 即刻将您的 JavaScript、HTML 和 CSS 变更推送给用户。

开始使用 Capgo