diff --git a/src/@types/partials.ts b/src/@types/partials.ts index 72fd77168..239310b0f 100644 --- a/src/@types/partials.ts +++ b/src/@types/partials.ts @@ -65,3 +65,39 @@ export interface IUsageLimit { // eslint-disable-next-line camelcase admin_contact?: string; } + +/** + * A policy name & url in a specific internationalisation + * @see https://spec.matrix.org/v1.13/identity-service-api/#get_matrixidentityv2terms_response-200_internationalised-policy + */ +export interface InternationalisedPolicy { + name: string; + url: string; +} + +/** + * A versioned policy with internationalised variants + * @see https://spec.matrix.org/v1.13/identity-service-api/#get_matrixidentityv2terms_response-200_policy-object + */ +export interface Policy { + /** + * The version for the policy. + * There are no requirements on what this might be and could be “alpha”, semantically versioned, or arbitrary. + */ + version: string; + /** + * The policy information for the specified language. + * @remarks the type has to include a union with string due to limitations in the type system. + */ + [lang: string]: InternationalisedPolicy | string; +} + +/** + * Response from the Terms API for Identity servers + * @see https://spec.matrix.org/v1.13/identity-service-api/#get_matrixidentityv2terms + */ +export interface Terms { + policies: { + [policyName: string]: Policy; + }; +} diff --git a/src/client.ts b/src/client.ts index c05e6a1a1..d2ed331cf 100644 --- a/src/client.ts +++ b/src/client.ts @@ -157,6 +157,7 @@ import { IdServerUnbindResult, JoinRule, Preset, + Terms, Visibility, } from "./@types/partials.ts"; import { EventMapper, eventMapperFor, MapperOpts } from "./event-mapper.ts"; @@ -10036,8 +10037,7 @@ export class MatrixClient extends TypedEventEmitter { - // TODO: Types + public getTerms(serviceType: SERVICE_TYPES, baseUrl: string): Promise { const url = this.termsUrlForService(serviceType, baseUrl); return this.http.requestOtherUrl(Method.Get, url); }