@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.
Files changed (53) hide show
  1. package/lib/CoreUtils.js +0 -3
  2. package/lib/index.js +1 -0
  3. package/lib/portal/attestation.js +189 -0
  4. package/lib/portal/compat.js +3 -0
  5. package/lib/portal/index.js +5 -0
  6. package/lib/portal/signer.js +432 -0
  7. package/lib/portal/types.js +1 -0
  8. package/lib/portal/workflow/contracts.js +1 -0
  9. package/lib/portal/workflow/execution.js +493 -0
  10. package/lib/portal/workflow/ingestion.js +265 -0
  11. package/lib/portal/workflow/lifecycle.js +616 -0
  12. package/lib/portal/workflow/logging.js +8 -0
  13. package/lib/portal/workflow/source/files.js +304 -0
  14. package/lib/portal/workflow/source/preparation.js +318 -0
  15. package/lib/portal/workflow/state/bundle.js +260 -0
  16. package/lib/portal/workflow/state/checkpoints.js +53 -0
  17. package/lib/portal/workflow/state/session.js +100 -0
  18. package/lib/portal/workflow.js +1 -0
  19. package/lib/publish/PublishCoreAttestation.js +18 -17
  20. package/lib/publish/PublishCoreRemove.js +7 -89
  21. package/lib/publish/PublishCoreSubmit.js +7 -117
  22. package/lib/publish/PublishCoreSupport.js +7 -86
  23. package/lib/publish/PublishCoreUpdate.js +7 -117
  24. package/lib/publish/index.js +1 -0
  25. package/lib/schemas/releaseJsonMetadata.json +1 -2
  26. package/package.json +2 -4
  27. package/src/CoreUtils.ts +0 -6
  28. package/src/index.ts +1 -0
  29. package/src/portal/attestation.ts +76 -0
  30. package/src/portal/compat.ts +5 -0
  31. package/src/portal/index.ts +5 -0
  32. package/src/portal/signer.ts +327 -0
  33. package/src/portal/types.ts +447 -0
  34. package/src/portal/workflow/contracts.ts +108 -0
  35. package/src/portal/workflow/execution.ts +412 -0
  36. package/src/portal/workflow/ingestion.ts +187 -0
  37. package/src/portal/workflow/lifecycle.ts +435 -0
  38. package/src/portal/workflow/logging.ts +17 -0
  39. package/src/portal/workflow/source/files.ts +49 -0
  40. package/src/portal/workflow/source/preparation.ts +189 -0
  41. package/src/portal/workflow/state/bundle.ts +193 -0
  42. package/src/portal/workflow/state/checkpoints.ts +70 -0
  43. package/src/portal/workflow/state/session.ts +87 -0
  44. package/src/portal/workflow.ts +9 -0
  45. package/src/publish/PublishCoreAttestation.ts +21 -26
  46. package/src/publish/PublishCoreRemove.ts +13 -109
  47. package/src/publish/PublishCoreSubmit.ts +18 -150
  48. package/src/publish/PublishCoreSupport.ts +13 -102
  49. package/src/publish/PublishCoreUpdate.ts +17 -155
  50. package/src/publish/index.ts +2 -1
  51. package/src/schemas/releaseJsonMetadata.json +1 -2
  52. package/lib/publish/dapp_publisher_portal.js +0 -206
  53. package/src/publish/dapp_publisher_portal.ts +0 -81
@@ -0,0 +1,265 @@
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 { logWorkflowInfo } from "./logging.js";
122
+ function isReadyIngestionSession(session) {
123
+ return session.status === "Ready" || session.status === "ready";
124
+ }
125
+ function buildIngestionStatusProgress(session) {
126
+ if (typeof session.processingProgress === "number" && Number.isFinite(session.processingProgress)) {
127
+ return Math.max(0, Math.min(1, session.processingProgress / 100));
128
+ }
129
+ switch(session.status){
130
+ case "created":
131
+ return 0.15;
132
+ case "queued":
133
+ return 0.3;
134
+ case "processing":
135
+ return 0.7;
136
+ case "Ready":
137
+ case "ready":
138
+ case "Failed":
139
+ case "failed":
140
+ return 1;
141
+ default:
142
+ return 0.15;
143
+ }
144
+ }
145
+ function buildIngestionStatusMessage(session) {
146
+ if (typeof session.processingDetail === "string" && session.processingDetail.trim().length > 0) {
147
+ return session.processingDetail.trim();
148
+ }
149
+ if (typeof session.processingStage === "string" && session.processingStage.trim().length > 0) {
150
+ return session.processingStage.trim();
151
+ }
152
+ switch(session.status){
153
+ case "created":
154
+ return "Portal ingestion request created";
155
+ case "queued":
156
+ return "Portal ingestion queued";
157
+ case "processing":
158
+ return "Portal ingestion is processing the APK";
159
+ case "Ready":
160
+ case "ready":
161
+ return "Portal ingestion is ready";
162
+ default:
163
+ return null;
164
+ }
165
+ }
166
+ export function waitForIngestionSessionReady(client, ingestionSessionId, options, logger) {
167
+ return _async_to_generator(function() {
168
+ var previousSnapshot, attempt, session, nextSnapshot, statusMessage, _session_releaseId, _session_publicationSessionId, _session_androidPackage, _session_versionName, _session_processingDetail, _ref, _nextSnapshot_progress, _nextSnapshot_stage, _nextSnapshot_detail, _session_releaseId1, _session_publicationSessionId1, _session_androidPackage1, _session_versionName1, _session_processingDetail1, _ref1, _session_processingStage, _session_processingDetail2;
169
+ return _ts_generator(this, function(_state) {
170
+ switch(_state.label){
171
+ case 0:
172
+ logWorkflowInfo(logger, "Waiting for portal ingestion to finish", {
173
+ step: "ingestion.wait",
174
+ status: "running",
175
+ ingestionSessionId: ingestionSessionId,
176
+ stepProgress: 0
177
+ });
178
+ attempt = 1;
179
+ _state.label = 1;
180
+ case 1:
181
+ if (!(attempt <= options.maxPollAttempts)) return [
182
+ 3,
183
+ 5
184
+ ];
185
+ return [
186
+ 4,
187
+ client.getIngestionSession({
188
+ sessionId: ingestionSessionId,
189
+ ingestionSessionId: ingestionSessionId
190
+ })
191
+ ];
192
+ case 2:
193
+ session = _state.sent();
194
+ if (session.status === "Failed" || session.status === "failed") {
195
+ throw new Error(session.error || session.processingError || "Publication ingestion failed before the bundle was ready");
196
+ }
197
+ nextSnapshot = {
198
+ status: session.status,
199
+ progress: typeof session.processingProgress === "number" ? session.processingProgress : null,
200
+ stage: typeof session.processingStage === "string" ? session.processingStage : null,
201
+ detail: typeof session.processingDetail === "string" ? session.processingDetail : null
202
+ };
203
+ if (!previousSnapshot || previousSnapshot.status !== nextSnapshot.status || previousSnapshot.progress !== nextSnapshot.progress || previousSnapshot.stage !== nextSnapshot.stage || previousSnapshot.detail !== nextSnapshot.detail) {
204
+ previousSnapshot = nextSnapshot;
205
+ statusMessage = buildIngestionStatusMessage(session);
206
+ if (statusMessage) {
207
+ ;
208
+ logWorkflowInfo(logger, statusMessage, {
209
+ step: "ingestion.wait",
210
+ status: "running",
211
+ ingestionSessionId: ingestionSessionId,
212
+ releaseId: (_session_releaseId = session.releaseId) !== null && _session_releaseId !== void 0 ? _session_releaseId : undefined,
213
+ publicationSessionId: (_session_publicationSessionId = session.publicationSessionId) !== null && _session_publicationSessionId !== void 0 ? _session_publicationSessionId : undefined,
214
+ androidPackage: (_session_androidPackage = session.androidPackage) !== null && _session_androidPackage !== void 0 ? _session_androidPackage : undefined,
215
+ versionName: (_session_versionName = session.versionName) !== null && _session_versionName !== void 0 ? _session_versionName : undefined,
216
+ ingestionStatus: (_ref = (_session_processingDetail = session.processingDetail) !== null && _session_processingDetail !== void 0 ? _session_processingDetail : session.processingStage) !== null && _ref !== void 0 ? _ref : session.status,
217
+ ingestionProgress: (_nextSnapshot_progress = nextSnapshot.progress) !== null && _nextSnapshot_progress !== void 0 ? _nextSnapshot_progress : undefined,
218
+ ingestionStage: (_nextSnapshot_stage = nextSnapshot.stage) !== null && _nextSnapshot_stage !== void 0 ? _nextSnapshot_stage : undefined,
219
+ ingestionDetail: (_nextSnapshot_detail = nextSnapshot.detail) !== null && _nextSnapshot_detail !== void 0 ? _nextSnapshot_detail : undefined,
220
+ stepProgress: buildIngestionStatusProgress(session)
221
+ });
222
+ }
223
+ }
224
+ if (isReadyIngestionSession(session)) {
225
+ ;
226
+ logWorkflowInfo(logger, "Portal ingestion is ready", {
227
+ step: "ingestion.wait",
228
+ status: "complete",
229
+ ingestionSessionId: ingestionSessionId,
230
+ releaseId: (_session_releaseId1 = session.releaseId) !== null && _session_releaseId1 !== void 0 ? _session_releaseId1 : undefined,
231
+ publicationSessionId: (_session_publicationSessionId1 = session.publicationSessionId) !== null && _session_publicationSessionId1 !== void 0 ? _session_publicationSessionId1 : undefined,
232
+ androidPackage: (_session_androidPackage1 = session.androidPackage) !== null && _session_androidPackage1 !== void 0 ? _session_androidPackage1 : undefined,
233
+ versionName: (_session_versionName1 = session.versionName) !== null && _session_versionName1 !== void 0 ? _session_versionName1 : undefined,
234
+ ingestionStatus: (_ref1 = (_session_processingDetail1 = session.processingDetail) !== null && _session_processingDetail1 !== void 0 ? _session_processingDetail1 : session.processingStage) !== null && _ref1 !== void 0 ? _ref1 : session.status,
235
+ ingestionProgress: typeof session.processingProgress === "number" ? session.processingProgress : 100,
236
+ ingestionStage: (_session_processingStage = session.processingStage) !== null && _session_processingStage !== void 0 ? _session_processingStage : "Ready",
237
+ ingestionDetail: (_session_processingDetail2 = session.processingDetail) !== null && _session_processingDetail2 !== void 0 ? _session_processingDetail2 : "Publication ingestion is ready",
238
+ stepProgress: 1
239
+ });
240
+ return [
241
+ 2,
242
+ session
243
+ ];
244
+ }
245
+ return [
246
+ 4,
247
+ new Promise(function(resolve) {
248
+ return setTimeout(resolve, options.pollIntervalMs);
249
+ })
250
+ ];
251
+ case 3:
252
+ _state.sent();
253
+ _state.label = 4;
254
+ case 4:
255
+ attempt += 1;
256
+ return [
257
+ 3,
258
+ 1
259
+ ];
260
+ case 5:
261
+ throw new Error("Timed out waiting for ingestion session ".concat(ingestionSessionId, " to become ready"));
262
+ }
263
+ });
264
+ })();
265
+ }