@sitepong/fastnode 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +81 -0
- package/bin/fastnode.js +13 -0
- package/bin/fastnode.ts +5 -0
- package/dist/actions/index.cjs +7405 -0
- package/dist/actions/index.cjs.map +1 -0
- package/dist/actions/index.d.cts +15 -0
- package/dist/actions/index.d.ts +15 -0
- package/dist/actions/index.mjs +7377 -0
- package/dist/actions/index.mjs.map +1 -0
- package/dist/cert/index.cjs +219 -0
- package/dist/cert/index.cjs.map +1 -0
- package/dist/cert/index.d.cts +4 -0
- package/dist/cert/index.d.ts +4 -0
- package/dist/cert/index.mjs +191 -0
- package/dist/cert/index.mjs.map +1 -0
- package/dist/cert-BmJGtYtb.d.cts +27 -0
- package/dist/cert-owkOFNW8.d.ts +27 -0
- package/dist/cli/index.cjs +7998 -0
- package/dist/cli/index.cjs.map +1 -0
- package/dist/cli/index.d.cts +9 -0
- package/dist/cli/index.d.ts +9 -0
- package/dist/cli/index.mjs +7972 -0
- package/dist/cli/index.mjs.map +1 -0
- package/dist/client/index.cjs +2592 -0
- package/dist/client/index.cjs.map +1 -0
- package/dist/client/index.d.cts +2 -0
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.mjs +2582 -0
- package/dist/client/index.mjs.map +1 -0
- package/dist/context-CymLkfrS.d.cts +13 -0
- package/dist/context-CymLkfrS.d.ts +13 -0
- package/dist/core/index.cjs +281 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +1 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.mjs +254 -0
- package/dist/core/index.mjs.map +1 -0
- package/dist/deliver/index.cjs +328 -0
- package/dist/deliver/index.cjs.map +1 -0
- package/dist/deliver/index.d.cts +3 -0
- package/dist/deliver/index.d.ts +3 -0
- package/dist/deliver/index.mjs +322 -0
- package/dist/deliver/index.mjs.map +1 -0
- package/dist/enums-B609j2rb.d.cts +20 -0
- package/dist/enums-B609j2rb.d.ts +20 -0
- package/dist/frameit/index.cjs +247 -0
- package/dist/frameit/index.cjs.map +1 -0
- package/dist/frameit/index.d.cts +1 -0
- package/dist/frameit/index.d.ts +1 -0
- package/dist/frameit/index.mjs +242 -0
- package/dist/frameit/index.mjs.map +1 -0
- package/dist/gym/index.cjs +356 -0
- package/dist/gym/index.cjs.map +1 -0
- package/dist/gym/index.d.cts +2 -0
- package/dist/gym/index.d.ts +2 -0
- package/dist/gym/index.mjs +346 -0
- package/dist/gym/index.mjs.map +1 -0
- package/dist/index-1Vu2cRQ2.d.ts +99 -0
- package/dist/index-A5MimeQk.d.ts +72 -0
- package/dist/index-B0yhu_LZ.d.ts +76 -0
- package/dist/index-B9yXicrQ.d.ts +62 -0
- package/dist/index-BFdNOmPJ.d.cts +53 -0
- package/dist/index-BLubSlgK.d.cts +1513 -0
- package/dist/index-BN0ubxjZ.d.ts +70 -0
- package/dist/index-BQJIJlK7.d.cts +70 -0
- package/dist/index-BYonklf3.d.cts +84 -0
- package/dist/index-BYonklf3.d.ts +84 -0
- package/dist/index-BimqCmY8.d.cts +78 -0
- package/dist/index-BimqCmY8.d.ts +78 -0
- package/dist/index-BoU8qt8r.d.cts +59 -0
- package/dist/index-BoU8qt8r.d.ts +59 -0
- package/dist/index-C2yG3wXA.d.cts +95 -0
- package/dist/index-C2yG3wXA.d.ts +95 -0
- package/dist/index-CR3BFPIz.d.cts +77 -0
- package/dist/index-CR3BFPIz.d.ts +77 -0
- package/dist/index-CWNLnSOL.d.cts +99 -0
- package/dist/index-Cp6cjtd-.d.cts +65 -0
- package/dist/index-Cp6cjtd-.d.ts +65 -0
- package/dist/index-D1Izm7qt.d.ts +1513 -0
- package/dist/index-D5eihzwM.d.cts +76 -0
- package/dist/index-DImN9PWc.d.ts +155 -0
- package/dist/index-DfCUVJX1.d.cts +62 -0
- package/dist/index-DfirmFbC.d.ts +32 -0
- package/dist/index-DkvinY7_.d.ts +54 -0
- package/dist/index-DrUpRXRG.d.cts +155 -0
- package/dist/index-EcVvViW8.d.cts +72 -0
- package/dist/index-HRiaaX-Q.d.cts +54 -0
- package/dist/index-TfXqwuac.d.ts +53 -0
- package/dist/index-lt819Jgj.d.cts +32 -0
- package/dist/index.cjs +8464 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +23 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.mjs +8410 -0
- package/dist/index.mjs.map +1 -0
- package/dist/lane/index.cjs +7641 -0
- package/dist/lane/index.cjs.map +1 -0
- package/dist/lane/index.d.cts +51 -0
- package/dist/lane/index.d.ts +51 -0
- package/dist/lane/index.mjs +7603 -0
- package/dist/lane/index.mjs.map +1 -0
- package/dist/match/index.cjs +942 -0
- package/dist/match/index.cjs.map +1 -0
- package/dist/match/index.d.cts +5 -0
- package/dist/match/index.d.ts +5 -0
- package/dist/match/index.mjs +913 -0
- package/dist/match/index.mjs.map +1 -0
- package/dist/pem/index.cjs +195 -0
- package/dist/pem/index.cjs.map +1 -0
- package/dist/pem/index.d.cts +3 -0
- package/dist/pem/index.d.ts +3 -0
- package/dist/pem/index.mjs +170 -0
- package/dist/pem/index.mjs.map +1 -0
- package/dist/pilot/index.cjs +206 -0
- package/dist/pilot/index.cjs.map +1 -0
- package/dist/pilot/index.d.cts +3 -0
- package/dist/pilot/index.d.ts +3 -0
- package/dist/pilot/index.mjs +196 -0
- package/dist/pilot/index.mjs.map +1 -0
- package/dist/precheck/index.cjs +277 -0
- package/dist/precheck/index.cjs.map +1 -0
- package/dist/precheck/index.d.cts +3 -0
- package/dist/precheck/index.d.ts +3 -0
- package/dist/precheck/index.mjs +274 -0
- package/dist/precheck/index.mjs.map +1 -0
- package/dist/produce/index.cjs +200 -0
- package/dist/produce/index.cjs.map +1 -0
- package/dist/produce/index.d.cts +3 -0
- package/dist/produce/index.d.ts +3 -0
- package/dist/produce/index.mjs +191 -0
- package/dist/produce/index.mjs.map +1 -0
- package/dist/scan/index.cjs +187 -0
- package/dist/scan/index.cjs.map +1 -0
- package/dist/scan/index.d.cts +1 -0
- package/dist/scan/index.d.ts +1 -0
- package/dist/scan/index.mjs +183 -0
- package/dist/scan/index.mjs.map +1 -0
- package/dist/sigh/index.cjs +203 -0
- package/dist/sigh/index.cjs.map +1 -0
- package/dist/sigh/index.d.cts +3 -0
- package/dist/sigh/index.d.ts +3 -0
- package/dist/sigh/index.mjs +198 -0
- package/dist/sigh/index.mjs.map +1 -0
- package/dist/snapshot/index.cjs +448 -0
- package/dist/snapshot/index.cjs.map +1 -0
- package/dist/snapshot/index.d.cts +1 -0
- package/dist/snapshot/index.d.ts +1 -0
- package/dist/snapshot/index.mjs +438 -0
- package/dist/snapshot/index.mjs.map +1 -0
- package/dist/trainer/index.cjs +395 -0
- package/dist/trainer/index.cjs.map +1 -0
- package/dist/trainer/index.d.cts +1 -0
- package/dist/trainer/index.d.ts +1 -0
- package/dist/trainer/index.mjs +372 -0
- package/dist/trainer/index.mjs.map +1 -0
- package/dist/xcode/index.cjs +188 -0
- package/dist/xcode/index.cjs.map +1 -0
- package/dist/xcode/index.d.cts +1 -0
- package/dist/xcode/index.d.ts +1 -0
- package/dist/xcode/index.mjs +176 -0
- package/dist/xcode/index.mjs.map +1 -0
- package/package.json +223 -0
|
@@ -0,0 +1,942 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var child_process = require('child_process');
|
|
4
|
+
var fs = require('fs');
|
|
5
|
+
var path = require('path');
|
|
6
|
+
var os = require('os');
|
|
7
|
+
var x509 = require('@peculiar/x509');
|
|
8
|
+
var crypto = require('crypto');
|
|
9
|
+
var util = require('util');
|
|
10
|
+
var promises = require('fs/promises');
|
|
11
|
+
|
|
12
|
+
function _interopNamespace(e) {
|
|
13
|
+
if (e && e.__esModule) return e;
|
|
14
|
+
var n = Object.create(null);
|
|
15
|
+
if (e) {
|
|
16
|
+
Object.keys(e).forEach(function (k) {
|
|
17
|
+
if (k !== 'default') {
|
|
18
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
19
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return e[k]; }
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
n.default = e;
|
|
27
|
+
return Object.freeze(n);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
var x509__namespace = /*#__PURE__*/_interopNamespace(x509);
|
|
31
|
+
|
|
32
|
+
var __defProp = Object.defineProperty;
|
|
33
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
34
|
+
var __esm = (fn, res) => function __init() {
|
|
35
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
36
|
+
};
|
|
37
|
+
var __export = (target, all) => {
|
|
38
|
+
for (var name in all)
|
|
39
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// src/match/storage/git.ts
|
|
43
|
+
var git_exports = {};
|
|
44
|
+
__export(git_exports, {
|
|
45
|
+
GitStorage: () => GitStorage
|
|
46
|
+
});
|
|
47
|
+
var GitStorage;
|
|
48
|
+
var init_git = __esm({
|
|
49
|
+
"src/match/storage/git.ts"() {
|
|
50
|
+
GitStorage = class {
|
|
51
|
+
workingDirectory;
|
|
52
|
+
gitUrl;
|
|
53
|
+
branch;
|
|
54
|
+
privateKeyPath;
|
|
55
|
+
privateKeyContent;
|
|
56
|
+
basicAuth;
|
|
57
|
+
bearerToken;
|
|
58
|
+
userName;
|
|
59
|
+
userEmail;
|
|
60
|
+
shallowClone;
|
|
61
|
+
/** Temp path written from `gitPrivateKeyContent`. Cleaned up on `cleanup`. */
|
|
62
|
+
tempKeyPath;
|
|
63
|
+
constructor(params) {
|
|
64
|
+
this.gitUrl = params.gitUrl ?? "";
|
|
65
|
+
this.branch = params.gitBranch ?? "master";
|
|
66
|
+
this.privateKeyPath = params.gitPrivateKey;
|
|
67
|
+
this.privateKeyContent = params.gitPrivateKeyContent;
|
|
68
|
+
this.basicAuth = params.gitBasicAuth;
|
|
69
|
+
this.bearerToken = params.gitBearerToken;
|
|
70
|
+
this.userName = params.gitUserName;
|
|
71
|
+
this.userEmail = params.gitUserEmail;
|
|
72
|
+
this.shallowClone = params.shallowClone ?? true;
|
|
73
|
+
this.workingDirectory = "";
|
|
74
|
+
}
|
|
75
|
+
async download() {
|
|
76
|
+
this.workingDirectory = fs.mkdtempSync(path.join(os.tmpdir(), "fastnode-match-"));
|
|
77
|
+
if (this.privateKeyContent && !this.privateKeyPath) {
|
|
78
|
+
this.tempKeyPath = path.join(
|
|
79
|
+
fs.mkdtempSync(path.join(os.tmpdir(), "fastnode-match-key-")),
|
|
80
|
+
"id_rsa"
|
|
81
|
+
);
|
|
82
|
+
fs.writeFileSync(this.tempKeyPath, this.privateKeyContent);
|
|
83
|
+
fs.chmodSync(this.tempKeyPath, 384);
|
|
84
|
+
}
|
|
85
|
+
const env = this.buildEnv();
|
|
86
|
+
const extraArgs = this.buildHttpAuthArgs();
|
|
87
|
+
["-c", "http.extraheader=", ...extraArgs];
|
|
88
|
+
const configArgs = extraArgs.flatMap((entry) => ["-c", entry]);
|
|
89
|
+
const baseArgs = this.shallowClone ? ["--depth", "1"] : [];
|
|
90
|
+
const branchArgs = ["-b", this.branch, "--single-branch"];
|
|
91
|
+
try {
|
|
92
|
+
child_process.execFileSync(
|
|
93
|
+
"git",
|
|
94
|
+
[
|
|
95
|
+
...configArgs,
|
|
96
|
+
"clone",
|
|
97
|
+
...baseArgs,
|
|
98
|
+
...branchArgs,
|
|
99
|
+
this.gitUrl,
|
|
100
|
+
this.workingDirectory
|
|
101
|
+
],
|
|
102
|
+
{ env, stdio: "pipe" }
|
|
103
|
+
);
|
|
104
|
+
} catch {
|
|
105
|
+
child_process.execFileSync(
|
|
106
|
+
"git",
|
|
107
|
+
[
|
|
108
|
+
...configArgs,
|
|
109
|
+
"clone",
|
|
110
|
+
...baseArgs,
|
|
111
|
+
this.gitUrl,
|
|
112
|
+
this.workingDirectory
|
|
113
|
+
],
|
|
114
|
+
{ env, stdio: "pipe" }
|
|
115
|
+
);
|
|
116
|
+
try {
|
|
117
|
+
child_process.execFileSync("git", ["checkout", this.branch], {
|
|
118
|
+
cwd: this.workingDirectory,
|
|
119
|
+
env,
|
|
120
|
+
stdio: "pipe"
|
|
121
|
+
});
|
|
122
|
+
} catch {
|
|
123
|
+
child_process.execFileSync("git", ["checkout", "--orphan", this.branch], {
|
|
124
|
+
cwd: this.workingDirectory,
|
|
125
|
+
env,
|
|
126
|
+
stdio: "pipe"
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (this.userName) {
|
|
131
|
+
child_process.execFileSync("git", ["config", "user.name", this.userName], {
|
|
132
|
+
cwd: this.workingDirectory,
|
|
133
|
+
env,
|
|
134
|
+
stdio: "pipe"
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
if (this.userEmail) {
|
|
138
|
+
child_process.execFileSync("git", ["config", "user.email", this.userEmail], {
|
|
139
|
+
cwd: this.workingDirectory,
|
|
140
|
+
env,
|
|
141
|
+
stdio: "pipe"
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
return this.workingDirectory;
|
|
145
|
+
}
|
|
146
|
+
async saveChanges(files, message) {
|
|
147
|
+
const env = this.buildEnv();
|
|
148
|
+
const extraArgs = this.buildHttpAuthArgs();
|
|
149
|
+
const configArgs = extraArgs.flatMap((entry) => ["-c", entry]);
|
|
150
|
+
const opts = {
|
|
151
|
+
cwd: this.workingDirectory,
|
|
152
|
+
env,
|
|
153
|
+
stdio: "pipe"
|
|
154
|
+
};
|
|
155
|
+
for (const file of files) {
|
|
156
|
+
child_process.execFileSync("git", ["add", file], opts);
|
|
157
|
+
}
|
|
158
|
+
try {
|
|
159
|
+
child_process.execFileSync("git", ["commit", "-m", message], opts);
|
|
160
|
+
child_process.execFileSync(
|
|
161
|
+
"git",
|
|
162
|
+
[...configArgs, "push", "origin", this.branch],
|
|
163
|
+
opts
|
|
164
|
+
);
|
|
165
|
+
} catch {
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
async cleanup() {
|
|
169
|
+
if (this.workingDirectory) {
|
|
170
|
+
fs.rmSync(this.workingDirectory, { recursive: true, force: true });
|
|
171
|
+
}
|
|
172
|
+
if (this.tempKeyPath) {
|
|
173
|
+
fs.rmSync(this.tempKeyPath, { force: true });
|
|
174
|
+
fs.rmSync(path.join(this.tempKeyPath, ".."), { recursive: true, force: true });
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
buildHttpAuthArgs() {
|
|
178
|
+
const args = [];
|
|
179
|
+
if (this.basicAuth) {
|
|
180
|
+
const encoded = Buffer.from(
|
|
181
|
+
`${this.basicAuth.user}:${this.basicAuth.pass}`
|
|
182
|
+
).toString("base64");
|
|
183
|
+
args.push(`http.extraheader=Authorization: Basic ${encoded}`);
|
|
184
|
+
} else if (this.bearerToken) {
|
|
185
|
+
args.push(`http.extraheader=Authorization: Bearer ${this.bearerToken}`);
|
|
186
|
+
}
|
|
187
|
+
return args;
|
|
188
|
+
}
|
|
189
|
+
buildEnv() {
|
|
190
|
+
const env = {
|
|
191
|
+
...process.env,
|
|
192
|
+
GIT_TERMINAL_PROMPT: "0"
|
|
193
|
+
};
|
|
194
|
+
const keyPath = this.privateKeyPath ?? this.tempKeyPath;
|
|
195
|
+
if (keyPath) {
|
|
196
|
+
env.GIT_SSH_COMMAND = `ssh -i ${keyPath} -o StrictHostKeyChecking=no -o IdentitiesOnly=yes`;
|
|
197
|
+
}
|
|
198
|
+
return env;
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
// src/match/storage/s3.ts
|
|
205
|
+
var s3_exports = {};
|
|
206
|
+
__export(s3_exports, {
|
|
207
|
+
S3Storage: () => S3Storage
|
|
208
|
+
});
|
|
209
|
+
var S3Storage;
|
|
210
|
+
var init_s3 = __esm({
|
|
211
|
+
"src/match/storage/s3.ts"() {
|
|
212
|
+
S3Storage = class {
|
|
213
|
+
workingDirectory;
|
|
214
|
+
bucket;
|
|
215
|
+
region;
|
|
216
|
+
prefix;
|
|
217
|
+
constructor(params) {
|
|
218
|
+
this.bucket = params.s3Bucket ?? "";
|
|
219
|
+
this.region = params.s3Region ?? "us-east-1";
|
|
220
|
+
this.prefix = params.s3ObjectPrefix ?? "";
|
|
221
|
+
this.workingDirectory = "";
|
|
222
|
+
}
|
|
223
|
+
async download() {
|
|
224
|
+
this.workingDirectory = fs.mkdtempSync(path.join(os.tmpdir(), "fastnode-match-s3-"));
|
|
225
|
+
const s3Path = this.prefix ? `s3://${this.bucket}/${this.prefix}` : `s3://${this.bucket}`;
|
|
226
|
+
child_process.execFileSync("aws", ["s3", "sync", s3Path, this.workingDirectory, "--region", this.region], { stdio: "pipe" });
|
|
227
|
+
return this.workingDirectory;
|
|
228
|
+
}
|
|
229
|
+
async saveChanges(files, _message) {
|
|
230
|
+
const s3Path = this.prefix ? `s3://${this.bucket}/${this.prefix}` : `s3://${this.bucket}`;
|
|
231
|
+
for (const file of files) {
|
|
232
|
+
const relativePath = file.replace(this.workingDirectory + "/", "");
|
|
233
|
+
child_process.execFileSync(
|
|
234
|
+
"aws",
|
|
235
|
+
["s3", "cp", file, `${s3Path}/${relativePath}`, "--region", this.region],
|
|
236
|
+
{ stdio: "pipe" }
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
async cleanup() {
|
|
241
|
+
if (this.workingDirectory) {
|
|
242
|
+
fs.rmSync(this.workingDirectory, { recursive: true, force: true });
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
// src/match/storage/local.ts
|
|
250
|
+
var local_exports = {};
|
|
251
|
+
__export(local_exports, {
|
|
252
|
+
LocalStorage: () => LocalStorage
|
|
253
|
+
});
|
|
254
|
+
var LocalStorage;
|
|
255
|
+
var init_local = __esm({
|
|
256
|
+
"src/match/storage/local.ts"() {
|
|
257
|
+
LocalStorage = class {
|
|
258
|
+
workingDirectory;
|
|
259
|
+
constructor(params) {
|
|
260
|
+
this.workingDirectory = params.localPath ?? "";
|
|
261
|
+
}
|
|
262
|
+
async download() {
|
|
263
|
+
fs.mkdirSync(this.workingDirectory, { recursive: true });
|
|
264
|
+
return this.workingDirectory;
|
|
265
|
+
}
|
|
266
|
+
async saveChanges(_files, _message) {
|
|
267
|
+
}
|
|
268
|
+
async cleanup() {
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
function toPem(header, der) {
|
|
274
|
+
const b64 = der.toString("base64");
|
|
275
|
+
const lines = [];
|
|
276
|
+
for (let i = 0; i < b64.length; i += 64) lines.push(b64.slice(i, i + 64));
|
|
277
|
+
return `-----BEGIN ${header}-----
|
|
278
|
+
${lines.join("\n")}
|
|
279
|
+
-----END ${header}-----`;
|
|
280
|
+
}
|
|
281
|
+
async function generateCSR() {
|
|
282
|
+
const algorithm = { name: "ECDSA", namedCurve: "P-256" };
|
|
283
|
+
const keyPair = await crypto.webcrypto.subtle.generateKey(algorithm, true, ["sign", "verify"]);
|
|
284
|
+
const csr = await x509__namespace.Pkcs10CertificateRequestGenerator.create({
|
|
285
|
+
name: "CN=PEM",
|
|
286
|
+
keys: keyPair,
|
|
287
|
+
signingAlgorithm: { name: "ECDSA", hash: "SHA-256" }
|
|
288
|
+
});
|
|
289
|
+
const pkcs8 = await crypto.webcrypto.subtle.exportKey("pkcs8", keyPair.privateKey);
|
|
290
|
+
return {
|
|
291
|
+
csr: csr.toString("pem"),
|
|
292
|
+
privateKey: toPem("PRIVATE KEY", Buffer.from(pkcs8))
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
var init_csr = __esm({
|
|
296
|
+
"src/cert/csr.ts"() {
|
|
297
|
+
x509__namespace.cryptoProvider.set(crypto.webcrypto);
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
// src/cert/cert.ts
|
|
302
|
+
var cert_exports = {};
|
|
303
|
+
__export(cert_exports, {
|
|
304
|
+
createCertificate: () => createCertificate,
|
|
305
|
+
downloadCertificate: () => downloadCertificate,
|
|
306
|
+
findValidCertificates: () => findValidCertificates,
|
|
307
|
+
revokeCertificate: () => revokeCertificate,
|
|
308
|
+
revokeExpiredCertificates: () => revokeExpiredCertificates
|
|
309
|
+
});
|
|
310
|
+
function resolveCertificateTypes(options) {
|
|
311
|
+
if (options.type) return [options.type];
|
|
312
|
+
const platform = options.platform ?? "ios";
|
|
313
|
+
if (options.development) {
|
|
314
|
+
return platform === "macos" ? ["MAC_APP_DEVELOPMENT"] : ["IOS_DEVELOPMENT"];
|
|
315
|
+
}
|
|
316
|
+
return platform === "macos" ? ["MAC_APP_DISTRIBUTION"] : ["IOS_DISTRIBUTION"];
|
|
317
|
+
}
|
|
318
|
+
async function findValidCertificates(options) {
|
|
319
|
+
const types = resolveCertificateTypes(options);
|
|
320
|
+
const certs = await options.client.certificates.list({
|
|
321
|
+
filter: { certificateType: types },
|
|
322
|
+
limit: 200
|
|
323
|
+
});
|
|
324
|
+
const now = /* @__PURE__ */ new Date();
|
|
325
|
+
return certs.filter(
|
|
326
|
+
(c) => new Date(c.attributes.expirationDate) > now
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
async function createCertificate(options) {
|
|
330
|
+
if (!options.force) {
|
|
331
|
+
const existing = await findValidCertificates(options);
|
|
332
|
+
if (existing.length > 0) {
|
|
333
|
+
const cert2 = existing[0];
|
|
334
|
+
const content2 = Buffer.from(cert2.attributes.certificateContent, "base64");
|
|
335
|
+
const result2 = {
|
|
336
|
+
certificate: cert2,
|
|
337
|
+
privateKey: "",
|
|
338
|
+
certificateContent: content2
|
|
339
|
+
};
|
|
340
|
+
if (options.outputDir) {
|
|
341
|
+
await promises.mkdir(options.outputDir, { recursive: true });
|
|
342
|
+
const certPath = path.join(options.outputDir, `${cert2.id}.cer`);
|
|
343
|
+
await promises.writeFile(certPath, content2);
|
|
344
|
+
result2.certPath = certPath;
|
|
345
|
+
}
|
|
346
|
+
return result2;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
const types = resolveCertificateTypes(options);
|
|
350
|
+
const { csr, privateKey } = await generateCSR();
|
|
351
|
+
const cert = await options.client.certificates.create({
|
|
352
|
+
certificateType: types[0],
|
|
353
|
+
csrContent: csr
|
|
354
|
+
});
|
|
355
|
+
const content = Buffer.from(cert.attributes.certificateContent, "base64");
|
|
356
|
+
const result = {
|
|
357
|
+
certificate: cert,
|
|
358
|
+
privateKey,
|
|
359
|
+
certificateContent: content
|
|
360
|
+
};
|
|
361
|
+
if (options.outputDir) {
|
|
362
|
+
await promises.mkdir(options.outputDir, { recursive: true });
|
|
363
|
+
const certPath = path.join(options.outputDir, `${cert.id}.cer`);
|
|
364
|
+
await promises.writeFile(certPath, content);
|
|
365
|
+
result.certPath = certPath;
|
|
366
|
+
const keyPath = path.join(options.outputDir, `${cert.id}.p12`);
|
|
367
|
+
await promises.writeFile(keyPath, privateKey);
|
|
368
|
+
result.p12Path = keyPath;
|
|
369
|
+
}
|
|
370
|
+
if (options.keychainPath && process.platform === "darwin") {
|
|
371
|
+
await importToKeychain(
|
|
372
|
+
content,
|
|
373
|
+
options.keychainPath,
|
|
374
|
+
options.keychainPassword
|
|
375
|
+
);
|
|
376
|
+
}
|
|
377
|
+
return result;
|
|
378
|
+
}
|
|
379
|
+
async function revokeCertificate(client, id) {
|
|
380
|
+
await client.certificates.revoke(id);
|
|
381
|
+
}
|
|
382
|
+
async function downloadCertificate(client, id) {
|
|
383
|
+
const cert = await client.certificates.get(id);
|
|
384
|
+
return Buffer.from(cert.attributes.certificateContent, "base64");
|
|
385
|
+
}
|
|
386
|
+
async function revokeExpiredCertificates(options) {
|
|
387
|
+
const types = resolveCertificateTypes(options);
|
|
388
|
+
const certs = await options.client.certificates.list({
|
|
389
|
+
filter: { certificateType: types }
|
|
390
|
+
});
|
|
391
|
+
const now = /* @__PURE__ */ new Date();
|
|
392
|
+
let count = 0;
|
|
393
|
+
for (const cert of certs) {
|
|
394
|
+
if (new Date(cert.attributes.expirationDate) <= now) {
|
|
395
|
+
try {
|
|
396
|
+
await options.client.certificates.revoke(cert.id);
|
|
397
|
+
count++;
|
|
398
|
+
} catch {
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
return count;
|
|
403
|
+
}
|
|
404
|
+
async function importToKeychain(certData, keychainPath, keychainPassword) {
|
|
405
|
+
const { tmpdir: tmpdir4 } = await import('os');
|
|
406
|
+
const tempCertPath = path.join(tmpdir4(), `fastnode-cert-${Date.now()}.cer`);
|
|
407
|
+
await promises.writeFile(tempCertPath, certData);
|
|
408
|
+
try {
|
|
409
|
+
const args = [
|
|
410
|
+
"import",
|
|
411
|
+
tempCertPath,
|
|
412
|
+
"-k",
|
|
413
|
+
keychainPath,
|
|
414
|
+
"-T",
|
|
415
|
+
"/usr/bin/codesign",
|
|
416
|
+
"-T",
|
|
417
|
+
"/usr/bin/security"
|
|
418
|
+
];
|
|
419
|
+
await execFileAsync("security", args);
|
|
420
|
+
if (keychainPassword) {
|
|
421
|
+
await execFileAsync("security", [
|
|
422
|
+
"set-key-partition-list",
|
|
423
|
+
"-S",
|
|
424
|
+
"apple-tool:,apple:,codesign:",
|
|
425
|
+
"-s",
|
|
426
|
+
"-k",
|
|
427
|
+
keychainPassword,
|
|
428
|
+
keychainPath
|
|
429
|
+
]);
|
|
430
|
+
}
|
|
431
|
+
} finally {
|
|
432
|
+
const { unlink } = await import('fs/promises');
|
|
433
|
+
await unlink(tempCertPath).catch(() => {
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
var execFileAsync;
|
|
438
|
+
var init_cert = __esm({
|
|
439
|
+
"src/cert/cert.ts"() {
|
|
440
|
+
init_csr();
|
|
441
|
+
execFileAsync = util.promisify(child_process.execFile);
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
// src/sigh/index.ts
|
|
446
|
+
var sigh_exports = {};
|
|
447
|
+
__export(sigh_exports, {
|
|
448
|
+
createProfile: () => createProfile,
|
|
449
|
+
downloadProfile: () => downloadProfile,
|
|
450
|
+
findMatchingProfile: () => findMatchingProfile,
|
|
451
|
+
installProfile: () => installProfile
|
|
452
|
+
});
|
|
453
|
+
function resolveProfileType(options) {
|
|
454
|
+
if (options.profileType) return options.profileType;
|
|
455
|
+
const platform = options.platform ?? "ios";
|
|
456
|
+
const isDev = options.development ?? false;
|
|
457
|
+
const isAdhoc = options.adhoc ?? false;
|
|
458
|
+
const isInHouse = options.inHouse ?? false;
|
|
459
|
+
switch (platform) {
|
|
460
|
+
case "macos":
|
|
461
|
+
if (isDev) return "MAC_APP_DEVELOPMENT";
|
|
462
|
+
if (isInHouse) return "MAC_APP_INHOUSE";
|
|
463
|
+
return "MAC_APP_STORE";
|
|
464
|
+
case "tvos":
|
|
465
|
+
if (isDev) return "TVOS_APP_DEVELOPMENT";
|
|
466
|
+
if (isAdhoc) return "TVOS_APP_ADHOC";
|
|
467
|
+
if (isInHouse) return "TVOS_APP_INHOUSE";
|
|
468
|
+
return "TVOS_APP_STORE";
|
|
469
|
+
case "catalyst":
|
|
470
|
+
if (isDev) return "MAC_CATALYST_APP_DEVELOPMENT";
|
|
471
|
+
if (isInHouse) return "MAC_CATALYST_APP_INHOUSE";
|
|
472
|
+
return "MAC_CATALYST_APP_STORE";
|
|
473
|
+
default:
|
|
474
|
+
if (isDev) return "IOS_APP_DEVELOPMENT";
|
|
475
|
+
if (isAdhoc) return "IOS_APP_ADHOC";
|
|
476
|
+
if (isInHouse) return "IOS_APP_INHOUSE";
|
|
477
|
+
return "IOS_APP_STORE";
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
function certificateTypesForProfile(profileType) {
|
|
481
|
+
switch (profileType) {
|
|
482
|
+
case "IOS_APP_DEVELOPMENT":
|
|
483
|
+
case "TVOS_APP_DEVELOPMENT":
|
|
484
|
+
case "MAC_CATALYST_APP_DEVELOPMENT":
|
|
485
|
+
return ["IOS_DEVELOPMENT"];
|
|
486
|
+
case "MAC_APP_DEVELOPMENT":
|
|
487
|
+
return ["MAC_APP_DEVELOPMENT"];
|
|
488
|
+
case "IOS_APP_STORE":
|
|
489
|
+
case "IOS_APP_ADHOC":
|
|
490
|
+
case "TVOS_APP_STORE":
|
|
491
|
+
case "TVOS_APP_ADHOC":
|
|
492
|
+
case "MAC_CATALYST_APP_STORE":
|
|
493
|
+
return ["IOS_DISTRIBUTION"];
|
|
494
|
+
case "IOS_APP_INHOUSE":
|
|
495
|
+
case "TVOS_APP_INHOUSE":
|
|
496
|
+
case "MAC_CATALYST_APP_INHOUSE":
|
|
497
|
+
return ["IOS_DISTRIBUTION"];
|
|
498
|
+
case "MAC_APP_STORE":
|
|
499
|
+
case "MAC_APP_INHOUSE":
|
|
500
|
+
return ["MAC_APP_DISTRIBUTION"];
|
|
501
|
+
case "MAC_APP_DIRECT":
|
|
502
|
+
return ["DEVELOPER_ID_APPLICATION"];
|
|
503
|
+
default:
|
|
504
|
+
return ["IOS_DISTRIBUTION"];
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
function needsDevices(profileType) {
|
|
508
|
+
return profileType.includes("DEVELOPMENT") || profileType.includes("ADHOC");
|
|
509
|
+
}
|
|
510
|
+
function profileExtension(profileType) {
|
|
511
|
+
return profileType.startsWith("MAC_") && !profileType.includes("CATALYST") ? ".provisionprofile" : ".mobileprovision";
|
|
512
|
+
}
|
|
513
|
+
async function findMatchingProfile(options) {
|
|
514
|
+
const profileType = resolveProfileType(options);
|
|
515
|
+
const profiles = await options.client.profiles.list({
|
|
516
|
+
filter: { profileType },
|
|
517
|
+
include: "bundleId",
|
|
518
|
+
limit: 200
|
|
519
|
+
});
|
|
520
|
+
const now = /* @__PURE__ */ new Date();
|
|
521
|
+
for (const profile of profiles) {
|
|
522
|
+
const bundleIdRel = profile.relationships?.bundleId?.data;
|
|
523
|
+
if (bundleIdRel) {
|
|
524
|
+
const bundleId = await options.client.bundleIds.get(bundleIdRel.id);
|
|
525
|
+
if (bundleId.attributes.identifier !== options.bundleIdentifier) continue;
|
|
526
|
+
}
|
|
527
|
+
if (profile.attributes.profileState !== "ACTIVE") continue;
|
|
528
|
+
if (new Date(profile.attributes.expirationDate) <= now) continue;
|
|
529
|
+
if (options.profileName && profile.attributes.name !== options.profileName) {
|
|
530
|
+
continue;
|
|
531
|
+
}
|
|
532
|
+
return profile;
|
|
533
|
+
}
|
|
534
|
+
return null;
|
|
535
|
+
}
|
|
536
|
+
async function createProfile(options) {
|
|
537
|
+
const profileType = resolveProfileType(options);
|
|
538
|
+
if (options.force) {
|
|
539
|
+
const existing = await findMatchingProfile(options);
|
|
540
|
+
if (existing) {
|
|
541
|
+
await options.client.profiles.delete(existing.id);
|
|
542
|
+
}
|
|
543
|
+
} else {
|
|
544
|
+
const existing = await findMatchingProfile(options);
|
|
545
|
+
if (existing) {
|
|
546
|
+
return downloadAndReturn(options, existing);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
let bundleId = await options.client.bundleIds.find(options.bundleIdentifier);
|
|
550
|
+
if (!bundleId) {
|
|
551
|
+
throw new Error(
|
|
552
|
+
`Bundle ID '${options.bundleIdentifier}' not found. Register it first with produce.registerBundleId().`
|
|
553
|
+
);
|
|
554
|
+
}
|
|
555
|
+
const certTypes = certificateTypesForProfile(profileType);
|
|
556
|
+
let certificateIds = options.certificateIds;
|
|
557
|
+
if (!certificateIds || certificateIds.length === 0) {
|
|
558
|
+
const certs = await options.client.certificates.list({
|
|
559
|
+
filter: { certificateType: certTypes }
|
|
560
|
+
});
|
|
561
|
+
const now = /* @__PURE__ */ new Date();
|
|
562
|
+
const validCerts = certs.filter(
|
|
563
|
+
(c) => new Date(c.attributes.expirationDate) > now
|
|
564
|
+
);
|
|
565
|
+
if (validCerts.length === 0) {
|
|
566
|
+
throw new Error(
|
|
567
|
+
`No valid certificates found of type ${certTypes.join(", ")}. Create one first with cert.createCertificate().`
|
|
568
|
+
);
|
|
569
|
+
}
|
|
570
|
+
certificateIds = options.includeAllCertificates ? validCerts.map((c) => c.id) : [validCerts[0].id];
|
|
571
|
+
}
|
|
572
|
+
let deviceIds = options.deviceIds;
|
|
573
|
+
if (needsDevices(profileType) && (!deviceIds || deviceIds.length === 0)) {
|
|
574
|
+
const platform = options.platform === "macos" ? "MAC_OS" : options.platform === "tvos" ? "TVOS" : "IOS";
|
|
575
|
+
const devices = await options.client.devices.list({
|
|
576
|
+
filter: { platform, status: "ENABLED" }
|
|
577
|
+
});
|
|
578
|
+
deviceIds = devices.map((d) => d.id);
|
|
579
|
+
}
|
|
580
|
+
const profileName = options.profileName ?? `${profileType} ${options.bundleIdentifier} ${Date.now()}`;
|
|
581
|
+
const profile = await options.client.profiles.create({
|
|
582
|
+
name: profileName,
|
|
583
|
+
profileType,
|
|
584
|
+
bundleIdId: bundleId.id,
|
|
585
|
+
certificateIds,
|
|
586
|
+
deviceIds
|
|
587
|
+
});
|
|
588
|
+
return downloadAndReturn(options, profile);
|
|
589
|
+
}
|
|
590
|
+
async function downloadAndReturn(options, profile) {
|
|
591
|
+
const content = Buffer.from(profile.attributes.profileContent, "base64");
|
|
592
|
+
const profileType = resolveProfileType(options);
|
|
593
|
+
const ext = profileExtension(profileType);
|
|
594
|
+
const result = {
|
|
595
|
+
profile,
|
|
596
|
+
profileContent: content,
|
|
597
|
+
uuid: profile.attributes.uuid,
|
|
598
|
+
name: profile.attributes.name
|
|
599
|
+
};
|
|
600
|
+
if (options.outputDir) {
|
|
601
|
+
await promises.mkdir(options.outputDir, { recursive: true });
|
|
602
|
+
const filename = `${profileType}_${options.bundleIdentifier}${ext}`;
|
|
603
|
+
const filePath = path.join(options.outputDir, filename);
|
|
604
|
+
await promises.writeFile(filePath, content);
|
|
605
|
+
result.filePath = filePath;
|
|
606
|
+
}
|
|
607
|
+
if (!options.skipInstall && process.platform === "darwin") {
|
|
608
|
+
await installProfile(content, profile.attributes.uuid);
|
|
609
|
+
}
|
|
610
|
+
return result;
|
|
611
|
+
}
|
|
612
|
+
async function downloadProfile(client, id) {
|
|
613
|
+
const profile = await client.profiles.get(id);
|
|
614
|
+
return Buffer.from(profile.attributes.profileContent, "base64");
|
|
615
|
+
}
|
|
616
|
+
async function installProfile(profileContent, uuid) {
|
|
617
|
+
const legacyDir = path.join(
|
|
618
|
+
os.homedir(),
|
|
619
|
+
"Library",
|
|
620
|
+
"MobileDevice",
|
|
621
|
+
"Provisioning Profiles"
|
|
622
|
+
);
|
|
623
|
+
const xcode16Dir = path.join(
|
|
624
|
+
os.homedir(),
|
|
625
|
+
"Library",
|
|
626
|
+
"Developer",
|
|
627
|
+
"Xcode",
|
|
628
|
+
"UserData",
|
|
629
|
+
"Provisioning Profiles"
|
|
630
|
+
);
|
|
631
|
+
const filename = `${uuid}.mobileprovision`;
|
|
632
|
+
await promises.mkdir(legacyDir, { recursive: true });
|
|
633
|
+
const legacyPath = path.join(legacyDir, filename);
|
|
634
|
+
await promises.writeFile(legacyPath, profileContent);
|
|
635
|
+
try {
|
|
636
|
+
await promises.mkdir(xcode16Dir, { recursive: true });
|
|
637
|
+
await promises.writeFile(path.join(xcode16Dir, filename), profileContent);
|
|
638
|
+
} catch {
|
|
639
|
+
}
|
|
640
|
+
return legacyPath;
|
|
641
|
+
}
|
|
642
|
+
var init_sigh = __esm({
|
|
643
|
+
"src/sigh/index.ts"() {
|
|
644
|
+
}
|
|
645
|
+
});
|
|
646
|
+
|
|
647
|
+
// src/match/storage/index.ts
|
|
648
|
+
async function createStorage(params) {
|
|
649
|
+
switch (params.mode) {
|
|
650
|
+
case "git": {
|
|
651
|
+
const { GitStorage: GitStorage2 } = await Promise.resolve().then(() => (init_git(), git_exports));
|
|
652
|
+
return new GitStorage2(params);
|
|
653
|
+
}
|
|
654
|
+
case "s3": {
|
|
655
|
+
const { S3Storage: S3Storage2 } = await Promise.resolve().then(() => (init_s3(), s3_exports));
|
|
656
|
+
return new S3Storage2(params);
|
|
657
|
+
}
|
|
658
|
+
case "local": {
|
|
659
|
+
const { LocalStorage: LocalStorage2 } = await Promise.resolve().then(() => (init_local(), local_exports));
|
|
660
|
+
return new LocalStorage2(params);
|
|
661
|
+
}
|
|
662
|
+
default:
|
|
663
|
+
throw new Error(`Unknown storage mode: ${params.mode}`);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
var V2_PREFIX = "match_encrypted_v2__";
|
|
667
|
+
var V1_PREFIX = "Salted__";
|
|
668
|
+
var PBKDF2_ITERATIONS = 1e4;
|
|
669
|
+
var PBKDF2_HASH = "sha256";
|
|
670
|
+
var PBKDF2_KEY_LEN = 32 + 12 + 24;
|
|
671
|
+
var ENCRYPTABLE_EXTENSIONS = [".cer", ".p12", ".mobileprovision", ".provisionprofile", ".pkey", ".pem"];
|
|
672
|
+
function encryptV2(data, password) {
|
|
673
|
+
const salt = crypto.randomBytes(8);
|
|
674
|
+
const derived = crypto.pbkdf2Sync(password, salt, PBKDF2_ITERATIONS, PBKDF2_KEY_LEN, PBKDF2_HASH);
|
|
675
|
+
const key = derived.subarray(0, 32);
|
|
676
|
+
const iv = derived.subarray(32, 44);
|
|
677
|
+
const authData = derived.subarray(44, 68);
|
|
678
|
+
const cipher = crypto.createCipheriv("aes-256-gcm", key, iv);
|
|
679
|
+
cipher.setAAD(authData);
|
|
680
|
+
const encrypted = Buffer.concat([cipher.update(data), cipher.final()]);
|
|
681
|
+
const authTag = cipher.getAuthTag();
|
|
682
|
+
const prefix = Buffer.from(V2_PREFIX, "utf-8");
|
|
683
|
+
const result = Buffer.concat([prefix, salt, authTag, encrypted]);
|
|
684
|
+
return Buffer.from(result.toString("base64"));
|
|
685
|
+
}
|
|
686
|
+
function decryptV2(data, password) {
|
|
687
|
+
const raw = Buffer.from(data.toString("utf-8"), "base64");
|
|
688
|
+
const prefixLen = Buffer.from(V2_PREFIX, "utf-8").length;
|
|
689
|
+
const salt = raw.subarray(prefixLen, prefixLen + 8);
|
|
690
|
+
const authTag = raw.subarray(prefixLen + 8, prefixLen + 24);
|
|
691
|
+
const ciphertext = raw.subarray(prefixLen + 24);
|
|
692
|
+
const derived = crypto.pbkdf2Sync(password, salt, PBKDF2_ITERATIONS, PBKDF2_KEY_LEN, PBKDF2_HASH);
|
|
693
|
+
const key = derived.subarray(0, 32);
|
|
694
|
+
const iv = derived.subarray(32, 44);
|
|
695
|
+
const authData = derived.subarray(44, 68);
|
|
696
|
+
const decipher = crypto.createDecipheriv("aes-256-gcm", key, iv);
|
|
697
|
+
decipher.setAAD(authData);
|
|
698
|
+
decipher.setAuthTag(authTag);
|
|
699
|
+
return Buffer.concat([decipher.update(ciphertext), decipher.final()]);
|
|
700
|
+
}
|
|
701
|
+
function evpBytesToKey(password, salt, keyLen, ivLen, hashAlg) {
|
|
702
|
+
const target = keyLen + ivLen;
|
|
703
|
+
const result = [];
|
|
704
|
+
let total = 0;
|
|
705
|
+
let prev = Buffer.alloc(0);
|
|
706
|
+
while (total < target) {
|
|
707
|
+
const input = Buffer.concat([prev, Buffer.from(password, "utf-8"), salt]);
|
|
708
|
+
prev = crypto.createHash(hashAlg).update(input).digest();
|
|
709
|
+
result.push(prev);
|
|
710
|
+
total += prev.length;
|
|
711
|
+
}
|
|
712
|
+
const derived = Buffer.concat(result);
|
|
713
|
+
return {
|
|
714
|
+
key: derived.subarray(0, keyLen),
|
|
715
|
+
iv: derived.subarray(keyLen, keyLen + ivLen)
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
function decryptV1(data, password) {
|
|
719
|
+
const raw = Buffer.from(data.toString("utf-8"), "base64");
|
|
720
|
+
const saltHeader = raw.subarray(0, 8).toString("utf-8");
|
|
721
|
+
if (saltHeader !== V1_PREFIX) {
|
|
722
|
+
throw new Error("Invalid V1 encrypted data: missing Salted__ header");
|
|
723
|
+
}
|
|
724
|
+
const salt = raw.subarray(8, 16);
|
|
725
|
+
const ciphertext = raw.subarray(16);
|
|
726
|
+
for (const hashAlg of ["md5", "sha256"]) {
|
|
727
|
+
try {
|
|
728
|
+
const { key, iv } = evpBytesToKey(password, salt, 32, 16, hashAlg);
|
|
729
|
+
const decipher = crypto.createDecipheriv("aes-256-cbc", key, iv);
|
|
730
|
+
return Buffer.concat([decipher.update(ciphertext), decipher.final()]);
|
|
731
|
+
} catch {
|
|
732
|
+
continue;
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
throw new Error("Failed to decrypt V1 data with both MD5 and SHA256");
|
|
736
|
+
}
|
|
737
|
+
function decrypt(data, password) {
|
|
738
|
+
const str = data.toString("utf-8");
|
|
739
|
+
const decoded = Buffer.from(str, "base64").toString("utf-8");
|
|
740
|
+
if (decoded.startsWith(V2_PREFIX)) {
|
|
741
|
+
return decryptV2(data, password);
|
|
742
|
+
}
|
|
743
|
+
if (decoded.startsWith(V1_PREFIX)) {
|
|
744
|
+
return decryptV1(data, password);
|
|
745
|
+
}
|
|
746
|
+
try {
|
|
747
|
+
return decryptV2(data, password);
|
|
748
|
+
} catch {
|
|
749
|
+
return decryptV1(data, password);
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
function encrypt(data, password) {
|
|
753
|
+
return encryptV2(data, password);
|
|
754
|
+
}
|
|
755
|
+
function isEncryptable(filePath) {
|
|
756
|
+
return ENCRYPTABLE_EXTENSIONS.includes(path.extname(filePath).toLowerCase());
|
|
757
|
+
}
|
|
758
|
+
async function decryptFiles(dir, password) {
|
|
759
|
+
const entries = await promises.readdir(dir, { withFileTypes: true });
|
|
760
|
+
for (const entry of entries) {
|
|
761
|
+
const fullPath = path.join(dir, entry.name);
|
|
762
|
+
if (entry.isDirectory()) {
|
|
763
|
+
await decryptFiles(fullPath, password);
|
|
764
|
+
} else if (isEncryptable(fullPath)) {
|
|
765
|
+
const data = await promises.readFile(fullPath);
|
|
766
|
+
try {
|
|
767
|
+
const decrypted = decrypt(data, password);
|
|
768
|
+
await promises.writeFile(fullPath, decrypted);
|
|
769
|
+
} catch {
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
async function encryptFiles(dir, password) {
|
|
775
|
+
const entries = await promises.readdir(dir, { withFileTypes: true });
|
|
776
|
+
for (const entry of entries) {
|
|
777
|
+
const fullPath = path.join(dir, entry.name);
|
|
778
|
+
if (entry.isDirectory()) {
|
|
779
|
+
await encryptFiles(fullPath, password);
|
|
780
|
+
} else if (isEncryptable(fullPath)) {
|
|
781
|
+
const data = await promises.readFile(fullPath);
|
|
782
|
+
const encrypted = encrypt(data, password);
|
|
783
|
+
await promises.writeFile(fullPath, encrypted);
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
// src/match/index.ts
|
|
789
|
+
function profileTypeForMatch(type, platform) {
|
|
790
|
+
const p = platform ?? "ios";
|
|
791
|
+
switch (type) {
|
|
792
|
+
case "development":
|
|
793
|
+
if (p === "macos") return "MAC_APP_DEVELOPMENT";
|
|
794
|
+
if (p === "tvos") return "TVOS_APP_DEVELOPMENT";
|
|
795
|
+
if (p === "catalyst") return "MAC_CATALYST_APP_DEVELOPMENT";
|
|
796
|
+
return "IOS_APP_DEVELOPMENT";
|
|
797
|
+
case "adhoc":
|
|
798
|
+
if (p === "tvos") return "TVOS_APP_ADHOC";
|
|
799
|
+
return "IOS_APP_ADHOC";
|
|
800
|
+
case "enterprise":
|
|
801
|
+
if (p === "macos") return "MAC_APP_INHOUSE";
|
|
802
|
+
if (p === "tvos") return "TVOS_APP_INHOUSE";
|
|
803
|
+
if (p === "catalyst") return "MAC_CATALYST_APP_INHOUSE";
|
|
804
|
+
return "IOS_APP_INHOUSE";
|
|
805
|
+
default:
|
|
806
|
+
if (p === "macos") return "MAC_APP_STORE";
|
|
807
|
+
if (p === "tvos") return "TVOS_APP_STORE";
|
|
808
|
+
if (p === "catalyst") return "MAC_CATALYST_APP_STORE";
|
|
809
|
+
return "IOS_APP_STORE";
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
function certTypeForMatch(type, platform) {
|
|
813
|
+
const p = platform ?? "ios";
|
|
814
|
+
if (type === "development") {
|
|
815
|
+
return p === "macos" ? "MAC_APP_DEVELOPMENT" : "IOS_DEVELOPMENT";
|
|
816
|
+
}
|
|
817
|
+
return p === "macos" ? "MAC_APP_DISTRIBUTION" : "IOS_DISTRIBUTION";
|
|
818
|
+
}
|
|
819
|
+
function certSubdir(type) {
|
|
820
|
+
return type === "development" ? "development" : "distribution";
|
|
821
|
+
}
|
|
822
|
+
function profileSubdir(type) {
|
|
823
|
+
switch (type) {
|
|
824
|
+
case "development":
|
|
825
|
+
return "development";
|
|
826
|
+
case "adhoc":
|
|
827
|
+
return "adhoc";
|
|
828
|
+
case "enterprise":
|
|
829
|
+
return "enterprise";
|
|
830
|
+
default:
|
|
831
|
+
return "appstore";
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
async function syncSigningAssets(options) {
|
|
835
|
+
const password = options.password ?? process.env.MATCH_PASSWORD ?? "";
|
|
836
|
+
if (!password) {
|
|
837
|
+
throw new Error("Match password is required. Set MATCH_PASSWORD or pass password option.");
|
|
838
|
+
}
|
|
839
|
+
const storage = await createStorage({
|
|
840
|
+
mode: options.storageMode,
|
|
841
|
+
gitUrl: options.gitUrl,
|
|
842
|
+
gitBranch: options.gitBranch,
|
|
843
|
+
gitPrivateKey: options.gitPrivateKey,
|
|
844
|
+
gitPrivateKeyContent: options.gitPrivateKeyContent,
|
|
845
|
+
gitBasicAuth: options.gitBasicAuth,
|
|
846
|
+
gitBearerToken: options.gitBearerToken,
|
|
847
|
+
gitUserName: options.gitUserName,
|
|
848
|
+
gitUserEmail: options.gitUserEmail,
|
|
849
|
+
shallowClone: options.shallowClone,
|
|
850
|
+
s3Bucket: options.s3Bucket,
|
|
851
|
+
s3Region: options.s3Region,
|
|
852
|
+
localPath: options.localPath,
|
|
853
|
+
teamId: options.teamId
|
|
854
|
+
});
|
|
855
|
+
const workDir = await storage.download();
|
|
856
|
+
await decryptFiles(workDir, password);
|
|
857
|
+
const certificates = [];
|
|
858
|
+
const profiles = [];
|
|
859
|
+
const filesToCommit = [];
|
|
860
|
+
const certDir = path.join(workDir, "certs", certSubdir(options.type));
|
|
861
|
+
const profileDir = path.join(workDir, "profiles", profileSubdir(options.type));
|
|
862
|
+
for (const appId of options.appIdentifiers) {
|
|
863
|
+
let certResult = null;
|
|
864
|
+
const certFiles = fs.existsSync(certDir) ? await findFilesWithExt(certDir, ".cer") : [];
|
|
865
|
+
if (certFiles.length > 0 && !options.force) {
|
|
866
|
+
const certContent = await promises.readFile(certFiles[0]);
|
|
867
|
+
certResult = {
|
|
868
|
+
certificate: null,
|
|
869
|
+
// Stored cert doesn't have full API object
|
|
870
|
+
privateKey: "",
|
|
871
|
+
certificateContent: certContent,
|
|
872
|
+
certPath: certFiles[0]
|
|
873
|
+
};
|
|
874
|
+
} else if (!options.readonly) {
|
|
875
|
+
const { createCertificate: createCertificate2 } = await Promise.resolve().then(() => (init_cert(), cert_exports));
|
|
876
|
+
certResult = await createCertificate2({
|
|
877
|
+
client: options.client,
|
|
878
|
+
type: certTypeForMatch(options.type, options.platform),
|
|
879
|
+
outputDir: certDir,
|
|
880
|
+
keychainPath: options.keychainName,
|
|
881
|
+
keychainPassword: options.keychainPassword
|
|
882
|
+
});
|
|
883
|
+
if (certResult.certPath) filesToCommit.push(certResult.certPath);
|
|
884
|
+
if (certResult.p12Path) filesToCommit.push(certResult.p12Path);
|
|
885
|
+
}
|
|
886
|
+
if (certResult) certificates.push(certResult);
|
|
887
|
+
const profileFiles = fs.existsSync(profileDir) ? await findFilesWithExt(profileDir, ".mobileprovision") : [];
|
|
888
|
+
const matchingProfile = profileFiles.find((f) => f.includes(appId));
|
|
889
|
+
if (matchingProfile && !options.force) {
|
|
890
|
+
const profileContent = await promises.readFile(matchingProfile);
|
|
891
|
+
profiles.push({
|
|
892
|
+
profile: null,
|
|
893
|
+
profileContent,
|
|
894
|
+
uuid: "",
|
|
895
|
+
name: "",
|
|
896
|
+
filePath: matchingProfile
|
|
897
|
+
});
|
|
898
|
+
} else if (!options.readonly) {
|
|
899
|
+
const { createProfile: createProfile2 } = await Promise.resolve().then(() => (init_sigh(), sigh_exports));
|
|
900
|
+
const profileType = profileTypeForMatch(options.type, options.platform);
|
|
901
|
+
const sighResult = await createProfile2({
|
|
902
|
+
client: options.client,
|
|
903
|
+
bundleIdentifier: appId,
|
|
904
|
+
profileType,
|
|
905
|
+
outputDir: profileDir,
|
|
906
|
+
skipInstall: false
|
|
907
|
+
});
|
|
908
|
+
if (sighResult.filePath) filesToCommit.push(sighResult.filePath);
|
|
909
|
+
profiles.push(sighResult);
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
if (filesToCommit.length > 0 && !options.readonly) {
|
|
913
|
+
await encryptFiles(workDir, password);
|
|
914
|
+
const appList = options.appIdentifiers.join(", ");
|
|
915
|
+
const message = `[fastlane-match] Updated ${options.type} and profile for ${appList}`;
|
|
916
|
+
await storage.saveChanges(filesToCommit, message);
|
|
917
|
+
}
|
|
918
|
+
await storage.cleanup();
|
|
919
|
+
return { certificates, profiles };
|
|
920
|
+
}
|
|
921
|
+
async function findFilesWithExt(dir, ext) {
|
|
922
|
+
const entries = await promises.readdir(dir, { withFileTypes: true });
|
|
923
|
+
const results = [];
|
|
924
|
+
for (const entry of entries) {
|
|
925
|
+
const fullPath = path.join(dir, entry.name);
|
|
926
|
+
if (!entry.isDirectory() && path.extname(entry.name) === ext) {
|
|
927
|
+
results.push(fullPath);
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
return results;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
exports.decrypt = decrypt;
|
|
934
|
+
exports.decryptFiles = decryptFiles;
|
|
935
|
+
exports.decryptV1 = decryptV1;
|
|
936
|
+
exports.decryptV2 = decryptV2;
|
|
937
|
+
exports.encrypt = encrypt;
|
|
938
|
+
exports.encryptFiles = encryptFiles;
|
|
939
|
+
exports.encryptV2 = encryptV2;
|
|
940
|
+
exports.syncSigningAssets = syncSigningAssets;
|
|
941
|
+
//# sourceMappingURL=index.cjs.map
|
|
942
|
+
//# sourceMappingURL=index.cjs.map
|