@reverbia/sdk 1.0.0-next.20260111131757 → 1.0.0-next.20260112105133
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/dist/expo/index.cjs +35 -130
- package/dist/expo/index.d.mts +1 -131
- package/dist/expo/index.d.ts +1 -131
- package/dist/expo/index.mjs +32 -126
- package/dist/index.cjs +12 -28
- package/dist/index.d.mts +54 -254
- package/dist/index.d.ts +54 -254
- package/dist/index.mjs +12 -26
- package/dist/react/index.cjs +81 -272
- package/dist/react/index.d.mts +1 -245
- package/dist/react/index.d.ts +1 -245
- package/dist/react/index.mjs +71 -260
- package/package.json +2 -2
package/dist/react/index.mjs
CHANGED
|
@@ -5081,32 +5081,12 @@ var postApiV1Embeddings = (options) => {
|
|
|
5081
5081
|
}
|
|
5082
5082
|
});
|
|
5083
5083
|
};
|
|
5084
|
-
var postApiV1ImagesGenerations = (options) => {
|
|
5085
|
-
return (options.client ?? client).post({
|
|
5086
|
-
url: "/api/v1/images/generations",
|
|
5087
|
-
...options,
|
|
5088
|
-
headers: {
|
|
5089
|
-
"Content-Type": "application/json",
|
|
5090
|
-
...options.headers
|
|
5091
|
-
}
|
|
5092
|
-
});
|
|
5093
|
-
};
|
|
5094
5084
|
var getApiV1Models = (options) => {
|
|
5095
5085
|
return (options?.client ?? client).get({
|
|
5096
5086
|
url: "/api/v1/models",
|
|
5097
5087
|
...options
|
|
5098
5088
|
});
|
|
5099
5089
|
};
|
|
5100
|
-
var postApiV1Search = (options) => {
|
|
5101
|
-
return (options.client ?? client).post({
|
|
5102
|
-
url: "/api/v1/search",
|
|
5103
|
-
...options,
|
|
5104
|
-
headers: {
|
|
5105
|
-
"Content-Type": "application/json",
|
|
5106
|
-
...options.headers
|
|
5107
|
-
}
|
|
5108
|
-
});
|
|
5109
|
-
};
|
|
5110
5090
|
var postAuthOauthByProviderExchange = (options) => {
|
|
5111
5091
|
return (options.client ?? client).post({
|
|
5112
5092
|
url: "/auth/oauth/{provider}/exchange",
|
|
@@ -5253,8 +5233,7 @@ function useMemoryStorage(options) {
|
|
|
5253
5233
|
content: [{ type: "text", text: m.content }]
|
|
5254
5234
|
}))
|
|
5255
5235
|
],
|
|
5256
|
-
model: model || completionsModel
|
|
5257
|
-
tool_choice: "none"
|
|
5236
|
+
model: model || completionsModel
|
|
5258
5237
|
},
|
|
5259
5238
|
headers: {
|
|
5260
5239
|
Authorization: `Bearer ${token}`
|
|
@@ -6579,172 +6558,6 @@ function useModels(options = {}) {
|
|
|
6579
6558
|
};
|
|
6580
6559
|
}
|
|
6581
6560
|
|
|
6582
|
-
// src/react/useSearch.ts
|
|
6583
|
-
import { useCallback as useCallback8, useEffect as useEffect5, useRef as useRef5, useState as useState8 } from "react";
|
|
6584
|
-
function useSearch(options = {}) {
|
|
6585
|
-
const { getToken, baseUrl = BASE_URL, onError } = options;
|
|
6586
|
-
const [isLoading, setIsLoading] = useState8(false);
|
|
6587
|
-
const [results, setResults] = useState8(null);
|
|
6588
|
-
const [response, setResponse] = useState8(null);
|
|
6589
|
-
const [error, setError] = useState8(null);
|
|
6590
|
-
const abortControllerRef = useRef5(null);
|
|
6591
|
-
useEffect5(() => {
|
|
6592
|
-
return () => {
|
|
6593
|
-
if (abortControllerRef.current) {
|
|
6594
|
-
abortControllerRef.current.abort();
|
|
6595
|
-
abortControllerRef.current = null;
|
|
6596
|
-
}
|
|
6597
|
-
};
|
|
6598
|
-
}, []);
|
|
6599
|
-
const search = useCallback8(
|
|
6600
|
-
async (query, searchOptions = {}) => {
|
|
6601
|
-
if (abortControllerRef.current) {
|
|
6602
|
-
abortControllerRef.current.abort();
|
|
6603
|
-
}
|
|
6604
|
-
const abortController = new AbortController();
|
|
6605
|
-
abortControllerRef.current = abortController;
|
|
6606
|
-
setIsLoading(true);
|
|
6607
|
-
setError(null);
|
|
6608
|
-
setResults(null);
|
|
6609
|
-
setResponse(null);
|
|
6610
|
-
try {
|
|
6611
|
-
let token;
|
|
6612
|
-
if (getToken) {
|
|
6613
|
-
token = await getToken() ?? void 0;
|
|
6614
|
-
}
|
|
6615
|
-
if (abortController.signal.aborted) return null;
|
|
6616
|
-
const queryArray = Array.isArray(query) ? query : [query];
|
|
6617
|
-
const res = await postApiV1Search({
|
|
6618
|
-
baseUrl,
|
|
6619
|
-
body: {
|
|
6620
|
-
query: queryArray,
|
|
6621
|
-
...searchOptions
|
|
6622
|
-
},
|
|
6623
|
-
headers: token ? {
|
|
6624
|
-
Authorization: `Bearer ${token}`
|
|
6625
|
-
} : void 0,
|
|
6626
|
-
signal: abortController.signal
|
|
6627
|
-
});
|
|
6628
|
-
if (res.error) {
|
|
6629
|
-
const errorMsg = res.error.error || res.error.message || "Failed to perform search";
|
|
6630
|
-
throw new Error(errorMsg);
|
|
6631
|
-
}
|
|
6632
|
-
if (res.data) {
|
|
6633
|
-
setResponse(res.data);
|
|
6634
|
-
setResults(res.data.results || []);
|
|
6635
|
-
return res.data;
|
|
6636
|
-
}
|
|
6637
|
-
return null;
|
|
6638
|
-
} catch (err) {
|
|
6639
|
-
if (err instanceof Error && err.name === "AbortError") {
|
|
6640
|
-
return null;
|
|
6641
|
-
}
|
|
6642
|
-
const errorObj = err instanceof Error ? err : new Error(String(err));
|
|
6643
|
-
setError(errorObj);
|
|
6644
|
-
if (onError) {
|
|
6645
|
-
onError(errorObj);
|
|
6646
|
-
}
|
|
6647
|
-
return null;
|
|
6648
|
-
} finally {
|
|
6649
|
-
if (abortControllerRef.current === abortController) {
|
|
6650
|
-
setIsLoading(false);
|
|
6651
|
-
abortControllerRef.current = null;
|
|
6652
|
-
}
|
|
6653
|
-
}
|
|
6654
|
-
},
|
|
6655
|
-
[baseUrl, getToken, onError]
|
|
6656
|
-
);
|
|
6657
|
-
return {
|
|
6658
|
-
isLoading,
|
|
6659
|
-
search,
|
|
6660
|
-
results,
|
|
6661
|
-
response,
|
|
6662
|
-
error
|
|
6663
|
-
};
|
|
6664
|
-
}
|
|
6665
|
-
|
|
6666
|
-
// src/react/useImageGeneration.ts
|
|
6667
|
-
import { useCallback as useCallback9, useEffect as useEffect6, useRef as useRef6, useState as useState9 } from "react";
|
|
6668
|
-
function useImageGeneration(options = {}) {
|
|
6669
|
-
const { getToken, baseUrl = BASE_URL, onFinish, onError } = options;
|
|
6670
|
-
const [isLoading, setIsLoading] = useState9(false);
|
|
6671
|
-
const abortControllerRef = useRef6(null);
|
|
6672
|
-
useEffect6(() => {
|
|
6673
|
-
return () => {
|
|
6674
|
-
if (abortControllerRef.current) {
|
|
6675
|
-
abortControllerRef.current.abort();
|
|
6676
|
-
abortControllerRef.current = null;
|
|
6677
|
-
}
|
|
6678
|
-
};
|
|
6679
|
-
}, []);
|
|
6680
|
-
const stop = useCallback9(() => {
|
|
6681
|
-
if (abortControllerRef.current) {
|
|
6682
|
-
abortControllerRef.current.abort();
|
|
6683
|
-
abortControllerRef.current = null;
|
|
6684
|
-
}
|
|
6685
|
-
}, []);
|
|
6686
|
-
const generateImage = useCallback9(
|
|
6687
|
-
async (args) => {
|
|
6688
|
-
if (abortControllerRef.current) {
|
|
6689
|
-
abortControllerRef.current.abort();
|
|
6690
|
-
}
|
|
6691
|
-
const abortController = new AbortController();
|
|
6692
|
-
abortControllerRef.current = abortController;
|
|
6693
|
-
setIsLoading(true);
|
|
6694
|
-
try {
|
|
6695
|
-
if (!getToken) {
|
|
6696
|
-
throw new Error("Token getter function is required.");
|
|
6697
|
-
}
|
|
6698
|
-
const token = await getToken();
|
|
6699
|
-
if (!token) {
|
|
6700
|
-
throw new Error("No access token available.");
|
|
6701
|
-
}
|
|
6702
|
-
const response = await postApiV1ImagesGenerations({
|
|
6703
|
-
baseUrl,
|
|
6704
|
-
body: args,
|
|
6705
|
-
headers: {
|
|
6706
|
-
Authorization: `Bearer ${token}`
|
|
6707
|
-
},
|
|
6708
|
-
signal: abortController.signal
|
|
6709
|
-
});
|
|
6710
|
-
if (response.error) {
|
|
6711
|
-
const errorMsg = response.error.error || "Failed to generate image";
|
|
6712
|
-
throw new Error(errorMsg);
|
|
6713
|
-
}
|
|
6714
|
-
if (!response.data) {
|
|
6715
|
-
throw new Error("No data received from image generation API");
|
|
6716
|
-
}
|
|
6717
|
-
const result = response.data;
|
|
6718
|
-
if (onFinish) {
|
|
6719
|
-
onFinish(result);
|
|
6720
|
-
}
|
|
6721
|
-
return { data: result, error: null };
|
|
6722
|
-
} catch (err) {
|
|
6723
|
-
if (err instanceof Error && err.name === "AbortError") {
|
|
6724
|
-
return { data: null, error: "Request aborted" };
|
|
6725
|
-
}
|
|
6726
|
-
const errorMsg = err instanceof Error ? err.message : "Failed to generate image.";
|
|
6727
|
-
const errorObj = err instanceof Error ? err : new Error(errorMsg);
|
|
6728
|
-
if (onError) {
|
|
6729
|
-
onError(errorObj);
|
|
6730
|
-
}
|
|
6731
|
-
return { data: null, error: errorMsg };
|
|
6732
|
-
} finally {
|
|
6733
|
-
if (abortControllerRef.current === abortController) {
|
|
6734
|
-
setIsLoading(false);
|
|
6735
|
-
abortControllerRef.current = null;
|
|
6736
|
-
}
|
|
6737
|
-
}
|
|
6738
|
-
},
|
|
6739
|
-
[getToken, baseUrl, onFinish, onError]
|
|
6740
|
-
);
|
|
6741
|
-
return {
|
|
6742
|
-
isLoading,
|
|
6743
|
-
generateImage,
|
|
6744
|
-
stop
|
|
6745
|
-
};
|
|
6746
|
-
}
|
|
6747
|
-
|
|
6748
6561
|
// src/lib/memory/chat.ts
|
|
6749
6562
|
var formatMemoriesForChat = (memories, format = "compact") => {
|
|
6750
6563
|
if (memories.length === 0) {
|
|
@@ -6801,7 +6614,7 @@ var extractConversationContext = (messages, maxMessages = 3) => {
|
|
|
6801
6614
|
};
|
|
6802
6615
|
|
|
6803
6616
|
// src/react/useDropboxBackup.ts
|
|
6804
|
-
import { useCallback as
|
|
6617
|
+
import { useCallback as useCallback9, useMemo as useMemo4 } from "react";
|
|
6805
6618
|
|
|
6806
6619
|
// src/lib/backup/dropbox/api.ts
|
|
6807
6620
|
var DROPBOX_API_URL = "https://api.dropboxapi.com/2";
|
|
@@ -7049,10 +6862,10 @@ async function performDropboxImport(userAddress, token, deps, onProgress, backup
|
|
|
7049
6862
|
import {
|
|
7050
6863
|
createContext,
|
|
7051
6864
|
createElement,
|
|
7052
|
-
useCallback as
|
|
6865
|
+
useCallback as useCallback8,
|
|
7053
6866
|
useContext,
|
|
7054
|
-
useEffect as
|
|
7055
|
-
useState as
|
|
6867
|
+
useEffect as useEffect5,
|
|
6868
|
+
useState as useState8
|
|
7056
6869
|
} from "react";
|
|
7057
6870
|
|
|
7058
6871
|
// src/lib/backup/oauth/storage.ts
|
|
@@ -7380,9 +7193,9 @@ function DropboxAuthProvider({
|
|
|
7380
7193
|
walletAddress,
|
|
7381
7194
|
children
|
|
7382
7195
|
}) {
|
|
7383
|
-
const [accessToken, setAccessToken] =
|
|
7196
|
+
const [accessToken, setAccessToken] = useState8(null);
|
|
7384
7197
|
const isConfigured = !!appKey;
|
|
7385
|
-
|
|
7198
|
+
useEffect5(() => {
|
|
7386
7199
|
const checkStoredToken = async () => {
|
|
7387
7200
|
if (walletAddress) {
|
|
7388
7201
|
await migrateUnencryptedTokens("dropbox", walletAddress);
|
|
@@ -7396,7 +7209,7 @@ function DropboxAuthProvider({
|
|
|
7396
7209
|
};
|
|
7397
7210
|
checkStoredToken();
|
|
7398
7211
|
}, [apiClient, walletAddress]);
|
|
7399
|
-
|
|
7212
|
+
useEffect5(() => {
|
|
7400
7213
|
if (!isConfigured) return;
|
|
7401
7214
|
const handleCallback = async () => {
|
|
7402
7215
|
if (isDropboxCallback()) {
|
|
@@ -7416,14 +7229,14 @@ function DropboxAuthProvider({
|
|
|
7416
7229
|
};
|
|
7417
7230
|
handleCallback();
|
|
7418
7231
|
}, [callbackPath, isConfigured, apiClient, walletAddress]);
|
|
7419
|
-
const refreshTokenFn =
|
|
7232
|
+
const refreshTokenFn = useCallback8(async () => {
|
|
7420
7233
|
const token = await getDropboxAccessToken(apiClient, walletAddress);
|
|
7421
7234
|
if (token) {
|
|
7422
7235
|
setAccessToken(token);
|
|
7423
7236
|
}
|
|
7424
7237
|
return token;
|
|
7425
7238
|
}, [apiClient, walletAddress]);
|
|
7426
|
-
const requestAccess =
|
|
7239
|
+
const requestAccess = useCallback8(async () => {
|
|
7427
7240
|
if (!isConfigured || !appKey) {
|
|
7428
7241
|
throw new Error("Dropbox is not configured");
|
|
7429
7242
|
}
|
|
@@ -7444,7 +7257,7 @@ function DropboxAuthProvider({
|
|
|
7444
7257
|
apiClient,
|
|
7445
7258
|
walletAddress
|
|
7446
7259
|
]);
|
|
7447
|
-
const logout =
|
|
7260
|
+
const logout = useCallback8(async () => {
|
|
7448
7261
|
await revokeDropboxToken(apiClient, walletAddress);
|
|
7449
7262
|
setAccessToken(null);
|
|
7450
7263
|
}, [apiClient, walletAddress]);
|
|
@@ -7495,7 +7308,7 @@ function useDropboxBackup(options) {
|
|
|
7495
7308
|
}),
|
|
7496
7309
|
[requestDropboxAccess, requestEncryptionKey2, exportConversation, importConversation]
|
|
7497
7310
|
);
|
|
7498
|
-
const ensureToken =
|
|
7311
|
+
const ensureToken = useCallback9(async () => {
|
|
7499
7312
|
if (dropboxToken) return dropboxToken;
|
|
7500
7313
|
try {
|
|
7501
7314
|
return await requestDropboxAccess();
|
|
@@ -7503,7 +7316,7 @@ function useDropboxBackup(options) {
|
|
|
7503
7316
|
return null;
|
|
7504
7317
|
}
|
|
7505
7318
|
}, [dropboxToken, requestDropboxAccess]);
|
|
7506
|
-
const backup =
|
|
7319
|
+
const backup = useCallback9(
|
|
7507
7320
|
async (backupOptions) => {
|
|
7508
7321
|
if (!userAddress) {
|
|
7509
7322
|
return { error: "Please sign in to backup to Dropbox" };
|
|
@@ -7529,7 +7342,7 @@ function useDropboxBackup(options) {
|
|
|
7529
7342
|
},
|
|
7530
7343
|
[database, userAddress, ensureToken, deps, backupFolder]
|
|
7531
7344
|
);
|
|
7532
|
-
const restore =
|
|
7345
|
+
const restore = useCallback9(
|
|
7533
7346
|
async (restoreOptions) => {
|
|
7534
7347
|
if (!userAddress) {
|
|
7535
7348
|
return { error: "Please sign in to restore from Dropbox" };
|
|
@@ -7566,10 +7379,10 @@ function useDropboxBackup(options) {
|
|
|
7566
7379
|
import {
|
|
7567
7380
|
createContext as createContext2,
|
|
7568
7381
|
createElement as createElement2,
|
|
7569
|
-
useCallback as
|
|
7382
|
+
useCallback as useCallback10,
|
|
7570
7383
|
useContext as useContext2,
|
|
7571
|
-
useEffect as
|
|
7572
|
-
useState as
|
|
7384
|
+
useEffect as useEffect6,
|
|
7385
|
+
useState as useState9
|
|
7573
7386
|
} from "react";
|
|
7574
7387
|
|
|
7575
7388
|
// src/lib/backup/google/auth.ts
|
|
@@ -7800,9 +7613,9 @@ function GoogleDriveAuthProvider({
|
|
|
7800
7613
|
walletAddress,
|
|
7801
7614
|
children
|
|
7802
7615
|
}) {
|
|
7803
|
-
const [accessToken, setAccessToken] =
|
|
7616
|
+
const [accessToken, setAccessToken] = useState9(null);
|
|
7804
7617
|
const isConfigured = !!clientId;
|
|
7805
|
-
|
|
7618
|
+
useEffect6(() => {
|
|
7806
7619
|
const checkStoredToken = async () => {
|
|
7807
7620
|
if (walletAddress) {
|
|
7808
7621
|
await migrateUnencryptedTokens("google-drive", walletAddress);
|
|
@@ -7816,7 +7629,7 @@ function GoogleDriveAuthProvider({
|
|
|
7816
7629
|
};
|
|
7817
7630
|
checkStoredToken();
|
|
7818
7631
|
}, [apiClient, walletAddress]);
|
|
7819
|
-
|
|
7632
|
+
useEffect6(() => {
|
|
7820
7633
|
if (!isConfigured) return;
|
|
7821
7634
|
const handleCallback = async () => {
|
|
7822
7635
|
if (isGoogleDriveCallback()) {
|
|
@@ -7836,14 +7649,14 @@ function GoogleDriveAuthProvider({
|
|
|
7836
7649
|
};
|
|
7837
7650
|
handleCallback();
|
|
7838
7651
|
}, [callbackPath, isConfigured, apiClient, walletAddress]);
|
|
7839
|
-
const refreshTokenFn =
|
|
7652
|
+
const refreshTokenFn = useCallback10(async () => {
|
|
7840
7653
|
const token = await getGoogleDriveAccessToken(apiClient, walletAddress);
|
|
7841
7654
|
if (token) {
|
|
7842
7655
|
setAccessToken(token);
|
|
7843
7656
|
}
|
|
7844
7657
|
return token;
|
|
7845
7658
|
}, [apiClient, walletAddress]);
|
|
7846
|
-
const requestAccess =
|
|
7659
|
+
const requestAccess = useCallback10(async () => {
|
|
7847
7660
|
if (!isConfigured || !clientId) {
|
|
7848
7661
|
throw new Error("Google Drive is not configured");
|
|
7849
7662
|
}
|
|
@@ -7867,7 +7680,7 @@ function GoogleDriveAuthProvider({
|
|
|
7867
7680
|
apiClient,
|
|
7868
7681
|
walletAddress
|
|
7869
7682
|
]);
|
|
7870
|
-
const logout =
|
|
7683
|
+
const logout = useCallback10(async () => {
|
|
7871
7684
|
await revokeGoogleDriveToken(apiClient, walletAddress);
|
|
7872
7685
|
setAccessToken(null);
|
|
7873
7686
|
}, [apiClient, walletAddress]);
|
|
@@ -7897,7 +7710,7 @@ function useGoogleDriveAuth() {
|
|
|
7897
7710
|
}
|
|
7898
7711
|
|
|
7899
7712
|
// src/react/useGoogleDriveBackup.ts
|
|
7900
|
-
import { useCallback as
|
|
7713
|
+
import { useCallback as useCallback11, useMemo as useMemo5 } from "react";
|
|
7901
7714
|
|
|
7902
7715
|
// src/lib/backup/google/api.ts
|
|
7903
7716
|
var DRIVE_API_URL = "https://www.googleapis.com/drive/v3";
|
|
@@ -8224,7 +8037,7 @@ function useGoogleDriveBackup(options) {
|
|
|
8224
8037
|
}),
|
|
8225
8038
|
[requestDriveAccess, requestEncryptionKey2, exportConversation, importConversation]
|
|
8226
8039
|
);
|
|
8227
|
-
const ensureToken =
|
|
8040
|
+
const ensureToken = useCallback11(async () => {
|
|
8228
8041
|
if (driveToken) return driveToken;
|
|
8229
8042
|
try {
|
|
8230
8043
|
return await requestDriveAccess();
|
|
@@ -8232,7 +8045,7 @@ function useGoogleDriveBackup(options) {
|
|
|
8232
8045
|
return null;
|
|
8233
8046
|
}
|
|
8234
8047
|
}, [driveToken, requestDriveAccess]);
|
|
8235
|
-
const backup =
|
|
8048
|
+
const backup = useCallback11(
|
|
8236
8049
|
async (backupOptions) => {
|
|
8237
8050
|
if (!userAddress) {
|
|
8238
8051
|
return { error: "Please sign in to backup to Google Drive" };
|
|
@@ -8259,7 +8072,7 @@ function useGoogleDriveBackup(options) {
|
|
|
8259
8072
|
},
|
|
8260
8073
|
[database, userAddress, ensureToken, deps, rootFolder, conversationsFolder]
|
|
8261
8074
|
);
|
|
8262
|
-
const restore =
|
|
8075
|
+
const restore = useCallback11(
|
|
8263
8076
|
async (restoreOptions) => {
|
|
8264
8077
|
if (!userAddress) {
|
|
8265
8078
|
return { error: "Please sign in to restore from Google Drive" };
|
|
@@ -8297,10 +8110,10 @@ function useGoogleDriveBackup(options) {
|
|
|
8297
8110
|
import {
|
|
8298
8111
|
createContext as createContext3,
|
|
8299
8112
|
createElement as createElement3,
|
|
8300
|
-
useCallback as
|
|
8113
|
+
useCallback as useCallback12,
|
|
8301
8114
|
useContext as useContext3,
|
|
8302
|
-
useEffect as
|
|
8303
|
-
useState as
|
|
8115
|
+
useEffect as useEffect7,
|
|
8116
|
+
useState as useState10
|
|
8304
8117
|
} from "react";
|
|
8305
8118
|
|
|
8306
8119
|
// src/lib/backup/icloud/api.ts
|
|
@@ -8544,12 +8357,12 @@ function ICloudAuthProvider({
|
|
|
8544
8357
|
environment = "production",
|
|
8545
8358
|
children
|
|
8546
8359
|
}) {
|
|
8547
|
-
const [isAuthenticated, setIsAuthenticated] =
|
|
8548
|
-
const [userRecordName, setUserRecordName] =
|
|
8549
|
-
const [isAvailable, setIsAvailable] =
|
|
8550
|
-
const [isConfigured, setIsConfigured] =
|
|
8551
|
-
const [isLoading, setIsLoading] =
|
|
8552
|
-
|
|
8360
|
+
const [isAuthenticated, setIsAuthenticated] = useState10(false);
|
|
8361
|
+
const [userRecordName, setUserRecordName] = useState10(null);
|
|
8362
|
+
const [isAvailable, setIsAvailable] = useState10(false);
|
|
8363
|
+
const [isConfigured, setIsConfigured] = useState10(false);
|
|
8364
|
+
const [isLoading, setIsLoading] = useState10(false);
|
|
8365
|
+
useEffect7(() => {
|
|
8553
8366
|
if (!apiToken || typeof window === "undefined") {
|
|
8554
8367
|
return;
|
|
8555
8368
|
}
|
|
@@ -8582,7 +8395,7 @@ function ICloudAuthProvider({
|
|
|
8582
8395
|
};
|
|
8583
8396
|
initCloudKit();
|
|
8584
8397
|
}, [apiToken, containerIdentifier, environment]);
|
|
8585
|
-
const requestAccess =
|
|
8398
|
+
const requestAccess = useCallback12(async () => {
|
|
8586
8399
|
if (!isConfigured) {
|
|
8587
8400
|
throw new Error("iCloud is not configured");
|
|
8588
8401
|
}
|
|
@@ -8599,7 +8412,7 @@ function ICloudAuthProvider({
|
|
|
8599
8412
|
);
|
|
8600
8413
|
}
|
|
8601
8414
|
}, [isAuthenticated, isConfigured]);
|
|
8602
|
-
const logout =
|
|
8415
|
+
const logout = useCallback12(() => {
|
|
8603
8416
|
setIsAuthenticated(false);
|
|
8604
8417
|
setUserRecordName(null);
|
|
8605
8418
|
}, []);
|
|
@@ -8632,7 +8445,7 @@ function clearICloudAuth() {
|
|
|
8632
8445
|
}
|
|
8633
8446
|
|
|
8634
8447
|
// src/react/useICloudBackup.ts
|
|
8635
|
-
import { useCallback as
|
|
8448
|
+
import { useCallback as useCallback13, useMemo as useMemo6 } from "react";
|
|
8636
8449
|
|
|
8637
8450
|
// src/lib/backup/icloud/backup.ts
|
|
8638
8451
|
var isAuthError3 = (err) => err instanceof Error && (err.message.includes("AUTHENTICATION") || err.message.includes("NOT_AUTHENTICATED") || err.message.includes("sign in"));
|
|
@@ -8782,7 +8595,7 @@ function useICloudBackup(options) {
|
|
|
8782
8595
|
}),
|
|
8783
8596
|
[requestAccess, requestEncryptionKey2, exportConversation, importConversation]
|
|
8784
8597
|
);
|
|
8785
|
-
const ensureAuthenticated =
|
|
8598
|
+
const ensureAuthenticated = useCallback13(async () => {
|
|
8786
8599
|
if (isAuthenticated) return true;
|
|
8787
8600
|
try {
|
|
8788
8601
|
await requestAccess();
|
|
@@ -8791,7 +8604,7 @@ function useICloudBackup(options) {
|
|
|
8791
8604
|
return false;
|
|
8792
8605
|
}
|
|
8793
8606
|
}, [isAuthenticated, requestAccess]);
|
|
8794
|
-
const backup =
|
|
8607
|
+
const backup = useCallback13(
|
|
8795
8608
|
async (backupOptions) => {
|
|
8796
8609
|
if (!userAddress) {
|
|
8797
8610
|
return { error: "Please sign in to backup to iCloud" };
|
|
@@ -8821,7 +8634,7 @@ function useICloudBackup(options) {
|
|
|
8821
8634
|
},
|
|
8822
8635
|
[database, userAddress, isAvailable, isConfigured, ensureAuthenticated, deps]
|
|
8823
8636
|
);
|
|
8824
|
-
const restore =
|
|
8637
|
+
const restore = useCallback13(
|
|
8825
8638
|
async (restoreOptions) => {
|
|
8826
8639
|
if (!userAddress) {
|
|
8827
8640
|
return { error: "Please sign in to restore from iCloud" };
|
|
@@ -8863,10 +8676,10 @@ function useICloudBackup(options) {
|
|
|
8863
8676
|
import {
|
|
8864
8677
|
createContext as createContext4,
|
|
8865
8678
|
createElement as createElement4,
|
|
8866
|
-
useCallback as
|
|
8679
|
+
useCallback as useCallback14,
|
|
8867
8680
|
useContext as useContext4,
|
|
8868
|
-
useEffect as
|
|
8869
|
-
useState as
|
|
8681
|
+
useEffect as useEffect8,
|
|
8682
|
+
useState as useState11
|
|
8870
8683
|
} from "react";
|
|
8871
8684
|
var BackupAuthContext = createContext4(null);
|
|
8872
8685
|
function BackupAuthProvider({
|
|
@@ -8881,15 +8694,15 @@ function BackupAuthProvider({
|
|
|
8881
8694
|
walletAddress,
|
|
8882
8695
|
children
|
|
8883
8696
|
}) {
|
|
8884
|
-
const [dropboxToken, setDropboxToken] =
|
|
8697
|
+
const [dropboxToken, setDropboxToken] = useState11(null);
|
|
8885
8698
|
const isDropboxConfigured = !!dropboxAppKey;
|
|
8886
|
-
const [googleToken, setGoogleToken] =
|
|
8699
|
+
const [googleToken, setGoogleToken] = useState11(null);
|
|
8887
8700
|
const isGoogleConfigured = !!googleClientId;
|
|
8888
|
-
const [icloudAuthenticated, setIcloudAuthenticated] =
|
|
8889
|
-
const [icloudUserRecordName, setIcloudUserRecordName] =
|
|
8890
|
-
const [isIcloudAvailable, setIsIcloudAvailable] =
|
|
8701
|
+
const [icloudAuthenticated, setIcloudAuthenticated] = useState11(false);
|
|
8702
|
+
const [icloudUserRecordName, setIcloudUserRecordName] = useState11(null);
|
|
8703
|
+
const [isIcloudAvailable, setIsIcloudAvailable] = useState11(false);
|
|
8891
8704
|
const isIcloudConfigured = isIcloudAvailable && !!icloudApiToken;
|
|
8892
|
-
|
|
8705
|
+
useEffect8(() => {
|
|
8893
8706
|
const checkStoredTokens = async () => {
|
|
8894
8707
|
if (walletAddress) {
|
|
8895
8708
|
await Promise.all([
|
|
@@ -8912,7 +8725,7 @@ function BackupAuthProvider({
|
|
|
8912
8725
|
};
|
|
8913
8726
|
checkStoredTokens();
|
|
8914
8727
|
}, [apiClient, walletAddress]);
|
|
8915
|
-
|
|
8728
|
+
useEffect8(() => {
|
|
8916
8729
|
if (!icloudApiToken || typeof window === "undefined") {
|
|
8917
8730
|
return;
|
|
8918
8731
|
}
|
|
@@ -8940,7 +8753,7 @@ function BackupAuthProvider({
|
|
|
8940
8753
|
};
|
|
8941
8754
|
initCloudKit();
|
|
8942
8755
|
}, [icloudApiToken, icloudContainerIdentifier, icloudEnvironment]);
|
|
8943
|
-
|
|
8756
|
+
useEffect8(() => {
|
|
8944
8757
|
if (!isDropboxConfigured) return;
|
|
8945
8758
|
const handleCallback = async () => {
|
|
8946
8759
|
if (isDropboxCallback()) {
|
|
@@ -8960,7 +8773,7 @@ function BackupAuthProvider({
|
|
|
8960
8773
|
};
|
|
8961
8774
|
handleCallback();
|
|
8962
8775
|
}, [dropboxCallbackPath, isDropboxConfigured, apiClient, walletAddress]);
|
|
8963
|
-
|
|
8776
|
+
useEffect8(() => {
|
|
8964
8777
|
if (!isGoogleConfigured) return;
|
|
8965
8778
|
const handleCallback = async () => {
|
|
8966
8779
|
if (isGoogleDriveCallback()) {
|
|
@@ -8980,14 +8793,14 @@ function BackupAuthProvider({
|
|
|
8980
8793
|
};
|
|
8981
8794
|
handleCallback();
|
|
8982
8795
|
}, [googleCallbackPath, isGoogleConfigured, apiClient, walletAddress]);
|
|
8983
|
-
const refreshDropboxTokenFn =
|
|
8796
|
+
const refreshDropboxTokenFn = useCallback14(async () => {
|
|
8984
8797
|
const token = await getDropboxAccessToken(apiClient, walletAddress);
|
|
8985
8798
|
if (token) {
|
|
8986
8799
|
setDropboxToken(token);
|
|
8987
8800
|
}
|
|
8988
8801
|
return token;
|
|
8989
8802
|
}, [apiClient, walletAddress]);
|
|
8990
|
-
const requestDropboxAccess =
|
|
8803
|
+
const requestDropboxAccess = useCallback14(async () => {
|
|
8991
8804
|
if (!isDropboxConfigured || !dropboxAppKey) {
|
|
8992
8805
|
throw new Error("Dropbox is not configured");
|
|
8993
8806
|
}
|
|
@@ -9004,18 +8817,18 @@ function BackupAuthProvider({
|
|
|
9004
8817
|
apiClient,
|
|
9005
8818
|
walletAddress
|
|
9006
8819
|
]);
|
|
9007
|
-
const logoutDropbox =
|
|
8820
|
+
const logoutDropbox = useCallback14(async () => {
|
|
9008
8821
|
await revokeDropboxToken(apiClient, walletAddress);
|
|
9009
8822
|
setDropboxToken(null);
|
|
9010
8823
|
}, [apiClient, walletAddress]);
|
|
9011
|
-
const refreshGoogleTokenFn =
|
|
8824
|
+
const refreshGoogleTokenFn = useCallback14(async () => {
|
|
9012
8825
|
const token = await getGoogleDriveAccessToken(apiClient, walletAddress);
|
|
9013
8826
|
if (token) {
|
|
9014
8827
|
setGoogleToken(token);
|
|
9015
8828
|
}
|
|
9016
8829
|
return token;
|
|
9017
8830
|
}, [apiClient, walletAddress]);
|
|
9018
|
-
const requestGoogleAccess =
|
|
8831
|
+
const requestGoogleAccess = useCallback14(async () => {
|
|
9019
8832
|
if (!isGoogleConfigured || !googleClientId) {
|
|
9020
8833
|
throw new Error("Google Drive is not configured");
|
|
9021
8834
|
}
|
|
@@ -9035,11 +8848,11 @@ function BackupAuthProvider({
|
|
|
9035
8848
|
apiClient,
|
|
9036
8849
|
walletAddress
|
|
9037
8850
|
]);
|
|
9038
|
-
const logoutGoogle =
|
|
8851
|
+
const logoutGoogle = useCallback14(async () => {
|
|
9039
8852
|
await revokeGoogleDriveToken(apiClient, walletAddress);
|
|
9040
8853
|
setGoogleToken(null);
|
|
9041
8854
|
}, [apiClient, walletAddress]);
|
|
9042
|
-
const refreshIcloudTokenFn =
|
|
8855
|
+
const refreshIcloudTokenFn = useCallback14(async () => {
|
|
9043
8856
|
try {
|
|
9044
8857
|
const userIdentity = await authenticateICloud();
|
|
9045
8858
|
if (userIdentity) {
|
|
@@ -9051,7 +8864,7 @@ function BackupAuthProvider({
|
|
|
9051
8864
|
}
|
|
9052
8865
|
return null;
|
|
9053
8866
|
}, []);
|
|
9054
|
-
const requestIcloudAccess =
|
|
8867
|
+
const requestIcloudAccess = useCallback14(async () => {
|
|
9055
8868
|
if (!isIcloudConfigured) {
|
|
9056
8869
|
throw new Error("iCloud is not configured");
|
|
9057
8870
|
}
|
|
@@ -9069,11 +8882,11 @@ function BackupAuthProvider({
|
|
|
9069
8882
|
);
|
|
9070
8883
|
}
|
|
9071
8884
|
}, [icloudAuthenticated, icloudUserRecordName, isIcloudConfigured]);
|
|
9072
|
-
const logoutIcloud =
|
|
8885
|
+
const logoutIcloud = useCallback14(async () => {
|
|
9073
8886
|
setIcloudAuthenticated(false);
|
|
9074
8887
|
setIcloudUserRecordName(null);
|
|
9075
8888
|
}, []);
|
|
9076
|
-
const logoutAll =
|
|
8889
|
+
const logoutAll = useCallback14(async () => {
|
|
9077
8890
|
await Promise.all([
|
|
9078
8891
|
isDropboxConfigured ? logoutDropbox() : Promise.resolve(),
|
|
9079
8892
|
isGoogleConfigured ? logoutGoogle() : Promise.resolve(),
|
|
@@ -9136,7 +8949,7 @@ function useBackupAuth() {
|
|
|
9136
8949
|
}
|
|
9137
8950
|
|
|
9138
8951
|
// src/react/useBackup.ts
|
|
9139
|
-
import { useCallback as
|
|
8952
|
+
import { useCallback as useCallback15, useMemo as useMemo7 } from "react";
|
|
9140
8953
|
function useBackup(options) {
|
|
9141
8954
|
const {
|
|
9142
8955
|
database,
|
|
@@ -9185,7 +8998,7 @@ function useBackup(options) {
|
|
|
9185
8998
|
}),
|
|
9186
8999
|
[icloudAuth.requestAccess, requestEncryptionKey2, exportConversation, importConversation]
|
|
9187
9000
|
);
|
|
9188
|
-
const dropboxBackup =
|
|
9001
|
+
const dropboxBackup = useCallback15(
|
|
9189
9002
|
async (backupOptions) => {
|
|
9190
9003
|
if (!userAddress) {
|
|
9191
9004
|
return { error: "Please sign in to backup to Dropbox" };
|
|
@@ -9213,7 +9026,7 @@ function useBackup(options) {
|
|
|
9213
9026
|
},
|
|
9214
9027
|
[database, userAddress, dropboxAuth, dropboxDeps, dropboxFolder]
|
|
9215
9028
|
);
|
|
9216
|
-
const dropboxRestore =
|
|
9029
|
+
const dropboxRestore = useCallback15(
|
|
9217
9030
|
async (restoreOptions) => {
|
|
9218
9031
|
if (!userAddress) {
|
|
9219
9032
|
return { error: "Please sign in to restore from Dropbox" };
|
|
@@ -9240,7 +9053,7 @@ function useBackup(options) {
|
|
|
9240
9053
|
},
|
|
9241
9054
|
[userAddress, dropboxAuth, dropboxDeps, dropboxFolder]
|
|
9242
9055
|
);
|
|
9243
|
-
const googleDriveBackup =
|
|
9056
|
+
const googleDriveBackup = useCallback15(
|
|
9244
9057
|
async (backupOptions) => {
|
|
9245
9058
|
if (!userAddress) {
|
|
9246
9059
|
return { error: "Please sign in to backup to Google Drive" };
|
|
@@ -9276,7 +9089,7 @@ function useBackup(options) {
|
|
|
9276
9089
|
googleConversationsFolder
|
|
9277
9090
|
]
|
|
9278
9091
|
);
|
|
9279
|
-
const googleDriveRestore =
|
|
9092
|
+
const googleDriveRestore = useCallback15(
|
|
9280
9093
|
async (restoreOptions) => {
|
|
9281
9094
|
if (!userAddress) {
|
|
9282
9095
|
return { error: "Please sign in to restore from Google Drive" };
|
|
@@ -9326,7 +9139,7 @@ function useBackup(options) {
|
|
|
9326
9139
|
connect: googleDriveAuth.requestAccess,
|
|
9327
9140
|
disconnect: googleDriveAuth.logout
|
|
9328
9141
|
};
|
|
9329
|
-
const icloudBackup =
|
|
9142
|
+
const icloudBackup = useCallback15(
|
|
9330
9143
|
async (backupOptions) => {
|
|
9331
9144
|
if (!userAddress) {
|
|
9332
9145
|
return { error: "Please sign in to backup to iCloud" };
|
|
@@ -9356,7 +9169,7 @@ function useBackup(options) {
|
|
|
9356
9169
|
},
|
|
9357
9170
|
[database, userAddress, icloudAuth, icloudDeps]
|
|
9358
9171
|
);
|
|
9359
|
-
const icloudRestore =
|
|
9172
|
+
const icloudRestore = useCallback15(
|
|
9360
9173
|
async (restoreOptions) => {
|
|
9361
9174
|
if (!userAddress) {
|
|
9362
9175
|
return { error: "Please sign in to restore from iCloud" };
|
|
@@ -9982,12 +9795,10 @@ export {
|
|
|
9982
9795
|
useGoogleDriveBackup,
|
|
9983
9796
|
useICloudAuth,
|
|
9984
9797
|
useICloudBackup,
|
|
9985
|
-
useImageGeneration,
|
|
9986
9798
|
useMemoryStorage,
|
|
9987
9799
|
useModels,
|
|
9988
9800
|
useOCR,
|
|
9989
9801
|
usePdf,
|
|
9990
|
-
useSearch,
|
|
9991
9802
|
useSettings,
|
|
9992
9803
|
userPreferencesStorageSchema,
|
|
9993
9804
|
writeEncryptedFile
|