@aippy/runtime 0.2.7-dev.2 โ 0.2.7-dev.4
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/ai/errors.d.ts +37 -0
- package/dist/ai/index.js +2 -2
- package/dist/ai/shared/fetch.d.ts +6 -0
- package/dist/bridge-Ca3H2iN1.js +197 -0
- package/dist/core/index.js +1 -1
- package/dist/helper-CIt1_T-j.js +275 -0
- package/dist/hooks-CE9cjXHP.js +46 -0
- package/dist/index/index.js +82 -111
- package/dist/{ui-D6IZ1jrR.js โ ui-y5N62DqC.js} +81 -25
- package/dist/user/bridge.d.ts +10 -141
- package/dist/user/config.d.ts +8 -17
- package/dist/user/hooks.d.ts +3 -65
- package/dist/user/index.d.ts +3 -9
- package/dist/user/index.js +7 -36
- package/dist/user/types.d.ts +2 -105
- package/dist/utils/index.js +11 -9
- package/dist/utils/platform.d.ts +42 -1
- package/package.json +1 -1
- package/dist/bridge-N9ELFpfV.js +0 -430
- package/dist/helper-CsFko67T.js +0 -264
- package/dist/user/api.d.ts +0 -9
- package/dist/user/userSessionInfo.d.ts +0 -6
- package/dist/userSessionInfo-DFvsuELU.js +0 -229
package/dist/user/index.js
CHANGED
|
@@ -1,38 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { c as o, u as s } from "../hooks-CE9cjXHP.js";
|
|
2
|
+
import { getAuthTokenAsync as f } from "../bridge-Ca3H2iN1.js";
|
|
3
|
+
import { i as t } from "../ui-y5N62DqC.js";
|
|
3
4
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
p as fetchUserProfile,
|
|
9
|
-
t as getAuthToken,
|
|
10
|
-
n as getAuthTokenAsync,
|
|
11
|
-
o as getCachedCredentials,
|
|
12
|
-
u as getCachedUserInfo,
|
|
13
|
-
Q as getCurrentUserId,
|
|
14
|
-
i as getCurrentUserIdAsync,
|
|
15
|
-
f as getUserInfoAsync,
|
|
16
|
-
U as getUserInfoFromParent,
|
|
17
|
-
d as getUserSdkConfig,
|
|
18
|
-
I as hasCredentials,
|
|
19
|
-
C as hasUserInfo,
|
|
20
|
-
g as initUserBridge,
|
|
21
|
-
l as initUserSdk,
|
|
22
|
-
c as isInIframe,
|
|
23
|
-
h as requestCredentialsFromParent,
|
|
24
|
-
m as requestCredentialsFromiOS,
|
|
25
|
-
P as requestUserInfoFromParent,
|
|
26
|
-
y as requestUserInfoFromiOS,
|
|
27
|
-
k as setAuthToken,
|
|
28
|
-
A as setCurrentUserId,
|
|
29
|
-
F as tryGetCredentialsFromParentStorage,
|
|
30
|
-
S as tryGetUserInfoFromParentStorage,
|
|
31
|
-
b as useAuthToken,
|
|
32
|
-
j as useCurrentUserId,
|
|
33
|
-
x as useGetCurrentUserProfileQuery,
|
|
34
|
-
B as useGetJoinedUserProfilesQuery,
|
|
35
|
-
O as useGetUserProfileByIdQuery,
|
|
36
|
-
v as useUserInfo,
|
|
37
|
-
w as userSessionInfo
|
|
5
|
+
o as clearUserInfoCache,
|
|
6
|
+
f as getAuthTokenAsync,
|
|
7
|
+
t as isInIframe,
|
|
8
|
+
s as useUserInfo
|
|
38
9
|
};
|
package/dist/user/types.d.ts
CHANGED
|
@@ -1,113 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* User SDK
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Global type declarations for User SDK iOS bridge
|
|
6
|
-
* Note: webkit.messageHandlers.aippyListener is already declared in tweaks/types.ts
|
|
2
|
+
* User SDK Types
|
|
7
3
|
*/
|
|
8
4
|
declare global {
|
|
9
5
|
interface Window {
|
|
10
|
-
/** User credentials callback from iOS */
|
|
11
6
|
processUserCredentials?: (data: unknown) => void;
|
|
12
|
-
/** User info callback from iOS */
|
|
13
7
|
processUserInfo?: (data: unknown) => void;
|
|
14
8
|
}
|
|
15
9
|
}
|
|
16
|
-
|
|
17
|
-
* User profile data structure
|
|
18
|
-
*/
|
|
19
|
-
export interface UserProfile {
|
|
20
|
-
/** User unique identifier */
|
|
21
|
-
id: string;
|
|
22
|
-
/** Display name */
|
|
23
|
-
displayName: string;
|
|
24
|
-
/** Username (for @mentions) */
|
|
25
|
-
username: string;
|
|
26
|
-
/** Avatar URL */
|
|
27
|
-
photoUrl?: string;
|
|
28
|
-
/** Online status */
|
|
29
|
-
online?: boolean;
|
|
30
|
-
/** User bio */
|
|
31
|
-
bio?: string;
|
|
32
|
-
/** Cover image URL */
|
|
33
|
-
coverImageUrl?: string;
|
|
34
|
-
/** Additional metadata */
|
|
35
|
-
[key: string]: unknown;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Query result for user profile
|
|
39
|
-
*/
|
|
40
|
-
export interface UserProfileQueryResult {
|
|
41
|
-
/** User profile data */
|
|
42
|
-
data: UserProfile | null;
|
|
43
|
-
/** Loading state */
|
|
44
|
-
isLoading: boolean;
|
|
45
|
-
/** Error state */
|
|
46
|
-
isError: boolean;
|
|
47
|
-
/** Error object */
|
|
48
|
-
error: Error | null;
|
|
49
|
-
/** Refetch function */
|
|
50
|
-
refetch: () => Promise<void>;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Options for getting user profile by ID
|
|
54
|
-
*/
|
|
55
|
-
export interface GetUserProfileByIdOptions {
|
|
56
|
-
/** User ID to fetch */
|
|
57
|
-
id: string;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Options for getting joined user profiles
|
|
61
|
-
*/
|
|
62
|
-
export interface GetJoinedUserProfilesOptions {
|
|
63
|
-
/** Whether to include current user */
|
|
64
|
-
includeSelf?: boolean;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Query result for multiple user profiles
|
|
68
|
-
*/
|
|
69
|
-
export interface UserProfilesQueryResult {
|
|
70
|
-
/** User profiles array */
|
|
71
|
-
data: UserProfile[];
|
|
72
|
-
/** Loading state */
|
|
73
|
-
isLoading: boolean;
|
|
74
|
-
/** Error state */
|
|
75
|
-
isError: boolean;
|
|
76
|
-
/** Error object */
|
|
77
|
-
error: Error | null;
|
|
78
|
-
/** Refetch function */
|
|
79
|
-
refetch: () => Promise<void>;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Date format options
|
|
83
|
-
*/
|
|
84
|
-
export interface FormatDateOptions {
|
|
85
|
-
/** Timestamp in milliseconds */
|
|
86
|
-
timestampMs: number;
|
|
87
|
-
/** Format string (e.g., 'MMM d, h:mm a') */
|
|
88
|
-
formatString: string;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* User session info interface
|
|
92
|
-
*/
|
|
93
|
-
export interface UserSessionInfoInterface {
|
|
94
|
-
/** Get current user ID synchronously */
|
|
95
|
-
getCurrentUserId: () => string | null;
|
|
96
|
-
/** Get current timestamp in milliseconds */
|
|
97
|
-
getTimestampInMs: () => number;
|
|
98
|
-
/** Format date with given format string */
|
|
99
|
-
formatDate: (options: FormatDateOptions) => string;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* User SDK configuration
|
|
103
|
-
*/
|
|
104
|
-
export interface UserSdkConfig {
|
|
105
|
-
/** API base URL */
|
|
106
|
-
apiBaseUrl: string;
|
|
107
|
-
/** Auth token */
|
|
108
|
-
authToken: string;
|
|
109
|
-
/** Current user ID */
|
|
110
|
-
currentUserId: string | null;
|
|
111
|
-
/** Cache time in milliseconds */
|
|
112
|
-
cacheTime?: number;
|
|
113
|
-
}
|
|
10
|
+
export {};
|
package/dist/utils/index.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { P as
|
|
2
|
-
import { a as
|
|
1
|
+
import { P as o, c as s, i as e, p as t, s as m } from "../ui-y5N62DqC.js";
|
|
2
|
+
import { a as f, P as i, p as n, b as c } from "../pwa-CilSlaik.js";
|
|
3
3
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
t as
|
|
4
|
+
f as PWAUtils,
|
|
5
|
+
i as PerformanceMonitor,
|
|
6
|
+
o as PlatformDetector,
|
|
7
|
+
s as compareVersions,
|
|
8
|
+
e as isInIframe,
|
|
9
|
+
n as performanceMonitor,
|
|
10
|
+
t as platform,
|
|
11
|
+
c as pwa,
|
|
12
|
+
m as showAlert
|
|
11
13
|
};
|
package/dist/utils/platform.d.ts
CHANGED
|
@@ -7,6 +7,34 @@ interface PlatformInfo {
|
|
|
7
7
|
isMobile: boolean;
|
|
8
8
|
isDesktop: boolean;
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Minimum app version configuration
|
|
12
|
+
*/
|
|
13
|
+
export interface AppVersionConfig {
|
|
14
|
+
iOS: string;
|
|
15
|
+
Android: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* App environment check result
|
|
19
|
+
*/
|
|
20
|
+
export interface AppEnvironmentCheckResult {
|
|
21
|
+
type: 'new_app' | 'old_ios_app' | 'old_android_app' | 'iframe' | 'web';
|
|
22
|
+
isValid: boolean;
|
|
23
|
+
aippyInfo?: {
|
|
24
|
+
platform: 'iOS' | 'Android';
|
|
25
|
+
version: string;
|
|
26
|
+
} | null;
|
|
27
|
+
message?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Check if running inside an iframe
|
|
31
|
+
*/
|
|
32
|
+
export declare function isInIframe(): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Compare version numbers
|
|
35
|
+
* @returns -1 if v1 < v2, 0 if v1 == v2, 1 if v1 > v2
|
|
36
|
+
*/
|
|
37
|
+
export declare function compareVersions(version1: string, version2: string): number;
|
|
10
38
|
/**
|
|
11
39
|
* Platform detection utilities
|
|
12
40
|
*/
|
|
@@ -17,6 +45,10 @@ export declare class PlatformDetector {
|
|
|
17
45
|
* Get platform information
|
|
18
46
|
*/
|
|
19
47
|
getPlatformInfo(): PlatformInfo;
|
|
48
|
+
/**
|
|
49
|
+
* Get raw UA parser result
|
|
50
|
+
*/
|
|
51
|
+
getRawParserResult(): import('ua-parser-js').IResult;
|
|
20
52
|
/**
|
|
21
53
|
* Get platform capabilities
|
|
22
54
|
*/
|
|
@@ -42,7 +74,16 @@ export declare class PlatformDetector {
|
|
|
42
74
|
*/
|
|
43
75
|
isAndroidChrome(): boolean;
|
|
44
76
|
/**
|
|
45
|
-
*
|
|
77
|
+
* Check if running in Android WebView (old app version)
|
|
78
|
+
* Detects by checking if browser name contains "webview"
|
|
79
|
+
*/
|
|
80
|
+
isAndroidWebView(): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Check app environment and validate version
|
|
83
|
+
*/
|
|
84
|
+
checkAppEnvironment(minVersions: AppVersionConfig): AppEnvironmentCheckResult;
|
|
85
|
+
/**
|
|
86
|
+
* Parse Aippy App info from User-Agent
|
|
46
87
|
*/
|
|
47
88
|
parseAippyInfo(): {
|
|
48
89
|
platform: 'iOS' | 'Android';
|
package/package.json
CHANGED
package/dist/bridge-N9ELFpfV.js
DELETED
|
@@ -1,430 +0,0 @@
|
|
|
1
|
-
import { a as I } from "./runtime-CmoG3v2m.js";
|
|
2
|
-
import { hasNativeBridge as k } from "./native-bridge-BnvipFJc.js";
|
|
3
|
-
import { p as M, s as w } from "./ui-D6IZ1jrR.js";
|
|
4
|
-
const C = {
|
|
5
|
-
apiBaseUrl: "https://api.aippy.dev/api",
|
|
6
|
-
authToken: "",
|
|
7
|
-
// ้ป่ฎคไธบ็ฉบ๏ผ็ฑ iOS ๆกฅๆฅๅกซๅ
|
|
8
|
-
currentUserId: null,
|
|
9
|
-
// ้ป่ฎคไธบ็ฉบ๏ผ็ฑ iOS ๆกฅๆฅๅกซๅ
|
|
10
|
-
cacheTime: 300 * 1e3
|
|
11
|
-
// 5 minutes
|
|
12
|
-
};
|
|
13
|
-
let p = { ...C };
|
|
14
|
-
function j(r) {
|
|
15
|
-
p = {
|
|
16
|
-
...C,
|
|
17
|
-
...r
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
function Z() {
|
|
21
|
-
return p;
|
|
22
|
-
}
|
|
23
|
-
function b(r) {
|
|
24
|
-
p.authToken = r;
|
|
25
|
-
}
|
|
26
|
-
function q(r) {
|
|
27
|
-
p.currentUserId = r;
|
|
28
|
-
}
|
|
29
|
-
function ee() {
|
|
30
|
-
return p.authToken;
|
|
31
|
-
}
|
|
32
|
-
const c = {
|
|
33
|
-
uid: "",
|
|
34
|
-
token: "",
|
|
35
|
-
apiBaseUrl: void 0
|
|
36
|
-
}, m = 500;
|
|
37
|
-
let f = !1, y = !1, d = null, u = null, U = !1, a = null, l = null;
|
|
38
|
-
function g() {
|
|
39
|
-
try {
|
|
40
|
-
return typeof window < "u" && window.parent !== window;
|
|
41
|
-
} catch {
|
|
42
|
-
return !0;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
function T(r = m) {
|
|
46
|
-
return new Promise((e) => {
|
|
47
|
-
if (!g()) {
|
|
48
|
-
console.log("โน๏ธ [UserSDK Bridge] Not in iframe, skipping parent request"), e(c);
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
console.log("๐ค [UserSDK Bridge] Requesting credentials from parent window");
|
|
52
|
-
const n = setTimeout(() => {
|
|
53
|
-
console.warn(`โ ๏ธ [UserSDK Bridge] Parent request timeout (${r}ms)`), window.removeEventListener("message", o), e(c);
|
|
54
|
-
}, r), o = (s) => {
|
|
55
|
-
if (s.data && s.data.type === "user-credentials-response") {
|
|
56
|
-
console.log("๐ฉ [UserSDK Bridge] Received credentials from parent:", s.data), clearTimeout(n), window.removeEventListener("message", o);
|
|
57
|
-
const t = K(s.data);
|
|
58
|
-
e(t || c);
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
window.addEventListener("message", o);
|
|
62
|
-
try {
|
|
63
|
-
window.parent.postMessage({
|
|
64
|
-
type: "user-credentials-request",
|
|
65
|
-
timestamp: Date.now()
|
|
66
|
-
}, "*");
|
|
67
|
-
} catch (s) {
|
|
68
|
-
console.error("โ [UserSDK Bridge] Failed to send request to parent:", s), clearTimeout(n), window.removeEventListener("message", o), e(c);
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
function P(r = m) {
|
|
73
|
-
return new Promise((e) => {
|
|
74
|
-
if (!g()) {
|
|
75
|
-
console.log("โน๏ธ [UserSDK Bridge] Not in iframe, skipping parent user info request"), e(null);
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
console.log("๐ค [UserSDK Bridge] Requesting user info from parent window");
|
|
79
|
-
const n = setTimeout(() => {
|
|
80
|
-
console.warn(`โ ๏ธ [UserSDK Bridge] Parent user info request timeout (${r}ms)`), window.removeEventListener("message", o), e(null);
|
|
81
|
-
}, r), o = (s) => {
|
|
82
|
-
if (s.data && s.data.type === "user-info-response") {
|
|
83
|
-
console.log("๐ฉ [UserSDK Bridge] Received user info from parent:", s.data), clearTimeout(n), window.removeEventListener("message", o);
|
|
84
|
-
const t = h(s.data);
|
|
85
|
-
e(t);
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
window.addEventListener("message", o);
|
|
89
|
-
try {
|
|
90
|
-
window.parent.postMessage({
|
|
91
|
-
type: "user-info-request",
|
|
92
|
-
timestamp: Date.now()
|
|
93
|
-
}, "*");
|
|
94
|
-
} catch (s) {
|
|
95
|
-
console.error("โ [UserSDK Bridge] Failed to send user info request to parent:", s), clearTimeout(n), window.removeEventListener("message", o), e(null);
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
function A() {
|
|
100
|
-
if (!g())
|
|
101
|
-
return null;
|
|
102
|
-
try {
|
|
103
|
-
const r = window.parent.localStorage.getItem("token"), e = window.parent.localStorage.getItem("user");
|
|
104
|
-
if (!r || !e)
|
|
105
|
-
return console.log("โน๏ธ [UserSDK Bridge] Parent localStorage credentials not found"), null;
|
|
106
|
-
const n = JSON.parse(e), o = n.uid || n.userId || n.id || "";
|
|
107
|
-
if (!o)
|
|
108
|
-
return console.warn("โ ๏ธ [UserSDK Bridge] Parent user data missing uid"), null;
|
|
109
|
-
const s = {
|
|
110
|
-
uid: String(o),
|
|
111
|
-
token: r,
|
|
112
|
-
apiBaseUrl: void 0
|
|
113
|
-
};
|
|
114
|
-
return q(s.uid), b(s.token), console.log("โ
[UserSDK Bridge] Got credentials from parent localStorage:", s.uid), d = s, f = !0, s;
|
|
115
|
-
} catch {
|
|
116
|
-
return console.log("โน๏ธ [UserSDK Bridge] Cannot access parent localStorage (cross-origin), will use postMessage"), null;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
function N() {
|
|
120
|
-
if (!g())
|
|
121
|
-
return null;
|
|
122
|
-
try {
|
|
123
|
-
const r = window.parent.localStorage.getItem("user");
|
|
124
|
-
if (!r)
|
|
125
|
-
return console.log("โน๏ธ [UserSDK Bridge] Parent localStorage user not found"), null;
|
|
126
|
-
const e = JSON.parse(r), n = e.uid || e.userId || e.id || "";
|
|
127
|
-
if (!n)
|
|
128
|
-
return console.warn("โ ๏ธ [UserSDK Bridge] Parent user data missing uid"), null;
|
|
129
|
-
const o = {
|
|
130
|
-
uid: String(n),
|
|
131
|
-
avatar: e.avatar || e.photoUrl || e.avatarUrl || "",
|
|
132
|
-
nickName: e.nickName || e.nickname || e.displayName || "",
|
|
133
|
-
username: e.username || e.userName || "",
|
|
134
|
-
displayName: e.displayName || e.nickName || "",
|
|
135
|
-
email: e.email || "",
|
|
136
|
-
phone: e.phone || "",
|
|
137
|
-
bio: e.bio || "",
|
|
138
|
-
online: e.online || e.isOnline || !1
|
|
139
|
-
};
|
|
140
|
-
return console.log("โ
[UserSDK Bridge] Got user info from parent localStorage (fresh):", o.uid), o;
|
|
141
|
-
} catch {
|
|
142
|
-
return console.log("โน๏ธ [UserSDK Bridge] Cannot access parent localStorage (cross-origin), will use postMessage"), null;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
function R(r = m) {
|
|
146
|
-
return f && d ? (console.log("โ
[UserSDK Bridge] Returning cached credentials"), Promise.resolve(d)) : y && !f ? (console.log("โน๏ธ [UserSDK Bridge] Previous request failed, returning empty credentials"), Promise.resolve(c)) : a ? (console.log("โณ [UserSDK Bridge] Request already pending, waiting..."), new Promise((e) => {
|
|
147
|
-
const n = a.resolve;
|
|
148
|
-
a.resolve = (o) => {
|
|
149
|
-
n(o), e(o);
|
|
150
|
-
};
|
|
151
|
-
})) : new Promise((e) => {
|
|
152
|
-
y = !0;
|
|
153
|
-
const n = window.webkit?.messageHandlers?.aippyListener;
|
|
154
|
-
if (!n) {
|
|
155
|
-
console.warn("โ ๏ธ [UserSDK Bridge] Native bridge not available, returning empty credentials"), e(c);
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
const o = setTimeout(() => {
|
|
159
|
-
console.warn(`โ ๏ธ [UserSDK Bridge] Request timeout (${r}ms), returning empty credentials`), a = null, e(c);
|
|
160
|
-
}, r);
|
|
161
|
-
a = { resolve: e, reject: () => {
|
|
162
|
-
} };
|
|
163
|
-
const s = I.receiveChannel.once("user.credentials", (t) => {
|
|
164
|
-
console.log("๐ฉ [UserSDK Bridge] Received credentials via receiveChannel:", t), clearTimeout(o);
|
|
165
|
-
const i = K(t);
|
|
166
|
-
i ? a?.resolve(i) : a?.resolve(c), a = null;
|
|
167
|
-
});
|
|
168
|
-
try {
|
|
169
|
-
const t = {
|
|
170
|
-
command: "user.getCredentials",
|
|
171
|
-
parameters: JSON.stringify({
|
|
172
|
-
timestamp: Date.now(),
|
|
173
|
-
endpoint: "user.credentials"
|
|
174
|
-
// Tell iOS which endpoint to respond to
|
|
175
|
-
})
|
|
176
|
-
};
|
|
177
|
-
console.log("๐ค [UserSDK Bridge] Requesting credentials from iOS:", t), n.postMessage(t);
|
|
178
|
-
} catch (t) {
|
|
179
|
-
console.error("โ [UserSDK Bridge] Failed to send request to iOS:", t), clearTimeout(o), s.cancel(), a = null, e(c);
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
function K(r) {
|
|
184
|
-
if (!r || typeof r != "object")
|
|
185
|
-
return console.warn("โ ๏ธ [UserSDK Bridge] Invalid credentials data:", r), null;
|
|
186
|
-
let e = r;
|
|
187
|
-
if (e.credentials && typeof e.credentials == "object" && (console.log("๐ฆ [UserSDK Bridge] Detected nested credentials format"), e = e.credentials), e.user && typeof e.user == "object" && e.token) {
|
|
188
|
-
console.log("๐ฆ [UserSDK Bridge] Detected parent window format");
|
|
189
|
-
const i = e.user;
|
|
190
|
-
e = {
|
|
191
|
-
uid: i.uid || i.userId || i.id,
|
|
192
|
-
token: e.token,
|
|
193
|
-
apiBaseUrl: e.apiBaseUrl
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
const n = e.uid || e.userId || e.id || "", o = e.token || e.authToken || "", s = e.apiBaseUrl || e.baseUrl;
|
|
197
|
-
if (!n || !o)
|
|
198
|
-
return console.warn("โ ๏ธ [UserSDK Bridge] Missing uid or token in credentials:", r), null;
|
|
199
|
-
const t = { uid: String(n), token: o, apiBaseUrl: s };
|
|
200
|
-
return q(t.uid), b(o), s && j({ apiBaseUrl: s }), console.log("โ
[UserSDK Bridge] Config updated with credentials:", t.uid), d = t, f = !0, t;
|
|
201
|
-
}
|
|
202
|
-
function D(r) {
|
|
203
|
-
console.log("๐ฉ [UserSDK Bridge] processUserCredentials called with:", r);
|
|
204
|
-
const e = K(r);
|
|
205
|
-
e && a && (a.resolve(e), a = null);
|
|
206
|
-
}
|
|
207
|
-
function h(r) {
|
|
208
|
-
if (!r || typeof r != "object")
|
|
209
|
-
return console.warn("โ ๏ธ [UserSDK Bridge] Invalid user info data:", r), null;
|
|
210
|
-
let e = r;
|
|
211
|
-
e.userInfo && typeof e.userInfo == "object" && (console.log("๐ฆ [UserSDK Bridge] Detected nested userInfo format"), e = e.userInfo), e.user && typeof e.user == "object" && (console.log("๐ฆ [UserSDK Bridge] Detected nested user format"), e = e.user);
|
|
212
|
-
const n = e.uid || e.userId || e.id || "";
|
|
213
|
-
if (!n)
|
|
214
|
-
return console.warn("โ ๏ธ [UserSDK Bridge] Missing uid in user info:", r), null;
|
|
215
|
-
const o = {
|
|
216
|
-
uid: String(n),
|
|
217
|
-
displayName: e.displayName,
|
|
218
|
-
nickname: e.nickname,
|
|
219
|
-
username: e.username,
|
|
220
|
-
photoUrl: e.photoUrl,
|
|
221
|
-
avatar: e.avatar,
|
|
222
|
-
email: e.email,
|
|
223
|
-
phone: e.phone,
|
|
224
|
-
bio: e.bio,
|
|
225
|
-
online: e.online,
|
|
226
|
-
...e
|
|
227
|
-
};
|
|
228
|
-
return console.log("โ
[UserSDK Bridge] Processed user info:", o.uid), u = o, U = !0, o;
|
|
229
|
-
}
|
|
230
|
-
function B(r) {
|
|
231
|
-
console.log("๐ฉ [UserSDK Bridge] processUserInfo called with:", r);
|
|
232
|
-
const e = h(r);
|
|
233
|
-
e && l && (l.resolve(e), l = null);
|
|
234
|
-
}
|
|
235
|
-
function O(r = !1, e = m) {
|
|
236
|
-
return U && u && !r ? (console.log("โ
[UserSDK Bridge] Returning cached user info"), Promise.resolve(u)) : l ? (console.log("โณ [UserSDK Bridge] User info request already pending, waiting..."), new Promise((n) => {
|
|
237
|
-
const o = l.resolve;
|
|
238
|
-
l.resolve = (s) => {
|
|
239
|
-
o(s), n(s);
|
|
240
|
-
};
|
|
241
|
-
})) : new Promise((n) => {
|
|
242
|
-
const o = window.webkit?.messageHandlers?.aippyListener;
|
|
243
|
-
if (!o) {
|
|
244
|
-
console.warn("โ ๏ธ [UserSDK Bridge] Native bridge not available, cannot get user info"), n(null);
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
const s = setTimeout(() => {
|
|
248
|
-
console.warn(`โ ๏ธ [UserSDK Bridge] User info request timeout (${e}ms)`), l = null, n(null);
|
|
249
|
-
}, e);
|
|
250
|
-
l = { resolve: n, reject: () => {
|
|
251
|
-
} };
|
|
252
|
-
const t = I.receiveChannel.once("user.info", (i) => {
|
|
253
|
-
console.log("๐ฉ [UserSDK Bridge] Received user info via receiveChannel:", i), clearTimeout(s);
|
|
254
|
-
const S = h(i);
|
|
255
|
-
l?.resolve(S), l = null;
|
|
256
|
-
});
|
|
257
|
-
try {
|
|
258
|
-
const i = {
|
|
259
|
-
command: "user.getUserInfo",
|
|
260
|
-
parameters: JSON.stringify({
|
|
261
|
-
timestamp: Date.now(),
|
|
262
|
-
endpoint: "user.info"
|
|
263
|
-
// Tell iOS which endpoint to respond to
|
|
264
|
-
})
|
|
265
|
-
};
|
|
266
|
-
console.log("๐ค [UserSDK Bridge] Requesting user info from iOS:", i), o.postMessage(i);
|
|
267
|
-
} catch (i) {
|
|
268
|
-
console.error("โ [UserSDK Bridge] Failed to send user info request to iOS:", i), clearTimeout(s), t.cancel(), l = null, n(null);
|
|
269
|
-
}
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
async function F(r = !1) {
|
|
273
|
-
return U && u && !r ? u : k() ? await O(r) : u;
|
|
274
|
-
}
|
|
275
|
-
async function G(r = m) {
|
|
276
|
-
if (!g())
|
|
277
|
-
return console.log("โน๏ธ [UserSDK Bridge] Not in iframe, cannot get user info from parent"), null;
|
|
278
|
-
console.log("๐ [UserSDK Bridge] Getting fresh user info from parent (no cache)");
|
|
279
|
-
const e = N();
|
|
280
|
-
if (e)
|
|
281
|
-
return console.log("โ
[UserSDK Bridge] Got fresh user info from parent localStorage"), e;
|
|
282
|
-
console.log("๐ [UserSDK Bridge] Trying postMessage to parent for user info");
|
|
283
|
-
const n = await P(r);
|
|
284
|
-
return n ? (console.log("โ
[UserSDK Bridge] Got fresh user info from parent postMessage"), n) : (console.log("โ ๏ธ [UserSDK Bridge] Could not get user info from parent"), null);
|
|
285
|
-
}
|
|
286
|
-
function _() {
|
|
287
|
-
return u;
|
|
288
|
-
}
|
|
289
|
-
function $() {
|
|
290
|
-
return U;
|
|
291
|
-
}
|
|
292
|
-
function V() {
|
|
293
|
-
u = null, U = !1, console.log("๐งน [UserSDK Bridge] Cleared cached user info");
|
|
294
|
-
}
|
|
295
|
-
function E() {
|
|
296
|
-
typeof window > "u" || (window.processUserCredentials = D, window.processUserInfo = B, window.addEventListener("message", (r) => {
|
|
297
|
-
r.data && r.data.type === "user-credentials" && (console.log("๐ฉ [UserSDK Bridge] Received credentials via postMessage:", r.data), D(r.data)), r.data && r.data.type === "user-info" && (console.log("๐ฉ [UserSDK Bridge] Received user info via postMessage:", r.data), B(r.data)), r.data && r.data.type === "user-info-response" && console.log("๐ฉ [UserSDK Bridge] Received user info response from parent");
|
|
298
|
-
}), console.log("โ
[UserSDK Bridge] Bridge initialized"));
|
|
299
|
-
}
|
|
300
|
-
async function v() {
|
|
301
|
-
if (f && d) {
|
|
302
|
-
console.log("โ
[UserSDK Bridge] Already have cached credentials");
|
|
303
|
-
return;
|
|
304
|
-
}
|
|
305
|
-
if (k()) {
|
|
306
|
-
console.log("๐ [UserSDK Bridge] Detected iOS environment, requesting from native");
|
|
307
|
-
try {
|
|
308
|
-
if (await R(), f) {
|
|
309
|
-
console.log("โ
[UserSDK Bridge] Got credentials from iOS");
|
|
310
|
-
return;
|
|
311
|
-
}
|
|
312
|
-
} catch (r) {
|
|
313
|
-
console.warn("โ ๏ธ [UserSDK Bridge] iOS request failed:", r);
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
if (g()) {
|
|
317
|
-
if (console.log("๐ [UserSDK Bridge] Detected iframe environment"), A()) {
|
|
318
|
-
console.log("โ
[UserSDK Bridge] Got credentials from parent localStorage");
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
console.log("๐ [UserSDK Bridge] Trying postMessage to parent");
|
|
322
|
-
try {
|
|
323
|
-
const e = await T();
|
|
324
|
-
if (e.uid && e.token) {
|
|
325
|
-
console.log("โ
[UserSDK Bridge] Got credentials from parent postMessage");
|
|
326
|
-
return;
|
|
327
|
-
}
|
|
328
|
-
} catch (e) {
|
|
329
|
-
console.warn("โ ๏ธ [UserSDK Bridge] Parent postMessage request failed:", e);
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
console.log("โน๏ธ [UserSDK Bridge] No credentials source available");
|
|
333
|
-
}
|
|
334
|
-
function x(r, e) {
|
|
335
|
-
const n = r.split(".").map(Number), o = e.split(".").map(Number), s = Math.max(n.length, o.length);
|
|
336
|
-
for (let t = 0; t < s; t++) {
|
|
337
|
-
const i = n[t] || 0, S = o[t] || 0;
|
|
338
|
-
if (i < S) return -1;
|
|
339
|
-
if (i > S) return 1;
|
|
340
|
-
}
|
|
341
|
-
return 0;
|
|
342
|
-
}
|
|
343
|
-
function H(r) {
|
|
344
|
-
if (!r)
|
|
345
|
-
return !1;
|
|
346
|
-
const n = {
|
|
347
|
-
iOS: "1.6.6",
|
|
348
|
-
Android: "1.1.8"
|
|
349
|
-
}[r.platform];
|
|
350
|
-
return n ? x(r.version, n) >= 0 : (console.warn("โ ๏ธ [UserSDK Bridge] Unknown platform:", r.platform), !1);
|
|
351
|
-
}
|
|
352
|
-
async function L() {
|
|
353
|
-
console.log("๐ฑ [UserSDK Bridge] Navigator UserAgent:", navigator.userAgent);
|
|
354
|
-
const r = M.parseAippyInfo();
|
|
355
|
-
if (r) {
|
|
356
|
-
if (console.log(`๐ฑ [UserSDK Bridge] Aippy App - Platform: ${r.platform}, Version: ${r.version}`), w("Your app version is outdated. Please upgrade to the latest version."), !H(r)) {
|
|
357
|
-
const n = { iOS: "1.6.6", Android: "1.1.8" };
|
|
358
|
-
throw console.error(`โ [UserSDK Bridge] App version ${r.version} < ${n[r.platform]}`), w("Your app version is outdated. Please upgrade to the latest version."), new Error("App version too old");
|
|
359
|
-
}
|
|
360
|
-
console.log("โ
[UserSDK Bridge] App version OK");
|
|
361
|
-
} else if (!g())
|
|
362
|
-
throw console.error("โ [UserSDK Bridge] Native bridge exists but no Aippy info (old version)"), w("Your app version is outdated. Please upgrade to the latest version."), new Error("App version too old");
|
|
363
|
-
await v();
|
|
364
|
-
const e = d?.token || "";
|
|
365
|
-
if (!e)
|
|
366
|
-
throw w("Please log in to use this feature."), new Error("Token unavailable: User needs to login");
|
|
367
|
-
return e;
|
|
368
|
-
}
|
|
369
|
-
async function J() {
|
|
370
|
-
return await v(), d?.uid || "";
|
|
371
|
-
}
|
|
372
|
-
function Y() {
|
|
373
|
-
return f;
|
|
374
|
-
}
|
|
375
|
-
function z() {
|
|
376
|
-
return d;
|
|
377
|
-
}
|
|
378
|
-
E();
|
|
379
|
-
L().catch((r) => {
|
|
380
|
-
console.warn("[UserSDK] Auth check on load:", r.message);
|
|
381
|
-
});
|
|
382
|
-
const re = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
383
|
-
__proto__: null,
|
|
384
|
-
autoRequestCredentials: v,
|
|
385
|
-
clearCachedUserInfo: V,
|
|
386
|
-
getAuthTokenAsync: L,
|
|
387
|
-
getCachedCredentials: z,
|
|
388
|
-
getCachedUserInfo: _,
|
|
389
|
-
getCurrentUserIdAsync: J,
|
|
390
|
-
getUserInfoAsync: F,
|
|
391
|
-
getUserInfoFromParent: G,
|
|
392
|
-
hasCredentials: Y,
|
|
393
|
-
hasUserInfo: $,
|
|
394
|
-
initUserBridge: E,
|
|
395
|
-
isInIframe: g,
|
|
396
|
-
processUserCredentials: D,
|
|
397
|
-
processUserInfo: B,
|
|
398
|
-
requestCredentialsFromParent: T,
|
|
399
|
-
requestCredentialsFromiOS: R,
|
|
400
|
-
requestUserInfoFromParent: P,
|
|
401
|
-
requestUserInfoFromiOS: O,
|
|
402
|
-
tryGetCredentialsFromParentStorage: A,
|
|
403
|
-
tryGetUserInfoFromParentStorage: N
|
|
404
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
405
|
-
export {
|
|
406
|
-
q as a,
|
|
407
|
-
ee as b,
|
|
408
|
-
g as c,
|
|
409
|
-
T as d,
|
|
410
|
-
E as e,
|
|
411
|
-
v as f,
|
|
412
|
-
Z as g,
|
|
413
|
-
L as h,
|
|
414
|
-
j as i,
|
|
415
|
-
J as j,
|
|
416
|
-
Y as k,
|
|
417
|
-
z as l,
|
|
418
|
-
O as m,
|
|
419
|
-
F as n,
|
|
420
|
-
_ as o,
|
|
421
|
-
$ as p,
|
|
422
|
-
V as q,
|
|
423
|
-
R as r,
|
|
424
|
-
b as s,
|
|
425
|
-
A as t,
|
|
426
|
-
P as u,
|
|
427
|
-
N as v,
|
|
428
|
-
G as w,
|
|
429
|
-
re as x
|
|
430
|
-
};
|