matrix-dimension/src/matrix/MatrixOpenIdClient.ts

21 lines
679 B
TypeScript
Raw Normal View History

import { doFederatedApiCall } from "./helpers";
import { OpenId } from "../models/OpenId";
export class MatrixOpenIdClient {
constructor(private openId: OpenId) {
}
2018-03-24 03:26:14 +00:00
public async getUserId(): Promise<string> {
// TODO: Implement/prefer https://github.com/matrix-org/matrix-doc/issues/1115
// #1115 also means this should become a client API call, not a federated one (finally)
2018-03-24 03:26:14 +00:00
const response = await doFederatedApiCall(
"GET",
this.openId.matrix_server_name,
"/_matrix/federation/v1/openid/userinfo",
{access_token: this.openId.access_token}
2018-03-24 03:26:14 +00:00
);
return response['sub'];
}
}