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.
Files changed (87) hide show
  1. package/InstantpayCodePush.podspec +20 -0
  2. package/LICENSE +20 -0
  3. package/README.md +158 -0
  4. package/android/build.gradle +91 -0
  5. package/android/gradle.properties +5 -0
  6. package/android/src/main/AndroidManifest.xml +2 -0
  7. package/android/src/main/java/com/instantpaycodepush/BundleFileStorageService.kt +835 -0
  8. package/android/src/main/java/com/instantpaycodepush/BundleMetadata.kt +249 -0
  9. package/android/src/main/java/com/instantpaycodepush/CommonHelper.kt +39 -0
  10. package/android/src/main/java/com/instantpaycodepush/DecompressService.kt +85 -0
  11. package/android/src/main/java/com/instantpaycodepush/DecompressionStrategy.kt +24 -0
  12. package/android/src/main/java/com/instantpaycodepush/FileManagerService.kt +105 -0
  13. package/android/src/main/java/com/instantpaycodepush/HashUtils.kt +50 -0
  14. package/android/src/main/java/com/instantpaycodepush/InstantpayCodePushModule.kt +182 -0
  15. package/android/src/main/java/com/instantpaycodepush/InstantpayCodePushPackage.kt +33 -0
  16. package/android/src/main/java/com/instantpaycodepush/IpayCodePush.kt +101 -0
  17. package/android/src/main/java/com/instantpaycodepush/IpayCodePushException.kt +135 -0
  18. package/android/src/main/java/com/instantpaycodepush/IpayCodePushImpl.kt +329 -0
  19. package/android/src/main/java/com/instantpaycodepush/OkHttpDownloadService.kt +283 -0
  20. package/android/src/main/java/com/instantpaycodepush/ReactIntegrationManager.kt +141 -0
  21. package/android/src/main/java/com/instantpaycodepush/ReactIntegrationManagerBase.kt +35 -0
  22. package/android/src/main/java/com/instantpaycodepush/SignatureVerifier.kt +354 -0
  23. package/android/src/main/java/com/instantpaycodepush/VersionedPreferencesService.kt +70 -0
  24. package/android/src/main/java/com/instantpaycodepush/ZipDecompressionStrategy.kt +198 -0
  25. package/ios/InstantpayCodePush.h +5 -0
  26. package/ios/InstantpayCodePush.mm +21 -0
  27. package/lib/module/DefaultResolver.js +34 -0
  28. package/lib/module/DefaultResolver.js.map +1 -0
  29. package/lib/module/NativeInstantpayCodePush.js +5 -0
  30. package/lib/module/NativeInstantpayCodePush.js.map +1 -0
  31. package/lib/module/checkForUpdate.js +68 -0
  32. package/lib/module/checkForUpdate.js.map +1 -0
  33. package/lib/module/error.js +137 -0
  34. package/lib/module/error.js.map +1 -0
  35. package/lib/module/fetchUpdateInfo.js +36 -0
  36. package/lib/module/fetchUpdateInfo.js.map +1 -0
  37. package/lib/module/global.d.js +8 -0
  38. package/lib/module/global.d.js.map +1 -0
  39. package/lib/module/hooks/useEventCallback.js +13 -0
  40. package/lib/module/hooks/useEventCallback.js.map +1 -0
  41. package/lib/module/index.js +291 -0
  42. package/lib/module/index.js.map +1 -0
  43. package/lib/module/native.js +233 -0
  44. package/lib/module/native.js.map +1 -0
  45. package/lib/module/package.json +1 -0
  46. package/lib/module/store.js +53 -0
  47. package/lib/module/store.js.map +1 -0
  48. package/lib/module/types.js +62 -0
  49. package/lib/module/types.js.map +1 -0
  50. package/lib/module/wrap.js +171 -0
  51. package/lib/module/wrap.js.map +1 -0
  52. package/lib/typescript/package.json +1 -0
  53. package/lib/typescript/src/DefaultResolver.d.ts +10 -0
  54. package/lib/typescript/src/DefaultResolver.d.ts.map +1 -0
  55. package/lib/typescript/src/NativeInstantpayCodePush.d.ts +100 -0
  56. package/lib/typescript/src/NativeInstantpayCodePush.d.ts.map +1 -0
  57. package/lib/typescript/src/checkForUpdate.d.ts +29 -0
  58. package/lib/typescript/src/checkForUpdate.d.ts.map +1 -0
  59. package/lib/typescript/src/error.d.ts +124 -0
  60. package/lib/typescript/src/error.d.ts.map +1 -0
  61. package/lib/typescript/src/fetchUpdateInfo.d.ts +8 -0
  62. package/lib/typescript/src/fetchUpdateInfo.d.ts.map +1 -0
  63. package/lib/typescript/src/hooks/useEventCallback.d.ts +5 -0
  64. package/lib/typescript/src/hooks/useEventCallback.d.ts.map +1 -0
  65. package/lib/typescript/src/index.d.ts +203 -0
  66. package/lib/typescript/src/index.d.ts.map +1 -0
  67. package/lib/typescript/src/native.d.ts +128 -0
  68. package/lib/typescript/src/native.d.ts.map +1 -0
  69. package/lib/typescript/src/store.d.ts +11 -0
  70. package/lib/typescript/src/store.d.ts.map +1 -0
  71. package/lib/typescript/src/types.d.ts +174 -0
  72. package/lib/typescript/src/types.d.ts.map +1 -0
  73. package/lib/typescript/src/wrap.d.ts +179 -0
  74. package/lib/typescript/src/wrap.d.ts.map +1 -0
  75. package/package.json +174 -0
  76. package/src/DefaultResolver.ts +36 -0
  77. package/src/NativeInstantpayCodePush.ts +111 -0
  78. package/src/checkForUpdate.ts +122 -0
  79. package/src/error.ts +159 -0
  80. package/src/fetchUpdateInfo.ts +47 -0
  81. package/src/global.d.ts +23 -0
  82. package/src/hooks/useEventCallback.ts +30 -0
  83. package/src/index.tsx +379 -0
  84. package/src/native.ts +280 -0
  85. package/src/store.ts +69 -0
  86. package/src/types.ts +227 -0
  87. package/src/wrap.tsx +384 -0
@@ -0,0 +1,171 @@
1
+ "use strict";
2
+
3
+ import React, { useEffect, useLayoutEffect, useState } from "react";
4
+ import { checkForUpdate } from "./checkForUpdate.js";
5
+ import { getBundleId, notifyAppReady as nativeNotifyAppReady, reload } from "./native.js";
6
+ import { useEventCallback } from "./hooks/useEventCallback.js";
7
+ import { useIpayCodePushStore } from "./store.js";
8
+
9
+ /**
10
+ * Common options shared between auto and manual update modes
11
+ */
12
+
13
+ /**
14
+ * Configuration with baseURL for standard server-based updates
15
+ */
16
+
17
+ /**
18
+ * Configuration with resolver for custom network operations
19
+ */
20
+
21
+ /**
22
+ * Union type ensuring baseURL and resolver are mutually exclusive
23
+ */
24
+
25
+ /**
26
+ * Internal options after normalization in index.ts
27
+ * Always has resolver (never baseURL)
28
+ */
29
+ import { jsx as _jsx } from "react/jsx-runtime";
30
+ /**
31
+ * Helper function to handle notifyAppReady flow
32
+ */
33
+ const handleNotifyAppReady = async options => {
34
+ try {
35
+ // Always call native notifyAppReady for bundle promotion
36
+ const nativeResult = nativeNotifyAppReady();
37
+
38
+ // If resolver.notifyAppReady exists, call it with simplified params
39
+ if (options.resolver?.notifyAppReady) {
40
+ await options.resolver.notifyAppReady({
41
+ status: nativeResult.status,
42
+ crashedBundleId: nativeResult.crashedBundleId,
43
+ requestHeaders: options.requestHeaders,
44
+ requestTimeout: options.requestTimeout
45
+ }).catch(e => {
46
+ console.warn("[IpayCodePush] Resolver notifyAppReady failed:", e);
47
+ });
48
+ }
49
+ options.onNotifyAppReady?.(nativeResult);
50
+ } catch (e) {
51
+ console.warn("[IpayCodePush] Failed to notify app ready:", e);
52
+ }
53
+ };
54
+
55
+ /**
56
+ * @usage IpayCodePushHOC.wrap({})(App); App Component or any other component
57
+ * @param options
58
+ * @returns
59
+ */
60
+ export function wrap(options) {
61
+ if (options.updateMode === "manual") {
62
+ return WrappedComponent => {
63
+ const ManualHOC = props => {
64
+ useLayoutEffect(() => {
65
+ void handleNotifyAppReady(options);
66
+ }, []);
67
+ return /*#__PURE__*/_jsx(WrappedComponent, {
68
+ ...props
69
+ });
70
+ };
71
+ return ManualHOC;
72
+ };
73
+ }
74
+
75
+ // updateMode: "auto"
76
+ const {
77
+ reloadOnForceUpdate = true,
78
+ ...restOptions
79
+ } = options;
80
+ return WrappedComponent => {
81
+ const IpayCodePushHOC = props => {
82
+ const progress = useIpayCodePushStore(state => state.progress);
83
+ const [message, setMessage] = useState(null);
84
+ const [updateStatus, setUpdateStatus] = useState("CHECK_FOR_UPDATE");
85
+ const initIpayCodePush = useEventCallback(async () => {
86
+ try {
87
+ setUpdateStatus("CHECK_FOR_UPDATE");
88
+ const updateInfo = await checkForUpdate({
89
+ resolver: restOptions.resolver,
90
+ updateStrategy: restOptions.updateStrategy,
91
+ requestHeaders: restOptions.requestHeaders,
92
+ requestTimeout: restOptions.requestTimeout,
93
+ onError: restOptions.onError
94
+ });
95
+ setMessage(updateInfo?.message ?? null);
96
+ if (!updateInfo) {
97
+ restOptions.onUpdateProcessCompleted?.({
98
+ status: "UP_TO_DATE",
99
+ shouldForceUpdate: false,
100
+ message: null,
101
+ id: getBundleId()
102
+ });
103
+ setUpdateStatus("UPDATE_PROCESS_COMPLETED");
104
+ return;
105
+ }
106
+
107
+ //If forceupdate is not allowed for the bunlde
108
+ if (updateInfo.shouldForceUpdate === false) {
109
+ void updateInfo.updateBundle().catch(error => {
110
+ restOptions.onError?.(error);
111
+ });
112
+ restOptions.onUpdateProcessCompleted?.({
113
+ id: updateInfo.id,
114
+ status: updateInfo.status,
115
+ shouldForceUpdate: updateInfo.shouldForceUpdate,
116
+ message: updateInfo.message
117
+ });
118
+ setUpdateStatus("UPDATE_PROCESS_COMPLETED");
119
+ return;
120
+ }
121
+
122
+ // Force Update Scenario
123
+ setUpdateStatus("UPDATING");
124
+ const isSuccess = await updateInfo.updateBundle();
125
+ if (!isSuccess) {
126
+ throw new Error("New update was found but failed to download the bundle.");
127
+ }
128
+ if (reloadOnForceUpdate) {
129
+ await reload();
130
+ }
131
+ restOptions.onUpdateProcessCompleted?.({
132
+ id: updateInfo.id,
133
+ status: updateInfo.status,
134
+ shouldForceUpdate: updateInfo.shouldForceUpdate,
135
+ message: updateInfo.message
136
+ });
137
+ setUpdateStatus("UPDATE_PROCESS_COMPLETED");
138
+ } catch (error) {
139
+ restOptions.onError?.(error);
140
+ setUpdateStatus("UPDATE_PROCESS_COMPLETED");
141
+ }
142
+ });
143
+ useEffect(() => {
144
+ restOptions.onProgress?.(progress);
145
+ }, [progress]);
146
+
147
+ // Notify native side that app is ready (JS bundle fully loaded)
148
+ useLayoutEffect(() => {
149
+ void handleNotifyAppReady(restOptions);
150
+ }, []);
151
+
152
+ // Start update check
153
+ useLayoutEffect(() => {
154
+ initIpayCodePush();
155
+ }, []);
156
+ if (restOptions.fallbackComponent && updateStatus !== "UPDATE_PROCESS_COMPLETED") {
157
+ const Fallback = restOptions.fallbackComponent;
158
+ return /*#__PURE__*/_jsx(Fallback, {
159
+ progress: progress,
160
+ status: updateStatus,
161
+ message: message
162
+ });
163
+ }
164
+ return /*#__PURE__*/_jsx(WrappedComponent, {
165
+ ...props
166
+ });
167
+ };
168
+ return IpayCodePushHOC;
169
+ };
170
+ }
171
+ //# sourceMappingURL=wrap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useEffect","useLayoutEffect","useState","checkForUpdate","getBundleId","notifyAppReady","nativeNotifyAppReady","reload","useEventCallback","useIpayCodePushStore","jsx","_jsx","handleNotifyAppReady","options","nativeResult","resolver","status","crashedBundleId","requestHeaders","requestTimeout","catch","e","console","warn","onNotifyAppReady","wrap","updateMode","WrappedComponent","ManualHOC","props","reloadOnForceUpdate","restOptions","IpayCodePushHOC","progress","state","message","setMessage","updateStatus","setUpdateStatus","initIpayCodePush","updateInfo","updateStrategy","onError","onUpdateProcessCompleted","shouldForceUpdate","id","updateBundle","error","isSuccess","Error","onProgress","fallbackComponent","Fallback"],"sourceRoot":"../../src","sources":["wrap.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAGC,SAAS,EAAEC,eAAe,EAAEC,QAAQ,QAAQ,OAAO;AAClE,SAASC,cAAc,QAAQ,qBAAkB;AACjD,SACIC,WAAW,EAEXC,cAAc,IAAIC,oBAAoB,EACtCC,MAAM,QACH,aAAU;AAGjB,SAASC,gBAAgB,QAAQ,6BAA0B;AAC3D,SAASC,oBAAoB,QAAQ,YAAS;;AAgB9C;AACA;AACA;;AA0CA;AACA;AACA;;AAcA;AACA;AACA;;AAaA;AACA;AACA;;AAyEA;AACA;AACA;AACA;AAHA,SAAAC,GAAA,IAAAC,IAAA;AAkCA;AACA;AACA;AACA,MAAMC,oBAAoB,GAAG,MAAOC,OAKnC,IAAoB;EACjB,IAAI;IACA;IACA,MAAMC,YAAY,GAAGR,oBAAoB,CAAC,CAAC;;IAE3C;IACA,IAAIO,OAAO,CAACE,QAAQ,EAAEV,cAAc,EAAE;MAClC,MAAMQ,OAAO,CAACE,QAAQ,CAACV,cAAc,CAA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;AACL","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,10 @@
1
+ import type { IpayCodePushResolver } from "./types";
2
+ /**
3
+ * Creates a default resolver that uses baseURL for network operations.
4
+ * This encapsulates the existing baseURL logic into a resolver.
5
+ *
6
+ * @param baseURL - The base URL for the update server
7
+ * @returns A HotUpdaterResolver that uses the baseURL
8
+ */
9
+ export declare function createDefaultResolver(baseURL: string): IpayCodePushResolver;
10
+ //# sourceMappingURL=DefaultResolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DefaultResolver.d.ts","sourceRoot":"","sources":["../../../src/DefaultResolver.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAA6B,MAAM,SAAS,CAAC;AAE/E;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,oBAAoB,CAwB3E"}
@@ -0,0 +1,100 @@
1
+ import { type TurboModule } from 'react-native';
2
+ export interface UpdateBundleParams {
3
+ bundleId: string;
4
+ fileUrl: string | null;
5
+ /**
6
+ * File hash for integrity/signature verification.
7
+ *
8
+ * Format depends on signing configuration:
9
+ * - Signed: `sig:<base64_signature>` - Native will verify signature (and implicitly hash)
10
+ * - Unsigned: `<hex_hash>` - Native will verify SHA256 hash only
11
+ *
12
+ * Native determines verification mode by checking for "sig:" prefix.
13
+ */
14
+ fileHash: string | null;
15
+ }
16
+ export interface Spec extends TurboModule {
17
+ reload(): Promise<void>;
18
+ /**
19
+ * Downloads and applies a bundle update.
20
+ *
21
+ * @param params - Update bundle parameters
22
+ * @returns Promise that resolves to true if successful
23
+ * @throws {IpayCodePushErrorCode} Rejects with one of the following error codes:
24
+ *
25
+ * Parameter validation:
26
+ * - MISSING_BUNDLE_ID: Missing or empty bundleId
27
+ * - INVALID_FILE_URL: Invalid fileUrl provided
28
+ *
29
+ * Bundle storage:
30
+ * - DIRECTORY_CREATION_FAILED: Failed to create bundle directory
31
+ * - DOWNLOAD_FAILED: Failed to download bundle
32
+ * - INCOMPLETE_DOWNLOAD: Download incomplete (size mismatch)
33
+ * - EXTRACTION_FORMAT_ERROR: Invalid or corrupted archive format
34
+ * - INVALID_BUNDLE: Bundle missing required platform files
35
+ * - INSUFFICIENT_DISK_SPACE: Insufficient disk space
36
+ * - MOVE_OPERATION_FAILED: Failed to move bundle files
37
+ * - BUNDLE_IN_CRASHED_HISTORY: Bundle was previously marked as crashed
38
+ *
39
+ * Signature:
40
+ * - SIGNATURE_VERIFICATION_FAILED: Any signature/hash verification failure
41
+ *
42
+ * Internal:
43
+ * - SELF_DEALLOCATED: Native object was deallocated (iOS)
44
+ * - UNKNOWN_ERROR: Fallback for rare or platform-specific errors
45
+ *
46
+ * Note: iOS normalizes rare signature/storage errors to SIGNATURE_VERIFICATION_FAILED
47
+ * or UNKNOWN_ERROR to keep the JS error surface small.
48
+ */
49
+ updateBundle(params: UpdateBundleParams): Promise<boolean>;
50
+ /**
51
+ * Notifies the native side that the app has successfully started with the given bundle.
52
+ * If the bundle matches the staging bundle, it promotes to stable.
53
+ *
54
+ * @param params - Parameters containing the bundle ID
55
+ * @returns Object with status and optional crashedBundleId
56
+ * - `status: "PROMOTED"` - Staging bundle was promoted to stable (ACTIVE event)
57
+ * - `status: "RECOVERED"` - App recovered from crash, rollback occurred (ROLLBACK event)
58
+ * - `status: "STABLE"` - No changes, already stable
59
+ * - `crashedBundleId` - Present only when status is "RECOVERED"
60
+ */
61
+ notifyAppReady(params: {
62
+ bundleId: string;
63
+ }): {
64
+ status: "PROMOTED" | "RECOVERED" | "STABLE";
65
+ crashedBundleId?: string;
66
+ };
67
+ /**
68
+ * Gets the list of bundle IDs that have been marked as crashed.
69
+ * These bundles will be rejected if attempted to install again.
70
+ *
71
+ * @returns Array of crashed bundle IDs
72
+ */
73
+ getCrashHistory(): string[];
74
+ /**
75
+ * Clears the crashed bundle history, allowing previously crashed bundles
76
+ * to be installed again.
77
+ *
78
+ * @returns true if clearing was successful
79
+ */
80
+ clearCrashHistory(): boolean;
81
+ /**
82
+ * Gets the base URL for the current active bundle directory.
83
+ * Returns the file:// URL to the bundle directory without trailing slash.
84
+ * This is used for Expo DOM components to construct full asset paths.
85
+ *
86
+ * @returns Base URL string (e.g., "file:///data/.../bundle-store/abc123") or "" if not available
87
+ */
88
+ getBaseURL: () => string;
89
+ addListener(eventName: string): void;
90
+ removeListeners(count: number): void;
91
+ readonly getConstants: () => {
92
+ MIN_BUNDLE_ID: string;
93
+ APP_VERSION: string | null;
94
+ CHANNEL: string;
95
+ FINGERPRINT_HASH: string | null;
96
+ };
97
+ }
98
+ declare const _default: Spec;
99
+ export default _default;
100
+ //# sourceMappingURL=NativeInstantpayCodePush.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeInstantpayCodePush.d.ts","sourceRoot":"","sources":["../../../src/NativeInstantpayCodePush.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAGrE,MAAM,WAAW,kBAAkB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB;;;;;;;;OAQG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,MAAM,WAAW,IAAK,SAAQ,WAAW;IAGrC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAExB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAE3D;;;;;;;;;;OAUG;IACH,cAAc,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG;QAC1C,MAAM,EAAE,UAAU,GAAG,WAAW,GAAG,QAAQ,CAAC;QAC5C,eAAe,CAAC,EAAE,MAAM,CAAC;KAC5B,CAAC;IAEF;;;;;OAKG;IACH,eAAe,IAAI,MAAM,EAAE,CAAC;IAE5B;;;;;OAKG;IACH,iBAAiB,IAAI,OAAO,CAAC;IAE7B;;;;;;OAMG;IACH,UAAU,EAAE,MAAM,MAAM,CAAC;IAGzB,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAErC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAErC,QAAQ,CAAC,YAAY,EAAE,MAAM;QACzB,aAAa,EAAE,MAAM,CAAC;QACtB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;QAC3B,OAAO,EAAE,MAAM,CAAC;QAChB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;KACnC,CAAC;CACL;;AAED,wBAA4E"}
@@ -0,0 +1,29 @@
1
+ import type { IpayCodePushResolver, AppUpdateInfo } from "./types";
2
+ export interface CheckForUpdateOptions {
3
+ /**
4
+ * Update strategy
5
+ * - "fingerprint": Use fingerprint hash to check for updates
6
+ * - "appVersion": Use app version to check for updates
7
+ * - Can override the strategy set in IpayCodePush.wrap()
8
+ */
9
+ updateStrategy: "appVersion" | "fingerprint";
10
+ requestHeaders?: Record<string, string>;
11
+ onError?: (error: Error) => void;
12
+ /**
13
+ * The timeout duration for the request.
14
+ * @default 5000
15
+ */
16
+ requestTimeout?: number;
17
+ }
18
+ export type CheckForUpdateResult = AppUpdateInfo & {
19
+ /**
20
+ * Updates the bundle.
21
+ * This method is equivalent to `IpayCodePush.updateBundle()` but with all required arguments pre-filled.
22
+ */
23
+ updateBundle: () => Promise<boolean>;
24
+ };
25
+ export interface InternalCheckForUpdateOptions extends CheckForUpdateOptions {
26
+ resolver: IpayCodePushResolver;
27
+ }
28
+ export declare function checkForUpdate(options: InternalCheckForUpdateOptions): Promise<CheckForUpdateResult | null>;
29
+ //# sourceMappingURL=checkForUpdate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkForUpdate.d.ts","sourceRoot":"","sources":["../../../src/checkForUpdate.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGnE,MAAM,WAAW,qBAAqB;IAClC;;;;;OAKG;IACH,cAAc,EAAE,YAAY,GAAG,aAAa,CAAC;IAE7C,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAExC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,MAAM,oBAAoB,GAAG,aAAa,GAAG;IAC/C;;;OAGG;IACH,YAAY,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;CACxC,CAAC;AAGF,MAAM,WAAW,6BAA8B,SAAQ,qBAAqB;IACxE,QAAQ,EAAE,oBAAoB,CAAC;CAClC;AAED,wBAAsB,cAAc,CAChC,OAAO,EAAE,6BAA6B,GACvC,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAwEtC"}
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Ipay Code Push Error Codes
3
+ *
4
+ * This file defines all possible error codes that can be thrown by the native
5
+ * updateBundle function. These error codes are shared across iOS and Android
6
+ * implementations to ensure consistent error handling.
7
+ *
8
+ * Error Classification:
9
+ * - Parameter Validation: Invalid or missing function parameters
10
+ * - Bundle Storage: Errors during download, extraction, and storage
11
+ * - Signature Verification: Cryptographic verification failures (collapsed to a single public code)
12
+ * - Internal: Platform-specific or unexpected errors
13
+ *
14
+ * Retryability:
15
+ * - Retryable: DOWNLOAD_FAILED, INCOMPLETE_DOWNLOAD
16
+ * - Non-retryable: Most validation and verification errors
17
+ */
18
+ export declare enum IpayCodePushErrorCode {
19
+ /**
20
+ * Bundle ID is missing or empty.
21
+ * Thrown when bundleId parameter is null, undefined, or empty string.
22
+ * @retryable false
23
+ */
24
+ MISSING_BUNDLE_ID = "MISSING_BUNDLE_ID",
25
+ /**
26
+ * File URL is invalid or malformed.
27
+ * Thrown when fileUrl parameter cannot be parsed as a valid URL.
28
+ * @retryable false
29
+ */
30
+ INVALID_FILE_URL = "INVALID_FILE_URL",
31
+ /**
32
+ * Failed to create required directory for bundle storage.
33
+ * Thrown when bundle directory creation fails due to permissions or disk errors.
34
+ * @retryable false - Usually indicates permissions or filesystem corruption
35
+ */
36
+ DIRECTORY_CREATION_FAILED = "DIRECTORY_CREATION_FAILED",
37
+ /**
38
+ * Bundle download failed.
39
+ * Covers network errors, HTTP errors (4xx/5xx), timeouts, and connection issues.
40
+ * Check error message for specific cause (network, HTTP status code, etc.).
41
+ * @retryable true - Network issues are often transient
42
+ */
43
+ DOWNLOAD_FAILED = "DOWNLOAD_FAILED",
44
+ /**
45
+ * Download incomplete - received size doesn't match expected size.
46
+ * Thrown when downloaded file size doesn't match Content-Length header.
47
+ * Error message includes both expected and actual byte counts.
48
+ * @retryable true - Download may succeed on retry
49
+ */
50
+ INCOMPLETE_DOWNLOAD = "INCOMPLETE_DOWNLOAD",
51
+ /**
52
+ * Bundle archive format is invalid or corrupted.
53
+ * Thrown when ZIP file has wrong magic bytes, invalid structure, or unsupported format.
54
+ * Also thrown for path traversal attempts during extraction.
55
+ * @retryable false - Indicates corrupted or malicious bundle
56
+ */
57
+ EXTRACTION_FORMAT_ERROR = "EXTRACTION_FORMAT_ERROR",
58
+ /**
59
+ * Bundle missing required platform files.
60
+ * Thrown when extracted bundle doesn't contain index.android.bundle (Android)
61
+ * or main.jsbundle (iOS).
62
+ * @retryable false - Indicates incorrectly built bundle
63
+ */
64
+ INVALID_BUNDLE = "INVALID_BUNDLE",
65
+ /**
66
+ * Insufficient disk space for bundle download and extraction.
67
+ * Thrown when available disk space is less than required (file size * 2).
68
+ * Error message includes required and available bytes.
69
+ * @retryable false - User must free up disk space
70
+ */
71
+ INSUFFICIENT_DISK_SPACE = "INSUFFICIENT_DISK_SPACE",
72
+ /**
73
+ * Bundle signature verification failed (general).
74
+ * Thrown when cryptographic signature verification fails.
75
+ * All signature/hash sub-errors are collapsed into this public code.
76
+ * @retryable false - Indicates tampered or incorrectly signed bundle
77
+ */
78
+ SIGNATURE_VERIFICATION_FAILED = "SIGNATURE_VERIFICATION_FAILED",
79
+ /**
80
+ * Failed to move bundle to final location.
81
+ * Thrown when atomic move from temp directory to final directory fails.
82
+ * iOS: Thrown if move operation fails.
83
+ * Android: Thrown if rename, move, AND copy all fail.
84
+ * @retryable false - Usually indicates filesystem corruption or permissions
85
+ */
86
+ MOVE_OPERATION_FAILED = "MOVE_OPERATION_FAILED",
87
+ /**
88
+ * Bundle is in crashed history and cannot be applied.
89
+ * Thrown when attempting to install a bundle that previously caused a crash.
90
+ * Use IpayCodePush.clearCrashHistory() to allow retrying this bundle.
91
+ * @retryable false - Bundle was marked as crashed for safety
92
+ */
93
+ BUNDLE_IN_CRASHED_HISTORY = "BUNDLE_IN_CRASHED_HISTORY",
94
+ /**
95
+ * Internal error: self deallocated during update (iOS only).
96
+ * Thrown when the native object is deallocated mid-operation.
97
+ * iOS-specific due to manual memory management (ARC).
98
+ * Not applicable to Android (uses garbage collection).
99
+ * @platform iOS
100
+ * @retryable false - Memory management issue
101
+ */
102
+ SELF_DEALLOCATED = "SELF_DEALLOCATED",
103
+ /**
104
+ * An unknown or unexpected error occurred.
105
+ * Catch-all for errors that don't fit other categories.
106
+ * Check error message for details.
107
+ * @retryable unknown - Depends on underlying cause
108
+ */
109
+ UNKNOWN_ERROR = "UNKNOWN_ERROR"
110
+ }
111
+ /**
112
+ * Type guard to check if an error is a IpayCodePushError
113
+ */
114
+ export declare function isIpayCodePushError(error: unknown): error is {
115
+ code: IpayCodePushErrorCode;
116
+ message: string;
117
+ };
118
+ /**
119
+ * Base error class for Ipay Code Push
120
+ */
121
+ export declare class IpayCodePushError extends Error {
122
+ constructor(message: string);
123
+ }
124
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../src/error.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,oBAAY,qBAAqB;IAG7B;;;;OAIG;IACH,iBAAiB,sBAAsB;IAEvC;;;;OAIG;IACH,gBAAgB,qBAAqB;IAIrC;;;;OAIG;IACH,yBAAyB,8BAA8B;IAEvD;;;;;OAKG;IACH,eAAe,oBAAoB;IAEnC;;;;;OAKG;IACH,mBAAmB,wBAAwB;IAE3C;;;;;OAKG;IACH,uBAAuB,4BAA4B;IAEnD;;;;;OAKG;IACH,cAAc,mBAAmB;IAEjC;;;;;OAKG;IACH,uBAAuB,4BAA4B;IAEnD;;;;;OAKG;IACH,6BAA6B,kCAAkC;IAE/D;;;;;;OAMG;IACH,qBAAqB,0BAA0B;IAE/C;;;;;OAKG;IACH,yBAAyB,8BAA8B;IAOvD;;;;;;;OAOG;IACH,gBAAgB,qBAAqB;IAErC;;;;;OAKG;IACH,aAAa,kBAAkB;CAClC;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAC/B,KAAK,EAAE,OAAO,GACf,KAAK,IAAI;IAAE,IAAI,EAAE,qBAAqB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAU3D;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;gBAC5B,OAAO,EAAE,MAAM;CAI9B"}
@@ -0,0 +1,8 @@
1
+ import type { AppUpdateInfo } from "./types";
2
+ export declare const fetchUpdateInfo: ({ url, requestHeaders, onError, requestTimeout, }: {
3
+ url: string;
4
+ requestHeaders?: Record<string, string>;
5
+ onError?: (error: Error) => void;
6
+ requestTimeout?: number;
7
+ }) => Promise<AppUpdateInfo | null>;
8
+ //# sourceMappingURL=fetchUpdateInfo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchUpdateInfo.d.ts","sourceRoot":"","sources":["../../../src/fetchUpdateInfo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,eAAO,MAAM,eAAe,GAAU,mDAKnC;IACC,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,cAAc,CAAC,EAAE,MAAM,CAAC;CAC3B,KAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAkC/B,CAAC"}
@@ -0,0 +1,5 @@
1
+ type EventCallback<Args extends unknown[], R> = ((...args: Args) => R) | undefined;
2
+ export declare function useEventCallback<Args extends unknown[], R>(fn: (...args: Args) => R): (...args: Args) => R;
3
+ export declare function useEventCallback<Args extends unknown[], R>(fn: EventCallback<Args, R>): EventCallback<Args, R>;
4
+ export {};
5
+ //# sourceMappingURL=useEventCallback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEventCallback.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useEventCallback.ts"],"names":[],"mappings":"AAEA,KAAK,aAAa,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,CAAC,IACxC,CAAC,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,CAAC,CAAC,GACtB,SAAS,CAAC;AAEd,wBAAgB,gBAAgB,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,CAAC,EACtD,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,CAAC,GACzB,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,CAAC,CAAC;AAExB,wBAAgB,gBAAgB,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,CAAC,EACtD,EAAE,EAAE,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC,GAC3B,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC"}