@authup/core-http-kit
Version:
Package containing global constants, types & interfaces.
1 lines • 106 kB
Source Map (JSON)
{"version":3,"file":"index.mjs","sources":["../src/cookies.ts","../src/client/helper.ts","../src/utils/duplicate-slashes.ts","../src/utils/object-property.ts","../src/domains/base.ts","../src/domains/entities/client/module.ts","../src/domains/entities/client-permission/module.ts","../src/domains/entities/client-role/module.ts","../src/domains/entities/client-scope/module.ts","../src/domains/entities/identity-provider/module.ts","../src/domains/entities/identity-provider-role-mapping/module.ts","../src/domains/entities/policy/module.ts","../src/domains/entities/permission/module.ts","../src/domains/entities/realm/module.ts","../src/domains/entities/robot/module.ts","../src/domains/entities/robot-permission/module.ts","../src/domains/entities/robot-role/module.ts","../src/domains/entities/role/module.ts","../src/domains/entities/role-attribute/module.ts","../src/domains/entities/role-permission/module.ts","../src/domains/entities/scope/module.ts","../src/domains/entities/user/module.ts","../src/domains/entities/user-attribute/module.ts","../src/domains/entities/user-permission/module.ts","../src/domains/entities/user-role/module.ts","../src/domains/workflows/oauth2/authorize/module.ts","../src/domains/workflows/oauth2/token/module.ts","../src/domains/workflows/oauth2/user-info/module.ts","../src/client/module.ts","../src/helpers/error-code.ts","../src/hook/constants.ts","../src/token-creator/constants.ts","../src/token-creator/variations/robot.ts","../src/token-creator/variations/robot-vault.ts","../src/token-creator/variations/user.ts","../src/token-creator/module.ts","../src/hook/utils.ts","../src/hook/module.ts"],"sourcesContent":["/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum CookieName {\n ACCESS_TOKEN = 'access_token',\n ACCESS_TOKEN_EXPIRE_DATE = 'access_token_expire_date',\n REFRESH_TOKEN = 'refresh_token',\n\n USER = 'user',\n REALM = 'realm',\n REALM_MANAGEMENT = 'realm_management',\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { ClientError } from 'hapic';\nimport { isClientError as isError } from 'hapic';\n\nexport function isClientError(input: unknown) : input is ClientError {\n return isError(input);\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function cleanDoubleSlashes(input: string) : string {\n if (input.indexOf('://') !== -1) {\n return input.split('://')\n .map((str) => cleanDoubleSlashes(str))\n .join('://');\n }\n\n return input.replace(/\\/+/g, '/');\n}\n","/*\n * Copyright (c) 2021-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function nullifyEmptyObjectProperties<T extends Record<string, any>>(data: T) : T {\n const keys : (keyof T)[] = Object.keys(data);\n\n for (let i = 0; i < keys.length; i++) {\n if (data[keys[i]] === '') {\n data[keys[i]] = null as T[keyof T];\n }\n }\n\n return data;\n}\n","/*\n * Copyright (c) 2023-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { createClient, isClient } from 'hapic';\nimport type { Client, RequestBaseOptions } from 'hapic';\nimport type { BaseAPIContext } from './types-base';\n\nexport class BaseAPI {\n protected client! : Client;\n\n // -----------------------------------------------------------------------------------\n\n constructor(context?: BaseAPIContext) {\n context = context || {};\n\n this.setClient(context.client);\n }\n\n // -----------------------------------------------------------------------------------\n\n setClient(input?: Client | RequestBaseOptions) {\n this.client = isClient(input) ?\n input :\n createClient(input);\n }\n}\n","/*\n * Copyright (c) 2021-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { BuildInput } from 'rapiq';\nimport { buildQuery } from 'rapiq';\nimport type { Client } from '@authup/core-kit';\nimport { nullifyEmptyObjectProperties } from '../../../utils';\nimport { BaseAPI } from '../../base';\nimport type { EntityAPI, EntityCollectionResponse, EntityRecordResponse } from '../../types-base';\n\nexport class ClientAPI extends BaseAPI implements EntityAPI<Client> {\n async getMany(\n options?: BuildInput<Client>,\n ): Promise<EntityCollectionResponse<Client>> {\n const response = await this.client\n .get(`clients${buildQuery(options)}`);\n\n return response.data;\n }\n\n async getOne(\n id: Client['id'],\n options?: BuildInput<Client>,\n ): Promise<EntityRecordResponse<Client>> {\n const response = await this.client\n .get(`clients/${id}${buildQuery(options)}`);\n\n return response.data;\n }\n\n async delete(\n id: Client['id'],\n ): Promise<EntityRecordResponse<Client>> {\n const response = await this.client\n .delete(`clients/${id}`);\n\n return response.data;\n }\n\n async create(\n data: Partial<Client>,\n ): Promise<EntityRecordResponse<Client>> {\n const response = await this.client\n .post('clients', nullifyEmptyObjectProperties(data));\n\n return response.data;\n }\n\n async update(\n id: Client['id'],\n data: Partial<Client>,\n ): Promise<EntityRecordResponse<Client>> {\n const response = await this.client.post(`clients/${id}`, nullifyEmptyObjectProperties(data));\n\n return response.data;\n }\n\n async createOrUpdate(\n idOrName: string,\n data: Partial<Client>,\n ): Promise<EntityRecordResponse<Client>> {\n const response = await this.client.put(`clients/${idOrName}`, nullifyEmptyObjectProperties(data));\n\n return response.data;\n }\n}\n","/*\n * Copyright (c) 2021-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { BuildInput } from 'rapiq';\nimport { buildQuery } from 'rapiq';\nimport type { ClientPermission } from '@authup/core-kit';\nimport { BaseAPI } from '../../base';\nimport type {\n EntityAPISlim, EntityCollectionResponse, EntityRecordResponse,\n} from '../../types-base';\n\nexport class ClientPermissionAPI extends BaseAPI implements EntityAPISlim<ClientPermission> {\n async getMany(data?: BuildInput<ClientPermission>) : Promise<EntityCollectionResponse<ClientPermission>> {\n const response = await this.client.get(`client-permissions${buildQuery(data)}`);\n return response.data;\n }\n\n async getOne(id: ClientPermission['id'], data?: BuildInput<ClientPermission>) : Promise<EntityRecordResponse<ClientPermission>> {\n const response = await this.client.get(`client-permissions/${id}${buildQuery(data)}`);\n\n return response.data;\n }\n\n async delete(id: ClientPermission['id']) : Promise<EntityRecordResponse<ClientPermission>> {\n const response = await this.client.delete(`client-permissions/${id}`);\n\n return response.data;\n }\n\n async create(data: Partial<ClientPermission>) : Promise<EntityRecordResponse<ClientPermission>> {\n const response = await this.client.post('client-permissions', data);\n\n return response.data;\n }\n}\n","/*\n * Copyright (c) 2021-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { BuildInput } from 'rapiq';\nimport { buildQuery } from 'rapiq';\nimport type { ClientRole } from '@authup/core-kit';\nimport { BaseAPI } from '../../base';\nimport type {\n EntityAPISlim, EntityCollectionResponse, EntityRecordResponse,\n} from '../../types-base';\n\nexport class ClientRoleAPI extends BaseAPI implements EntityAPISlim<ClientRole> {\n async getMany(data: BuildInput<ClientRole> = {}): Promise<EntityCollectionResponse<ClientRole>> {\n const response = await this.client.get(`client-roles${buildQuery(data)}`);\n\n return response.data;\n }\n\n async getOne(id: ClientRole['id']): Promise<EntityRecordResponse<ClientRole>> {\n const response = await this.client.get(`client-roles/${id}`);\n\n return response.data;\n }\n\n async delete(id: ClientRole['id']): Promise<EntityRecordResponse<ClientRole>> {\n const response = await this.client.delete(`client-roles/${id}`);\n\n return response.data;\n }\n\n async create(data: Partial<ClientRole>): Promise<EntityRecordResponse<ClientRole>> {\n const response = await this.client.post('client-roles', data);\n\n return response.data;\n }\n}\n","/*\n * Copyright (c) 2021-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { BuildInput } from 'rapiq';\nimport { buildQuery } from 'rapiq';\nimport type { ClientScope } from '@authup/core-kit';\nimport { BaseAPI } from '../../base';\nimport type { EntityAPISlim, EntityCollectionResponse, EntityRecordResponse } from '../../types-base';\n\nexport class ClientScopeAPI extends BaseAPI implements EntityAPISlim<ClientScope> {\n async getMany(data?: BuildInput<ClientScope>) : Promise<EntityCollectionResponse<ClientScope>> {\n const response = await this.client.get(`client-scopes${buildQuery(data)}`);\n return response.data;\n }\n\n async getOne(id: ClientScope['id']) : Promise<EntityRecordResponse<ClientScope>> {\n const response = await this.client.get(`client-scopes/${id}`);\n\n return response.data;\n }\n\n async delete(id: ClientScope['id']) : Promise<EntityRecordResponse<ClientScope>> {\n const response = await this.client.delete(`client-scopes/${id}`);\n\n return response.data;\n }\n\n async create(data: Partial<ClientScope>) : Promise<EntityRecordResponse<ClientScope>> {\n const response = await this.client.post('client-scopes', data);\n\n return response.data;\n }\n}\n","/*\n * Copyright (c) 2021-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { BuildInput } from 'rapiq';\nimport { buildQuery } from 'rapiq';\nimport type { IdentityProvider } from '@authup/core-kit';\nimport { buildIdentityProviderAuthorizePath } from '@authup/core-kit';\nimport { cleanDoubleSlashes, nullifyEmptyObjectProperties } from '../../../utils';\nimport type { EntityAPI, EntityCollectionResponse, EntityRecordResponse } from '../../types-base';\nimport { BaseAPI } from '../../base';\n\nexport class IdentityProviderAPI extends BaseAPI implements EntityAPI<IdentityProvider> {\n getAuthorizeUri(id: IdentityProvider['id']): string {\n return cleanDoubleSlashes(`${this.client.defaults.baseURL}/${buildIdentityProviderAuthorizePath(id)}`);\n }\n\n async getMany(record?: BuildInput<IdentityProvider>): Promise<EntityCollectionResponse<IdentityProvider>> {\n const response = await this.client.get(`identity-providers${buildQuery(record)}`);\n\n return response.data;\n }\n\n async getOne(\n id: IdentityProvider['id'],\n record?: BuildInput<IdentityProvider>,\n ): Promise<EntityRecordResponse<IdentityProvider>> {\n const response = await this.client.get(`identity-providers/${id}${buildQuery(record)}`);\n\n return response.data;\n }\n\n async delete(id: IdentityProvider['id']): Promise<EntityRecordResponse<IdentityProvider>> {\n const response = await this.client.delete(`identity-providers/${id}`);\n\n return response.data;\n }\n\n async create(data: Partial<IdentityProvider>): Promise<EntityRecordResponse<IdentityProvider>> {\n const response = await this.client.post('identity-providers', nullifyEmptyObjectProperties(data));\n\n return response.data;\n }\n\n async update(id: IdentityProvider['id'], data: Partial<IdentityProvider>): Promise<EntityRecordResponse<IdentityProvider>> {\n const response = await this.client.post(`identity-providers/${id}`, nullifyEmptyObjectProperties(data));\n\n return response.data;\n }\n\n async createOrUpdate(\n idOrName: string,\n data: Partial<IdentityProvider>,\n ): Promise<EntityRecordResponse<IdentityProvider>> {\n const response = await this.client.put(`identity-providers/${idOrName}`, nullifyEmptyObjectProperties(data));\n\n return response.data;\n }\n}\n","/*\n * Copyright (c) 2021-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { BuildInput } from 'rapiq';\nimport { buildQuery } from 'rapiq';\nimport type { IdentityProviderRoleMapping } from '@authup/core-kit';\nimport { nullifyEmptyObjectProperties } from '../../../utils';\nimport { BaseAPI } from '../../base';\nimport type { EntityAPI, EntityCollectionResponse, EntityRecordResponse } from '../../types-base';\n\nexport class IdentityProviderRoleMappingAPI extends BaseAPI implements EntityAPI<IdentityProviderRoleMapping> {\n async getMany(data: BuildInput<IdentityProviderRoleMapping>): Promise<EntityCollectionResponse<IdentityProviderRoleMapping>> {\n const response = await this.client.get(`identity-provider-role-mappings${buildQuery(data)}`);\n\n return response.data;\n }\n\n async getOne(id: IdentityProviderRoleMapping['id']): Promise<EntityRecordResponse<IdentityProviderRoleMapping>> {\n const response = await this.client.get(`identity-provider-role-mappings/${id}`);\n\n return response.data;\n }\n\n async delete(id: IdentityProviderRoleMapping['id']): Promise<EntityRecordResponse<IdentityProviderRoleMapping>> {\n const response = await this.client.delete(`identity-provider-role-mappings/${id}`);\n\n return response.data;\n }\n\n async create(data: Partial<IdentityProviderRoleMapping>): Promise<EntityRecordResponse<IdentityProviderRoleMapping>> {\n const response = await this.client.post('identity-provider-role-mappings', nullifyEmptyObjectProperties(data));\n\n return response.data;\n }\n\n async update(\n id: IdentityProviderRoleMapping['id'],\n data: Partial<IdentityProviderRoleMapping>,\n ): Promise<EntityRecordResponse<IdentityProviderRoleMapping>> {\n const response = await this.client.post(`identity-provider-role-mappings/${id}`, data);\n\n return response.data;\n }\n}\n","/*\n * Copyright (c) 2021-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { BuildInput } from 'rapiq';\nimport { buildQuery } from 'rapiq';\nimport type { Policy } from '@authup/core-kit';\nimport { nullifyEmptyObjectProperties } from '../../../utils';\nimport { BaseAPI } from '../../base';\nimport type { EntityAPI, EntityCollectionResponse, EntityRecordResponse } from '../../types-base';\nimport type {\n BuiltInPolicyCreateRequest,\n BuiltInPolicyResponse, BuiltInPolicyUpdateRequest, PolicyAPICheckResponse, PolicyCreateRequest, PolicyResponse, PolicyUpdateRequest,\n} from './types';\n\nexport class PolicyAPI extends BaseAPI implements EntityAPI<Policy> {\n async getMany<\n OUTPUT extends PolicyResponse = PolicyResponse,\n >(data?: BuildInput<Policy & { parent_id?: string | null }>): Promise<EntityCollectionResponse<OUTPUT>> {\n const response = await this.client.get(`policies${buildQuery(data)}`);\n return response.data;\n }\n\n async delete<\n OUTPUT extends PolicyResponse = PolicyResponse,\n >(id: Policy['id']): Promise<EntityRecordResponse<OUTPUT>> {\n const response = await this.client.delete(`policies/${id}`);\n\n return response.data;\n }\n\n async getOne<\n OUTPUT extends PolicyResponse = PolicyResponse,\n >(id: Policy['id'], record?: BuildInput<Policy>) : Promise<EntityRecordResponse<OUTPUT>> {\n const response = await this.client.get(`policies/${id}${buildQuery(record)}`);\n\n return response.data;\n }\n\n async getOneExpanded<\n OUTPUT extends PolicyResponse = PolicyResponse,\n >(id: Policy['id'], record?: BuildInput<Policy>) : Promise<EntityRecordResponse<OUTPUT>> {\n const response = await this.client.get(`policies/${id}/expanded${buildQuery(record)}`);\n\n return response.data;\n }\n\n async create<\n INPUT extends PolicyCreateRequest = PolicyCreateRequest,\n OUTPUT extends PolicyResponse = PolicyResponse,\n >(data: INPUT): Promise<EntityRecordResponse<OUTPUT>> {\n const response = await this.client.post('policies', nullifyEmptyObjectProperties(data));\n\n return response.data;\n }\n\n async createBuiltIn(\n data: BuiltInPolicyCreateRequest,\n ): Promise<EntityRecordResponse<BuiltInPolicyResponse>> {\n return this.create(data);\n }\n\n async update<\n INPUT extends PolicyUpdateRequest = PolicyUpdateRequest,\n OUTPUT extends PolicyResponse = PolicyResponse,\n >(id: Policy['id'], data: INPUT): Promise<EntityRecordResponse<OUTPUT>> {\n const response = await this.client.post(`policies/${id}`, nullifyEmptyObjectProperties(data));\n\n return response.data;\n }\n\n async updateBuiltIn(\n id: Policy['id'],\n data: BuiltInPolicyUpdateRequest,\n ): Promise<EntityRecordResponse<BuiltInPolicyResponse>> {\n return this.update(id, data);\n }\n\n async createOrUpdate<\n INPUT extends PolicyCreateRequest = PolicyCreateRequest,\n OUTPUT extends PolicyResponse = PolicyResponse,\n >(\n idOrName: string,\n data: INPUT,\n ): Promise<EntityRecordResponse<OUTPUT>> {\n const response = await this.client.put(`policies/${idOrName}`, nullifyEmptyObjectProperties(data));\n\n return response.data;\n }\n\n async createOrUpdateBuiltin(\n idOrName: string,\n data: BuiltInPolicyCreateRequest,\n ): Promise<EntityRecordResponse<BuiltInPolicyResponse>> {\n return this.createOrUpdate(idOrName, data);\n }\n\n async check(\n idOrName: string,\n data: Record<string, any> = {},\n ) : Promise<PolicyAPICheckResponse> {\n const response = await this.client.post(\n `policies/${idOrName}/check`,\n nullifyEmptyObjectProperties(data),\n );\n\n return response.data;\n }\n}\n","/*\n * Copyright (c) 2021-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { BuildInput } from 'rapiq';\nimport { buildQuery } from 'rapiq';\nimport type { Permission } from '@authup/core-kit';\nimport { nullifyEmptyObjectProperties } from '../../../utils';\nimport { BaseAPI } from '../../base';\nimport type { EntityAPI, EntityCollectionResponse, EntityRecordResponse } from '../../types-base';\nimport type { PermissionAPICheckResponse } from './types';\n\nexport class PermissionAPI extends BaseAPI implements EntityAPI<Permission> {\n async getMany(data?: BuildInput<Permission>): Promise<EntityCollectionResponse<Permission>> {\n const response = await this.client.get(`permissions${buildQuery(data)}`);\n return response.data;\n }\n\n async delete(id: Permission['id']): Promise<EntityRecordResponse<Permission>> {\n const response = await this.client.delete(`permissions/${id}`);\n\n return response.data;\n }\n\n async getOne(id: Permission['id'], record?: BuildInput<Permission>) {\n const response = await this.client.get(`permissions/${id}${buildQuery(record)}`);\n\n return response.data;\n }\n\n async create(data: Partial<Permission>): Promise<EntityRecordResponse<Permission>> {\n const response = await this.client.post('permissions', nullifyEmptyObjectProperties(data));\n\n return response.data;\n }\n\n async update(id: Permission['id'], data: Partial<Permission>): Promise<EntityRecordResponse<Permission>> {\n const response = await this.client.post(`permissions/${id}`, nullifyEmptyObjectProperties(data));\n\n return response.data;\n }\n\n async createOrUpdate(\n idOrName: string,\n data: Partial<Permission>,\n ): Promise<EntityRecordResponse<Permission>> {\n const response = await this.client.put(`permissions/${idOrName}`, nullifyEmptyObjectProperties(data));\n\n return response.data;\n }\n\n async check(\n idOrName: string,\n data: Record<string, any> = {},\n ) : Promise<PermissionAPICheckResponse> {\n const response = await this.client.post(\n `permissions/${idOrName}/check`,\n nullifyEmptyObjectProperties(data),\n );\n\n return response.data;\n }\n}\n","/*\n * Copyright (c) 2021-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { BuildInput } from 'rapiq';\nimport { buildQuery } from 'rapiq';\nimport type { Realm } from '@authup/core-kit';\nimport { nullifyEmptyObjectProperties } from '../../../utils';\nimport { BaseAPI } from '../../base';\nimport type { EntityAPI, EntityCollectionResponse, EntityRecordResponse } from '../../types-base';\n\nexport class RealmAPI extends BaseAPI implements EntityAPI<Realm> {\n async getMany(data?: BuildInput<Realm>): Promise<EntityCollectionResponse<Realm>> {\n const response = await this.client.get(`realms${buildQuery(data)}`);\n\n return response.data;\n }\n\n async getOne(id: Realm['id']): Promise<EntityRecordResponse<Realm>> {\n const response = await this.client.get(`realms/${id}`);\n\n return response.data;\n }\n\n async delete(id: Realm['id']): Promise<EntityRecordResponse<Realm>> {\n const response = await this.client.delete(`realms/${id}`);\n\n return response.data;\n }\n\n async create(data: Partial<Realm>): Promise<EntityRecordResponse<Realm>> {\n const response = await this.client.post('realms', nullifyEmptyObjectProperties(data));\n\n return response.data;\n }\n\n async update(realmId: Realm['id'], data: Partial<Realm>): Promise<EntityRecordResponse<Realm>> {\n const response = await this.client.post(`realms/${realmId}`, nullifyEmptyObjectProperties(data));\n\n return response.data;\n }\n\n async createOrUpdate(\n idOrName: string,\n data: Partial<Realm>,\n ): Promise<EntityRecordResponse<Realm>> {\n const response = await this.client.put(`realms/${idOrName}`, nullifyEmptyObjectProperties(data));\n\n return response.data;\n }\n}\n","/*\n * Copyright (c) 2021-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { BuildInput } from 'rapiq';\nimport { buildQuery } from 'rapiq';\nimport type { Robot } from '@authup/core-kit';\nimport { nullifyEmptyObjectProperties } from '../../../utils';\nimport { BaseAPI } from '../../base';\nimport type { EntityAPI, EntityCollectionResponse, EntityRecordResponse } from '../../types-base';\n\nexport class RobotAPI extends BaseAPI implements EntityAPI<Robot> {\n async getMany(\n options?: BuildInput<Robot>,\n ): Promise<EntityCollectionResponse<Robot>> {\n const response = await this.client\n .get(`robots${buildQuery(options)}`);\n\n return response.data;\n }\n\n async getOne(\n id: Robot['id'],\n options?: BuildInput<Robot>,\n ): Promise<EntityRecordResponse<Robot>> {\n const response = await this.client\n .get(`robots/${id}${buildQuery(options)}`);\n\n return response.data;\n }\n\n async delete(\n id: Robot['id'],\n ): Promise<EntityRecordResponse<Robot>> {\n const response = await this.client\n .delete(`robots/${id}`);\n\n return response.data;\n }\n\n async create(\n data: Partial<Robot>,\n ): Promise<EntityRecordResponse<Robot>> {\n const response = await this.client\n .post('robots', nullifyEmptyObjectProperties(data));\n\n return response.data;\n }\n\n async update(\n id: Robot['id'],\n data: Partial<Robot>,\n ): Promise<EntityRecordResponse<Robot>> {\n const response = await this.client.post(`robots/${id}`, nullifyEmptyObjectProperties(data));\n\n return response.data;\n }\n\n async createOrUpdate(\n idOrName: string,\n data: Partial<Robot>,\n ): Promise<EntityRecordResponse<Robot>> {\n const response = await this.client.put(`robots/${idOrName}`, nullifyEmptyObjectProperties(data));\n\n return response.data;\n }\n\n async integrity(\n id: Robot['id'] | Robot['name'],\n ): Promise<EntityRecordResponse<Robot>> {\n const { data: response } = await this.client\n .get(`robots/${id}/integrity`);\n\n return response;\n }\n}\n","/*\n * Copyright (c) 2021-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { BuildInput } from 'rapiq';\nimport { buildQuery } from 'rapiq';\nimport type { RobotPermission } from '@authup/core-kit';\nimport { BaseAPI } from '../../base';\nimport type {\n EntityAPISlim, EntityCollectionResponse, EntityRecordResponse,\n} from '../../types-base';\n\nexport class RobotPermissionAPI extends BaseAPI implements EntityAPISlim<RobotPermission> {\n async getMany(data?: BuildInput<RobotPermission>) : Promise<EntityCollectionResponse<RobotPermission>> {\n const response = await this.client.get(`robot-permissions${buildQuery(data)}`);\n return response.data;\n }\n\n async getOne(id: RobotPermission['id'], data?: BuildInput<RobotPermission>) : Promise<EntityRecordResponse<RobotPermission>> {\n const response = await this.client.get(`robot-permissions/${id}${buildQuery(data)}`);\n\n return response.data;\n }\n\n async delete(id: RobotPermission['id']) : Promise<EntityRecordResponse<RobotPermission>> {\n const response = await this.client.delete(`robot-permissions/${id}`);\n\n return response.data;\n }\n\n async create(data: Partial<RobotPermission>) : Promise<EntityRecordResponse<RobotPermission>> {\n const response = await this.client.post('robot-permissions', data);\n\n return response.data;\n }\n}\n","/*\n * Copyright (c) 2021-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { BuildInput } from 'rapiq';\nimport { buildQuery } from 'rapiq';\nimport type { RobotRole } from '@authup/core-kit';\nimport { BaseAPI } from '../../base';\nimport type {\n EntityAPISlim, EntityCollectionResponse, EntityRecordResponse,\n} from '../../types-base';\n\nexport class RobotRoleAPI extends BaseAPI implements EntityAPISlim<RobotRole> {\n async getMany(data: BuildInput<RobotRole> = {}): Promise<EntityCollectionResponse<RobotRole>> {\n const response = await this.client.get(`robot-roles${buildQuery(data)}`);\n\n return response.data;\n }\n\n async getOne(id: RobotRole['id']): Promise<EntityRecordResponse<RobotRole>> {\n const response = await this.client.get(`robot-roles/${id}`);\n\n return response.data;\n }\n\n async delete(id: RobotRole['id']): Promise<EntityRecordResponse<RobotRole>> {\n const response = await this.client.delete(`robot-roles/${id}`);\n\n return response.data;\n }\n\n async create(data: Partial<RobotRole>): Promise<EntityRecordResponse<RobotRole>> {\n const response = await this.client.post('robot-roles', data);\n\n return response.data;\n }\n}\n","/*\n * Copyright (c) 2021-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { BuildInput } from 'rapiq';\nimport { buildQuery } from 'rapiq';\nimport type { Role } from '@authup/core-kit';\nimport { nullifyEmptyObjectProperties } from '../../../utils';\nimport { BaseAPI } from '../../base';\nimport type {\n EntityAPI, EntityCollectionResponse, EntityRecordResponse,\n} from '../../types-base';\n\nexport class RoleAPI extends BaseAPI implements EntityAPI<Role> {\n async getMany(data?: BuildInput<Role>): Promise<EntityCollectionResponse<Role>> {\n const response = await this.client.get(`roles${buildQuery(data)}`);\n\n return response.data;\n }\n\n async getOne(roleId: Role['id']): Promise<EntityRecordResponse<Role>> {\n const response = await this.client.get(`roles/${roleId}`);\n\n return response.data;\n }\n\n async delete(roleId: Role['id']): Promise<EntityRecordResponse<Role>> {\n const response = await this.client.delete(`roles/${roleId}`);\n\n return response.data;\n }\n\n async create(data: Partial<Role>): Promise<EntityRecordResponse<Role>> {\n const response = await this.client.post('roles', nullifyEmptyObjectProperties(data));\n\n return response.data;\n }\n\n async update(id: Role['id'], data: Partial<Role>): Promise<EntityRecordResponse<Role>> {\n const response = await this.client.post(`roles/${id}`, nullifyEmptyObjectProperties(data));\n\n return response.data;\n }\n\n async createOrUpdate(\n idOrName: string,\n data: Partial<Role>,\n ): Promise<EntityRecordResponse<Role>> {\n const response = await this.client.put(`roles/${idOrName}`, nullifyEmptyObjectProperties(data));\n\n return response.data;\n }\n}\n","/*\n * Copyright (c) 2021-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { BuildInput } from 'rapiq';\nimport { buildQuery } from 'rapiq';\nimport type { RoleAttribute } from '@authup/core-kit';\nimport { nullifyEmptyObjectProperties } from '../../../utils';\nimport { BaseAPI } from '../../base';\nimport type {\n EntityAPI, EntityCollectionResponse, EntityRecordResponse,\n} from '../../types-base';\n\nexport class RoleAttributeAPI extends BaseAPI implements EntityAPI<RoleAttribute> {\n async getMany(data?: BuildInput<RoleAttribute>): Promise<EntityCollectionResponse<RoleAttribute>> {\n const response = await this.client.get(`role-attributes${buildQuery(data)}`);\n\n return response.data;\n }\n\n async getOne(roleId: RoleAttribute['id']): Promise<EntityRecordResponse<RoleAttribute>> {\n const response = await this.client.get(`role-attributes/${roleId}`);\n\n return response.data;\n }\n\n async delete(roleId: RoleAttribute['id']): Promise<EntityRecordResponse<RoleAttribute>> {\n const response = await this.client.delete(`role-attributes/${roleId}`);\n\n return response.data;\n }\n\n async create(data: Partial<RoleAttribute>): Promise<EntityRecordResponse<RoleAttribute>> {\n const response = await this.client.post('role-attributes', nullifyEmptyObjectProperties(data));\n\n return response.data;\n }\n\n async update(id: RoleAttribute['id'], data: Partial<RoleAttribute>): Promise<EntityRecordResponse<RoleAttribute>> {\n const response = await this.client.post(`role-attributes/${id}`, nullifyEmptyObjectProperties(data));\n\n return response.data;\n }\n}\n","/*\n * Copyright (c) 2021-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { BuildInput } from 'rapiq';\nimport { buildQuery } from 'rapiq';\nimport type { RolePermission } from '@authup/core-kit';\nimport { BaseAPI } from '../../base';\nimport type { EntityAPISlim, EntityCollectionResponse, EntityRecordResponse } from '../../types-base';\n\nexport class RolePermissionAPI extends BaseAPI implements EntityAPISlim<RolePermission> {\n async getMany(data?: BuildInput<RolePermission>) : Promise<EntityCollectionResponse<RolePermission>> {\n const response = await this.client.get(`role-permissions${buildQuery(data)}`);\n return response.data;\n }\n\n async getOne(id: RolePermission['id']) : Promise<EntityRecordResponse<RolePermission>> {\n const response = await this.client.get(`role-permissions/${id}`);\n\n return response.data;\n }\n\n async delete(id: RolePermission['id']) : Promise<EntityRecordResponse<RolePermission>> {\n const response = await this.client.delete(`role-permissions/${id}`);\n\n return response.data;\n }\n\n async create(data: Partial<RolePermission>) : Promise<EntityRecordResponse<RolePermission>> {\n const response = await this.client.post('role-permissions', data);\n\n return response.data;\n }\n}\n","/*\n * Copyright (c) 2021-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { BuildInput } from 'rapiq';\nimport { buildQuery } from 'rapiq';\nimport type { Scope } from '@authup/core-kit';\nimport { nullifyEmptyObjectProperties } from '../../../utils';\nimport { BaseAPI } from '../../base';\nimport type {\n EntityAPI, EntityCollectionResponse, EntityRecordResponse,\n} from '../../types-base';\n\nexport class ScopeAPI extends BaseAPI implements EntityAPI<Scope> {\n async getMany(data?: BuildInput<Scope>): Promise<EntityCollectionResponse<Scope>> {\n const response = await this.client.get(`scopes${buildQuery(data)}`);\n\n return response.data;\n }\n\n async getOne(id: Scope['id']): Promise<EntityRecordResponse<Scope>> {\n const response = await this.client.get(`scopes/${id}`);\n\n return response.data;\n }\n\n async delete(id: Scope['id']): Promise<EntityRecordResponse<Scope>> {\n const response = await this.client.delete(`scopes/${id}`);\n\n return response.data;\n }\n\n async create(data: Partial<Scope>): Promise<EntityRecordResponse<Scope>> {\n const response = await this.client.post('scopes', nullifyEmptyObjectProperties(data));\n\n return response.data;\n }\n\n async update(id: Scope['id'], data: Partial<Scope>): Promise<EntityRecordResponse<Scope>> {\n const response = await this.client.post(`scopes/${id}`, nullifyEmptyObjectProperties(data));\n\n return response.data;\n }\n\n async createOrUpdate(\n idOrName: string,\n data: Partial<Scope>,\n ): Promise<EntityRecordResponse<Scope>> {\n const response = await this.client.put(`scopes/${idOrName}`, nullifyEmptyObjectProperties(data));\n\n return response.data;\n }\n}\n","/*\n * Copyright (c) 2021-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { BuildInput } from 'rapiq';\nimport { buildQuery } from 'rapiq';\nimport type { User } from '@authup/core-kit';\nimport { nullifyEmptyObjectProperties } from '../../../utils';\nimport { BaseAPI } from '../../base';\nimport type { EntityAPI, EntityCollectionResponse, EntityRecordResponse } from '../../types-base';\n\nexport class UserAPI extends BaseAPI implements EntityAPI<User> {\n async getMany(\n options?: BuildInput<User>,\n ): Promise<EntityCollectionResponse<User>> {\n const response = await this.client\n .get(`users${buildQuery(options)}`);\n\n return response.data;\n }\n\n async getOne(\n id: User['id'],\n options?: BuildInput<User>,\n ): Promise<EntityRecordResponse<User>> {\n const response = await this.client\n .get(`users/${id}${buildQuery(options)}`);\n\n return response.data;\n }\n\n async delete(\n id: User['id'],\n ): Promise<EntityRecordResponse<User>> {\n const response = await this.client\n .delete(`users/${id}`);\n\n return response.data;\n }\n\n async create(\n data: Partial<User>,\n ): Promise<EntityRecordResponse<User>> {\n const response = await this.client\n .post('users', nullifyEmptyObjectProperties(data));\n\n return response.data;\n }\n\n async update(\n id: User['id'],\n data: Partial<User> & { password_repeat?: User['password'] },\n ): Promise<EntityRecordResponse<User>> {\n const response = await this.client.post(`users/${id}`, nullifyEmptyObjectProperties(data));\n\n return response.data;\n }\n\n async createOrUpdate(\n idOrName: string,\n data: Partial<User> & { password_repeat?: User['password'] },\n ): Promise<EntityRecordResponse<User>> {\n const response = await this.client.put(`users/${idOrName}`, nullifyEmptyObjectProperties(data));\n\n return response.data;\n }\n\n // ---------------------------------------------------------------------------\n\n async activate(\n token: string,\n ): Promise<User> {\n const response = await this.client.post('users/activate', {\n token,\n });\n\n return response.data;\n }\n\n async register(\n data: Partial<Pick<User, 'email' | 'name' | 'password' | 'realm_id'>>,\n ): Promise<User> {\n const response = await this.client.post('users/register', nullifyEmptyObjectProperties(data));\n\n return response.data;\n }\n\n async passwordForgot(\n data: Partial<Pick<User, 'email' | 'name' | 'realm_id'>>,\n ) : Promise<User> {\n const response = await this.client.post('users/password-forgot', nullifyEmptyObjectProperties(data));\n\n return response.data;\n }\n\n async passwordReset(\n data: Partial<Pick<User, 'email' | 'name' | 'realm_id'>> &\n { token: string, password: string },\n ) : Promise<User> {\n const response = await this.client.post('users/password-reset', nullifyEmptyObjectProperties(data));\n\n return response.data;\n }\n}\n","/*\n * Copyright (c) 2021-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { BuildInput } from 'rapiq';\nimport { buildQuery } from 'rapiq';\nimport type { UserAttribute } from '@authup/core-kit';\nimport { nullifyEmptyObjectProperties } from '../../../utils';\nimport { BaseAPI } from '../../base';\nimport type {\n EntityAPI, EntityCollectionResponse, EntityRecordResponse,\n} from '../../types-base';\n\nexport class UserAttributeAPI extends BaseAPI implements EntityAPI<UserAttribute> {\n async getMany(data?: BuildInput<UserAttribute>): Promise<EntityCollectionResponse<UserAttribute>> {\n const response = await this.client.get(`user-attributes${buildQuery(data)}`);\n\n return response.data;\n }\n\n async getOne(roleId: UserAttribute['id']): Promise<EntityRecordResponse<UserAttribute>> {\n const response = await this.client.get(`user-attributes/${roleId}`);\n\n return response.data;\n }\n\n async delete(roleId: UserAttribute['id']): Promise<EntityRecordResponse<UserAttribute>> {\n const response = await this.client.delete(`user-attributes/${roleId}`);\n\n return response.data;\n }\n\n async create(data: Partial<UserAttribute>): Promise<EntityRecordResponse<UserAttribute>> {\n const response = await this.client.post('user-attributes', nullifyEmptyObjectProperties(data));\n\n return response.data;\n }\n\n async update(id: UserAttribute['id'], data: Partial<UserAttribute>): Promise<EntityRecordResponse<UserAttribute>> {\n const response = await this.client.post(`user-attributes/${id}`, nullifyEmptyObjectProperties(data));\n\n return response.data;\n }\n}\n","/*\n * Copyright (c) 2021-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { BuildInput } from 'rapiq';\nimport { buildQuery } from 'rapiq';\nimport type { UserPermission } from '@authup/core-kit';\nimport { nullifyEmptyObjectProperties } from '../../../utils';\nimport { BaseAPI } from '../../base';\nimport type { EntityAPISlim, EntityCollectionResponse, EntityRecordResponse } from '../../types-base';\n\nexport class UserPermissionAPI extends BaseAPI implements EntityAPISlim<UserPermission> {\n async getMany(data?: BuildInput<UserPermission>) : Promise<EntityCollectionResponse<UserPermission>> {\n const response = await this.client.get(`user-permissions${buildQuery(data)}`);\n return response.data;\n }\n\n async getOne(id: UserPermission['id']) : Promise<EntityRecordResponse<UserPermission>> {\n const response = await this.client.get(`user-permissions/${id}`);\n\n return response.data;\n }\n\n async delete(id: UserPermission['id']) : Promise<EntityRecordResponse<UserPermission>> {\n const response = await this.client.delete(`user-permissions/${id}`);\n\n return response.data;\n }\n\n async create(data: Partial<UserPermission>) : Promise<EntityRecordResponse<UserPermission>> {\n const response = await this.client.post('user-permissions', nullifyEmptyObjectProperties(data));\n\n return response.data;\n }\n}\n","/*\n * Copyright (c) 2021-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { BuildInput } from 'rapiq';\nimport { buildQuery } from 'rapiq';\nimport type { UserRole } from '@authup/core-kit';\nimport { BaseAPI } from '../../base';\nimport type { EntityAPISlim, EntityCollectionResponse, EntityRecordResponse } from '../../types-base';\n\nexport class UserRoleAPI extends BaseAPI implements EntityAPISlim<UserRole> {\n async getMany(data: BuildInput<UserRole> = {}): Promise<EntityCollectionResponse<UserRole>> {\n const response = await this.client.get(`user-roles${buildQuery(data)}`);\n\n return response.data;\n }\n\n async getOne(id: UserRole['id']): Promise<EntityRecordResponse<UserRole>> {\n const response = await this.client.get(`user-roles/${id}`);\n\n return response.data;\n }\n\n async delete(id: UserRole['id']): Promise<EntityRecordResponse<UserRole>> {\n const response = await this.client.delete(`user-roles/${id}`);\n\n return response.data;\n }\n\n async create(data: Partial<UserRole>): Promise<EntityRecordResponse<UserRole>> {\n const response = await this.client.post('user-roles', data);\n\n return response.data;\n }\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { OAuth2AuthorizationCodeRequest } from '@authup/core-kit';\nimport { AuthorizeAPI } from '@hapic/oauth2';\nimport { nullifyEmptyObjectProperties } from '../../../../utils';\n\nexport class OAuth2AuthorizeAPI extends AuthorizeAPI {\n async confirm(\n data: OAuth2AuthorizationCodeRequest,\n ) : Promise<{ url: string }> {\n const response = await this.client.post(\n 'authorize',\n nullifyEmptyObjectProperties(data),\n );\n\n return response.data;\n }\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { TokenAPI } from '@hapic/oauth2';\n\nexport class OAuth2TokenAPI extends TokenAPI {\n\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { UserInfoAPI } from '@hapic/oauth2';\n\nexport class OAuth2UserInfoAPI extends UserInfoAPI {\n\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { Client as BaseClient, HookName, isClientError } from 'hapic';\nimport type {\n Options,\n} from '@hapic/oauth2';\nimport type { OAuth2JsonWebKey, OpenIDProviderMetadata } from '@authup/specs';\nimport {\n ClientAPI,\n ClientPermissionAPI,\n ClientRoleAPI,\n ClientScopeAPI,\n IdentityProviderAPI,\n IdentityProviderRoleMappingAPI,\n OAuth2AuthorizeAPI,\n OAuth2TokenAPI,\n OAuth2UserInfoAPI,\n PermissionAPI,\n PolicyAPI,\n RealmAPI,\n RobotAPI,\n RobotPermissionAPI,\n RobotRoleAPI,\n RoleAPI,\n RoleAttributeAPI,\n RolePermissionAPI,\n ScopeAPI,\n UserAPI,\n UserAttributeAPI,\n UserPermissionAPI,\n UserRoleAPI,\n} from '../domains';\nimport type { ClientOptions } from './type';\n\nexport class Client extends BaseClient {\n public readonly token : OAuth2TokenAPI;\n\n public readonly authorize : OAuth2AuthorizeAPI;\n\n public readonly client : ClientAPI;\n\n public readonly clientPermission : ClientPermissionAPI;\n\n public readonly clientRole : ClientRoleAPI;\n\n public readonly clientScope : ClientScopeAPI;\n\n public readonly identityProvider : IdentityProviderAPI;\n\n public readonly identityProviderRoleMapping : IdentityProviderRoleMappingAPI;\n\n public readonly policy: PolicyAPI;\n\n public readonly permission : PermissionAPI;\n\n public readonly realm : RealmAPI;\n\n public readonly robot : RobotAPI;\n\n public readonly robotPermission : RobotPermissionAPI;\n\n public readonly robotRole : RobotRoleAPI;\n\n public readonly role : RoleAPI;\n\n public readonly roleAttribute : RoleAttributeAPI;\n\n public readonly rolePermission : RolePermissionAPI;\n\n public readonly scope: ScopeAPI;\n\n public readonly user : UserAPI;\n\n public readonly userInfo : OAuth2UserInfoAPI;\n\n public readonly userAttribute: UserAttributeAPI;\n\n public readonly userPermission : UserPermissionAPI;\n\n public readonly userRole : UserRoleAPI;\n\n constructor(config: ClientOptions = {}) {\n super(config);\n\n const options : Options = {\n authorizationEndpoint: 'authorize',\n introspectionEndpoint: 'token/introspect',\n tokenEndpoint: 'token',\n userinfoEndpoint: 'users/@me',\n };\n\n const baseURL = this.getBaseURL();\n\n if (typeof baseURL === 'string') {\n const keys = Object.keys(options);\n for (let i = 0; i < keys.length; i++) {\n options[keys[i]] = new URL(options[keys[i]], baseURL).href;\n }\n }\n\n this.authorize = new OAuth2AuthorizeAPI({ client: this, options });\n this.token = new OAuth2TokenAPI({ client: this, options });\n\n this.client = new ClientAPI({ client: this });\n this.clientPermission = new ClientPermissionAPI({ client: this });\n this.clientRole = new ClientRoleAPI({ client: this });\n this.clientScope = new ClientScopeAPI({ client: this });\n\n this.identityProvider = new IdentityProviderAPI({ client: this });\n this.identityProviderRoleMapping = new IdentityProviderRoleMappingAPI({ client: this });\n\n this.policy = new PolicyAPI({ client: this });\n this.permission = new PermissionAPI({ client: this });\n\n this.realm = new RealmAPI({ client: this });\n\n this.robot = new RobotAPI({ client: this });\n this.robotPermission = new RobotPermissionAPI({ client: this });\n this.robotRole = new RobotRoleAPI({ client: this });\n\n this.role = new RoleAPI({ client: this });\n this.roleAttribute = new RoleAttributeAPI({ client: this });\n this.rolePermission = new RolePermissionAPI({ client: this });\n\n this.scope = new ScopeAPI({ client: this });\n\n this.user = new UserAPI({ client: this });\n\n this.userInfo = new OAuth2UserInfoAPI({ client: this, options });\n this.userAttribute = new UserAttributeAPI({ client: this });\n this.userPermission = new UserPermissionAPI({ client: this });\n this.use