1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-08-07 23:02:56 +03:00

Fix types around Terms (#4674)

This commit is contained in:
Michael Telatynski
2025-02-03 08:48:00 +00:00
committed by GitHub
parent c93128ed39
commit 5be104a35c
2 changed files with 38 additions and 2 deletions

View File

@@ -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;
};
}

View File

@@ -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<EmittedEvents, ClientEventHa
return this.http.authedRequest(Method.Get, path, params);
}
public getTerms(serviceType: SERVICE_TYPES, baseUrl: string): Promise<any> {
// TODO: Types
public getTerms(serviceType: SERVICE_TYPES, baseUrl: string): Promise<Terms> {
const url = this.termsUrlForService(serviceType, baseUrl);
return this.http.requestOtherUrl(Method.Get, url);
}