matrix-dimension/src/matrix/MatrixOpenIdClient.ts
Travis Ralston 8cdae3359d Support explicit setting of the federation/client URLs
The client/server URL is needed for go-neb to work correctly, and to remove our complete dependence on federation.

The federation URL is also configurable so servers that don't wish to federate can specify a local address.
2018-03-24 17:09:34 -06:00

21 lines
679 B
TypeScript

import { doFederatedApiCall } from "./helpers";
import { OpenId } from "../models/OpenId";
export class MatrixOpenIdClient {
constructor(private openId: OpenId) {
}
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)
const response = await doFederatedApiCall(
"GET",
this.openId.matrix_server_name,
"/_matrix/federation/v1/openid/userinfo",
{access_token: this.openId.access_token}
);
return response['sub'];
}
}