nativescript
Version:
Command-line interface for building NativeScript projects
42 lines • 1.63 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AppleLogin = void 0;
const command_params_1 = require("../common/command-params");
const yok_1 = require("../common/yok");
class AppleLogin {
constructor($applePortalSessionService, $errors, $injector, $logger, $prompter) {
this.$applePortalSessionService = $applePortalSessionService;
this.$errors = $errors;
this.$injector = $injector;
this.$logger = $logger;
this.$prompter = $prompter;
this.allowedParameters = [
new command_params_1.StringCommandParameter(this.$injector),
new command_params_1.StringCommandParameter(this.$injector),
];
}
async execute(args) {
let username = args[0];
if (!username) {
username = await this.$prompter.getString("Apple ID", {
allowEmpty: false,
});
}
let password = args[1];
if (!password) {
password = await this.$prompter.getPassword("Apple ID password");
}
const user = await this.$applePortalSessionService.createUserSession({
username,
password,
});
if (!user.areCredentialsValid) {
this.$errors.fail(`Invalid username and password combination. Used '${username}' as the username.`);
}
const output = Buffer.from(user.userSessionCookie).toString("base64");
this.$logger.info(output);
}
}
exports.AppleLogin = AppleLogin;
yok_1.injector.registerCommand("apple-login", AppleLogin);
//# sourceMappingURL=apple-login.js.map