@capgo/capacitor-updater 8.0.1 → 8.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/CapgoCapacitorUpdater.podspec +7 -5
- package/Package.swift +9 -7
- package/README.md +984 -215
- package/android/build.gradle +24 -12
- package/android/proguard-rules.pro +22 -5
- package/android/src/main/java/ee/forgr/capacitor_updater/BundleInfo.java +110 -22
- package/android/src/main/java/ee/forgr/capacitor_updater/Callback.java +2 -2
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +1310 -488
- package/android/src/main/java/ee/forgr/capacitor_updater/{CapacitorUpdater.java → CapgoUpdater.java} +640 -203
- package/android/src/main/java/ee/forgr/capacitor_updater/{CryptoCipherV2.java → CryptoCipher.java} +119 -33
- package/android/src/main/java/ee/forgr/capacitor_updater/DelayCondition.java +0 -3
- package/android/src/main/java/ee/forgr/capacitor_updater/DelayUpdateUtils.java +260 -0
- package/android/src/main/java/ee/forgr/capacitor_updater/DeviceIdHelper.java +221 -0
- package/android/src/main/java/ee/forgr/capacitor_updater/DownloadService.java +497 -133
- package/android/src/main/java/ee/forgr/capacitor_updater/DownloadWorkerManager.java +80 -25
- package/android/src/main/java/ee/forgr/capacitor_updater/Logger.java +338 -0
- package/android/src/main/java/ee/forgr/capacitor_updater/ShakeDetector.java +72 -0
- package/android/src/main/java/ee/forgr/capacitor_updater/ShakeMenu.java +169 -0
- package/dist/docs.json +873 -154
- package/dist/esm/definitions.d.ts +881 -114
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/history.d.ts +1 -0
- package/dist/esm/history.js +283 -0
- package/dist/esm/history.js.map +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/web.d.ts +12 -1
- package/dist/esm/web.js +29 -2
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +311 -2
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +311 -2
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/CapacitorUpdaterPlugin/AES.swift +69 -0
- package/ios/Sources/CapacitorUpdaterPlugin/BigInt.swift +55 -0
- package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/BundleInfo.swift +37 -10
- package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/BundleStatus.swift +1 -1
- package/ios/Sources/CapacitorUpdaterPlugin/CapacitorUpdaterPlugin.swift +1605 -0
- package/ios/{Plugin/CapacitorUpdater.swift → Sources/CapacitorUpdaterPlugin/CapgoUpdater.swift} +523 -230
- package/ios/Sources/CapacitorUpdaterPlugin/CryptoCipher.swift +267 -0
- package/ios/Sources/CapacitorUpdaterPlugin/DelayUpdateUtils.swift +220 -0
- package/ios/Sources/CapacitorUpdaterPlugin/DeviceIdHelper.swift +120 -0
- package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/InternalUtils.swift +53 -0
- package/ios/Sources/CapacitorUpdaterPlugin/Logger.swift +310 -0
- package/ios/Sources/CapacitorUpdaterPlugin/RSA.swift +274 -0
- package/ios/Sources/CapacitorUpdaterPlugin/ShakeMenu.swift +112 -0
- package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/UserDefaultsExtension.swift +0 -2
- package/package.json +21 -19
- package/ios/Plugin/CapacitorUpdaterPlugin.swift +0 -975
- package/ios/Plugin/CryptoCipherV2.swift +0 -310
- /package/{LICENCE → LICENSE} +0 -0
- /package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/DelayCondition.swift +0 -0
- /package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/DelayUntilNext.swift +0 -0
- /package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/Info.plist +0 -0
package/dist/plugin.js
CHANGED
|
@@ -1,6 +1,288 @@
|
|
|
1
1
|
var capacitorCapacitorUpdater = (function (exports, core) {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
+
/*
|
|
5
|
+
* Maintains navigation history across Capgo-controlled reloads when keepUrlPathAfterReload is enabled.
|
|
6
|
+
*/
|
|
7
|
+
const KEEP_FLAG_KEY = '__capgo_keep_url_path_after_reload';
|
|
8
|
+
const HISTORY_STORAGE_KEY = '__capgo_history_stack__';
|
|
9
|
+
const MAX_STACK_ENTRIES = 100;
|
|
10
|
+
const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && typeof history !== 'undefined';
|
|
11
|
+
if (isBrowser) {
|
|
12
|
+
const win = window;
|
|
13
|
+
if (!win.__capgoHistoryPatched) {
|
|
14
|
+
win.__capgoHistoryPatched = true;
|
|
15
|
+
const isFeatureConfigured = () => {
|
|
16
|
+
try {
|
|
17
|
+
if (win.__capgoKeepUrlPathAfterReload) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
// ignore access issues
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
return window.localStorage.getItem(KEEP_FLAG_KEY) === '1';
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const readStored = () => {
|
|
32
|
+
try {
|
|
33
|
+
const raw = window.sessionStorage.getItem(HISTORY_STORAGE_KEY);
|
|
34
|
+
if (!raw) {
|
|
35
|
+
return { stack: [], index: -1 };
|
|
36
|
+
}
|
|
37
|
+
const parsed = JSON.parse(raw);
|
|
38
|
+
if (!parsed || !Array.isArray(parsed.stack) || typeof parsed.index !== 'number') {
|
|
39
|
+
return { stack: [], index: -1 };
|
|
40
|
+
}
|
|
41
|
+
return parsed;
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
return { stack: [], index: -1 };
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const writeStored = (stack, index) => {
|
|
48
|
+
try {
|
|
49
|
+
window.sessionStorage.setItem(HISTORY_STORAGE_KEY, JSON.stringify({ stack, index }));
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
// Storage might be unavailable; fail silently.
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const clearStored = () => {
|
|
56
|
+
try {
|
|
57
|
+
window.sessionStorage.removeItem(HISTORY_STORAGE_KEY);
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
// ignore
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const normalize = (url) => {
|
|
64
|
+
try {
|
|
65
|
+
const base = url !== null && url !== void 0 ? url : window.location.href;
|
|
66
|
+
const parsed = new URL(base instanceof URL ? base.toString() : base, window.location.href);
|
|
67
|
+
return `${parsed.pathname}${parsed.search}${parsed.hash}`;
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const trimStack = (stack, index) => {
|
|
74
|
+
if (stack.length <= MAX_STACK_ENTRIES) {
|
|
75
|
+
return { stack, index };
|
|
76
|
+
}
|
|
77
|
+
const start = stack.length - MAX_STACK_ENTRIES;
|
|
78
|
+
const trimmed = stack.slice(start);
|
|
79
|
+
const adjustedIndex = Math.max(0, index - start);
|
|
80
|
+
return { stack: trimmed, index: adjustedIndex };
|
|
81
|
+
};
|
|
82
|
+
const runWhenReady = (fn) => {
|
|
83
|
+
if (document.readyState === 'complete' || document.readyState === 'interactive') {
|
|
84
|
+
fn();
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
window.addEventListener('DOMContentLoaded', fn, { once: true });
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
let featureActive = false;
|
|
91
|
+
let isRestoring = false;
|
|
92
|
+
let restoreScheduled = false;
|
|
93
|
+
const ensureCurrentTracked = () => {
|
|
94
|
+
if (!featureActive) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const stored = readStored();
|
|
98
|
+
const current = normalize();
|
|
99
|
+
if (!current) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (stored.stack.length === 0) {
|
|
103
|
+
stored.stack.push(current);
|
|
104
|
+
stored.index = 0;
|
|
105
|
+
writeStored(stored.stack, stored.index);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (stored.index < 0 || stored.index >= stored.stack.length) {
|
|
109
|
+
stored.index = stored.stack.length - 1;
|
|
110
|
+
}
|
|
111
|
+
if (stored.stack[stored.index] !== current) {
|
|
112
|
+
stored.stack[stored.index] = current;
|
|
113
|
+
writeStored(stored.stack, stored.index);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
const record = (url, replace) => {
|
|
117
|
+
if (!featureActive || isRestoring) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const normalized = normalize(url);
|
|
121
|
+
if (!normalized) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
let { stack, index } = readStored();
|
|
125
|
+
if (stack.length === 0) {
|
|
126
|
+
stack.push(normalized);
|
|
127
|
+
index = stack.length - 1;
|
|
128
|
+
}
|
|
129
|
+
else if (replace) {
|
|
130
|
+
if (index < 0 || index >= stack.length) {
|
|
131
|
+
index = stack.length - 1;
|
|
132
|
+
}
|
|
133
|
+
stack[index] = normalized;
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
if (index >= stack.length - 1) {
|
|
137
|
+
stack.push(normalized);
|
|
138
|
+
index = stack.length - 1;
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
stack = stack.slice(0, index + 1);
|
|
142
|
+
stack.push(normalized);
|
|
143
|
+
index = stack.length - 1;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
({ stack, index } = trimStack(stack, index));
|
|
147
|
+
writeStored(stack, index);
|
|
148
|
+
};
|
|
149
|
+
const restoreHistory = () => {
|
|
150
|
+
if (!featureActive || isRestoring) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const stored = readStored();
|
|
154
|
+
if (stored.stack.length === 0) {
|
|
155
|
+
ensureCurrentTracked();
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const targetIndex = stored.index >= 0 && stored.index < stored.stack.length ? stored.index : stored.stack.length - 1;
|
|
159
|
+
const normalizedCurrent = normalize();
|
|
160
|
+
if (stored.stack.length === 1 && normalizedCurrent === stored.stack[0]) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const firstEntry = stored.stack[0];
|
|
164
|
+
if (!firstEntry) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
isRestoring = true;
|
|
168
|
+
try {
|
|
169
|
+
history.replaceState(history.state, document.title, firstEntry);
|
|
170
|
+
for (let i = 1; i < stored.stack.length; i += 1) {
|
|
171
|
+
history.pushState(history.state, document.title, stored.stack[i]);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
catch (err) {
|
|
175
|
+
isRestoring = false;
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
isRestoring = false;
|
|
179
|
+
const currentIndex = stored.stack.length - 1;
|
|
180
|
+
const offset = targetIndex - currentIndex;
|
|
181
|
+
if (offset !== 0) {
|
|
182
|
+
history.go(offset);
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
history.replaceState(history.state, document.title, stored.stack[targetIndex]);
|
|
186
|
+
window.dispatchEvent(new PopStateEvent('popstate'));
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
const scheduleRestore = () => {
|
|
190
|
+
if (!featureActive || restoreScheduled) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
restoreScheduled = true;
|
|
194
|
+
runWhenReady(() => {
|
|
195
|
+
restoreScheduled = false;
|
|
196
|
+
restoreHistory();
|
|
197
|
+
});
|
|
198
|
+
};
|
|
199
|
+
let originalPushState = null;
|
|
200
|
+
let originalReplaceState = null;
|
|
201
|
+
const popstateHandler = () => {
|
|
202
|
+
if (!featureActive || isRestoring) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
const normalized = normalize();
|
|
206
|
+
if (!normalized) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
const stored = readStored();
|
|
210
|
+
const idx = stored.stack.lastIndexOf(normalized);
|
|
211
|
+
if (idx >= 0) {
|
|
212
|
+
stored.index = idx;
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
stored.stack.push(normalized);
|
|
216
|
+
stored.index = stored.stack.length - 1;
|
|
217
|
+
}
|
|
218
|
+
const trimmed = trimStack(stored.stack, stored.index);
|
|
219
|
+
writeStored(trimmed.stack, trimmed.index);
|
|
220
|
+
};
|
|
221
|
+
const patchHistory = () => {
|
|
222
|
+
if (originalPushState && originalReplaceState) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
originalPushState = history.pushState;
|
|
226
|
+
originalReplaceState = history.replaceState;
|
|
227
|
+
history.pushState = function pushStatePatched(state, title, url) {
|
|
228
|
+
const result = originalPushState.call(history, state, title, url);
|
|
229
|
+
record(url, false);
|
|
230
|
+
return result;
|
|
231
|
+
};
|
|
232
|
+
history.replaceState = function replaceStatePatched(state, title, url) {
|
|
233
|
+
const result = originalReplaceState.call(history, state, title, url);
|
|
234
|
+
record(url, true);
|
|
235
|
+
return result;
|
|
236
|
+
};
|
|
237
|
+
window.addEventListener('popstate', popstateHandler);
|
|
238
|
+
};
|
|
239
|
+
const unpatchHistory = () => {
|
|
240
|
+
if (originalPushState) {
|
|
241
|
+
history.pushState = originalPushState;
|
|
242
|
+
originalPushState = null;
|
|
243
|
+
}
|
|
244
|
+
if (originalReplaceState) {
|
|
245
|
+
history.replaceState = originalReplaceState;
|
|
246
|
+
originalReplaceState = null;
|
|
247
|
+
}
|
|
248
|
+
window.removeEventListener('popstate', popstateHandler);
|
|
249
|
+
};
|
|
250
|
+
const setFeatureActive = (enabled) => {
|
|
251
|
+
if (featureActive === enabled) {
|
|
252
|
+
if (featureActive) {
|
|
253
|
+
ensureCurrentTracked();
|
|
254
|
+
scheduleRestore();
|
|
255
|
+
}
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
featureActive = enabled;
|
|
259
|
+
if (featureActive) {
|
|
260
|
+
patchHistory();
|
|
261
|
+
ensureCurrentTracked();
|
|
262
|
+
scheduleRestore();
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
unpatchHistory();
|
|
266
|
+
clearStored();
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
window.addEventListener('CapacitorUpdaterKeepUrlPathAfterReload', (event) => {
|
|
270
|
+
var _a;
|
|
271
|
+
const evt = event;
|
|
272
|
+
const enabled = (_a = evt === null || evt === void 0 ? void 0 : evt.detail) === null || _a === void 0 ? void 0 : _a.enabled;
|
|
273
|
+
if (typeof enabled === 'boolean') {
|
|
274
|
+
win.__capgoKeepUrlPathAfterReload = enabled;
|
|
275
|
+
setFeatureActive(enabled);
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
win.__capgoKeepUrlPathAfterReload = true;
|
|
279
|
+
setFeatureActive(true);
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
setFeatureActive(isFeatureConfigured());
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
4
286
|
/*
|
|
5
287
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
6
288
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
@@ -66,6 +348,10 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
66
348
|
async delete(options) {
|
|
67
349
|
console.warn('Cannot delete bundle in web', options);
|
|
68
350
|
}
|
|
351
|
+
async setBundleError(options) {
|
|
352
|
+
console.warn('Cannot setBundleError in web', options);
|
|
353
|
+
return BUNDLE_BUILTIN;
|
|
354
|
+
}
|
|
69
355
|
async list() {
|
|
70
356
|
console.warn('Cannot list bundles in web');
|
|
71
357
|
return { bundles: [] };
|
|
@@ -110,8 +396,14 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
110
396
|
error: 'Cannot getChannel in web',
|
|
111
397
|
};
|
|
112
398
|
}
|
|
399
|
+
async listChannels() {
|
|
400
|
+
console.warn('Cannot listChannels in web');
|
|
401
|
+
throw {
|
|
402
|
+
message: 'Cannot listChannels in web',
|
|
403
|
+
error: 'platform_not_supported',
|
|
404
|
+
};
|
|
405
|
+
}
|
|
113
406
|
async notifyAppReady() {
|
|
114
|
-
console.warn('Cannot notify App Ready in web');
|
|
115
407
|
return { bundle: BUNDLE_BUILTIN };
|
|
116
408
|
}
|
|
117
409
|
async setMultiDelay(options) {
|
|
@@ -135,9 +427,26 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
135
427
|
return BUNDLE_BUILTIN;
|
|
136
428
|
}
|
|
137
429
|
async getNextBundle() {
|
|
138
|
-
|
|
430
|
+
return Promise.resolve(null);
|
|
431
|
+
}
|
|
432
|
+
async getFailedUpdate() {
|
|
433
|
+
console.warn('Cannot getFailedUpdate in web');
|
|
139
434
|
return null;
|
|
140
435
|
}
|
|
436
|
+
async setShakeMenu(_options) {
|
|
437
|
+
throw this.unimplemented('Shake menu not available on web platform');
|
|
438
|
+
}
|
|
439
|
+
async isShakeMenuEnabled() {
|
|
440
|
+
return Promise.resolve({ enabled: false });
|
|
441
|
+
}
|
|
442
|
+
async getAppId() {
|
|
443
|
+
console.warn('Cannot getAppId in web');
|
|
444
|
+
return { appId: 'default' };
|
|
445
|
+
}
|
|
446
|
+
async setAppId(options) {
|
|
447
|
+
console.warn('Cannot setAppId in web', options);
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
141
450
|
}
|
|
142
451
|
|
|
143
452
|
var web = /*#__PURE__*/Object.freeze({
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["/*\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at https://mozilla.org/MPL/2.0/.\n */\nimport { registerPlugin } from '@capacitor/core';\nconst CapacitorUpdater = registerPlugin('CapacitorUpdater', {\n web: () => import('./web').then((m) => new m.CapacitorUpdaterWeb()),\n});\nexport * from './definitions';\nexport { CapacitorUpdater };\n//# sourceMappingURL=index.js.map","/*\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at https://mozilla.org/MPL/2.0/.\n */\nimport { WebPlugin } from '@capacitor/core';\nconst BUNDLE_BUILTIN = {\n status: 'success',\n version: '',\n downloaded: '1970-01-01T00:00:00.000Z',\n id: 'builtin',\n checksum: '',\n};\nexport class CapacitorUpdaterWeb extends WebPlugin {\n async setStatsUrl(options) {\n console.warn('Cannot setStatsUrl in web', options);\n return;\n }\n async setUpdateUrl(options) {\n console.warn('Cannot setUpdateUrl in web', options);\n return;\n }\n async setChannelUrl(options) {\n console.warn('Cannot setChannelUrl in web', options);\n return;\n }\n async download(options) {\n console.warn('Cannot download version in web', options);\n return BUNDLE_BUILTIN;\n }\n async next(options) {\n console.warn('Cannot set next version in web', options);\n return BUNDLE_BUILTIN;\n }\n async isAutoUpdateEnabled() {\n console.warn('Cannot get isAutoUpdateEnabled in web');\n return { enabled: false };\n }\n async set(options) {\n console.warn('Cannot set active bundle in web', options);\n return;\n }\n async getDeviceId() {\n console.warn('Cannot get ID in web');\n return { deviceId: 'default' };\n }\n async getBuiltinVersion() {\n console.warn('Cannot get version in web');\n return { version: 'default' };\n }\n async getPluginVersion() {\n console.warn('Cannot get plugin version in web');\n return { version: 'default' };\n }\n async delete(options) {\n console.warn('Cannot delete bundle in web', options);\n }\n async list() {\n console.warn('Cannot list bundles in web');\n return { bundles: [] };\n }\n async reset(options) {\n console.warn('Cannot reset version in web', options);\n }\n async current() {\n console.warn('Cannot get current bundle in web');\n return { bundle: BUNDLE_BUILTIN, native: '0.0.0' };\n }\n async reload() {\n console.warn('Cannot reload current bundle in web');\n return;\n }\n async getLatest() {\n console.warn('Cannot getLatest current bundle in web');\n return {\n version: '0.0.0',\n message: 'Cannot getLatest current bundle in web',\n };\n }\n async setChannel(options) {\n console.warn('Cannot setChannel in web', options);\n return {\n status: 'error',\n error: 'Cannot setChannel in web',\n };\n }\n async unsetChannel(options) {\n console.warn('Cannot unsetChannel in web', options);\n return;\n }\n async setCustomId(options) {\n console.warn('Cannot setCustomId in web', options);\n return;\n }\n async getChannel() {\n console.warn('Cannot getChannel in web');\n return {\n status: 'error',\n error: 'Cannot getChannel in web',\n };\n }\n async notifyAppReady() {\n console.warn('Cannot notify App Ready in web');\n return { bundle: BUNDLE_BUILTIN };\n }\n async setMultiDelay(options) {\n console.warn('Cannot setMultiDelay in web', options === null || options === void 0 ? void 0 : options.delayConditions);\n return;\n }\n async setDelay(option) {\n console.warn('Cannot setDelay in web', option);\n return;\n }\n async cancelDelay() {\n console.warn('Cannot cancelDelay in web');\n return;\n }\n async isAutoUpdateAvailable() {\n console.warn('Cannot isAutoUpdateAvailable in web');\n return { available: false };\n }\n async getCurrentBundle() {\n console.warn('Cannot get current bundle in web');\n return BUNDLE_BUILTIN;\n }\n async getNextBundle() {\n console.warn('Cannot get next bundle in web');\n return null;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;IAAA;IACA;IACA;IACA;IACA;AAEK,UAAC,gBAAgB,GAAGA,mBAAc,CAAC,kBAAkB,EAAE;IAC5D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,mBAAmB,EAAE,CAAC;IACvE,CAAC;;ICRD;IACA;IACA;IACA;IACA;IAEA,MAAM,cAAc,GAAG;IACvB,IAAI,MAAM,EAAE,SAAS;IACrB,IAAI,OAAO,EAAE,EAAE;IACf,IAAI,UAAU,EAAE,0BAA0B;IAC1C,IAAI,EAAE,EAAE,SAAS;IACjB,IAAI,QAAQ,EAAE,EAAE;IAChB,CAAC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A+B,CAAC;IACrD,QAAQ,OAAO,IAAI;IACnB;IACA;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/history.js","esm/index.js","esm/web.js"],"sourcesContent":["/*\n * Maintains navigation history across Capgo-controlled reloads when keepUrlPathAfterReload is enabled.\n */\nconst KEEP_FLAG_KEY = '__capgo_keep_url_path_after_reload';\nconst HISTORY_STORAGE_KEY = '__capgo_history_stack__';\nconst MAX_STACK_ENTRIES = 100;\nconst isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && typeof history !== 'undefined';\nif (isBrowser) {\n const win = window;\n if (!win.__capgoHistoryPatched) {\n win.__capgoHistoryPatched = true;\n const isFeatureConfigured = () => {\n try {\n if (win.__capgoKeepUrlPathAfterReload) {\n return true;\n }\n }\n catch (err) {\n // ignore access issues\n }\n try {\n return window.localStorage.getItem(KEEP_FLAG_KEY) === '1';\n }\n catch (err) {\n return false;\n }\n };\n const readStored = () => {\n try {\n const raw = window.sessionStorage.getItem(HISTORY_STORAGE_KEY);\n if (!raw) {\n return { stack: [], index: -1 };\n }\n const parsed = JSON.parse(raw);\n if (!parsed || !Array.isArray(parsed.stack) || typeof parsed.index !== 'number') {\n return { stack: [], index: -1 };\n }\n return parsed;\n }\n catch (err) {\n return { stack: [], index: -1 };\n }\n };\n const writeStored = (stack, index) => {\n try {\n window.sessionStorage.setItem(HISTORY_STORAGE_KEY, JSON.stringify({ stack, index }));\n }\n catch (err) {\n // Storage might be unavailable; fail silently.\n }\n };\n const clearStored = () => {\n try {\n window.sessionStorage.removeItem(HISTORY_STORAGE_KEY);\n }\n catch (err) {\n // ignore\n }\n };\n const normalize = (url) => {\n try {\n const base = url !== null && url !== void 0 ? url : window.location.href;\n const parsed = new URL(base instanceof URL ? base.toString() : base, window.location.href);\n return `${parsed.pathname}${parsed.search}${parsed.hash}`;\n }\n catch (err) {\n return null;\n }\n };\n const trimStack = (stack, index) => {\n if (stack.length <= MAX_STACK_ENTRIES) {\n return { stack, index };\n }\n const start = stack.length - MAX_STACK_ENTRIES;\n const trimmed = stack.slice(start);\n const adjustedIndex = Math.max(0, index - start);\n return { stack: trimmed, index: adjustedIndex };\n };\n const runWhenReady = (fn) => {\n if (document.readyState === 'complete' || document.readyState === 'interactive') {\n fn();\n }\n else {\n window.addEventListener('DOMContentLoaded', fn, { once: true });\n }\n };\n let featureActive = false;\n let isRestoring = false;\n let restoreScheduled = false;\n const ensureCurrentTracked = () => {\n if (!featureActive) {\n return;\n }\n const stored = readStored();\n const current = normalize();\n if (!current) {\n return;\n }\n if (stored.stack.length === 0) {\n stored.stack.push(current);\n stored.index = 0;\n writeStored(stored.stack, stored.index);\n return;\n }\n if (stored.index < 0 || stored.index >= stored.stack.length) {\n stored.index = stored.stack.length - 1;\n }\n if (stored.stack[stored.index] !== current) {\n stored.stack[stored.index] = current;\n writeStored(stored.stack, stored.index);\n }\n };\n const record = (url, replace) => {\n if (!featureActive || isRestoring) {\n return;\n }\n const normalized = normalize(url);\n if (!normalized) {\n return;\n }\n let { stack, index } = readStored();\n if (stack.length === 0) {\n stack.push(normalized);\n index = stack.length - 1;\n }\n else if (replace) {\n if (index < 0 || index >= stack.length) {\n index = stack.length - 1;\n }\n stack[index] = normalized;\n }\n else {\n if (index >= stack.length - 1) {\n stack.push(normalized);\n index = stack.length - 1;\n }\n else {\n stack = stack.slice(0, index + 1);\n stack.push(normalized);\n index = stack.length - 1;\n }\n }\n ({ stack, index } = trimStack(stack, index));\n writeStored(stack, index);\n };\n const restoreHistory = () => {\n if (!featureActive || isRestoring) {\n return;\n }\n const stored = readStored();\n if (stored.stack.length === 0) {\n ensureCurrentTracked();\n return;\n }\n const targetIndex = stored.index >= 0 && stored.index < stored.stack.length ? stored.index : stored.stack.length - 1;\n const normalizedCurrent = normalize();\n if (stored.stack.length === 1 && normalizedCurrent === stored.stack[0]) {\n return;\n }\n const firstEntry = stored.stack[0];\n if (!firstEntry) {\n return;\n }\n isRestoring = true;\n try {\n history.replaceState(history.state, document.title, firstEntry);\n for (let i = 1; i < stored.stack.length; i += 1) {\n history.pushState(history.state, document.title, stored.stack[i]);\n }\n }\n catch (err) {\n isRestoring = false;\n return;\n }\n isRestoring = false;\n const currentIndex = stored.stack.length - 1;\n const offset = targetIndex - currentIndex;\n if (offset !== 0) {\n history.go(offset);\n }\n else {\n history.replaceState(history.state, document.title, stored.stack[targetIndex]);\n window.dispatchEvent(new PopStateEvent('popstate'));\n }\n };\n const scheduleRestore = () => {\n if (!featureActive || restoreScheduled) {\n return;\n }\n restoreScheduled = true;\n runWhenReady(() => {\n restoreScheduled = false;\n restoreHistory();\n });\n };\n let originalPushState = null;\n let originalReplaceState = null;\n const popstateHandler = () => {\n if (!featureActive || isRestoring) {\n return;\n }\n const normalized = normalize();\n if (!normalized) {\n return;\n }\n const stored = readStored();\n const idx = stored.stack.lastIndexOf(normalized);\n if (idx >= 0) {\n stored.index = idx;\n }\n else {\n stored.stack.push(normalized);\n stored.index = stored.stack.length - 1;\n }\n const trimmed = trimStack(stored.stack, stored.index);\n writeStored(trimmed.stack, trimmed.index);\n };\n const patchHistory = () => {\n if (originalPushState && originalReplaceState) {\n return;\n }\n originalPushState = history.pushState;\n originalReplaceState = history.replaceState;\n history.pushState = function pushStatePatched(state, title, url) {\n const result = originalPushState.call(history, state, title, url);\n record(url, false);\n return result;\n };\n history.replaceState = function replaceStatePatched(state, title, url) {\n const result = originalReplaceState.call(history, state, title, url);\n record(url, true);\n return result;\n };\n window.addEventListener('popstate', popstateHandler);\n };\n const unpatchHistory = () => {\n if (originalPushState) {\n history.pushState = originalPushState;\n originalPushState = null;\n }\n if (originalReplaceState) {\n history.replaceState = originalReplaceState;\n originalReplaceState = null;\n }\n window.removeEventListener('popstate', popstateHandler);\n };\n const setFeatureActive = (enabled) => {\n if (featureActive === enabled) {\n if (featureActive) {\n ensureCurrentTracked();\n scheduleRestore();\n }\n return;\n }\n featureActive = enabled;\n if (featureActive) {\n patchHistory();\n ensureCurrentTracked();\n scheduleRestore();\n }\n else {\n unpatchHistory();\n clearStored();\n }\n };\n window.addEventListener('CapacitorUpdaterKeepUrlPathAfterReload', (event) => {\n var _a;\n const evt = event;\n const enabled = (_a = evt === null || evt === void 0 ? void 0 : evt.detail) === null || _a === void 0 ? void 0 : _a.enabled;\n if (typeof enabled === 'boolean') {\n win.__capgoKeepUrlPathAfterReload = enabled;\n setFeatureActive(enabled);\n }\n else {\n win.__capgoKeepUrlPathAfterReload = true;\n setFeatureActive(true);\n }\n });\n setFeatureActive(isFeatureConfigured());\n }\n}\nexport {};\n//# sourceMappingURL=history.js.map","/*\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at https://mozilla.org/MPL/2.0/.\n */\nimport { registerPlugin } from '@capacitor/core';\nimport './history';\nconst CapacitorUpdater = registerPlugin('CapacitorUpdater', {\n web: () => import('./web').then((m) => new m.CapacitorUpdaterWeb()),\n});\nexport * from './definitions';\nexport { CapacitorUpdater };\n//# sourceMappingURL=index.js.map","/*\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at https://mozilla.org/MPL/2.0/.\n */\nimport { WebPlugin } from '@capacitor/core';\nconst BUNDLE_BUILTIN = {\n status: 'success',\n version: '',\n downloaded: '1970-01-01T00:00:00.000Z',\n id: 'builtin',\n checksum: '',\n};\nexport class CapacitorUpdaterWeb extends WebPlugin {\n async setStatsUrl(options) {\n console.warn('Cannot setStatsUrl in web', options);\n return;\n }\n async setUpdateUrl(options) {\n console.warn('Cannot setUpdateUrl in web', options);\n return;\n }\n async setChannelUrl(options) {\n console.warn('Cannot setChannelUrl in web', options);\n return;\n }\n async download(options) {\n console.warn('Cannot download version in web', options);\n return BUNDLE_BUILTIN;\n }\n async next(options) {\n console.warn('Cannot set next version in web', options);\n return BUNDLE_BUILTIN;\n }\n async isAutoUpdateEnabled() {\n console.warn('Cannot get isAutoUpdateEnabled in web');\n return { enabled: false };\n }\n async set(options) {\n console.warn('Cannot set active bundle in web', options);\n return;\n }\n async getDeviceId() {\n console.warn('Cannot get ID in web');\n return { deviceId: 'default' };\n }\n async getBuiltinVersion() {\n console.warn('Cannot get version in web');\n return { version: 'default' };\n }\n async getPluginVersion() {\n console.warn('Cannot get plugin version in web');\n return { version: 'default' };\n }\n async delete(options) {\n console.warn('Cannot delete bundle in web', options);\n }\n async setBundleError(options) {\n console.warn('Cannot setBundleError in web', options);\n return BUNDLE_BUILTIN;\n }\n async list() {\n console.warn('Cannot list bundles in web');\n return { bundles: [] };\n }\n async reset(options) {\n console.warn('Cannot reset version in web', options);\n }\n async current() {\n console.warn('Cannot get current bundle in web');\n return { bundle: BUNDLE_BUILTIN, native: '0.0.0' };\n }\n async reload() {\n console.warn('Cannot reload current bundle in web');\n return;\n }\n async getLatest() {\n console.warn('Cannot getLatest current bundle in web');\n return {\n version: '0.0.0',\n message: 'Cannot getLatest current bundle in web',\n };\n }\n async setChannel(options) {\n console.warn('Cannot setChannel in web', options);\n return {\n status: 'error',\n error: 'Cannot setChannel in web',\n };\n }\n async unsetChannel(options) {\n console.warn('Cannot unsetChannel in web', options);\n return;\n }\n async setCustomId(options) {\n console.warn('Cannot setCustomId in web', options);\n return;\n }\n async getChannel() {\n console.warn('Cannot getChannel in web');\n return {\n status: 'error',\n error: 'Cannot getChannel in web',\n };\n }\n async listChannels() {\n console.warn('Cannot listChannels in web');\n throw {\n message: 'Cannot listChannels in web',\n error: 'platform_not_supported',\n };\n }\n async notifyAppReady() {\n return { bundle: BUNDLE_BUILTIN };\n }\n async setMultiDelay(options) {\n console.warn('Cannot setMultiDelay in web', options === null || options === void 0 ? void 0 : options.delayConditions);\n return;\n }\n async setDelay(option) {\n console.warn('Cannot setDelay in web', option);\n return;\n }\n async cancelDelay() {\n console.warn('Cannot cancelDelay in web');\n return;\n }\n async isAutoUpdateAvailable() {\n console.warn('Cannot isAutoUpdateAvailable in web');\n return { available: false };\n }\n async getCurrentBundle() {\n console.warn('Cannot get current bundle in web');\n return BUNDLE_BUILTIN;\n }\n async getNextBundle() {\n return Promise.resolve(null);\n }\n async getFailedUpdate() {\n console.warn('Cannot getFailedUpdate in web');\n return null;\n }\n async setShakeMenu(_options) {\n throw this.unimplemented('Shake menu not available on web platform');\n }\n async isShakeMenuEnabled() {\n return Promise.resolve({ enabled: false });\n }\n async getAppId() {\n console.warn('Cannot getAppId in web');\n return { appId: 'default' };\n }\n async setAppId(options) {\n console.warn('Cannot setAppId in web', options);\n return;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;IAAA;IACA;IACA;IACA,MAAM,aAAa,GAAG,oCAAoC;IAC1D,MAAM,mBAAmB,GAAG,yBAAyB;IACrD,MAAM,iBAAiB,GAAG,GAAG;IAC7B,MAAM,SAAS,GAAG,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,QAAQ,KAAK,WAAW,IAAI,OAAO,OAAO,KAAK,WAAW;IACpH,IAAI,SAAS,EAAE;IACf,IAAI,MAAM,GAAG,GAAG,MAAM;IACtB,IAAI,IAAI,CAAC,GAAG,CAAC,qBAAqB,EAAE;IACpC,QAAQ,GAAG,CAAC,qBAAqB,GAAG,IAAI;IACxC,QAAQ,MAAM,mBAAmB,GAAG,MAAM;IAC1C,YAAY,IAAI;IAChB,gBAAgB,IAAI,GAAG,CAAC,6BAA6B,EAAE;IACvD,oBAAoB,OAAO,IAAI;IAC/B,gBAAgB;IAChB,YAAY;IACZ,YAAY,OAAO,GAAG,EAAE;IACxB;IACA,YAAY;IACZ,YAAY,IAAI;IAChB,gBAAgB,OAAO,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,GAAG;IACzE,YAAY;IACZ,YAAY,OAAO,GAAG,EAAE;IACxB,gBAAgB,OAAO,KAAK;IAC5B,YAAY;IACZ,QAAQ,CAAC;IACT,QAAQ,MAAM,UAAU,GAAG,MAAM;IACjC,YAAY,I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,QAAQ,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE;IACnC,IAAI;IACJ,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,CAAC,IAAI,CAAC,kCAAkC,CAAC;IACxD,QAAQ,OAAO,cAAc;IAC7B,IAAI;IACJ,IAAI,MAAM,aAAa,GAAG;IAC1B,QAAQ,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;IACpC,IAAI;IACJ,IAAI,MAAM,eAAe,GAAG;IAC5B,QAAQ,OAAO,CAAC,IAAI,CAAC,+BAA+B,CAAC;IACrD,QAAQ,OAAO,IAAI;IACnB,IAAI;IACJ,IAAI,MAAM,YAAY,CAAC,QAAQ,EAAE;IACjC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,0CAA0C,CAAC;IAC5E,IAAI;IACJ,IAAI,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAClD,IAAI;IACJ,IAAI,MAAM,QAAQ,GAAG;IACrB,QAAQ,OAAO,CAAC,IAAI,CAAC,wBAAwB,CAAC;IAC9C,QAAQ,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE;IACnC,IAAI;IACJ,IAAI,MAAM,QAAQ,CAAC,OAAO,EAAE;IAC5B,QAAQ,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAE,OAAO,CAAC;IACvD,QAAQ;IACR,IAAI;IACJ;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import BigInt
|
|
2
|
+
import Foundation
|
|
3
|
+
import CommonCrypto
|
|
4
|
+
import CryptoKit
|
|
5
|
+
|
|
6
|
+
///
|
|
7
|
+
/// Constants
|
|
8
|
+
///
|
|
9
|
+
private enum AESConstants {
|
|
10
|
+
static let aesAlgorithm: CCAlgorithm = CCAlgorithm(kCCAlgorithmAES)
|
|
11
|
+
static let aesOptions: CCOptions = CCOptions(kCCOptionPKCS7Padding)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// We do all this stuff because ios is shit and open source libraries allow to do decryption with public key
|
|
15
|
+
// So we have to do it manually, while in nodejs or Java it's ok and done at language level.
|
|
16
|
+
|
|
17
|
+
///
|
|
18
|
+
/// The AES key. Contains both the initialization vector and secret key.
|
|
19
|
+
///
|
|
20
|
+
public struct AES128Key {
|
|
21
|
+
/// Initialization vector
|
|
22
|
+
private let iv: Data
|
|
23
|
+
private let logger: Logger
|
|
24
|
+
private let aes128Key: Data
|
|
25
|
+
#if DEBUG
|
|
26
|
+
public var __debug_iv: Data { iv }
|
|
27
|
+
public var __debug_aes128Key: Data { aes128Key }
|
|
28
|
+
#endif
|
|
29
|
+
init(iv: Data, aes128Key: Data, logger: Logger) {
|
|
30
|
+
self.iv = iv
|
|
31
|
+
self.aes128Key = aes128Key
|
|
32
|
+
self.logger = logger
|
|
33
|
+
}
|
|
34
|
+
///
|
|
35
|
+
/// Takes the data and uses the private key to decrypt it. Will call `CCCrypt` in CommonCrypto
|
|
36
|
+
/// and provide it `ivData` for the initialization vector. Will use cipher block chaining (CBC) as
|
|
37
|
+
/// the mode of operation.
|
|
38
|
+
///
|
|
39
|
+
/// Returns the decrypted data.
|
|
40
|
+
///
|
|
41
|
+
public func decrypt(data: Data) -> Data? {
|
|
42
|
+
let encryptedData: UnsafePointer<UInt8> = (data as NSData).bytes.bindMemory(to: UInt8.self, capacity: data.count)
|
|
43
|
+
let encryptedDataLength: Int = data.count
|
|
44
|
+
|
|
45
|
+
if let result: NSMutableData = NSMutableData(length: encryptedDataLength) {
|
|
46
|
+
let keyData: UnsafePointer<UInt8> = (self.aes128Key as NSData).bytes.bindMemory(to: UInt8.self, capacity: self.aes128Key.count)
|
|
47
|
+
let keyLength: size_t = size_t(self.aes128Key.count)
|
|
48
|
+
let ivData: UnsafePointer<UInt8> = (iv as NSData).bytes.bindMemory(to: UInt8.self, capacity: self.iv.count)
|
|
49
|
+
|
|
50
|
+
let decryptedData: UnsafeMutablePointer<UInt8> = UnsafeMutablePointer<UInt8>(result.mutableBytes.assumingMemoryBound(to: UInt8.self))
|
|
51
|
+
let decryptedDataLength: size_t = size_t(result.length)
|
|
52
|
+
|
|
53
|
+
var decryptedLength: size_t = 0
|
|
54
|
+
|
|
55
|
+
let status: CCCryptorStatus = CCCrypt(CCOperation(kCCDecrypt), AESConstants.aesAlgorithm, AESConstants.aesOptions, keyData, keyLength, ivData, encryptedData, encryptedDataLength, decryptedData, decryptedDataLength, &decryptedLength)
|
|
56
|
+
|
|
57
|
+
if Int32(status) == Int32(kCCSuccess) {
|
|
58
|
+
result.length = Int(decryptedLength)
|
|
59
|
+
return result as Data
|
|
60
|
+
} else {
|
|
61
|
+
logger.error("AES decryption failed with status: \(status)")
|
|
62
|
+
return nil
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
logger.error("Failed to allocate memory for AES decryption")
|
|
66
|
+
return nil
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import BigInt
|
|
2
|
+
|
|
3
|
+
// Extension to serialize BigInt to bytes array
|
|
4
|
+
extension BigInt {
|
|
5
|
+
func serializeToBytes() -> [UInt8] {
|
|
6
|
+
let byteCount = (self.bitWidth + 7) / 8
|
|
7
|
+
var bytes = [UInt8](repeating: 0, count: byteCount)
|
|
8
|
+
|
|
9
|
+
var value = self
|
|
10
|
+
for i in 0..<byteCount {
|
|
11
|
+
bytes[byteCount - i - 1] = UInt8(truncatingIfNeeded: value & 0xFF)
|
|
12
|
+
value >>= 8
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return bytes
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Add this custom power function to ensure safer handling of power operations
|
|
20
|
+
|
|
21
|
+
// Manual exponentiation using the square-and-multiply algorithm
|
|
22
|
+
// which is more efficient and avoids using the built-in functions that might handle BigInt differently
|
|
23
|
+
extension BigInt {
|
|
24
|
+
func manualPower(_ exponent: BigInt, modulus: BigInt) -> BigInt {
|
|
25
|
+
// Quick checks
|
|
26
|
+
if modulus == 0 {
|
|
27
|
+
return 0
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if exponent == 0 {
|
|
31
|
+
return 1
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
guard let base = self.magnitude as? BigUInt,
|
|
35
|
+
let exp = exponent.magnitude as? BigUInt,
|
|
36
|
+
let mod = modulus.magnitude as? BigUInt else {
|
|
37
|
+
return 0
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Square and multiply algorithm for modular exponentiation
|
|
41
|
+
var result = BigUInt(1)
|
|
42
|
+
var x = base % mod
|
|
43
|
+
var e = exp
|
|
44
|
+
|
|
45
|
+
while e > 0 {
|
|
46
|
+
if e & 1 == 1 {
|
|
47
|
+
result = (result * x) % mod
|
|
48
|
+
}
|
|
49
|
+
x = (x * x) % mod
|
|
50
|
+
e >>= 1
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return BigInt(result)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -16,21 +16,25 @@ import Foundation
|
|
|
16
16
|
private let version: String
|
|
17
17
|
private let checksum: String
|
|
18
18
|
private let status: BundleStatus
|
|
19
|
+
private let link: String?
|
|
20
|
+
private let comment: String?
|
|
19
21
|
|
|
20
|
-
convenience init(id: String, version: String, status: BundleStatus, downloaded: Date, checksum: String) {
|
|
21
|
-
self.init(id: id, version: version, status: status, downloaded: downloaded.iso8601withFractionalSeconds, checksum: checksum)
|
|
22
|
+
convenience init(id: String, version: String, status: BundleStatus, downloaded: Date, checksum: String, link: String? = nil, comment: String? = nil) {
|
|
23
|
+
self.init(id: id, version: version, status: status, downloaded: downloaded.iso8601withFractionalSeconds, checksum: checksum, link: link, comment: comment)
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
init(id: String, version: String, status: BundleStatus, downloaded: String = BundleInfo.DOWNLOADED_BUILTIN, checksum: String) {
|
|
26
|
+
init(id: String, version: String, status: BundleStatus, downloaded: String = BundleInfo.DOWNLOADED_BUILTIN, checksum: String, link: String? = nil, comment: String? = nil) {
|
|
25
27
|
self.downloaded = downloaded.trim()
|
|
26
28
|
self.id = id
|
|
27
29
|
self.version = version
|
|
28
30
|
self.checksum = checksum
|
|
29
31
|
self.status = status
|
|
32
|
+
self.link = link
|
|
33
|
+
self.comment = comment
|
|
30
34
|
}
|
|
31
35
|
|
|
32
36
|
enum CodingKeys: String, CodingKey {
|
|
33
|
-
case downloaded, id, version, status, checksum
|
|
37
|
+
case downloaded, id, version, status, checksum, link, comment
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
public func isBuiltin() -> Bool {
|
|
@@ -62,11 +66,11 @@ import Foundation
|
|
|
62
66
|
}
|
|
63
67
|
|
|
64
68
|
public func setChecksum(checksum: String) -> BundleInfo {
|
|
65
|
-
return BundleInfo(id: self.id, version: self.version, status: self.status, downloaded: self.downloaded, checksum: checksum)
|
|
69
|
+
return BundleInfo(id: self.id, version: self.version, status: self.status, downloaded: self.downloaded, checksum: checksum, link: self.link, comment: self.comment)
|
|
66
70
|
}
|
|
67
71
|
|
|
68
72
|
public func setDownloaded(downloaded: Date) -> BundleInfo {
|
|
69
|
-
return BundleInfo(id: self.id, version: self.version, status: self.status, downloaded: downloaded, checksum: self.checksum)
|
|
73
|
+
return BundleInfo(id: self.id, version: self.version, status: self.status, downloaded: downloaded, checksum: self.checksum, link: self.link, comment: self.comment)
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
public func getId() -> String {
|
|
@@ -74,7 +78,7 @@ import Foundation
|
|
|
74
78
|
}
|
|
75
79
|
|
|
76
80
|
public func setId(id: String) -> BundleInfo {
|
|
77
|
-
return BundleInfo(id: id, version: self.version, status: self.status, downloaded: self.downloaded, checksum: self.checksum)
|
|
81
|
+
return BundleInfo(id: id, version: self.version, status: self.status, downloaded: self.downloaded, checksum: self.checksum, link: self.link, comment: self.comment)
|
|
78
82
|
}
|
|
79
83
|
|
|
80
84
|
public func getVersionName() -> String {
|
|
@@ -82,7 +86,7 @@ import Foundation
|
|
|
82
86
|
}
|
|
83
87
|
|
|
84
88
|
public func setVersionName(version: String) -> BundleInfo {
|
|
85
|
-
return BundleInfo(id: self.id, version: version, status: self.status, downloaded: self.downloaded, checksum: self.checksum)
|
|
89
|
+
return BundleInfo(id: self.id, version: version, status: self.status, downloaded: self.downloaded, checksum: self.checksum, link: self.link, comment: self.comment)
|
|
86
90
|
}
|
|
87
91
|
|
|
88
92
|
public func getStatus() -> String {
|
|
@@ -90,17 +94,40 @@ import Foundation
|
|
|
90
94
|
}
|
|
91
95
|
|
|
92
96
|
public func setStatus(status: String) -> BundleInfo {
|
|
93
|
-
return BundleInfo(id: self.id, version: self.version, status: BundleStatus(localizedString: status)!, downloaded: self.downloaded, checksum: self.checksum)
|
|
97
|
+
return BundleInfo(id: self.id, version: self.version, status: BundleStatus(localizedString: status)!, downloaded: self.downloaded, checksum: self.checksum, link: self.link, comment: self.comment)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
public func getLink() -> String? {
|
|
101
|
+
return self.link
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
public func setLink(link: String?) -> BundleInfo {
|
|
105
|
+
return BundleInfo(id: self.id, version: self.version, status: self.status, downloaded: self.downloaded, checksum: self.checksum, link: link, comment: self.comment)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
public func getComment() -> String? {
|
|
109
|
+
return self.comment
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
public func setComment(comment: String?) -> BundleInfo {
|
|
113
|
+
return BundleInfo(id: self.id, version: self.version, status: self.status, downloaded: self.downloaded, checksum: self.checksum, link: self.link, comment: comment)
|
|
94
114
|
}
|
|
95
115
|
|
|
96
116
|
public func toJSON() -> [String: String] {
|
|
97
|
-
|
|
117
|
+
var result: [String: String] = [
|
|
98
118
|
"id": self.getId(),
|
|
99
119
|
"version": self.getVersionName(),
|
|
100
120
|
"downloaded": self.getDownloaded(),
|
|
101
121
|
"checksum": self.getChecksum(),
|
|
102
122
|
"status": self.getStatus()
|
|
103
123
|
]
|
|
124
|
+
if let link = self.link {
|
|
125
|
+
result["link"] = link
|
|
126
|
+
}
|
|
127
|
+
if let comment = self.comment {
|
|
128
|
+
result["comment"] = comment
|
|
129
|
+
}
|
|
130
|
+
return result
|
|
104
131
|
}
|
|
105
132
|
|
|
106
133
|
public static func == (lhs: BundleInfo, rhs: BundleInfo) -> Bool {
|