@solana-mobile/dapp-store-cli 0.15.0 → 0.16.1
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/bin/dapp-store.js +3 -1
- package/lib/CliSetup.js +304 -505
- package/lib/CliUtils.js +6 -376
- package/lib/__tests__/CliSetupTest.js +484 -74
- package/lib/cli/__tests__/parseErrors.test.js +25 -0
- package/lib/cli/__tests__/signer.test.js +436 -0
- package/lib/cli/constants.js +23 -0
- package/lib/cli/messages.js +21 -0
- package/lib/cli/parseErrors.js +41 -0
- package/lib/{commands/publish/PublishCliSupport.js → cli/selfUpdate.js} +72 -38
- package/lib/{commands/publish/PublishCliRemove.js → cli/signer.js} +35 -56
- package/lib/index.js +96 -5
- package/lib/package.json +5 -24
- package/lib/portal/__tests__/releaseMetadata.test.js +647 -0
- package/lib/portal/__tests__/translators.test.js +76 -0
- package/lib/portal/__tests__/workflowClient.test.js +457 -0
- package/lib/portal/attestationClient.js +143 -0
- package/lib/portal/files.js +64 -0
- package/lib/portal/http.js +364 -0
- package/lib/portal/records.js +64 -0
- package/lib/portal/releaseMetadata.js +748 -0
- package/lib/portal/translators.js +460 -0
- package/lib/portal/types.js +1 -0
- package/lib/portal/workflowClient.js +704 -0
- package/lib/publication/PublicationProgressReporter.js +1051 -0
- package/lib/publication/__tests__/PublicationProgressReporter.test.js +174 -0
- package/lib/{commands/ValidateCommand.js → publication/__tests__/fundingPreflight.test.js} +90 -66
- package/lib/publication/__tests__/publicationSummary.test.js +26 -0
- package/lib/publication/cliValidation.js +482 -0
- package/lib/publication/fundingPreflight.js +246 -0
- package/lib/publication/publicationSummary.js +99 -0
- package/lib/{commands/utils.js → publication/runPublicationWorkflow.js} +16 -46
- package/package.json +5 -24
- package/src/CliSetup.ts +370 -505
- package/src/CliUtils.ts +9 -233
- package/src/__tests__/CliSetupTest.ts +272 -120
- package/src/cli/__tests__/parseErrors.test.ts +34 -0
- package/src/cli/__tests__/signer.test.ts +359 -0
- package/src/cli/constants.ts +3 -0
- package/src/cli/messages.ts +27 -0
- package/src/cli/parseErrors.ts +62 -0
- package/src/cli/selfUpdate.ts +59 -0
- package/src/cli/signer.ts +38 -0
- package/src/index.ts +31 -4
- package/src/portal/__tests__/releaseMetadata.test.ts +508 -0
- package/src/portal/__tests__/translators.test.ts +82 -0
- package/src/portal/__tests__/workflowClient.test.ts +278 -0
- package/src/portal/attestationClient.ts +19 -0
- package/src/portal/files.ts +73 -0
- package/src/portal/http.ts +170 -0
- package/src/portal/records.ts +38 -0
- package/src/portal/releaseMetadata.ts +489 -0
- package/src/portal/translators.ts +750 -0
- package/src/portal/types.ts +27 -0
- package/src/portal/workflowClient.ts +575 -0
- package/src/publication/PublicationProgressReporter.ts +1026 -0
- package/src/publication/__tests__/PublicationProgressReporter.test.ts +210 -0
- package/src/publication/__tests__/fundingPreflight.test.ts +78 -0
- package/src/publication/__tests__/publicationSummary.test.ts +30 -0
- package/src/publication/cliValidation.ts +264 -0
- package/src/publication/fundingPreflight.ts +123 -0
- package/src/publication/publicationSummary.ts +26 -0
- package/src/publication/runPublicationWorkflow.ts +46 -0
- package/lib/commands/create/CreateCliApp.js +0 -223
- package/lib/commands/create/CreateCliRelease.js +0 -290
- package/lib/commands/create/index.js +0 -40
- package/lib/commands/index.js +0 -3
- package/lib/commands/publish/PublishCliSubmit.js +0 -208
- package/lib/commands/publish/PublishCliUpdate.js +0 -211
- package/lib/commands/publish/index.js +0 -22
- package/lib/commands/scaffolding/ScaffoldInit.js +0 -15
- package/lib/commands/scaffolding/index.js +0 -1
- package/lib/config/EnvVariables.js +0 -59
- package/lib/config/PublishDetails.js +0 -915
- package/lib/config/S3StorageManager.js +0 -93
- package/lib/config/index.js +0 -2
- package/lib/generated/config_obj.json +0 -1
- package/lib/generated/config_schema.json +0 -1
- package/lib/prebuild_schema/publishing_source.yaml +0 -64
- package/lib/prebuild_schema/schemagen.js +0 -25
- package/lib/upload/CachedStorageDriver.js +0 -293
- package/lib/upload/TurboStorageDriver.js +0 -718
- package/lib/upload/index.js +0 -2
- package/src/commands/ValidateCommand.ts +0 -82
- package/src/commands/create/CreateCliApp.ts +0 -93
- package/src/commands/create/CreateCliRelease.ts +0 -149
- package/src/commands/create/index.ts +0 -47
- package/src/commands/index.ts +0 -3
- package/src/commands/publish/PublishCliRemove.ts +0 -66
- package/src/commands/publish/PublishCliSubmit.ts +0 -93
- package/src/commands/publish/PublishCliSupport.ts +0 -66
- package/src/commands/publish/PublishCliUpdate.ts +0 -101
- package/src/commands/publish/index.ts +0 -29
- package/src/commands/scaffolding/ScaffoldInit.ts +0 -20
- package/src/commands/scaffolding/index.ts +0 -1
- package/src/commands/utils.ts +0 -33
- package/src/config/EnvVariables.ts +0 -39
- package/src/config/PublishDetails.ts +0 -456
- package/src/config/S3StorageManager.ts +0 -47
- package/src/config/index.ts +0 -2
- package/src/prebuild_schema/publishing_source.yaml +0 -64
- package/src/prebuild_schema/schemagen.js +0 -31
- package/src/upload/CachedStorageDriver.ts +0 -99
- package/src/upload/TurboStorageDriver.ts +0 -277
- package/src/upload/index.ts +0 -2
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { describe, expect, it } from '@jest/globals';
|
|
2
|
+
import { mapBackendBundleToPublicationBundle } from '../translators.js';
|
|
3
|
+
describe('mapBackendBundleToPublicationBundle', function() {
|
|
4
|
+
it('keeps localized short-description fallback distinct from metadata shortDescription', function() {
|
|
5
|
+
var description = 'A'.repeat(80);
|
|
6
|
+
var bundle = mapBackendBundleToPublicationBundle({
|
|
7
|
+
dapp: {
|
|
8
|
+
dappName: 'Example dApp',
|
|
9
|
+
description: description,
|
|
10
|
+
subtitle: 'Portal subtitle'
|
|
11
|
+
},
|
|
12
|
+
release: {},
|
|
13
|
+
publisher: {},
|
|
14
|
+
installFile: {},
|
|
15
|
+
signerAuthority: {}
|
|
16
|
+
}, '', 'portal');
|
|
17
|
+
expect(bundle.metadata.shortDescription).toBe('Portal subtitle');
|
|
18
|
+
expect(bundle.metadata.localizedStrings[0].shortDescription).toBe(description.slice(0, 50));
|
|
19
|
+
});
|
|
20
|
+
it('preserves required release metadata fields from the backend bundle', function() {
|
|
21
|
+
var bundle = mapBackendBundleToPublicationBundle({
|
|
22
|
+
dapp: {
|
|
23
|
+
id: 'dapp-1',
|
|
24
|
+
dappName: 'Example dApp',
|
|
25
|
+
description: 'Long description',
|
|
26
|
+
walletAddress: 'wallet-1',
|
|
27
|
+
androidPackage: 'com.example.app',
|
|
28
|
+
dappIconUrl: 'https://example.com/icon.png',
|
|
29
|
+
dappPreviewUrls: [
|
|
30
|
+
'https://example.com/preview.png'
|
|
31
|
+
],
|
|
32
|
+
editorsChoiceGraphicUrl: 'https://example.com/editor.png',
|
|
33
|
+
languages: [
|
|
34
|
+
'en-US'
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
release: {
|
|
38
|
+
id: 'release-1',
|
|
39
|
+
dappId: 'dapp-1',
|
|
40
|
+
releaseFileUrl: 'https://example.com/release.apk',
|
|
41
|
+
releaseFileName: 'release.apk',
|
|
42
|
+
releaseFileSize: 123,
|
|
43
|
+
releaseFileHash: 'apk-hash',
|
|
44
|
+
versionCode: 42,
|
|
45
|
+
versionName: '1.0.42',
|
|
46
|
+
androidPackage: 'com.example.app',
|
|
47
|
+
minSdkVersion: 26,
|
|
48
|
+
targetSdkVersion: 35,
|
|
49
|
+
permissions: [
|
|
50
|
+
'android.permission.INTERNET'
|
|
51
|
+
],
|
|
52
|
+
locales: [
|
|
53
|
+
'en-US'
|
|
54
|
+
],
|
|
55
|
+
certificateFingerprint: 'fingerprint',
|
|
56
|
+
shortDescription: 'Short description',
|
|
57
|
+
longDescription: 'Long description',
|
|
58
|
+
localizedName: 'Example App',
|
|
59
|
+
newInVersion: 'Bug fixes'
|
|
60
|
+
},
|
|
61
|
+
publisher: {},
|
|
62
|
+
installFile: {},
|
|
63
|
+
signerAuthority: {}
|
|
64
|
+
}, 'https://example.com/metadata.json', 'portal');
|
|
65
|
+
expect(bundle.dapp.editorsChoiceGraphicUrl).toBe('https://example.com/editor.png');
|
|
66
|
+
expect(bundle.release.targetSdkVersion).toBe(35);
|
|
67
|
+
expect(bundle.release.certificateFingerprint).toBe('fingerprint');
|
|
68
|
+
expect(bundle.release.permissions).toEqual([
|
|
69
|
+
'android.permission.INTERNET'
|
|
70
|
+
]);
|
|
71
|
+
expect(bundle.release.locales).toEqual([
|
|
72
|
+
'en-US'
|
|
73
|
+
]);
|
|
74
|
+
expect(bundle.release.releaseFileHash).toBe('apk-hash');
|
|
75
|
+
});
|
|
76
|
+
});
|
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
function _array_like_to_array(arr, len) {
|
|
2
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
+
return arr2;
|
|
5
|
+
}
|
|
6
|
+
function _array_with_holes(arr) {
|
|
7
|
+
if (Array.isArray(arr)) return arr;
|
|
8
|
+
}
|
|
9
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
10
|
+
try {
|
|
11
|
+
var info = gen[key](arg);
|
|
12
|
+
var value = info.value;
|
|
13
|
+
} catch (error) {
|
|
14
|
+
reject(error);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (info.done) {
|
|
18
|
+
resolve(value);
|
|
19
|
+
} else {
|
|
20
|
+
Promise.resolve(value).then(_next, _throw);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function _async_to_generator(fn) {
|
|
24
|
+
return function() {
|
|
25
|
+
var self = this, args = arguments;
|
|
26
|
+
return new Promise(function(resolve, reject) {
|
|
27
|
+
var gen = fn.apply(self, args);
|
|
28
|
+
function _next(value) {
|
|
29
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
30
|
+
}
|
|
31
|
+
function _throw(err) {
|
|
32
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
33
|
+
}
|
|
34
|
+
_next(undefined);
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function _iterable_to_array_limit(arr, i) {
|
|
39
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
40
|
+
if (_i == null) return;
|
|
41
|
+
var _arr = [];
|
|
42
|
+
var _n = true;
|
|
43
|
+
var _d = false;
|
|
44
|
+
var _s, _e;
|
|
45
|
+
try {
|
|
46
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
47
|
+
_arr.push(_s.value);
|
|
48
|
+
if (i && _arr.length === i) break;
|
|
49
|
+
}
|
|
50
|
+
} catch (err) {
|
|
51
|
+
_d = true;
|
|
52
|
+
_e = err;
|
|
53
|
+
} finally{
|
|
54
|
+
try {
|
|
55
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
56
|
+
} finally{
|
|
57
|
+
if (_d) throw _e;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return _arr;
|
|
61
|
+
}
|
|
62
|
+
function _non_iterable_rest() {
|
|
63
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
64
|
+
}
|
|
65
|
+
function _sliced_to_array(arr, i) {
|
|
66
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
67
|
+
}
|
|
68
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
69
|
+
if (!o) return;
|
|
70
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
71
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
72
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
73
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
74
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
75
|
+
}
|
|
76
|
+
function _ts_generator(thisArg, body) {
|
|
77
|
+
var f, y, t, _ = {
|
|
78
|
+
label: 0,
|
|
79
|
+
sent: function() {
|
|
80
|
+
if (t[0] & 1) throw t[1];
|
|
81
|
+
return t[1];
|
|
82
|
+
},
|
|
83
|
+
trys: [],
|
|
84
|
+
ops: []
|
|
85
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
86
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
87
|
+
return this;
|
|
88
|
+
}), g;
|
|
89
|
+
function verb(n) {
|
|
90
|
+
return function(v) {
|
|
91
|
+
return step([
|
|
92
|
+
n,
|
|
93
|
+
v
|
|
94
|
+
]);
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function step(op) {
|
|
98
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
99
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
100
|
+
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;
|
|
101
|
+
if (y = 0, t) op = [
|
|
102
|
+
op[0] & 2,
|
|
103
|
+
t.value
|
|
104
|
+
];
|
|
105
|
+
switch(op[0]){
|
|
106
|
+
case 0:
|
|
107
|
+
case 1:
|
|
108
|
+
t = op;
|
|
109
|
+
break;
|
|
110
|
+
case 4:
|
|
111
|
+
_.label++;
|
|
112
|
+
return {
|
|
113
|
+
value: op[1],
|
|
114
|
+
done: false
|
|
115
|
+
};
|
|
116
|
+
case 5:
|
|
117
|
+
_.label++;
|
|
118
|
+
y = op[1];
|
|
119
|
+
op = [
|
|
120
|
+
0
|
|
121
|
+
];
|
|
122
|
+
continue;
|
|
123
|
+
case 7:
|
|
124
|
+
op = _.ops.pop();
|
|
125
|
+
_.trys.pop();
|
|
126
|
+
continue;
|
|
127
|
+
default:
|
|
128
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
129
|
+
_ = 0;
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
133
|
+
_.label = op[1];
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
137
|
+
_.label = t[1];
|
|
138
|
+
t = op;
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
if (t && _.label < t[2]) {
|
|
142
|
+
_.label = t[2];
|
|
143
|
+
_.ops.push(op);
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
if (t[2]) _.ops.pop();
|
|
147
|
+
_.trys.pop();
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
op = body.call(thisArg, _);
|
|
151
|
+
} catch (e) {
|
|
152
|
+
op = [
|
|
153
|
+
6,
|
|
154
|
+
e
|
|
155
|
+
];
|
|
156
|
+
y = 0;
|
|
157
|
+
} finally{
|
|
158
|
+
f = t = 0;
|
|
159
|
+
}
|
|
160
|
+
if (op[0] & 5) throw op[1];
|
|
161
|
+
return {
|
|
162
|
+
value: op[0] ? op[1] : void 0,
|
|
163
|
+
done: true
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
import fs from "node:fs";
|
|
168
|
+
import os from "node:os";
|
|
169
|
+
import path from "node:path";
|
|
170
|
+
import { afterEach, beforeEach, expect, jest, test } from "@jest/globals";
|
|
171
|
+
import { createPortalWorkflowClient } from "../workflowClient.js";
|
|
172
|
+
function createProcedureResponse(result) {
|
|
173
|
+
return new Response(JSON.stringify({
|
|
174
|
+
result: {
|
|
175
|
+
data: result
|
|
176
|
+
}
|
|
177
|
+
}), {
|
|
178
|
+
status: 200,
|
|
179
|
+
headers: {
|
|
180
|
+
"content-type": "application/json"
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
var originalFetch;
|
|
185
|
+
var fetchMock;
|
|
186
|
+
var tempDirs = [];
|
|
187
|
+
beforeEach(function() {
|
|
188
|
+
originalFetch = global.fetch;
|
|
189
|
+
fetchMock = jest.fn();
|
|
190
|
+
global.fetch = fetchMock;
|
|
191
|
+
});
|
|
192
|
+
afterEach(function() {
|
|
193
|
+
global.fetch = originalFetch;
|
|
194
|
+
while(tempDirs.length > 0){
|
|
195
|
+
fs.rmSync(tempDirs.pop(), {
|
|
196
|
+
recursive: true,
|
|
197
|
+
force: true
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
test("createIngestionSession maps apk-url sources to the portal externalUrl API shape", function() {
|
|
202
|
+
return _async_to_generator(function() {
|
|
203
|
+
var _result_bundle_metadata, _result_bundle, _result_publicationSession, client, result, _fetchMock_mock_calls_, requestUrl, requestInit, requestBody;
|
|
204
|
+
return _ts_generator(this, function(_state) {
|
|
205
|
+
switch(_state.label){
|
|
206
|
+
case 0:
|
|
207
|
+
fetchMock.mockResolvedValueOnce(createProcedureResponse({
|
|
208
|
+
id: "ingestion-1",
|
|
209
|
+
dappId: "dapp-1",
|
|
210
|
+
idempotencyKey: "idem-1",
|
|
211
|
+
status: "Created",
|
|
212
|
+
sourceKind: "externalUrl",
|
|
213
|
+
sourceUrl: "https://downloads.example.com/releases/app-release.apk",
|
|
214
|
+
releaseFileName: "app-release.apk",
|
|
215
|
+
releaseFileSize: 10,
|
|
216
|
+
releaseId: "release-1",
|
|
217
|
+
publicationSessionId: "session-1",
|
|
218
|
+
bundle: {
|
|
219
|
+
release: {
|
|
220
|
+
id: "release-1",
|
|
221
|
+
releaseFileName: "app-release.apk",
|
|
222
|
+
versionCode: 42,
|
|
223
|
+
versionName: "42",
|
|
224
|
+
androidPackage: "com.example.app",
|
|
225
|
+
localizedName: "Example App",
|
|
226
|
+
newInVersion: "Fixes"
|
|
227
|
+
},
|
|
228
|
+
dapp: {
|
|
229
|
+
id: "dapp-1",
|
|
230
|
+
dappName: "Example App",
|
|
231
|
+
description: "A dApp",
|
|
232
|
+
walletAddress: "wallet-1",
|
|
233
|
+
androidPackage: "com.example.app"
|
|
234
|
+
},
|
|
235
|
+
publisher: {
|
|
236
|
+
id: "publisher-1",
|
|
237
|
+
type: "organization",
|
|
238
|
+
name: "Example Publisher",
|
|
239
|
+
website: "https://example.com",
|
|
240
|
+
email: "team@example.com"
|
|
241
|
+
},
|
|
242
|
+
installFile: {
|
|
243
|
+
uri: "https://downloads.example.com/releases/app-release.apk",
|
|
244
|
+
size: 10
|
|
245
|
+
},
|
|
246
|
+
signerAuthority: {
|
|
247
|
+
dappWalletAddress: "wallet-1",
|
|
248
|
+
collectionAuthority: "wallet-1"
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
publicationSession: {
|
|
252
|
+
id: "session-1",
|
|
253
|
+
releaseId: "release-1",
|
|
254
|
+
stage: "PreparedForMint",
|
|
255
|
+
created: "2024-01-01T00:00:00.000Z",
|
|
256
|
+
updated: "2024-01-01T00:00:00.000Z"
|
|
257
|
+
}
|
|
258
|
+
}));
|
|
259
|
+
client = createPortalWorkflowClient({
|
|
260
|
+
apiBaseUrl: "https://portal.example.com/api",
|
|
261
|
+
apiKey: "portal-key"
|
|
262
|
+
});
|
|
263
|
+
return [
|
|
264
|
+
4,
|
|
265
|
+
client.createIngestionSession({
|
|
266
|
+
source: {
|
|
267
|
+
kind: "apk-url",
|
|
268
|
+
url: "https://downloads.example.com/releases/app-release.apk"
|
|
269
|
+
},
|
|
270
|
+
whatsNew: "Fixes",
|
|
271
|
+
idempotencyKey: "idem-1"
|
|
272
|
+
})
|
|
273
|
+
];
|
|
274
|
+
case 1:
|
|
275
|
+
result = _state.sent();
|
|
276
|
+
_fetchMock_mock_calls_ = _sliced_to_array(fetchMock.mock.calls[0], 2), requestUrl = _fetchMock_mock_calls_[0], requestInit = _fetchMock_mock_calls_[1];
|
|
277
|
+
requestBody = JSON.parse(String(requestInit === null || requestInit === void 0 ? void 0 : requestInit.body));
|
|
278
|
+
expect(String(requestUrl)).toContain("/trpc/publication.createIngestionSession");
|
|
279
|
+
expect(requestInit === null || requestInit === void 0 ? void 0 : requestInit.method).toBe("POST");
|
|
280
|
+
expect(requestBody).toMatchObject({
|
|
281
|
+
source: {
|
|
282
|
+
kind: "externalUrl",
|
|
283
|
+
apkUrl: "https://downloads.example.com/releases/app-release.apk",
|
|
284
|
+
releaseFileName: "app-release.apk"
|
|
285
|
+
},
|
|
286
|
+
whatsNew: "Fixes",
|
|
287
|
+
idempotencyKey: "idem-1"
|
|
288
|
+
});
|
|
289
|
+
expect(result.source.kind).toBe("apk-url");
|
|
290
|
+
expect((_result_bundle = result.bundle) === null || _result_bundle === void 0 ? void 0 : (_result_bundle_metadata = _result_bundle.metadata) === null || _result_bundle_metadata === void 0 ? void 0 : _result_bundle_metadata.installFile.origin).toBe("external");
|
|
291
|
+
expect((_result_publicationSession = result.publicationSession) === null || _result_publicationSession === void 0 ? void 0 : _result_publicationSession.checkpoint).toBe("bundle-ready");
|
|
292
|
+
return [
|
|
293
|
+
2
|
|
294
|
+
];
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
})();
|
|
298
|
+
});
|
|
299
|
+
test("createIngestionSession uploads local APK files before creating the ingestion session", function() {
|
|
300
|
+
return _async_to_generator(function() {
|
|
301
|
+
var _result_bundle_metadata, _result_bundle, tempDir, apkPath, client, result, _fetchMock_mock_calls_, uploadTargetUrl, uploadTargetInit, uploadTargetBody, _fetchMock_mock_calls_1, uploadUrl, uploadInit, _fetchMock_mock_calls_2, ingestionUrl, ingestionInit, ingestionBody;
|
|
302
|
+
return _ts_generator(this, function(_state) {
|
|
303
|
+
switch(_state.label){
|
|
304
|
+
case 0:
|
|
305
|
+
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "dapp-store-apk-"));
|
|
306
|
+
apkPath = path.join(tempDir, "release-build");
|
|
307
|
+
tempDirs.push(tempDir);
|
|
308
|
+
fs.writeFileSync(apkPath, Buffer.from("apk-binary"));
|
|
309
|
+
fetchMock.mockResolvedValueOnce(createProcedureResponse({
|
|
310
|
+
uploadUrl: "https://uploads.example.com/app.apk",
|
|
311
|
+
key: "upload-key",
|
|
312
|
+
providerId: "provider-1",
|
|
313
|
+
publicUrl: "https://cdn.example.com/app.apk"
|
|
314
|
+
})).mockResolvedValueOnce(new Response("", {
|
|
315
|
+
status: 200
|
|
316
|
+
})).mockResolvedValueOnce(createProcedureResponse({
|
|
317
|
+
id: "ingestion-2",
|
|
318
|
+
dappId: "dapp-1",
|
|
319
|
+
idempotencyKey: "idem-2",
|
|
320
|
+
status: "Created",
|
|
321
|
+
sourceKind: "portalUpload",
|
|
322
|
+
sourceUrl: "https://cdn.example.com/app.apk",
|
|
323
|
+
releaseFileName: "release-build.apk",
|
|
324
|
+
releaseFileSize: 10,
|
|
325
|
+
releaseId: "release-2",
|
|
326
|
+
publicationSessionId: "session-2",
|
|
327
|
+
bundle: {
|
|
328
|
+
release: {
|
|
329
|
+
id: "release-2",
|
|
330
|
+
releaseFileName: "release-build.apk",
|
|
331
|
+
releaseFileUrl: "https://cdn.example.com/app.apk",
|
|
332
|
+
versionCode: 7,
|
|
333
|
+
versionName: "7",
|
|
334
|
+
androidPackage: "com.example.app",
|
|
335
|
+
localizedName: "Example App",
|
|
336
|
+
newInVersion: "Local upload"
|
|
337
|
+
},
|
|
338
|
+
dapp: {
|
|
339
|
+
id: "dapp-1",
|
|
340
|
+
dappName: "Example App",
|
|
341
|
+
description: "A dApp",
|
|
342
|
+
walletAddress: "wallet-1",
|
|
343
|
+
androidPackage: "com.example.app"
|
|
344
|
+
},
|
|
345
|
+
publisher: {
|
|
346
|
+
id: "publisher-1",
|
|
347
|
+
type: "organization",
|
|
348
|
+
name: "Example Publisher",
|
|
349
|
+
website: "https://example.com",
|
|
350
|
+
email: "team@example.com"
|
|
351
|
+
},
|
|
352
|
+
installFile: {
|
|
353
|
+
uri: "https://cdn.example.com/app.apk",
|
|
354
|
+
size: 10
|
|
355
|
+
},
|
|
356
|
+
signerAuthority: {
|
|
357
|
+
dappWalletAddress: "wallet-1",
|
|
358
|
+
collectionAuthority: "wallet-1"
|
|
359
|
+
}
|
|
360
|
+
},
|
|
361
|
+
publicationSession: {
|
|
362
|
+
id: "session-2",
|
|
363
|
+
releaseId: "release-2",
|
|
364
|
+
stage: "PreparedForMint",
|
|
365
|
+
created: "2024-01-01T00:00:00.000Z",
|
|
366
|
+
updated: "2024-01-01T00:00:00.000Z"
|
|
367
|
+
}
|
|
368
|
+
}));
|
|
369
|
+
client = createPortalWorkflowClient({
|
|
370
|
+
apiBaseUrl: "https://portal.example.com/api",
|
|
371
|
+
apiKey: "portal-key"
|
|
372
|
+
});
|
|
373
|
+
return [
|
|
374
|
+
4,
|
|
375
|
+
client.createIngestionSession({
|
|
376
|
+
source: {
|
|
377
|
+
kind: "apk-file",
|
|
378
|
+
filePath: apkPath
|
|
379
|
+
},
|
|
380
|
+
whatsNew: "Local upload",
|
|
381
|
+
idempotencyKey: "idem-2"
|
|
382
|
+
})
|
|
383
|
+
];
|
|
384
|
+
case 1:
|
|
385
|
+
result = _state.sent();
|
|
386
|
+
_fetchMock_mock_calls_ = _sliced_to_array(fetchMock.mock.calls[0], 2), uploadTargetUrl = _fetchMock_mock_calls_[0], uploadTargetInit = _fetchMock_mock_calls_[1];
|
|
387
|
+
uploadTargetBody = JSON.parse(String(uploadTargetInit === null || uploadTargetInit === void 0 ? void 0 : uploadTargetInit.body));
|
|
388
|
+
expect(String(uploadTargetUrl)).toContain("/trpc/publication.createUploadTarget");
|
|
389
|
+
expect(uploadTargetBody).toMatchObject({
|
|
390
|
+
fileExtension: "apk",
|
|
391
|
+
contentType: "application/vnd.android.package-archive"
|
|
392
|
+
});
|
|
393
|
+
_fetchMock_mock_calls_1 = _sliced_to_array(fetchMock.mock.calls[1], 2), uploadUrl = _fetchMock_mock_calls_1[0], uploadInit = _fetchMock_mock_calls_1[1];
|
|
394
|
+
expect(String(uploadUrl)).toBe("https://uploads.example.com/app.apk");
|
|
395
|
+
expect(uploadInit === null || uploadInit === void 0 ? void 0 : uploadInit.method).toBe("PUT");
|
|
396
|
+
expect(Buffer.from(uploadInit === null || uploadInit === void 0 ? void 0 : uploadInit.body).toString()).toBe("apk-binary");
|
|
397
|
+
_fetchMock_mock_calls_2 = _sliced_to_array(fetchMock.mock.calls[2], 2), ingestionUrl = _fetchMock_mock_calls_2[0], ingestionInit = _fetchMock_mock_calls_2[1];
|
|
398
|
+
ingestionBody = JSON.parse(String(ingestionInit === null || ingestionInit === void 0 ? void 0 : ingestionInit.body));
|
|
399
|
+
expect(String(ingestionUrl)).toContain("/trpc/publication.createIngestionSession");
|
|
400
|
+
expect(ingestionBody).toMatchObject({
|
|
401
|
+
source: {
|
|
402
|
+
kind: "portalUpload",
|
|
403
|
+
releaseFileUrl: "https://cdn.example.com/app.apk",
|
|
404
|
+
releaseFileName: "release-build.apk",
|
|
405
|
+
releaseFileSize: 10
|
|
406
|
+
},
|
|
407
|
+
whatsNew: "Local upload",
|
|
408
|
+
idempotencyKey: "idem-2"
|
|
409
|
+
});
|
|
410
|
+
expect(result.source.kind).toBe("apk-file");
|
|
411
|
+
expect((_result_bundle = result.bundle) === null || _result_bundle === void 0 ? void 0 : (_result_bundle_metadata = _result_bundle.metadata) === null || _result_bundle_metadata === void 0 ? void 0 : _result_bundle_metadata.installFile.origin).toBe("portal");
|
|
412
|
+
expect(result.releaseId).toBe("release-2");
|
|
413
|
+
expect(result.publicationSessionId).toBe("session-2");
|
|
414
|
+
return [
|
|
415
|
+
2
|
|
416
|
+
];
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
})();
|
|
420
|
+
});
|
|
421
|
+
test("createIngestionSession explains local file permission errors", function() {
|
|
422
|
+
return _async_to_generator(function() {
|
|
423
|
+
var readFileSpy, client;
|
|
424
|
+
return _ts_generator(this, function(_state) {
|
|
425
|
+
switch(_state.label){
|
|
426
|
+
case 0:
|
|
427
|
+
readFileSpy = jest.spyOn(fs, "readFileSync").mockImplementation(function() {
|
|
428
|
+
var error = Object.assign(new Error("operation not permitted"), {
|
|
429
|
+
code: "EPERM"
|
|
430
|
+
});
|
|
431
|
+
throw error;
|
|
432
|
+
});
|
|
433
|
+
client = createPortalWorkflowClient({
|
|
434
|
+
apiBaseUrl: "https://portal.example.com/api",
|
|
435
|
+
apiKey: "portal-key"
|
|
436
|
+
});
|
|
437
|
+
return [
|
|
438
|
+
4,
|
|
439
|
+
expect(client.createIngestionSession({
|
|
440
|
+
source: {
|
|
441
|
+
kind: "apk-file",
|
|
442
|
+
filePath: "/Users/skumail/Downloads/app.apk"
|
|
443
|
+
},
|
|
444
|
+
whatsNew: "Local upload",
|
|
445
|
+
idempotencyKey: "idem-3"
|
|
446
|
+
})).rejects.toThrow("Move the APK out of Downloads into your workspace or another accessible folder")
|
|
447
|
+
];
|
|
448
|
+
case 1:
|
|
449
|
+
_state.sent();
|
|
450
|
+
readFileSpy.mockRestore();
|
|
451
|
+
return [
|
|
452
|
+
2
|
|
453
|
+
];
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
})();
|
|
457
|
+
});
|
|
@@ -0,0 +1,143 @@
|
|
|
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 { callPortalProcedure } from './http.js';
|
|
122
|
+
export function createPortalAttestationClient(config) {
|
|
123
|
+
return {
|
|
124
|
+
getBlockData: function getBlockData() {
|
|
125
|
+
return _async_to_generator(function() {
|
|
126
|
+
return _ts_generator(this, function(_state) {
|
|
127
|
+
switch(_state.label){
|
|
128
|
+
case 0:
|
|
129
|
+
return [
|
|
130
|
+
4,
|
|
131
|
+
callPortalProcedure(config, 'attestation.getBlockData', {}, 'query')
|
|
132
|
+
];
|
|
133
|
+
case 1:
|
|
134
|
+
return [
|
|
135
|
+
2,
|
|
136
|
+
_state.sent()
|
|
137
|
+
];
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
})();
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
}
|