@dynamic-labs-wallet/browser 0.0.239 → 0.0.240
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/index.cjs.js +7 -56
- package/index.esm.js +7 -56
- package/package.json +2 -2
- package/src/backup/providers/iCloud.d.ts +0 -1
- package/src/backup/providers/iCloud.d.ts.map +1 -1
package/index.cjs.js
CHANGED
|
@@ -658,16 +658,6 @@ const downloadStringAsFile = ({ filename, content, mimeType = 'application/json'
|
|
|
658
658
|
URL.revokeObjectURL(url);
|
|
659
659
|
};
|
|
660
660
|
|
|
661
|
-
// CloudKit Web Services API token for public operations
|
|
662
|
-
// This token only allows access to the iCloud.KeyShareBackup container
|
|
663
|
-
// and is safe to include in client-side code
|
|
664
|
-
const DEFAULT_CONFIG = {
|
|
665
|
-
containerIdentifier: 'iCloud.KeyShareBackup',
|
|
666
|
-
// apiToken: '1221c5ccdf2ddb9abdb035befe7c197b07102972b30bbcbe363f6d722f3127a1', // prod
|
|
667
|
-
apiToken: '332a46c457183332f8d2a3d94d2ac87e9e9ae2af81d8a6d1ea89c27bb2fc0e97',
|
|
668
|
-
// environment: 'production',
|
|
669
|
-
environment: 'development'
|
|
670
|
-
};
|
|
671
661
|
const CLOUDKIT_CDN_URL = 'https://cdn.apple-cloudkit.com/ck/2/cloudkit.js';
|
|
672
662
|
const BACKUP_RECORD_TYPE = 'Backup';
|
|
673
663
|
let cloudKitLoaded = false;
|
|
@@ -703,7 +693,6 @@ const loadCloudKit = ()=>{
|
|
|
703
693
|
script.src = CLOUDKIT_CDN_URL;
|
|
704
694
|
script.onload = ()=>{
|
|
705
695
|
cloudKitLoaded = true;
|
|
706
|
-
logger.debug('[iCloud] CloudKit JS loaded successfully');
|
|
707
696
|
resolve();
|
|
708
697
|
};
|
|
709
698
|
script.onerror = (error)=>{
|
|
@@ -717,12 +706,14 @@ const configureCloudKit = (config, signInButtonId)=>{
|
|
|
717
706
|
if (cloudKitConfigured && currentSignInButtonId === signInButtonId) {
|
|
718
707
|
return;
|
|
719
708
|
}
|
|
720
|
-
|
|
709
|
+
if (!(config == null ? void 0 : config.containerIdentifier) || !(config == null ? void 0 : config.apiToken) || !(config == null ? void 0 : config.environment)) {
|
|
710
|
+
throw new Error('iCloud configuration is incomplete. Please configure iCloud settings in the dashboard.');
|
|
711
|
+
}
|
|
721
712
|
const containerConfig = {
|
|
722
|
-
containerIdentifier:
|
|
723
|
-
environment:
|
|
713
|
+
containerIdentifier: config.containerIdentifier,
|
|
714
|
+
environment: config.environment,
|
|
724
715
|
apiTokenAuth: {
|
|
725
|
-
apiToken:
|
|
716
|
+
apiToken: config.apiToken,
|
|
726
717
|
persist: true,
|
|
727
718
|
signInButton: signInButtonId ? {
|
|
728
719
|
id: signInButtonId,
|
|
@@ -737,15 +728,10 @@ const configureCloudKit = (config, signInButtonId)=>{
|
|
|
737
728
|
});
|
|
738
729
|
cloudKitConfigured = true;
|
|
739
730
|
currentSignInButtonId = signInButtonId || null;
|
|
740
|
-
logger.debug('[iCloud] CloudKit configured', {
|
|
741
|
-
containerIdentifier: mergedConfig.containerIdentifier,
|
|
742
|
-
environment: mergedConfig.environment
|
|
743
|
-
});
|
|
744
731
|
};
|
|
745
732
|
const resetCloudKitConfig = ()=>{
|
|
746
733
|
cloudKitConfigured = false;
|
|
747
734
|
currentSignInButtonId = null;
|
|
748
|
-
logger.debug('[iCloud] CloudKit config reset');
|
|
749
735
|
};
|
|
750
736
|
/**
|
|
751
737
|
* Check if user is already authenticated using fetchCurrentUserIdentity.
|
|
@@ -765,7 +751,6 @@ const resetCloudKitConfig = ()=>{
|
|
|
765
751
|
if (authenticationAbortController) {
|
|
766
752
|
authenticationAbortController.abort();
|
|
767
753
|
authenticationAbortController = null;
|
|
768
|
-
logger.info('[iCloud] Authentication cancelled by user');
|
|
769
754
|
}
|
|
770
755
|
};
|
|
771
756
|
const ensureICloudAuth = async (onSignInRequired, onSignInComplete, onAuthStatusUpdate, options)=>{
|
|
@@ -784,7 +769,6 @@ const ensureICloudAuth = async (onSignInRequired, onSignInComplete, onAuthStatus
|
|
|
784
769
|
// First, check if user is already authenticated (more reliable than setUpAuth)
|
|
785
770
|
const alreadyAuthenticated = await isUserAuthenticated(container);
|
|
786
771
|
if (alreadyAuthenticated) {
|
|
787
|
-
logger.info('[iCloud] User already authenticated');
|
|
788
772
|
onAuthStatusUpdate == null ? void 0 : onAuthStatusUpdate('Authenticated');
|
|
789
773
|
return;
|
|
790
774
|
}
|
|
@@ -793,12 +777,10 @@ const ensureICloudAuth = async (onSignInRequired, onSignInComplete, onAuthStatus
|
|
|
793
777
|
await container.setUpAuth();
|
|
794
778
|
// Double-check authentication after setUpAuth
|
|
795
779
|
if (await isUserAuthenticated(container)) {
|
|
796
|
-
logger.info('[iCloud] User authenticated after setUpAuth');
|
|
797
780
|
onAuthStatusUpdate == null ? void 0 : onAuthStatusUpdate('Authenticated');
|
|
798
781
|
return;
|
|
799
782
|
}
|
|
800
783
|
// User needs to sign in
|
|
801
|
-
logger.info('[iCloud] User authentication required');
|
|
802
784
|
onAuthStatusUpdate == null ? void 0 : onAuthStatusUpdate('Waiting for sign-in...');
|
|
803
785
|
if (onSignInRequired) ;
|
|
804
786
|
return new Promise((resolve, reject)=>{
|
|
@@ -829,7 +811,6 @@ const ensureICloudAuth = async (onSignInRequired, onSignInComplete, onAuthStatus
|
|
|
829
811
|
if (await isUserAuthenticated(container)) {
|
|
830
812
|
resolved = true;
|
|
831
813
|
cleanup();
|
|
832
|
-
logger.info('[iCloud] Authentication successful');
|
|
833
814
|
onAuthStatusUpdate == null ? void 0 : onAuthStatusUpdate('Authenticated');
|
|
834
815
|
if (onSignInComplete) ;
|
|
835
816
|
resolve();
|
|
@@ -843,7 +824,6 @@ const ensureICloudAuth = async (onSignInRequired, onSignInComplete, onAuthStatus
|
|
|
843
824
|
resolved = true;
|
|
844
825
|
cleanup();
|
|
845
826
|
if (onSignInComplete) ;
|
|
846
|
-
logger.warn('[iCloud] Authentication timed out');
|
|
847
827
|
reject(new Error('iCloud sign-in timed out. Please ensure you are signed into iCloud ' + 'in your browser settings and try again. If the problem persists, ' + 'check your internet connection or try a different backup method.'));
|
|
848
828
|
}
|
|
849
829
|
}, timeoutMs);
|
|
@@ -859,7 +839,6 @@ const ensureICloudAuth = async (onSignInRequired, onSignInComplete, onAuthStatus
|
|
|
859
839
|
};
|
|
860
840
|
/**
|
|
861
841
|
* Save backup data to iCloud with retry logic
|
|
862
|
-
* Stores data in the same format as Google Drive for consistency
|
|
863
842
|
*/ const saveBackupToICloud = async (backupData, retryOptions)=>{
|
|
864
843
|
const { maxAttempts = 3, retryInterval = 1000 } = {};
|
|
865
844
|
return retryPromise(async ()=>{
|
|
@@ -868,16 +847,11 @@ const ensureICloudAuth = async (onSignInRequired, onSignInComplete, onAuthStatus
|
|
|
868
847
|
const record = {
|
|
869
848
|
recordType: BACKUP_RECORD_TYPE,
|
|
870
849
|
fields: {
|
|
871
|
-
// Store as JSON string to match Google Drive format
|
|
872
850
|
backupData: {
|
|
873
851
|
value: JSON.stringify(backupData)
|
|
874
|
-
},
|
|
875
|
-
timestamp: {
|
|
876
|
-
value: Date.now()
|
|
877
852
|
}
|
|
878
853
|
}
|
|
879
854
|
};
|
|
880
|
-
logger.debug('[iCloud] Saving backup record to CloudKit');
|
|
881
855
|
const response = await privateDB.saveRecords([
|
|
882
856
|
record
|
|
883
857
|
]);
|
|
@@ -887,9 +861,6 @@ const ensureICloudAuth = async (onSignInRequired, onSignInComplete, onAuthStatus
|
|
|
887
861
|
throw new Error(errorMessage);
|
|
888
862
|
}
|
|
889
863
|
const savedRecord = response.records[0];
|
|
890
|
-
logger.info('[iCloud] Backup saved successfully', {
|
|
891
|
-
recordName: savedRecord.recordName
|
|
892
|
-
});
|
|
893
864
|
return savedRecord;
|
|
894
865
|
}, {
|
|
895
866
|
maxAttempts,
|
|
@@ -904,12 +875,11 @@ const ensureICloudAuth = async (onSignInRequired, onSignInComplete, onAuthStatus
|
|
|
904
875
|
const container = CloudKit.getDefaultContainer();
|
|
905
876
|
const privateDB = container.privateCloudDatabase;
|
|
906
877
|
try {
|
|
907
|
-
logger.debug('[iCloud] Querying backup records');
|
|
908
878
|
const response = await privateDB.performQuery({
|
|
909
879
|
recordType: BACKUP_RECORD_TYPE,
|
|
910
880
|
sortBy: [
|
|
911
881
|
{
|
|
912
|
-
fieldName: '
|
|
882
|
+
fieldName: 'created',
|
|
913
883
|
ascending: false
|
|
914
884
|
}
|
|
915
885
|
]
|
|
@@ -931,9 +901,6 @@ const ensureICloudAuth = async (onSignInRequired, onSignInComplete, onAuthStatus
|
|
|
931
901
|
backupData: JSON.parse(fields.backupData.value)
|
|
932
902
|
};
|
|
933
903
|
});
|
|
934
|
-
logger.info('[iCloud] Found backups', {
|
|
935
|
-
count: records.length
|
|
936
|
-
});
|
|
937
904
|
return records;
|
|
938
905
|
} catch (error) {
|
|
939
906
|
logger.error('[iCloud] Failed to list backups:', error);
|
|
@@ -947,9 +914,6 @@ const ensureICloudAuth = async (onSignInRequired, onSignInComplete, onAuthStatus
|
|
|
947
914
|
const privateDB = container.privateCloudDatabase;
|
|
948
915
|
try {
|
|
949
916
|
var _fields_backupData;
|
|
950
|
-
logger.debug('[iCloud] Fetching backup record', {
|
|
951
|
-
recordName
|
|
952
|
-
});
|
|
953
917
|
const response = await privateDB.fetchRecords([
|
|
954
918
|
recordName
|
|
955
919
|
]);
|
|
@@ -959,9 +923,6 @@ const ensureICloudAuth = async (onSignInRequired, onSignInComplete, onAuthStatus
|
|
|
959
923
|
}
|
|
960
924
|
const record = response.records[0];
|
|
961
925
|
if (!record) {
|
|
962
|
-
logger.warn('[iCloud] Backup record not found', {
|
|
963
|
-
recordName
|
|
964
|
-
});
|
|
965
926
|
return null;
|
|
966
927
|
}
|
|
967
928
|
const fields = record.fields;
|
|
@@ -974,9 +935,6 @@ const ensureICloudAuth = async (onSignInRequired, onSignInComplete, onAuthStatus
|
|
|
974
935
|
modified: record.modified.timestamp,
|
|
975
936
|
backupData: JSON.parse(fields.backupData.value)
|
|
976
937
|
};
|
|
977
|
-
logger.info('[iCloud] Backup retrieved successfully', {
|
|
978
|
-
recordName
|
|
979
|
-
});
|
|
980
938
|
return backupRecord;
|
|
981
939
|
} catch (error) {
|
|
982
940
|
logger.error('[iCloud] Failed to get backup:', error);
|
|
@@ -989,9 +947,6 @@ const ensureICloudAuth = async (onSignInRequired, onSignInComplete, onAuthStatus
|
|
|
989
947
|
const container = CloudKit.getDefaultContainer();
|
|
990
948
|
const privateDB = container.privateCloudDatabase;
|
|
991
949
|
try {
|
|
992
|
-
logger.debug('[iCloud] Deleting backup record', {
|
|
993
|
-
recordName
|
|
994
|
-
});
|
|
995
950
|
const response = await privateDB.deleteRecords([
|
|
996
951
|
recordName
|
|
997
952
|
]);
|
|
@@ -999,16 +954,12 @@ const ensureICloudAuth = async (onSignInRequired, onSignInComplete, onAuthStatus
|
|
|
999
954
|
logger.error('[iCloud] Delete error:', response.errors);
|
|
1000
955
|
throw new Error(mapCloudKitError(response.errors[0]));
|
|
1001
956
|
}
|
|
1002
|
-
logger.info('[iCloud] Backup deleted successfully', {
|
|
1003
|
-
recordName
|
|
1004
|
-
});
|
|
1005
957
|
} catch (error) {
|
|
1006
958
|
logger.error('[iCloud] Failed to delete backup:', error);
|
|
1007
959
|
throw error;
|
|
1008
960
|
}
|
|
1009
961
|
};
|
|
1010
962
|
const initializeCloudKit = async (config, signInButtonId, onSignInRequired, onSignInComplete, onAuthStatusUpdate, authOptions)=>{
|
|
1011
|
-
logger.info('[iCloud] Initializing CloudKit');
|
|
1012
963
|
await loadCloudKit();
|
|
1013
964
|
if (signInButtonId) {
|
|
1014
965
|
resetCloudKitConfig();
|
package/index.esm.js
CHANGED
|
@@ -659,16 +659,6 @@ const downloadStringAsFile = ({ filename, content, mimeType = 'application/json'
|
|
|
659
659
|
URL.revokeObjectURL(url);
|
|
660
660
|
};
|
|
661
661
|
|
|
662
|
-
// CloudKit Web Services API token for public operations
|
|
663
|
-
// This token only allows access to the iCloud.KeyShareBackup container
|
|
664
|
-
// and is safe to include in client-side code
|
|
665
|
-
const DEFAULT_CONFIG = {
|
|
666
|
-
containerIdentifier: 'iCloud.KeyShareBackup',
|
|
667
|
-
// apiToken: '1221c5ccdf2ddb9abdb035befe7c197b07102972b30bbcbe363f6d722f3127a1', // prod
|
|
668
|
-
apiToken: '332a46c457183332f8d2a3d94d2ac87e9e9ae2af81d8a6d1ea89c27bb2fc0e97',
|
|
669
|
-
// environment: 'production',
|
|
670
|
-
environment: 'development'
|
|
671
|
-
};
|
|
672
662
|
const CLOUDKIT_CDN_URL = 'https://cdn.apple-cloudkit.com/ck/2/cloudkit.js';
|
|
673
663
|
const BACKUP_RECORD_TYPE = 'Backup';
|
|
674
664
|
let cloudKitLoaded = false;
|
|
@@ -704,7 +694,6 @@ const loadCloudKit = ()=>{
|
|
|
704
694
|
script.src = CLOUDKIT_CDN_URL;
|
|
705
695
|
script.onload = ()=>{
|
|
706
696
|
cloudKitLoaded = true;
|
|
707
|
-
logger.debug('[iCloud] CloudKit JS loaded successfully');
|
|
708
697
|
resolve();
|
|
709
698
|
};
|
|
710
699
|
script.onerror = (error)=>{
|
|
@@ -718,12 +707,14 @@ const configureCloudKit = (config, signInButtonId)=>{
|
|
|
718
707
|
if (cloudKitConfigured && currentSignInButtonId === signInButtonId) {
|
|
719
708
|
return;
|
|
720
709
|
}
|
|
721
|
-
|
|
710
|
+
if (!(config == null ? void 0 : config.containerIdentifier) || !(config == null ? void 0 : config.apiToken) || !(config == null ? void 0 : config.environment)) {
|
|
711
|
+
throw new Error('iCloud configuration is incomplete. Please configure iCloud settings in the dashboard.');
|
|
712
|
+
}
|
|
722
713
|
const containerConfig = {
|
|
723
|
-
containerIdentifier:
|
|
724
|
-
environment:
|
|
714
|
+
containerIdentifier: config.containerIdentifier,
|
|
715
|
+
environment: config.environment,
|
|
725
716
|
apiTokenAuth: {
|
|
726
|
-
apiToken:
|
|
717
|
+
apiToken: config.apiToken,
|
|
727
718
|
persist: true,
|
|
728
719
|
signInButton: signInButtonId ? {
|
|
729
720
|
id: signInButtonId,
|
|
@@ -738,15 +729,10 @@ const configureCloudKit = (config, signInButtonId)=>{
|
|
|
738
729
|
});
|
|
739
730
|
cloudKitConfigured = true;
|
|
740
731
|
currentSignInButtonId = signInButtonId || null;
|
|
741
|
-
logger.debug('[iCloud] CloudKit configured', {
|
|
742
|
-
containerIdentifier: mergedConfig.containerIdentifier,
|
|
743
|
-
environment: mergedConfig.environment
|
|
744
|
-
});
|
|
745
732
|
};
|
|
746
733
|
const resetCloudKitConfig = ()=>{
|
|
747
734
|
cloudKitConfigured = false;
|
|
748
735
|
currentSignInButtonId = null;
|
|
749
|
-
logger.debug('[iCloud] CloudKit config reset');
|
|
750
736
|
};
|
|
751
737
|
/**
|
|
752
738
|
* Check if user is already authenticated using fetchCurrentUserIdentity.
|
|
@@ -766,7 +752,6 @@ const resetCloudKitConfig = ()=>{
|
|
|
766
752
|
if (authenticationAbortController) {
|
|
767
753
|
authenticationAbortController.abort();
|
|
768
754
|
authenticationAbortController = null;
|
|
769
|
-
logger.info('[iCloud] Authentication cancelled by user');
|
|
770
755
|
}
|
|
771
756
|
};
|
|
772
757
|
const ensureICloudAuth = async (onSignInRequired, onSignInComplete, onAuthStatusUpdate, options)=>{
|
|
@@ -785,7 +770,6 @@ const ensureICloudAuth = async (onSignInRequired, onSignInComplete, onAuthStatus
|
|
|
785
770
|
// First, check if user is already authenticated (more reliable than setUpAuth)
|
|
786
771
|
const alreadyAuthenticated = await isUserAuthenticated(container);
|
|
787
772
|
if (alreadyAuthenticated) {
|
|
788
|
-
logger.info('[iCloud] User already authenticated');
|
|
789
773
|
onAuthStatusUpdate == null ? void 0 : onAuthStatusUpdate('Authenticated');
|
|
790
774
|
return;
|
|
791
775
|
}
|
|
@@ -794,12 +778,10 @@ const ensureICloudAuth = async (onSignInRequired, onSignInComplete, onAuthStatus
|
|
|
794
778
|
await container.setUpAuth();
|
|
795
779
|
// Double-check authentication after setUpAuth
|
|
796
780
|
if (await isUserAuthenticated(container)) {
|
|
797
|
-
logger.info('[iCloud] User authenticated after setUpAuth');
|
|
798
781
|
onAuthStatusUpdate == null ? void 0 : onAuthStatusUpdate('Authenticated');
|
|
799
782
|
return;
|
|
800
783
|
}
|
|
801
784
|
// User needs to sign in
|
|
802
|
-
logger.info('[iCloud] User authentication required');
|
|
803
785
|
onAuthStatusUpdate == null ? void 0 : onAuthStatusUpdate('Waiting for sign-in...');
|
|
804
786
|
if (onSignInRequired) ;
|
|
805
787
|
return new Promise((resolve, reject)=>{
|
|
@@ -830,7 +812,6 @@ const ensureICloudAuth = async (onSignInRequired, onSignInComplete, onAuthStatus
|
|
|
830
812
|
if (await isUserAuthenticated(container)) {
|
|
831
813
|
resolved = true;
|
|
832
814
|
cleanup();
|
|
833
|
-
logger.info('[iCloud] Authentication successful');
|
|
834
815
|
onAuthStatusUpdate == null ? void 0 : onAuthStatusUpdate('Authenticated');
|
|
835
816
|
if (onSignInComplete) ;
|
|
836
817
|
resolve();
|
|
@@ -844,7 +825,6 @@ const ensureICloudAuth = async (onSignInRequired, onSignInComplete, onAuthStatus
|
|
|
844
825
|
resolved = true;
|
|
845
826
|
cleanup();
|
|
846
827
|
if (onSignInComplete) ;
|
|
847
|
-
logger.warn('[iCloud] Authentication timed out');
|
|
848
828
|
reject(new Error('iCloud sign-in timed out. Please ensure you are signed into iCloud ' + 'in your browser settings and try again. If the problem persists, ' + 'check your internet connection or try a different backup method.'));
|
|
849
829
|
}
|
|
850
830
|
}, timeoutMs);
|
|
@@ -860,7 +840,6 @@ const ensureICloudAuth = async (onSignInRequired, onSignInComplete, onAuthStatus
|
|
|
860
840
|
};
|
|
861
841
|
/**
|
|
862
842
|
* Save backup data to iCloud with retry logic
|
|
863
|
-
* Stores data in the same format as Google Drive for consistency
|
|
864
843
|
*/ const saveBackupToICloud = async (backupData, retryOptions)=>{
|
|
865
844
|
const { maxAttempts = 3, retryInterval = 1000 } = {};
|
|
866
845
|
return retryPromise(async ()=>{
|
|
@@ -869,16 +848,11 @@ const ensureICloudAuth = async (onSignInRequired, onSignInComplete, onAuthStatus
|
|
|
869
848
|
const record = {
|
|
870
849
|
recordType: BACKUP_RECORD_TYPE,
|
|
871
850
|
fields: {
|
|
872
|
-
// Store as JSON string to match Google Drive format
|
|
873
851
|
backupData: {
|
|
874
852
|
value: JSON.stringify(backupData)
|
|
875
|
-
},
|
|
876
|
-
timestamp: {
|
|
877
|
-
value: Date.now()
|
|
878
853
|
}
|
|
879
854
|
}
|
|
880
855
|
};
|
|
881
|
-
logger.debug('[iCloud] Saving backup record to CloudKit');
|
|
882
856
|
const response = await privateDB.saveRecords([
|
|
883
857
|
record
|
|
884
858
|
]);
|
|
@@ -888,9 +862,6 @@ const ensureICloudAuth = async (onSignInRequired, onSignInComplete, onAuthStatus
|
|
|
888
862
|
throw new Error(errorMessage);
|
|
889
863
|
}
|
|
890
864
|
const savedRecord = response.records[0];
|
|
891
|
-
logger.info('[iCloud] Backup saved successfully', {
|
|
892
|
-
recordName: savedRecord.recordName
|
|
893
|
-
});
|
|
894
865
|
return savedRecord;
|
|
895
866
|
}, {
|
|
896
867
|
maxAttempts,
|
|
@@ -905,12 +876,11 @@ const ensureICloudAuth = async (onSignInRequired, onSignInComplete, onAuthStatus
|
|
|
905
876
|
const container = CloudKit.getDefaultContainer();
|
|
906
877
|
const privateDB = container.privateCloudDatabase;
|
|
907
878
|
try {
|
|
908
|
-
logger.debug('[iCloud] Querying backup records');
|
|
909
879
|
const response = await privateDB.performQuery({
|
|
910
880
|
recordType: BACKUP_RECORD_TYPE,
|
|
911
881
|
sortBy: [
|
|
912
882
|
{
|
|
913
|
-
fieldName: '
|
|
883
|
+
fieldName: 'created',
|
|
914
884
|
ascending: false
|
|
915
885
|
}
|
|
916
886
|
]
|
|
@@ -932,9 +902,6 @@ const ensureICloudAuth = async (onSignInRequired, onSignInComplete, onAuthStatus
|
|
|
932
902
|
backupData: JSON.parse(fields.backupData.value)
|
|
933
903
|
};
|
|
934
904
|
});
|
|
935
|
-
logger.info('[iCloud] Found backups', {
|
|
936
|
-
count: records.length
|
|
937
|
-
});
|
|
938
905
|
return records;
|
|
939
906
|
} catch (error) {
|
|
940
907
|
logger.error('[iCloud] Failed to list backups:', error);
|
|
@@ -948,9 +915,6 @@ const ensureICloudAuth = async (onSignInRequired, onSignInComplete, onAuthStatus
|
|
|
948
915
|
const privateDB = container.privateCloudDatabase;
|
|
949
916
|
try {
|
|
950
917
|
var _fields_backupData;
|
|
951
|
-
logger.debug('[iCloud] Fetching backup record', {
|
|
952
|
-
recordName
|
|
953
|
-
});
|
|
954
918
|
const response = await privateDB.fetchRecords([
|
|
955
919
|
recordName
|
|
956
920
|
]);
|
|
@@ -960,9 +924,6 @@ const ensureICloudAuth = async (onSignInRequired, onSignInComplete, onAuthStatus
|
|
|
960
924
|
}
|
|
961
925
|
const record = response.records[0];
|
|
962
926
|
if (!record) {
|
|
963
|
-
logger.warn('[iCloud] Backup record not found', {
|
|
964
|
-
recordName
|
|
965
|
-
});
|
|
966
927
|
return null;
|
|
967
928
|
}
|
|
968
929
|
const fields = record.fields;
|
|
@@ -975,9 +936,6 @@ const ensureICloudAuth = async (onSignInRequired, onSignInComplete, onAuthStatus
|
|
|
975
936
|
modified: record.modified.timestamp,
|
|
976
937
|
backupData: JSON.parse(fields.backupData.value)
|
|
977
938
|
};
|
|
978
|
-
logger.info('[iCloud] Backup retrieved successfully', {
|
|
979
|
-
recordName
|
|
980
|
-
});
|
|
981
939
|
return backupRecord;
|
|
982
940
|
} catch (error) {
|
|
983
941
|
logger.error('[iCloud] Failed to get backup:', error);
|
|
@@ -990,9 +948,6 @@ const ensureICloudAuth = async (onSignInRequired, onSignInComplete, onAuthStatus
|
|
|
990
948
|
const container = CloudKit.getDefaultContainer();
|
|
991
949
|
const privateDB = container.privateCloudDatabase;
|
|
992
950
|
try {
|
|
993
|
-
logger.debug('[iCloud] Deleting backup record', {
|
|
994
|
-
recordName
|
|
995
|
-
});
|
|
996
951
|
const response = await privateDB.deleteRecords([
|
|
997
952
|
recordName
|
|
998
953
|
]);
|
|
@@ -1000,16 +955,12 @@ const ensureICloudAuth = async (onSignInRequired, onSignInComplete, onAuthStatus
|
|
|
1000
955
|
logger.error('[iCloud] Delete error:', response.errors);
|
|
1001
956
|
throw new Error(mapCloudKitError(response.errors[0]));
|
|
1002
957
|
}
|
|
1003
|
-
logger.info('[iCloud] Backup deleted successfully', {
|
|
1004
|
-
recordName
|
|
1005
|
-
});
|
|
1006
958
|
} catch (error) {
|
|
1007
959
|
logger.error('[iCloud] Failed to delete backup:', error);
|
|
1008
960
|
throw error;
|
|
1009
961
|
}
|
|
1010
962
|
};
|
|
1011
963
|
const initializeCloudKit = async (config, signInButtonId, onSignInRequired, onSignInComplete, onAuthStatusUpdate, authOptions)=>{
|
|
1012
|
-
logger.info('[iCloud] Initializing CloudKit');
|
|
1013
964
|
await loadCloudKit();
|
|
1014
965
|
if (signInButtonId) {
|
|
1015
966
|
resetCloudKitConfig();
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs-wallet/browser",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.240",
|
|
4
4
|
"license": "Licensed under the Dynamic Labs, Inc. Terms Of Service (https://www.dynamic.xyz/terms-conditions)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@dynamic-labs-wallet/core": "0.0.
|
|
7
|
+
"@dynamic-labs-wallet/core": "0.0.240",
|
|
8
8
|
"@dynamic-labs/logger": "^4.25.3",
|
|
9
9
|
"@dynamic-labs/sdk-api-core": "^0.0.828",
|
|
10
10
|
"argon2id": "1.0.1",
|
|
@@ -22,7 +22,6 @@ export declare const cancelICloudAuth: () => void;
|
|
|
22
22
|
export declare const ensureICloudAuth: (onSignInRequired?: () => void, onSignInComplete?: () => void, onAuthStatusUpdate?: (status: string) => void, options?: ICloudAuthOptions) => Promise<void>;
|
|
23
23
|
/**
|
|
24
24
|
* Save backup data to iCloud with retry logic
|
|
25
|
-
* Stores data in the same format as Google Drive for consistency
|
|
26
25
|
*/
|
|
27
26
|
export declare const saveBackupToICloud: (backupData: unknown, retryOptions?: {
|
|
28
27
|
maxAttempts?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iCloud.d.ts","sourceRoot":"","sources":["../../../src/backup/providers/iCloud.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,KAAK,KAAK,aAAa,MAAM,oBAAoB,CAAC;AAIzD,MAAM,MAAM,WAAW,GAAG,aAAa,CAAC,cAAc,CAAC;AAEvD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,UAAU,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC;
|
|
1
|
+
{"version":3,"file":"iCloud.d.ts","sourceRoot":"","sources":["../../../src/backup/providers/iCloud.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,KAAK,KAAK,aAAa,MAAM,oBAAoB,CAAC;AAIzD,MAAM,MAAM,WAAW,GAAG,aAAa,CAAC,cAAc,CAAC;AAEvD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,UAAU,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC;AAsCF,eAAO,MAAM,YAAY,QAAO,OAAO,CAAC,IAAI,CAsB3C,CAAC;AAEF,eAAO,MAAM,iBAAiB,YACnB,YAAY,mBACJ,MAAM,KACtB,IAqCF,CAAC;AAEF,eAAO,MAAM,mBAAmB,QAAO,IAGtC,CAAC;AAkBF;;GAEG;AACH,eAAO,MAAM,gBAAgB,QAAO,IAKnC,CAAC;AAEF,eAAO,MAAM,gBAAgB,sBACR,MAAM,IAAI,qBACV,MAAM,IAAI,uBACR,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,YACnC,iBAAiB,KAC1B,OAAO,CAAC,IAAI,CAkHd,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,eACjB,OAAO,iBACJ;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,KAC9D,OAAO,CAAC,WAAW,CAkCrB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,QAAa,OAAO,CAAC,kBAAkB,EAAE,CAqCtE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,eACd,MAAM,KACjB,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAqCnC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,eAAsB,MAAM,KAAG,OAAO,CAAC,IAAI,CAezE,CAAC;AAEF,eAAO,MAAM,kBAAkB,YACpB,YAAY,mBACJ,MAAM,qBACJ,MAAM,IAAI,qBACV,MAAM,IAAI,uBACR,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,gBAC/B,iBAAiB,KAC9B,OAAO,CAAC,IAAI,CAcd,CAAC"}
|