@aippy/runtime 0.2.5-dev.1 → 0.2.6
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/README.md +0 -34
- package/dist/core/index.js +14 -15
- package/dist/device/index.js +256 -263
- package/dist/device/sensors.d.ts +8 -56
- package/dist/index/index.js +47 -93
- package/dist/index.d.ts +0 -2
- package/dist/leaderboard/index.js +22 -18
- package/dist/leaderboard/types.d.ts +2 -0
- package/dist/{runtime-CmoG3v2m.js → runtime-DjBdOttl.js} +76 -55
- package/package.json +36 -48
- package/dist/ai/errors.d.ts +0 -21
- package/dist/ai/index.d.ts +0 -45
- package/dist/ai/index.js +0 -20
- package/dist/ai/openai/index.d.ts +0 -11
- package/dist/ai/openai/provider.d.ts +0 -51
- package/dist/ai/shared/config.d.ts +0 -50
- package/dist/ai/shared/index.d.ts +0 -5
- package/dist/ai/ui/config.d.ts +0 -81
- package/dist/ai/ui/endpoints.d.ts +0 -16
- package/dist/ai/ui/index.d.ts +0 -15
- package/dist/ai/ui/types.d.ts +0 -46
- package/dist/ai.d.ts +0 -2
- package/dist/bridge-DdAH4txB.js +0 -222
- package/dist/core/native-bridge.d.ts +0 -9
- package/dist/errors-CDEBaBxB.js +0 -26
- package/dist/errors-D29z-Qus.js +0 -148
- package/dist/native-bridge-JAmH-zTN.js +0 -6
- package/dist/user/api.d.ts +0 -9
- package/dist/user/bridge.d.ts +0 -80
- package/dist/user/config.d.ts +0 -21
- package/dist/user/hooks.d.ts +0 -38
- package/dist/user/index.d.ts +0 -11
- package/dist/user/index.js +0 -28
- package/dist/user/types.d.ts +0 -111
- package/dist/user/userSessionInfo.d.ts +0 -6
- package/dist/user.d.ts +0 -2
- package/dist/userSessionInfo-CBk9ywXi.js +0 -186
package/dist/bridge-DdAH4txB.js
DELETED
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
import { a as K } from "./runtime-CmoG3v2m.js";
|
|
2
|
-
import { h as y } from "./native-bridge-JAmH-zTN.js";
|
|
3
|
-
const U = {
|
|
4
|
-
apiBaseUrl: "https://api.aippy.dev/api",
|
|
5
|
-
authToken: "",
|
|
6
|
-
// 默认为空,由 iOS 桥接填充
|
|
7
|
-
currentUserId: null,
|
|
8
|
-
// 默认为空,由 iOS 桥接填充
|
|
9
|
-
cacheTime: 300 * 1e3
|
|
10
|
-
// 5 minutes
|
|
11
|
-
};
|
|
12
|
-
let u = { ...U };
|
|
13
|
-
function h(r) {
|
|
14
|
-
u = {
|
|
15
|
-
...U,
|
|
16
|
-
...r
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
function R() {
|
|
20
|
-
return u;
|
|
21
|
-
}
|
|
22
|
-
function w(r) {
|
|
23
|
-
u.authToken = r;
|
|
24
|
-
}
|
|
25
|
-
function B(r) {
|
|
26
|
-
u.currentUserId = r;
|
|
27
|
-
}
|
|
28
|
-
function P() {
|
|
29
|
-
return u.authToken;
|
|
30
|
-
}
|
|
31
|
-
const a = {
|
|
32
|
-
uid: "",
|
|
33
|
-
token: "",
|
|
34
|
-
apiBaseUrl: void 0
|
|
35
|
-
}, D = 5e3;
|
|
36
|
-
let d = !1, m = !1, l = null, o = null;
|
|
37
|
-
function g() {
|
|
38
|
-
try {
|
|
39
|
-
return typeof window < "u" && window.parent !== window;
|
|
40
|
-
} catch {
|
|
41
|
-
return !0;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
function k(r = D) {
|
|
45
|
-
return new Promise((e) => {
|
|
46
|
-
if (!g()) {
|
|
47
|
-
console.log("ℹ️ [UserSDK Bridge] Not in iframe, skipping parent request"), e(a);
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
console.log("📤 [UserSDK Bridge] Requesting credentials from parent window");
|
|
51
|
-
const i = setTimeout(() => {
|
|
52
|
-
console.warn(`⚠️ [UserSDK Bridge] Parent request timeout (${r}ms)`), window.removeEventListener("message", n), e(a);
|
|
53
|
-
}, r), n = (t) => {
|
|
54
|
-
if (t.data && t.data.type === "user-credentials-response") {
|
|
55
|
-
console.log("📩 [UserSDK Bridge] Received credentials from parent:", t.data), clearTimeout(i), window.removeEventListener("message", n);
|
|
56
|
-
const s = f(t.data);
|
|
57
|
-
e(s || a);
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
window.addEventListener("message", n);
|
|
61
|
-
try {
|
|
62
|
-
window.parent.postMessage({
|
|
63
|
-
type: "user-credentials-request",
|
|
64
|
-
timestamp: Date.now()
|
|
65
|
-
}, "*");
|
|
66
|
-
} catch (t) {
|
|
67
|
-
console.error("❌ [UserSDK Bridge] Failed to send request to parent:", t), clearTimeout(i), window.removeEventListener("message", n), e(a);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
function C() {
|
|
72
|
-
if (!g())
|
|
73
|
-
return null;
|
|
74
|
-
try {
|
|
75
|
-
const r = window.parent.localStorage.getItem("token"), e = window.parent.localStorage.getItem("user");
|
|
76
|
-
if (!r || !e)
|
|
77
|
-
return console.log("ℹ️ [UserSDK Bridge] Parent localStorage credentials not found"), null;
|
|
78
|
-
const i = JSON.parse(e), n = i.uid || i.userId || i.id || "";
|
|
79
|
-
if (!n)
|
|
80
|
-
return console.warn("⚠️ [UserSDK Bridge] Parent user data missing uid"), null;
|
|
81
|
-
const t = {
|
|
82
|
-
uid: String(n),
|
|
83
|
-
token: r,
|
|
84
|
-
apiBaseUrl: void 0
|
|
85
|
-
};
|
|
86
|
-
return B(t.uid), w(t.token), console.log("✅ [UserSDK Bridge] Got credentials from parent localStorage:", t.uid), l = t, d = !0, t;
|
|
87
|
-
} catch {
|
|
88
|
-
return console.log("ℹ️ [UserSDK Bridge] Cannot access parent localStorage (cross-origin), will use postMessage"), null;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
function v(r = D) {
|
|
92
|
-
return d && l ? (console.log("✅ [UserSDK Bridge] Returning cached credentials"), Promise.resolve(l)) : m && !d ? (console.log("ℹ️ [UserSDK Bridge] Previous request failed, returning empty credentials"), Promise.resolve(a)) : o ? (console.log("⏳ [UserSDK Bridge] Request already pending, waiting..."), new Promise((e) => {
|
|
93
|
-
const i = o.resolve;
|
|
94
|
-
o.resolve = (n) => {
|
|
95
|
-
i(n), e(n);
|
|
96
|
-
};
|
|
97
|
-
})) : new Promise((e) => {
|
|
98
|
-
m = !0;
|
|
99
|
-
const i = window.webkit?.messageHandlers?.aippyListener;
|
|
100
|
-
if (!i) {
|
|
101
|
-
console.warn("⚠️ [UserSDK Bridge] Native bridge not available, returning empty credentials"), e(a);
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
const n = setTimeout(() => {
|
|
105
|
-
console.warn(`⚠️ [UserSDK Bridge] Request timeout (${r}ms), returning empty credentials`), o = null, e(a);
|
|
106
|
-
}, r);
|
|
107
|
-
o = { resolve: e, reject: () => {
|
|
108
|
-
} };
|
|
109
|
-
const t = K.receiveChannel.once("user.credentials", (s) => {
|
|
110
|
-
console.log("📩 [UserSDK Bridge] Received credentials via receiveChannel:", s), clearTimeout(n);
|
|
111
|
-
const c = f(s);
|
|
112
|
-
c ? o?.resolve(c) : o?.resolve(a), o = null;
|
|
113
|
-
});
|
|
114
|
-
try {
|
|
115
|
-
const s = {
|
|
116
|
-
command: "user.getCredentials",
|
|
117
|
-
parameters: JSON.stringify({
|
|
118
|
-
timestamp: Date.now(),
|
|
119
|
-
endpoint: "user.credentials"
|
|
120
|
-
// Tell iOS which endpoint to respond to
|
|
121
|
-
})
|
|
122
|
-
};
|
|
123
|
-
console.log("📤 [UserSDK Bridge] Requesting credentials from iOS:", s), i.postMessage(s);
|
|
124
|
-
} catch (s) {
|
|
125
|
-
console.error("❌ [UserSDK Bridge] Failed to send request to iOS:", s), clearTimeout(n), t.cancel(), o = null, e(a);
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
function f(r) {
|
|
130
|
-
if (!r || typeof r != "object")
|
|
131
|
-
return console.warn("⚠️ [UserSDK Bridge] Invalid credentials data:", r), null;
|
|
132
|
-
let e = r;
|
|
133
|
-
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) {
|
|
134
|
-
console.log("📦 [UserSDK Bridge] Detected parent window format");
|
|
135
|
-
const c = e.user;
|
|
136
|
-
e = {
|
|
137
|
-
uid: c.uid || c.userId || c.id,
|
|
138
|
-
token: e.token,
|
|
139
|
-
apiBaseUrl: e.apiBaseUrl
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
const i = e.uid || e.userId || e.id || "", n = e.token || e.authToken || "", t = e.apiBaseUrl || e.baseUrl;
|
|
143
|
-
if (!i || !n)
|
|
144
|
-
return console.warn("⚠️ [UserSDK Bridge] Missing uid or token in credentials:", r), null;
|
|
145
|
-
const s = { uid: String(i), token: n, apiBaseUrl: t };
|
|
146
|
-
return B(s.uid), w(n), t && h({ apiBaseUrl: t }), console.log("✅ [UserSDK Bridge] Config updated with credentials:", s.uid), l = s, d = !0, s;
|
|
147
|
-
}
|
|
148
|
-
function S(r) {
|
|
149
|
-
console.log("📩 [UserSDK Bridge] processUserCredentials called with:", r);
|
|
150
|
-
const e = f(r);
|
|
151
|
-
e && o && (o.resolve(e), o = null);
|
|
152
|
-
}
|
|
153
|
-
function T() {
|
|
154
|
-
typeof window > "u" || (window.processUserCredentials = S, window.addEventListener("message", (r) => {
|
|
155
|
-
r.data && r.data.type === "user-credentials" && (console.log("📩 [UserSDK Bridge] Received credentials via postMessage:", r.data), S(r.data));
|
|
156
|
-
}), console.log("✅ [UserSDK Bridge] Bridge initialized"));
|
|
157
|
-
}
|
|
158
|
-
async function p() {
|
|
159
|
-
if (d && l) {
|
|
160
|
-
console.log("✅ [UserSDK Bridge] Already have cached credentials");
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
if (y()) {
|
|
164
|
-
console.log("🔍 [UserSDK Bridge] Detected iOS environment, requesting from native");
|
|
165
|
-
try {
|
|
166
|
-
if (await v(), d) {
|
|
167
|
-
console.log("✅ [UserSDK Bridge] Got credentials from iOS");
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
} catch (r) {
|
|
171
|
-
console.warn("⚠️ [UserSDK Bridge] iOS request failed:", r);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
if (g()) {
|
|
175
|
-
if (console.log("🔍 [UserSDK Bridge] Detected iframe environment"), C()) {
|
|
176
|
-
console.log("✅ [UserSDK Bridge] Got credentials from parent localStorage");
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
console.log("🔍 [UserSDK Bridge] Trying postMessage to parent");
|
|
180
|
-
try {
|
|
181
|
-
const e = await k();
|
|
182
|
-
if (e.uid && e.token) {
|
|
183
|
-
console.log("✅ [UserSDK Bridge] Got credentials from parent postMessage");
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
} catch (e) {
|
|
187
|
-
console.warn("⚠️ [UserSDK Bridge] Parent postMessage request failed:", e);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
console.log("ℹ️ [UserSDK Bridge] No credentials source available");
|
|
191
|
-
}
|
|
192
|
-
async function b() {
|
|
193
|
-
return await p(), l?.token || "";
|
|
194
|
-
}
|
|
195
|
-
async function E() {
|
|
196
|
-
return await p(), l?.uid || "";
|
|
197
|
-
}
|
|
198
|
-
function O() {
|
|
199
|
-
return d;
|
|
200
|
-
}
|
|
201
|
-
function A() {
|
|
202
|
-
return l;
|
|
203
|
-
}
|
|
204
|
-
T();
|
|
205
|
-
p();
|
|
206
|
-
export {
|
|
207
|
-
B as a,
|
|
208
|
-
P as b,
|
|
209
|
-
g as c,
|
|
210
|
-
k as d,
|
|
211
|
-
T as e,
|
|
212
|
-
p as f,
|
|
213
|
-
R as g,
|
|
214
|
-
b as h,
|
|
215
|
-
h as i,
|
|
216
|
-
E as j,
|
|
217
|
-
O as k,
|
|
218
|
-
A as l,
|
|
219
|
-
v as r,
|
|
220
|
-
w as s,
|
|
221
|
-
C as t
|
|
222
|
-
};
|
package/dist/errors-CDEBaBxB.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
var e = Object.defineProperty;
|
|
2
|
-
var o = (E, R, N) => R in E ? e(E, R, { enumerable: !0, configurable: !0, writable: !0, value: N }) : E[R] = N;
|
|
3
|
-
var O = (E, R, N) => o(E, typeof R != "symbol" ? R + "" : R, N);
|
|
4
|
-
class I extends Error {
|
|
5
|
-
constructor(N, r = "AIPPY_ERROR", t) {
|
|
6
|
-
super(N);
|
|
7
|
-
O(this, "code");
|
|
8
|
-
O(this, "context");
|
|
9
|
-
this.name = "AippyRuntimeError", this.code = r, this.context = t;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
const _ = {
|
|
13
|
-
NOT_SUPPORTED: "NOT_SUPPORTED",
|
|
14
|
-
PERMISSION_DENIED: "PERMISSION_DENIED",
|
|
15
|
-
INVALID_CONFIG: "INVALID_CONFIG",
|
|
16
|
-
NETWORK_ERROR: "NETWORK_ERROR",
|
|
17
|
-
UNKNOWN_ERROR: "UNKNOWN_ERROR"
|
|
18
|
-
};
|
|
19
|
-
function s(E, R = "UNKNOWN_ERROR", N) {
|
|
20
|
-
return new I(E, _[R], N);
|
|
21
|
-
}
|
|
22
|
-
export {
|
|
23
|
-
I as A,
|
|
24
|
-
_ as E,
|
|
25
|
-
s as c
|
|
26
|
-
};
|
package/dist/errors-D29z-Qus.js
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { createOpenAICompatible as A } from "@ai-sdk/openai-compatible";
|
|
2
|
-
import "react";
|
|
3
|
-
import { h as i } from "./bridge-DdAH4txB.js";
|
|
4
|
-
import { DefaultChatTransport as f, AISDKError as n } from "ai";
|
|
5
|
-
const m = "https://api.aippy.dev", l = `${m}/api/aisdk/v1`, d = `${m}/api/aisdk/v1/ui`, g = "gpt-5", _ = "";
|
|
6
|
-
function h(e = {}) {
|
|
7
|
-
return {
|
|
8
|
-
baseUrl: e.baseUrl ?? l
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
function u(e = {}) {
|
|
12
|
-
return {
|
|
13
|
-
baseUrl: e.baseUrl ?? d
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
const y = [
|
|
17
|
-
"gpt-image-1",
|
|
18
|
-
"gpt-image-1-mini",
|
|
19
|
-
"gpt-image-1.5"
|
|
20
|
-
];
|
|
21
|
-
function U(e) {
|
|
22
|
-
try {
|
|
23
|
-
const r = JSON.parse(e);
|
|
24
|
-
if (r.model && y.some((t) => r.model.startsWith(t))) {
|
|
25
|
-
const { response_format: t, ...s } = r;
|
|
26
|
-
return JSON.stringify(s);
|
|
27
|
-
}
|
|
28
|
-
} catch {
|
|
29
|
-
}
|
|
30
|
-
return e;
|
|
31
|
-
}
|
|
32
|
-
function w(e = {}) {
|
|
33
|
-
const { baseUrl: r } = h(e);
|
|
34
|
-
return A({
|
|
35
|
-
name: "aippy",
|
|
36
|
-
baseURL: r,
|
|
37
|
-
fetch: async (s, a) => {
|
|
38
|
-
const o = await i(), c = new Headers(a?.headers);
|
|
39
|
-
c.set("Authorization", `Bearer ${o}`);
|
|
40
|
-
let p = a;
|
|
41
|
-
return s.toString().includes("/images/generations") && a?.method?.toUpperCase() === "POST" && a?.body && (p = {
|
|
42
|
-
...a,
|
|
43
|
-
body: U(a.body)
|
|
44
|
-
}), globalThis.fetch(s, {
|
|
45
|
-
...p,
|
|
46
|
-
headers: c
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
const I = "/chat", T = "/completion", E = "/object";
|
|
52
|
-
async function C(e = {}) {
|
|
53
|
-
const { baseUrl: r } = u(e), t = await i(), s = e.model ?? g, a = e.system ?? _, o = e.api ?? `${r}${I}`, c = { Authorization: `Bearer ${t}` }, p = { model: s, system: a };
|
|
54
|
-
return {
|
|
55
|
-
transport: new f({
|
|
56
|
-
api: o,
|
|
57
|
-
headers: c,
|
|
58
|
-
body: p
|
|
59
|
-
})
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
async function N(e = {}) {
|
|
63
|
-
const { baseUrl: r } = u(e), t = await i();
|
|
64
|
-
return {
|
|
65
|
-
api: `${r}${T}`,
|
|
66
|
-
headers: { Authorization: `Bearer ${t}` }
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
async function k(e) {
|
|
70
|
-
const { schemaId: r, ...t } = e, { baseUrl: s } = u(t), a = await i();
|
|
71
|
-
return {
|
|
72
|
-
api: `${s}${E}`,
|
|
73
|
-
headers: { Authorization: `Bearer ${a}` },
|
|
74
|
-
schemaId: r
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
async function B(e = {}) {
|
|
78
|
-
const { baseUrl: r } = u(e), t = await i();
|
|
79
|
-
return {
|
|
80
|
-
api: `${r}${E}`,
|
|
81
|
-
headers: { Authorization: `Bearer ${t}` }
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
function D(e, r) {
|
|
85
|
-
const t = e.status;
|
|
86
|
-
if (r && typeof r == "object" && "error" in r) {
|
|
87
|
-
const s = r, a = s.error.code, o = a != null ? `AippyAIError_${a}` : `AippyAIError_${t}`;
|
|
88
|
-
return new n({
|
|
89
|
-
name: o,
|
|
90
|
-
message: s.error.message,
|
|
91
|
-
cause: {
|
|
92
|
-
type: s.error.type ?? void 0,
|
|
93
|
-
param: s.error.param ?? void 0,
|
|
94
|
-
status: t
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
return new n({
|
|
99
|
-
name: `AippyAIError_${t}`,
|
|
100
|
-
message: `Request failed with status ${t}`,
|
|
101
|
-
cause: { status: t }
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
function L() {
|
|
105
|
-
return new n({
|
|
106
|
-
name: "AippyAIError_MISSING_TOKEN",
|
|
107
|
-
message: "User token is required. Ensure user credentials are available via initUserBridge()."
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
function v() {
|
|
111
|
-
return new n({
|
|
112
|
-
name: "AippyAIError_REQUEST_ABORTED",
|
|
113
|
-
message: "Request was aborted"
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
function F(e) {
|
|
117
|
-
const r = e instanceof Error ? e.message : "Network request failed";
|
|
118
|
-
return new n({
|
|
119
|
-
name: "AippyAIError_NETWORK_ERROR",
|
|
120
|
-
message: r,
|
|
121
|
-
cause: e instanceof Error ? e : String(e)
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
function P(e) {
|
|
125
|
-
return new n({
|
|
126
|
-
name: "AippyAIError_PARSE_ERROR",
|
|
127
|
-
message: `Failed to parse response: ${e}`
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
export {
|
|
131
|
-
l as D,
|
|
132
|
-
I as U,
|
|
133
|
-
w as a,
|
|
134
|
-
C as b,
|
|
135
|
-
N as c,
|
|
136
|
-
k as d,
|
|
137
|
-
B as e,
|
|
138
|
-
T as f,
|
|
139
|
-
E as g,
|
|
140
|
-
d as h,
|
|
141
|
-
g as i,
|
|
142
|
-
_ as j,
|
|
143
|
-
v as k,
|
|
144
|
-
F as l,
|
|
145
|
-
L as m,
|
|
146
|
-
D as n,
|
|
147
|
-
P as p
|
|
148
|
-
};
|
package/dist/user/api.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { UserProfile } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Fetch user profile by ID from API
|
|
4
|
-
*/
|
|
5
|
-
export declare function fetchUserProfile(userId: string): Promise<UserProfile | null>;
|
|
6
|
-
/**
|
|
7
|
-
* Clear profile cache
|
|
8
|
-
*/
|
|
9
|
-
export declare function clearProfileCache(userId?: string): void;
|
package/dist/user/bridge.d.ts
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* User SDK Bridge
|
|
3
|
-
* Handles communication with:
|
|
4
|
-
* - iOS native layer via window.webkit.aippyListener
|
|
5
|
-
* - Parent window via postMessage (iframe scenario)
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* User credentials
|
|
9
|
-
*/
|
|
10
|
-
export interface IOSUserCredentials {
|
|
11
|
-
uid: string;
|
|
12
|
-
token: string;
|
|
13
|
-
apiBaseUrl?: string;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Check if running inside an iframe
|
|
17
|
-
*/
|
|
18
|
-
export declare function isInIframe(): boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Request user credentials from parent window (iframe scenario)
|
|
21
|
-
* Parent window should respond with postMessage containing credentials
|
|
22
|
-
*
|
|
23
|
-
* @param timeoutMs - Timeout in milliseconds (default: 5000)
|
|
24
|
-
* @returns Promise resolving to user credentials
|
|
25
|
-
*/
|
|
26
|
-
export declare function requestCredentialsFromParent(timeoutMs?: number): Promise<IOSUserCredentials>;
|
|
27
|
-
/**
|
|
28
|
-
* Try to get credentials from parent localStorage directly
|
|
29
|
-
* This works when same-origin, otherwise falls back to postMessage
|
|
30
|
-
*
|
|
31
|
-
* localStorage format:
|
|
32
|
-
* - token: JWT string
|
|
33
|
-
* - user: JSON string with { uid, nickName, ... }
|
|
34
|
-
*/
|
|
35
|
-
export declare function tryGetCredentialsFromParentStorage(): IOSUserCredentials | null;
|
|
36
|
-
/**
|
|
37
|
-
* Request user credentials from iOS native layer
|
|
38
|
-
* Uses aippyRuntime's message passing mechanism
|
|
39
|
-
*
|
|
40
|
-
* @param timeoutMs - Timeout in milliseconds (default: 5000)
|
|
41
|
-
* @returns Promise resolving to user credentials (empty if unavailable)
|
|
42
|
-
*/
|
|
43
|
-
export declare function requestCredentialsFromiOS(timeoutMs?: number): Promise<IOSUserCredentials>;
|
|
44
|
-
/**
|
|
45
|
-
* Receive credentials directly from iOS or parent window
|
|
46
|
-
* Called via: window.processUserCredentials(data)
|
|
47
|
-
*/
|
|
48
|
-
export declare function processUserCredentials(data: unknown): void;
|
|
49
|
-
/**
|
|
50
|
-
* Initialize bridge and expose to window
|
|
51
|
-
*/
|
|
52
|
-
export declare function initUserBridge(): void;
|
|
53
|
-
/**
|
|
54
|
-
* Auto-request credentials on SDK load
|
|
55
|
-
* Tries multiple sources in order:
|
|
56
|
-
* 1. iOS native bridge (if available)
|
|
57
|
-
* 2. Parent localStorage (if in iframe, same-origin)
|
|
58
|
-
* 3. Parent postMessage (if in iframe, cross-origin)
|
|
59
|
-
*/
|
|
60
|
-
export declare function autoRequestCredentials(): Promise<void>;
|
|
61
|
-
/**
|
|
62
|
-
* Get auth token asynchronously
|
|
63
|
-
* Waits for credentials if not already available
|
|
64
|
-
* @returns Promise resolving to token string, or "" if unavailable
|
|
65
|
-
*/
|
|
66
|
-
export declare function getAuthTokenAsync(): Promise<string>;
|
|
67
|
-
/**
|
|
68
|
-
* Get current user ID asynchronously
|
|
69
|
-
* Waits for credentials if not already available
|
|
70
|
-
* @returns Promise resolving to user ID string, or "" if unavailable
|
|
71
|
-
*/
|
|
72
|
-
export declare function getCurrentUserIdAsync(): Promise<string>;
|
|
73
|
-
/**
|
|
74
|
-
* Check if credentials have been received
|
|
75
|
-
*/
|
|
76
|
-
export declare function hasCredentials(): boolean;
|
|
77
|
-
/**
|
|
78
|
-
* Get cached credentials (synchronous, may be null if not yet received)
|
|
79
|
-
*/
|
|
80
|
-
export declare function getCachedCredentials(): IOSUserCredentials | null;
|
package/dist/user/config.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { UserSdkConfig } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Initialize user SDK configuration
|
|
4
|
-
*/
|
|
5
|
-
export declare function initUserSdk(config: Partial<UserSdkConfig>): void;
|
|
6
|
-
/**
|
|
7
|
-
* Get current user SDK configuration
|
|
8
|
-
*/
|
|
9
|
-
export declare function getUserSdkConfig(): UserSdkConfig;
|
|
10
|
-
/**
|
|
11
|
-
* Update auth token
|
|
12
|
-
*/
|
|
13
|
-
export declare function setAuthToken(token: string): void;
|
|
14
|
-
/**
|
|
15
|
-
* Update current user ID
|
|
16
|
-
*/
|
|
17
|
-
export declare function setCurrentUserId(userId: string | null): void;
|
|
18
|
-
/**
|
|
19
|
-
* Get current auth token synchronously
|
|
20
|
-
*/
|
|
21
|
-
export declare function getAuthToken(): string;
|
package/dist/user/hooks.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { UserProfileQueryResult, UserProfilesQueryResult, GetUserProfileByIdOptions, GetJoinedUserProfilesOptions } from './types';
|
|
2
|
-
import { getAuthToken } from './config';
|
|
3
|
-
/**
|
|
4
|
-
* Hook to get current user ID
|
|
5
|
-
* @returns Current user ID or null
|
|
6
|
-
*/
|
|
7
|
-
export declare function useCurrentUserId(): string | null;
|
|
8
|
-
/**
|
|
9
|
-
* Hook to get current auth token
|
|
10
|
-
* @returns Current auth token string
|
|
11
|
-
*/
|
|
12
|
-
export declare function useAuthToken(): string;
|
|
13
|
-
/**
|
|
14
|
-
* Hook to get current user's profile
|
|
15
|
-
* @returns Query result with current user profile data
|
|
16
|
-
*/
|
|
17
|
-
export declare function useGetCurrentUserProfileQuery(): UserProfileQueryResult;
|
|
18
|
-
/**
|
|
19
|
-
* Hook to get user profile by ID
|
|
20
|
-
* @param options - Options containing user ID to fetch
|
|
21
|
-
* @returns Query result with user profile data
|
|
22
|
-
*/
|
|
23
|
-
export declare function useGetUserProfileByIdQuery(options: GetUserProfileByIdOptions): UserProfileQueryResult;
|
|
24
|
-
/**
|
|
25
|
-
* Hook to get all joined user profiles
|
|
26
|
-
* @param options - Options for filtering users
|
|
27
|
-
* @returns Query result with user profiles array
|
|
28
|
-
*
|
|
29
|
-
* Note: This is a simplified implementation that only fetches the current user.
|
|
30
|
-
* In production, this would fetch all users from a users list API.
|
|
31
|
-
*/
|
|
32
|
-
export declare function useGetJoinedUserProfilesQuery(options?: GetJoinedUserProfilesOptions): UserProfilesQueryResult;
|
|
33
|
-
/**
|
|
34
|
-
* Synchronous function to get current user ID
|
|
35
|
-
* Use this in non-React contexts
|
|
36
|
-
*/
|
|
37
|
-
export declare function getCurrentUserId(): string | null;
|
|
38
|
-
export { getAuthToken };
|
package/dist/user/index.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* User SDK module
|
|
3
|
-
* Provides user profile fetching and session management
|
|
4
|
-
*/
|
|
5
|
-
export type { UserProfile, UserProfileQueryResult, UserProfilesQueryResult, GetUserProfileByIdOptions, GetJoinedUserProfilesOptions, FormatDateOptions, UserSessionInfoInterface, UserSdkConfig, } from './types';
|
|
6
|
-
export { initUserSdk, getUserSdkConfig, setAuthToken, setCurrentUserId, } from './config';
|
|
7
|
-
export { useCurrentUserId, useAuthToken, useGetCurrentUserProfileQuery, useGetUserProfileByIdQuery, useGetJoinedUserProfilesQuery, getCurrentUserId, getAuthToken, } from './hooks';
|
|
8
|
-
export { fetchUserProfile, clearProfileCache } from './api';
|
|
9
|
-
export { userSessionInfo } from './userSessionInfo';
|
|
10
|
-
export { isInIframe, requestCredentialsFromiOS, requestCredentialsFromParent, tryGetCredentialsFromParentStorage, initUserBridge, autoRequestCredentials, getAuthTokenAsync, getCurrentUserIdAsync, hasCredentials, getCachedCredentials, } from './bridge';
|
|
11
|
-
export type { IOSUserCredentials } from './bridge';
|
package/dist/user/index.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { f as r, b as a, h as t, l as n, j as u, g as i, k as o, e as d, i as C, c as f, d as l, r as g, s as U, a as h, t as c } from "../bridge-DdAH4txB.js";
|
|
2
|
-
import { e as k, f as y, g as P, a as m, u as A, b as S, d as G, c as T, h as q } from "../userSessionInfo-CBk9ywXi.js";
|
|
3
|
-
export {
|
|
4
|
-
r as autoRequestCredentials,
|
|
5
|
-
k as clearProfileCache,
|
|
6
|
-
y as fetchUserProfile,
|
|
7
|
-
a as getAuthToken,
|
|
8
|
-
t as getAuthTokenAsync,
|
|
9
|
-
n as getCachedCredentials,
|
|
10
|
-
P as getCurrentUserId,
|
|
11
|
-
u as getCurrentUserIdAsync,
|
|
12
|
-
i as getUserSdkConfig,
|
|
13
|
-
o as hasCredentials,
|
|
14
|
-
d as initUserBridge,
|
|
15
|
-
C as initUserSdk,
|
|
16
|
-
f as isInIframe,
|
|
17
|
-
l as requestCredentialsFromParent,
|
|
18
|
-
g as requestCredentialsFromiOS,
|
|
19
|
-
U as setAuthToken,
|
|
20
|
-
h as setCurrentUserId,
|
|
21
|
-
c as tryGetCredentialsFromParentStorage,
|
|
22
|
-
m as useAuthToken,
|
|
23
|
-
A as useCurrentUserId,
|
|
24
|
-
S as useGetCurrentUserProfileQuery,
|
|
25
|
-
G as useGetJoinedUserProfilesQuery,
|
|
26
|
-
T as useGetUserProfileByIdQuery,
|
|
27
|
-
q as userSessionInfo
|
|
28
|
-
};
|