@codecovevienna/gittt-cli
Version:
Tracking time with CLI into a git repository
38 lines (37 loc) • 1.61 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AuthHelper = void 0;
const client_oauth2_1 = __importDefault(require("client-oauth2"));
const MULTIPIE_OAUTH_CLIENT_ID = "cc-gittt-cli";
const MULTIPIE_OAUTH_ACCESS_TOKEN_URI = "https://auth.multipie.cc/auth/realms/multipie/protocol/openid-connect/token";
const MULTIPIE_OAUTH_AUTHORIZATION_URI = "https://auth.multipie.cc/auth/realms/multipie/protocol/openid-connect/auth";
const MULTIPIE_OAUTH_REDIRECT_URI = MULTIPIE_OAUTH_AUTHORIZATION_URI;
class AuthHelper {
constructor() {
this.getAuthClient = (multipieLink) => {
if (!this.authClient) {
this.authClient = new client_oauth2_1.default({
clientId: MULTIPIE_OAUTH_CLIENT_ID,
clientSecret: multipieLink.clientSecret,
accessTokenUri: MULTIPIE_OAUTH_ACCESS_TOKEN_URI,
authorizationUri: MULTIPIE_OAUTH_AUTHORIZATION_URI,
redirectUri: MULTIPIE_OAUTH_REDIRECT_URI,
scopes: ['openid', 'offline_access']
});
}
return this.authClient;
};
this.getLegacyAuth = (multipieLink) => {
if (multipieLink.username) {
return multipieLink.username;
}
else {
throw new Error("Unable to get username");
}
};
}
}
exports.AuthHelper = AuthHelper;