mirror of
https://github.com/turt2live/matrix-dimension.git
synced 2024-10-01 01:05:53 -04:00
27 lines
749 B
TypeScript
27 lines
749 B
TypeScript
import * as Promise from "bluebird";
|
|
import { doFederatedApiCall } from "./helpers";
|
|
import AppService from "../db/models/AppService";
|
|
|
|
export interface MatrixUserResponse {
|
|
access_token: string;
|
|
device_id: string;
|
|
home_server: string;
|
|
user_id: string;
|
|
}
|
|
|
|
export class MatrixAppserviceClient {
|
|
|
|
constructor(private homeserverName: string, private appservice: AppService) {
|
|
}
|
|
|
|
public registerUser(localpart: string): Promise<MatrixUserResponse> {
|
|
return doFederatedApiCall(
|
|
"POST",
|
|
this.homeserverName,
|
|
"/_matrix/client/r0/register",
|
|
{access_token: this.appservice.asToken},
|
|
{type: "m.login.application_service", username: localpart},
|
|
);
|
|
}
|
|
}
|