react-native-instantpay-code-push 1.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/InstantpayCodePush.podspec +20 -0
- package/LICENSE +20 -0
- package/README.md +158 -0
- package/android/build.gradle +91 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/instantpaycodepush/BundleFileStorageService.kt +835 -0
- package/android/src/main/java/com/instantpaycodepush/BundleMetadata.kt +249 -0
- package/android/src/main/java/com/instantpaycodepush/CommonHelper.kt +39 -0
- package/android/src/main/java/com/instantpaycodepush/DecompressService.kt +85 -0
- package/android/src/main/java/com/instantpaycodepush/DecompressionStrategy.kt +24 -0
- package/android/src/main/java/com/instantpaycodepush/FileManagerService.kt +105 -0
- package/android/src/main/java/com/instantpaycodepush/HashUtils.kt +50 -0
- package/android/src/main/java/com/instantpaycodepush/InstantpayCodePushModule.kt +182 -0
- package/android/src/main/java/com/instantpaycodepush/InstantpayCodePushPackage.kt +33 -0
- package/android/src/main/java/com/instantpaycodepush/IpayCodePush.kt +101 -0
- package/android/src/main/java/com/instantpaycodepush/IpayCodePushException.kt +135 -0
- package/android/src/main/java/com/instantpaycodepush/IpayCodePushImpl.kt +329 -0
- package/android/src/main/java/com/instantpaycodepush/OkHttpDownloadService.kt +283 -0
- package/android/src/main/java/com/instantpaycodepush/ReactIntegrationManager.kt +141 -0
- package/android/src/main/java/com/instantpaycodepush/ReactIntegrationManagerBase.kt +35 -0
- package/android/src/main/java/com/instantpaycodepush/SignatureVerifier.kt +354 -0
- package/android/src/main/java/com/instantpaycodepush/VersionedPreferencesService.kt +70 -0
- package/android/src/main/java/com/instantpaycodepush/ZipDecompressionStrategy.kt +198 -0
- package/ios/InstantpayCodePush.h +5 -0
- package/ios/InstantpayCodePush.mm +21 -0
- package/lib/module/DefaultResolver.js +34 -0
- package/lib/module/DefaultResolver.js.map +1 -0
- package/lib/module/NativeInstantpayCodePush.js +5 -0
- package/lib/module/NativeInstantpayCodePush.js.map +1 -0
- package/lib/module/checkForUpdate.js +68 -0
- package/lib/module/checkForUpdate.js.map +1 -0
- package/lib/module/error.js +137 -0
- package/lib/module/error.js.map +1 -0
- package/lib/module/fetchUpdateInfo.js +36 -0
- package/lib/module/fetchUpdateInfo.js.map +1 -0
- package/lib/module/global.d.js +8 -0
- package/lib/module/global.d.js.map +1 -0
- package/lib/module/hooks/useEventCallback.js +13 -0
- package/lib/module/hooks/useEventCallback.js.map +1 -0
- package/lib/module/index.js +291 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/native.js +233 -0
- package/lib/module/native.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/store.js +53 -0
- package/lib/module/store.js.map +1 -0
- package/lib/module/types.js +62 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/wrap.js +171 -0
- package/lib/module/wrap.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/DefaultResolver.d.ts +10 -0
- package/lib/typescript/src/DefaultResolver.d.ts.map +1 -0
- package/lib/typescript/src/NativeInstantpayCodePush.d.ts +100 -0
- package/lib/typescript/src/NativeInstantpayCodePush.d.ts.map +1 -0
- package/lib/typescript/src/checkForUpdate.d.ts +29 -0
- package/lib/typescript/src/checkForUpdate.d.ts.map +1 -0
- package/lib/typescript/src/error.d.ts +124 -0
- package/lib/typescript/src/error.d.ts.map +1 -0
- package/lib/typescript/src/fetchUpdateInfo.d.ts +8 -0
- package/lib/typescript/src/fetchUpdateInfo.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useEventCallback.d.ts +5 -0
- package/lib/typescript/src/hooks/useEventCallback.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +203 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/native.d.ts +128 -0
- package/lib/typescript/src/native.d.ts.map +1 -0
- package/lib/typescript/src/store.d.ts +11 -0
- package/lib/typescript/src/store.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +174 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/lib/typescript/src/wrap.d.ts +179 -0
- package/lib/typescript/src/wrap.d.ts.map +1 -0
- package/package.json +174 -0
- package/src/DefaultResolver.ts +36 -0
- package/src/NativeInstantpayCodePush.ts +111 -0
- package/src/checkForUpdate.ts +122 -0
- package/src/error.ts +159 -0
- package/src/fetchUpdateInfo.ts +47 -0
- package/src/global.d.ts +23 -0
- package/src/hooks/useEventCallback.ts +30 -0
- package/src/index.tsx +379 -0
- package/src/native.ts +280 -0
- package/src/store.ts +69 -0
- package/src/types.ts +227 -0
- package/src/wrap.tsx +384 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { type CheckForUpdateOptions } from "./checkForUpdate";
|
|
2
|
+
import { type UpdateParams } from "./native";
|
|
3
|
+
import { type IpayCodePushOptions } from "./wrap";
|
|
4
|
+
export type { IpayCodePushEvent, NotifyAppReadyResult } from "./native";
|
|
5
|
+
export * from "./store";
|
|
6
|
+
export { extractSignatureFailure, type IpayCodePushResolver, isSignatureVerificationError, type ResolverCheckUpdateParams, type ResolverNotifyAppReadyParams, type SignatureVerificationFailure, } from "./types";
|
|
7
|
+
export type { IpayCodePushOptions, RunUpdateProcessResponse } from "./wrap";
|
|
8
|
+
export declare const IpayCodePush: {
|
|
9
|
+
/**
|
|
10
|
+
* `IpayCodePush.wrap` checks for updates at the entry point, and if there is a bundle to update, it downloads the bundle and applies the update strategy.
|
|
11
|
+
*
|
|
12
|
+
* @param {object} options - Configuration options
|
|
13
|
+
* @param {string} options.source - Update server URL
|
|
14
|
+
* @param {object} [options.requestHeaders] - Request headers
|
|
15
|
+
* @param {React.ComponentType} [options.fallbackComponent] - Component to display during updates
|
|
16
|
+
* @param {boolean} [options.reloadOnForceUpdate=true] - Whether to automatically reload the app on force updates
|
|
17
|
+
* @param {Function} [options.onUpdateProcessCompleted] - Callback after update process completes
|
|
18
|
+
* @param {Function} [options.onProgress] - Callback to track bundle download progress
|
|
19
|
+
* @returns {Function} Higher-order component that wraps the app component
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* export default IpayCodePush.wrap({
|
|
24
|
+
* baseURL: "<your-update-server-url>",
|
|
25
|
+
* updateStrategy: "appVersion", //"appVersion" | "fingerprint"
|
|
26
|
+
* updateMode: "auto",
|
|
27
|
+
* requestHeaders: {
|
|
28
|
+
* "Authorization": "Bearer <your-access-token>",
|
|
29
|
+
* },
|
|
30
|
+
* })(App);
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
wrap: (options: IpayCodePushOptions) => (WrappedComponent: import("react").ComponentType<object>) => import("react").ComponentType<object>;
|
|
34
|
+
/**
|
|
35
|
+
* Reloads the app.
|
|
36
|
+
*/
|
|
37
|
+
reload: () => Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Returns whether an update has finished downloading in this app session.
|
|
40
|
+
*
|
|
41
|
+
* When it returns true, calling `IpayCodePush.reload()` (or restarting the app)
|
|
42
|
+
* will apply the downloaded update bundle.
|
|
43
|
+
*
|
|
44
|
+
* - Derived from `progress` reaching 1.0
|
|
45
|
+
* - Resets to false when a new download starts (progress < 1)
|
|
46
|
+
*
|
|
47
|
+
* @returns {boolean} True if a downloaded update is ready to apply
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* if (IpayCodePush.isUpdateDownloaded()) {
|
|
51
|
+
* await IpayCodePush.reload();
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
isUpdateDownloaded: () => boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Fetches the current app version.
|
|
58
|
+
*/
|
|
59
|
+
getAppVersion: () => string | null;
|
|
60
|
+
/**
|
|
61
|
+
* Fetches the current bundle ID of the app.
|
|
62
|
+
*/
|
|
63
|
+
getBundleId: () => string;
|
|
64
|
+
/**
|
|
65
|
+
* Retrieves the initial bundle ID based on the build time of the native app.
|
|
66
|
+
*/
|
|
67
|
+
getMinBundleId: () => string;
|
|
68
|
+
/**
|
|
69
|
+
* Fetches the current channel of the app.
|
|
70
|
+
*
|
|
71
|
+
* If no channel is specified, the app is assigned to the 'production' channel.
|
|
72
|
+
*
|
|
73
|
+
* @returns {string} The current release channel of the app
|
|
74
|
+
* @default "production"
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* const channel = IpayCodePush.getChannel();
|
|
78
|
+
* console.log(`Current channel: ${channel}`);
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
getChannel: () => string;
|
|
82
|
+
/**
|
|
83
|
+
* Adds a listener to IpayCodePush events.
|
|
84
|
+
*
|
|
85
|
+
* @param {keyof IpayCodePushEvent} eventName - The name of the event to listen for
|
|
86
|
+
* @param {(event: IpayCodePushEvent[T]) => void} listener - The callback function to handle the event
|
|
87
|
+
* @returns {() => void} A cleanup function that removes the event listener
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```ts
|
|
91
|
+
* const unsubscribe = IpayCodePush.addListener("onProgress", ({ progress }) => {
|
|
92
|
+
* console.log(`Update progress: ${progress * 100}%`);
|
|
93
|
+
* });
|
|
94
|
+
*
|
|
95
|
+
* // Unsubscribe when no longer needed
|
|
96
|
+
* unsubscribe();
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
addListener: <T extends keyof import("./native").IpayCodePushEvent>(eventName: T, listener: (event: any) => void) => () => void;
|
|
100
|
+
/**
|
|
101
|
+
* Manually checks for updates.
|
|
102
|
+
*
|
|
103
|
+
* @param {Object} config - Update check configuration
|
|
104
|
+
* @param {string} config.source - Update server URL
|
|
105
|
+
* @param {Record<string, string>} [config.requestHeaders] - Request headers
|
|
106
|
+
*
|
|
107
|
+
* @returns {Promise<UpdateInfo | null>} Update information or null if up to date
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```ts
|
|
111
|
+
* const updateInfo = await IpayCodePush.checkForUpdate({
|
|
112
|
+
* source: "<your-update-server-url>",
|
|
113
|
+
* requestHeaders: {
|
|
114
|
+
* Authorization: "Bearer <your-access-token>",
|
|
115
|
+
* },
|
|
116
|
+
* });
|
|
117
|
+
*
|
|
118
|
+
* if (!updateInfo) {
|
|
119
|
+
* console.log("App is up to date");
|
|
120
|
+
* return;
|
|
121
|
+
* }
|
|
122
|
+
*
|
|
123
|
+
* await IpayCodePush.updateBundle(updateInfo.id, updateInfo.fileUrl);
|
|
124
|
+
* if (updateInfo.shouldForceUpdate) {
|
|
125
|
+
* await HotUpdater.reload();
|
|
126
|
+
* }
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
checkForUpdate: (config: CheckForUpdateOptions) => Promise<import("./checkForUpdate").CheckForUpdateResult | null>;
|
|
130
|
+
/**
|
|
131
|
+
* Updates the bundle of the app.
|
|
132
|
+
*
|
|
133
|
+
* @param {UpdateBundleParams} params - Parameters object required for bundle update
|
|
134
|
+
* @param {string} params.bundleId - The bundle ID of the app
|
|
135
|
+
* @param {string|null} params.fileUrl - The URL of the zip file
|
|
136
|
+
*
|
|
137
|
+
* @returns {Promise<boolean>} Whether the update was successful
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```ts
|
|
141
|
+
* const updateInfo = await IpayCodePush.checkForUpdate({
|
|
142
|
+
* source: "<your-update-server-url>",
|
|
143
|
+
* requestHeaders: {
|
|
144
|
+
* Authorization: "Bearer <your-access-token>",
|
|
145
|
+
* },
|
|
146
|
+
* });
|
|
147
|
+
*
|
|
148
|
+
* if (!updateInfo) {
|
|
149
|
+
* return {
|
|
150
|
+
* status: "UP_TO_DATE",
|
|
151
|
+
* };
|
|
152
|
+
* }
|
|
153
|
+
*
|
|
154
|
+
* await IpayCodePush.updateBundle({
|
|
155
|
+
* bundleId: updateInfo.id,
|
|
156
|
+
* fileUrl: updateInfo.fileUrl
|
|
157
|
+
* });
|
|
158
|
+
* if (updateInfo.shouldForceUpdate) {
|
|
159
|
+
* await HotUpdater.reload();
|
|
160
|
+
* }
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
updateBundle: (params: UpdateParams) => Promise<boolean>;
|
|
164
|
+
/**
|
|
165
|
+
* Fetches the fingerprint of the app.
|
|
166
|
+
*
|
|
167
|
+
* @returns {string} The fingerprint of the app
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```ts
|
|
171
|
+
* const fingerprint = IpayCodePush.getFingerprintHash();
|
|
172
|
+
* console.log(`Fingerprint: ${fingerprint}`);
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
getFingerprintHash: () => string | null;
|
|
176
|
+
/**
|
|
177
|
+
* Gets the list of bundle IDs that have been marked as crashed.
|
|
178
|
+
* These bundles will be rejected if attempted to install again.
|
|
179
|
+
*
|
|
180
|
+
* @returns {string[]} Array of crashed bundle IDs
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* ```ts
|
|
184
|
+
* const crashedBundles = IpayCodePush.getCrashHistory();
|
|
185
|
+
* console.log("Crashed bundles:", crashedBundles);
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
getCrashHistory: () => string[];
|
|
189
|
+
/**
|
|
190
|
+
* Clears the crashed bundle history, allowing previously crashed bundles
|
|
191
|
+
* to be installed again.
|
|
192
|
+
*
|
|
193
|
+
* @returns {boolean} true if clearing was successful
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```ts
|
|
197
|
+
* // Clear crash history to allow retrying a previously failed bundle
|
|
198
|
+
* IpayCodePush.clearCrashHistory();
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
201
|
+
clearCrashHistory: () => boolean;
|
|
202
|
+
};
|
|
203
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,qBAAqB,EAG7B,MAAM,kBAAkB,CAAC;AAI1B,OAAO,EAWH,KAAK,YAAY,EAEpB,MAAM,UAAU,CAAC;AAMlB,OAAO,EAAE,KAAK,mBAAmB,EAAkC,MAAM,QAAQ,CAAC;AAElF,YAAY,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAExE,cAAc,SAAS,CAAC;AAExB,OAAO,EACH,uBAAuB,EACvB,KAAK,oBAAoB,EACzB,4BAA4B,EAC5B,KAAK,yBAAyB,EAC9B,KAAK,4BAA4B,EACjC,KAAK,4BAA4B,GACpC,MAAM,SAAS,CAAC;AAEjB,YAAY,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,QAAQ,CAAC;AA8U5E,eAAO,MAAM,YAAY;IArQjB;;;;;;;;;;;;;;;;;;;;;;;OAuBG;oBACa,mBAAmB;IAsCnC;;OAEG;;IAGH;;;;;;;;;;;;;;;;OAgBG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;;;;;;;;;;;OAYG;;IAGH;;;;;;;;;;;;;;;;OAgBG;;IAGH;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;6BACsB,qBAAqB;IAgB9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;2BACoB,YAAY;IAKnC;;;;;;;;;;OAUG;;IAGH;;;;;;;;;;;OAWG;;IAGH;;;;;;;;;;;OAWG;;CAK2C,CAAC"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { IpayCodePushErrorCode, isIpayCodePushError } from "./error";
|
|
2
|
+
import type { UpdateStatus } from "./types";
|
|
3
|
+
import { type UpdateBundleParams } from './NativeInstantpayCodePush';
|
|
4
|
+
export { IpayCodePushErrorCode, isIpayCodePushError };
|
|
5
|
+
export declare const IpayCodePushConstants: {
|
|
6
|
+
IPAY_CODE_PUSH_BUNDLE_ID: string;
|
|
7
|
+
};
|
|
8
|
+
export type IpayCodePushEvent = {
|
|
9
|
+
onProgress: {
|
|
10
|
+
progress: number;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export declare const addListener: <T extends keyof IpayCodePushEvent>(eventName: T, listener: (event: any) => void) => () => void;
|
|
14
|
+
export type UpdateParams = UpdateBundleParams & {
|
|
15
|
+
status: UpdateStatus;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Downloads files and applies them to the app.
|
|
19
|
+
*
|
|
20
|
+
* @param {UpdateParams} params - Parameters object required for bundle update
|
|
21
|
+
* @returns {Promise<boolean>} Resolves with true if download was successful
|
|
22
|
+
* @throws {Error} Rejects with error.code from HotUpdaterErrorCode enum and error.message
|
|
23
|
+
*/
|
|
24
|
+
export declare function updateBundle(params: UpdateParams): Promise<boolean>;
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated Use updateBundle(params: UpdateBundleParamsWithStatus) instead
|
|
27
|
+
*/
|
|
28
|
+
export declare function updateBundle(bundleId: string, fileUrl: string | null): Promise<boolean>;
|
|
29
|
+
/**
|
|
30
|
+
* Fetches the current app version.
|
|
31
|
+
*/
|
|
32
|
+
export declare const getAppVersion: () => string | null;
|
|
33
|
+
/**
|
|
34
|
+
* Reloads the app.
|
|
35
|
+
*/
|
|
36
|
+
export declare const reload: () => Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Fetches the minimum bundle id, which represents the initial bundle of the app
|
|
39
|
+
* since it is created at build time.
|
|
40
|
+
*
|
|
41
|
+
* @returns {string} Resolves with the minimum bundle id or null if not available.
|
|
42
|
+
*/
|
|
43
|
+
export declare const getMinBundleId: () => string;
|
|
44
|
+
/**
|
|
45
|
+
* Fetches the current bundle version id.
|
|
46
|
+
*
|
|
47
|
+
* @async
|
|
48
|
+
* @returns {string} Resolves with the current version id or null if not available.
|
|
49
|
+
*/
|
|
50
|
+
export declare const getBundleId: () => string;
|
|
51
|
+
/**
|
|
52
|
+
* Fetches the channel for the app.
|
|
53
|
+
*
|
|
54
|
+
* @returns {string} Resolves with the channel or null if not available.
|
|
55
|
+
*/
|
|
56
|
+
export declare const getChannel: () => string;
|
|
57
|
+
/**
|
|
58
|
+
* Fetches the fingerprint for the app.
|
|
59
|
+
*
|
|
60
|
+
* @returns {string | null} Resolves with the fingerprint hash
|
|
61
|
+
*/
|
|
62
|
+
export declare const getFingerprintHash: () => string | null;
|
|
63
|
+
/**
|
|
64
|
+
* Result returned by notifyAppReady()
|
|
65
|
+
* - `status: "PROMOTED"` - Staging bundle was promoted to stable (ACTIVE event)
|
|
66
|
+
* - `status: "RECOVERED"` - App recovered from crash, rollback occurred (ROLLBACK event)
|
|
67
|
+
* - `status: "STABLE"` - No changes, already stable
|
|
68
|
+
* - `crashedBundleId` - Present only when status is "RECOVERED"
|
|
69
|
+
*/
|
|
70
|
+
export type NotifyAppReadyResult = {
|
|
71
|
+
status: "PROMOTED" | "RECOVERED" | "STABLE";
|
|
72
|
+
crashedBundleId?: string;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Notifies the native side that the app has successfully started with the current bundle.
|
|
76
|
+
* If the bundle matches the staging bundle, it promotes to stable.
|
|
77
|
+
*
|
|
78
|
+
* This function is called automatically when the module loads.
|
|
79
|
+
*
|
|
80
|
+
* @returns {NotifyAppReadyResult} Bundle state information
|
|
81
|
+
* - `status: "PROMOTED"` - Staging bundle was promoted to stable (ACTIVE event)
|
|
82
|
+
* - `status: "RECOVERED"` - App recovered from crash, rollback occurred (ROLLBACK event)
|
|
83
|
+
* - `status: "STABLE"` - No changes, already stable
|
|
84
|
+
* - `crashedBundleId` - Present only when status is "RECOVERED"
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts
|
|
88
|
+
* const result = IpayCodePush.notifyAppReady();
|
|
89
|
+
*
|
|
90
|
+
* switch (result.status) {
|
|
91
|
+
* case "PROMOTED":
|
|
92
|
+
* // Send ACTIVE analytics event
|
|
93
|
+
* analytics.track('bundle_active', { bundleId: IpayCodePush.getBundleId() });
|
|
94
|
+
* break;
|
|
95
|
+
* case "RECOVERED":
|
|
96
|
+
* // Send ROLLBACK analytics event
|
|
97
|
+
* analytics.track('bundle_rollback', { crashedBundleId: result.crashedBundleId });
|
|
98
|
+
* break;
|
|
99
|
+
* case "STABLE":
|
|
100
|
+
* // No special action needed
|
|
101
|
+
* break;
|
|
102
|
+
* }
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
export declare const notifyAppReady: () => NotifyAppReadyResult;
|
|
106
|
+
/**
|
|
107
|
+
* Gets the list of bundle IDs that have been marked as crashed.
|
|
108
|
+
* These bundles will be rejected if attempted to install again.
|
|
109
|
+
*
|
|
110
|
+
* @returns {string[]} Array of crashed bundle IDs
|
|
111
|
+
*/
|
|
112
|
+
export declare const getCrashHistory: () => string[];
|
|
113
|
+
/**
|
|
114
|
+
* Clears the crashed bundle history, allowing previously crashed bundles
|
|
115
|
+
* to be installed again.
|
|
116
|
+
*
|
|
117
|
+
* @returns {boolean} true if clearing was successful
|
|
118
|
+
*/
|
|
119
|
+
export declare const clearCrashHistory: () => boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Gets the base URL for the current active bundle directory.
|
|
122
|
+
* Returns the file:// URL to the bundle directory without trailing slash.
|
|
123
|
+
* This is used for Expo DOM components to construct full asset paths.
|
|
124
|
+
*
|
|
125
|
+
* @returns {string | null} Base URL string (e.g., "file:///data/.../bundle-store/abc123") or null if not available
|
|
126
|
+
*/
|
|
127
|
+
export declare const getBaseURL: () => string | null;
|
|
128
|
+
//# sourceMappingURL=native.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../../../src/native.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAE3C,OAA2B,EACvB,KAAK,kBAAkB,EAC1B,MAAM,4BAA4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G;AACH,eAAO,MAAM,cAAc,QAAO,oBAYjC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,QAAO,MAAM,EAWxC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,QAAO,OAEpC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,QAAO,MAAM,GAAG,IAMtC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type IpayCodePushState = {
|
|
2
|
+
progress: number;
|
|
3
|
+
isUpdateDownloaded: boolean;
|
|
4
|
+
};
|
|
5
|
+
export declare const ipayCodePushStore: {
|
|
6
|
+
getSnapshot: () => IpayCodePushState;
|
|
7
|
+
setState: (newState: Partial<IpayCodePushState>) => void;
|
|
8
|
+
subscribe: (listener: () => void) => () => boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare const useIpayCodePushStore: <T = IpayCodePushState>(selector?: (snapshot: IpayCodePushState) => T) => T;
|
|
11
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/store.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,iBAAiB,GAAG;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,OAAO,CAAC;CAC/B,CAAC;AAmDF,eAAO,MAAM,iBAAiB;;yBA5BE,OAAO,CAAC,iBAAiB,CAAC;0BAoBzB,MAAM,IAAI;CAQe,CAAC;AAE3D,eAAO,MAAM,oBAAoB,GAAI,CAAC,GAAG,iBAAiB,EACtD,WAAU,CAAC,QAAQ,EAAE,iBAAiB,KAAK,CAA+B,MAQ7E,CAAC"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parameters passed to resolver.checkUpdate method
|
|
3
|
+
*/
|
|
4
|
+
export interface ResolverCheckUpdateParams {
|
|
5
|
+
/**
|
|
6
|
+
* The platform the app is running on
|
|
7
|
+
*/
|
|
8
|
+
platform: "ios" | "android";
|
|
9
|
+
/**
|
|
10
|
+
* The current app version
|
|
11
|
+
*/
|
|
12
|
+
appVersion: string;
|
|
13
|
+
/**
|
|
14
|
+
* The current bundle ID
|
|
15
|
+
*/
|
|
16
|
+
bundleId: string;
|
|
17
|
+
/**
|
|
18
|
+
* Minimum bundle ID from build time
|
|
19
|
+
*/
|
|
20
|
+
minBundleId: string;
|
|
21
|
+
/**
|
|
22
|
+
* The channel name (e.g., "production", "staging")
|
|
23
|
+
*/
|
|
24
|
+
channel: string;
|
|
25
|
+
/**
|
|
26
|
+
* Update strategy being used
|
|
27
|
+
*/
|
|
28
|
+
updateStrategy: "fingerprint" | "appVersion";
|
|
29
|
+
/**
|
|
30
|
+
* The fingerprint hash (only present when using fingerprint strategy)
|
|
31
|
+
*/
|
|
32
|
+
fingerprintHash: string | null;
|
|
33
|
+
/**
|
|
34
|
+
* Request headers from global config (for optional use)
|
|
35
|
+
*/
|
|
36
|
+
requestHeaders?: Record<string, string>;
|
|
37
|
+
/**
|
|
38
|
+
* Request timeout from global config (for optional use)
|
|
39
|
+
*/
|
|
40
|
+
requestTimeout?: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Parameters passed to resolver.notifyAppReady method
|
|
44
|
+
*/
|
|
45
|
+
export interface ResolverNotifyAppReadyParams {
|
|
46
|
+
/**
|
|
47
|
+
* The bundle state from native notifyAppReady
|
|
48
|
+
* - "PROMOTED": Staging bundle was promoted to stable
|
|
49
|
+
* - "RECOVERED": App recovered from crash, rollback occurred
|
|
50
|
+
* - "STABLE": No changes, bundle is stable
|
|
51
|
+
*/
|
|
52
|
+
status: "PROMOTED" | "RECOVERED" | "STABLE";
|
|
53
|
+
/**
|
|
54
|
+
* Present only when status is "RECOVERED"
|
|
55
|
+
*/
|
|
56
|
+
crashedBundleId?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Request headers from global config (for optional use)
|
|
59
|
+
*/
|
|
60
|
+
requestHeaders?: Record<string, string>;
|
|
61
|
+
/**
|
|
62
|
+
* Request timeout from global config (for optional use)
|
|
63
|
+
*/
|
|
64
|
+
requestTimeout?: number;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Resolver interface for custom network operations
|
|
68
|
+
*/
|
|
69
|
+
export interface IpayCodePushResolver {
|
|
70
|
+
/**
|
|
71
|
+
* Custom implementation for checking updates.
|
|
72
|
+
* When provided, this completely replaces the default fetchUpdateInfo flow.
|
|
73
|
+
*
|
|
74
|
+
* @param params - All parameters needed to check for updates
|
|
75
|
+
* @returns Update information or null if up to date
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* checkUpdate: async (params) => {
|
|
80
|
+
* const response = await fetch(`https://api.custom.com/check`, {
|
|
81
|
+
* method: 'POST',
|
|
82
|
+
* body: JSON.stringify(params),
|
|
83
|
+
* headers: params.requestHeaders,
|
|
84
|
+
* });
|
|
85
|
+
*
|
|
86
|
+
* if (!response.ok) return null;
|
|
87
|
+
* return response.json();
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
checkUpdate?: (params: ResolverCheckUpdateParams) => Promise<AppUpdateInfo | null>;
|
|
92
|
+
/**
|
|
93
|
+
* Custom implementation for notifying app ready.
|
|
94
|
+
* When provided, this completely replaces the default notifyAppReady network flow.
|
|
95
|
+
* Note: The native notifyAppReady for bundle promotion still happens automatically.
|
|
96
|
+
*
|
|
97
|
+
* @param params - All parameters about the current app state
|
|
98
|
+
* @returns Notification result
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* notifyAppReady: async (params) => {
|
|
103
|
+
* await fetch(`https://api.custom.com/notify`, {
|
|
104
|
+
* method: 'POST',
|
|
105
|
+
* body: JSON.stringify(params),
|
|
106
|
+
* });
|
|
107
|
+
*
|
|
108
|
+
* return { status: "STABLE" };
|
|
109
|
+
* }
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
notifyAppReady?: (params: ResolverNotifyAppReadyParams) => Promise<undefined>;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Information about a signature verification failure.
|
|
116
|
+
* This is a security-critical event that indicates the bundle
|
|
117
|
+
* may have been tampered with or the public key is misconfigured.
|
|
118
|
+
*/
|
|
119
|
+
export interface SignatureVerificationFailure {
|
|
120
|
+
/**
|
|
121
|
+
* The bundle ID that failed verification.
|
|
122
|
+
*/
|
|
123
|
+
bundleId: string;
|
|
124
|
+
/**
|
|
125
|
+
* Human-readable error message from the native layer.
|
|
126
|
+
*/
|
|
127
|
+
message: string;
|
|
128
|
+
/**
|
|
129
|
+
* The underlying error object.
|
|
130
|
+
*/
|
|
131
|
+
error: Error;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Checks if an error is a signature verification failure.
|
|
135
|
+
* Matches error messages from both iOS and Android native implementations.
|
|
136
|
+
*
|
|
137
|
+
* **IMPORTANT**: This function relies on specific error message patterns from native code.
|
|
138
|
+
* If you change the error messages in the native implementations, update these patterns:
|
|
139
|
+
* - iOS: `ios/ipaycodepush/Internal/SignatureVerifier.swift` (SignatureVerificationError)
|
|
140
|
+
* - Android: `android/src/main/java/com/ipaycodepush/SignatureVerifier.kt` (SignatureVerificationException)
|
|
141
|
+
*/
|
|
142
|
+
export declare function isSignatureVerificationError(error: unknown): boolean;
|
|
143
|
+
/**
|
|
144
|
+
* Extracts signature verification failure details from an error.
|
|
145
|
+
*/
|
|
146
|
+
export declare function extractSignatureFailure(error: unknown, bundleId: string): SignatureVerificationFailure;
|
|
147
|
+
export type UpdateStatus = "ROLLBACK" | "UPDATE";
|
|
148
|
+
/**
|
|
149
|
+
* The update info for the database layer.
|
|
150
|
+
* This is the update info that is used by the database.
|
|
151
|
+
*/
|
|
152
|
+
export interface UpdateInfo {
|
|
153
|
+
id: string;
|
|
154
|
+
shouldForceUpdate: boolean;
|
|
155
|
+
message: string | null;
|
|
156
|
+
status: UpdateStatus;
|
|
157
|
+
storageUri: string | null;
|
|
158
|
+
fileHash: string | null;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* The update info for the app layer.
|
|
162
|
+
* This is the update info that is used by the app.
|
|
163
|
+
*/
|
|
164
|
+
export interface AppUpdateInfo extends Omit<UpdateInfo, "storageUri"> {
|
|
165
|
+
fileUrl: string | null;
|
|
166
|
+
/**
|
|
167
|
+
* SHA256 hash of the bundle file, optionally with embedded signature.
|
|
168
|
+
* Format when signed: "sig:<base64_signature>"
|
|
169
|
+
* Format when unsigned: "<hex_hash>" (64-character lowercase hex)
|
|
170
|
+
* The client parses this to extract signature for native verification.
|
|
171
|
+
*/
|
|
172
|
+
fileHash: string | null;
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AACA;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACtC;;OAEG;IACH,QAAQ,EAAE,KAAK,GAAG,SAAS,CAAC;IAE5B;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,cAAc,EAAE,aAAa,GAAG,YAAY,CAAC;IAE7C;;OAEG;IACH,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAE/B;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAExC;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,4BAA4B;IACzC;;;;;OAKG;IACH,MAAM,EAAE,UAAU,GAAG,WAAW,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