mirror of
https://github.com/bitwarden/directory-connector
synced 2025-12-22 19:23:22 +00:00
* [deps]: Update eslint to v9 * resolve lint errors, upgrade eslint, replace unmaintained packages * refresh lockfile --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Brandon <btreston@bitwarden.com> Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com> Co-authored-by: Thomas Rittson <trittson@bitwarden.com>
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import { DeviceRequest } from "../deviceRequest";
|
|
|
|
import { TokenRequestTwoFactor } from "./tokenRequestTwoFactor";
|
|
|
|
export abstract class TokenRequest {
|
|
protected device?: DeviceRequest;
|
|
|
|
constructor(
|
|
protected twoFactor: TokenRequestTwoFactor,
|
|
device?: DeviceRequest,
|
|
) {
|
|
this.device = device != null ? device : null;
|
|
}
|
|
|
|
alterIdentityTokenHeaders(headers: Headers) {
|
|
// Implemented in subclass if required
|
|
}
|
|
|
|
setTwoFactor(twoFactor: TokenRequestTwoFactor) {
|
|
this.twoFactor = twoFactor;
|
|
}
|
|
|
|
protected toIdentityToken(clientId: string) {
|
|
const obj: any = {
|
|
scope: "api offline_access",
|
|
client_id: clientId,
|
|
};
|
|
|
|
if (this.device) {
|
|
obj.deviceType = this.device.type;
|
|
obj.deviceIdentifier = this.device.identifier;
|
|
obj.deviceName = this.device.name;
|
|
// no push tokens for browser apps yet
|
|
// obj.devicePushToken = this.device.pushToken;
|
|
}
|
|
|
|
if (this.twoFactor.token && this.twoFactor.provider != null) {
|
|
obj.twoFactorToken = this.twoFactor.token;
|
|
obj.twoFactorProvider = this.twoFactor.provider;
|
|
obj.twoFactorRemember = this.twoFactor.remember ? "1" : "0";
|
|
}
|
|
|
|
return obj;
|
|
}
|
|
}
|