@capgo/capacitor-updater 4.12.11 → 4.13.2
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 +0 -1
- package/README.md +10 -10
- package/android/src/main/java/ee/forgr/capacitor_updater/BundleInfo.java +194 -134
- package/android/src/main/java/ee/forgr/capacitor_updater/BundleStatus.java +23 -23
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdater.java +756 -686
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +1108 -830
- package/android/src/main/java/ee/forgr/capacitor_updater/CryptoCipher.java +147 -0
- package/android/src/main/java/ee/forgr/capacitor_updater/DelayCondition.java +45 -41
- package/android/src/main/java/ee/forgr/capacitor_updater/DelayUntilNext.java +4 -4
- package/dist/docs.json +16 -16
- package/dist/esm/definitions.d.ts +12 -12
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +4 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/web.d.ts +2 -2
- package/dist/esm/web.js +34 -34
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +34 -34
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +34 -34
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/CapacitorUpdater.swift +25 -12
- package/ios/Plugin/CapacitorUpdaterPlugin.swift +4 -2
- package/ios/Plugin/CryptoCipher.swift +264 -0
- package/package.json +2 -2
- package/android/src/main/java/ee/forgr/capacitor_updater/RSACipher.java +0 -51
package/README.md
CHANGED
|
@@ -404,7 +404,7 @@ Set Channel for this device
|
|
|
404
404
|
### addListener('download', ...)
|
|
405
405
|
|
|
406
406
|
```typescript
|
|
407
|
-
addListener(eventName:
|
|
407
|
+
addListener(eventName: "download", listenerFunc: DownloadChangeListener) => Promise<PluginListenerHandle> & PluginListenerHandle
|
|
408
408
|
```
|
|
409
409
|
|
|
410
410
|
Listen for download event in the App, let you know when the download is started, loading and finished
|
|
@@ -424,7 +424,7 @@ Listen for download event in the App, let you know when the download is started,
|
|
|
424
424
|
### addListener('noNeedUpdate', ...)
|
|
425
425
|
|
|
426
426
|
```typescript
|
|
427
|
-
addListener(eventName:
|
|
427
|
+
addListener(eventName: "noNeedUpdate", listenerFunc: NoNeedListener) => Promise<PluginListenerHandle> & PluginListenerHandle
|
|
428
428
|
```
|
|
429
429
|
|
|
430
430
|
Listen for no need to update event, usefull when you want force check every time the app is launched
|
|
@@ -444,7 +444,7 @@ Listen for no need to update event, usefull when you want force check every time
|
|
|
444
444
|
### addListener('updateAvailable', ...)
|
|
445
445
|
|
|
446
446
|
```typescript
|
|
447
|
-
addListener(eventName:
|
|
447
|
+
addListener(eventName: "updateAvailable", listenerFunc: UpdateAvailabledListener) => Promise<PluginListenerHandle> & PluginListenerHandle
|
|
448
448
|
```
|
|
449
449
|
|
|
450
450
|
Listen for availbale update event, usefull when you want to force check every time the app is launched
|
|
@@ -464,7 +464,7 @@ Listen for availbale update event, usefull when you want to force check every ti
|
|
|
464
464
|
### addListener('downloadComplete', ...)
|
|
465
465
|
|
|
466
466
|
```typescript
|
|
467
|
-
addListener(eventName:
|
|
467
|
+
addListener(eventName: "downloadComplete", listenerFunc: DownloadCompleteListener) => Promise<PluginListenerHandle> & PluginListenerHandle
|
|
468
468
|
```
|
|
469
469
|
|
|
470
470
|
Listen for download event in the App, let you know when the download is started, loading and finished
|
|
@@ -484,7 +484,7 @@ Listen for download event in the App, let you know when the download is started,
|
|
|
484
484
|
### addListener('majorAvailable', ...)
|
|
485
485
|
|
|
486
486
|
```typescript
|
|
487
|
-
addListener(eventName:
|
|
487
|
+
addListener(eventName: "majorAvailable", listenerFunc: MajorAvailableListener) => Promise<PluginListenerHandle> & PluginListenerHandle
|
|
488
488
|
```
|
|
489
489
|
|
|
490
490
|
Listen for Major update event in the App, let you know when major update is blocked by setting disableAutoUpdateBreaking
|
|
@@ -504,7 +504,7 @@ Listen for Major update event in the App, let you know when major update is bloc
|
|
|
504
504
|
### addListener('updateFailed', ...)
|
|
505
505
|
|
|
506
506
|
```typescript
|
|
507
|
-
addListener(eventName:
|
|
507
|
+
addListener(eventName: "updateFailed", listenerFunc: UpdateFailedListener) => Promise<PluginListenerHandle> & PluginListenerHandle
|
|
508
508
|
```
|
|
509
509
|
|
|
510
510
|
Listen for update fail event in the App, let you know when update has fail to install at next app start
|
|
@@ -524,7 +524,7 @@ Listen for update fail event in the App, let you know when update has fail to in
|
|
|
524
524
|
### addListener('downloadFailed', ...)
|
|
525
525
|
|
|
526
526
|
```typescript
|
|
527
|
-
addListener(eventName:
|
|
527
|
+
addListener(eventName: "downloadFailed", listenerFunc: DownloadFailedListener) => Promise<PluginListenerHandle> & PluginListenerHandle
|
|
528
528
|
```
|
|
529
529
|
|
|
530
530
|
Listen for download fail event in the App, let you know when download has fail finished
|
|
@@ -544,7 +544,7 @@ Listen for download fail event in the App, let you know when download has fail f
|
|
|
544
544
|
### addListener('appReloaded', ...)
|
|
545
545
|
|
|
546
546
|
```typescript
|
|
547
|
-
addListener(eventName:
|
|
547
|
+
addListener(eventName: "appReloaded", listenerFunc: AppReloadedListener) => Promise<PluginListenerHandle> & PluginListenerHandle
|
|
548
548
|
```
|
|
549
549
|
|
|
550
550
|
Listen for download fail event in the App, let you know when download has fail finished
|
|
@@ -727,12 +727,12 @@ Get the state of auto update config. This will return `false` in manual mode.
|
|
|
727
727
|
|
|
728
728
|
#### BundleStatus
|
|
729
729
|
|
|
730
|
-
<code>
|
|
730
|
+
<code>"success" | "error" | "pending" | "downloading"</code>
|
|
731
731
|
|
|
732
732
|
|
|
733
733
|
#### DelayUntilNext
|
|
734
734
|
|
|
735
|
-
<code>
|
|
735
|
+
<code>"background" | "kill" | "nativeVersion" | "date"</code>
|
|
736
736
|
|
|
737
737
|
|
|
738
738
|
#### DownloadChangeListener
|
|
@@ -11,138 +11,198 @@ import org.json.JSONTokener;
|
|
|
11
11
|
|
|
12
12
|
public class BundleInfo {
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
14
|
+
private static final SimpleDateFormat sdf = new SimpleDateFormat(
|
|
15
|
+
"yyyy-MM-dd'T'HH:mm:ss.SSSZ"
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
public static final String ID_BUILTIN = "builtin";
|
|
19
|
+
public static final String VERSION_UNKNOWN = "unknown";
|
|
20
|
+
public static final String DOWNLOADED_BUILTIN = "1970-01-01T00:00:00.000Z";
|
|
21
|
+
|
|
22
|
+
private final String downloaded;
|
|
23
|
+
private final String id;
|
|
24
|
+
private final String version;
|
|
25
|
+
private final String checksum;
|
|
26
|
+
private final BundleStatus status;
|
|
27
|
+
|
|
28
|
+
static {
|
|
29
|
+
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public BundleInfo(final BundleInfo source) {
|
|
33
|
+
this(
|
|
34
|
+
source.id,
|
|
35
|
+
source.version,
|
|
36
|
+
source.status,
|
|
37
|
+
source.downloaded,
|
|
38
|
+
source.checksum
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public BundleInfo(
|
|
43
|
+
final String id,
|
|
44
|
+
final String version,
|
|
45
|
+
final BundleStatus status,
|
|
46
|
+
final Date downloaded,
|
|
47
|
+
final String checksum
|
|
48
|
+
) {
|
|
49
|
+
this(id, version, status, sdf.format(downloaded), checksum);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public BundleInfo(
|
|
53
|
+
final String id,
|
|
54
|
+
final String version,
|
|
55
|
+
final BundleStatus status,
|
|
56
|
+
final String downloaded,
|
|
57
|
+
final String checksum
|
|
58
|
+
) {
|
|
59
|
+
this.downloaded = downloaded.trim();
|
|
60
|
+
this.id = id;
|
|
61
|
+
this.version = version;
|
|
62
|
+
this.checksum = checksum;
|
|
63
|
+
this.status = status;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public Boolean isBuiltin() {
|
|
67
|
+
return ID_BUILTIN.equals(this.id);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
public Boolean isUnknown() {
|
|
71
|
+
return VERSION_UNKNOWN.equals(this.id);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
public Boolean isErrorStatus() {
|
|
75
|
+
return BundleStatus.ERROR == this.status;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
public Boolean isDeleted() {
|
|
79
|
+
return BundleStatus.DELETED == this.status;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
public boolean isDownloaded() {
|
|
83
|
+
return (
|
|
84
|
+
!this.isBuiltin() &&
|
|
85
|
+
this.downloaded != null &&
|
|
86
|
+
!this.downloaded.equals("") &&
|
|
87
|
+
!this.isDeleted()
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
public String getDownloaded() {
|
|
92
|
+
return this.isBuiltin() ? DOWNLOADED_BUILTIN : this.downloaded;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
public BundleInfo setDownloaded(Date downloaded) {
|
|
96
|
+
return new BundleInfo(
|
|
97
|
+
this.id,
|
|
98
|
+
this.version,
|
|
99
|
+
this.status,
|
|
100
|
+
downloaded,
|
|
101
|
+
this.checksum
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
public String getChecksum() {
|
|
106
|
+
return this.isBuiltin() ? "" : this.checksum;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
public BundleInfo setChecksum(String checksum) {
|
|
110
|
+
return new BundleInfo(
|
|
111
|
+
this.id,
|
|
112
|
+
this.version,
|
|
113
|
+
this.status,
|
|
114
|
+
this.downloaded,
|
|
115
|
+
checksum
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
public String getId() {
|
|
120
|
+
return this.isBuiltin() ? ID_BUILTIN : this.id;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
public BundleInfo setId(String id) {
|
|
124
|
+
return new BundleInfo(
|
|
125
|
+
id,
|
|
126
|
+
this.version,
|
|
127
|
+
this.status,
|
|
128
|
+
this.downloaded,
|
|
129
|
+
this.checksum
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
public String getVersionName() {
|
|
134
|
+
return this.version == null ? ID_BUILTIN : this.version;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
public BundleInfo setVersionName(String version) {
|
|
138
|
+
return new BundleInfo(
|
|
139
|
+
this.id,
|
|
140
|
+
version,
|
|
141
|
+
this.status,
|
|
142
|
+
this.downloaded,
|
|
143
|
+
this.checksum
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
public BundleStatus getStatus() {
|
|
148
|
+
return this.isBuiltin() ? BundleStatus.SUCCESS : this.status;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
public BundleInfo setStatus(BundleStatus status) {
|
|
152
|
+
return new BundleInfo(
|
|
153
|
+
this.id,
|
|
154
|
+
this.version,
|
|
155
|
+
status,
|
|
156
|
+
this.downloaded,
|
|
157
|
+
this.checksum
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
public static BundleInfo fromJSON(final JSObject json) throws JSONException {
|
|
162
|
+
return BundleInfo.fromJSON(json.toString());
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
public static BundleInfo fromJSON(final String jsonString)
|
|
166
|
+
throws JSONException {
|
|
167
|
+
JSONObject json = new JSONObject(new JSONTokener(jsonString));
|
|
168
|
+
return new BundleInfo(
|
|
169
|
+
json.has("id") ? json.getString("id") : "",
|
|
170
|
+
json.has("version")
|
|
171
|
+
? json.getString("version")
|
|
172
|
+
: BundleInfo.VERSION_UNKNOWN,
|
|
173
|
+
json.has("status")
|
|
174
|
+
? BundleStatus.fromString(json.getString("status"))
|
|
175
|
+
: BundleStatus.PENDING,
|
|
176
|
+
json.has("downloaded") ? json.getString("downloaded") : "",
|
|
177
|
+
json.has("checksum") ? json.getString("checksum") : ""
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
public JSObject toJSON() {
|
|
182
|
+
final JSObject result = new JSObject();
|
|
183
|
+
result.put("id", this.getId());
|
|
184
|
+
result.put("version", this.getVersionName());
|
|
185
|
+
result.put("downloaded", this.getDownloaded());
|
|
186
|
+
result.put("checksum", this.getChecksum());
|
|
187
|
+
result.put("status", this.getStatus());
|
|
188
|
+
return result;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
@Override
|
|
192
|
+
public boolean equals(final Object o) {
|
|
193
|
+
if (this == o) return true;
|
|
194
|
+
if (!(o instanceof BundleInfo)) return false;
|
|
195
|
+
final BundleInfo that = (BundleInfo) o;
|
|
196
|
+
return this.getId().equals(that.getId());
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
@Override
|
|
200
|
+
public int hashCode() {
|
|
201
|
+
return Objects.hash(this.version);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
@Override
|
|
205
|
+
public String toString() {
|
|
206
|
+
return this.toJSON().toString();
|
|
207
|
+
}
|
|
148
208
|
}
|
|
@@ -4,35 +4,35 @@ import java.util.HashMap;
|
|
|
4
4
|
import java.util.Map;
|
|
5
5
|
|
|
6
6
|
public enum BundleStatus {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
SUCCESS("success"),
|
|
8
|
+
ERROR("error"),
|
|
9
|
+
PENDING("pending"),
|
|
10
|
+
DELETED("deleted"),
|
|
11
|
+
DOWNLOADING("downloading");
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
public final String label;
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
private static final Map<String, BundleStatus> BY_LABEL = new HashMap<>();
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
17
|
+
static {
|
|
18
|
+
for (final BundleStatus e : values()) {
|
|
19
|
+
BY_LABEL.put(e.label, e);
|
|
21
20
|
}
|
|
21
|
+
}
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
BundleStatus(final String label) {
|
|
24
|
+
this.label = label;
|
|
25
|
+
}
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
@Override
|
|
28
|
+
public String toString() {
|
|
29
|
+
return this.label;
|
|
30
|
+
}
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
return BundleStatus.BY_LABEL.get(status);
|
|
32
|
+
public static BundleStatus fromString(final String status) {
|
|
33
|
+
if (status == null || status.isEmpty()) {
|
|
34
|
+
return BundleStatus.PENDING;
|
|
37
35
|
}
|
|
36
|
+
return BundleStatus.BY_LABEL.get(status);
|
|
37
|
+
}
|
|
38
38
|
}
|