diff --git a/src/AuthenticationClient.ts b/src/AuthenticationClient.ts index 5986f41..714e981 100644 --- a/src/AuthenticationClient.ts +++ b/src/AuthenticationClient.ts @@ -90,8 +90,10 @@ import type { SendEmailDto } from './models/SendEmailDto'; import type { SendEmailRespDto } from './models/SendEmailRespDto'; import type { SendSMSDto } from './models/SendSMSDto'; import type { SendSMSRespDto } from './models/SendSMSRespDto'; +import type { SigninByCredentialsDto } from './models/SigninByCredentialsDto'; import type { SigninByMobileDto } from './models/SigninByMobileDto'; import type { SignInByPushDto } from './models/SignInByPushDto'; +import type { SignUpDto } from './models/SignUpDto'; import type { SystemInfoResp } from './models/SystemInfoResp'; import type { UnbindEmailDto } from './models/UnbindEmailDto'; import type { UnbindPhoneDto } from './models/UnbindPhoneDto'; @@ -127,6 +129,8 @@ import type { PreCheckCodeDto } from './models/PreCheckCodeDto'; import type { PreCheckCodeRespDto } from './models/PreCheckCodeRespDto'; import type { RemoveDeviceCredentialDto } from './models/RemoveDeviceCredentialDto'; import type { WechatMobileAuthByCodeInput } from './models/WechatMobileAuthByCodeInput'; +import type { MfaTokenIntrospectEndpointParams } from './models/MfaTokenIntrospectEndpointParams'; +import type { MfaTokenIntrospectResponse } from './models/MfaTokenIntrospectResponse'; import type { EnrollFactorDto } from './models/EnrollFactorDto'; import type { EnrollFactorRespDto } from './models/EnrollFactorRespDto'; import type { GetFactorRespDto } from './models/GetFactorRespDto'; @@ -1579,6 +1583,108 @@ export class AuthenticationClient { // ==== AUTO GENERATED AUTHENTICATION METHODS BEGIN ==== /** + * @summary 生成绑定外部身份源的链接 + * @description + * 此接口用于生成绑定外部身份源的链接,生成之后可以引导用户进行跳转。 + * + * @returns GenerateBindExtIdpLinkRespDto + */ +public async generateLinkExtIdpUrl({ + extIdpConnIdentifier, + appId, + idToken, +}: { + /** 外部身份源连接唯一标志 **/ + extIdpConnIdentifier: string, + /** Authing 应用 ID **/ + appId: string, + /** 用户的 id_token **/ + idToken: string, +}): Promise { + const result = await this.httpClient.request({ + method: 'GET', + url: '/api/v3/generate-link-extidp-url', + params: { + ext_idp_conn_identifier: extIdpConnIdentifier, + app_id: appId, + id_token: idToken, + }, + }); + return result; +} +/** + * @summary 解绑外部身份源 + * @description 解绑外部身份源,此接口需要传递用户绑定的外部身份源 ID,**注意不是身份源连接 ID**。 + * @returns CommonResponseDto + */ +public async unlinkExtIdp(requestBody: UnlinkExtIdpDto, +): Promise { + const result = await this.httpClient.request({ + method: 'POST', + url: '/api/v3/unlink-extidp', + data: requestBody, + }); + return result; +} +/** + * @summary 获取绑定的外部身份源 + * @description + * 如在**介绍**部分中所描述的,一个外部身份源对应多个外部身份源连接,用户通过某个外部身份源连接绑定了某个外部身份源账号之后, + * 用户会建立一条与此外部身份源之间的关联关系。此接口用于获取此用户绑定的所有外部身份源。 + * + * 取决于外部身份源的具体实现,一个用户在外部身份源中,可能会有多个身份 ID,比如在微信体系中会有 `openid` 和 `unionid`,在非书中有 + * `open_id`、`union_id` 和 `user_id`。在 Authing 中,我们把这样的一条 `open_id` 或者 `unionid_` 叫做一条 `Identity`, 所以用户在一个身份源会有多条 `Identity` 记录。 + * + * 以微信为例,如果用户使用微信登录或者绑定了微信账号,他的 `Identity` 信息如下所示: + * + * ```json + * [ + * { + * "identityId": "62f20932xxxxbcc10d966ee5", + * "extIdpId": "62f209327xxxxcc10d966ee5", + * "provider": "wechat", + * "type": "openid", + * "userIdInIdp": "oH_5k5SflrwjGvk7wqpoBKq_cc6M", + * "originConnIds": ["62f2093244fa5cb19ff21ed3"] + * }, + * { + * "identityId": "62f726239xxxxe3285d21c93", + * "extIdpId": "62f209327xxxxcc10d966ee5", + * "provider": "wechat", + * "type": "unionid", + * "userIdInIdp": "o9Nka5ibU-lUGQaeAHqu0nOZyJg0", + * "originConnIds": ["62f2093244fa5cb19ff21ed3"] + * } + * ] + * ``` + * + * + * 可以看到他们的 `extIdpId` 是一样的,这个是你在 Authing 中创建的**身份源 ID**;`provider` 都是 `wechat`; + * 通过 `type` 可以区分出哪个是 `openid`,哪个是 `unionid`,以及具体的值(`userIdInIdp`);他们都来自于同一个身份源连接(`originConnIds`)。 + * + * + * + * @returns GetIdentitiesRespDto + */ + public async getIdentities(): Promise { + const result = await this.httpClient.request({ + method: 'GET', + url: '/api/v3/get-identities', + }); + return result; + } + /** + * @summary 获取应用开启的外部身份源列表 + * @description 获取应用开启的外部身份源列表,前端可以基于此渲染外部身份源按钮。 + * @returns GetExtIdpsRespDto + */ + public async getApplicationEnabledExtIdps(): Promise { + const result = await this.httpClient.request({ + method: 'GET', + url: '/api/v3/get-application-enabled-extidps', + }); + return result; + } /** * @summary 使用用户凭证登录 * @description @@ -1882,41 +1988,26 @@ public async changePushCodeStatus(requestBody: ChangePushCodeStatusDto, return result; } /** - * @summary 获取快速认证二维码数据 - * @description 此端点用于在用户个人中心,获取快速认证参数生成二维码,可使用 Authing 令牌 APP 扫码,完成快速认证。**此接口要求具备用户的登录态**。 - * @returns GeneFastpassQRCodeRespDto + * @summary 注册 + * @description + * 此端点目前支持以下几种基于的注册方式: + * + * 1. 基于密码(PASSWORD):用户名 + 密码,邮箱 + 密码。 + * 2. 基于一次性临时验证码(PASSCODE):手机号 + 验证码,邮箱 + 验证码。你需要先调用发送短信或者发送邮件接口获取验证码。 + * + * 社会化登录等使用外部身份源“注册”请直接使用**登录**接口,我们会在其第一次登录的时候为其创建一个新账号。 + * + * @returns UserSingleRespDto */ -public async geneFastpassQrcodeInfo(requestBody: SignInFastpassDto, -): Promise { +public async signUp(requestBody: SignUpDto, +): Promise { const result = await this.httpClient.request({ method: 'POST', - url: '/api/v3/gene-fastpass-qrcode-info', + url: '/api/v3/signup', data: requestBody, }); return result; } -/** - * @summary 获取快速认证的应用列表 - * @description 此端点用于使用 Authing 令牌 APP 扫「用户个人中心」-「快速认证」二维码后,拉取可快速认证的客户端应用列表。 - * @returns GetFastpassQRCodeRelationAppsRespDto - */ -public async getFastpassParams({ - qrcodeId, - appId, -}: { - qrcodeId: string, - appId: string, -}): Promise { - const result = await this.httpClient.request({ - method: 'GET', - url: '/api/v3/get-fastpass-client-apps', - params: { - qrcodeId: qrcodeId, - appId: appId, - }, - }); - return result; -} /** * @summary 发送短信 * @description 发送短信时必须指定短信 Channel,每个手机号同一 Channel 在一分钟内只能发送一次。 @@ -1946,118 +2037,333 @@ public async sendEmail(requestBody: SendEmailDto, return result; } /** - * @summary 获取用户资料 - * @description 此端点用户获取用户资料,需要在请求头中带上用户的 `access_token`,Authing 服务器会根据用户 `access_token` 中的 `scope` 返回对应的字段。 - * @returns UserSingleRespDto - */ -public async getProfile({ - withCustomData = false, - withIdentities = false, - withDepartmentIds = false, -}: { - /** 是否获取自定义数据 **/ - withCustomData?: boolean, - /** 是否获取 identities **/ - withIdentities?: boolean, - /** 是否获取部门 ID 列表 **/ - withDepartmentIds?: boolean, -}): Promise { - const result = await this.httpClient.request({ - method: 'GET', - url: '/api/v3/get-profile', - params: { - withCustomData: withCustomData, - withIdentities: withIdentities, - withDepartmentIds: withDepartmentIds, - }, - }); - return result; -} -/** - * @summary 修改用户资料 - * @description 此接口用于修改用户的用户资料,包含用户的自定义数据。如果需要**修改邮箱**、**修改手机号**、**修改密码**,请使用对应的单独接口。 - * @returns UserSingleRespDto + * @summary 解密微信小程序数据 + * @description 解密微信小程序数据 + * @returns DecryptWechatMiniProgramDataRespDto */ -public async updateProfile(requestBody: UpdateUserProfileDto, -): Promise { +public async decryptWechatMiniProgramData(requestBody: DecryptWechatMiniProgramDataDto, +): Promise { const result = await this.httpClient.request({ method: 'POST', - url: '/api/v3/update-profile', + url: '/api/v3/decrypt-wechat-miniprogram-data', data: requestBody, }); return result; } /** - * @summary 绑定邮箱 - * @description 如果用户还**没有绑定邮箱**,此接口可用于用户**自主**绑定邮箱。如果用户已经绑定邮箱想要修改邮箱,请使用**修改邮箱**接口。你需要先调用**发送邮件**接口发送邮箱验证码。 - * @returns CommonResponseDto + * @deprecated + * @summary 获取微信小程序、公众号 Access Token + * @description 获取 Authing 服务器缓存的微信小程序、公众号 Access Token(废弃,请使用 /api/v3/get-wechat-access-token-info) + * @returns GetWechatAccessTokenRespDto */ -public async bindEmail(requestBody: BindEmailDto, -): Promise { +public async getWechatMpAccessToken(requestBody: GetWechatAccessTokenDto, +): Promise { const result = await this.httpClient.request({ method: 'POST', - url: '/api/v3/bind-email', + url: '/api/v3/get-wechat-access-token', data: requestBody, }); return result; } /** - * @summary 解绑邮箱 - * @description 用户解绑邮箱,如果用户没有绑定其他登录方式(手机号、社会化登录账号),将无法解绑邮箱,会提示错误。 - * @returns CommonResponseDto + * @summary 获取微信小程序、公众号 Access Token + * @description 获取 Authing 服务器缓存的微信小程序、公众号 Access Token + * @returns GetWechatAccessTokenInfoRespDto */ -public async unbindEmail(requestBody: UnbindEmailDto, -): Promise { +public async getWechatMpAccessTokenInfo(requestBody: GetWechatAccessTokenDto, +): Promise { const result = await this.httpClient.request({ method: 'POST', - url: '/api/v3/unbind-email', + url: '/api/v3/get-wechat-access-token-info', data: requestBody, }); return result; } /** - * @summary 绑定手机号 - * @description 如果用户还**没有绑定手机号**,此接口可用于用户**自主**绑定手机号。如果用户已经绑定手机号想要修改手机号,请使用**修改手机号**接口。你需要先调用**发送短信**接口发送短信验证码。 - * @returns CommonResponseDto + * @summary 获取登录日志 + * @description 获取登录日志 + * @returns GetLoginHistoryRespDto */ -public async bindPhone(requestBody: BindPhoneDto, -): Promise { +public async getLoginHistory({ + appId, + clientIp, + success, + start, + end, + page = 1, + limit = 10, +}: { + /** 应用 ID,可根据应用 ID 筛选。默认不传获取所有应用的登录历史。 **/ + appId?: string, + /** 客户端 IP,可根据登录时的客户端 IP 进行筛选。默认不传获取所有登录 IP 的登录历史。 **/ + clientIp?: string, + /** 是否登录成功,可根据是否登录成功进行筛选。默认不传获取的记录中既包含成功也包含失败的的登录历史。 **/ + success?: boolean, + /** 开始时间,为单位为毫秒的时间戳 **/ + start?: number, + /** 结束时间,为单位为毫秒的时间戳 **/ + end?: number, + /** 当前页数,从 1 开始 **/ + page?: number, + /** 每页数目,最大不能超过 50,默认为 10 **/ + limit?: number, +}): Promise { const result = await this.httpClient.request({ - method: 'POST', - url: '/api/v3/bind-phone', - data: requestBody, + method: 'GET', + url: '/api/v3/get-my-login-history', + params: { + appId: appId, + clientIp: clientIp, + success: success, + start: start, + end: end, + page: page, + limit: limit, + }, }); return result; } /** - * @summary 解绑手机号 - * @description 用户解绑手机号,如果用户没有绑定其他登录方式(邮箱、社会化登录账号),将无法解绑手机号,会提示错误。 - * @returns CommonResponseDto + * @summary 获取登录应用 + * @description 获取登录应用 + * @returns GetLoggedInAppsRespDto */ -public async unbindPhone(requestBody: UnbindPhoneDto, -): Promise { +public async getLoggedInApps(): Promise { const result = await this.httpClient.request({ - method: 'POST', - url: '/api/v3/unbind-phone', - data: requestBody, + method: 'GET', + url: '/api/v3/get-my-logged-in-apps', }); return result; } /** - * @summary 获取密码强度和账号安全等级评分 - * @description 获取用户的密码强度和账号安全等级评分,需要在请求头中带上用户的 `access_token`。 - * @returns GetSecurityInfoRespDto + * @summary 获取具备访问权限的应用 + * @description 获取具备访问权限的应用 + * @returns GetAccessibleAppsRespDto */ -public async getSecurityLevel(): Promise { +public async getAccessibleApps(): Promise { const result = await this.httpClient.request({ method: 'GET', - url: '/api/v3/get-security-info', + url: '/api/v3/get-my-accessible-apps', }); return result; } /** - * @summary 修改密码 - * @description 此端点用于用户自主修改密码,如果用户之前已经设置密码,需要提供用户的原始密码作为凭证。如果用户忘记了当前密码,请使用**忘记密码**接口。 + * @summary 获取租户列表 + * @description 获取租户列表 + * @returns GetTenantListRespDto + */ +public async getTenantList(): Promise { + const result = await this.httpClient.request({ + method: 'GET', + url: '/api/v3/get-my-tenant-list', + }); + return result; +} +/** + * @summary 获取角色列表 + * @description 获取角色列表 + * @returns RoleListRespDto + */ +public async getRoleList({ + namespace, +}: { + /** 所属权限分组(权限空间)的 Code **/ + namespace?: string, +}): Promise { + const result = await this.httpClient.request({ + method: 'GET', + url: '/api/v3/get-my-role-list', + params: { + namespace: namespace, + }, + }); + return result; +} +/** + * @summary 获取分组列表 + * @description 获取分组列表 + * @returns GroupListRespDto + */ +public async getGroupList(): Promise { + const result = await this.httpClient.request({ + method: 'GET', + url: '/api/v3/get-my-group-list', + }); + return result; +} +/** + * @summary 获取部门列表 + * @description 此接口用于获取用户的部门列表,可根据一定排序规则进行排序。 + * @returns UserDepartmentPaginatedRespDto + */ +public async getDepartmentList({ + page = 1, + limit = 10, + withCustomData = false, + sortBy = 'JoinDepartmentAt', + orderBy = 'Desc', +}: { + /** 当前页数,从 1 开始 **/ + page?: number, + /** 每页数目,最大不能超过 50,默认为 10 **/ + limit?: number, + /** 是否获取部门的自定义数据 **/ + withCustomData?: boolean, + /** 排序依据,如 部门创建时间、加入部门时间、部门名称、部门标志符 **/ + sortBy?: 'DepartmentCreatedAt' | 'JoinDepartmentAt' | 'DepartmentName' | 'DepartmemtCode', + /** 增序或降序 **/ + orderBy?: 'Asc' | 'Desc', +}): Promise { + const result = await this.httpClient.request({ + method: 'GET', + url: '/api/v3/get-my-department-list', + params: { + page: page, + limit: limit, + withCustomData: withCustomData, + sortBy: sortBy, + orderBy: orderBy, + }, + }); + return result; +} +/** + * @summary 获取被授权的资源列表 + * @description 此接口用于获取用户被授权的资源列表。 + * @returns AuthorizedResourcePaginatedRespDto + */ +public async getAuthorizedResources({ + namespace, + resourceType, +}: { + /** 所属权限分组(权限空间)的 Code **/ + namespace?: string, + /** 资源类型,如 数据、API、菜单、按钮 **/ + resourceType?: 'DATA' | 'API' | 'MENU' | 'BUTTON' | 'UI', +}): Promise { + const result = await this.httpClient.request({ + method: 'GET', + url: '/api/v3/get-my-authorized-resources', + params: { + namespace: namespace, + resourceType: resourceType, + }, + }); + return result; +} +/** + * @summary 获取用户资料 + * @description 此端点用户获取用户资料,需要在请求头中带上用户的 `access_token`,Authing 服务器会根据用户 `access_token` 中的 `scope` 返回对应的字段。 + * @returns UserSingleRespDto + */ +public async getProfile({ + withCustomData = false, + withIdentities = false, + withDepartmentIds = false, +}: { + /** 是否获取自定义数据 **/ + withCustomData?: boolean, + /** 是否获取 identities **/ + withIdentities?: boolean, + /** 是否获取部门 ID 列表 **/ + withDepartmentIds?: boolean, +}): Promise { + const result = await this.httpClient.request({ + method: 'GET', + url: '/api/v3/get-profile', + params: { + withCustomData: withCustomData, + withIdentities: withIdentities, + withDepartmentIds: withDepartmentIds, + }, + }); + return result; +} +/** + * @summary 修改用户资料 + * @description 此接口用于修改用户的用户资料,包含用户的自定义数据。如果需要**修改邮箱**、**修改手机号**、**修改密码**,请使用对应的单独接口。 + * @returns UserSingleRespDto + */ +public async updateProfile(requestBody: UpdateUserProfileDto, +): Promise { + const result = await this.httpClient.request({ + method: 'POST', + url: '/api/v3/update-profile', + data: requestBody, + }); + return result; +} +/** + * @summary 绑定邮箱 + * @description 如果用户还**没有绑定邮箱**,此接口可用于用户**自主**绑定邮箱。如果用户已经绑定邮箱想要修改邮箱,请使用**修改邮箱**接口。你需要先调用**发送邮件**接口发送邮箱验证码。 + * @returns CommonResponseDto + */ +public async bindEmail(requestBody: BindEmailDto, +): Promise { + const result = await this.httpClient.request({ + method: 'POST', + url: '/api/v3/bind-email', + data: requestBody, + }); + return result; +} +/** + * @summary 解绑邮箱 + * @description 用户解绑邮箱,如果用户没有绑定其他登录方式(手机号、社会化登录账号),将无法解绑邮箱,会提示错误。 + * @returns CommonResponseDto + */ +public async unbindEmail(requestBody: UnbindEmailDto, +): Promise { + const result = await this.httpClient.request({ + method: 'POST', + url: '/api/v3/unbind-email', + data: requestBody, + }); + return result; +} +/** + * @summary 绑定手机号 + * @description 如果用户还**没有绑定手机号**,此接口可用于用户**自主**绑定手机号。如果用户已经绑定手机号想要修改手机号,请使用**修改手机号**接口。你需要先调用**发送短信**接口发送短信验证码。 + * @returns CommonResponseDto + */ +public async bindPhone(requestBody: BindPhoneDto, +): Promise { + const result = await this.httpClient.request({ + method: 'POST', + url: '/api/v3/bind-phone', + data: requestBody, + }); + return result; +} +/** + * @summary 解绑手机号 + * @description 用户解绑手机号,如果用户没有绑定其他登录方式(邮箱、社会化登录账号),将无法解绑手机号,会提示错误。 + * @returns CommonResponseDto + */ +public async unbindPhone(requestBody: UnbindPhoneDto, +): Promise { + const result = await this.httpClient.request({ + method: 'POST', + url: '/api/v3/unbind-phone', + data: requestBody, + }); + return result; +} +/** + * @summary 获取密码强度和账号安全等级评分 + * @description 获取用户的密码强度和账号安全等级评分,需要在请求头中带上用户的 `access_token`。 + * @returns GetSecurityInfoRespDto + */ +public async getSecurityLevel(): Promise { + const result = await this.httpClient.request({ + method: 'GET', + url: '/api/v3/get-security-info', + }); + return result; +} +/** + * @summary 修改密码 + * @description 此端点用于用户自主修改密码,如果用户之前已经设置密码,需要提供用户的原始密码作为凭证。如果用户忘记了当前密码,请使用**忘记密码**接口。 * @returns CommonResponseDto */ public async updatePassword(requestBody: UpdatePasswordDto, @@ -2207,798 +2513,571 @@ public async getCountryList(): Promise { }); return result; } - /** - * @summary 获取推送登录请求关联的客户端应用 - * @description 此端点用于在 Authing 令牌 APP 收到推送登录通知时,可检查当前用户登录的应用是否支持对推送登录请求进行授权。 - * @returns GetPushCodeRelationAppsRespDto + * @summary 字符串类型资源鉴权 + * @description 字符串类型资源鉴权,支持用户对一个或者多个字符串资源进行权限判断 + * @returns CheckResourcePermissionsRespDto */ -public async getPushLoginRelationApps(requestBody: GetPushCodeRelationAppsDto, -): Promise { +public async checkPermissionByStringResource(requestBody: CheckPermissionStringResourceDto, +): Promise { const result = await this.httpClient.request({ method: 'POST', - url: '/api/v3/get-pushlogin-relation-apps', + url: '/api/v3/check-permission-string-resource', data: requestBody, }); return result; } - - /** - * @summary 查询个人中心「快速认证二维码」的状态 - * @description 按照用户扫码顺序,共分为未扫码、已扫码、已登录、二维码过期以及未知错误五种状态,前端应该通过不同的状态给到用户不同的反馈。 - * @returns CheckQRCodeStatusRespDto + * @summary 数组类型资源鉴权 + * @description 数组类型资源鉴权,支持用户对一个或者多个数组资源进行权限判断 + * @returns CheckResourcePermissionsRespDto */ -public async getQrCodeStatus({ - qrcodeId, -}: { - /** 二维码唯一 ID **/ - qrcodeId: string, -}): Promise { +public async checkPermissionByArrayResource(requestBody: CheckPermissionArrayResourceDto, +): Promise { const result = await this.httpClient.request({ - method: 'GET', - url: '/api/v3/get-app-login-qrcode-status', - params: { - qrcodeId: qrcodeId, - }, + method: 'POST', + url: '/api/v3/check-permission-array-resource', + data: requestBody, }); return result; } /** - * @summary APP 端扫码登录 - * @description 此端点用于在授权使 APP 成功扫码登录中,对应着在「个人中心」-「快速认证」页面渲染出二维码,终端用户扫码并成功登录的过程。 - * @returns LoginTokenRespDto - */ -public async qrCodeAppLogin(requestBody: AppQRCodeLoginDto, -): Promise { - const result = await this.httpClient.request({ - method: 'POST', - url: '/api/v3/qrcode-app-login', - data: requestBody, - }); - return result; -} -/** - * @summary 预检验验证码是否正确 - * @description 预检测验证码是否有效,此检验不会使得验证码失效。 - * @returns PreCheckCodeRespDto + * @summary 树类型资源鉴权 + * @description 树类型资源鉴权,支持用户对一个或者多个树资源进行权限判断 + * @returns CheckResourcePermissionsRespDto */ -public async preCheckCode(requestBody: PreCheckCodeDto, -): Promise { +public async checkPermissionByTreeResource(requestBody: CheckPermissionTreeResourceDto, +): Promise { const result = await this.httpClient.request({ method: 'POST', - url: '/api/v3/pre-check-code', + url: '/api/v3/check-permission-tree-resource', data: requestBody, }); return result; } /** - * @returns any + * @summary 获取用户在登录应用下被授权资源列表 + * @description 获取用户指定资源权限列表,用户获取在某个应用下所拥有的资源列表。 + * @returns GetUserAuthResourceListRespDto */ -public async listCredentialsByPage(requestBody: ListDeviceCredentialDto, -): Promise { +public async getUserAuthorizedResourcesList(): Promise { const result = await this.httpClient.request({ - method: 'POST', - url: '/api/v3/webauthn/page-authenticator-device', - data: requestBody, + method: 'GET', + url: '/api/v3/get-user-auth-resource-list', }); return result; } /** - * @returns any + * @summary 获取用户指定资源权限列表 + * @description 获取用户指定资源的权限列表,用户获取某个应用下指定资源的权限列表。 + * @returns GetUserAuthResourcePermissionListRespDto */ -public async checkValidCredentialsByCredIds(requestBody: CheckDeviceCredentialIdDto, -): Promise { +public async getUserAuthResourcePermissionList(requestBody: GetUserAuthResourcePermissionListDto, +): Promise { const result = await this.httpClient.request({ method: 'POST', - url: '/api/v3/webauthn/check-valid-credentials-by-credIds', + url: '/api/v3/get-user-auth-resource-permission-list', data: requestBody, }); return result; } /** - * @returns any + * @summary 获取用户授权资源的结构列表 + * @description 获取用户授权的资源列表,用户获取某个应用下的某个资源所授权的结构列表,通过不同的资源类型返回对应资源的授权列表。 + * @returns GetUserAuthResourceStructRespDto */ -public async removeAllCredentials(requestBody: RemoveDeviceCredentialDto, -): Promise { +public async getUserAuthResourceStruct(requestBody: GetUserAuthResourceStructDto, +): Promise { const result = await this.httpClient.request({ method: 'POST', - url: '/api/v3/webauthn/remove-credentials-by-authenticator-code', + url: '/api/v3/get-user-auth-resource-struct', data: requestBody, }); return result; } /** - * @returns any + * @summary 获取 WebAuthn 认证请求初始化参数 + * @description 获取 WebAuthn 认证请求初始化参数 + * @returns GetAuthenticationOptionsRespDto */ -public async removeCredential(credentialId: string, -): Promise { +public async initAuthenticationOptions(): Promise { const result = await this.httpClient.request({ - method: 'POST', - url: '/api/v3/webauthn/remove-credential/{credentialID}', + method: 'GET', + url: '/api/v3/webauthn/authentication', }); return result; } /** - * @returns any + * @summary 验证 WebAuthn 认证请求凭证 + * @description 验证 WebAuthn 认证请求凭证 + * @returns VerifyAuthenticationResultRespDto */ -public async authByCode(requestBody: WechatMobileAuthByCodeInput, -): Promise { +public async verifyAuthentication(requestBody: VerifyAuthenticationDto, +): Promise { const result = await this.httpClient.request({ method: 'POST', - url: '/api/v2/ecConn/wechatMobile/authByCode', + url: '/api/v3/webauthn/authentication', data: requestBody, }); return result; } /** - * @summary 发起绑定 MFA 认证要素请求 - * @description 当用户未绑定某个 MFA 认证要素时,可以发起绑定 MFA 认证要素请求。不同类型的 MFA 认证要素绑定请求需要发送不同的参数,详细见 profile 参数。发起验证请求之后,Authing 服务器会根据相应的认证要素类型和传递的参数,使用不同的手段要求验证。此接口会返回 enrollmentToken,你需要在请求「绑定 MFA 认证要素」接口时带上此 enrollmentToken,并提供相应的凭证。 - * @returns SendEnrollFactorRequestRespDto + * @summary 获取 webauthn 凭证创建初始化参数 + * @description 获取 webauthn 凭证创建初始化参数。此接口要求具备用户的登录态** + * @returns GetRegistrationOptionsRespDto */ -public async sendEnrollFactorRequest(requestBody: SendEnrollFactorRequestDto, -): Promise { +public async initRegisterOptions(): Promise { const result = await this.httpClient.request({ - method: 'POST', - url: '/api/v3/send-enroll-factor-request', - data: requestBody, + method: 'GET', + url: '/api/v3/webauthn/registration', }); return result; } /** - * @summary 绑定 MFA 认证要素 - * @description 绑定 MFA 要素。 - * @returns EnrollFactorRespDto + * @summary 验证 webauthn 绑定注册认证器凭证 + * @description 验证 webauthn 绑定注册认证器凭证 + * @returns VerifyRegistrationResultRespDto */ -public async enrollFactor(requestBody: EnrollFactorDto, -): Promise { +public async verifyRegister(requestBody: VerifyRegistrationDto, +): Promise { const result = await this.httpClient.request({ method: 'POST', - url: '/api/v3/enroll-factor', + url: '/api/v3/webauthn/registration', data: requestBody, }); return result; } /** - * @summary 解绑 MFA 认证要素 - * @description 根据 Factor ID 解绑用户绑定的某个 MFA 认证要素。 - * @returns ResetFactorRespDto + * @summary 微信移动端登录 + * @description 移动端应用:使用微信作为外部身份源登录。 + * @returns LoginTokenResponseDataDto */ -public async resetFactor(requestBody: ResetFactorDto, -): Promise { +public async authByCodeIdentity(requestBody: WechatMobileAuthByCodeIdentityInput, +): Promise { const result = await this.httpClient.request({ method: 'POST', - url: '/api/v3/reset-factor', + url: '/api/v2/ecConn/wechatMobile/authByCodeIdentity', data: requestBody, }); return result; } /** - * @summary 获取绑定的所有 MFA 认证要素 - * @description Authing 目前支持四种类型的 MFA 认证要素:手机短信、邮件验证码、OTP、人脸。 - * @returns ListEnrolledFactorsRespDto + * @summary 微信移动端:使用身份源中用户信息 + * @description 询问绑定开启时:绑定到外部身份源,根据外部身份源中的用户信息创建用户后绑定到当前身份源并登录。 + * @returns WechatLoginTokenRespDto */ -public async listEnrolledFactors(): Promise { +public async registerNewUser(requestBody: BindByRegiserInputApi, +): Promise { const result = await this.httpClient.request({ - method: 'GET', - url: '/api/v3/list-enrolled-factors', + method: 'POST', + url: '/api/v2/ecConn/wechatMobile/register', + data: requestBody, }); return result; } /** - * @summary 获取绑定的某个 MFA 认证要素 - * @description 根据 Factor ID 获取用户绑定的某个 MFA Factor 详情。 - * @returns GetFactorRespDto + * @summary 微信移动端:邮箱验证码模式 + * @description 询问绑定开启时:绑定到外部身份源,根据输入的邮箱验证用户信息,找到对应的用户后绑定到当前身份源并登录;找不到时报错“用户不存在”。 + * @returns WechatLoginTokenRespDto */ -public async getFactor({ - factorId, -}: { - /** MFA Factor ID **/ - factorId: string, -}): Promise { +public async bindByEmailCode(requestBody: BindByEmailCodeInputApi, +): Promise { const result = await this.httpClient.request({ - method: 'GET', - url: '/api/v3/get-factor', - params: { - factorId: factorId, - }, + method: 'POST', + url: '/api/v2/ecConn/wechatMobile/byEmailCode', + data: requestBody, }); return result; } /** - * @summary 获取可绑定的 MFA 认证要素 - * @description 获取所有应用已经开启、用户暂未绑定的 MFA 认证要素,用户可以从返回的列表中绑定新的 MFA 认证要素。 - * @returns ListFactorsToEnrollRespDto + * @summary 微信移动端:手机号验证码模式 + * @description 询问绑定开启时:绑定到外部身份源,根据输入的手机验证用户信息,找到对应的用户后绑定到当前身份源并登录;找不到时报错“用户不存在”。 + * @returns WechatLoginTokenRespDto */ -public async listFactorsToEnroll(): Promise { +public async bindByPhoneCode(requestBody: BindByPhoneCodeInputApi, +): Promise { const result = await this.httpClient.request({ - method: 'GET', - url: '/api/v3/list-factors-to-enroll', + method: 'POST', + url: '/api/v2/ecConn/wechatMobile/byPhoneCode', + data: requestBody, }); return result; } /** - * @summary 校验用户 MFA 绑定的 OTP - * @description 校验用户 MFA 绑定的 OTP。 - * @returns MfaOtpVerityRespDto + * @summary 微信移动端:账号密码模式 + * @description 询问绑定开启时:绑定到外部身份源,根据输入的账号(用户名/手机号/邮箱)密码验证用户信息,找到对应的用户后绑定到当前身份源并登录;找不到时报错“用户不存在”。 + * @returns WechatLoginTokenRespDto */ -public async mfaOtpVerify(requestBody: MfaOtpVerityDto, -): Promise { +public async bindByAccount(requestBody: BindByAccountInputApi, +): Promise { const result = await this.httpClient.request({ method: 'POST', - url: '/api/v3/mfa-totp-verify', + url: '/api/v2/ecConn/wechatMobile/byAccount', data: requestBody, }); return result; } /** - * @summary 生成绑定外部身份源的链接 - * @description - * 此接口用于生成绑定外部身份源的链接,生成之后可以引导用户进行跳转。 - * - * @returns GenerateBindExtIdpLinkRespDto + * @summary 微信移动端:多账号场景 + * @description 询问绑定开启时:根据选择的账号绑定外部身份源,根据输入的账号 ID 验证用户信息,找到对应的用户后绑定到当前身份源并登录;找不到时报错“用户不存在”。 + * @returns WechatLoginTokenRespDto */ -public async generateLinkExtIdpUrl({ - extIdpConnIdentifier, - appId, - idToken, -}: { - /** 外部身份源连接唯一标志 **/ - extIdpConnIdentifier: string, - /** Authing 应用 ID **/ - appId: string, - /** 用户的 id_token **/ - idToken: string, -}): Promise { +public async selectAccount(requestBody: BindByAccountsInputApi, +): Promise { const result = await this.httpClient.request({ - method: 'GET', - url: '/api/v3/generate-link-extidp-url', - params: { - ext_idp_conn_identifier: extIdpConnIdentifier, - app_id: appId, - id_token: idToken, - }, + method: 'POST', + url: '/api/v2/ecConn/wechatMobile/select', + data: requestBody, }); return result; } /** - * @summary 解绑外部身份源 - * @description 解绑外部身份源,此接口需要传递用户绑定的外部身份源 ID,**注意不是身份源连接 ID**。 - * @returns CommonResponseDto + * @summary 微信移动端:账号 ID 模式 + * @description 询问绑定开启时:绑定到外部身份源,根据输入的账号 ID 验证用户信息,找到对应的用户后绑定到当前身份源并登录;找不到时报错“用户不存在”。 + * @returns WechatLoginTokenRespDto */ -public async unlinkExtIdp(requestBody: UnlinkExtIdpDto, -): Promise { +public async bindByAccountId(requestBody: BindByAccountIdInputApi, +): Promise { const result = await this.httpClient.request({ method: 'POST', - url: '/api/v3/unlink-extidp', + url: '/api/v2/ecConn/wechatMobile/byAccountId', data: requestBody, }); return result; } /** - * @summary 获取绑定的外部身份源 + * @summary 使用用户凭证登录 * @description - * 如在**介绍**部分中所描述的,一个外部身份源对应多个外部身份源连接,用户通过某个外部身份源连接绑定了某个外部身份源账号之后, - * 用户会建立一条与此外部身份源之间的关联关系。此接口用于获取此用户绑定的所有外部身份源。 + * 此端点为基于直接 API 调用形式的登录端点,适用于你需要自建登录页面的场景。**此端点暂时不支持 MFA、信息补全、首次密码重置等流程,如有需要,请使用 OIDC 标准协议认证端点。** * - * 取决于外部身份源的具体实现,一个用户在外部身份源中,可能会有多个身份 ID,比如在微信体系中会有 `openid` 和 `unionid`,在非书中有 - * `open_id`、`union_id` 和 `user_id`。在 Authing 中,我们把这样的一条 `open_id` 或者 `unionid_` 叫做一条 `Identity`, 所以用户在一个身份源会有多条 `Identity` 记录。 * - * 以微信为例,如果用户使用微信登录或者绑定了微信账号,他的 `Identity` 信息如下所示: + * 注意事项:取决于你在 Authing 创建应用时选择的**应用类型**和应用配置的**换取 token 身份验证方式**,在调用此接口时需要对客户端的身份进行不同形式的验证。 * - * ```json - * [ - * { - * "identityId": "62f20932xxxxbcc10d966ee5", - * "extIdpId": "62f209327xxxxcc10d966ee5", - * "provider": "wechat", - * "type": "openid", - * "userIdInIdp": "oH_5k5SflrwjGvk7wqpoBKq_cc6M", - * "originConnIds": ["62f2093244fa5cb19ff21ed3"] - * }, - * { - * "identityId": "62f726239xxxxe3285d21c93", - * "extIdpId": "62f209327xxxxcc10d966ee5", - * "provider": "wechat", - * "type": "unionid", - * "userIdInIdp": "o9Nka5ibU-lUGQaeAHqu0nOZyJg0", - * "originConnIds": ["62f2093244fa5cb19ff21ed3"] - * } - * ] - * ``` - * - * - * 可以看到他们的 `extIdpId` 是一样的,这个是你在 Authing 中创建的**身份源 ID**;`provider` 都是 `wechat`; - * 通过 `type` 可以区分出哪个是 `openid`,哪个是 `unionid`,以及具体的值(`userIdInIdp`);他们都来自于同一个身份源连接(`originConnIds`)。 - * - * - * - * @returns GetIdentitiesRespDto - */ - public async getIdentities(): Promise { - const result = await this.httpClient.request({ - method: 'GET', - url: '/api/v3/get-identities', - }); - return result; - } - /** - * @summary 获取应用开启的外部身份源列表 - * @description 获取应用开启的外部身份源列表,前端可以基于此渲染外部身份源按钮。 - * @returns GetExtIdpsRespDto - */ - public async getApplicationEnabledExtIdps(): Promise { - const result = await this.httpClient.request({ - method: 'GET', - url: '/api/v3/get-application-enabled-extidps', - }); - return result; - } - /** - * @summary 注册 - * @description - * 此端点目前支持以下几种基于的注册方式: - * - * 1. 基于密码(PASSWORD):用户名 + 密码,邮箱 + 密码。 - * 2. 基于一次性临时验证码(PASSCODE):手机号 + 验证码,邮箱 + 验证码。你需要先调用发送短信或者发送邮件接口获取验证码。 - * - * 社会化登录等使用外部身份源“注册”请直接使用**登录**接口,我们会在其第一次登录的时候为其创建一个新账号。 - * - * @returns UserSingleRespDto - */ - public async signUp(requestBody: SignUpDto, - ): Promise { - const result = await this.httpClient.request({ - method: 'POST', - url: '/api/v3/signup', - data: requestBody, - }); - return result; - } - /** - * @summary 解密微信小程序数据 - * @description 解密微信小程序数据 - * @returns DecryptWechatMiniProgramDataRespDto - */ - public async decryptWechatMiniProgramData(requestBody: DecryptWechatMiniProgramDataDto, - ): Promise { - const result = await this.httpClient.request({ - method: 'POST', - url: '/api/v3/decrypt-wechat-miniprogram-data', - data: requestBody, - }); - return result; - } - /** - * @summary 获取微信小程序、公众号 Access Token - * @description 获取 Authing 服务器缓存的微信小程序、公众号 Access Token - * @returns GetWechatAccessTokenRespDto - */ - public async getWechatMpAccessToken(requestBody: GetWechatAccessTokenDto, -): Promise { + *
+ * 点击展开详情 + * + *
+ * + * 你可以在 [Authing 控制台](https://console.authing.cn) 的**应用** - **自建应用** - **应用详情** - **应用配置** - **其他设置** - **授权配置** + * 中找到**换取 token 身份验证方式** 配置项: + * + * > 单页 Web 应用和客户端应用隐藏,默认为 `none`,不允许修改;后端应用和标准 Web 应用可以修改此配置项。 + * + * ![](https://files.authing.co/api-explorer/tokenAuthMethod.jpg) + * + * #### 换取 token 身份验证方式为 none 时 + * + * 调用此接口不需要进行额外操作。 + * + * #### 换取 token 身份验证方式为 client_secret_post 时 + * + * 调用此接口时必须在 body 中传递 `client_id` 和 `client_secret` 参数,作为验证客户端身份的条件。其中 `client_id` 为应用 ID、`client_secret` 为应用密钥。 + * + * #### 换取 token 身份验证方式为 client_secret_basic 时 + * + * 调用此接口时必须在 HTTP 请求头中携带 `authorization` 请求头,作为验证客户端身份的条件。`authorization` 请求头的格式如下(其中 `client_id` 为应用 ID、`client_secret` 为应用密钥。): + * + * ``` + * Basic base64(:) + * ``` + * + * 结果示例: + * + * ``` + * Basic NjA2M2ZiMmYzY3h4eHg2ZGY1NWYzOWViOjJmZTdjODdhODFmODY3eHh4eDAzMjRkZjEyZGFlZGM3 + * ``` + * + * JS 代码示例: + * + * ```js + * 'Basic ' + Buffer.from(client_id + ':' + client_secret).toString('base64'); + * ``` + * + *
+ * + * + * @returns LoginTokenRespDto 成功认证 + */ +public async signInByCredentials(requestBody: SigninByCredentialsDto, +): Promise { const result = await this.httpClient.request({ method: 'POST', - url: '/api/v3/get-wechat-access-token', + url: '/api/v3/signin', data: requestBody, }); return result; } /** - * @summary 获取登录日志 - * @description 获取登录日志 - * @returns GetLoginHistoryRespDto - */ -public async getLoginHistory({ - appId, - clientIp, - success, - start, - end, - page = 1, - limit = 10, -}: { - /** 应用 ID,可根据应用 ID 筛选。默认不传获取所有应用的登录历史。 **/ - appId?: string, - /** 客户端 IP,可根据登录时的客户端 IP 进行筛选。默认不传获取所有登录 IP 的登录历史。 **/ - clientIp?: string, - /** 是否登录成功,可根据是否登录成功进行筛选。默认不传获取的记录中既包含成功也包含失败的的登录历史。 **/ - success?: boolean, - /** 开始时间,为单位为毫秒的时间戳 **/ - start?: number, - /** 结束时间,为单位为毫秒的时间戳 **/ - end?: number, - /** 当前页数,从 1 开始 **/ - page?: number, - /** 每页数目,最大不能超过 50,默认为 10 **/ - limit?: number, -}): Promise { - const result = await this.httpClient.request({ - method: 'GET', - url: '/api/v3/get-my-login-history', - params: { - appId: appId, - clientIp: clientIp, - success: success, - start: start, - end: end, - page: page, - limit: limit, - }, - }); - return result; -} -/** - * @summary 获取登录应用 - * @description 获取登录应用 - * @returns GetLoggedInAppsRespDto - */ -public async getLoggedInApps(): Promise { - const result = await this.httpClient.request({ - method: 'GET', - url: '/api/v3/get-my-logged-in-apps', - }); - return result; -} -/** - * @summary 获取具备访问权限的应用 - * @description 获取具备访问权限的应用 - * @returns GetAccessibleAppsRespDto - */ -public async getAccessibleApps(): Promise { - const result = await this.httpClient.request({ - method: 'GET', - url: '/api/v3/get-my-accessible-apps', - }); - return result; -} -/** - * @summary 获取租户列表 - * @description 获取租户列表 - * @returns GetTenantListRespDto - */ -public async getTenantList(): Promise { - const result = await this.httpClient.request({ - method: 'GET', - url: '/api/v3/get-my-tenant-list', - }); - return result; -} -/** - * @summary 获取角色列表 - * @description 获取角色列表 - * @returns RoleListRespDto - */ -public async getRoleList({ - namespace, -}: { - /** 所属权限分组(权限空间)的 Code **/ - namespace?: string, -}): Promise { - const result = await this.httpClient.request({ - method: 'GET', - url: '/api/v3/get-my-role-list', - params: { - namespace: namespace, - }, - }); - return result; -} -/** - * @summary 获取分组列表 - * @description 获取分组列表 - * @returns GroupListRespDto + * @summary 获取推送登录请求关联的客户端应用 + * @description 此端点用于在 Authing 令牌 APP 收到推送登录通知时,可检查当前用户登录的应用是否支持对推送登录请求进行授权。 + * @returns GetPushCodeRelationAppsRespDto */ -public async getGroupList(): Promise { +public async getPushLoginRelationApps(requestBody: GetPushCodeRelationAppsDto, +): Promise { const result = await this.httpClient.request({ - method: 'GET', - url: '/api/v3/get-my-group-list', + method: 'POST', + url: '/api/v3/get-pushlogin-relation-apps', + data: requestBody, }); return result; } /** - * @summary 获取部门列表 - * @description 此接口用于获取用户的部门列表,可根据一定排序规则进行排序。 - * @returns UserDepartmentPaginatedRespDto - */ -public async getDepartmentList({ - page = 1, - limit = 10, - withCustomData = false, - sortBy = 'JoinDepartmentAt', - orderBy = 'Desc', -}: { - /** 当前页数,从 1 开始 **/ - page?: number, - /** 每页数目,最大不能超过 50,默认为 10 **/ - limit?: number, - /** 是否获取部门的自定义数据 **/ - withCustomData?: boolean, - /** 排序依据,如 部门创建时间、加入部门时间、部门名称、部门标志符 **/ - sortBy?: 'DepartmentCreatedAt' | 'JoinDepartmentAt' | 'DepartmentName' | 'DepartmemtCode', - /** 增序或降序 **/ - orderBy?: 'Asc' | 'Desc', -}): Promise { + * @summary 获取快速认证二维码数据 + * @description 此端点用于在用户个人中心,获取快速认证参数生成二维码,可使用 Authing 令牌 APP 扫码,完成快速认证。**此接口要求具备用户的登录态**。 + * @returns GeneFastpassQRCodeRespDto + */ +public async geneFastpassQrcodeInfo(requestBody: SignInFastpassDto, +): Promise { const result = await this.httpClient.request({ - method: 'GET', - url: '/api/v3/get-my-department-list', - params: { - page: page, - limit: limit, - withCustomData: withCustomData, - sortBy: sortBy, - orderBy: orderBy, - }, + method: 'POST', + url: '/api/v3/gene-fastpass-qrcode-info', + data: requestBody, }); return result; } /** - * @summary 获取被授权的资源列表 - * @description 此接口用于获取用户被授权的资源列表。 - * @returns AuthorizedResourcePaginatedRespDto + * @summary 获取快速认证的应用列表 + * @description 此端点用于使用 Authing 令牌 APP 扫「用户个人中心」-「快速认证」二维码后,拉取可快速认证的客户端应用列表。 + * @returns GetFastpassQRCodeRelationAppsRespDto */ -public async getAuthorizedResources({ - namespace, - resourceType, +public async getFastpassParams({ + qrcodeId, + appId, }: { - /** 所属权限分组(权限空间)的 Code **/ - namespace?: string, - /** 资源类型,如 数据、API、菜单、按钮 **/ - resourceType?: 'DATA' | 'API' | 'MENU' | 'BUTTON' | 'UI', -}): Promise { + qrcodeId: string, + appId: string, +}): Promise { const result = await this.httpClient.request({ method: 'GET', - url: '/api/v3/get-my-authorized-resources', + url: '/api/v3/get-fastpass-client-apps', params: { - namespace: namespace, - resourceType: resourceType, + qrcodeId: qrcodeId, + appId: appId, }, }); return result; } /** - * @summary 字符串类型资源鉴权 - * @description 字符串类型资源鉴权,支持用户对一个或者多个字符串资源进行权限判断 - * @returns CheckResourcePermissionsRespDto - */ -public async checkPermissionByStringResource(requestBody: CheckPermissionStringResourceDto, -): Promise { - return await this.httpClient.request({ - method: 'POST', - url: '/api/v3/check-permission-string-resource', - data: requestBody, - }); -} -/** - * @summary 数组类型资源鉴权 - * @description 数组类型资源鉴权,支持用户对一个或者多个数组资源进行权限判断 - * @returns CheckResourcePermissionsRespDto + * @summary 查询个人中心「快速认证二维码」的状态 + * @description 按照用户扫码顺序,共分为未扫码、已扫码、已登录、二维码过期以及未知错误五种状态,前端应该通过不同的状态给到用户不同的反馈。 + * @returns CheckQRCodeStatusRespDto */ -public async checkPermissionByArrayResource(requestBody: CheckPermissionArrayResourceDto, -): Promise { - return await this.httpClient.request({ - method: 'POST', - url: '/api/v3/check-permission-array-resource', - data: requestBody, +public async getQrCodeStatus({ + qrcodeId, +}: { + /** 二维码唯一 ID **/ + qrcodeId: string, +}): Promise { + const result = await this.httpClient.request({ + method: 'GET', + url: '/api/v3/get-app-login-qrcode-status', + params: { + qrcodeId: qrcodeId, + }, }); + return result; } /** - * @summary 树类型资源鉴权 - * @description 树类型资源鉴权,支持用户对一个或者多个树资源进行权限判断 - * @returns CheckResourcePermissionsRespDto + * @summary APP 端扫码登录 + * @description 此端点用于在授权使 APP 成功扫码登录中,对应着在「个人中心」-「快速认证」页面渲染出二维码,终端用户扫码并成功登录的过程。 + * @returns LoginTokenRespDto */ -public async checkPermissionByTreeResource(requestBody: CheckPermissionTreeResourceDto, -): Promise { - return await this.httpClient.request({ - method: 'POST', - url: '/api/v3/check-permission-tree-resource', - data: requestBody, +public async qrCodeAppLogin(requestBody: AppQRCodeLoginDto, +): Promise { + const result = await this.httpClient.request({ + method: 'POST', + url: '/api/v3/qrcode-app-login', + data: requestBody, }); + return result; } /** - * @summary 获取用户在登录应用下被授权资源列表 - * @description 获取用户指定资源权限列表,用户获取在某个应用下所拥有的资源列表。 - * @returns GetUserAuthResourceListRespDto + * @summary 预检验验证码是否正确 + * @description 预检测验证码是否有效,此检验不会使得验证码失效。 + * @returns PreCheckCodeRespDto */ -public async getUserAuthorizedResourcesList(): Promise { - return await this.httpClient.request({ - method: 'GET', - url: '/api/v3/get-user-auth-resource-list', +public async preCheckCode(requestBody: PreCheckCodeDto, +): Promise { + const result = await this.httpClient.request({ + method: 'POST', + url: '/api/v3/pre-check-code', + data: requestBody, }); + return result; } /** - * @summary 获取用户指定资源权限列表 - * @description 获取用户指定资源的权限列表,用户获取某个应用下指定资源的权限列表。 - * @returns GetUserAuthResourcePermissionListRespDto + * @returns any */ -public async getUserAuthResourcePermissionList(requestBody: GetUserAuthResourcePermissionListDto, -): Promise { +public async listCredentialsByPage(requestBody: ListDeviceCredentialDto, +): Promise { const result = await this.httpClient.request({ method: 'POST', - url: '/api/v3/get-user-auth-resource-permission-list', + url: '/api/v3/webauthn/page-authenticator-device', data: requestBody, }); return result; } /** - * @summary 获取用户授权资源的结构列表 - * @description 获取用户授权的资源列表,用户获取某个应用下的某个资源所授权的结构列表,通过不同的资源类型返回对应资源的授权列表。 - * @returns GetUserAuthResourceStructRespDto + * @returns any */ -public async getUserAuthResourceStruct(requestBody: GetUserAuthResourceStructDto, -): Promise { +public async checkValidCredentialsByCredIds(requestBody: CheckDeviceCredentialIdDto, +): Promise { const result = await this.httpClient.request({ method: 'POST', - url: '/api/v3/get-user-auth-resource-struct', + url: '/api/v3/webauthn/check-valid-credentials-by-credIds', data: requestBody, }); return result; } /** - * @summary 微信移动端登录 - * @description 移动端应用:使用微信作为外部身份源登录。 - * @returns LoginTokenResponseDataDto + * @returns any */ -public async authByCodeIdentity(requestBody: WechatMobileAuthByCodeIdentityInput, -): Promise { +public async removeAllCredentials(requestBody: RemoveDeviceCredentialDto, +): Promise { const result = await this.httpClient.request({ method: 'POST', - url: '/api/v2/ecConn/wechatMobile/authByCodeIdentity', + url: '/api/v3/webauthn/remove-credentials-by-authenticator-code', data: requestBody, }); return result; } /** - * @summary 微信移动端:使用身份源中用户信息 - * @description 询问绑定开启时:绑定到外部身份源,根据外部身份源中的用户信息创建用户后绑定到当前身份源并登录。 - * @returns WechatLoginTokenRespDto + * @returns any */ -public async registerNewUser(requestBody: BindByRegiserInputApi, -): Promise { +public async removeCredential(credentialId: string, +): Promise { const result = await this.httpClient.request({ method: 'POST', - url: '/api/v2/ecConn/wechatMobile/register', - data: requestBody, + url: '/api/v3/webauthn/remove-credential/{credentialID}', }); return result; } /** - * @summary 微信移动端:邮箱验证码模式 - * @description 询问绑定开启时:绑定到外部身份源,根据输入的邮箱验证用户信息,找到对应的用户后绑定到当前身份源并登录;找不到时报错“用户不存在”。 - * @returns WechatLoginTokenRespDto + * @returns any */ -public async bindByEmailCode(requestBody: BindByEmailCodeInputApi, -): Promise { +public async authByCode(requestBody: WechatMobileAuthByCodeInput, +): Promise { const result = await this.httpClient.request({ method: 'POST', - url: '/api/v2/ecConn/wechatMobile/byEmailCode', + url: '/api/v2/ecConn/wechatMobile/authByCode', data: requestBody, }); return result; } /** - * @summary 微信移动端:手机号验证码模式 - * @description 询问绑定开启时:绑定到外部身份源,根据输入的手机验证用户信息,找到对应的用户后绑定到当前身份源并登录;找不到时报错“用户不存在”。 - * @returns WechatLoginTokenRespDto + * @summary 验证 MFA Token + * @description 验证 MFA Token + * @returns MfaTokenIntrospectResponse */ -public async bindByPhoneCode(requestBody: BindByPhoneCodeInputApi, -): Promise { +public async verifyMfaToken(formData: MfaTokenIntrospectEndpointParams, +): Promise { const result = await this.httpClient.request({ method: 'POST', - url: '/api/v2/ecConn/wechatMobile/byPhoneCode', - data: requestBody, + url: '/mfa/token/introspection', }); return result; } /** - * @summary 微信移动端:账号密码模式 - * @description 询问绑定开启时:绑定到外部身份源,根据输入的账号(用户名/手机号/邮箱)密码验证用户信息,找到对应的用户后绑定到当前身份源并登录;找不到时报错“用户不存在”。 - * @returns WechatLoginTokenRespDto + * @summary 发起绑定 MFA 认证要素请求 + * @description 当用户未绑定某个 MFA 认证要素时,可以发起绑定 MFA 认证要素请求。不同类型的 MFA 认证要素绑定请求需要发送不同的参数,详细见 profile 参数。发起验证请求之后,Authing 服务器会根据相应的认证要素类型和传递的参数,使用不同的手段要求验证。此接口会返回 enrollmentToken,你需要在请求「绑定 MFA 认证要素」接口时带上此 enrollmentToken,并提供相应的凭证。 + * @returns SendEnrollFactorRequestRespDto */ -public async bindByAccount(requestBody: BindByAccountInputApi, -): Promise { +public async sendEnrollFactorRequest(requestBody: SendEnrollFactorRequestDto, +): Promise { const result = await this.httpClient.request({ method: 'POST', - url: '/api/v2/ecConn/wechatMobile/byAccount', + url: '/api/v3/send-enroll-factor-request', data: requestBody, }); return result; } /** - * @summary 微信移动端:多账号场景 - * @description 询问绑定开启时:根据选择的账号绑定外部身份源,根据输入的账号 ID 验证用户信息,找到对应的用户后绑定到当前身份源并登录;找不到时报错“用户不存在”。 - * @returns WechatLoginTokenRespDto + * @summary 绑定 MFA 认证要素 + * @description 绑定 MFA 要素。 + * @returns EnrollFactorRespDto */ -public async selectAccount(requestBody: BindByAccountsInputApi, -): Promise { +public async enrollFactor(requestBody: EnrollFactorDto, +): Promise { const result = await this.httpClient.request({ method: 'POST', - url: '/api/v2/ecConn/wechatMobile/select', + url: '/api/v3/enroll-factor', data: requestBody, }); return result; } /** - * @summary 微信移动端:账号 ID 模式 - * @description 询问绑定开启时:绑定到外部身份源,根据输入的账号 ID 验证用户信息,找到对应的用户后绑定到当前身份源并登录;找不到时报错“用户不存在”。 - * @returns WechatLoginTokenRespDto + * @summary 解绑 MFA 认证要素 + * @description 根据 Factor ID 解绑用户绑定的某个 MFA 认证要素。 + * @returns ResetFactorRespDto */ -public async bindByAccountId(requestBody: BindByAccountIdInputApi, -): Promise { +public async resetFactor(requestBody: ResetFactorDto, +): Promise { const result = await this.httpClient.request({ method: 'POST', - url: '/api/v2/ecConn/wechatMobile/byAccountId', + url: '/api/v3/reset-factor', data: requestBody, }); return result; } /** - * @summary 获取 WebAuthn 认证请求初始化参数 - * @description 获取 WebAuthn 认证请求初始化参数 - * @returns GetAuthenticationOptionsRespDto + * @summary 获取绑定的所有 MFA 认证要素 + * @description Authing 目前支持四种类型的 MFA 认证要素:手机短信、邮件验证码、OTP、人脸。 + * @returns ListEnrolledFactorsRespDto */ -public async initAuthenticationOptions(): Promise { +public async listEnrolledFactors(): Promise { const result = await this.httpClient.request({ method: 'GET', - url: '/api/v3/webauthn/authentication', + url: '/api/v3/list-enrolled-factors', }); return result; } /** - * @summary 验证 WebAuthn 认证请求凭证 - * @description 验证 WebAuthn 认证请求凭证 - * @returns VerifyAuthenticationResultRespDto + * @summary 获取绑定的某个 MFA 认证要素 + * @description 根据 Factor ID 获取用户绑定的某个 MFA Factor 详情。 + * @returns GetFactorRespDto */ -public async verifyAuthentication(requestBody: VerifyAuthenticationDto, -): Promise { +public async getFactor({ + factorId, +}: { + /** MFA Factor ID **/ + factorId: string, +}): Promise { const result = await this.httpClient.request({ - method: 'POST', - url: '/api/v3/webauthn/authentication', - data: requestBody, + method: 'GET', + url: '/api/v3/get-factor', + params: { + factorId: factorId, + }, }); return result; } /** - * @summary 获取 webauthn 凭证创建初始化参数 - * @description 获取 webauthn 凭证创建初始化参数。此接口要求具备用户的登录态** - * @returns GetRegistrationOptionsRespDto + * @summary 获取可绑定的 MFA 认证要素 + * @description 获取所有应用已经开启、用户暂未绑定的 MFA 认证要素,用户可以从返回的列表中绑定新的 MFA 认证要素。 + * @returns ListFactorsToEnrollRespDto */ -public async initRegisterOptions(): Promise { +public async listFactorsToEnroll(): Promise { const result = await this.httpClient.request({ method: 'GET', - url: '/api/v3/webauthn/registration', + url: '/api/v3/list-factors-to-enroll', }); return result; } /** - * @summary 验证 webauthn 绑定注册认证器凭证 - * @description 验证 webauthn 绑定注册认证器凭证 - * @returns VerifyRegistrationResultRespDto + * @summary 校验用户 MFA 绑定的 OTP + * @description 校验用户 MFA 绑定的 OTP。 + * @returns MfaOtpVerityRespDto */ -public async verifyRegister(requestBody: VerifyRegistrationDto, -): Promise { +public async mfaOtpVerify(requestBody: MfaOtpVerityDto, +): Promise { const result = await this.httpClient.request({ method: 'POST', - url: '/api/v3/webauthn/registration', + url: '/api/v3/mfa-totp-verify', data: requestBody, }); return result; } - /** - * @summary 验证 MFA Token - * @description 验证 MFA Token - * @returns MfaTokenIntrospectResponse - */ - public async verifyMfaToken(formData: MfaTokenIntrospectEndpointParams, - ): Promise { - const result = await this.httpClient.request({ - method: 'POST', - url: '/mfa/token/introspection', - }); - return result; - } - - // ==== AUTO GENERATED AUTHENTICATION METHODS END ==== /** diff --git a/src/ManagementClient.ts b/src/ManagementClient.ts index 9d679b1..13340c8 100644 --- a/src/ManagementClient.ts +++ b/src/ManagementClient.ts @@ -26,6 +26,8 @@ import type { CancelSyncRiskOperationDto } from "./models/CancelSyncRiskOperatio import type { CancelSyncRiskOperationsRespDto } from "./models/CancelSyncRiskOperationsRespDto"; import type { ChangeExtIdpAssociationStateDto } from "./models/ChangeExtIdpAssociationStateDto"; import type { ChangeExtIdpConnStateDto } from "./models/ChangeExtIdpConnStateDto"; +import type { ChangePushCodeStatusDto } from "./models/ChangePushCodeStatusDto"; +import type { ChangeQRCodeStatusDto } from "./models/ChangeQRCodeStatusDto"; import type { ChangeUserPoolTenantExtIdpConnDto } from "./models/ChangeUserPoolTenantExtIdpConnDto"; import type { CheckDomainAvailable } from "./models/CheckDomainAvailable"; import type { CheckDomainAvailableSecretRespDto } from "./models/CheckDomainAvailableSecretRespDto"; @@ -36,6 +38,8 @@ import type { CheckParamsDataResourceResponseDto } from "./models/CheckParamsDat import type { CheckPermissionDto } from "./models/CheckPermissionDto"; import type { CheckPermissionNamespaceExistsDto } from "./models/CheckPermissionNamespaceExistsDto"; import type { CheckPermissionRespDto } from "./models/CheckPermissionRespDto"; +import type { CheckPushCodeStatusRespDto } from "./models/CheckPushCodeStatusRespDto"; +import type { CheckQRCodeStatusRespDto } from "./models/CheckQRCodeStatusRespDto"; import type { CheckRoleParamsDto } from "./models/CheckRoleParamsDto"; import type { CheckSessionStatusDto } from "./models/CheckSessionStatusDto"; import type { CheckSessionStatusRespDto } from "./models/CheckSessionStatusRespDto"; @@ -101,6 +105,7 @@ import type { DeleteAsaAccountBatchDto } from "./models/DeleteAsaAccountBatchDto import type { DeleteAsaAccountDto } from "./models/DeleteAsaAccountDto"; import type { DeleteAuthorizeDataPolicyDto } from "./models/DeleteAuthorizeDataPolicyDto"; import type { DeleteCommonResourcesBatchDto } from "./models/DeleteCommonResourcesBatchDto"; +import type { DeleteCustomFieldsReqDto } from "./models/DeleteCustomFieldsReqDto"; import type { DeleteDataPolicyDto } from "./models/DeleteDataPolicyDto"; import type { DeleteDataResourceDto } from "./models/DeleteDataResourceDto"; import type { DeleteDepartmentReqDto } from "./models/DeleteDepartmentReqDto"; @@ -124,13 +129,18 @@ import type { DepartmentSingleRespDto } from "./models/DepartmentSingleRespDto"; import type { EmailProviderRespDto } from "./models/EmailProviderRespDto"; import type { EmailTemplateSingleItemRespDto } from "./models/EmailTemplateSingleItemRespDto"; import type { EventAppPaginatedRespDto } from "./models/EventAppPaginatedRespDto"; +import type { ExchangeTokenSetWithQRcodeTicketDto } from "./models/ExchangeTokenSetWithQRcodeTicketDto"; import type { ExtIdpConnDetailSingleRespDto } from "./models/ExtIdpConnDetailSingleRespDto"; import type { ExtIdpDetailSingleRespDto } from "./models/ExtIdpDetailSingleRespDto"; import type { ExtIdpListPaginatedRespDto } from "./models/ExtIdpListPaginatedRespDto"; import type { ExtIdpSingleRespDto } from "./models/ExtIdpSingleRespDto"; +import type { GenePushCodeRespDto } from "./models/GenePushCodeRespDto"; +import type { GeneQRCodeRespDto } from "./models/GeneQRCodeRespDto"; import type { GenerateInviteTenantUserLink } from "./models/GenerateInviteTenantUserLink"; +import type { GenerateQrcodeDto } from "./models/GenerateQrcodeDto"; import type { GetAccessibleAppsRespDto } from "./models/GetAccessibleAppsRespDto"; import type { GetAdminAuditLogsDto } from "./models/GetAdminAuditLogsDto"; +import type { GetAlipayAuthInfoRespDto } from "./models/GetAlipayAuthInfoRespDto"; import type { GetApplicationPermissionStrategyRespDto } from "./models/GetApplicationPermissionStrategyRespDto"; import type { GetApplicationSecretRespDto } from "./models/GetApplicationSecretRespDto"; import type { GetAsaAccountAssignedTargetRespDto } from "./models/GetAsaAccountAssignedTargetRespDto"; @@ -143,15 +153,19 @@ import type { GetExternalUserResourceStructDto } from "./models/GetExternalUserR import type { GetExternalUserResourceStructRespDto } from "./models/GetExternalUserResourceStructRespDto"; import type { GetLoggedInAppsRespDto } from "./models/GetLoggedInAppsRespDto"; import type { GetLoginHistoryRespDto } from "./models/GetLoginHistoryRespDto"; +import type { GetMapInfoRespDto } from "./models/GetMapInfoRespDto"; import type { GetOtpSecretRespDto } from "./models/GetOtpSecretRespDto"; import type { GetPermissionNamespaceListResponseDto } from "./models/GetPermissionNamespaceListResponseDto"; import type { GetPermissionNamespaceResponseDto } from "./models/GetPermissionNamespaceResponseDto"; import type { GetPostByIdListDto } from "./models/GetPostByIdListDto"; import type { GetResourceAuthorizedTargetRespDto } from "./models/GetResourceAuthorizedTargetRespDto"; import type { GetResourceAuthorizedTargetsDto } from "./models/GetResourceAuthorizedTargetsDto"; +import type { GetSubjectAuthRespDto } from "./models/GetSubjectAuthRespDto"; import type { GetTenantListRespDto } from "./models/GetTenantListRespDto"; import type { GetTenantUserDto } from "./models/GetTenantUserDto"; import type { GetUserActionLogsDto } from "./models/GetUserActionLogsDto"; +import type { GetUserPasswordCiphertextDto } from "./models/GetUserPasswordCiphertextDto"; +import type { GetUserPasswordCiphertextRespDto } from "./models/GetUserPasswordCiphertextRespDto"; import type { GetUserPermissionListDto } from "./models/GetUserPermissionListDto"; import type { GetUserPermissionListRespDto } from "./models/GetUserPermissionListRespDto"; import type { GetUserResourcePermissionListDto } from "./models/GetUserResourcePermissionListDto"; @@ -175,8 +189,14 @@ import type { IsUserExistsReqDto } from "./models/IsUserExistsReqDto"; import type { IsUserExistsRespDto } from "./models/IsUserExistsRespDto"; import type { IsUserInDepartmentRespDto } from "./models/IsUserInDepartmentRespDto"; import type { KickUsersDto } from "./models/KickUsersDto"; +import type { LinkIdentity } from "./models/LinkIdentity"; import type { ListApplicationActiveUsersDto } from "./models/ListApplicationActiveUsersDto"; +import type { ListApplicationAuthDto } from "./models/ListApplicationAuthDto"; +import type { ListApplicationAuthPaginatedRespDto } from "./models/ListApplicationAuthPaginatedRespDto"; +import type { ListApplicationSubjectRespDto } from "./models/ListApplicationSubjectRespDto"; import type { ListArchivedUsersSingleRespDto } from "./models/ListArchivedUsersSingleRespDto"; +import type { ListAuthSubjectDto } from "./models/ListAuthSubjectDto"; +import type { ListCistomFieldsResDto } from "./models/ListCistomFieldsResDto"; import type { ListDataPoliciesPaginatedRespDto } from "./models/ListDataPoliciesPaginatedRespDto"; import type { ListDataPolicySubjectPaginatedRespDto } from "./models/ListDataPolicySubjectPaginatedRespDto"; import type { ListDataResourcesPaginatedRespDto } from "./models/ListDataResourcesPaginatedRespDto"; @@ -187,6 +207,7 @@ import type { ListSimpleDataPoliciesPaginatedRespDto } from "./models/ListSimple import type { ListTenantAdminDto } from "./models/ListTenantAdminDto"; import type { ListTenantUserDto } from "./models/ListTenantUserDto"; import type { ListUsersRequestDto } from "./models/ListUsersRequestDto"; +import type { LoginTokenRespDto } from "./models/LoginTokenRespDto"; import type { MFASettingsDto } from "./models/MFASettingsDto"; import type { MFASettingsRespDto } from "./models/MFASettingsRespDto"; import type { MultipleTenantAdminPaginatedRespDto } from "./models/MultipleTenantAdminPaginatedRespDto"; @@ -239,8 +260,12 @@ import type { SendManyTenantEmailDto } from "./models/SendManyTenantEmailDto"; import type { SendManyTenantSmsDto } from "./models/SendManyTenantSmsDto"; import type { SetCustomDataReqDto } from "./models/SetCustomDataReqDto"; import type { SetCustomFieldsReqDto } from "./models/SetCustomFieldsReqDto"; +import type { SetMfaStatusDto } from "./models/SetMfaStatusDto"; import type { SetUserBaseFieldsReqDto } from "./models/SetUserBaseFieldsReqDto"; import type { SetUserDepartmentsDto } from "./models/SetUserDepartmentsDto"; +import type { SigninByCredentialsDto } from "./models/SigninByCredentialsDto"; +import type { SigninByMobileDto } from "./models/SigninByMobileDto"; +import type { SignInByPushDto } from "./models/SignInByPushDto"; import type { SignUpDto } from "./models/SignUpDto"; import type { SyncJobPaginatedRespDto } from "./models/SyncJobPaginatedRespDto"; import type { SyncJobSingleRespDto } from "./models/SyncJobSingleRespDto"; @@ -259,8 +284,11 @@ import type { TriggerSyncRiskOperationDto } from "./models/TriggerSyncRiskOperat import type { TriggerSyncRiskOperationsRespDto } from "./models/TriggerSyncRiskOperationsRespDto"; import type { TriggerSyncTaskDto } from "./models/TriggerSyncTaskDto"; import type { TriggerSyncTaskRespDto } from "./models/TriggerSyncTaskRespDto"; +import type { UnlinkIdentity } from "./models/UnlinkIdentity"; +import type { UpdateApplicationMfaSettingsDto } from "./models/UpdateApplicationMfaSettingsDto"; import type { UpdateApplicationPermissionStrategyDataDto } from "./models/UpdateApplicationPermissionStrategyDataDto"; import type { UpdateAsaAccountDto } from "./models/UpdateAsaAccountDto"; +import type { UpdateAuthEnabledDto } from "./models/UpdateAuthEnabledDto"; import type { UpdateDataPolicyDto } from "./models/UpdateDataPolicyDto"; import type { UpdateDataPolicyResponseDto } from "./models/UpdateDataPolicyResponseDto"; import type { UpdateDataResourceDto } from "./models/UpdateDataResourceDto"; @@ -281,6 +309,7 @@ import type { UpdateResourceDto } from "./models/UpdateResourceDto"; import type { UpdateRoleDto } from "./models/UpdateRoleDto"; import type { UpdateSecuritySettingsDto } from "./models/UpdateSecuritySettingsDto"; import type { UpdateSyncTaskDto } from "./models/UpdateSyncTaskDto"; +import type { UpdateTenantAppqrcodeState } from "./models/UpdateTenantAppqrcodeState"; import type { UpdateTenantCooperatorDto } from "./models/UpdateTenantCooperatorDto"; import type { UpdateTenantDto } from "./models/UpdateTenantDto"; import type { UpdateTenantUserDto } from "./models/UpdateTenantUserDto"; @@ -299,21 +328,10 @@ import type { UserMfaSingleRespDto } from "./models/UserMfaSingleRespDto"; import type { UserPaginatedRespDto } from "./models/UserPaginatedRespDto"; import type { UserPoolTenantConfigDtoRespDto } from "./models/UserPoolTenantConfigDtoRespDto"; import type { UserSingleRespDto } from "./models/UserSingleRespDto"; -import type { ChangePushCodeStatusDto } from "./models/ChangePushCodeStatusDto"; -import type { ChangeQRCodeStatusDto } from "./models/ChangeQRCodeStatusDto"; -import type { CheckPushCodeStatusRespDto } from "./models/CheckPushCodeStatusRespDto"; -import type { CheckQRCodeStatusRespDto } from "./models/CheckQRCodeStatusRespDto"; -import type { ExchangeTokenSetWithQRcodeTicketDto } from "./models/ExchangeTokenSetWithQRcodeTicketDto"; import type { GeneFastpassQRCodeRespDto } from "./models/GeneFastpassQRCodeRespDto"; -import type { GenePushCodeRespDto } from "./models/GenePushCodeRespDto"; -import type { GeneQRCodeRespDto } from "./models/GeneQRCodeRespDto"; -import type { GenerateQrcodeDto } from "./models/GenerateQrcodeDto"; -import type { GetAlipayAuthInfoRespDto } from "./models/GetAlipayAuthInfoRespDto"; import type { GetFastpassQRCodeRelationAppsRespDto } from "./models/GetFastpassQRCodeRelationAppsRespDto"; -import type { LoginTokenRespDto } from "./models/LoginTokenRespDto"; -import type { SigninByCredentialsDto } from "./models/SigninByCredentialsDto"; -import type { SigninByMobileDto } from "./models/SigninByMobileDto"; -import type { SignInByPushDto } from "./models/SignInByPushDto"; +import type { GetPushCodeRelationAppsDto } from "./models/GetPushCodeRelationAppsDto"; +import type { GetPushCodeRelationAppsRespDto } from "./models/GetPushCodeRelationAppsRespDto"; import type { SignInFastpassDto } from "./models/SignInFastpassDto"; import type { AppQRCodeLoginDto } from "./models/AppQRCodeLoginDto"; import type { CreatePipelineFunctionDto } from "./models/CreatePipelineFunctionDto"; @@ -342,8 +360,6 @@ import type { DeleteAccessKeyDto } from "./models/DeleteAccessKeyDto"; import type { GetAccessKeyResponseDto } from "./models/GetAccessKeyResponseDto"; import type { ListAccessKeyResponseDto } from "./models/ListAccessKeyResponseDto"; import type { UpdateAccessKeyDto } from "./models/UpdateAccessKeyDto"; -import WebSocket from 'ws'; - import { DEFAULT_OPTIONS, @@ -352,37 +368,16 @@ import { import { ManagementHttpClient } from "./ManagementHttpClient"; import { domainC14n } from "./utils"; import Axios, { AxiosRequestConfig } from "axios"; -import { buildAuthorization, buildStringToSign } from "./utils/buildSignature"; -import {GetMapInfoRespDto} from "./models/GetMapInfoRespDto"; -import {UpdateAuthEnabledDto} from "./models/UpdateAuthEnabledDto"; -import {ListApplicationAuthDto} from "./models/ListApplicationAuthDto"; -import {ListApplicationAuthPaginatedRespDto} from "./models/ListApplicationAuthPaginatedRespDto"; -import {GetSubjectAuthRespDto} from "./models/GetSubjectAuthRespDto"; -import {ListAuthSubjectDto} from "./models/ListAuthSubjectDto"; -import {ListApplicationSubjectRespDto} from "./models/ListApplicationSubjectRespDto"; -import {UpdateApplicationMfaSettingsDto} from "./models/UpdateApplicationMfaSettingsDto"; - -const pkg = require("../package.json") export class ManagementClient { private httpClient: ManagementHttpClient; private options: ManagementClientOptions; - private wsMap: {[propName: string]: { - socket: WebSocket, - lockConnect: boolean, - timeConnect: number - }}; - private eventBus: {[propName: string]: [Function, Function][]}; - constructor(options: ManagementClientOptions) { // @ts-ignore - Object.keys(options).forEach((i: any) => typeof options[i] !== 'number' && !options[i] && delete options[i]); + Object.keys(options).forEach((i: any) => !options[i] && delete options[i]); this.options = Object.assign({}, DEFAULT_OPTIONS, options); Axios.defaults.baseURL = domainC14n(String(this.options.host)); this.httpClient = new ManagementHttpClient(this.options); - this.wsMap = {}; - this.eventBus = {} - if (!this.options.accessKeyId) { throw new Error("accessKeyId is required"); @@ -831,134 +826,443 @@ export class ManagementClient { } /** - * @summary 注册 + * @summary 使用用户凭证登录 * @description - * 此端点目前支持以下几种基于的注册方式: + * 此端点为基于直接 API 调用形式的登录端点,适用于你需要自建登录页面的场景。**此端点暂时不支持 MFA、信息补全、首次密码重置等流程,如有需要,请使用 OIDC 标准协议认证端点。** * - * 1. 基于密码(PASSWORD):用户名 + 密码,邮箱 + 密码。 - * 2. 基于一次性临时验证码(PASSCODE):手机号 + 验证码,邮箱 + 验证码。你需要先调用发送短信或者发送邮件接口获取验证码。 * - * 社会化登录等使用外部身份源“注册”请直接使用**登录**接口,我们会在其第一次登录的时候为其创建一个新账号。 + * 注意事项:取决于你在 Authing 创建应用时选择的**应用类型**和应用配置的**换取 token 身份验证方式**,在调用此接口时需要对客户端的身份进行不同形式的验证。 * - * @returns UserSingleRespDto + *
+ * 点击展开详情 + * + *
+ * + * 你可以在 [Authing 控制台](https://console.authing.cn) 的**应用** - **自建应用** - **应用详情** - **应用配置** - **其他设置** - **授权配置** + * 中找到**换取 token 身份验证方式** 配置项: + * + * > 单页 Web 应用和客户端应用隐藏,默认为 `none`,不允许修改;后端应用和标准 Web 应用可以修改此配置项。 + * + * ![](https://files.authing.co/api-explorer/tokenAuthMethod.jpg) + * + * #### 换取 token 身份验证方式为 none 时 + * + * 调用此接口不需要进行额外操作。 + * + * #### 换取 token 身份验证方式为 client_secret_post 时 + * + * 调用此接口时必须在 body 中传递 `client_id` 和 `client_secret` 参数,作为验证客户端身份的条件。其中 `client_id` 为应用 ID、`client_secret` 为应用密钥。 + * + * #### 换取 token 身份验证方式为 client_secret_basic 时 + * + * 调用此接口时必须在 HTTP 请求头中携带 `authorization` 请求头,作为验证客户端身份的条件。`authorization` 请求头的格式如下(其中 `client_id` 为应用 ID、`client_secret` 为应用密钥。): + * + * ``` + * Basic base64(:) + * ``` + * + * 结果示例: + * + * ``` + * Basic NjA2M2ZiMmYzY3h4eHg2ZGY1NWYzOWViOjJmZTdjODdhODFmODY3eHh4eDAzMjRkZjEyZGFlZGM3 + * ``` + * + * JS 代码示例: + * + * ```js + * 'Basic ' + Buffer.from(client_id + ':' + client_secret).toString('base64'); + * ``` + * + *
+ * + * + * @returns LoginTokenRespDto 成功认证 */ - public async signUp(requestBody: SignUpDto): Promise { + public async signInByCredentials( + requestBody: SigninByCredentialsDto + ): Promise { return await this.httpClient.request({ method: "POST", - url: "/api/v3/signup", + url: "/api/v3/signin", data: requestBody, }); } /** - * @summary 获取登录日志 - * @description 获取登录日志 - * @returns GetLoginHistoryRespDto - */ - public async getLoginHistory({ - appId, - clientIp, - success, - start, - end, - page = 1, - limit = 10, - }: { - /** 应用 ID,可根据应用 ID 筛选。默认不传获取所有应用的登录历史。 **/ - appId?: string; - /** 客户端 IP,可根据登录时的客户端 IP 进行筛选。默认不传获取所有登录 IP 的登录历史。 **/ - clientIp?: string; - /** 是否登录成功,可根据是否登录成功进行筛选。默认不传获取的记录中既包含成功也包含失败的的登录历史。 **/ - success?: boolean; - /** 开始时间,为单位为毫秒的时间戳 **/ - start?: number; - /** 结束时间,为单位为毫秒的时间戳 **/ - end?: number; - /** 当前页数,从 1 开始 **/ - page?: number; - /** 每页数目,最大不能超过 50,默认为 10 **/ - limit?: number; - }): Promise { - return await this.httpClient.request({ - method: "GET", - url: "/api/v3/get-my-login-history", - params: { - appId: appId, - clientIp: clientIp, - success: success, - start: start, - end: end, - page: page, - limit: limit, - }, - }); - } - - /** - * @summary 获取登录应用 - * @description 获取登录应用 - * @returns GetLoggedInAppsRespDto + * @summary 使用移动端社会化登录 + * @description + * 此端点为移动端社会化登录接口,使用第三方移动社会化登录返回的临时凭证登录,并换取用户的 `id_token` 和 `access_token`。请先阅读相应社会化登录的接入流程。 + * + * + * 注意事项:取决于你在 Authing 创建应用时选择的**应用类型**和应用配置的**换取 token 身份验证方式**,在调用此接口时需要对客户端的身份进行不同形式的验证。 + * + *
+ * 点击展开详情 + * + *
+ * + * 你可以在 [Authing 控制台](https://console.authing.cn) 的**应用** - **自建应用** - **应用详情** - **应用配置** - **其他设置** - **授权配置** + * 中找到**换取 token 身份验证方式** 配置项: + * + * > 单页 Web 应用和客户端应用隐藏,默认为 `none`,不允许修改;后端应用和标准 Web 应用可以修改此配置项。 + * + * ![](https://files.authing.co/api-explorer/tokenAuthMethod.jpg) + * + * #### 换取 token 身份验证方式为 none 时 + * + * 调用此接口不需要进行额外操作。 + * + * #### 换取 token 身份验证方式为 client_secret_post 时 + * + * 调用此接口时必须在 body 中传递 `client_id` 和 `client_secret` 参数,作为验证客户端身份的条件。其中 `client_id` 为应用 ID、`client_secret` 为应用密钥。 + * + * #### 换取 token 身份验证方式为 client_secret_basic 时 + * + * 调用此接口时必须在 HTTP 请求头中携带 `authorization` 请求头,作为验证客户端身份的条件。`authorization` 请求头的格式如下(其中 `client_id` 为应用 ID、`client_secret` 为应用密钥。): + * + * ``` + * Basic base64(:) + * ``` + * + * 结果示例: + * + * ``` + * Basic NjA2M2ZiMmYzY3h4eHg2ZGY1NWYzOWViOjJmZTdjODdhODFmODY3eHh4eDAzMjRkZjEyZGFlZGM3 + * ``` + * + * JS 代码示例: + * + * ```js + * 'Basic ' + Buffer.from(client_id + ':' + client_secret).toString('base64'); + * ``` + * + *
+ * + * + * @returns LoginTokenRespDto */ - public async getLoggedInApps(): Promise { + public async signInByMobile( + requestBody: SigninByMobileDto + ): Promise { return await this.httpClient.request({ - method: "GET", - url: "/api/v3/get-my-logged-in-apps", + method: "POST", + url: "/api/v3/signin-by-mobile", + data: requestBody, }); } /** - * @summary 获取具备访问权限的应用 - * @description 获取具备访问权限的应用 - * @returns GetAccessibleAppsRespDto + * @summary 获取支付宝 AuthInfo + * @description 此接口用于获取发起支付宝认证需要的[初始化参数 AuthInfo](https://opendocs.alipay.com/open/218/105325)。 + * @returns GetAlipayAuthInfoRespDto */ - public async getAccessibleApps(): Promise { + public async getAlipayAuthInfo({ + extIdpConnidentifier, + }: { + /** 外部身份源连接标志符 **/ + extIdpConnidentifier: string; + }): Promise { return await this.httpClient.request({ method: "GET", - url: "/api/v3/get-my-accessible-apps", + url: "/api/v3/get-alipay-authinfo", + params: { + extIdpConnidentifier: extIdpConnidentifier, + }, }); } /** - * @summary 获取租户列表 - * @description 获取租户列表 - * @returns GetTenantListRespDto + * @summary 生成用于登录的二维码 + * @description 生成用于登录的二维码,目前支持生成微信公众号扫码登录、小程序扫码登录、自建移动 APP 扫码登录的二维码。 + * @returns GeneQRCodeRespDto */ - public async getTenantList(): Promise { + public async geneQrCode( + requestBody: GenerateQrcodeDto + ): Promise { return await this.httpClient.request({ - method: "GET", - url: "/api/v3/get-my-tenant-list", + method: "POST", + url: "/api/v3/gene-qrcode", + data: requestBody, }); } /** - * @summary 获取角色列表 - * @description 获取角色列表 - * @returns RoleListRespDto + * @summary 查询二维码状态 + * @description 按照用户扫码顺序,共分为未扫码、已扫码等待用户确认、用户同意/取消授权、二维码过期以及未知错误六种状态,前端应该通过不同的状态给到用户不同的反馈。你可以通过下面这篇文章了解扫码登录详细的流程:https://docs.authing.cn/v2/concepts/how-qrcode-works.html. + * @returns CheckQRCodeStatusRespDto */ - public async getRoleList({ - namespace, + public async checkQrCodeStatus({ + qrcodeId, }: { - /** 所属权限分组(权限空间)的 Code **/ - namespace?: string; - }): Promise { + /** 二维码唯一 ID **/ + qrcodeId: string; + }): Promise { return await this.httpClient.request({ method: "GET", - url: "/api/v3/get-my-role-list", + url: "/api/v3/check-qrcode-status", params: { - namespace: namespace, + qrcodeId: qrcodeId, }, }); } /** - * @summary 获取分组列表 - * @description 获取分组列表 - * @returns GroupListRespDto - */ - public async getGroupList(): Promise { - return await this.httpClient.request({ - method: "GET", - url: "/api/v3/get-my-group-list", + * @summary 使用二维码 ticket 换取 TokenSet + * @description + * 此端点为使用二维码的 ticket 换取用户的 `access_token` 和 `id_token`。 + * + * + * 注意事项:取决于你在 Authing 创建应用时选择的**应用类型**和应用配置的**换取 token 身份验证方式**,在调用此接口时需要对客户端的身份进行不同形式的验证。 + * + *
+ * 点击展开详情 + * + *
+ * + * 你可以在 [Authing 控制台](https://console.authing.cn) 的**应用** - **自建应用** - **应用详情** - **应用配置** - **其他设置** - **授权配置** + * 中找到**换取 token 身份验证方式** 配置项: + * + * > 单页 Web 应用和客户端应用隐藏,默认为 `none`,不允许修改;后端应用和标准 Web 应用可以修改此配置项。 + * + * ![](https://files.authing.co/api-explorer/tokenAuthMethod.jpg) + * + * #### 换取 token 身份验证方式为 none 时 + * + * 调用此接口不需要进行额外操作。 + * + * #### 换取 token 身份验证方式为 client_secret_post 时 + * + * 调用此接口时必须在 body 中传递 `client_id` 和 `client_secret` 参数,作为验证客户端身份的条件。其中 `client_id` 为应用 ID、`client_secret` 为应用密钥。 + * + * #### 换取 token 身份验证方式为 client_secret_basic 时 + * + * 调用此接口时必须在 HTTP 请求头中携带 `authorization` 请求头,作为验证客户端身份的条件。`authorization` 请求头的格式如下(其中 `client_id` 为应用 ID、`client_secret` 为应用密钥。): + * + * ``` + * Basic base64(:) + * ``` + * + * 结果示例: + * + * ``` + * Basic NjA2M2ZiMmYzY3h4eHg2ZGY1NWYzOWViOjJmZTdjODdhODFmODY3eHh4eDAzMjRkZjEyZGFlZGM3 + * ``` + * + * JS 代码示例: + * + * ```js + * 'Basic ' + Buffer.from(client_id + ':' + client_secret).toString('base64'); + * ``` + * + *
+ * + * + * @returns LoginTokenRespDto + */ + public async exchangeTokenSetWithQrCodeTicket( + requestBody: ExchangeTokenSetWithQRcodeTicketDto + ): Promise { + return await this.httpClient.request({ + method: "POST", + url: "/api/v3/exchange-tokenset-with-qrcode-ticket", + data: requestBody, + }); + } + + /** + * @summary 自建 APP 扫码登录:APP 端修改二维码状态 + * @description 此端点用于在自建 APP 扫码登录中修改二维码状态,对应着在浏览器渲染出二维码之后,终端用户扫码、确认授权、取消授权的过程。**此接口要求具备用户的登录态**。 + * @returns CommonResponseDto + */ + public async changeQrCodeStatus( + requestBody: ChangeQRCodeStatusDto + ): Promise { + return await this.httpClient.request({ + method: "POST", + url: "/api/v3/change-qrcode-status", + data: requestBody, + }); + } + + /** + * @summary 推送登录 + * @description 推送登录。 + * @returns GenePushCodeRespDto + */ + public async signInByPush( + requestBody: SignInByPushDto + ): Promise { + return await this.httpClient.request({ + method: "POST", + url: "/api/v3/signin-by-push", + data: requestBody, + }); + } + + /** + * @summary 查询推送码状态 + * @description 按照推送码使用顺序,共分为已推送、等待用户 同意/取消 授权、推送码过期以及未知错误五种状态,前端应该通过不同的状态给到用户不同的反馈。 + * @returns CheckPushCodeStatusRespDto + */ + public async checkPushCodeStatus({ + pushCodeId, + }: { + /** 推送码(推送登录唯一 ID) **/ + pushCodeId: string; + }): Promise { + return await this.httpClient.request({ + method: "GET", + url: "/api/v3/check-pushcode-status", + params: { + pushCodeId: pushCodeId, + }, + }); + } + + /** + * @summary 推送登录:APP 端修改推送码状态 + * @description 此端点用于在 Authing 令牌 APP 推送登录中修改推送码状态,对应着在浏览器使用推送登录,点击登录之后,终端用户收到推送登录信息,确认授权、取消授权的过程。**此接口要求具备用户的登录态**。 + * @returns CommonResponseDto + */ + public async changePushCodeStatus( + requestBody: ChangePushCodeStatusDto + ): Promise { + return await this.httpClient.request({ + method: "POST", + url: "/api/v3/change-pushcode-status", + data: requestBody, + }); + } + + /** + * @summary 注册 + * @description + * 此端点目前支持以下几种基于的注册方式: + * + * 1. 基于密码(PASSWORD):用户名 + 密码,邮箱 + 密码。 + * 2. 基于一次性临时验证码(PASSCODE):手机号 + 验证码,邮箱 + 验证码。你需要先调用发送短信或者发送邮件接口获取验证码。 + * + * 社会化登录等使用外部身份源“注册”请直接使用**登录**接口,我们会在其第一次登录的时候为其创建一个新账号。 + * + * @returns UserSingleRespDto + */ + public async signUp(requestBody: SignUpDto): Promise { + return await this.httpClient.request({ + method: "POST", + url: "/api/v3/signup", + data: requestBody, + }); + } + + /** + * @summary 获取登录日志 + * @description 获取登录日志 + * @returns GetLoginHistoryRespDto + */ + public async getLoginHistory({ + appId, + clientIp, + success, + start, + end, + page = 1, + limit = 10, + }: { + /** 应用 ID,可根据应用 ID 筛选。默认不传获取所有应用的登录历史。 **/ + appId?: string; + /** 客户端 IP,可根据登录时的客户端 IP 进行筛选。默认不传获取所有登录 IP 的登录历史。 **/ + clientIp?: string; + /** 是否登录成功,可根据是否登录成功进行筛选。默认不传获取的记录中既包含成功也包含失败的的登录历史。 **/ + success?: boolean; + /** 开始时间,为单位为毫秒的时间戳 **/ + start?: number; + /** 结束时间,为单位为毫秒的时间戳 **/ + end?: number; + /** 当前页数,从 1 开始 **/ + page?: number; + /** 每页数目,最大不能超过 50,默认为 10 **/ + limit?: number; + }): Promise { + return await this.httpClient.request({ + method: "GET", + url: "/api/v3/get-my-login-history", + params: { + appId: appId, + clientIp: clientIp, + success: success, + start: start, + end: end, + page: page, + limit: limit, + }, + }); + } + + /** + * @summary 获取登录应用 + * @description 获取登录应用 + * @returns GetLoggedInAppsRespDto + */ + public async getLoggedInApps(): Promise { + return await this.httpClient.request({ + method: "GET", + url: "/api/v3/get-my-logged-in-apps", + }); + } + + /** + * @summary 获取具备访问权限的应用 + * @description 获取具备访问权限的应用 + * @returns GetAccessibleAppsRespDto + */ + public async getAccessibleApps(): Promise { + return await this.httpClient.request({ + method: "GET", + url: "/api/v3/get-my-accessible-apps", + }); + } + + /** + * @summary 获取租户列表 + * @description 获取租户列表 + * @returns GetTenantListRespDto + */ + public async getTenantList(): Promise { + return await this.httpClient.request({ + method: "GET", + url: "/api/v3/get-my-tenant-list", + }); + } + + /** + * @summary 获取角色列表 + * @description 获取角色列表 + * @returns RoleListRespDto + */ + public async getRoleList({ + namespace, + }: { + /** 所属权限分组(权限空间)的 Code **/ + namespace?: string; + }): Promise { + return await this.httpClient.request({ + method: "GET", + url: "/api/v3/get-my-role-list", + params: { + namespace: namespace, + }, + }); + } + + /** + * @summary 获取分组列表 + * @description 获取分组列表 + * @returns GroupListRespDto + */ + public async getGroupList(): Promise { + return await this.httpClient.request({ + method: "GET", + url: "/api/v3/get-my-group-list", }); } @@ -2162,19 +2466,99 @@ export class ManagementClient { }); } - // /** - // * @summary 获取用户自定义加密的密码 - // * @description 此功能主要是用户在控制台配置加基于 RSA、SM2 等加密的密钥后,加密用户的密码。 - // * @returns GetUserPasswordCiphertextRespDto - // */ - // public async getUserPasswordCiphertext(requestBody: GetUserPasswordCiphertextDto, - // ): Promise { - // return await this.httpClient.request({ - // method: 'POST', - // url: '/api/v3/get-user-password-ciphertext', - // data: requestBody, - // }); - // } + /** + * @summary 获取用户自定义加密的密码 + * @description 此功能主要是用户在控制台配置加基于 RSA、SM2 等加密的密钥后,加密用户的密码。 + * @returns GetUserPasswordCiphertextRespDto + */ + public async getUserPasswordCiphertext( + requestBody: GetUserPasswordCiphertextDto + ): Promise { + return await this.httpClient.request({ + method: "POST", + url: "/api/v3/get-user-password-ciphertext", + data: requestBody, + }); + } + + /** + * @summary 给用户绑定一个身份信息 + * @description 用户池管理员手动将来自外部身份源的身份信息绑定到用户上。绑定完成后,可以用执行过绑定操作的身份源登录到对应的 Authing 用户。 + * @returns any + */ + public async linkIdentity(requestBody: LinkIdentity): Promise { + return await this.httpClient.request({ + method: "POST", + url: "/api/v3/link-identity", + data: requestBody, + }); + } + + /** + * @summary 解除绑定用户在身份源下的所有身份信息 + * @description 解除绑定用户在某个身份源下的所有身份信息。解绑后,将无法使用执行过解绑操作的身份源登录到对应的 Authing 用户,除非重新绑定身份信息。 + * @returns any + */ + public async unlinkIdentity(requestBody: UnlinkIdentity): Promise { + return await this.httpClient.request({ + method: "POST", + url: "/api/v3/unlink-identity", + data: requestBody, + }); + } + + /** + * @summary 设置用户 MFA 状态 + * @description 设置用户 MFA 状态,即 MFA 触发数据。 + * @returns IsSuccessRespDto + */ + public async setUsersMfaStatus( + requestBody: SetMfaStatusDto + ): Promise { + return await this.httpClient.request({ + method: "POST", + url: "/api/v3/set-mfa-status", + data: requestBody, + }); + } + + /** + * @summary 获取用户 MFA 状态 + * @description 获取用户 MFA 状态,即 MFA 触发数据。 + * @returns GetMapInfoRespDto + */ + public async getUserMfaStatus({ + userId, + userIdType = "user_id", + }: { + /** 用户唯一标志,可以是用户 ID、用户名、邮箱、手机号、外部 ID、在外部身份源的 ID。 **/ + userId: string; + /** 用户 ID 类型,默认值为 `user_id`,可选值为: + * - `user_id`: Authing 用户 ID,如 `6319a1504f3xxxxf214dd5b7` + * - `phone`: 用户手机号 + * - `email`: 用户邮箱 + * - `username`: 用户名 + * - `external_id`: 用户在外部系统的 ID,对应 Authing 用户信息的 `externalId` 字段 + * - `identity`: 用户的外部身份源信息,格式为 `:`,其中 `` 为 Authing 身份源的 ID,`` 为用户在外部身份源的 ID。 + * 示例值:`62f20932716fbcc10d966ee5:ou_8bae746eac07cd2564654140d2a9ac61`。 + * **/ + userIdType?: + | "user_id" + | "external_id" + | "phone" + | "email" + | "username" + | "identity"; + }): Promise { + return await this.httpClient.request({ + method: "GET", + url: "/api/v3/get-mfa-status", + params: { + userId: userId, + userIdType: userIdType, + }, + }); + } /** * @summary 获取组织机构详情 @@ -3569,6 +3953,73 @@ export class ManagementClient { }); } + /** + * @summary 获取用户内置字段列表 + * @description 获取用户内置的字段列表 + * @returns ListCistomFieldsResDto + */ + public async listUserBaseFields({ + targetType, + dataType, + tenantId, + page = 1, + limit = 10, + userVisible, + adminVisible, + accessControl, + keyword, + lang, + }: { + /** 目标对象类型: + * - `USER`: 用户 + * - `ROLE`: 角色 + * - `GROUP`: 分组 + * - `DEPARTMENT`: 部门 + * ;该接口暂不支持分组(GROUP) **/ + targetType: "USER" | "ROLE" | "GROUP" | "DEPARTMENT"; + /** 字段类型 **/ + dataType: + | "STRING" + | "NUMBER" + | "DATETIME" + | "BOOLEAN" + | "OBJECT" + | "SELECT"; + /** 租户 ID **/ + tenantId?: string; + /** 当前页数,从 1 开始 **/ + page?: number; + /** 每页数目,最大不能超过 50,默认为 10 **/ + limit?: number; + /** 用户是否可见 **/ + userVisible?: boolean; + /** 管理员是否可见 **/ + adminVisible?: boolean; + /** 访问控制 **/ + accessControl?: boolean; + /** 搜索关键词 **/ + keyword?: string; + /** 搜索语言 **/ + lang?: string; + }): Promise { + return await this.httpClient.request({ + method: "GET", + url: "/api/v3/list-user-base-fields", + params: { + tenantId: tenantId, + targetType: targetType, + dataType: dataType, + page: page, + limit: limit, + userVisible: userVisible, + adminVisible: adminVisible, + accessControl: accessControl, + keyword: keyword, + lang: lang, + }, + }); + } + /** * @summary 修改用户内置字段配置 * @description 修改用户内置字段配置,内置字段不允许修改数据类型、唯一性。 @@ -3591,6 +4042,7 @@ export class ManagementClient { */ public async getCustomFields({ targetType, + tenantId, }: { /** 目标对象类型: * - `USER`: 用户 @@ -3599,12 +4051,82 @@ export class ManagementClient { * - `DEPARTMENT`: 部门 * ;该接口暂不支持分组(GROUP) **/ targetType: "USER" | "ROLE" | "GROUP" | "DEPARTMENT"; + /** 租户 ID **/ + tenantId?: string; }): Promise { return await this.httpClient.request({ method: "GET", url: "/api/v3/get-custom-fields", params: { targetType: targetType, + tenantId: tenantId, + }, + }); + } + + /** + * @summary 获取自定义字段列表 + * @description 通过主体类型,获取用户、部门或角色的自定义字段列表。 + * @returns ListCistomFieldsResDto + */ + public async listCustFields({ + targetType, + dataType, + tenantId, + page = 1, + limit = 10, + userVisible, + adminVisible, + accessControl, + keyword, + lang, + }: { + /** 目标对象类型: + * - `USER`: 用户 + * - `ROLE`: 角色 + * - `GROUP`: 分组 + * - `DEPARTMENT`: 部门 + * ;该接口暂不支持分组(GROUP) **/ + targetType: "USER" | "ROLE" | "GROUP" | "DEPARTMENT"; + /** 字段类型 **/ + dataType: + | "STRING" + | "NUMBER" + | "DATETIME" + | "BOOLEAN" + | "OBJECT" + | "SELECT"; + /** 租户 ID **/ + tenantId?: string; + /** 当前页数,从 1 开始 **/ + page?: number; + /** 每页数目,最大不能超过 50,默认为 10 **/ + limit?: number; + /** 用户是否可见 **/ + userVisible?: boolean; + /** 管理员是否可见 **/ + adminVisible?: boolean; + /** 访问控制 **/ + accessControl?: boolean; + /** 搜索关键词 **/ + keyword?: string; + /** 搜索语言 **/ + lang?: string; + }): Promise { + return await this.httpClient.request({ + method: "GET", + url: "/api/v3/list-custom-fields", + params: { + tenantId: tenantId, + targetType: targetType, + dataType: dataType, + page: page, + limit: limit, + userVisible: userVisible, + adminVisible: adminVisible, + accessControl: accessControl, + keyword: keyword, + lang: lang, }, }); } @@ -3624,6 +4146,21 @@ export class ManagementClient { }); } + /** + * @summary 删除自定义字段定义 + * @description 删除用户、部门或角色自定义字段定义。 + * @returns IsSuccessRespDto + */ + public async deleteCustomFields( + requestBody: DeleteCustomFieldsReqDto + ): Promise { + return await this.httpClient.request({ + method: "POST", + url: "/api/v3/delete-custom-fields", + data: requestBody, + }); + } + /** * @summary 设置自定义字段的值 * @description 给用户、角色或部门设置自定义字段的值,如果存在则更新,不存在则创建。 @@ -3645,10 +4182,13 @@ export class ManagementClient { * @returns GetCustomDataRespDto */ public async getCustomData({ + tenantId, targetType, targetIdentifier, namespace, }: { + /** 租户 ID **/ + tenantId: string; /** 目标对象类型: * - `USER`: 用户 * - `ROLE`: 角色 @@ -3670,6 +4210,7 @@ export class ManagementClient { method: "GET", url: "/api/v3/get-custom-data", params: { + tenantId: tenantId, targetType: targetType, targetIdentifier: targetIdentifier, namespace: namespace, @@ -3879,21 +4420,6 @@ export class ManagementClient { }); } - /** - * @summary 批量删除资源 - * @description 通过资源id批量删除资源 - * @returns IsSuccessRespDto - */ - public async deleteResourcesByIdBatch( - requestBody: DeleteCommonResourcesBatchDto - ): Promise { - return await this.httpClient.request({ - method: "POST", - url: "/api/v3/delete-common-resources-batch", - data: requestBody, - }); - } - /** * @summary 关联/取消关联应用资源到租户 * @description 通过资源唯一标识以及权限分组,关联或取消关联资源到租户 @@ -4254,20 +4780,20 @@ export class ManagementClient { * @returns GetSubjectAuthRespDto */ public async detailAuthSubject({ - targetId, - targetType, - appId, - }: { + targetId, + targetType, + appId, + }: { /** 主体 id **/ - targetId: string, + targetId: string; /** 主体类型 **/ - targetType: 'USER' | 'ROLE' | 'GROUP' | 'ORG' | 'AK_SK', + targetType: "USER" | "ROLE" | "GROUP" | "ORG" | "AK_SK"; /** 应用 ID **/ - appId: string, + appId: string; }): Promise { return await this.httpClient.request({ - method: 'GET', - url: '/api/v3/get-subject-auth-detail', + method: "GET", + url: "/api/v3/get-subject-auth-detail", params: { targetId: targetId, targetType: targetType, @@ -4281,11 +4807,12 @@ export class ManagementClient { * @description 主体授权列表 * @returns ListApplicationSubjectRespDto */ - public async listAuthSubject(requestBody: ListAuthSubjectDto, + public async listAuthSubject( + requestBody: ListAuthSubjectDto ): Promise { return await this.httpClient.request({ - method: 'POST', - url: '/api/v3/list-subject-auth', + method: "POST", + url: "/api/v3/list-subject-auth", data: requestBody, }); } @@ -4295,11 +4822,12 @@ export class ManagementClient { * @description 应用授权列表 * @returns ListApplicationAuthPaginatedRespDto */ - public async listAuthApplication(requestBody: ListApplicationAuthDto, + public async listAuthApplication( + requestBody: ListApplicationAuthDto ): Promise { return await this.httpClient.request({ - method: 'POST', - url: '/api/v3/list-applications-auth', + method: "POST", + url: "/api/v3/list-applications-auth", data: requestBody, }); } @@ -4309,11 +4837,12 @@ export class ManagementClient { * @description 更新授权开关 * @returns IsSuccessRespDto */ - public async enabledAuth(requestBody: UpdateAuthEnabledDto, + public async enabledAuth( + requestBody: UpdateAuthEnabledDto ): Promise { return await this.httpClient.request({ - method: 'POST', - url: '/api/v3/update-auth-enabled', + method: "POST", + url: "/api/v3/update-auth-enabled", data: requestBody, }); } @@ -4323,11 +4852,10 @@ export class ManagementClient { * @description 批量删除应用授权 * @returns IsSuccessRespDto */ - public async deleteAuth(authIds: Array, - ): Promise { + public async deleteAuth(authIds: Array): Promise { return await this.httpClient.request({ - method: 'DELETE', - url: '/api/v3/batch-applications-auth', + method: "DELETE", + url: "/api/v3/batch-applications-auth", params: { authIds: authIds, }, @@ -4340,14 +4868,14 @@ export class ManagementClient { * @returns ApplicationPaginatedRespDto */ public async listApplications({ - page = 1, - limit = 10, - isIntegrateApp = false, - isSelfBuiltApp = false, - ssoEnabled = false, - keywords, - all, - }: { + page = 1, + limit = 10, + isIntegrateApp = false, + isSelfBuiltApp = false, + ssoEnabled = false, + keywords, + all, + }: { /** 当前页数,从 1 开始 **/ page?: number; /** 每页数目,最大不能超过 50,默认为 10 **/ @@ -4359,9 +4887,9 @@ export class ManagementClient { /** 是否开启单点登录 **/ ssoEnabled?: boolean; /** 模糊搜索字符串 **/ - keywords?: string, + keywords?: string; /** 搜索应用,true:搜索所有应用, 默认为 false **/ - all?: boolean, + all?: boolean; }): Promise { return await this.httpClient.request({ method: "GET", @@ -4672,6 +5200,21 @@ export class ManagementClient { }); } + /** + * @summary 更新租户控制台扫码登录状态 + * @description 更新租户控制台扫码登录状态 + * @returns IsSuccessRespDto + */ + public async updateTenantQrCodeState( + requestBody: UpdateTenantAppqrcodeState + ): Promise { + return await this.httpClient.request({ + method: "POST", + url: "/api/v3/update-userpool-tenant-appqrcode-state", + data: requestBody, + }); + } + /** * @summary 设置用户池多租户身份源连接 * @description 设置用户池多租户身份源连接,支持同时设置多个身份源连接,支持设置连接和取消连接 @@ -4692,11 +5235,12 @@ export class ManagementClient { * @description 传入 MFA 认证因素列表进行开启或关闭 * @returns MFASettingsRespDto */ - public async updateApplicationMfaSettings(requestBody: UpdateApplicationMfaSettingsDto, + public async updateApplicationMfaSettings( + requestBody: UpdateApplicationMfaSettingsDto ): Promise { return await this.httpClient.request({ - method: 'POST', - url: '/api/v3/update-application-mfa-settings', + method: "POST", + url: "/api/v3/update-application-mfa-settings", data: requestBody, }); } @@ -4707,14 +5251,14 @@ export class ManagementClient { * @returns GetMapInfoRespDto */ public async getMfaTriggerData({ - appId, - userId, - userIdType = 'user_id', - }: { + appId, + userId, + userIdType = "user_id", + }: { /** 所属应用 ID **/ - appId: string, + appId: string; /** 用户唯一标志,可以是用户 ID、用户名、邮箱、手机号、外部 ID、在外部身份源的 ID。 **/ - userId: string, + userId: string; /** 用户 ID 类型,默认值为 `user_id`,可选值为: * - `user_id`: Authing 用户 ID,如 `6319a1504f3xxxxf214dd5b7` * - `phone`: 用户手机号 @@ -4724,11 +5268,17 @@ export class ManagementClient { * - `identity`: 用户的外部身份源信息,格式为 `:`,其中 `` 为 Authing 身份源的 ID,`` 为用户在外部身份源的 ID。 * 示例值:`62f20932716fbcc10d966ee5:ou_8bae746eac07cd2564654140d2a9ac61`。 * **/ - userIdType?: 'user_id' | 'external_id' | 'phone' | 'email' | 'username' | 'identity', + userIdType?: + | "user_id" + | "external_id" + | "phone" + | "email" + | "username" + | "identity"; }): Promise { return await this.httpClient.request({ - method: 'GET', - url: '/api/v3/get-mfa-trigger-data', + method: "GET", + url: "/api/v3/get-mfa-trigger-data", params: { appId: appId, userId: userId, @@ -5090,6 +5640,7 @@ export class ManagementClient { withSourceAppDetail, page, limit, + source, }: { /** 搜索关键字 **/ keywords?: string; @@ -5105,6 +5656,8 @@ export class ManagementClient { page?: string; /** 每页获取的数据量 **/ limit?: string; + /** 租户来源 **/ + source?: any; }): Promise { return await this.httpClient.request({ method: "GET", @@ -5117,6 +5670,43 @@ export class ManagementClient { withSourceAppDetail: withSourceAppDetail, page: page, limit: limit, + source: source, + }, + }); + } + + /** + * @summary 获取租户一点点的信息 + * @description 根据租户 ID 获取租户一点点的详情 + * @returns TenantSingleRespDto + */ + public async getTenantLittleInfo({ + tenantId, + withMembersCount, + withAppDetail, + withCreatorDetail, + withSourceAppDetail, + }: { + /** 租户 ID **/ + tenantId: string; + /** 是否增加返回租户成员统计 **/ + withMembersCount?: boolean; + /** 增加返回租户关联应用简单信息 **/ + withAppDetail?: boolean; + /** 增加返回租户下创建者简单信息 **/ + withCreatorDetail?: boolean; + /** 增加返回租户来源应用简单信息 **/ + withSourceAppDetail?: boolean; + }): Promise { + return await this.httpClient.request({ + method: "GET", + url: "/api/v3/get-tenant-little-info", + params: { + tenantId: tenantId, + withMembersCount: withMembersCount, + withAppDetail: withAppDetail, + withCreatorDetail: withCreatorDetail, + withSourceAppDetail: withSourceAppDetail, }, }); } @@ -5576,13 +6166,33 @@ export class ManagementClient { } /** - * @summary 发送邀请租户用户邮件 - * @description 向多个邮箱发送邀请成为租户用户的邮件 - * @returns CommonResponseDto + * @summary 获取租户详情 + * @description 根据租户 Code 获取租户详情 + * @returns TenantSingleRespDto */ - public async sendInviteTenantUserEmail( - requestBody: sendInviteTenantUserEmailDto - ): Promise { + public async getTenantByCode({ + code, + }: { + /** 租户 Code **/ + code: string; + }): Promise { + return await this.httpClient.request({ + method: "GET", + url: "/api/v3/get-tenant-by-code", + params: { + code: code, + }, + }); + } + + /** + * @summary 发送邀请租户用户邮件 + * @description 向多个邮箱发送邀请成为租户用户的邮件 + * @returns CommonResponseDto + */ + public async sendInviteTenantUserEmail( + requestBody: sendInviteTenantUserEmailDto + ): Promise { return await this.httpClient.request({ method: "POST", url: "/api/v3/send-invite-tenant-user-email", @@ -7803,247 +8413,16 @@ export class ManagementClient { } /** - * @summary 使用移动端社会化登录 - * @description - * 此端点为移动端社会化登录接口,使用第三方移动社会化登录返回的临时凭证登录,并换取用户的 `id_token` 和 `access_token`。请先阅读相应社会化登录的接入流程。 - * - * - * 注意事项:取决于你在 Authing 创建应用时选择的**应用类型**和应用配置的**换取 token 身份验证方式**,在调用此接口时需要对客户端的身份进行不同形式的验证。 - * - *
- * 点击展开详情 - * - *
- * - * 你可以在 [Authing 控制台](https://console.authing.cn) 的**应用** - **自建应用** - **应用详情** - **应用配置** - **其他设置** - **授权配置** - * 中找到**换取 token 身份验证方式** 配置项: - * - * > 单页 Web 应用和客户端应用隐藏,默认为 `none`,不允许修改;后端应用和标准 Web 应用可以修改此配置项。 - * - * ![](https://files.authing.co/api-explorer/tokenAuthMethod.jpg) - * - * #### 换取 token 身份验证方式为 none 时 - * - * 调用此接口不需要进行额外操作。 - * - * #### 换取 token 身份验证方式为 client_secret_post 时 - * - * 调用此接口时必须在 body 中传递 `client_id` 和 `client_secret` 参数,作为验证客户端身份的条件。其中 `client_id` 为应用 ID、`client_secret` 为应用密钥。 - * - * #### 换取 token 身份验证方式为 client_secret_basic 时 - * - * 调用此接口时必须在 HTTP 请求头中携带 `authorization` 请求头,作为验证客户端身份的条件。`authorization` 请求头的格式如下(其中 `client_id` 为应用 ID、`client_secret` 为应用密钥。): - * - * ``` - * Basic base64(:) - * ``` - * - * 结果示例: - * - * ``` - * Basic NjA2M2ZiMmYzY3h4eHg2ZGY1NWYzOWViOjJmZTdjODdhODFmODY3eHh4eDAzMjRkZjEyZGFlZGM3 - * ``` - * - * JS 代码示例: - * - * ```js - * 'Basic ' + Buffer.from(client_id + ':' + client_secret).toString('base64'); - * ``` - * - *
- * - * - * @returns LoginTokenRespDto - */ - public async signInByMobile( - requestBody: SigninByMobileDto - ): Promise { - return await this.httpClient.request({ - method: "POST", - url: "/api/v3/signin-by-mobile", - data: requestBody, - }); - } - - /** - * @summary 获取支付宝 AuthInfo - * @description 此接口用于获取发起支付宝认证需要的[初始化参数 AuthInfo](https://opendocs.alipay.com/open/218/105325)。 - * @returns GetAlipayAuthInfoRespDto - */ - public async getAlipayAuthInfo({ - extIdpConnidentifier, - }: { - /** 外部身份源连接标志符 **/ - extIdpConnidentifier: string; - }): Promise { - return await this.httpClient.request({ - method: "GET", - url: "/api/v3/get-alipay-authinfo", - params: { - extIdpConnidentifier: extIdpConnidentifier, - }, - }); - } - - /** - * @summary 生成用于登录的二维码 - * @description 生成用于登录的二维码,目前支持生成微信公众号扫码登录、小程序扫码登录、自建移动 APP 扫码登录的二维码。 - * @returns GeneQRCodeRespDto - */ - public async geneQrCode( - requestBody: GenerateQrcodeDto - ): Promise { - return await this.httpClient.request({ - method: "POST", - url: "/api/v3/gene-qrcode", - data: requestBody, - }); - } - - /** - * @summary 查询二维码状态 - * @description 按照用户扫码顺序,共分为未扫码、已扫码等待用户确认、用户同意/取消授权、二维码过期以及未知错误六种状态,前端应该通过不同的状态给到用户不同的反馈。你可以通过下面这篇文章了解扫码登录详细的流程:https://docs.authing.cn/v2/concepts/how-qrcode-works.html. - * @returns CheckQRCodeStatusRespDto - */ - public async checkQrCodeStatus({ - qrcodeId, - }: { - /** 二维码唯一 ID **/ - qrcodeId: string; - }): Promise { - return await this.httpClient.request({ - method: "GET", - url: "/api/v3/check-qrcode-status", - params: { - qrcodeId: qrcodeId, - }, - }); - } - - /** - * @summary 使用二维码 ticket 换取 TokenSet - * @description - * 此端点为使用二维码的 ticket 换取用户的 `access_token` 和 `id_token`。 - * - * - * 注意事项:取决于你在 Authing 创建应用时选择的**应用类型**和应用配置的**换取 token 身份验证方式**,在调用此接口时需要对客户端的身份进行不同形式的验证。 - * - *
- * 点击展开详情 - * - *
- * - * 你可以在 [Authing 控制台](https://console.authing.cn) 的**应用** - **自建应用** - **应用详情** - **应用配置** - **其他设置** - **授权配置** - * 中找到**换取 token 身份验证方式** 配置项: - * - * > 单页 Web 应用和客户端应用隐藏,默认为 `none`,不允许修改;后端应用和标准 Web 应用可以修改此配置项。 - * - * ![](https://files.authing.co/api-explorer/tokenAuthMethod.jpg) - * - * #### 换取 token 身份验证方式为 none 时 - * - * 调用此接口不需要进行额外操作。 - * - * #### 换取 token 身份验证方式为 client_secret_post 时 - * - * 调用此接口时必须在 body 中传递 `client_id` 和 `client_secret` 参数,作为验证客户端身份的条件。其中 `client_id` 为应用 ID、`client_secret` 为应用密钥。 - * - * #### 换取 token 身份验证方式为 client_secret_basic 时 - * - * 调用此接口时必须在 HTTP 请求头中携带 `authorization` 请求头,作为验证客户端身份的条件。`authorization` 请求头的格式如下(其中 `client_id` 为应用 ID、`client_secret` 为应用密钥。): - * - * ``` - * Basic base64(:) - * ``` - * - * 结果示例: - * - * ``` - * Basic NjA2M2ZiMmYzY3h4eHg2ZGY1NWYzOWViOjJmZTdjODdhODFmODY3eHh4eDAzMjRkZjEyZGFlZGM3 - * ``` - * - * JS 代码示例: - * - * ```js - * 'Basic ' + Buffer.from(client_id + ':' + client_secret).toString('base64'); - * ``` - * - *
- * - * - * @returns LoginTokenRespDto - */ - public async exchangeTokenSetWithQrCodeTicket( - requestBody: ExchangeTokenSetWithQRcodeTicketDto - ): Promise { - return await this.httpClient.request({ - method: "POST", - url: "/api/v3/exchange-tokenset-with-qrcode-ticket", - data: requestBody, - }); - } - - /** - * @summary 自建 APP 扫码登录:APP 端修改二维码状态 - * @description 此端点用于在自建 APP 扫码登录中修改二维码状态,对应着在浏览器渲染出二维码之后,终端用户扫码、确认授权、取消授权的过程。**此接口要求具备用户的登录态**。 - * @returns CommonResponseDto - */ - public async changeQrCodeStatus( - requestBody: ChangeQRCodeStatusDto - ): Promise { - return await this.httpClient.request({ - method: "POST", - url: "/api/v3/change-qrcode-status", - data: requestBody, - }); - } - - /** - * @summary 推送登录 - * @description 推送登录。 - * @returns GenePushCodeRespDto + * @summary 获取推送登录请求关联的客户端应用 + * @description 此端点用于在 Authing 令牌 APP 收到推送登录通知时,可检查当前用户登录的应用是否支持对推送登录请求进行授权。 + * @returns GetPushCodeRelationAppsRespDto */ - public async signInByPush( - requestBody: SignInByPushDto - ): Promise { + public async getPushLoginRelationApps( + requestBody: GetPushCodeRelationAppsDto + ): Promise { return await this.httpClient.request({ method: "POST", - url: "/api/v3/signin-by-push", - data: requestBody, - }); - } - - /** - * @summary 查询推送码状态 - * @description 按照推送码使用顺序,共分为已推送、等待用户 同意/取消 授权、推送码过期以及未知错误五种状态,前端应该通过不同的状态给到用户不同的反馈。 - * @returns CheckPushCodeStatusRespDto - */ - public async checkPushCodeStatus({ - pushCodeId, - }: { - /** 推送码(推送登录唯一 ID) **/ - pushCodeId: string; - }): Promise { - return await this.httpClient.request({ - method: "GET", - url: "/api/v3/check-pushcode-status", - params: { - pushCodeId: pushCodeId, - }, - }); - } - - /** - * @summary 推送登录:APP 端修改推送码状态 - * @description 此端点用于在 Authing 令牌 APP 推送登录中修改推送码状态,对应着在浏览器使用推送登录,点击登录之后,终端用户收到推送登录信息,确认授权、取消授权的过程。**此接口要求具备用户的登录态**。 - * @returns CommonResponseDto - */ - public async changePushCodeStatus( - requestBody: ChangePushCodeStatusDto - ): Promise { - return await this.httpClient.request({ - method: "POST", - url: "/api/v3/change-pushcode-status", + url: "/api/v3/get-pushlogin-relation-apps", data: requestBody, }); } @@ -8513,154 +8892,17 @@ export class ManagementClient { } /** - * @summary socket 重连 - * @returns - */ - private reconnect(eventName: string) { - return new Promise((resolve, reject) => { - if (this.options.retryTimes && this.wsMap[eventName].timeConnect < this.options.retryTimes) { - if (!this.wsMap[eventName].lockConnect) { - this.wsMap[eventName].lockConnect = true - this.wsMap[eventName].timeConnect ++ - setTimeout(() => { - this.wsMap[eventName].lockConnect = false - this.initWebSocket(eventName, true).then(res => { - resolve(true) - }).catch(e => { - reject(e) - }) - }, 2000); - } - } else { - reject(`socket 服务连接超时`); - } - }) - } - - /** - * @summary 建立 socket 连接,监听 message 回调事件队列 - * @returns - */ - private initWebSocket(eventName: string, retry?: boolean) { - return new Promise((resolve, reject) => { - if (!this.wsMap[eventName] || retry) { - - this.wsMap[eventName] = { - socket: new WebSocket(`${this.options.socketUri}/events/v1/management/sub?code=${eventName}`, { - headers: { - // 构建 token - authorization: buildAuthorization( - this.options.accessKeyId, - this.options.accessKeySecret, - buildStringToSign("websocket", '', {}, {}) - ) - } - }), - timeConnect: retry ? this.wsMap[eventName].timeConnect : 0, - lockConnect: false - } - - this.wsMap[eventName].socket.on('open', () => { - resolve(true) - }) - - this.wsMap[eventName].socket.on('message', (data: Buffer) => { - try { - if (this.eventBus[eventName]) { - this.eventBus[eventName].forEach(callback => { - callback[0](data.toString("utf8")) - }) - } else { - // 未订阅事件 - console.warn("未订阅的事件:", eventName); - } - } catch (error) { - return reject(`数据格式化错误,检查传输数据格式!!! ${error}`); - } - }) - - this.wsMap[eventName].socket.on('error', async(e) => { - try { - await this.reconnect(eventName) - resolve(true) - } catch (error) { - return reject(`socket 连接异常:${e}`) - } - }) - - this.wsMap[eventName].socket.on('close', async() => { - try { - await this.reconnect(eventName) - resolve(true) - } catch (error) { - return reject(`socket 连接关闭`) - } - }) - } else { - resolve(true) - } - }) - } - - /** - * @summary 事件订阅 - * @description 订阅后通过建立 socket 连接接收服务端消息回调 - * @returns - */ - public sub(eventName: string, callback: Function, errCallback: Function) { - /** - * 1. 判断是否连接 socket - * 2. 获取 socket 实例 - * 3. 订阅 - */ - if (typeof eventName !== 'string') { - throw new Error("订阅事件名称为 string 类型!!!") - } - - if (typeof callback !== 'function') { - throw new Error("订阅事件回调函数需要为 function 类型!!!"); - } - - if (!this.options.socketUri) { - throw new Error("订阅事件需要添加 socketUri 连接地址!!!") - } - - this.initWebSocket(eventName).catch(e => { - this.eventBus[eventName].forEach((item) => { - item[1]?.(e) - }) - }) - - if (this.eventBus[eventName]) { - this.eventBus[eventName].push([callback, errCallback]) - } else { - this.eventBus[eventName] = [[callback, errCallback]] - } - } - - /** - * @summary 事件发布 - * @description 客户调用发布事件到事件中心 - * @returns + * @summary 更新一个管理员 AccessKey + * @description 根据 AccessKeyId 更新一个管理员 AccessKey,目前只支持更新 status,status 支持 activated / revoked + * @returns IsSuccessRespDto */ - public async pub(eventName: string, data: string) { - if (typeof eventName !== 'string') { - throw new Error("事件名称为 string 类型!!!") - } - - if (typeof data !== 'string') { - throw new Error("发布数据为 string 类型!!!") - } - + public async updateAccessKey( + requestBody: UpdateAccessKeyDto + ): Promise { return await this.httpClient.request({ method: "POST", - url: "/api/v3/pub-event", - data: { - eventType: eventName, - source: `${pkg.name}: ${pkg.version}`, - eventData: data - }, + url: "/api/v3/update-access-key", + data: requestBody, }); } - } diff --git a/src/models/ApplicationTabMethodsSortConfigDto.ts b/src/models/ApplicationTabMethodsSortConfigDto.ts new file mode 100644 index 0000000..ba83519 --- /dev/null +++ b/src/models/ApplicationTabMethodsSortConfigDto.ts @@ -0,0 +1,6 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type ApplicationTabMethodsSortConfigDto = { +}; diff --git a/src/models/CountCustomFieldsDto.ts b/src/models/CountCustomFieldsDto.ts new file mode 100644 index 0000000..cc9cfe7 --- /dev/null +++ b/src/models/CountCustomFieldsDto.ts @@ -0,0 +1,18 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type CountCustomFieldsDto = { + /** + * 记录总数 + */ + all: number; + /** + * 计数 + */ + userVisible: number; + /** + * 计数 + */ + adminVisible: number; +}; diff --git a/src/models/CreateTenantDto.ts b/src/models/CreateTenantDto.ts index 2f82dd3..e20fb59 100644 --- a/src/models/CreateTenantDto.ts +++ b/src/models/CreateTenantDto.ts @@ -27,4 +27,24 @@ export type CreateTenantDto = { * 租户来源的应用 ID,该值不存在时代表租户来源为 Authing 控制台 */ sourceAppId?: string; + /** + * 企业邮箱域名 + */ + enterpriseDomains?: Array; + /** + * 租户过期时间 + */ + expireTime?: string; + /** + * 租户 MAU 上限 + */ + mauAmount?: number; + /** + * 租户成员上限 + */ + memberAmount?: number; + /** + * 租户管理员上限 + */ + adminAmount?: number; }; diff --git a/src/models/DeleteCustomFieldDto.ts b/src/models/DeleteCustomFieldDto.ts new file mode 100644 index 0000000..e09a1c2 --- /dev/null +++ b/src/models/DeleteCustomFieldDto.ts @@ -0,0 +1,29 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type DeleteCustomFieldDto = { + /** + * 主体类型,目前支持用户、角色、分组和部门 + */ + targetType: DeleteCustomFieldDto.targetType; + /** + * 字段 key,不能和内置字段的 key 冲突,**设置之后将不能进行修改**。 + */ + key: string; +}; + +export namespace DeleteCustomFieldDto { + + /** + * 主体类型,目前支持用户、角色、分组和部门 + */ + export enum targetType { + USER = 'USER', + ROLE = 'ROLE', + GROUP = 'GROUP', + DEPARTMENT = 'DEPARTMENT', + } + + +} diff --git a/src/models/DeleteCustomFieldsReqDto.ts b/src/models/DeleteCustomFieldsReqDto.ts new file mode 100644 index 0000000..01afaab --- /dev/null +++ b/src/models/DeleteCustomFieldsReqDto.ts @@ -0,0 +1,16 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { DeleteCustomFieldDto } from './DeleteCustomFieldDto'; + +export type DeleteCustomFieldsReqDto = { + /** + * 租户 ID + */ + tenantId: string; + /** + * 自定义字段列表 + */ + list: Array; +}; diff --git a/src/models/GetCustomDataDto.ts b/src/models/GetCustomDataDto.ts index 4bed61e..9d69e35 100644 --- a/src/models/GetCustomDataDto.ts +++ b/src/models/GetCustomDataDto.ts @@ -6,6 +6,10 @@ * 通过筛选条件,获取用户、分组、角色、组织机构的自定义字段值。 */ export type GetCustomDataDto = { + /** + * 租户 ID + */ + tenantId?: any; /** * 目标对象类型: * - `USER`: 用户 diff --git a/src/models/GetCustomFieldsDto.ts b/src/models/GetCustomFieldsDto.ts index a9478d9..e0ddb06 100644 --- a/src/models/GetCustomFieldsDto.ts +++ b/src/models/GetCustomFieldsDto.ts @@ -15,4 +15,8 @@ export type GetCustomFieldsDto = { * ;该接口暂不支持分组(GROUP) */ targetType?: any; + /** + * 租户 ID + */ + tenantId?: any; }; diff --git a/src/models/GetMfaInfoDataDto.ts b/src/models/GetMfaInfoDataDto.ts index 5011aec..1c7e2be 100644 --- a/src/models/GetMfaInfoDataDto.ts +++ b/src/models/GetMfaInfoDataDto.ts @@ -12,39 +12,39 @@ export type GetMfaInfoDataDto = { /** * MFA 绑定的手机号 */ - mfaPhone: string; + mfaPhone?: string; /** * MFA 绑定的手机区号 */ - mfaPhoneCountryCode: string; + mfaPhoneCountryCode?: string; /** * MFA 绑定的邮箱 */ - mfaEmail: string; + mfaEmail?: string; /** * 用户昵称 */ - nickname: string; + nickname?: string; /** * 用户名 */ - username: string; + username?: string; /** * 用户手机号 */ - phone: string; + phone?: string; /** * 用户手机区号 */ - phoneCountryCode: string; + phoneCountryCode?: string; /** * 人脸校验是否开启 */ - faceMfaEnabled: boolean; + faceMfaEnabled?: boolean; /** * OTP 校验是否开启 */ - totpMfaEnabled: boolean; + totpMfaEnabled?: boolean; /** * MFA Factor 列表 */ diff --git a/src/models/GetMfaStatusDto.ts b/src/models/GetMfaStatusDto.ts new file mode 100644 index 0000000..5ab481a --- /dev/null +++ b/src/models/GetMfaStatusDto.ts @@ -0,0 +1,25 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * 获取用户 MFA 状态,即 MFA 触发数据。 + */ +export type GetMfaStatusDto = { + /** + * 用户唯一标志,可以是用户 ID、用户名、邮箱、手机号、外部 ID、在外部身份源的 ID。 + */ + userId?: any; + /** + * 用户 ID 类型,默认值为 `user_id`,可选值为: + * - `user_id`: Authing 用户 ID,如 `6319a1504f3xxxxf214dd5b7` + * - `phone`: 用户手机号 + * - `email`: 用户邮箱 + * - `username`: 用户名 + * - `external_id`: 用户在外部系统的 ID,对应 Authing 用户信息的 `externalId` 字段 + * - `identity`: 用户的外部身份源信息,格式为 `:`,其中 `` 为 Authing 身份源的 ID,`` 为用户在外部身份源的 ID。 + * 示例值:`62f20932716fbcc10d966ee5:ou_8bae746eac07cd2564654140d2a9ac61`。 + * + */ + userIdType?: any; +}; diff --git a/src/models/GetTenantByCodeDto.ts b/src/models/GetTenantByCodeDto.ts new file mode 100644 index 0000000..b07a742 --- /dev/null +++ b/src/models/GetTenantByCodeDto.ts @@ -0,0 +1,13 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * 根据租户 Code 获取租户详情 + */ +export type GetTenantByCodeDto = { + /** + * 租户 Code + */ + code?: any; +}; diff --git a/src/models/GetTenantLittleInfoDto.ts b/src/models/GetTenantLittleInfoDto.ts new file mode 100644 index 0000000..908973f --- /dev/null +++ b/src/models/GetTenantLittleInfoDto.ts @@ -0,0 +1,29 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * 根据租户 ID 获取租户一点点的详情 + */ +export type GetTenantLittleInfoDto = { + /** + * 租户 ID + */ + tenantId?: any; + /** + * 是否增加返回租户成员统计 + */ + withMembersCount?: any; + /** + * 增加返回租户关联应用简单信息 + */ + withAppDetail?: any; + /** + * 增加返回租户下创建者简单信息 + */ + withCreatorDetail?: any; + /** + * 增加返回租户来源应用简单信息 + */ + withSourceAppDetail?: any; +}; diff --git a/src/models/LinkIdentity.ts b/src/models/LinkIdentity.ts new file mode 100644 index 0000000..1e23c56 --- /dev/null +++ b/src/models/LinkIdentity.ts @@ -0,0 +1,26 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type LinkIdentity = { + /** + * 必传,用户在该外部身份源的唯一标识,需要从外部身份源的认证返回值中获取。 + */ + userIdInIdp: string; + /** + * 必传,进行绑定操作的 Authing 用户 ID。 + */ + userId: string; + /** + * 必传,身份源 ID,用于指定该身份属于哪个身份源。 + */ + extIdpId: string; + /** + * 非必传,表示该条身份的具体类型,可从用户身份信息的 type 字段中获取。如果不传,默认为 generic + */ + type?: string; + /** + * 已废弃,可任意传入,未来将移除该字段。 + */ + isSocial?: boolean; +}; diff --git a/src/models/ListCistomFieldsResDto.ts b/src/models/ListCistomFieldsResDto.ts new file mode 100644 index 0000000..c83e62b --- /dev/null +++ b/src/models/ListCistomFieldsResDto.ts @@ -0,0 +1,28 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ListCustomFieldsDto } from './ListCustomFieldsDto'; + +export type ListCistomFieldsResDto = { + /** + * 业务状态码,可以通过此状态码判断操作是否成功,200 表示成功。 + */ + statusCode: number; + /** + * 描述信息 + */ + message: string; + /** + * 细分错误码,可通过此错误码得到具体的错误类型。 + */ + apiCode?: number; + /** + * 请求 ID。当请求失败时会返回。 + */ + requestId?: string; + /** + * 响应数据 + */ + data: ListCustomFieldsDto; +}; diff --git a/src/models/ListCustomFieldsDto.ts b/src/models/ListCustomFieldsDto.ts new file mode 100644 index 0000000..6b27c67 --- /dev/null +++ b/src/models/ListCustomFieldsDto.ts @@ -0,0 +1,54 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * 通过主体类型,获取用户、部门或角色的自定义字段列表。 + */ +export type ListCustomFieldsDto = { + /** + * 目标对象类型: + * - `USER`: 用户 + * - `ROLE`: 角色 + * - `GROUP`: 分组 + * - `DEPARTMENT`: 部门 + * ;该接口暂不支持分组(GROUP) + */ + targetType?: any; + /** + * 字段类型 + */ + dataType?: any; + /** + * 租户 ID + */ + tenantId?: any; + /** + * 当前页数,从 1 开始 + */ + page?: any; + /** + * 每页数目,最大不能超过 50,默认为 10 + */ + limit?: any; + /** + * 用户是否可见 + */ + userVisible?: any; + /** + * 管理员是否可见 + */ + adminVisible?: any; + /** + * 访问控制 + */ + accessControl?: any; + /** + * 搜索关键词 + */ + keyword?: any; + /** + * 搜索语言 + */ + lang?: any; +}; diff --git a/src/models/ListTenantsDto.ts b/src/models/ListTenantsDto.ts index b449a10..b424484 100644 --- a/src/models/ListTenantsDto.ts +++ b/src/models/ListTenantsDto.ts @@ -34,4 +34,8 @@ export type ListTenantsDto = { * 每页获取的数据量 */ limit?: any; + /** + * 租户来源 + */ + source?: any; }; diff --git a/src/models/ListUserBaseFieldsDto.ts b/src/models/ListUserBaseFieldsDto.ts new file mode 100644 index 0000000..812a10c --- /dev/null +++ b/src/models/ListUserBaseFieldsDto.ts @@ -0,0 +1,54 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * 获取用户内置的字段列表 + */ +export type ListUserBaseFieldsDto = { + /** + * 目标对象类型: + * - `USER`: 用户 + * - `ROLE`: 角色 + * - `GROUP`: 分组 + * - `DEPARTMENT`: 部门 + * ;该接口暂不支持分组(GROUP) + */ + targetType?: any; + /** + * 字段类型 + */ + dataType?: any; + /** + * 租户 ID + */ + tenantId?: any; + /** + * 当前页数,从 1 开始 + */ + page?: any; + /** + * 每页数目,最大不能超过 50,默认为 10 + */ + limit?: any; + /** + * 用户是否可见 + */ + userVisible?: any; + /** + * 管理员是否可见 + */ + adminVisible?: any; + /** + * 访问控制 + */ + accessControl?: any; + /** + * 搜索关键词 + */ + keyword?: any; + /** + * 搜索语言 + */ + lang?: any; +}; diff --git a/src/models/LoginHistoryDto.ts b/src/models/LoginHistoryDto.ts index 368fd19..d852d81 100644 --- a/src/models/LoginHistoryDto.ts +++ b/src/models/LoginHistoryDto.ts @@ -58,4 +58,8 @@ export type LoginHistoryDto = { * 地理位置 */ geoip: GeoIp; + /** + * 租户 ID + */ + tenantId?: string; }; diff --git a/src/models/SetCustomDataDto.ts b/src/models/SetCustomDataDto.ts index 11ecf73..4a883f3 100644 --- a/src/models/SetCustomDataDto.ts +++ b/src/models/SetCustomDataDto.ts @@ -3,6 +3,10 @@ /* eslint-disable */ export type SetCustomDataDto = { + /** + * 租户 ID + */ + tenantId: string; /** * 字段 key,不能和内置字段的 key 冲突 */ diff --git a/src/models/SetCustomDataReqDto.ts b/src/models/SetCustomDataReqDto.ts index 2998929..47df23b 100644 --- a/src/models/SetCustomDataReqDto.ts +++ b/src/models/SetCustomDataReqDto.ts @@ -27,6 +27,10 @@ export type SetCustomDataReqDto = { * */ targetType: SetCustomDataReqDto.targetType; + /** + * 租户 ID + */ + tenantId: string; /** * 所属权限分组的 code,当 target_type 为角色的时候需要填写,否则可以忽略 */ diff --git a/src/models/SetCustomFieldDto.ts b/src/models/SetCustomFieldDto.ts index 7369d40..dff1d3d 100644 --- a/src/models/SetCustomFieldDto.ts +++ b/src/models/SetCustomFieldDto.ts @@ -56,6 +56,18 @@ export type SetCustomFieldDto = { * 是否在用户个人中心展示(此参数不控制 API 接口是否返回)。 */ visibleInUserCenter?: boolean; + /** + * 校验规则 + */ + validateRules?: any; + /** + * App Id 列表 + */ + appIds?: Array; + /** + * 脱敏 + */ + desensitization?: boolean; /** * 枚举值类型选择项 */ diff --git a/src/models/SetCustomFieldsReqDto.ts b/src/models/SetCustomFieldsReqDto.ts index 43c9707..51cb2e3 100644 --- a/src/models/SetCustomFieldsReqDto.ts +++ b/src/models/SetCustomFieldsReqDto.ts @@ -5,6 +5,10 @@ import type { SetCustomFieldDto } from './SetCustomFieldDto'; export type SetCustomFieldsReqDto = { + /** + * 租户 ID + */ + tenantId: string; /** * 自定义字段列表 */ diff --git a/src/models/SetMfaStatusDto.ts b/src/models/SetMfaStatusDto.ts new file mode 100644 index 0000000..8e9ffb2 --- /dev/null +++ b/src/models/SetMfaStatusDto.ts @@ -0,0 +1,53 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { GetMfaInfoDataDto } from './GetMfaInfoDataDto'; + +export type SetMfaStatusDto = { + /** + * MFA Factor 列表 + */ + mfaTriggerData: GetMfaInfoDataDto; + /** + * 用户唯一标志,可以是用户 ID、用户名、邮箱、手机号、外部 ID、在外部身份源的 ID。 + */ + userId: string; + /** + * 用户 ID 类型,默认值为 `user_id`,可选值为: + * - `user_id`: Authing 用户 ID,如 `6319a1504f3xxxxf214dd5b7` + * - `phone`: 用户手机号 + * - `email`: 用户邮箱 + * - `username`: 用户名 + * - `external_id`: 用户在外部系统的 ID,对应 Authing 用户信息的 `externalId` 字段 + * - `identity`: 用户的外部身份源信息,格式为 `:`,其中 `` 为 Authing 身份源的 ID,`` 为用户在外部身份源的 ID。 + * 示例值:`62f20932716fbcc10d966ee5:ou_8bae746eac07cd2564654140d2a9ac61`。 + * + */ + userIdType?: SetMfaStatusDto.userIdType; +}; + +export namespace SetMfaStatusDto { + + /** + * 用户 ID 类型,默认值为 `user_id`,可选值为: + * - `user_id`: Authing 用户 ID,如 `6319a1504f3xxxxf214dd5b7` + * - `phone`: 用户手机号 + * - `email`: 用户邮箱 + * - `username`: 用户名 + * - `external_id`: 用户在外部系统的 ID,对应 Authing 用户信息的 `externalId` 字段 + * - `identity`: 用户的外部身份源信息,格式为 `:`,其中 `` 为 Authing 身份源的 ID,`` 为用户在外部身份源的 ID。 + * 示例值:`62f20932716fbcc10d966ee5:ou_8bae746eac07cd2564654140d2a9ac61`。 + * + */ + export enum userIdType { + USER_ID = 'user_id', + EXTERNAL_ID = 'external_id', + PHONE = 'phone', + EMAIL = 'email', + USERNAME = 'username', + IDENTITY = 'identity', + } + + +} diff --git a/src/models/TenantDto.ts b/src/models/TenantDto.ts index 7db073d..3e35970 100644 --- a/src/models/TenantDto.ts +++ b/src/models/TenantDto.ts @@ -39,4 +39,16 @@ export type TenantDto = { * 租户来源的应用 ID,该值不存在时代表租户来源为 Authing 控制台 */ sourceAppId: string; + /** + * 租户来源 + */ + source: string; + /** + * 租户 Code + */ + code: string; + /** + * 租户配置的企业域名 + */ + enterpriseDomains: string; }; diff --git a/src/models/TenantRespDto.ts b/src/models/TenantRespDto.ts index d9c8616..7d58860 100644 --- a/src/models/TenantRespDto.ts +++ b/src/models/TenantRespDto.ts @@ -39,6 +39,18 @@ export type TenantRespDto = { * 租户来源的应用 ID,该值不存在时代表租户来源为 Authing 控制台 */ sourceAppId: string; + /** + * 租户来源 + */ + source: string; + /** + * 租户 Code + */ + code: string; + /** + * 租户配置的企业域名 + */ + enterpriseDomains: string; /** * 创建者基本信息 */ diff --git a/src/models/UnlinkIdentity.ts b/src/models/UnlinkIdentity.ts new file mode 100644 index 0000000..fcab5df --- /dev/null +++ b/src/models/UnlinkIdentity.ts @@ -0,0 +1,22 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type UnlinkIdentity = { + /** + * 必传,进行绑定操作的 Authing 用户 ID。 + */ + userId: string; + /** + * 必传,身份源 ID,用于指定该身份属于哪个身份源。 + */ + extIdpId: string; + /** + * 非必传,表示该条身份的具体类型,可从用户身份信息的 type 字段中获取。如果不传,默认为 generic + */ + type?: string; + /** + * 已废弃,可任意传入,未来将移除该字段。 + */ + isSocial?: boolean; +}; diff --git a/src/models/UpdateLoginConfig.ts b/src/models/UpdateLoginConfig.ts index 6f6b8af..5f76ccc 100644 --- a/src/models/UpdateLoginConfig.ts +++ b/src/models/UpdateLoginConfig.ts @@ -2,13 +2,40 @@ /* tslint:disable */ /* eslint-disable */ +import type { ApplicationTabMethodsSortConfigDto } from './ApplicationTabMethodsSortConfigDto'; import type { ISsoPageCustomizationSettingsDto } from './ISsoPageCustomizationSettingsDto'; import type { LanguageCoinfigDto } from './LanguageCoinfigDto'; import type { TabConfigDto } from './TabConfigDto'; export type UpdateLoginConfig = { + tabMethodsSortConfig: ApplicationTabMethodsSortConfigDto; + qrCodeSortConfig: ApplicationTabMethodsSortConfigDto; ssoPageCustomizationSettings: ISsoPageCustomizationSettingsDto; passwordTabConfig: TabConfigDto; verifyCodeTabConfig: TabConfigDto; config: LanguageCoinfigDto; + /** + * 是否允许创建租户 + */ + enableCreateTenant: boolean; + /** + * 允许创建租户的场景 + */ + createTenantScenes: Array; + /** + * 是否允许加入租户 + */ + enableJoinTenant: boolean; + /** + * 允许创建加入的场景 + */ + joinTenantScenes: Array; + /** + * 是否校验企业域名 + */ + enableVerifyDomain: boolean; + /** + * 校验企业域名的场景 + */ + verifyDomainScenes: Array; }; diff --git a/src/models/UpdateTenantAppqrcodeState.ts b/src/models/UpdateTenantAppqrcodeState.ts new file mode 100644 index 0000000..928f141 --- /dev/null +++ b/src/models/UpdateTenantAppqrcodeState.ts @@ -0,0 +1,10 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type UpdateTenantAppqrcodeState = { + /** + * 是否允许开启扫码登录 + */ + enabled: boolean; +}; diff --git a/src/models/UserPoolTenantConfigDto.ts b/src/models/UserPoolTenantConfigDto.ts index e97bdc8..5c5cbed 100644 --- a/src/models/UserPoolTenantConfigDto.ts +++ b/src/models/UserPoolTenantConfigDto.ts @@ -42,6 +42,30 @@ export type UserPoolTenantConfigDto = { * 自定义 Loading 背景 */ loadingBackground: string; + /** + * 是否允许创建租户 + */ + enableCreateTenant: boolean; + /** + * 允许创建租户的场景 + */ + createTenantScenes: Array; + /** + * 是否允许加入租户 + */ + enableJoinTenant: boolean; + /** + * 允许创建加入的场景 + */ + joinTenantScenes: Array; + /** + * 是否校验企业域名 + */ + enableVerifyDomain: boolean; + /** + * 校验企业域名的场景 + */ + verifyDomainScenes: Array; /** * 页面自定义配置 */