@pooflabs/core 0.0.25 → 0.0.26
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/client/config.d.ts +1 -52
- package/dist/index.d.ts +1 -1
- package/dist/index.js +14 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/client/config.d.ts
CHANGED
|
@@ -1,35 +1,4 @@
|
|
|
1
1
|
import { AuthProvider } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Context passed to the redirect URL resolver function.
|
|
4
|
-
* Allows dynamic redirect URL selection based on the current environment.
|
|
5
|
-
*/
|
|
6
|
-
export interface RedirectUrlContext {
|
|
7
|
-
/** The current platform (best effort detection) */
|
|
8
|
-
platform: 'android' | 'ios' | 'web' | 'unknown';
|
|
9
|
-
/** The user agent string */
|
|
10
|
-
userAgent: string;
|
|
11
|
-
/** Whether this appears to be a WebView */
|
|
12
|
-
isWebView: boolean;
|
|
13
|
-
/** The current URL origin */
|
|
14
|
-
origin: string;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Redirect URL can be a static string or a function that returns a string.
|
|
18
|
-
* Using a function allows dynamic selection based on platform/environment.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* // Static string
|
|
22
|
-
* redirectUrl: 'seekerwheel://callback'
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* // Dynamic function
|
|
26
|
-
* redirectUrl: (context) => {
|
|
27
|
-
* if (context.platform === 'android') return 'seekerwheel://callback';
|
|
28
|
-
* if (context.platform === 'ios') return 'seekerwheel://callback';
|
|
29
|
-
* return context.origin; // web fallback
|
|
30
|
-
* }
|
|
31
|
-
*/
|
|
32
|
-
export type RedirectUrlResolver = string | ((context: RedirectUrlContext) => string);
|
|
33
2
|
export interface ClientConfig {
|
|
34
3
|
name: string;
|
|
35
4
|
logoUrl: string;
|
|
@@ -44,27 +13,6 @@ export interface ClientConfig {
|
|
|
44
13
|
skipBackendInit: boolean;
|
|
45
14
|
authProvider: AuthProvider | null;
|
|
46
15
|
isServer: boolean;
|
|
47
|
-
/**
|
|
48
|
-
* Custom redirect URL for OAuth flows.
|
|
49
|
-
* Can be a static string or a function that dynamically determines the URL based on platform.
|
|
50
|
-
* Required for Android/iOS apps with custom URI schemes (e.g., 'seekerwheel://callback').
|
|
51
|
-
* This tells the wallet/OAuth provider where to redirect after authentication.
|
|
52
|
-
* Works with both Privy and Phantom auth methods.
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* // Static - always use custom scheme
|
|
56
|
-
* redirectUrl: 'seekerwheel://callback'
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* // Dynamic - use custom scheme only on mobile
|
|
60
|
-
* redirectUrl: (context) => {
|
|
61
|
-
* if (context.platform === 'android' || context.platform === 'ios') {
|
|
62
|
-
* return 'seekerwheel://callback';
|
|
63
|
-
* }
|
|
64
|
-
* return context.origin; // web uses standard redirect
|
|
65
|
-
* }
|
|
66
|
-
*/
|
|
67
|
-
redirectUrl?: RedirectUrlResolver;
|
|
68
16
|
privyConfig?: {
|
|
69
17
|
appId: string;
|
|
70
18
|
config: any;
|
|
@@ -77,6 +25,7 @@ export interface ClientConfig {
|
|
|
77
25
|
theme?: 'light' | 'dark';
|
|
78
26
|
appName?: string;
|
|
79
27
|
appIcon?: string;
|
|
28
|
+
enablePrivyFallback?: boolean;
|
|
80
29
|
};
|
|
81
30
|
mockAuth?: boolean;
|
|
82
31
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { init } from './client/config';
|
|
2
|
-
export { getConfig, ClientConfig
|
|
2
|
+
export { getConfig, ClientConfig } from './client/config';
|
|
3
3
|
export { get, set, setMany, setFile, getFiles, runQuery, runQueryMany, runExpression, runExpressionMany, signMessage, signTransaction, signAndSubmitTransaction, SetOptions, RunExpressionOptions, RunExpressionResult } from './client/operations';
|
|
4
4
|
export { subscribe, closeAllSubscriptions, clearCache, getCachedData, reconnectWithNewAuth } from './client/subscription';
|
|
5
5
|
export * from './types';
|
package/dist/index.js
CHANGED
|
@@ -3633,23 +3633,31 @@ async function getFiles(path) {
|
|
|
3633
3633
|
async function setFile(path, file) {
|
|
3634
3634
|
var _a;
|
|
3635
3635
|
// 1) Get the presigned URL from your backend
|
|
3636
|
-
|
|
3637
|
-
const response = await makeApiRequest('POST', 'storage/url', {
|
|
3636
|
+
const requestBody = {
|
|
3638
3637
|
destinationPath: path,
|
|
3639
|
-
operation: file ? 'upload' : 'delete'
|
|
3640
|
-
}
|
|
3638
|
+
operation: file ? 'upload' : 'delete',
|
|
3639
|
+
};
|
|
3640
|
+
// Send file size so the server can enforce upload limits before issuing a presigned URL
|
|
3641
|
+
if (file) {
|
|
3642
|
+
requestBody.contentLength = file.size;
|
|
3643
|
+
}
|
|
3644
|
+
const response = await makeApiRequest('POST', 'storage/url', requestBody, undefined);
|
|
3641
3645
|
if (file == null) {
|
|
3642
3646
|
return true;
|
|
3643
3647
|
}
|
|
3644
3648
|
if (!((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.s3Url)) {
|
|
3645
3649
|
throw new Error("No s3Url in response");
|
|
3646
3650
|
}
|
|
3647
|
-
|
|
3651
|
+
// Client-side size guard using the limit returned by the server
|
|
3652
|
+
const maxFileSize = response.data.maxFileSize;
|
|
3653
|
+
if (maxFileSize && file.size > maxFileSize) {
|
|
3654
|
+
throw new Error(`File size ${(file.size / (1024 * 1024)).toFixed(2)} MB exceeds the maximum upload size of ${(maxFileSize / (1024 * 1024)).toFixed(0)} MB.`);
|
|
3655
|
+
}
|
|
3656
|
+
const presignedUrl = response.data.s3Url;
|
|
3648
3657
|
// 2) Upload the file directly to S3 with a PUT request
|
|
3649
3658
|
const uploadResponse = await fetch(presignedUrl, {
|
|
3650
3659
|
method: 'PUT',
|
|
3651
3660
|
headers: {
|
|
3652
|
-
// Use the file's actual content type so S3 knows how to serve it
|
|
3653
3661
|
'Content-Type': file.type,
|
|
3654
3662
|
},
|
|
3655
3663
|
body: file
|
|
@@ -3659,7 +3667,6 @@ async function setFile(path, file) {
|
|
|
3659
3667
|
await uploadResponse.text();
|
|
3660
3668
|
throw new Error(`Upload failed with status: ${uploadResponse.status}`);
|
|
3661
3669
|
}
|
|
3662
|
-
// Optionally return the file's public URL or some confirmation
|
|
3663
3670
|
return true;
|
|
3664
3671
|
}
|
|
3665
3672
|
async function signMessage(message) {
|