@solana-mobile/dapp-store-publishing-tools 0.16.0 → 1.0.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/lib/CoreUtils.js +0 -3
- package/lib/index.js +1 -0
- package/lib/portal/attestation.js +189 -0
- package/lib/portal/compat.js +3 -0
- package/lib/portal/index.js +5 -0
- package/lib/portal/signer.js +432 -0
- package/lib/portal/types.js +1 -0
- package/lib/portal/workflow/contracts.js +1 -0
- package/lib/portal/workflow/execution.js +493 -0
- package/lib/portal/workflow/ingestion.js +265 -0
- package/lib/portal/workflow/lifecycle.js +616 -0
- package/lib/portal/workflow/logging.js +8 -0
- package/lib/portal/workflow/source/files.js +304 -0
- package/lib/portal/workflow/source/preparation.js +318 -0
- package/lib/portal/workflow/state/bundle.js +260 -0
- package/lib/portal/workflow/state/checkpoints.js +53 -0
- package/lib/portal/workflow/state/session.js +100 -0
- package/lib/portal/workflow.js +1 -0
- package/lib/publish/PublishCoreAttestation.js +18 -17
- package/lib/publish/PublishCoreRemove.js +7 -89
- package/lib/publish/PublishCoreSubmit.js +7 -117
- package/lib/publish/PublishCoreSupport.js +7 -86
- package/lib/publish/PublishCoreUpdate.js +7 -117
- package/lib/publish/index.js +1 -0
- package/lib/schemas/releaseJsonMetadata.json +1 -2
- package/package.json +2 -4
- package/src/CoreUtils.ts +0 -6
- package/src/index.ts +1 -0
- package/src/portal/attestation.ts +76 -0
- package/src/portal/compat.ts +5 -0
- package/src/portal/index.ts +5 -0
- package/src/portal/signer.ts +327 -0
- package/src/portal/types.ts +447 -0
- package/src/portal/workflow/contracts.ts +108 -0
- package/src/portal/workflow/execution.ts +412 -0
- package/src/portal/workflow/ingestion.ts +187 -0
- package/src/portal/workflow/lifecycle.ts +435 -0
- package/src/portal/workflow/logging.ts +17 -0
- package/src/portal/workflow/source/files.ts +49 -0
- package/src/portal/workflow/source/preparation.ts +189 -0
- package/src/portal/workflow/state/bundle.ts +193 -0
- package/src/portal/workflow/state/checkpoints.ts +70 -0
- package/src/portal/workflow/state/session.ts +87 -0
- package/src/portal/workflow.ts +9 -0
- package/src/publish/PublishCoreAttestation.ts +21 -26
- package/src/publish/PublishCoreRemove.ts +13 -109
- package/src/publish/PublishCoreSubmit.ts +18 -150
- package/src/publish/PublishCoreSupport.ts +13 -102
- package/src/publish/PublishCoreUpdate.ts +17 -155
- package/src/publish/index.ts +2 -1
- package/src/schemas/releaseJsonMetadata.json +1 -2
- package/lib/publish/dapp_publisher_portal.js +0 -206
- package/src/publish/dapp_publisher_portal.ts +0 -81
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
function _async_iterator(iterable) {
|
|
2
|
+
var method, async, sync, retry = 2;
|
|
3
|
+
for("undefined" != typeof Symbol && (async = Symbol.asyncIterator, sync = Symbol.iterator); retry--;){
|
|
4
|
+
if (async && null != (method = iterable[async])) return method.call(iterable);
|
|
5
|
+
if (sync && null != (method = iterable[sync])) return new AsyncFromSyncIterator(method.call(iterable));
|
|
6
|
+
async = "@@asyncIterator", sync = "@@iterator";
|
|
7
|
+
}
|
|
8
|
+
throw new TypeError("Object is not async iterable");
|
|
9
|
+
}
|
|
10
|
+
function AsyncFromSyncIterator(s) {
|
|
11
|
+
function AsyncFromSyncIteratorContinuation(r) {
|
|
12
|
+
if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object."));
|
|
13
|
+
var done = r.done;
|
|
14
|
+
return Promise.resolve(r.value).then(function(value) {
|
|
15
|
+
return {
|
|
16
|
+
value: value,
|
|
17
|
+
done: done
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return AsyncFromSyncIterator = function(s) {
|
|
22
|
+
this.s = s, this.n = s.next;
|
|
23
|
+
}, AsyncFromSyncIterator.prototype = {
|
|
24
|
+
s: null,
|
|
25
|
+
n: null,
|
|
26
|
+
next: function() {
|
|
27
|
+
return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
|
|
28
|
+
},
|
|
29
|
+
return: function(value) {
|
|
30
|
+
var ret = this.s.return;
|
|
31
|
+
return void 0 === ret ? Promise.resolve({
|
|
32
|
+
value: value,
|
|
33
|
+
done: !0
|
|
34
|
+
}) : AsyncFromSyncIteratorContinuation(ret.apply(this.s, arguments));
|
|
35
|
+
},
|
|
36
|
+
throw: function(value) {
|
|
37
|
+
var thr = this.s.return;
|
|
38
|
+
return void 0 === thr ? Promise.reject(value) : AsyncFromSyncIteratorContinuation(thr.apply(this.s, arguments));
|
|
39
|
+
}
|
|
40
|
+
}, new AsyncFromSyncIterator(s);
|
|
41
|
+
}
|
|
42
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
43
|
+
try {
|
|
44
|
+
var info = gen[key](arg);
|
|
45
|
+
var value = info.value;
|
|
46
|
+
} catch (error) {
|
|
47
|
+
reject(error);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (info.done) {
|
|
51
|
+
resolve(value);
|
|
52
|
+
} else {
|
|
53
|
+
Promise.resolve(value).then(_next, _throw);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function _async_to_generator(fn) {
|
|
57
|
+
return function() {
|
|
58
|
+
var self = this, args = arguments;
|
|
59
|
+
return new Promise(function(resolve, reject) {
|
|
60
|
+
var gen = fn.apply(self, args);
|
|
61
|
+
function _next(value) {
|
|
62
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
63
|
+
}
|
|
64
|
+
function _throw(err) {
|
|
65
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
66
|
+
}
|
|
67
|
+
_next(undefined);
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function _instanceof(left, right) {
|
|
72
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
73
|
+
return !!right[Symbol.hasInstance](left);
|
|
74
|
+
} else {
|
|
75
|
+
return left instanceof right;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function _type_of(obj) {
|
|
79
|
+
"@swc/helpers - typeof";
|
|
80
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
81
|
+
}
|
|
82
|
+
function _ts_generator(thisArg, body) {
|
|
83
|
+
var f, y, t, _ = {
|
|
84
|
+
label: 0,
|
|
85
|
+
sent: function() {
|
|
86
|
+
if (t[0] & 1) throw t[1];
|
|
87
|
+
return t[1];
|
|
88
|
+
},
|
|
89
|
+
trys: [],
|
|
90
|
+
ops: []
|
|
91
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
92
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
93
|
+
return this;
|
|
94
|
+
}), g;
|
|
95
|
+
function verb(n) {
|
|
96
|
+
return function(v) {
|
|
97
|
+
return step([
|
|
98
|
+
n,
|
|
99
|
+
v
|
|
100
|
+
]);
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function step(op) {
|
|
104
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
105
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
106
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
107
|
+
if (y = 0, t) op = [
|
|
108
|
+
op[0] & 2,
|
|
109
|
+
t.value
|
|
110
|
+
];
|
|
111
|
+
switch(op[0]){
|
|
112
|
+
case 0:
|
|
113
|
+
case 1:
|
|
114
|
+
t = op;
|
|
115
|
+
break;
|
|
116
|
+
case 4:
|
|
117
|
+
_.label++;
|
|
118
|
+
return {
|
|
119
|
+
value: op[1],
|
|
120
|
+
done: false
|
|
121
|
+
};
|
|
122
|
+
case 5:
|
|
123
|
+
_.label++;
|
|
124
|
+
y = op[1];
|
|
125
|
+
op = [
|
|
126
|
+
0
|
|
127
|
+
];
|
|
128
|
+
continue;
|
|
129
|
+
case 7:
|
|
130
|
+
op = _.ops.pop();
|
|
131
|
+
_.trys.pop();
|
|
132
|
+
continue;
|
|
133
|
+
default:
|
|
134
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
135
|
+
_ = 0;
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
139
|
+
_.label = op[1];
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
143
|
+
_.label = t[1];
|
|
144
|
+
t = op;
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
if (t && _.label < t[2]) {
|
|
148
|
+
_.label = t[2];
|
|
149
|
+
_.ops.push(op);
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
if (t[2]) _.ops.pop();
|
|
153
|
+
_.trys.pop();
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
op = body.call(thisArg, _);
|
|
157
|
+
} catch (e) {
|
|
158
|
+
op = [
|
|
159
|
+
6,
|
|
160
|
+
e
|
|
161
|
+
];
|
|
162
|
+
y = 0;
|
|
163
|
+
} finally{
|
|
164
|
+
f = t = 0;
|
|
165
|
+
}
|
|
166
|
+
if (op[0] & 5) throw op[1];
|
|
167
|
+
return {
|
|
168
|
+
value: op[0] ? op[1] : void 0,
|
|
169
|
+
done: true
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
import { createHash } from "node:crypto";
|
|
174
|
+
import { createReadStream } from "node:fs";
|
|
175
|
+
import { basename } from "node:path";
|
|
176
|
+
export function ensureApkFileName(fileName) {
|
|
177
|
+
return /\.apk$/i.test(fileName) ? fileName : "".concat(fileName, ".apk");
|
|
178
|
+
}
|
|
179
|
+
export function inferFileNameFromUrl(url) {
|
|
180
|
+
try {
|
|
181
|
+
var pathname = new URL(url).pathname;
|
|
182
|
+
var fileName = basename(pathname);
|
|
183
|
+
return fileName.length > 0 ? fileName : "release.apk";
|
|
184
|
+
} catch (e) {
|
|
185
|
+
return "release.apk";
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
export function normalizeLocalFileAccessError(filePath, error) {
|
|
189
|
+
var code = error && (typeof error === "undefined" ? "undefined" : _type_of(error)) === "object" && "code" in error ? String(error.code || "") : "";
|
|
190
|
+
if (code === "EPERM" || code === "EACCES") {
|
|
191
|
+
return new Error("Cannot read local APK at ".concat(filePath, ". macOS denied access to this location (").concat(code, "). Move the APK out of Downloads into your workspace or another accessible folder, or grant this app Full Disk Access, then retry."));
|
|
192
|
+
}
|
|
193
|
+
return _instanceof(error, Error) ? error : new Error(String(error));
|
|
194
|
+
}
|
|
195
|
+
export function hashFileSha256(filePath) {
|
|
196
|
+
return _async_to_generator(function() {
|
|
197
|
+
var hash, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, chunk, err, error;
|
|
198
|
+
return _ts_generator(this, function(_state) {
|
|
199
|
+
switch(_state.label){
|
|
200
|
+
case 0:
|
|
201
|
+
hash = createHash("sha256");
|
|
202
|
+
_state.label = 1;
|
|
203
|
+
case 1:
|
|
204
|
+
_state.trys.push([
|
|
205
|
+
1,
|
|
206
|
+
14,
|
|
207
|
+
,
|
|
208
|
+
15
|
|
209
|
+
]);
|
|
210
|
+
_iteratorAbruptCompletion = false, _didIteratorError = false;
|
|
211
|
+
_state.label = 2;
|
|
212
|
+
case 2:
|
|
213
|
+
_state.trys.push([
|
|
214
|
+
2,
|
|
215
|
+
7,
|
|
216
|
+
8,
|
|
217
|
+
13
|
|
218
|
+
]);
|
|
219
|
+
_iterator = _async_iterator(createReadStream(filePath));
|
|
220
|
+
_state.label = 3;
|
|
221
|
+
case 3:
|
|
222
|
+
return [
|
|
223
|
+
4,
|
|
224
|
+
_iterator.next()
|
|
225
|
+
];
|
|
226
|
+
case 4:
|
|
227
|
+
if (!(_iteratorAbruptCompletion = !(_step = _state.sent()).done)) return [
|
|
228
|
+
3,
|
|
229
|
+
6
|
|
230
|
+
];
|
|
231
|
+
_value = _step.value;
|
|
232
|
+
chunk = _value;
|
|
233
|
+
hash.update(chunk);
|
|
234
|
+
_state.label = 5;
|
|
235
|
+
case 5:
|
|
236
|
+
_iteratorAbruptCompletion = false;
|
|
237
|
+
return [
|
|
238
|
+
3,
|
|
239
|
+
3
|
|
240
|
+
];
|
|
241
|
+
case 6:
|
|
242
|
+
return [
|
|
243
|
+
3,
|
|
244
|
+
13
|
|
245
|
+
];
|
|
246
|
+
case 7:
|
|
247
|
+
err = _state.sent();
|
|
248
|
+
_didIteratorError = true;
|
|
249
|
+
_iteratorError = err;
|
|
250
|
+
return [
|
|
251
|
+
3,
|
|
252
|
+
13
|
|
253
|
+
];
|
|
254
|
+
case 8:
|
|
255
|
+
_state.trys.push([
|
|
256
|
+
8,
|
|
257
|
+
,
|
|
258
|
+
11,
|
|
259
|
+
12
|
|
260
|
+
]);
|
|
261
|
+
if (!(_iteratorAbruptCompletion && _iterator.return != null)) return [
|
|
262
|
+
3,
|
|
263
|
+
10
|
|
264
|
+
];
|
|
265
|
+
return [
|
|
266
|
+
4,
|
|
267
|
+
_iterator.return()
|
|
268
|
+
];
|
|
269
|
+
case 9:
|
|
270
|
+
_state.sent();
|
|
271
|
+
_state.label = 10;
|
|
272
|
+
case 10:
|
|
273
|
+
return [
|
|
274
|
+
3,
|
|
275
|
+
12
|
|
276
|
+
];
|
|
277
|
+
case 11:
|
|
278
|
+
if (_didIteratorError) {
|
|
279
|
+
throw _iteratorError;
|
|
280
|
+
}
|
|
281
|
+
return [
|
|
282
|
+
7
|
|
283
|
+
];
|
|
284
|
+
case 12:
|
|
285
|
+
return [
|
|
286
|
+
7
|
|
287
|
+
];
|
|
288
|
+
case 13:
|
|
289
|
+
return [
|
|
290
|
+
3,
|
|
291
|
+
15
|
|
292
|
+
];
|
|
293
|
+
case 14:
|
|
294
|
+
error = _state.sent();
|
|
295
|
+
throw normalizeLocalFileAccessError(filePath, error);
|
|
296
|
+
case 15:
|
|
297
|
+
return [
|
|
298
|
+
2,
|
|
299
|
+
hash.digest("hex")
|
|
300
|
+
];
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
})();
|
|
304
|
+
}
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2
|
+
try {
|
|
3
|
+
var info = gen[key](arg);
|
|
4
|
+
var value = info.value;
|
|
5
|
+
} catch (error) {
|
|
6
|
+
reject(error);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (info.done) {
|
|
10
|
+
resolve(value);
|
|
11
|
+
} else {
|
|
12
|
+
Promise.resolve(value).then(_next, _throw);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function _async_to_generator(fn) {
|
|
16
|
+
return function() {
|
|
17
|
+
var self = this, args = arguments;
|
|
18
|
+
return new Promise(function(resolve, reject) {
|
|
19
|
+
var gen = fn.apply(self, args);
|
|
20
|
+
function _next(value) {
|
|
21
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
22
|
+
}
|
|
23
|
+
function _throw(err) {
|
|
24
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
25
|
+
}
|
|
26
|
+
_next(undefined);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function _ts_generator(thisArg, body) {
|
|
31
|
+
var f, y, t, _ = {
|
|
32
|
+
label: 0,
|
|
33
|
+
sent: function() {
|
|
34
|
+
if (t[0] & 1) throw t[1];
|
|
35
|
+
return t[1];
|
|
36
|
+
},
|
|
37
|
+
trys: [],
|
|
38
|
+
ops: []
|
|
39
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
40
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
41
|
+
return this;
|
|
42
|
+
}), g;
|
|
43
|
+
function verb(n) {
|
|
44
|
+
return function(v) {
|
|
45
|
+
return step([
|
|
46
|
+
n,
|
|
47
|
+
v
|
|
48
|
+
]);
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function step(op) {
|
|
52
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
53
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
54
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
55
|
+
if (y = 0, t) op = [
|
|
56
|
+
op[0] & 2,
|
|
57
|
+
t.value
|
|
58
|
+
];
|
|
59
|
+
switch(op[0]){
|
|
60
|
+
case 0:
|
|
61
|
+
case 1:
|
|
62
|
+
t = op;
|
|
63
|
+
break;
|
|
64
|
+
case 4:
|
|
65
|
+
_.label++;
|
|
66
|
+
return {
|
|
67
|
+
value: op[1],
|
|
68
|
+
done: false
|
|
69
|
+
};
|
|
70
|
+
case 5:
|
|
71
|
+
_.label++;
|
|
72
|
+
y = op[1];
|
|
73
|
+
op = [
|
|
74
|
+
0
|
|
75
|
+
];
|
|
76
|
+
continue;
|
|
77
|
+
case 7:
|
|
78
|
+
op = _.ops.pop();
|
|
79
|
+
_.trys.pop();
|
|
80
|
+
continue;
|
|
81
|
+
default:
|
|
82
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
83
|
+
_ = 0;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
87
|
+
_.label = op[1];
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
91
|
+
_.label = t[1];
|
|
92
|
+
t = op;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
if (t && _.label < t[2]) {
|
|
96
|
+
_.label = t[2];
|
|
97
|
+
_.ops.push(op);
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
if (t[2]) _.ops.pop();
|
|
101
|
+
_.trys.pop();
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
op = body.call(thisArg, _);
|
|
105
|
+
} catch (e) {
|
|
106
|
+
op = [
|
|
107
|
+
6,
|
|
108
|
+
e
|
|
109
|
+
];
|
|
110
|
+
y = 0;
|
|
111
|
+
} finally{
|
|
112
|
+
f = t = 0;
|
|
113
|
+
}
|
|
114
|
+
if (op[0] & 5) throw op[1];
|
|
115
|
+
return {
|
|
116
|
+
value: op[0] ? op[1] : void 0,
|
|
117
|
+
done: true
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
import { createReadStream } from "node:fs";
|
|
122
|
+
import { stat } from "node:fs/promises";
|
|
123
|
+
import { basename } from "node:path";
|
|
124
|
+
import { Transform } from "node:stream";
|
|
125
|
+
import { logWorkflowDebug, logWorkflowInfo } from "../logging.js";
|
|
126
|
+
import { ensureApkFileName, hashFileSha256, inferFileNameFromUrl, normalizeLocalFileAccessError } from "./files.js";
|
|
127
|
+
var DEFAULT_APK_CONTENT_TYPE = "application/vnd.android.package-archive";
|
|
128
|
+
function uploadLocalApkToPortal(client, source, logger) {
|
|
129
|
+
return _async_to_generator(function() {
|
|
130
|
+
var createUploadTarget, fileStat, _source_mimeType, contentType, fileHash, fileName, uploadTarget, totalBytes, uploadedBytes, lastLoggedBytes, lastLoggedAt, emitUploadProgress, uploadBody, uploadResponse;
|
|
131
|
+
return _ts_generator(this, function(_state) {
|
|
132
|
+
switch(_state.label){
|
|
133
|
+
case 0:
|
|
134
|
+
createUploadTarget = client.createUploadTarget;
|
|
135
|
+
if (!createUploadTarget) {
|
|
136
|
+
throw new Error("Local apk-file sources require a createUploadTarget client method");
|
|
137
|
+
}
|
|
138
|
+
return [
|
|
139
|
+
4,
|
|
140
|
+
stat(source.filePath).catch(function(error) {
|
|
141
|
+
throw normalizeLocalFileAccessError(source.filePath, error);
|
|
142
|
+
})
|
|
143
|
+
];
|
|
144
|
+
case 1:
|
|
145
|
+
fileStat = _state.sent();
|
|
146
|
+
contentType = (_source_mimeType = source.mimeType) !== null && _source_mimeType !== void 0 ? _source_mimeType : DEFAULT_APK_CONTENT_TYPE;
|
|
147
|
+
return [
|
|
148
|
+
4,
|
|
149
|
+
hashFileSha256(source.filePath)
|
|
150
|
+
];
|
|
151
|
+
case 2:
|
|
152
|
+
fileHash = _state.sent();
|
|
153
|
+
fileName = ensureApkFileName(source.fileName || basename(source.filePath));
|
|
154
|
+
logWorkflowInfo(logger, "Uploading APK to portal storage", {
|
|
155
|
+
step: "source.upload",
|
|
156
|
+
status: "running",
|
|
157
|
+
fileName: fileName,
|
|
158
|
+
filePath: source.filePath,
|
|
159
|
+
fileSize: fileStat.size
|
|
160
|
+
});
|
|
161
|
+
return [
|
|
162
|
+
4,
|
|
163
|
+
createUploadTarget({
|
|
164
|
+
fileHash: fileHash,
|
|
165
|
+
fileExtension: "apk",
|
|
166
|
+
contentType: contentType
|
|
167
|
+
})
|
|
168
|
+
];
|
|
169
|
+
case 3:
|
|
170
|
+
uploadTarget = _state.sent();
|
|
171
|
+
totalBytes = fileStat.size;
|
|
172
|
+
uploadedBytes = 0;
|
|
173
|
+
lastLoggedBytes = 0;
|
|
174
|
+
lastLoggedAt = 0;
|
|
175
|
+
emitUploadProgress = function() {
|
|
176
|
+
var force = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
|
|
177
|
+
var now = Date.now();
|
|
178
|
+
var progress = totalBytes > 0 ? uploadedBytes / totalBytes : 1;
|
|
179
|
+
var byteDelta = uploadedBytes - lastLoggedBytes;
|
|
180
|
+
var minByteDelta = Math.max(256 * 1024, Math.floor(totalBytes * 0.01));
|
|
181
|
+
var shouldLog = force || uploadedBytes >= totalBytes || now - lastLoggedAt >= 250 || byteDelta >= minByteDelta;
|
|
182
|
+
if (!shouldLog) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
lastLoggedAt = now;
|
|
186
|
+
lastLoggedBytes = uploadedBytes;
|
|
187
|
+
logWorkflowDebug(logger, "Uploading APK to portal storage", {
|
|
188
|
+
step: "source.upload",
|
|
189
|
+
status: "running",
|
|
190
|
+
fileName: fileName,
|
|
191
|
+
filePath: source.filePath,
|
|
192
|
+
fileSize: totalBytes,
|
|
193
|
+
bytesUploaded: uploadedBytes,
|
|
194
|
+
bytesTotal: totalBytes,
|
|
195
|
+
stepProgress: progress
|
|
196
|
+
});
|
|
197
|
+
};
|
|
198
|
+
uploadBody = createReadStream(source.filePath).pipe(new Transform({
|
|
199
|
+
transform: function transform(chunk, _encoding, callback) {
|
|
200
|
+
uploadedBytes += chunk.length;
|
|
201
|
+
emitUploadProgress();
|
|
202
|
+
callback(null, chunk);
|
|
203
|
+
}
|
|
204
|
+
}));
|
|
205
|
+
return [
|
|
206
|
+
4,
|
|
207
|
+
fetch(uploadTarget.uploadUrl, {
|
|
208
|
+
method: "PUT",
|
|
209
|
+
headers: {
|
|
210
|
+
"content-type": contentType,
|
|
211
|
+
"content-length": String(totalBytes)
|
|
212
|
+
},
|
|
213
|
+
body: uploadBody,
|
|
214
|
+
duplex: "half"
|
|
215
|
+
})
|
|
216
|
+
];
|
|
217
|
+
case 4:
|
|
218
|
+
uploadResponse = _state.sent();
|
|
219
|
+
if (!uploadResponse.ok) {
|
|
220
|
+
throw new Error("Failed to upload APK to portal storage: ".concat(uploadResponse.status, " ").concat(uploadResponse.statusText));
|
|
221
|
+
}
|
|
222
|
+
uploadedBytes = totalBytes;
|
|
223
|
+
emitUploadProgress(true);
|
|
224
|
+
logWorkflowInfo(logger, "APK uploaded to portal storage", {
|
|
225
|
+
step: "source.upload",
|
|
226
|
+
status: "complete",
|
|
227
|
+
fileName: fileName,
|
|
228
|
+
publicUrl: uploadTarget.publicUrl
|
|
229
|
+
});
|
|
230
|
+
return [
|
|
231
|
+
2,
|
|
232
|
+
{
|
|
233
|
+
kind: "portalUpload",
|
|
234
|
+
releaseFileUrl: uploadTarget.publicUrl,
|
|
235
|
+
releaseFileName: fileName,
|
|
236
|
+
releaseFileSize: fileStat.size,
|
|
237
|
+
releaseFileHash: fileHash,
|
|
238
|
+
contentType: contentType
|
|
239
|
+
}
|
|
240
|
+
];
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
})();
|
|
244
|
+
}
|
|
245
|
+
export function preparePublicationSource(client, source, logger) {
|
|
246
|
+
return _async_to_generator(function() {
|
|
247
|
+
var _source_releaseFileName, _source_canonicalUrl, _source_fileName, _source_canonicalUrl1, _source_canonicalUrl2, _source_canonicalUrl3, _source_fileName1, exhaustiveCheck;
|
|
248
|
+
return _ts_generator(this, function(_state) {
|
|
249
|
+
switch(source.kind){
|
|
250
|
+
case "portalUpload":
|
|
251
|
+
logWorkflowInfo(logger, "Using portal-hosted APK source", {
|
|
252
|
+
step: "source.ready",
|
|
253
|
+
status: "complete",
|
|
254
|
+
fileName: source.releaseFileName
|
|
255
|
+
});
|
|
256
|
+
return [
|
|
257
|
+
2,
|
|
258
|
+
source
|
|
259
|
+
];
|
|
260
|
+
case "externalUrl":
|
|
261
|
+
;
|
|
262
|
+
logWorkflowInfo(logger, "Using external APK URL", {
|
|
263
|
+
step: "source.ready",
|
|
264
|
+
status: "complete",
|
|
265
|
+
fileName: (_source_releaseFileName = source.releaseFileName) !== null && _source_releaseFileName !== void 0 ? _source_releaseFileName : inferFileNameFromUrl(source.apkUrl),
|
|
266
|
+
apkUrl: source.apkUrl
|
|
267
|
+
});
|
|
268
|
+
return [
|
|
269
|
+
2,
|
|
270
|
+
source
|
|
271
|
+
];
|
|
272
|
+
case "existingRelease":
|
|
273
|
+
logWorkflowInfo(logger, "Using an existing release as the source", {
|
|
274
|
+
step: "source.ready",
|
|
275
|
+
status: "complete",
|
|
276
|
+
sourceReleaseId: source.sourceReleaseId
|
|
277
|
+
});
|
|
278
|
+
return [
|
|
279
|
+
2,
|
|
280
|
+
source
|
|
281
|
+
];
|
|
282
|
+
case "apk-url":
|
|
283
|
+
;
|
|
284
|
+
logWorkflowInfo(logger, "Preparing external APK URL", {
|
|
285
|
+
step: "source.ready",
|
|
286
|
+
status: "running",
|
|
287
|
+
fileName: (_source_fileName = source.fileName) !== null && _source_fileName !== void 0 ? _source_fileName : inferFileNameFromUrl((_source_canonicalUrl = source.canonicalUrl) !== null && _source_canonicalUrl !== void 0 ? _source_canonicalUrl : source.url),
|
|
288
|
+
apkUrl: (_source_canonicalUrl1 = source.canonicalUrl) !== null && _source_canonicalUrl1 !== void 0 ? _source_canonicalUrl1 : source.url
|
|
289
|
+
});
|
|
290
|
+
;
|
|
291
|
+
return [
|
|
292
|
+
2,
|
|
293
|
+
{
|
|
294
|
+
kind: "externalUrl",
|
|
295
|
+
apkUrl: (_source_canonicalUrl2 = source.canonicalUrl) !== null && _source_canonicalUrl2 !== void 0 ? _source_canonicalUrl2 : source.url,
|
|
296
|
+
releaseFileName: (_source_fileName1 = source.fileName) !== null && _source_fileName1 !== void 0 ? _source_fileName1 : inferFileNameFromUrl((_source_canonicalUrl3 = source.canonicalUrl) !== null && _source_canonicalUrl3 !== void 0 ? _source_canonicalUrl3 : source.url)
|
|
297
|
+
}
|
|
298
|
+
];
|
|
299
|
+
case "apk-file":
|
|
300
|
+
return [
|
|
301
|
+
2,
|
|
302
|
+
uploadLocalApkToPortal(client, source, logger)
|
|
303
|
+
];
|
|
304
|
+
default:
|
|
305
|
+
{
|
|
306
|
+
exhaustiveCheck = source;
|
|
307
|
+
return [
|
|
308
|
+
2,
|
|
309
|
+
exhaustiveCheck
|
|
310
|
+
];
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
return [
|
|
314
|
+
2
|
|
315
|
+
];
|
|
316
|
+
});
|
|
317
|
+
})();
|
|
318
|
+
}
|