From d160f9f618e67fe059cc0d098a8c9fb4dd4c7c74 Mon Sep 17 00:00:00 2001 From: Praveen Yadav Date: Wed, 2 Aug 2023 14:04:55 +0530 Subject: [PATCH] feat: support shield js client (#288) --- sdks/js/packages/core/client/V1Beta1.ts | 2478 +++++++++++++++++ sdks/js/packages/core/client/WellKnown.ts | 33 + .../js/packages/core/client/data-contracts.ts | 1006 +++++++ sdks/js/packages/core/client/http-client.ts | 220 ++ sdks/js/packages/core/package.json | 3 +- .../packages/core/react/components/login.tsx | 10 +- .../react/components/magiclink-verify.tsx | 8 +- .../core/react/components/magiclink.tsx | 10 +- .../core/react/components/organization.tsx | 4 +- .../packages/core/react/components/signup.tsx | 10 +- .../core/react/contexts/FrontierContext.tsx | 63 +- sdks/js/packages/core/react/frontier.ts | 93 +- sdks/js/packages/core/src/index.ts | 4 +- 13 files changed, 3820 insertions(+), 122 deletions(-) create mode 100644 sdks/js/packages/core/client/V1Beta1.ts create mode 100644 sdks/js/packages/core/client/WellKnown.ts create mode 100644 sdks/js/packages/core/client/data-contracts.ts create mode 100644 sdks/js/packages/core/client/http-client.ts diff --git a/sdks/js/packages/core/client/V1Beta1.ts b/sdks/js/packages/core/client/V1Beta1.ts new file mode 100644 index 000000000..68a1b9af4 --- /dev/null +++ b/sdks/js/packages/core/client/V1Beta1.ts @@ -0,0 +1,2478 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +import { + RpcStatus, + V1Beta1AcceptOrganizationInvitationResponse, + V1Beta1AddGroupUsersResponse, + V1Beta1AddOrganizationUsersResponse, + V1Beta1AuditLog, + V1Beta1AuthCallbackRequest, + V1Beta1AuthCallbackResponse, + V1Beta1AuthLogoutResponse, + V1Beta1AuthTokenRequest, + V1Beta1AuthTokenResponse, + V1Beta1AuthenticateResponse, + V1Beta1CheckResourcePermissionRequest, + V1Beta1CheckResourcePermissionResponse, + V1Beta1CreateGroupResponse, + V1Beta1CreateMetaSchemaResponse, + V1Beta1CreateOrganizationAuditLogsResponse, + V1Beta1CreateOrganizationInvitationResponse, + V1Beta1CreateOrganizationResponse, + V1Beta1CreateOrganizationRoleResponse, + V1Beta1CreatePermissionRequest, + V1Beta1CreatePermissionResponse, + V1Beta1CreatePolicyResponse, + V1Beta1CreateProjectResourceResponse, + V1Beta1CreateProjectResponse, + V1Beta1CreateRelationResponse, + V1Beta1CreateRoleResponse, + V1Beta1CreateServiceUserKeyResponse, + V1Beta1CreateServiceUserRequest, + V1Beta1CreateServiceUserResponse, + V1Beta1CreateServiceUserSecretResponse, + V1Beta1CreateUserResponse, + V1Beta1DeleteGroupResponse, + V1Beta1DeleteMetaSchemaResponse, + V1Beta1DeleteOrganizationInvitationResponse, + V1Beta1DeleteOrganizationResponse, + V1Beta1DeleteOrganizationRoleResponse, + V1Beta1DeletePermissionResponse, + V1Beta1DeletePolicyResponse, + V1Beta1DeleteProjectResourceResponse, + V1Beta1DeleteProjectResponse, + V1Beta1DeleteRelationResponse, + V1Beta1DeleteRoleResponse, + V1Beta1DeleteServiceUserKeyResponse, + V1Beta1DeleteServiceUserResponse, + V1Beta1DeleteServiceUserSecretResponse, + V1Beta1DeleteUserResponse, + V1Beta1DisableGroupResponse, + V1Beta1DisableOrganizationResponse, + V1Beta1DisableProjectResponse, + V1Beta1DisableUserResponse, + V1Beta1EnableGroupResponse, + V1Beta1EnableOrganizationResponse, + V1Beta1EnableProjectResponse, + V1Beta1EnableUserResponse, + V1Beta1GetCurrentUserResponse, + V1Beta1GetGroupResponse, + V1Beta1GetJWKsResponse, + V1Beta1GetMetaSchemaResponse, + V1Beta1GetNamespaceResponse, + V1Beta1GetOrganizationAuditLogResponse, + V1Beta1GetOrganizationInvitationResponse, + V1Beta1GetOrganizationResponse, + V1Beta1GetOrganizationRoleResponse, + V1Beta1GetOrganizationsByCurrentUserResponse, + V1Beta1GetOrganizationsByUserResponse, + V1Beta1GetPermissionResponse, + V1Beta1GetPolicyResponse, + V1Beta1GetProjectResourceResponse, + V1Beta1GetProjectResponse, + V1Beta1GetProjectsByCurrentUserResponse, + V1Beta1GetProjectsByUserResponse, + V1Beta1GetRelationResponse, + V1Beta1GetServiceUserKeyResponse, + V1Beta1GetServiceUserResponse, + V1Beta1GetUserResponse, + V1Beta1GroupRequestBody, + V1Beta1ListAllOrganizationsResponse, + V1Beta1ListAllUsersResponse, + V1Beta1ListAuthStrategiesResponse, + V1Beta1ListCurrentUserGroupsResponse, + V1Beta1ListGroupUsersResponse, + V1Beta1ListGroupsResponse, + V1Beta1ListMetaSchemasResponse, + V1Beta1ListNamespacesResponse, + V1Beta1ListOrganizationAdminsResponse, + V1Beta1ListOrganizationAuditLogsResponse, + V1Beta1ListOrganizationGroupsResponse, + V1Beta1ListOrganizationInvitationsResponse, + V1Beta1ListOrganizationProjectsResponse, + V1Beta1ListOrganizationRolesResponse, + V1Beta1ListOrganizationServiceUsersResponse, + V1Beta1ListOrganizationUsersResponse, + V1Beta1ListOrganizationsResponse, + V1Beta1ListPermissionsResponse, + V1Beta1ListPoliciesResponse, + V1Beta1ListProjectAdminsResponse, + V1Beta1ListProjectResourcesResponse, + V1Beta1ListProjectUsersResponse, + V1Beta1ListProjectsResponse, + V1Beta1ListRelationsResponse, + V1Beta1ListResourcesResponse, + V1Beta1ListRolesResponse, + V1Beta1ListServiceUserKeysResponse, + V1Beta1ListServiceUserSecretsResponse, + V1Beta1ListServiceUsersResponse, + V1Beta1ListUserGroupsResponse, + V1Beta1ListUserInvitationsResponse, + V1Beta1ListUsersResponse, + V1Beta1MetaSchemaRequestBody, + V1Beta1OrganizationRequestBody, + V1Beta1PermissionRequestBody, + V1Beta1PolicyRequestBody, + V1Beta1ProjectRequestBody, + V1Beta1RelationRequestBody, + V1Beta1RemoveGroupUserResponse, + V1Beta1RemoveOrganizationUserResponse, + V1Beta1ResourceRequestBody, + V1Beta1RoleRequestBody, + V1Beta1UpdateCurrentUserResponse, + V1Beta1UpdateGroupResponse, + V1Beta1UpdateMetaSchemaResponse, + V1Beta1UpdateOrganizationResponse, + V1Beta1UpdateOrganizationRoleResponse, + V1Beta1UpdatePermissionResponse, + V1Beta1UpdatePolicyResponse, + V1Beta1UpdateProjectResourceResponse, + V1Beta1UpdateProjectResponse, + V1Beta1UpdateUserResponse, + V1Beta1UserRequestBody +} from './data-contracts'; +import { ContentType, HttpClient, RequestParams } from './http-client'; + +export class V1Beta1 extends HttpClient { + /** + * @description Lists all the groups from all the organizations in a Frontier instance. It can be filtered by organization and state. + * + * @tags Group + * @name AdminServiceListGroups + * @summary List all groups + * @request GET:/v1beta1/admin/groups + * @secure + */ + adminServiceListGroups = ( + query?: { + /** The organization id to filter by. */ + orgId?: string; + /** The state to filter by. It can be enabled or disabled. */ + state?: string; + }, + params: RequestParams = {} + ) => + this.request({ + path: `/v1beta1/admin/groups`, + method: 'GET', + query: query, + secure: true, + format: 'json', + ...params + }); + /** + * @description Lists all the organizations in a Frontier instance. It can be filtered by user and state. + * + * @tags Organization + * @name AdminServiceListAllOrganizations + * @summary List all organizations + * @request GET:/v1beta1/admin/organizations + * @secure + */ + adminServiceListAllOrganizations = ( + query?: { + /** The user id to filter by. */ + userId?: string; + /** The state to filter by. It can be enabled or disabled. */ + state?: string; + }, + params: RequestParams = {} + ) => + this.request({ + path: `/v1beta1/admin/organizations`, + method: 'GET', + query: query, + secure: true, + format: 'json', + ...params + }); + /** + * @description Lists all the projects from all the organizations in a Frontier instance. It can be filtered by organization and state. + * + * @tags Project + * @name AdminServiceListProjects + * @summary List all projects + * @request GET:/v1beta1/admin/projects + * @secure + */ + adminServiceListProjects = ( + query?: { + /** The organization id to filter by. */ + orgId?: string; + /** The state to filter by. It can be enabled or disabled. */ + state?: string; + }, + params: RequestParams = {} + ) => + this.request({ + path: `/v1beta1/admin/projects`, + method: 'GET', + query: query, + secure: true, + format: 'json', + ...params + }); + /** + * No description + * + * @tags Relation + * @name AdminServiceListRelations + * @summary List all relations + * @request GET:/v1beta1/admin/relations + * @secure + */ + adminServiceListRelations = (params: RequestParams = {}) => + this.request({ + path: `/v1beta1/admin/relations`, + method: 'GET', + secure: true, + format: 'json', + ...params + }); + /** + * @description Lists all the resources from all the organizations in a Frontier instance. It can be filtered by user, project, organization and namespace. + * + * @tags Resource + * @name AdminServiceListResources + * @summary List all resources + * @request GET:/v1beta1/admin/resources + * @secure + */ + adminServiceListResources = ( + query?: { + /** The user id to filter by. */ + userId?: string; + /** The project id to filter by. */ + projectId?: string; + /** The organization id to filter by. */ + organizationId?: string; + /** The namespace to filter by. */ + namespace?: string; + }, + params: RequestParams = {} + ) => + this.request({ + path: `/v1beta1/admin/resources`, + method: 'GET', + query: query, + secure: true, + format: 'json', + ...params + }); + /** + * @description Lists all the users from all the organizations in a Frontier instance. It can be filtered by keyword, organization, group and state. + * + * @tags User + * @name AdminServiceListAllUsers + * @summary List all users + * @request GET:/v1beta1/admin/users + * @secure + */ + adminServiceListAllUsers = ( + query?: { + /** + * The maximum number of users to return per page. The default is 50. + * @format int32 + */ + pageSize?: number; + /** + * The page number to return. The default is 1. + * @format int32 + */ + pageNum?: number; + /** The keyword to search for. It can be a user's name, email,metadata or id. */ + keyword?: string; + /** The organization id to filter by. */ + orgId?: string; + /** The group id to filter by. */ + groupId?: string; + /** The state to filter by. It can be enabled or disabled. */ + state?: string; + }, + params: RequestParams = {} + ) => + this.request({ + path: `/v1beta1/admin/users`, + method: 'GET', + query: query, + secure: true, + format: 'json', + ...params + }); + /** + * @description Returns a list of identity providers configured on an instance level in Frontier. e.g Google, AzureAD, Github etc + * + * @tags Authn + * @name FrontierServiceListAuthStrategies + * @summary List authentication strategies + * @request GET:/v1beta1/auth + * @secure + */ + frontierServiceListAuthStrategies = (params: RequestParams = {}) => + this.request({ + path: `/v1beta1/auth`, + method: 'GET', + secure: true, + format: 'json', + ...params + }); + /** + * @description Callback from a strategy. This is the endpoint where the strategy will redirect the user after successful authentication. This endpoint will be called with the code and state query parameters. The code will be used to get the access token from the strategy and the state will be used to get the return_to url from the session and redirect the user to that url. + * + * @tags Authn + * @name FrontierServiceAuthCallback + * @summary Callback from a strategy + * @request GET:/v1beta1/auth/callback + * @secure + */ + frontierServiceAuthCallback = ( + query?: { + /** strategy_name will not be set for oidc but can be utilized for methods like email magic links */ + strategyName?: string; + /** for oidc & magic links */ + state?: string; + code?: string; + }, + params: RequestParams = {} + ) => + this.request({ + path: `/v1beta1/auth/callback`, + method: 'GET', + query: query, + secure: true, + format: 'json', + ...params + }); + /** + * @description Callback from a strategy. This is the endpoint where the strategy will redirect the user after successful authentication. This endpoint will be called with the code and state query parameters. The code will be used to get the access token from the strategy and the state will be used to get the return_to url from the session and redirect the user to that url. + * + * @tags Authn + * @name FrontierServiceAuthCallback2 + * @summary Callback from a strategy + * @request POST:/v1beta1/auth/callback + * @secure + */ + frontierServiceAuthCallback2 = (body: V1Beta1AuthCallbackRequest, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/auth/callback`, + method: 'POST', + body: body, + secure: true, + type: ContentType.Json, + format: 'json', + ...params + }); + /** + * No description + * + * @tags Authz + * @name FrontierServiceGetJwKs + * @summary Get well known JWKs + * @request GET:/v1beta1/auth/jwks + * @secure + */ + frontierServiceGetJwKs = (params: RequestParams = {}) => + this.request({ + path: `/v1beta1/auth/jwks`, + method: 'GET', + secure: true, + format: 'json', + ...params + }); + /** + * No description + * + * @tags Authn + * @name FrontierServiceAuthLogout + * @summary Logout from a strategy + * @request GET:/v1beta1/auth/logout + * @secure + */ + frontierServiceAuthLogout = (params: RequestParams = {}) => + this.request({ + path: `/v1beta1/auth/logout`, + method: 'GET', + secure: true, + format: 'json', + ...params + }); + /** + * No description + * + * @tags Authn + * @name FrontierServiceAuthLogout2 + * @summary Logout from a strategy + * @request DELETE:/v1beta1/auth/logout + * @secure + */ + frontierServiceAuthLogout2 = (params: RequestParams = {}) => + this.request({ + path: `/v1beta1/auth/logout`, + method: 'DELETE', + secure: true, + format: 'json', + ...params + }); + /** + * @description Authenticate a user with a strategy. By default, after successful authentication no operation will be performed to apply redirection in case of browsers, provide a url in the authenticate request body that will be used for redirection after authentication. Also set redirect as true for redirecting the user request to the redirect_url after successful authentication. + * + * @tags Authn + * @name FrontierServiceAuthenticate + * @summary Authenticate with a strategy + * @request GET:/v1beta1/auth/register/{strategyName} + * @secure + */ + frontierServiceAuthenticate = ( + strategyName: string, + query?: { + /** + * by default, location redirect header for starting authentication flow if applicable + * will be skipped unless this is set to true, useful in browser + * + * If set to true, location header will be set for redirect + */ + redirect?: boolean; + /** + * by default, after successful authentication no operation will be performed + * to apply redirection in case of browsers, provide a url that will be used + * for redirection after authentication + * + * URL to redirect after successful authentication.
*Example:*`"https://frontier.example.com"` + */ + returnTo?: string; + /** + * email of the user for magic links + * + * Email of the user to authenticate. Used for magic links.
*Example:*`example@acme.org` + */ + email?: string; + }, + params: RequestParams = {} + ) => + this.request({ + path: `/v1beta1/auth/register/${strategyName}`, + method: 'GET', + query: query, + secure: true, + format: 'json', + ...params + }); + /** + * @description Authenticate a user with a strategy. By default, after successful authentication no operation will be performed to apply redirection in case of browsers, provide a url in the authenticate request body that will be used for redirection after authentication. Also set redirect as true for redirecting the user request to the redirect_url after successful authentication. + * + * @tags Authn + * @name FrontierServiceAuthenticate2 + * @summary Authenticate with a strategy + * @request POST:/v1beta1/auth/register/{strategyName} + * @secure + */ + frontierServiceAuthenticate2 = ( + strategyName: string, + body: { + /** + * by default, location redirect header for starting authentication flow if applicable + * will be skipped unless this is set to true, useful in browser + * If set to true, location header will be set for redirect + */ + redirect?: boolean; + /** + * by default, after successful authentication no operation will be performed + * to apply redirection in case of browsers, provide a url that will be used + * for redirection after authentication + * URL to redirect after successful authentication.
*Example:*`"https://frontier.example.com"` + */ + returnTo?: string; + /** + * email of the user for magic links + * Email of the user to authenticate. Used for magic links.
*Example:*`example@acme.org` + */ + email?: string; + }, + params: RequestParams = {} + ) => + this.request({ + path: `/v1beta1/auth/register/${strategyName}`, + method: 'POST', + body: body, + secure: true, + type: ContentType.Json, + format: 'json', + ...params + }); + /** + * @description Access token can be generated by providing the credentials in the request body/header. The credentials can be client id and secret or service account generated key jwt. Use the generated access token in Authorization header to access the frontier resources. + * + * @tags Authn + * @name FrontierServiceAuthToken + * @summary Generate access token by given credentials + * @request POST:/v1beta1/auth/token + * @secure + */ + frontierServiceAuthToken = (body: V1Beta1AuthTokenRequest, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/auth/token`, + method: 'POST', + body: body, + secure: true, + type: ContentType.Json, + format: 'json', + ...params + }); + /** + * @description Returns true if a principal has required permissions to access a resource and false otherwise.
Note the principal can be a user or a service account, and Frontier will the credentials from the current logged in principal from the session cookie (if any), or the client id and secret (in case of service users) or the access token (in case of human user accounts). + * + * @tags Authz + * @name FrontierServiceCheckResourcePermission + * @summary Check + * @request POST:/v1beta1/check + * @secure + */ + frontierServiceCheckResourcePermission = (body: V1Beta1CheckResourcePermissionRequest, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/check`, + method: 'POST', + body: body, + secure: true, + type: ContentType.Json, + format: 'json', + ...params + }); + /** + * @description Returns a list of all metaschemas configured on an instance level in Frontier. e.g user, project, organization etc + * + * @tags MetaSchema + * @name FrontierServiceListMetaSchemas + * @summary List metaschemas + * @request GET:/v1beta1/meta/schemas + * @secure + */ + frontierServiceListMetaSchemas = (params: RequestParams = {}) => + this.request({ + path: `/v1beta1/meta/schemas`, + method: 'GET', + secure: true, + format: 'json', + ...params + }); + /** + * @description Create a new metadata schema. The metaschema **name** must be unique within the entire Frontier instance and can contain only alphanumeric characters, dashes and underscores. The metaschema **schema** must be a valid JSON schema.Please refer to https://json-schema.org/ to know more about json schema.
*Example:* `{name:"user",schema:{"type":"object","properties":{"label":{"type":"object","additionalProperties":{"type":"string"}},"description":{"type":"string"}}}}` + * + * @tags MetaSchema + * @name FrontierServiceCreateMetaSchema + * @summary Create metaschema + * @request POST:/v1beta1/meta/schemas + * @secure + */ + frontierServiceCreateMetaSchema = (body: V1Beta1MetaSchemaRequestBody, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/meta/schemas`, + method: 'POST', + body: body, + secure: true, + format: 'json', + ...params + }); + /** + * @description Get a metadata schema by ID. + * + * @tags MetaSchema + * @name FrontierServiceGetMetaSchema + * @summary Get metaschema + * @request GET:/v1beta1/meta/schemas/{id} + * @secure + */ + frontierServiceGetMetaSchema = (id: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/meta/schemas/${id}`, + method: 'GET', + secure: true, + format: 'json', + ...params + }); + /** + * @description Delete a metadata schema permanently. Once deleted the metaschema won't be used to validate the metadata. For example, if a metaschema(with `label` and `description` fields) is used to validate the metadata of a user, then deleting the metaschema will not validate the metadata of the user and metadata field can contain any key-value pair(and say another field called `foo` can be inserted in a user's metadata). + * + * @tags MetaSchema + * @name FrontierServiceDeleteMetaSchema + * @summary Delete metaschema + * @request DELETE:/v1beta1/meta/schemas/{id} + * @secure + */ + frontierServiceDeleteMetaSchema = (id: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/meta/schemas/${id}`, + method: 'DELETE', + secure: true, + format: 'json', + ...params + }); + /** + * @description Update a metadata schema. Only `schema` field of a metaschema can be updated. The metaschema `schema` must be a valid JSON schema.Please refer to https://json-schema.org/ to know more about json schema.
*Example:* `{name:"user",schema:{"type":"object","properties":{"label":{"type":"object","additionalProperties":{"type":"string"}},"description":{"type":"string"}}}}` + * + * @tags MetaSchema + * @name FrontierServiceUpdateMetaSchema + * @summary Update metaschema + * @request PUT:/v1beta1/meta/schemas/{id} + * @secure + */ + frontierServiceUpdateMetaSchema = (id: string, body: V1Beta1MetaSchemaRequestBody, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/meta/schemas/${id}`, + method: 'PUT', + body: body, + secure: true, + format: 'json', + ...params + }); + /** + * @description Returns the list of all namespaces in a Frontier instance + * + * @tags Namespace + * @name FrontierServiceListNamespaces + * @summary Get all namespaces + * @request GET:/v1beta1/namespaces + * @secure + */ + frontierServiceListNamespaces = (params: RequestParams = {}) => + this.request({ + path: `/v1beta1/namespaces`, + method: 'GET', + secure: true, + format: 'json', + ...params + }); + /** + * @description Returns a namespace by ID + * + * @tags Namespace + * @name FrontierServiceGetNamespace + * @summary Get namespace + * @request GET:/v1beta1/namespaces/{id} + * @secure + */ + frontierServiceGetNamespace = (id: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/namespaces/${id}`, + method: 'GET', + secure: true, + format: 'json', + ...params + }); + /** + * @description Returns a list of audit logs of an organization in Frontier. + * + * @tags AuditLog + * @name FrontierServiceListOrganizationAuditLogs + * @summary List audit logs + * @request GET:/v1beta1/organization/{orgId}/auditlogs + * @secure + */ + frontierServiceListOrganizationAuditLogs = ( + orgId: string, + query?: { + source?: string; + action?: string; + /** + * start_time and end_time are inclusive + * @format date-time + */ + startTime?: string; + /** @format date-time */ + endTime?: string; + }, + params: RequestParams = {} + ) => + this.request({ + path: `/v1beta1/organization/${orgId}/auditlogs`, + method: 'GET', + query: query, + secure: true, + format: 'json', + ...params + }); + /** + * @description Create new audit logs in a batch. + * + * @tags AuditLog + * @name FrontierServiceCreateOrganizationAuditLogs + * @summary Create audit log + * @request POST:/v1beta1/organization/{orgId}/auditlogs + * @secure + */ + frontierServiceCreateOrganizationAuditLogs = ( + orgId: string, + body: { + logs?: V1Beta1AuditLog[]; + }, + params: RequestParams = {} + ) => + this.request({ + path: `/v1beta1/organization/${orgId}/auditlogs`, + method: 'POST', + body: body, + secure: true, + type: ContentType.Json, + format: 'json', + ...params + }); + /** + * @description Get an audit log by ID. + * + * @tags AuditLog + * @name FrontierServiceGetOrganizationAuditLog + * @summary Get audit log + * @request GET:/v1beta1/organization/{orgId}/auditlogs/{id} + * @secure + */ + frontierServiceGetOrganizationAuditLog = (orgId: string, id: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/organization/${orgId}/auditlogs/${id}`, + method: 'GET', + secure: true, + format: 'json', + ...params + }); + /** + * @description Returns a list of organizations. It can be filtered by userID or organization state. + * + * @tags Organization + * @name FrontierServiceListOrganizations + * @summary List organizations + * @request GET:/v1beta1/organizations + * @secure + */ + frontierServiceListOrganizations = ( + query?: { + /** The user ID to filter by. It can be used to list all the organizations that the user is a member of. Otherwise, all the organizations in the Frontier instance will be listed. */ + userId?: string; + /** The state to filter by. It can be `enabled` or `disabled`. */ + state?: string; + }, + params: RequestParams = {} + ) => + this.request({ + path: `/v1beta1/organizations`, + method: 'GET', + query: query, + secure: true, + format: 'json', + ...params + }); + /** + * No description + * + * @tags Organization + * @name FrontierServiceCreateOrganization + * @summary Create organization + * @request POST:/v1beta1/organizations + * @secure + */ + frontierServiceCreateOrganization = (body: V1Beta1OrganizationRequestBody, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/organizations`, + method: 'POST', + body: body, + secure: true, + format: 'json', + ...params + }); + /** + * @description Get organization by ID or name + * + * @tags Organization + * @name FrontierServiceGetOrganization + * @summary Get organization + * @request GET:/v1beta1/organizations/{id} + * @secure + */ + frontierServiceGetOrganization = (id: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/organizations/${id}`, + method: 'GET', + secure: true, + format: 'json', + ...params + }); + /** + * @description Delete an organization and all of its relations permanently. The organization users will not be deleted from Frontier. + * + * @tags Organization + * @name FrontierServiceDeleteOrganization + * @summary Delete organization + * @request DELETE:/v1beta1/organizations/{id} + * @secure + */ + frontierServiceDeleteOrganization = (id: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/organizations/${id}`, + method: 'DELETE', + secure: true, + format: 'json', + ...params + }); + /** + * @description Update organization by ID + * + * @tags Organization + * @name FrontierServiceUpdateOrganization + * @summary Update organization + * @request PUT:/v1beta1/organizations/{id} + * @secure + */ + frontierServiceUpdateOrganization = (id: string, body: V1Beta1OrganizationRequestBody, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/organizations/${id}`, + method: 'PUT', + body: body, + secure: true, + format: 'json', + ...params + }); + /** + * @description Returns a list admins of an organization + * + * @tags Organization + * @name FrontierServiceListOrganizationAdmins + * @summary List organization admins + * @request GET:/v1beta1/organizations/{id}/admins + * @secure + */ + frontierServiceListOrganizationAdmins = (id: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/organizations/${id}/admins`, + method: 'GET', + secure: true, + format: 'json', + ...params + }); + /** + * @description Sets the state of the organization as disabled. The existing users in the org will not be able to access any organization resources. + * + * @tags Organization + * @name FrontierServiceDisableOrganization + * @summary Disable organization + * @request POST:/v1beta1/organizations/{id}/disable + * @secure + */ + frontierServiceDisableOrganization = (id: string, body: object, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/organizations/${id}/disable`, + method: 'POST', + body: body, + secure: true, + format: 'json', + ...params + }); + /** + * @description Sets the state of the organization as enabled. The existing users in the org will be able to access any organization resources. + * + * @tags Organization + * @name FrontierServiceEnableOrganization + * @summary Enable organization + * @request POST:/v1beta1/organizations/{id}/enable + * @secure + */ + frontierServiceEnableOrganization = (id: string, body: object, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/organizations/${id}/enable`, + method: 'POST', + body: body, + secure: true, + format: 'json', + ...params + }); + /** + * @description Get all projects that belong to an organization + * + * @tags Organization + * @name FrontierServiceListOrganizationProjects + * @summary Get organization projects + * @request GET:/v1beta1/organizations/{id}/projects + * @secure + */ + frontierServiceListOrganizationProjects = ( + id: string, + query?: { + /** Filter projects by state. If not specified, all projects are returned.
*Possible values:* `enabled` or `disabled` */ + state?: string; + }, + params: RequestParams = {} + ) => + this.request({ + path: `/v1beta1/organizations/${id}/projects`, + method: 'GET', + query: query, + secure: true, + format: 'json', + ...params + }); + /** + * No description + * + * @tags Organization + * @name FrontierServiceListOrganizationServiceUsers + * @summary List organization service users + * @request GET:/v1beta1/organizations/{id}/serviceusers + * @secure + */ + frontierServiceListOrganizationServiceUsers = (id: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/organizations/${id}/serviceusers`, + method: 'GET', + secure: true, + format: 'json', + ...params + }); + /** + * No description + * + * @tags Organization + * @name FrontierServiceListOrganizationUsers + * @summary List organization users + * @request GET:/v1beta1/organizations/{id}/users + * @secure + */ + frontierServiceListOrganizationUsers = ( + id: string, + query?: { + permissionFilter?: string; + }, + params: RequestParams = {} + ) => + this.request({ + path: `/v1beta1/organizations/${id}/users`, + method: 'GET', + query: query, + secure: true, + format: 'json', + ...params + }); + /** + * @description Add a user to an organization. A user must exists in Frontier before adding it to an org. This request will fail if the user doesn't exists + * + * @tags Organization + * @name FrontierServiceAddOrganizationUsers + * @summary Add organization user + * @request POST:/v1beta1/organizations/{id}/users + * @secure + */ + frontierServiceAddOrganizationUsers = ( + id: string, + body: { + /** List of user IDs to be added to the organization. */ + userIds?: string[]; + }, + params: RequestParams = {} + ) => + this.request({ + path: `/v1beta1/organizations/${id}/users`, + method: 'POST', + body: body, + secure: true, + type: ContentType.Json, + format: 'json', + ...params + }); + /** + * @description Remove a user from an organization + * + * @tags Organization + * @name FrontierServiceRemoveOrganizationUser + * @summary Remove organization user + * @request DELETE:/v1beta1/organizations/{id}/users/{userId} + * @secure + */ + frontierServiceRemoveOrganizationUser = (id: string, userId: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/organizations/${id}/users/${userId}`, + method: 'DELETE', + secure: true, + format: 'json', + ...params + }); + /** + * @description Get all groups that belong to an organization. The results can be filtered by state which can be either be enabled or disabled. + * + * @tags Group + * @name FrontierServiceListOrganizationGroups + * @summary List organization groups + * @request GET:/v1beta1/organizations/{orgId}/groups + * @secure + */ + frontierServiceListOrganizationGroups = ( + orgId: string, + query?: { + /** The state of the group to filter by. It can be enabled or disabled. */ + state?: string; + }, + params: RequestParams = {} + ) => + this.request({ + path: `/v1beta1/organizations/${orgId}/groups`, + method: 'GET', + query: query, + secure: true, + format: 'json', + ...params + }); + /** + * @description Create a new group in an organization which serves as a container for users. The group can be assigned roles and permissions and can be used to manage access to resources. Also a group can also be assigned to other groups. + * + * @tags Group + * @name FrontierServiceCreateGroup + * @summary Create group + * @request POST:/v1beta1/organizations/{orgId}/groups + * @secure + */ + frontierServiceCreateGroup = (orgId: string, body: V1Beta1GroupRequestBody, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/organizations/${orgId}/groups`, + method: 'POST', + body: body, + secure: true, + format: 'json', + ...params + }); + /** + * No description + * + * @tags Group + * @name FrontierServiceGetGroup + * @summary Get group + * @request GET:/v1beta1/organizations/{orgId}/groups/{id} + * @secure + */ + frontierServiceGetGroup = (orgId: string, id: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/organizations/${orgId}/groups/${id}`, + method: 'GET', + secure: true, + format: 'json', + ...params + }); + /** + * @description Delete an organization group permanently and all of its relations + * + * @tags Group + * @name FrontierServiceDeleteGroup + * @summary Delete group + * @request DELETE:/v1beta1/organizations/{orgId}/groups/{id} + * @secure + */ + frontierServiceDeleteGroup = (orgId: string, id: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/organizations/${orgId}/groups/${id}`, + method: 'DELETE', + secure: true, + format: 'json', + ...params + }); + /** + * No description + * + * @tags Group + * @name FrontierServiceUpdateGroup + * @summary Update group + * @request PUT:/v1beta1/organizations/{orgId}/groups/{id} + * @secure + */ + frontierServiceUpdateGroup = (orgId: string, id: string, body: V1Beta1GroupRequestBody, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/organizations/${orgId}/groups/${id}`, + method: 'PUT', + body: body, + secure: true, + format: 'json', + ...params + }); + /** + * @description Sets the state of the group as disabled. The group will not be available for access control and the existing users in the group will not be able to access any resources that are assigned to the group. No other users can be added to the group while it is disabled. + * + * @tags Group + * @name FrontierServiceDisableGroup + * @summary Disable group + * @request POST:/v1beta1/organizations/{orgId}/groups/{id}/disable + * @secure + */ + frontierServiceDisableGroup = (orgId: string, id: string, body: object, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/organizations/${orgId}/groups/${id}/disable`, + method: 'POST', + body: body, + secure: true, + format: 'json', + ...params + }); + /** + * @description Sets the state of the group as enabled. The `enabled` flag is used to determine if the group can be used for access control. + * + * @tags Group + * @name FrontierServiceEnableGroup + * @summary Enable group + * @request POST:/v1beta1/organizations/{orgId}/groups/{id}/enable + * @secure + */ + frontierServiceEnableGroup = (orgId: string, id: string, body: object, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/organizations/${orgId}/groups/${id}/enable`, + method: 'POST', + body: body, + secure: true, + format: 'json', + ...params + }); + /** + * @description Returns a list of users that belong to a group. + * + * @tags Group + * @name FrontierServiceListGroupUsers + * @summary List group users + * @request GET:/v1beta1/organizations/{orgId}/groups/{id}/users + * @secure + */ + frontierServiceListGroupUsers = (orgId: string, id: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/organizations/${orgId}/groups/${id}/users`, + method: 'GET', + secure: true, + format: 'json', + ...params + }); + /** + * @description Adds a principle(user and service-users) to a group, existing users in the group will be ignored. A group can't have nested groups as members. + * + * @tags Group + * @name FrontierServiceAddGroupUsers + * @summary Add group user + * @request POST:/v1beta1/organizations/{orgId}/groups/{id}/users + * @secure + */ + frontierServiceAddGroupUsers = ( + orgId: string, + id: string, + body: { + userIds?: string[]; + }, + params: RequestParams = {} + ) => + this.request({ + path: `/v1beta1/organizations/${orgId}/groups/${id}/users`, + method: 'POST', + body: body, + secure: true, + type: ContentType.Json, + format: 'json', + ...params + }); + /** + * @description Removes a principle(user and service-users) from a group. If the user is not in the group, the request will succeed but no changes will be made. + * + * @tags Group + * @name FrontierServiceRemoveGroupUser + * @summary Remove group user + * @request DELETE:/v1beta1/organizations/{orgId}/groups/{id}/users/{userId} + * @secure + */ + frontierServiceRemoveGroupUser = (orgId: string, id: string, userId: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/organizations/${orgId}/groups/${id}/users/${userId}`, + method: 'DELETE', + secure: true, + format: 'json', + ...params + }); + /** + * @description Returns all pending invitations queued for an organization + * + * @tags Organization + * @name FrontierServiceListOrganizationInvitations + * @summary List pending invitations + * @request GET:/v1beta1/organizations/{orgId}/invitations + * @secure + */ + frontierServiceListOrganizationInvitations = ( + orgId: string, + query?: { + /** user_id filter is the email id of user who are invited inside the organization. */ + userId?: string; + }, + params: RequestParams = {} + ) => + this.request({ + path: `/v1beta1/organizations/${orgId}/invitations`, + method: 'GET', + query: query, + secure: true, + format: 'json', + ...params + }); + /** + * @description Invite users to an organization, if the user doesn't exists, it will be created and notified. Invitations expire in 7 days + * + * @tags Organization + * @name FrontierServiceCreateOrganizationInvitation + * @summary Invite user + * @request POST:/v1beta1/organizations/{orgId}/invitations + * @secure + */ + frontierServiceCreateOrganizationInvitation = ( + orgId: string, + body: { + /** user_id is email id of user who are invited inside the organization. If user is not registered on the platform, it will be notified */ + userId: string; + /** list of group ids to which user needs to be added as a member. */ + groupIds?: string[]; + }, + params: RequestParams = {} + ) => + this.request({ + path: `/v1beta1/organizations/${orgId}/invitations`, + method: 'POST', + body: body, + secure: true, + type: ContentType.Json, + format: 'json', + ...params + }); + /** + * @description Returns a pending invitation queued for an organization + * + * @tags Organization + * @name FrontierServiceGetOrganizationInvitation + * @summary Get pending invitation + * @request GET:/v1beta1/organizations/{orgId}/invitations/{id} + * @secure + */ + frontierServiceGetOrganizationInvitation = (orgId: string, id: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/organizations/${orgId}/invitations/${id}`, + method: 'GET', + secure: true, + format: 'json', + ...params + }); + /** + * @description Delete a pending invitation queued for an organization + * + * @tags Organization + * @name FrontierServiceDeleteOrganizationInvitation + * @summary Delete pending invitation + * @request DELETE:/v1beta1/organizations/{orgId}/invitations/{id} + * @secure + */ + frontierServiceDeleteOrganizationInvitation = (orgId: string, id: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/organizations/${orgId}/invitations/${id}`, + method: 'DELETE', + secure: true, + format: 'json', + ...params + }); + /** + * @description Accept pending invitation queued for an organization. The user will be added to the organization and groups defined in the invitation + * + * @tags Organization + * @name FrontierServiceAcceptOrganizationInvitation + * @summary Accept pending invitation + * @request POST:/v1beta1/organizations/{orgId}/invitations/{id}/accept + * @secure + */ + frontierServiceAcceptOrganizationInvitation = (orgId: string, id: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/organizations/${orgId}/invitations/${id}/accept`, + method: 'POST', + secure: true, + format: 'json', + ...params + }); + /** + * @description Returns a list of custom roles created under an organization with their associated permissions + * + * @tags Role + * @name FrontierServiceListOrganizationRoles + * @summary List organization roles + * @request GET:/v1beta1/organizations/{orgId}/roles + * @secure + */ + frontierServiceListOrganizationRoles = ( + orgId: string, + query?: { + state?: string; + }, + params: RequestParams = {} + ) => + this.request({ + path: `/v1beta1/organizations/${orgId}/roles`, + method: 'GET', + query: query, + secure: true, + format: 'json', + ...params + }); + /** + * @description Create a custom role under an organization. This custom role will only be available for assignment to the principles within the organization. + * + * @tags Role + * @name FrontierServiceCreateOrganizationRole + * @summary Create organization role + * @request POST:/v1beta1/organizations/{orgId}/roles + * @secure + */ + frontierServiceCreateOrganizationRole = (orgId: string, body: V1Beta1RoleRequestBody, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/organizations/${orgId}/roles`, + method: 'POST', + body: body, + secure: true, + format: 'json', + ...params + }); + /** + * @description Returns a custom role under an organization along with its associated permissions + * + * @tags Role + * @name FrontierServiceGetOrganizationRole + * @summary Get organization role + * @request GET:/v1beta1/organizations/{orgId}/roles/{id} + * @secure + */ + frontierServiceGetOrganizationRole = (orgId: string, id: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/organizations/${orgId}/roles/${id}`, + method: 'GET', + secure: true, + format: 'json', + ...params + }); + /** + * @description Delete a custom role and all of its relations under an organization permanently. + * + * @tags Role + * @name FrontierServiceDeleteOrganizationRole + * @summary Delete organization role + * @request DELETE:/v1beta1/organizations/{orgId}/roles/{id} + * @secure + */ + frontierServiceDeleteOrganizationRole = (orgId: string, id: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/organizations/${orgId}/roles/${id}`, + method: 'DELETE', + secure: true, + format: 'json', + ...params + }); + /** + * @description Update a custom role under an organization. This custom role will only be available for assignment to the principles within the organization. + * + * @tags Role + * @name FrontierServiceUpdateOrganizationRole + * @summary Update organization role + * @request PUT:/v1beta1/organizations/{orgId}/roles/{id} + * @secure + */ + frontierServiceUpdateOrganizationRole = ( + orgId: string, + id: string, + body: V1Beta1RoleRequestBody, + params: RequestParams = {} + ) => + this.request({ + path: `/v1beta1/organizations/${orgId}/roles/${id}`, + method: 'PUT', + body: body, + secure: true, + format: 'json', + ...params + }); + /** + * No description + * + * @tags Permission + * @name FrontierServiceListPermissions + * @summary Get all permissions + * @request GET:/v1beta1/permissions + * @secure + */ + frontierServiceListPermissions = (params: RequestParams = {}) => + this.request({ + path: `/v1beta1/permissions`, + method: 'GET', + secure: true, + format: 'json', + ...params + }); + /** + * @description Creates a permission. It can be used to grant permissions to all the resources in a Frontier instance. + * + * @tags Permission + * @name AdminServiceCreatePermission + * @summary Create platform permission + * @request POST:/v1beta1/permissions + * @secure + */ + adminServiceCreatePermission = (body: V1Beta1CreatePermissionRequest, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/permissions`, + method: 'POST', + body: body, + secure: true, + type: ContentType.Json, + format: 'json', + ...params + }); + /** + * @description Returns a permission by ID + * + * @tags Permission + * @name FrontierServiceGetPermission + * @summary Get permission + * @request GET:/v1beta1/permissions/{id} + * @secure + */ + frontierServiceGetPermission = (id: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/permissions/${id}`, + method: 'GET', + secure: true, + format: 'json', + ...params + }); + /** + * No description + * + * @tags Permission + * @name AdminServiceDeletePermission + * @summary Delete platform permission + * @request DELETE:/v1beta1/permissions/{id} + * @secure + */ + adminServiceDeletePermission = (id: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/permissions/${id}`, + method: 'DELETE', + secure: true, + format: 'json', + ...params + }); + /** + * @description Updates a permission by ID. It can be used to grant permissions to all the resources in a Frontier instance. + * + * @tags Permission + * @name AdminServiceUpdatePermission + * @summary Update platform permission + * @request PUT:/v1beta1/permissions/{id} + * @secure + */ + adminServiceUpdatePermission = (id: string, body: V1Beta1PermissionRequestBody, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/permissions/${id}`, + method: 'PUT', + body: body, + secure: true, + type: ContentType.Json, + format: 'json', + ...params + }); + /** + * @description Lists all the policies from all the organizations in a Frontier instance. It can be filtered by organization, project, user, role and group. + * + * @tags Policy + * @name AdminServiceListPolicies + * @summary List all policies + * @request GET:/v1beta1/policies + * @secure + */ + adminServiceListPolicies = ( + query?: { + /** The organization id to filter by. */ + orgId?: string; + /** The project id to filter by. */ + projectId?: string; + /** The user id to filter by. */ + userId?: string; + /** The role id to filter by. */ + roleId?: string; + /** The group id to filter by. */ + groupId?: string; + }, + params: RequestParams = {} + ) => + this.request({ + path: `/v1beta1/policies`, + method: 'GET', + query: query, + secure: true, + format: 'json', + ...params + }); + /** + * @description Creates a policy + * + * @tags Policy + * @name FrontierServiceCreatePolicy + * @summary Create policy + * @request POST:/v1beta1/policies + * @secure + */ + frontierServiceCreatePolicy = (body: V1Beta1PolicyRequestBody, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/policies`, + method: 'POST', + body: body, + secure: true, + format: 'json', + ...params + }); + /** + * @description Returns a policy by ID + * + * @tags Policy + * @name FrontierServiceGetPolicy + * @summary Get policy + * @request GET:/v1beta1/policies/{id} + * @secure + */ + frontierServiceGetPolicy = (id: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/policies/${id}`, + method: 'GET', + secure: true, + format: 'json', + ...params + }); + /** + * @description Delete a policy all of its relations permanently. + * + * @tags Policy + * @name FrontierServiceDeletePolicy + * @summary Delete Policy + * @request DELETE:/v1beta1/policies/{id} + * @secure + */ + frontierServiceDeletePolicy = (id: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/policies/${id}`, + method: 'DELETE', + secure: true, + format: 'json', + ...params + }); + /** + * @description Updates a policy by ID + * + * @tags Policy + * @name FrontierServiceUpdatePolicy + * @summary Update policy + * @request PUT:/v1beta1/policies/{id} + * @secure + */ + frontierServiceUpdatePolicy = (id: string, body: V1Beta1PolicyRequestBody, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/policies/${id}`, + method: 'PUT', + body: body, + secure: true, + format: 'json', + ...params + }); + /** + * No description + * + * @tags Project + * @name FrontierServiceCreateProject + * @summary Create project + * @request POST:/v1beta1/projects + * @secure + */ + frontierServiceCreateProject = (body: V1Beta1ProjectRequestBody, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/projects`, + method: 'POST', + body: body, + secure: true, + format: 'json', + ...params + }); + /** + * @description Returns a project by ID + * + * @tags Project + * @name FrontierServiceGetProject + * @summary Get project + * @request GET:/v1beta1/projects/{id} + * @secure + */ + frontierServiceGetProject = (id: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/projects/${id}`, + method: 'GET', + secure: true, + format: 'json', + ...params + }); + /** + * @description Delete a project all of its relations permanently. + * + * @tags Project + * @name FrontierServiceDeleteProject + * @summary Delete Project + * @request DELETE:/v1beta1/projects/{id} + * @secure + */ + frontierServiceDeleteProject = (id: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/projects/${id}`, + method: 'DELETE', + secure: true, + format: 'json', + ...params + }); + /** + * @description Updates a project by ID + * + * @tags Project + * @name FrontierServiceUpdateProject + * @summary Update project + * @request PUT:/v1beta1/projects/{id} + * @secure + */ + frontierServiceUpdateProject = (id: string, body: V1Beta1ProjectRequestBody, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/projects/${id}`, + method: 'PUT', + body: body, + secure: true, + format: 'json', + ...params + }); + /** + * @description Returns a collection of admins of a project + * + * @tags Project + * @name FrontierServiceListProjectAdmins + * @summary List project admins + * @request GET:/v1beta1/projects/{id}/admins + * @secure + */ + frontierServiceListProjectAdmins = (id: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/projects/${id}/admins`, + method: 'GET', + secure: true, + format: 'json', + ...params + }); + /** + * No description + * + * @tags Project + * @name FrontierServiceDisableProject + * @summary Disable project + * @request POST:/v1beta1/projects/{id}/disable + * @secure + */ + frontierServiceDisableProject = (id: string, body: object, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/projects/${id}/disable`, + method: 'POST', + body: body, + secure: true, + format: 'json', + ...params + }); + /** + * No description + * + * @tags Project + * @name FrontierServiceEnableProject + * @summary Enable project + * @request POST:/v1beta1/projects/{id}/enable + * @secure + */ + frontierServiceEnableProject = (id: string, body: object, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/projects/${id}/enable`, + method: 'POST', + body: body, + secure: true, + format: 'json', + ...params + }); + /** + * @description Returns a collection of users of a project. Filter by user permissions is supported. + * + * @tags Project + * @name FrontierServiceListProjectUsers + * @summary List project users + * @request GET:/v1beta1/projects/{id}/users + * @secure + */ + frontierServiceListProjectUsers = ( + id: string, + query?: { + permissionFilter?: string; + }, + params: RequestParams = {} + ) => + this.request({ + path: `/v1beta1/projects/${id}/users`, + method: 'GET', + query: query, + secure: true, + format: 'json', + ...params + }); + /** + * No description + * + * @tags Resource + * @name FrontierServiceListProjectResources + * @summary Get all resources + * @request GET:/v1beta1/projects/{projectId}/resources + * @secure + */ + frontierServiceListProjectResources = ( + projectId: string, + query?: { + namespace?: string; + }, + params: RequestParams = {} + ) => + this.request({ + path: `/v1beta1/projects/${projectId}/resources`, + method: 'GET', + query: query, + secure: true, + format: 'json', + ...params + }); + /** + * @description Creates a resource in a project + * + * @tags Resource + * @name FrontierServiceCreateProjectResource + * @summary Create resource + * @request POST:/v1beta1/projects/{projectId}/resources + * @secure + */ + frontierServiceCreateProjectResource = ( + projectId: string, + body: V1Beta1ResourceRequestBody, + query?: { + /** Autogenerated if skipped. */ + id?: string; + }, + params: RequestParams = {} + ) => + this.request({ + path: `/v1beta1/projects/${projectId}/resources`, + method: 'POST', + query: query, + body: body, + secure: true, + format: 'json', + ...params + }); + /** + * @description Returns a project resource by ID + * + * @tags Resource + * @name FrontierServiceGetProjectResource + * @summary Get resource + * @request GET:/v1beta1/projects/{projectId}/resources/{id} + * @secure + */ + frontierServiceGetProjectResource = (projectId: string, id: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/projects/${projectId}/resources/${id}`, + method: 'GET', + secure: true, + format: 'json', + ...params + }); + /** + * @description Deletes a resource from a project permanently + * + * @tags Resource + * @name FrontierServiceDeleteProjectResource + * @summary Delete resource + * @request DELETE:/v1beta1/projects/{projectId}/resources/{id} + * @secure + */ + frontierServiceDeleteProjectResource = (projectId: string, id: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/projects/${projectId}/resources/${id}`, + method: 'DELETE', + secure: true, + format: 'json', + ...params + }); + /** + * @description Updates a resource in a project + * + * @tags Resource + * @name FrontierServiceUpdateProjectResource + * @summary Update resource + * @request PUT:/v1beta1/projects/{projectId}/resources/{id} + * @secure + */ + frontierServiceUpdateProjectResource = ( + projectId: string, + id: string, + body: V1Beta1ResourceRequestBody, + params: RequestParams = {} + ) => + this.request({ + path: `/v1beta1/projects/${projectId}/resources/${id}`, + method: 'PUT', + body: body, + secure: true, + format: 'json', + ...params + }); + /** + * No description + * + * @tags Relation + * @name FrontierServiceCreateRelation + * @summary Create relation + * @request POST:/v1beta1/relations + * @secure + */ + frontierServiceCreateRelation = (body: V1Beta1RelationRequestBody, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/relations`, + method: 'POST', + body: body, + secure: true, + type: ContentType.Json, + format: 'json', + ...params + }); + /** + * @description Returns a relation by ID + * + * @tags Relation + * @name FrontierServiceGetRelation + * @summary Get relation + * @request GET:/v1beta1/relations/{id} + * @secure + */ + frontierServiceGetRelation = (id: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/relations/${id}`, + method: 'GET', + secure: true, + format: 'json', + ...params + }); + /** + * @description Remove a subject having a relation from an object + * + * @tags Relation + * @name FrontierServiceDeleteRelation + * @summary Delete relation + * @request DELETE:/v1beta1/relations/{relation}/object/{object}/subject/{subject} + * @secure + */ + frontierServiceDeleteRelation = (relation: string, object: string, subject: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/relations/${relation}/object/${object}/subject/${subject}`, + method: 'DELETE', + secure: true, + format: 'json', + ...params + }); + /** + * @description Returns a list of platform wide roles available in enitre Frontier instance along with their associated permissions + * + * @tags Role + * @name FrontierServiceListRoles + * @summary List platform roles + * @request GET:/v1beta1/roles + * @secure + */ + frontierServiceListRoles = ( + query?: { + state?: string; + }, + params: RequestParams = {} + ) => + this.request({ + path: `/v1beta1/roles`, + method: 'GET', + query: query, + secure: true, + format: 'json', + ...params + }); + /** + * @description Creates a platform wide role. It can be used to grant permissions to all the resources in a Frontier instance. + * + * @tags Role + * @name AdminServiceCreateRole + * @summary Create platform role + * @request POST:/v1beta1/roles + * @secure + */ + adminServiceCreateRole = (body: V1Beta1RoleRequestBody, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/roles`, + method: 'POST', + body: body, + secure: true, + format: 'json', + ...params + }); + /** + * @description Delete a platform wide role and all of its relations. + * + * @tags Role + * @name AdminServiceDeleteRole + * @summary Delete platform role + * @request DELETE:/v1beta1/roles/{id} + * @secure + */ + adminServiceDeleteRole = (id: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/roles/${id}`, + method: 'DELETE', + secure: true, + format: 'json', + ...params + }); + /** + * @description Returns the service user of an organization in a Frontier instance. It can be filter by it's state + * + * @tags ServiceUser + * @name FrontierServiceListServiceUsers + * @summary List org service users + * @request GET:/v1beta1/serviceusers + * @secure + */ + frontierServiceListServiceUsers = ( + query: { + /** The organization ID to filter service users by. */ + orgId: string; + /** The state to filter by. It can be enabled or disabled. */ + state?: string; + }, + params: RequestParams = {} + ) => + this.request({ + path: `/v1beta1/serviceusers`, + method: 'GET', + query: query, + secure: true, + format: 'json', + ...params + }); + /** + * @description Create a service user. + * + * @tags ServiceUser + * @name FrontierServiceCreateServiceUser + * @summary Create service user + * @request POST:/v1beta1/serviceusers + * @secure + */ + frontierServiceCreateServiceUser = (body: V1Beta1CreateServiceUserRequest, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/serviceusers`, + method: 'POST', + body: body, + secure: true, + type: ContentType.Json, + format: 'json', + ...params + }); + /** + * @description Get service user details by its id. + * + * @tags ServiceUser + * @name FrontierServiceGetServiceUser + * @summary Get service user + * @request GET:/v1beta1/serviceusers/{id} + * @secure + */ + frontierServiceGetServiceUser = (id: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/serviceusers/${id}`, + method: 'GET', + secure: true, + format: 'json', + ...params + }); + /** + * @description Delete a service user permanently and all of its relations (keys, organizations, roles, etc) + * + * @tags ServiceUser + * @name FrontierServiceDeleteServiceUser + * @summary Delete service user + * @request DELETE:/v1beta1/serviceusers/{id} + * @secure + */ + frontierServiceDeleteServiceUser = ( + id: string, + query?: { + orgId?: string; + }, + params: RequestParams = {} + ) => + this.request({ + path: `/v1beta1/serviceusers/${id}`, + method: 'DELETE', + query: query, + secure: true, + format: 'json', + ...params + }); + /** + * @description List all the keys of a service user with its details except jwk. + * + * @tags ServiceUser + * @name FrontierServiceListServiceUserKeys + * @summary List service user keys + * @request GET:/v1beta1/serviceusers/{id}/keys + * @secure + */ + frontierServiceListServiceUserKeys = (id: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/serviceusers/${id}/keys`, + method: 'GET', + secure: true, + format: 'json', + ...params + }); + /** + * @description Generate a service user key and return it, the private key part of the response will not be persisted and should be kept securely by client. + * + * @tags ServiceUser + * @name FrontierServiceCreateServiceUserKey + * @summary Create service user key + * @request POST:/v1beta1/serviceusers/{id}/keys + * @secure + */ + frontierServiceCreateServiceUserKey = ( + id: string, + body: { + title?: string; + }, + params: RequestParams = {} + ) => + this.request({ + path: `/v1beta1/serviceusers/${id}/keys`, + method: 'POST', + body: body, + secure: true, + format: 'json', + ...params + }); + /** + * @description Get a service user public RSA JWK set. + * + * @tags ServiceUser + * @name FrontierServiceGetServiceUserKey + * @summary Get service user key + * @request GET:/v1beta1/serviceusers/{id}/keys/{keyId} + * @secure + */ + frontierServiceGetServiceUserKey = (id: string, keyId: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/serviceusers/${id}/keys/${keyId}`, + method: 'GET', + secure: true, + format: 'json', + ...params + }); + /** + * @description Delete a service user key permanently. + * + * @tags ServiceUser + * @name FrontierServiceDeleteServiceUserKey + * @summary Delete service user key + * @request DELETE:/v1beta1/serviceusers/{id}/keys/{keyId} + * @secure + */ + frontierServiceDeleteServiceUserKey = (id: string, keyId: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/serviceusers/${id}/keys/${keyId}`, + method: 'DELETE', + secure: true, + format: 'json', + ...params + }); + /** + * @description List all the secrets of a service user. + * + * @tags ServiceUser + * @name FrontierServiceListServiceUserSecrets + * @summary List service user secrets + * @request GET:/v1beta1/serviceusers/{id}/secrets + * @secure + */ + frontierServiceListServiceUserSecrets = (id: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/serviceusers/${id}/secrets`, + method: 'GET', + secure: true, + format: 'json', + ...params + }); + /** + * @description Generate a service user secret and return it. The secret value will not be persisted and should be securely stored by client. + * + * @tags ServiceUser + * @name FrontierServiceCreateServiceUserSecret + * @summary Create service user secret + * @request POST:/v1beta1/serviceusers/{id}/secrets + * @secure + */ + frontierServiceCreateServiceUserSecret = ( + id: string, + body: { + title?: string; + }, + params: RequestParams = {} + ) => + this.request({ + path: `/v1beta1/serviceusers/${id}/secrets`, + method: 'POST', + body: body, + secure: true, + format: 'json', + ...params + }); + /** + * @description Delete a service user secret credential. + * + * @tags ServiceUser + * @name FrontierServiceDeleteServiceUserSecret + * @summary Delete service user secret + * @request DELETE:/v1beta1/serviceusers/{id}/secrets/{secretId} + * @secure + */ + frontierServiceDeleteServiceUserSecret = (id: string, secretId: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/serviceusers/${id}/secrets/${secretId}`, + method: 'DELETE', + secure: true, + format: 'json', + ...params + }); + /** + * @description Returns the users from all the organizations in a Frontier instance. It can be filtered by keyword, organization, group and state. Additionally you can include page number and page size for pagination. + * + * @tags User + * @name FrontierServiceListUsers + * @summary List public users + * @request GET:/v1beta1/users + * @secure + */ + frontierServiceListUsers = ( + query?: { + /** + * The maximum number of users to return per page. The default is 50. + * @format int32 + */ + pageSize?: number; + /** + * The page number to return. The default is 1. + * @format int32 + */ + pageNum?: number; + /** The keyword to search for in name or email. */ + keyword?: string; + /** The organization ID to filter users by. */ + orgId?: string; + /** The group id to filter by. */ + groupId?: string; + /** The state to filter by. It can be enabled or disabled. */ + state?: string; + }, + params: RequestParams = {} + ) => + this.request({ + path: `/v1beta1/users`, + method: 'GET', + query: query, + secure: true, + format: 'json', + ...params + }); + /** + * @description Create a user with the given details. A user is not attached to an organization or a group by default,and can be invited to the org/group. The name of the user must be unique within the entire Frontier instance. If a user name is not provided, Frontier automatically generates a name from the user email. The user metadata is validated against the user metaschema. By default the user metaschema contains `labels` and `descriptions` for the user. The `title` field can be optionally added for a user-friendly name.

*Example:*`{"email":"john.doe@raystack.org","title":"John Doe",metadata:{"label": {"key1": "value1"}, "description": "User Description"}}` + * + * @tags User + * @name FrontierServiceCreateUser + * @summary Create user + * @request POST:/v1beta1/users + */ + frontierServiceCreateUser = (body: V1Beta1UserRequestBody, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/users`, + method: 'POST', + body: body, + format: 'json', + ...params + }); + /** + * @description Get a user by id searched over all organizations in Frontier. + * + * @tags User + * @name FrontierServiceGetUser + * @summary Get user + * @request GET:/v1beta1/users/{id} + * @secure + */ + frontierServiceGetUser = (id: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/users/${id}`, + method: 'GET', + secure: true, + format: 'json', + ...params + }); + /** + * @description Delete an user permanently forever and all of its relations (organizations, groups, etc) + * + * @tags User + * @name FrontierServiceDeleteUser + * @summary Delete user + * @request DELETE:/v1beta1/users/{id} + * @secure + */ + frontierServiceDeleteUser = (id: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/users/${id}`, + method: 'DELETE', + secure: true, + format: 'json', + ...params + }); + /** + * No description + * + * @tags User + * @name FrontierServiceUpdateUser + * @summary Update user + * @request PUT:/v1beta1/users/{id} + * @secure + */ + frontierServiceUpdateUser = (id: string, body: V1Beta1UserRequestBody, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/users/${id}`, + method: 'PUT', + body: body, + secure: true, + format: 'json', + ...params + }); + /** + * @description Sets the state of the user as diabled.The user's membership to groups and organizations will still exist along with all it's roles for access control, but the user will not be able to log in and access the Frontier instance. + * + * @tags User + * @name FrontierServiceDisableUser + * @summary Disable user + * @request POST:/v1beta1/users/{id}/disable + * @secure + */ + frontierServiceDisableUser = (id: string, body: object, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/users/${id}/disable`, + method: 'POST', + body: body, + secure: true, + format: 'json', + ...params + }); + /** + * @description Sets the state of the user as enabled. The user will be able to log in and access the Frontier instance. + * + * @tags User + * @name FrontierServiceEnableUser + * @summary Enable user + * @request POST:/v1beta1/users/{id}/enable + * @secure + */ + frontierServiceEnableUser = (id: string, body: object, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/users/${id}/enable`, + method: 'POST', + body: body, + secure: true, + format: 'json', + ...params + }); + /** + * @description Lists all the groups a user belongs to across all organization in Frontier. To get the groups of a user in a specific organization, use the org_id filter in the query parameter. + * + * @tags User + * @name FrontierServiceListUserGroups + * @summary List user groups + * @request GET:/v1beta1/users/{id}/groups + * @secure + */ + frontierServiceListUserGroups = ( + id: string, + query?: { + /** The organization ID to filter groups by. If not provided, groups from all organizations are returned. */ + orgId?: string; + }, + params: RequestParams = {} + ) => + this.request({ + path: `/v1beta1/users/${id}/groups`, + method: 'GET', + query: query, + secure: true, + format: 'json', + ...params + }); + /** + * @description List all the invitations sent to a user. + * + * @tags User + * @name FrontierServiceListUserInvitations + * @summary List user invitations + * @request GET:/v1beta1/users/{id}/invitations + * @secure + */ + frontierServiceListUserInvitations = (id: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/users/${id}/invitations`, + method: 'GET', + secure: true, + format: 'json', + ...params + }); + /** + * @description Get all the organizations a user belongs to. + * + * @tags User + * @name FrontierServiceGetOrganizationsByUser + * @summary Get user organizations + * @request GET:/v1beta1/users/{id}/organizations + * @secure + */ + frontierServiceGetOrganizationsByUser = (id: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/users/${id}/organizations`, + method: 'GET', + secure: true, + format: 'json', + ...params + }); + /** + * @description Get all the projects a user belongs to. + * + * @tags User + * @name FrontierServiceGetProjectsByUser + * @summary Get user projects + * @request GET:/v1beta1/users/{id}/projects + * @secure + */ + frontierServiceGetProjectsByUser = (id: string, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/users/${id}/projects`, + method: 'GET', + secure: true, + format: 'json', + ...params + }); + /** + * No description + * + * @tags User + * @name FrontierServiceGetCurrentUser + * @summary Get current user + * @request GET:/v1beta1/users/self + * @secure + */ + frontierServiceGetCurrentUser = (params: RequestParams = {}) => + this.request({ + path: `/v1beta1/users/self`, + method: 'GET', + secure: true, + format: 'json', + ...params + }); + /** + * No description + * + * @tags User + * @name FrontierServiceUpdateCurrentUser + * @summary Update current user + * @request PUT:/v1beta1/users/self + * @secure + */ + frontierServiceUpdateCurrentUser = (body: V1Beta1UserRequestBody, params: RequestParams = {}) => + this.request({ + path: `/v1beta1/users/self`, + method: 'PUT', + body: body, + secure: true, + format: 'json', + ...params + }); + /** + * No description + * + * @tags User + * @name FrontierServiceListCurrentUserGroups + * @summary List my groups + * @request GET:/v1beta1/users/self/groups + * @secure + */ + frontierServiceListCurrentUserGroups = (params: RequestParams = {}) => + this.request({ + path: `/v1beta1/users/self/groups`, + method: 'GET', + secure: true, + format: 'json', + ...params + }); + /** + * @description Get all organizations the current user belongs to + * + * @tags User + * @name FrontierServiceGetOrganizationsByCurrentUser + * @summary Get my organizations + * @request GET:/v1beta1/users/self/organizations + * @secure + */ + frontierServiceGetOrganizationsByCurrentUser = (params: RequestParams = {}) => + this.request({ + path: `/v1beta1/users/self/organizations`, + method: 'GET', + secure: true, + format: 'json', + ...params + }); + /** + * @description Get all projects the current user belongs to + * + * @tags User + * @name FrontierServiceGetProjectsByCurrentUser + * @summary Get my projects + * @request GET:/v1beta1/users/self/projects + * @secure + */ + frontierServiceGetProjectsByCurrentUser = (params: RequestParams = {}) => + this.request({ + path: `/v1beta1/users/self/projects`, + method: 'GET', + secure: true, + format: 'json', + ...params + }); +} diff --git a/sdks/js/packages/core/client/WellKnown.ts b/sdks/js/packages/core/client/WellKnown.ts new file mode 100644 index 000000000..2569626b5 --- /dev/null +++ b/sdks/js/packages/core/client/WellKnown.ts @@ -0,0 +1,33 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +import { RpcStatus, V1Beta1GetJWKsResponse } from './data-contracts'; +import { HttpClient, RequestParams } from './http-client'; + +export class WellKnown extends HttpClient { + /** + * No description + * + * @tags Authz + * @name FrontierServiceGetJwKs2 + * @summary Get well known JWKs + * @request GET:/.well-known/jwks.json + * @secure + */ + frontierServiceGetJwKs2 = (params: RequestParams = {}) => + this.request({ + path: `/.well-known/jwks.json`, + method: 'GET', + secure: true, + format: 'json', + ...params + }); +} diff --git a/sdks/js/packages/core/client/data-contracts.ts b/sdks/js/packages/core/client/data-contracts.ts new file mode 100644 index 000000000..6c5dcb75e --- /dev/null +++ b/sdks/js/packages/core/client/data-contracts.ts @@ -0,0 +1,1006 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +export interface ProtobufAny { + '@type'?: string; + [key: string]: any; +} + +/** + * `NullValue` is a singleton enumeration to represent the null value for the + * `Value` type union. + * + * The JSON representation for `NullValue` is JSON `null`. + * + * - NULL_VALUE: Null value. + * @default "NULL_VALUE" + */ +export enum ProtobufNullValue { + NULL_VALUE = 'NULL_VALUE' +} + +export interface RpcStatus { + /** @format int32 */ + code?: number; + message?: string; + details?: ProtobufAny[]; +} + +export type V1Beta1AcceptOrganizationInvitationResponse = object; + +export type V1Beta1AddGroupUsersResponse = object; + +export type V1Beta1AddOrganizationUsersResponse = object; + +export interface V1Beta1AuditLog { + /** A unique identifier of the audit log if not supplied will be autogenerated */ + id?: string; + /** + * Source service generating the event + * The source service generating the event. + * @example "auth" + */ + source: string; + /** Action performed, e.g. project.create, user.update, serviceuser.delete */ + action: string; + /** Actor performing the action */ + actor?: V1Beta1AuditLogActor; + /** Target of the action */ + target?: V1Beta1AuditLogTarget; + /** Context contains additional information about the event */ + context?: Record; + /** + * The time the log was created. + * @format date-time + * @example "2023-06-07T05:39:56.961Z" + */ + createdAt?: string; +} + +export interface V1Beta1AuditLogActor { + id?: string; + type?: string; + name?: string; +} + +export interface V1Beta1AuditLogTarget { + id?: string; + type?: string; + name?: string; +} + +export interface V1Beta1AuthCallbackRequest { + /** strategy_name will not be set for oidc but can be utilized for methods like email magic links */ + strategyName?: string; + /** for oidc & magic links */ + state?: string; + code?: string; +} + +export type V1Beta1AuthCallbackResponse = object; + +export type V1Beta1AuthLogoutResponse = object; + +export interface V1Beta1AuthStrategy { + name?: string; + params?: object; +} + +export interface V1Beta1AuthTokenRequest { + /** + * grant_type can be one of the following: + * - client_credentials + * - urn:ietf:params:oauth:grant-type:jwt-bearer + */ + grantType?: string; + /** client_id and client_secret are required for grant_type client_credentials */ + clientId?: string; + clientSecret?: string; + /** assertion is required for grant_type urn:ietf:params:oauth:grant-type:jwt-bearer */ + assertion?: string; +} + +export interface V1Beta1AuthTokenResponse { + accessToken?: string; + tokenType?: string; +} + +export interface V1Beta1AuthenticateResponse { + endpoint?: string; + state?: string; +} + +export interface V1Beta1CheckResourcePermissionRequest { + /** Deprecated. Use `resource` field instead. */ + objectId?: string; + /** Deprecated. Use `resource` field instead. */ + objectNamespace?: string; + /** the permission name to check.
*Example:* `get` or `list` */ + permission: string; + /** `namespace:uuid` or `namespace:name` of the org or project, and `namespace:urn` of a resource under a project. In case of an org/project either provide the complete namespace (app/organization) or Frontier can also parse aliases for the same as `org` or `project`.
*Example:* `organization:92f69c3a-334b-4f25-90b8-4d4f3be6b825` or `app/project:project-name` or `compute/instance:92f69c3a-334b-4f25-90b8-4d4f3be6b825` */ + resource?: string; +} + +export interface V1Beta1CheckResourcePermissionResponse { + status?: boolean; +} + +export interface V1Beta1CreateGroupResponse { + group?: V1Beta1Group; +} + +export interface V1Beta1CreateMetaSchemaResponse { + metaschema?: V1Beta1MetaSchema; +} + +export type V1Beta1CreateOrganizationAuditLogsResponse = object; + +export interface V1Beta1CreateOrganizationInvitationResponse { + invitation?: V1Beta1Invitation; +} + +export interface V1Beta1CreateOrganizationResponse { + organization?: V1Beta1Organization; +} + +export interface V1Beta1CreateOrganizationRoleResponse { + role?: V1Beta1Role; +} + +export interface V1Beta1CreatePermissionRequest { + bodies?: V1Beta1PermissionRequestBody[]; +} + +export interface V1Beta1CreatePermissionResponse { + permissions?: V1Beta1Permission[]; +} + +export interface V1Beta1CreatePolicyResponse { + policy?: V1Beta1Policy; +} + +export interface V1Beta1CreateProjectResourceResponse { + resource?: V1Beta1Resource; +} + +export interface V1Beta1CreateProjectResponse { + project?: V1Beta1Project; +} + +export interface V1Beta1CreateRelationResponse { + relation?: V1Beta1Relation; +} + +export interface V1Beta1CreateRoleResponse { + role?: V1Beta1Role; +} + +export interface V1Beta1CreateServiceUserKeyResponse { + key?: V1Beta1KeyCredential; +} + +export interface V1Beta1CreateServiceUserRequest { + body?: V1Beta1ServiceUserRequestBody; + /** The organization ID to which the service user belongs to. */ + orgId: string; +} + +export interface V1Beta1CreateServiceUserResponse { + serviceuser?: V1Beta1ServiceUser; +} + +export interface V1Beta1CreateServiceUserSecretResponse { + secret?: V1Beta1SecretCredential; +} + +export interface V1Beta1CreateUserResponse { + user?: V1Beta1User; +} + +export type V1Beta1DeleteGroupResponse = object; + +export type V1Beta1DeleteMetaSchemaResponse = object; + +export type V1Beta1DeleteOrganizationInvitationResponse = object; + +export type V1Beta1DeleteOrganizationResponse = object; + +export type V1Beta1DeleteOrganizationRoleResponse = object; + +export type V1Beta1DeletePermissionResponse = object; + +export type V1Beta1DeletePolicyResponse = object; + +export type V1Beta1DeleteProjectResourceResponse = object; + +export type V1Beta1DeleteProjectResponse = object; + +export type V1Beta1DeleteRelationResponse = object; + +export type V1Beta1DeleteRoleResponse = object; + +export type V1Beta1DeleteServiceUserKeyResponse = object; + +export type V1Beta1DeleteServiceUserResponse = object; + +export type V1Beta1DeleteServiceUserSecretResponse = object; + +export type V1Beta1DeleteUserResponse = object; + +export type V1Beta1DisableGroupResponse = object; + +export type V1Beta1DisableOrganizationResponse = object; + +export type V1Beta1DisableProjectResponse = object; + +export type V1Beta1DisableUserResponse = object; + +export type V1Beta1EnableGroupResponse = object; + +export type V1Beta1EnableOrganizationResponse = object; + +export type V1Beta1EnableProjectResponse = object; + +export type V1Beta1EnableUserResponse = object; + +export interface V1Beta1GetCurrentUserResponse { + user?: V1Beta1User; + serviceuser?: V1Beta1ServiceUser; +} + +export interface V1Beta1GetGroupResponse { + group?: V1Beta1Group; +} + +/** GetJWKsResponse is a valid JSON Web Key Set as specififed in rfc 7517 */ +export interface V1Beta1GetJWKsResponse { + keys?: V1Beta1JSONWebKey[]; +} + +export interface V1Beta1GetMetaSchemaResponse { + metaschema?: V1Beta1MetaSchema; +} + +export interface V1Beta1GetNamespaceResponse { + namespace?: V1Beta1Namespace; +} + +export interface V1Beta1GetOrganizationAuditLogResponse { + log?: V1Beta1AuditLog; +} + +export interface V1Beta1GetOrganizationInvitationResponse { + invitation?: V1Beta1Invitation; +} + +export interface V1Beta1GetOrganizationResponse { + organization?: V1Beta1Organization; +} + +export interface V1Beta1GetOrganizationRoleResponse { + role?: V1Beta1Role; +} + +export interface V1Beta1GetOrganizationsByCurrentUserResponse { + organizations?: V1Beta1Organization[]; +} + +export interface V1Beta1GetOrganizationsByUserResponse { + organizations?: V1Beta1Organization[]; +} + +export interface V1Beta1GetPermissionResponse { + permission?: V1Beta1Permission; +} + +export interface V1Beta1GetPolicyResponse { + policy?: V1Beta1Policy; +} + +export interface V1Beta1GetProjectResourceResponse { + resource?: V1Beta1Resource; +} + +export interface V1Beta1GetProjectResponse { + project?: V1Beta1Project; +} + +export interface V1Beta1GetProjectsByCurrentUserResponse { + projects?: V1Beta1Project[]; +} + +export interface V1Beta1GetProjectsByUserResponse { + projects?: V1Beta1Project[]; +} + +export interface V1Beta1GetRelationResponse { + relation?: V1Beta1Relation; +} + +export interface V1Beta1GetServiceUserKeyResponse { + keys?: V1Beta1JSONWebKey[]; +} + +export interface V1Beta1GetServiceUserResponse { + serviceuser?: V1Beta1ServiceUser; +} + +export interface V1Beta1GetUserResponse { + user?: V1Beta1User; +} + +export interface V1Beta1Group { + id?: string; + name?: string; + title?: string; + orgId?: string; + metadata?: object; + /** + * The time the group was created. + * @format date-time + * @example "2023-06-07T05:39:56.961Z" + */ + createdAt?: string; + /** + * The time the group was last updated. + * @format date-time + * @example "2023-06-07T05:39:56.961Z" + */ + updatedAt?: string; +} + +export interface V1Beta1GroupRequestBody { + /** The name of the group. The name must be unique within the entire Frontier instance. The name can contain only alphanumeric characters, dashes and underscores. */ + name: string; + /** The title can contain any UTF-8 character, used to provide a human-readable name for the group. Can also be left empty. */ + title?: string; + /** Metadata object for groups that can hold key value pairs defined in Group Metaschema. The metadata object can be used to store arbitrary information about the group such as labels, descriptions etc. The default Group Metaschema contains labels and descripton fields. Update the Group Metaschema to add more fields.
*Example:*`{"labels": {"key": "value"}, "description": "Group description"}` */ + metadata?: object; +} + +export interface V1Beta1Invitation { + /** + * The unique invitation identifier. + * @example "k9c4f4e2-9b9a-4c1a-8f1a-2b9b9b9b9b9b" + */ + id?: string; + /** + * The user email of the invited user. + * @example "john.doe@raystack.org" + */ + userId?: string; + /** + * The organization id to which the user is invited. + * @example "b9c4f4e2-9b9a-4c1a-8f1a-2b9b9b9b9b9b" + */ + orgId?: string; + /** + * The list of group ids to which the user is invited. + * @example "c9c4f4e2-9b9a-4c1a-8f1a-2b9b9b9b9b9b" + */ + groupIds?: string[]; + /** + * The metadata of the invitation. + * @example {"key":"value"} + */ + metadata?: object; + /** + * The time when the invitation was created. + * @format date-time + * @example "2023-06-07T05:39:56.961Z" + */ + createdAt?: string; + /** + * The time when the invitation expires. + * @format date-time + * @example "2023-06-07T05:39:56.961Z" + */ + expiresAt?: string; +} + +/** JSON Web Key as specified in RFC 7517 */ +export interface V1Beta1JSONWebKey { + /** Key Type. */ + kty?: string; + /** Algorithm. */ + alg?: string; + /** Permitted uses for the public keys. */ + use?: string; + /** Key ID. */ + kid?: string; + /** Used for RSA keys. */ + n?: string; + /** Used for RSA keys. */ + e?: string; + /** Used for ECDSA keys. */ + x?: string; + /** Used for ECDSA keys. */ + y?: string; + /** Used for ECDSA keys. */ + crv?: string; +} + +export interface V1Beta1KeyCredential { + type?: string; + kid?: string; + principalId?: string; + /** RSA private key as string */ + privateKey?: string; +} + +export interface V1Beta1ListAllOrganizationsResponse { + organizations?: V1Beta1Organization[]; +} + +export interface V1Beta1ListAllUsersResponse { + /** @format int32 */ + count?: number; + users?: V1Beta1User[]; +} + +export interface V1Beta1ListAuthStrategiesResponse { + strategies?: V1Beta1AuthStrategy[]; +} + +export interface V1Beta1ListCurrentUserGroupsResponse { + groups?: V1Beta1Group[]; +} + +export interface V1Beta1ListGroupUsersResponse { + users?: V1Beta1User[]; +} + +export interface V1Beta1ListGroupsResponse { + groups?: V1Beta1Group[]; +} + +export interface V1Beta1ListMetaSchemasResponse { + metaschemas?: V1Beta1MetaSchema[]; +} + +export interface V1Beta1ListNamespacesResponse { + namespaces?: V1Beta1Namespace[]; +} + +export interface V1Beta1ListOrganizationAdminsResponse { + users?: V1Beta1User[]; +} + +export interface V1Beta1ListOrganizationAuditLogsResponse { + logs?: V1Beta1AuditLog[]; +} + +export interface V1Beta1ListOrganizationGroupsResponse { + groups?: V1Beta1Group[]; +} + +export interface V1Beta1ListOrganizationInvitationsResponse { + invitations?: V1Beta1Invitation[]; +} + +export interface V1Beta1ListOrganizationProjectsResponse { + projects?: V1Beta1Project[]; +} + +export interface V1Beta1ListOrganizationRolesResponse { + roles?: V1Beta1Role[]; +} + +export interface V1Beta1ListOrganizationServiceUsersResponse { + serviceusers?: V1Beta1ServiceUser[]; +} + +export interface V1Beta1ListOrganizationUsersResponse { + users?: V1Beta1User[]; +} + +export interface V1Beta1ListOrganizationsResponse { + organizations?: V1Beta1Organization[]; +} + +export interface V1Beta1ListPermissionsResponse { + permissions?: V1Beta1Permission[]; +} + +export interface V1Beta1ListPoliciesResponse { + policies?: V1Beta1Policy[]; +} + +export interface V1Beta1ListProjectAdminsResponse { + users?: V1Beta1User[]; +} + +export interface V1Beta1ListProjectResourcesResponse { + resources?: V1Beta1Resource[]; +} + +export interface V1Beta1ListProjectUsersResponse { + users?: V1Beta1User[]; +} + +export interface V1Beta1ListProjectsResponse { + projects?: V1Beta1Project[]; +} + +export interface V1Beta1ListRelationsResponse { + relations?: V1Beta1Relation[]; +} + +export interface V1Beta1ListResourcesResponse { + resources?: V1Beta1Resource[]; +} + +export interface V1Beta1ListRolesResponse { + roles?: V1Beta1Role[]; +} + +export interface V1Beta1ListServiceUserKeysResponse { + keys?: V1Beta1ServiceUserKey[]; +} + +export interface V1Beta1ListServiceUserSecretsResponse { + /** secrets will be listed without the secret value */ + secrets?: V1Beta1SecretCredential[]; +} + +export interface V1Beta1ListServiceUsersResponse { + serviceusers?: V1Beta1ServiceUser[]; +} + +export interface V1Beta1ListUserGroupsResponse { + groups?: V1Beta1Group[]; +} + +export interface V1Beta1ListUserInvitationsResponse { + invitations?: V1Beta1Invitation[]; +} + +export interface V1Beta1ListUsersResponse { + /** @format int32 */ + count?: number; + users?: V1Beta1User[]; +} + +export interface V1Beta1MetaSchema { + /** + * The unique metaschema uuid. + * @example "a9c4f4e2-9b9a-4c1a-8f1a-2b9b9b9b9b9b" + */ + id?: string; + name?: string; + /** + * The metaschema json schema. + * @example {"type":"object"} + */ + schema?: string; + /** + * The time when the metaschema was created. + * @format date-time + * @example "2023-06-07T05:39:56.961Z" + */ + createdAt?: string; + /** + * The time when the metaschema was updated. + * @format date-time + * @example "2023-06-07T05:39:56.961Z" + */ + updatedAt?: string; +} + +export interface V1Beta1MetaSchemaRequestBody { + /** The name of the metaschema. The name must be unique within the entire Frontier instance. The name can contain only alphanumeric characters, dashes and underscores. */ + name: string; + /** The schema of the metaschema. The schema must be a valid JSON schema.Please refer to https://json-schema.org/ to know more about json schema. */ + schema: string; +} + +export interface V1Beta1Namespace { + id?: string; + /** name could be in a format like: app/organization */ + name?: string; + metadata?: object; + /** + * The time the namespace was created. + * @format date-time + * @example "2023-06-07T05:39:56.961Z" + */ + createdAt?: string; + /** + * The time the namespace was last updated. + * @format date-time + * @example "2023-06-07T05:39:56.961Z" + */ + updatedAt?: string; +} + +export interface V1Beta1Organization { + id?: string; + name?: string; + title?: string; + metadata?: object; + /** + * The time the organization was created. + * @format date-time + * @example "2023-06-07T05:39:56.961Z" + */ + createdAt?: string; + /** + * The time the organization was last updated. + * @format date-time + * @example "2023-06-07T05:39:56.961Z" + */ + updatedAt?: string; +} + +export interface V1Beta1OrganizationRequestBody { + /** The name of the organization. The name must be unique within the entire Frontier instance. The name can contain only alphanumeric characters, dashes and underscores.
*Example:*`"frontier-org1-acme"` */ + name: string; + /** The title can contain any UTF-8 character, used to provide a human-readable name for the organization. Can also be left empty.
*Example*: `"Acme Inc"` */ + title?: string; + /** Metadata object for organizations that can hold key value pairs defined in Organization Metaschema. The metadata object can be used to store arbitrary information about the organization such as labels, descriptions etc. The default Organization Metaschema contains labels and descripton fields. Update the Organization Metaschema to add more fields.
*Example*:`{"labels": {"key": "value"}, "description": "Organization description"}` */ + metadata?: object; +} + +export interface V1Beta1Permission { + id?: string; + name?: string; + title?: string; + /** + * The time the permission was created. + * @format date-time + * @example "2023-06-07T05:39:56.961Z" + */ + createdAt?: string; + /** + * The time the permission was last updated. + * @format date-time + * @example "2023-06-07T05:39:56.961Z" + */ + updatedAt?: string; + namespace?: string; + metadata?: object; + /** + * Permission path key is composed of three parts, 'service.resource.verb'. Where 'service.resource' works as a namespace for the 'verb'. + * @example "compute.instance.get" + */ + key?: string; +} + +export interface V1Beta1PermissionRequestBody { + /** The name of the permission. It should be unique across a Frontier instance and can contain only alphanumeric characters. */ + name?: string; + /** + * namespace should be in service/resource format + * The namespace of the permission.The namespace should be in service/resource format.
*Example:*`app/guardian` + */ + namespace?: string; + /** The metadata object for permissions that can hold key value pairs. */ + metadata?: object; + /** The title can contain any UTF-8 character, used to provide a human-readable name for the permissions. Can also be left empty. */ + title?: string; + /** + * Permission path key is composed of three parts, 'service.resource.verb'. Where 'service.resource' works as a namespace for the 'verb'. + * @example "compute.instance.get" + */ + key?: string; +} + +export interface V1Beta1Policy { + id?: string; + title?: string; + /** + * The time the policy was created. + * @format date-time + * @example "2023-06-07T05:39:56.961Z" + */ + createdAt?: string; + /** + * The time the policy was last updated. + * @format date-time + * @example "2023-06-07T05:39:56.961Z" + */ + updatedAt?: string; + roleId?: string; + /** namespace:uuid */ + resource?: string; + /** namespace:uuid */ + principal?: string; + metadata?: object; +} + +export interface V1Beta1PolicyRequestBody { + /** unique id of the role to which policy is assigned */ + roleId: string; + /** The title can contain any UTF-8 character, used to provide a human-readable name for the policy. Can also be left empty.
*Example:* `Policy title` */ + title?: string; + /** The resource to which policy is assigned in this format `namespace:uuid`.
*Example:* `app/guardian:70f69c3a-334b-4f25-90b8-4d4f3be6b8e2` */ + resource: string; + /** principal is the user or group to which policy is assigned. The principal id must be prefixed with its namespace id in this format `namespace:uuid`. The namespace can be `app/user`, `app/group` or `app/serviceuser` (coming up!) and uuid is the unique id of the principal.
*Example:* `app/user:92f69c3a-334b-4f25-90b8-4d4f3be6b825` */ + principal: string; + /** Metadata object for policies that can hold key value pairs defined in Policy Metaschema.
*Example:* `{"labels": {"key": "value"}, "description": "Policy description"}` */ + metadata?: object; +} + +export interface V1Beta1Project { + id?: string; + name?: string; + title?: string; + orgId?: string; + metadata?: object; + /** + * The time the project was created. + * @format date-time + * @example "2023-06-07T05:39:56.961Z" + */ + createdAt?: string; + /** + * The time the project was last updated. + * @format date-time + * @example "2023-06-07T05:39:56.961Z" + */ + updatedAt?: string; +} + +export interface V1Beta1ProjectRequestBody { + /** The name of the project. The name must be unique within the entire Frontier instance. The name can contain only alphanumeric characters, dashes and underscores.
*Example:* `frontier-playground` */ + name: string; + /** The title can contain any UTF-8 character, used to provide a human-readable name for the project. Can also be left empty.
*Example:* `Frontier Playground` */ + title?: string; + /** Metadata object for projects that can hold key value pairs defined in Project Metaschema. */ + metadata?: object; + /** unique id of the organization to which project belongs */ + orgId: string; +} + +export interface V1Beta1Relation { + id?: string; + /** + * The time the relation was created. + * @format date-time + * @example "2023-06-07T05:39:56.961Z" + */ + createdAt?: string; + /** + * The time the relation was last updated. + * @format date-time + * @example "2023-06-07T05:39:56.961Z" + */ + updatedAt?: string; + subjectSubRelation?: string; + relation?: string; + /** objectnamespace:id */ + object?: string; + /** subjectnamespace:id */ + subject?: string; +} + +export interface V1Beta1RelationRequestBody { + /** objectnamespace:uuid */ + object?: string; + /** subjectnamespace:uuid */ + subject?: string; + relation?: string; + subjectSubRelation?: string; +} + +export type V1Beta1RemoveGroupUserResponse = object; + +export type V1Beta1RemoveOrganizationUserResponse = object; + +export interface V1Beta1Resource { + id?: string; + /** Name of the resource. Must be unique within the project. */ + name?: string; + /** + * The time the resource was created. + * @format date-time + * @example "2023-06-07T05:39:56.961Z" + */ + createdAt?: string; + /** + * The time the resource was last updated. + * @format date-time + * @example "2023-06-07T05:39:56.961Z" + */ + updatedAt?: string; + urn?: string; + projectId?: string; + namespace?: string; + principal?: string; + metadata?: object; +} + +export interface V1Beta1ResourceRequestBody { + /** The name of the resource. Must be unique within the project.
*Example:* `my-resource` */ + name: string; + /** The title can contain any UTF-8 character, used to provide a human-readable name for the resource. Can also be left empty. */ + title?: string; + /** The namespace of the resource. The resource namespace are created when permissions for that resource is created in Frontier. If namespace doesn't exists the request will fail.
*Example:* `compute/instance` */ + namespace: string; + /** + * format namespace:uuid or just uuid for user + * UserID or ServiceUserID that should be marked as owner of the resource. If not provided, the current logged in user will be made the resource owner.
*Example:* `user:92f69c3a-334b-4f25-90b8-4d4f3be6b825` + */ + principal?: string; + metadata?: object; +} + +export interface V1Beta1Role { + id?: string; + name?: string; + permissions?: string[]; + title?: string; + metadata?: object; + /** + * The time the role was created. + * @format date-time + * @example "2023-06-07T05:39:56.961Z" + */ + createdAt?: string; + /** + * The time the role was last updated. + * @format date-time + * @example "2023-06-07T05:39:56.961Z" + */ + updatedAt?: string; + orgId?: string; + state?: string; +} + +export interface V1Beta1RoleRequestBody { + name?: string; + permissions?: string[]; + metadata?: object; + title?: string; +} + +export interface V1Beta1SecretCredential { + id?: string; + title?: string; + /** + * secret will only be returned once as part of the create process + * this value is never persisted in the system so if lost, can't be recovered + */ + secret?: string; + /** + * The time when the secret was created. + * @format date-time + * @example "2023-06-07T05:39:56.961Z" + */ + createdAt?: string; +} + +export interface V1Beta1ServiceUser { + id?: string; + /** + * User friendly name of the service user. + * @example "Order Service" + */ + title?: string; + metadata?: object; + /** + * The time the user was created. + * @format date-time + * @example "2023-06-07T05:39:56.961Z" + */ + createdAt?: string; + /** + * The time the user was last updated. + * @format date-time + * @example "2023-06-07T05:39:56.961Z" + */ + updatedAt?: string; + state?: string; + orgId?: string; +} + +export interface V1Beta1ServiceUserKey { + id?: string; + title?: string; + principalId?: string; + publicKey?: string; + /** + * The time when the secret was created. + * @format date-time + * @example "2023-06-07T05:39:56.961Z" + */ + createdAt?: string; +} + +export interface V1Beta1ServiceUserRequestBody { + /** + * User friendly name of the service user. + * @example "Order Service" + */ + title?: string; + metadata?: object; +} + +export interface V1Beta1UpdateCurrentUserResponse { + user?: V1Beta1User; +} + +export interface V1Beta1UpdateGroupResponse { + group?: V1Beta1Group; +} + +export interface V1Beta1UpdateMetaSchemaResponse { + metaschema?: V1Beta1MetaSchema; +} + +export interface V1Beta1UpdateOrganizationResponse { + organization?: V1Beta1Organization; +} + +export interface V1Beta1UpdateOrganizationRoleResponse { + role?: V1Beta1Role; +} + +export interface V1Beta1UpdatePermissionResponse { + permission?: V1Beta1Permission; +} + +export interface V1Beta1UpdatePolicyResponse { + policies?: V1Beta1Policy[]; +} + +export interface V1Beta1UpdateProjectResourceResponse { + resource?: V1Beta1Resource; +} + +export interface V1Beta1UpdateProjectResponse { + project?: V1Beta1Project; +} + +export interface V1Beta1UpdateUserResponse { + user?: V1Beta1User; +} + +export interface V1Beta1User { + id?: string; + /** + * can either be empty or must start with a character + * Unique name of the user. + * @example "johndoe" + */ + name?: string; + /** + * Name of the user. + * @example "John Doe" + */ + title?: string; + email?: string; + metadata?: object; + /** + * The time the user was created. + * @format date-time + * @example "2023-06-07T05:39:56.961Z" + */ + createdAt?: string; + /** + * The time the user was last updated. + * @format date-time + * @example "2023-06-07T05:39:56.961Z" + */ + updatedAt?: string; + state?: string; +} + +export interface V1Beta1UserRequestBody { + /** The name of the user. The name must be unique within the entire Frontier instance. The name can contain only alphanumeric characters, dashes and underscores and must start with a letter. If not provided, Frontier automatically generates a name from the user email. */ + name?: string; + /** The email of the user. The email must be unique within the entire Frontier instance.
*Example:*`"john.doe@raystack.org"` */ + email: string; + /** Metadata object for users that can hold key value pairs pre-defined in User Metaschema. The metadata object can be used to store arbitrary information about the user such as label, description etc. By default the user metaschema contains labels and descriptions for the user. Update the same to add more fields to the user metadata object.
*Example:*`{"label": {"key1": "value1"}, "description": "User Description"}` */ + metadata?: object; + /** The title can contain any UTF-8 character, used to provide a human-readable name for the user. Can also be left empty.
*Example:*`"John Doe"` */ + title?: string; +} diff --git a/sdks/js/packages/core/client/http-client.ts b/sdks/js/packages/core/client/http-client.ts new file mode 100644 index 000000000..1f8c26574 --- /dev/null +++ b/sdks/js/packages/core/client/http-client.ts @@ -0,0 +1,220 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: ResponseFormat; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType | null) => Promise | RequestParams | void; + customFetch?: typeof fetch; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +type CancelToken = Symbol | string | number; + +export enum ContentType { + Json = 'application/json', + FormData = 'multipart/form-data', + UrlEncoded = 'application/x-www-form-urlencoded', + Text = 'text/plain' +} + +export class HttpClient { + public baseUrl: string = 'http://127.0.0.1:7400'; + private securityData: SecurityDataType | null = null; + private securityWorker?: ApiConfig['securityWorker']; + private abortControllers = new Map(); + private customFetch = (...fetchParams: Parameters) => fetch(...fetchParams); + + private baseApiParams: RequestParams = { + credentials: 'same-origin', + headers: {}, + redirect: 'follow', + referrerPolicy: 'no-referrer' + }; + + constructor(apiConfig: ApiConfig = {}) { + Object.assign(this, apiConfig); + } + + public setSecurityData = (data: SecurityDataType | null) => { + this.securityData = data; + }; + + protected encodeQueryParam(key: string, value: any) { + const encodedKey = encodeURIComponent(key); + return `${encodedKey}=${encodeURIComponent(typeof value === 'number' ? value : `${value}`)}`; + } + + protected addQueryParam(query: QueryParamsType, key: string) { + return this.encodeQueryParam(key, query[key]); + } + + protected addArrayQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + return value.map((v: any) => this.encodeQueryParam(key, v)).join('&'); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter(key => 'undefined' !== typeof query[key]); + return keys + .map(key => (Array.isArray(query[key]) ? this.addArrayQueryParam(query, key) : this.addQueryParam(query, key))) + .join('&'); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ''; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === 'object' || typeof input === 'string') ? JSON.stringify(input) : input, + [ContentType.Text]: (input: any) => (input !== null && typeof input !== 'string' ? JSON.stringify(input) : input), + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((formData, key) => { + const property = input[key]; + formData.append( + key, + property instanceof Blob + ? property + : typeof property === 'object' && property !== null + ? JSON.stringify(property) + : `${property}` + ); + return formData; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input) + }; + + protected mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams { + return { + ...this.baseApiParams, + ...params1, + ...(params2 || {}), + headers: { + ...(this.baseApiParams.headers || {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}) + } + }; + } + + protected createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => { + if (this.abortControllers.has(cancelToken)) { + const abortController = this.abortControllers.get(cancelToken); + if (abortController) { + return abortController.signal; + } + return void 0; + } + + const abortController = new AbortController(); + this.abortControllers.set(cancelToken, abortController); + return abortController.signal; + }; + + public abortRequest = (cancelToken: CancelToken) => { + const abortController = this.abortControllers.get(cancelToken); + + if (abortController) { + abortController.abort(); + this.abortControllers.delete(cancelToken); + } + }; + + public request = async ({ + body, + secure, + path, + type, + query, + format, + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = + ((typeof secure === 'boolean' ? secure : this.baseApiParams.secure) && + this.securityWorker && + (await this.securityWorker(this.securityData))) || + {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + const responseFormat = format || requestParams.format; + + return this.customFetch(`${baseUrl || this.baseUrl || ''}${path}${queryString ? `?${queryString}` : ''}`, { + ...requestParams, + headers: { + ...(requestParams.headers || {}), + ...(type && type !== ContentType.FormData ? { 'Content-Type': type } : {}) + }, + signal: (cancelToken ? this.createAbortSignal(cancelToken) : requestParams.signal) || null, + body: typeof body === 'undefined' || body === null ? null : payloadFormatter(body) + }).then(async response => { + const r = response as HttpResponse; + r.data = null as unknown as T; + r.error = null as unknown as E; + + const data = !responseFormat + ? r + : await response[responseFormat]() + .then(data => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch(e => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} diff --git a/sdks/js/packages/core/package.json b/sdks/js/packages/core/package.json index bf36ef84d..09fa64364 100644 --- a/sdks/js/packages/core/package.json +++ b/sdks/js/packages/core/package.json @@ -16,7 +16,8 @@ "dev": "tsup --watch src", "size": "size-limit", "lint": "eslint \"./**/*.ts*\"", - "test": "echo \"Error: no test specified\" && exit 0" + "test": "echo \"Error: no test specified\" && exit 0", + "gen:client": "npx swagger-typescript-api -p ../../../../proto/apidocs.swagger.yaml -o client --modular" }, "author": "pyadav9678@gmail.com", "license": "Apache-2.0", diff --git a/sdks/js/packages/core/react/components/login.tsx b/sdks/js/packages/core/react/components/login.tsx index 9b0491134..c2e9af0bf 100644 --- a/sdks/js/packages/core/react/components/login.tsx +++ b/sdks/js/packages/core/react/components/login.tsx @@ -25,13 +25,11 @@ export const SignedIn = ({ const { client, strategies = [] } = useFrontier(); const clickHandler = useCallback( - async (name: string) => { - const { - data: { endpoint } - } = await client.getAuthStrategyEndpoint(name); - window.location.href = endpoint; + async (name?: string) => { + if (!name) return; + if (!client) return; + await client.frontierServiceAuthenticate(name, { redirect: true }); }, - // eslint-disable-next-line react-hooks/exhaustive-deps [strategies] ); diff --git a/sdks/js/packages/core/react/components/magiclink-verify.tsx b/sdks/js/packages/core/react/components/magiclink-verify.tsx index 1e28ac896..20f4766ab 100644 --- a/sdks/js/packages/core/react/components/magiclink-verify.tsx +++ b/sdks/js/packages/core/react/components/magiclink-verify.tsx @@ -56,7 +56,13 @@ export const MagicLinkVerify = ({ const OTPVerifyClickHandler = useCallback(async () => { setLoading(true); try { - await client.verifyMagicLinkAuthStrategyEndpoint(otp, stateParam!); + if (!client) return; + + await client.frontierServiceAuthCallback({ + strategyName: 'mailotp', + code: otp, + state: stateParam + }); const searchParams = new URLSearchParams( hasWindow() ? window.location.search : `` diff --git a/sdks/js/packages/core/react/components/magiclink.tsx b/sdks/js/packages/core/react/components/magiclink.tsx index dd4580b0d..79b7b9fd4 100644 --- a/sdks/js/packages/core/react/components/magiclink.tsx +++ b/sdks/js/packages/core/react/components/magiclink.tsx @@ -29,10 +29,16 @@ export const MagicLink = ({ children, ...props }: MagicLinkProps) => { const magicLinkClickHandler = useCallback(async () => { setLoading(true); try { + if (!client) return; + const { - data: { state } - } = await client.getMagicLinkAuthStrategyEndpoint(email); + data: { state = '' } + } = await client.frontierServiceAuthenticate('mailotp', { + email + }); + const searchParams = new URLSearchParams({ state, email }); + // @ts-ignore window.location = `${ config.redirectMagicLinkVerify diff --git a/sdks/js/packages/core/react/components/organization.tsx b/sdks/js/packages/core/react/components/organization.tsx index dd8af484a..dcbb0ac23 100644 --- a/sdks/js/packages/core/react/components/organization.tsx +++ b/sdks/js/packages/core/react/components/organization.tsx @@ -49,9 +49,11 @@ export const CreateOrganization = ({ const { client } = useFrontier(); async function onSubmit(data: any) { + if (!client) return; + const { data: { organization } - } = await client.createOrganisation(data); + } = await client.frontierServiceCreateOrganization(data); // @ts-ignore window.location = `${window.location.origin}/${organization.name}`; } diff --git a/sdks/js/packages/core/react/components/signup.tsx b/sdks/js/packages/core/react/components/signup.tsx index 41b20a464..0d5f57908 100644 --- a/sdks/js/packages/core/react/components/signup.tsx +++ b/sdks/js/packages/core/react/components/signup.tsx @@ -25,11 +25,15 @@ export const Signup = ({ const { client, strategies = [] } = useFrontier(); const clickHandler = useCallback( - async (name: string) => { + async (name?: string) => { + if (!name) return; + if (!client) return; + const { data: { endpoint } - } = await client.getAuthStrategyEndpoint(name); - window.location.href = endpoint; + } = await client.frontierServiceAuthenticate(name, { + redirect: true + }); }, [strategies] ); diff --git a/sdks/js/packages/core/react/contexts/FrontierContext.tsx b/sdks/js/packages/core/react/contexts/FrontierContext.tsx index 03e61505e..b0eb152aa 100644 --- a/sdks/js/packages/core/react/contexts/FrontierContext.tsx +++ b/sdks/js/packages/core/react/contexts/FrontierContext.tsx @@ -9,29 +9,32 @@ import React, { import { FrontierClientOptions, - FrontierProviderProps, - Group, - Organization, - Strategy, - User + FrontierProviderProps } from '../../shared/types'; +import { V1Beta1 } from '../../client/V1Beta1'; +import { + V1Beta1AuthStrategy, + V1Beta1Group, + V1Beta1Organization, + V1Beta1User +} from '../../client/data-contracts'; import Frontier from '../frontier'; interface FrontierContextProviderProps { config: FrontierClientOptions; - client: Frontier; + client: V1Beta1 | undefined; - organizations: Organization[]; - setOrganizations: Dispatch>; + organizations: V1Beta1Organization[]; + setOrganizations: Dispatch>; - groups: Group[]; - setGroups: Dispatch>; + groups: V1Beta1Group[]; + setGroups: Dispatch>; - strategies: Strategy[]; - setStrategies: Dispatch>; + strategies: V1Beta1AuthStrategy[]; + setStrategies: Dispatch>; - user: User | null; - setUser: Dispatch>; + user: V1Beta1User | undefined; + setUser: Dispatch>; } const defaultConfig = { @@ -43,7 +46,7 @@ const defaultConfig = { const initialValues: FrontierContextProviderProps = { config: defaultConfig, - client: Frontier.getOrCreateInstance(defaultConfig), + client: undefined, organizations: [], setOrganizations: () => undefined, @@ -54,7 +57,7 @@ const initialValues: FrontierContextProviderProps = { strategies: [], setStrategies: () => undefined, - user: null, + user: undefined, setUser: () => undefined }; @@ -70,17 +73,17 @@ export const FrontierContextProvider = ({ }: FrontierProviderProps) => { const { frontierClient } = useFrontierClient(config); - const [organizations, setOrganizations] = useState([]); - const [groups, setGroups] = useState([]); - const [strategies, setStrategies] = useState([]); - const [user, setUser] = useState(null); + const [organizations, setOrganizations] = useState([]); + const [groups, setGroups] = useState([]); + const [strategies, setStrategies] = useState([]); + const [user, setUser] = useState(); useEffect(() => { async function getFrontierInformation() { try { const { - data: { strategies } - } = await frontierClient.getAuthAtrategies(); + data: { strategies = [] } + } = await frontierClient.frontierServiceListAuthStrategies(); setStrategies(strategies); } catch (error) { console.error( @@ -96,7 +99,7 @@ export const FrontierContextProvider = ({ try { const { data: { user } - } = await frontierClient.getCurrentUser(); + } = await frontierClient.frontierServiceGetCurrentUser(); setUser(user); } catch (error) { console.error( @@ -111,8 +114,8 @@ export const FrontierContextProvider = ({ async function getFrontierCurrentUserGroups(userId: string) { try { const { - data: { groups } - } = await frontierClient.getUserGroups(userId); + data: { groups = [] } + } = await frontierClient.frontierServiceListUserGroups(userId); setGroups(groups); } catch (error) { console.error( @@ -121,7 +124,7 @@ export const FrontierContextProvider = ({ } } - if (user) { + if (user?.id) { getFrontierCurrentUserGroups(user.id); } }, [user]); @@ -130,8 +133,8 @@ export const FrontierContextProvider = ({ async function getFrontierCurrentUserOrganizations(userId: string) { try { const { - data: { organizations } - } = await frontierClient.getUserOrganisations(userId); + data: { organizations = [] } + } = await frontierClient.frontierServiceGetOrganizationsByUser(userId); setOrganizations(organizations); } catch (error) { console.error( @@ -140,7 +143,7 @@ export const FrontierContextProvider = ({ } } - if (user) { + if (user?.id) { getFrontierCurrentUserOrganizations(user.id); } }, [user]); @@ -167,7 +170,7 @@ export const FrontierContextProvider = ({ export const useFrontierClient = (options: FrontierClientOptions) => { const frontierClient = React.useMemo( - () => Frontier.getOrCreateInstance(options), + () => Frontier.getInstance({ endpoint: options.endpoint }), [] ); diff --git a/sdks/js/packages/core/react/frontier.ts b/sdks/js/packages/core/react/frontier.ts index 5123df842..8cc80221e 100644 --- a/sdks/js/packages/core/react/frontier.ts +++ b/sdks/js/packages/core/react/frontier.ts @@ -1,82 +1,21 @@ -import type { AxiosInstance, AxiosResponse } from 'axios'; -import axios from 'axios'; - -import { - FrontierClientOptions, - Group, - Organization, - Strategy, - User -} from '../shared/types'; +import { V1Beta1 } from '../client/V1Beta1'; +import { FrontierClient } from '../src'; +// Create a class to hold the singleton instance export default class Frontier { - protected readonly instance: AxiosInstance; - private readonly options: FrontierClientOptions; - private static classInstance?: Frontier; - - static getOrCreateInstance(options: FrontierClientOptions) { - if (!this.classInstance) { - return new Frontier(options); + private static instance: V1Beta1 | null = null; + + private constructor() {} + + public static getInstance({ endpoint }: any): V1Beta1 { + if (!Frontier.instance) { + Frontier.instance = new FrontierClient({ + baseUrl: endpoint, + baseApiParams: { + credentials: 'include' + } + }); } - return this.classInstance; - } - - constructor(options: FrontierClientOptions) { - this.options = options; - this.instance = axios.create({ - baseURL: options.endpoint, - withCredentials: true - }); + return Frontier.instance; } - - public getAuthAtrategies = async (): Promise< - AxiosResponse<{ strategies: Strategy[] }> - > => { - return await this.instance.get('/v1beta1/auth'); - }; - - public getAuthStrategyEndpoint = async ( - strategy: string - ): Promise> => { - return await this.instance.get(`/v1beta1/auth/register/${strategy}`); - }; - - public getMagicLinkAuthStrategyEndpoint = async ( - email: string - ): Promise> => { - return await this.instance.get( - `/v1beta1/auth/register/mailotp?email=${email}` - ); - }; - - public verifyMagicLinkAuthStrategyEndpoint = async ( - code: string, - state: string - ): Promise> => { - return await this.instance.get( - `/v1beta1/auth/callback?strategy_name=mailotp&code=${code}&state=${state}` - ); - }; - - public getCurrentUser = async (): Promise> => { - return await this.instance.get('/v1beta1/users/self'); - }; - - public getUserGroups = async ( - userId: string - ): Promise> => { - return await this.instance.get(`/v1beta1/users/${userId}/groups`); - }; - - public getUserOrganisations = async ( - userId: string - ): Promise> => { - return await this.instance.get(`/v1beta1/users/${userId}/organizations`); - }; - - public createOrganisation = async ( - data: any - ): Promise> => { - return await this.instance.post(`/v1beta1/organizations`, data); - }; } diff --git a/sdks/js/packages/core/src/index.ts b/sdks/js/packages/core/src/index.ts index cfb9fe2b7..25eda669b 100644 --- a/sdks/js/packages/core/src/index.ts +++ b/sdks/js/packages/core/src/index.ts @@ -1 +1,3 @@ -export class Frontier {} +import { V1Beta1 } from '../client/V1Beta1'; + +export const FrontierClient = V1Beta1;