Skip to content

Commit 802e8e6

Browse files
committed
feat: add apple-login command
1 parent 0b1e750 commit 802e8e6

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

lib/bootstrap.ts

+1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ $injector.requireCommand("dev-generate-help", "./commands/generate-help");
100100
$injector.requireCommand("appstore|*list", "./commands/appstore-list");
101101
$injector.requireCommand("appstore|upload", "./commands/appstore-upload");
102102
$injector.requireCommand("publish|ios", "./commands/appstore-upload");
103+
$injector.requireCommand("apple-login", "./commands/apple-login");
103104
$injector.require("itmsTransporterService", "./services/itmstransporter-service");
104105

105106
$injector.requireCommand("setup|*", "./commands/setup");

lib/commands/apple-login.ts

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { StringCommandParameter } from "../common/command-params";
2+
3+
export class AppleLogin implements ICommand {
4+
public allowedParameters: ICommandParameter[] = [new StringCommandParameter(this.$injector), new StringCommandParameter(this.$injector)];
5+
6+
constructor(
7+
private $applePortalSessionService: IApplePortalSessionService,
8+
private $errors: IErrors,
9+
private $injector: IInjector,
10+
private $logger: ILogger,
11+
private $prompter: IPrompter
12+
) { }
13+
14+
public async execute(args: string[]): Promise<void> {
15+
let username = args[0];
16+
if (!username) {
17+
username = await this.$prompter.getString("Apple ID", { allowEmpty: false });
18+
}
19+
20+
let password = args[1];
21+
if (!password) {
22+
password = await this.$prompter.getPassword("Apple ID password");
23+
}
24+
25+
const user = await this.$applePortalSessionService.createUserSession({ username, password });
26+
if (!user.areCredentialsValid) {
27+
this.$errors.failWithoutHelp(`Invalid username and password combination. Used '${username}' as the username.`);
28+
}
29+
30+
const output = Buffer.from(user.userSessionCookie).toString("base64");
31+
this.$logger.info(output);
32+
}
33+
}
34+
$injector.registerCommand("apple-login", AppleLogin);

0 commit comments

Comments
 (0)