mirror of
https://github.com/turt2live/matrix-dimension.git
synced 2024-10-01 01:05:53 -04:00
4965b61f2d
This still doesn't allow editing, but it supports showing the widgets at least.
23 lines
650 B
TypeScript
23 lines
650 B
TypeScript
import * as Promise from "bluebird";
|
|
import { doFederatedApiCall } from "./helpers";
|
|
import { OpenId } from "../models/OpenId";
|
|
|
|
export class MatrixOpenIdClient {
|
|
|
|
constructor(private openId: OpenId) {
|
|
}
|
|
|
|
public getUserId(): Promise<string> {
|
|
return doFederatedApiCall(
|
|
"GET",
|
|
this.openId.matrix_server_name,
|
|
"/_matrix/federation/v1/openid/userinfo",
|
|
{access_token: this.openId.access_token}
|
|
).then(response => {
|
|
// Annoyingly, the response isn't JSON for this
|
|
response = JSON.parse(response);
|
|
return response['sub'];
|
|
});
|
|
}
|
|
}
|