@cloudparse/up-miniapps-sdk 0.1.0 → 0.1.2
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 +100 -31
- package/dist/index.browser.min.js +2 -2
- package/dist/index.browser.min.js.map +1 -7
- package/dist/index.d.mts +519 -0
- package/dist/index.d.ts +519 -4
- package/dist/index.js +336 -2
- package/dist/index.js.map +1 -7
- package/dist/index.mjs +307 -2
- package/dist/index.mjs.map +1 -7
- package/package.json +8 -7
- package/dist/bridge.d.ts +0 -9
- package/dist/sdk.d.ts +0 -98
- package/dist/types.d.ts +0 -75
package/dist/index.js
CHANGED
|
@@ -1,2 +1,336 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
MiniAppSDK: () => MiniAppSDK,
|
|
24
|
+
UIEvent: () => UIEvent,
|
|
25
|
+
default: () => index_default,
|
|
26
|
+
sdk: () => sdk
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(index_exports);
|
|
29
|
+
|
|
30
|
+
// src/bridge.ts
|
|
31
|
+
var Bridge = class {
|
|
32
|
+
callbacks = {};
|
|
33
|
+
eventListeners = {};
|
|
34
|
+
/**
|
|
35
|
+
* Registers a global listener for messages coming from the native shell.
|
|
36
|
+
* Also listens for standard browser `message` events to support multiple
|
|
37
|
+
* communication channels (e.g., React Native WebView postMessage).
|
|
38
|
+
*/
|
|
39
|
+
constructor() {
|
|
40
|
+
if (typeof window !== "undefined") {
|
|
41
|
+
window.__MiniAppBridge = {
|
|
42
|
+
onNativeMessage: (envelope) => this.handleNativeMessage(envelope)
|
|
43
|
+
};
|
|
44
|
+
window.addEventListener("message", (event) => {
|
|
45
|
+
try {
|
|
46
|
+
const data = typeof event.data === "string" ? JSON.parse(event.data) : event.data;
|
|
47
|
+
this.handleNativeMessage(data);
|
|
48
|
+
} catch (_e) {
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Internal handler for all incoming messages from the native shell.
|
|
55
|
+
* Matches incoming payloads to either pending callbacks or event listeners.
|
|
56
|
+
*
|
|
57
|
+
* @internal
|
|
58
|
+
* @param envelope The message envelope received from native code.
|
|
59
|
+
*/
|
|
60
|
+
handleNativeMessage(envelope) {
|
|
61
|
+
if (!envelope || typeof envelope !== "object") return;
|
|
62
|
+
if (envelope.callbackId && typeof envelope.callbackId === "string" && this.callbacks[envelope.callbackId]) {
|
|
63
|
+
const { callbackId } = envelope;
|
|
64
|
+
const { resolve, reject } = this.callbacks[callbackId];
|
|
65
|
+
if (envelope.success === false || envelope.error) {
|
|
66
|
+
reject(envelope.error || "Unknown error");
|
|
67
|
+
} else {
|
|
68
|
+
resolve(envelope.value ?? envelope.payload ?? envelope);
|
|
69
|
+
}
|
|
70
|
+
delete this.callbacks[callbackId];
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (envelope.event && typeof envelope.event === "string") {
|
|
74
|
+
const listeners = this.eventListeners[envelope.event];
|
|
75
|
+
if (listeners) {
|
|
76
|
+
for (const listener of listeners) {
|
|
77
|
+
try {
|
|
78
|
+
listener(envelope.payload || envelope.value);
|
|
79
|
+
} catch (e) {
|
|
80
|
+
console.error(`Error in event listener for ${envelope.event}:`, e);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Subscribes to a pushed event from the native shell.
|
|
88
|
+
*
|
|
89
|
+
* @param event The event name to listen for.
|
|
90
|
+
* @param callback Function to execute when the event occurs.
|
|
91
|
+
* @returns An unsubscription function.
|
|
92
|
+
*/
|
|
93
|
+
on(event, callback) {
|
|
94
|
+
if (!this.eventListeners[event]) {
|
|
95
|
+
this.eventListeners[event] = [];
|
|
96
|
+
}
|
|
97
|
+
this.eventListeners[event].push(callback);
|
|
98
|
+
return () => this.off(event, callback);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Unsubscribes a specific callback from an event.
|
|
102
|
+
*
|
|
103
|
+
* @param event The event name.
|
|
104
|
+
* @param callback The callback function to remove.
|
|
105
|
+
*/
|
|
106
|
+
off(event, callback) {
|
|
107
|
+
if (!this.eventListeners[event]) return;
|
|
108
|
+
this.eventListeners[event] = this.eventListeners[event].filter(
|
|
109
|
+
(cb) => cb !== callback
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Sends a message to the native shell and waits for a response.
|
|
114
|
+
*
|
|
115
|
+
* @template T The expected response type.
|
|
116
|
+
* @param type The action type (e.g., "GET_LOCATION").
|
|
117
|
+
* @param payload Data associated with the action.
|
|
118
|
+
* @returns A promise that resolves with the native response.
|
|
119
|
+
*/
|
|
120
|
+
send(type, payload) {
|
|
121
|
+
return new Promise((resolve, reject) => {
|
|
122
|
+
const callbackId = `${type}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
123
|
+
this.callbacks[callbackId] = {
|
|
124
|
+
reject,
|
|
125
|
+
resolve
|
|
126
|
+
};
|
|
127
|
+
const message = {
|
|
128
|
+
callbackId,
|
|
129
|
+
payload,
|
|
130
|
+
type
|
|
131
|
+
};
|
|
132
|
+
const win = window;
|
|
133
|
+
if (win.ReactNativeWebView?.postMessage) {
|
|
134
|
+
win.ReactNativeWebView.postMessage(JSON.stringify(message));
|
|
135
|
+
} else {
|
|
136
|
+
console.warn(
|
|
137
|
+
"UP Bridge not available. Are you running inside the UP Shell?"
|
|
138
|
+
);
|
|
139
|
+
delete this.callbacks[callbackId];
|
|
140
|
+
reject(new Error("Bridge not available"));
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
// src/sdk.ts
|
|
147
|
+
var MiniAppSDK = class {
|
|
148
|
+
bridge;
|
|
149
|
+
constructor() {
|
|
150
|
+
this.bridge = new Bridge();
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* The starting point for the Mini-App. Must be called before any other SDK methods.
|
|
154
|
+
* @param options The options to provide to the shell app
|
|
155
|
+
*/
|
|
156
|
+
initialize(options) {
|
|
157
|
+
return this.bridge.send("INITIALIZE", options);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Local SQLite Storage.
|
|
161
|
+
* Data is persisted on the device and is isolated per Mini-App.
|
|
162
|
+
*/
|
|
163
|
+
storage = {
|
|
164
|
+
/** Retrieves a value by key. */
|
|
165
|
+
get: (key) => this.bridge.send("STORAGE_GET", { key }),
|
|
166
|
+
/** Retrieves all key-value pairs stored for this Mini-App. */
|
|
167
|
+
getAll: () => this.bridge.send("STORAGE_GET_ALL"),
|
|
168
|
+
/** Sets a value for a specific key. */
|
|
169
|
+
set: (key, value) => this.bridge.send("STORAGE_SET", { key, value })
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* Hardware-level Secure Storage.
|
|
173
|
+
* Data is stored in the device's secure enclave (Keychain/Keystore) and is isolated per Mini-App.
|
|
174
|
+
*/
|
|
175
|
+
secureStore = {
|
|
176
|
+
/** Retrieves a value by key from secure storage. */
|
|
177
|
+
get: (key) => this.bridge.send("SECURE_GET", { key }),
|
|
178
|
+
/** Sets a value for a specific key in secure storage. */
|
|
179
|
+
set: (key, value) => this.bridge.send("SECURE_SET", { key, value })
|
|
180
|
+
};
|
|
181
|
+
/**
|
|
182
|
+
* Device Location services.
|
|
183
|
+
*/
|
|
184
|
+
location = {
|
|
185
|
+
/** Retrieves the current GPS position of the device. */
|
|
186
|
+
getCurrentPosition: () => this.bridge.send("GET_LOCATION")
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* Identity & Profile management.
|
|
190
|
+
*/
|
|
191
|
+
user = {
|
|
192
|
+
/**
|
|
193
|
+
* Fetch a short-lived Scoped Identity Token (JWT).
|
|
194
|
+
* This token is signed by the UP Hub and can be verified by your backend.
|
|
195
|
+
* @param scopes Optional list of scopes requested (e.g., ['profile', 'email']).
|
|
196
|
+
*/
|
|
197
|
+
getIdentityToken: (scopes) => this.bridge.send("GET_IDENTITY_TOKEN", { scopes }),
|
|
198
|
+
/**
|
|
199
|
+
* Fetch user profile data.
|
|
200
|
+
* @param fields Optional list of specific fields to retrieve (e.g., ['fullName', 'username']).
|
|
201
|
+
*/
|
|
202
|
+
getProfile: (fields) => this.bridge.send("GET_USER_PROFILE", { fields })
|
|
203
|
+
};
|
|
204
|
+
/**
|
|
205
|
+
* Explicit Permission Management.
|
|
206
|
+
* Allows requesting access to sensitive device features or user data.
|
|
207
|
+
*/
|
|
208
|
+
permission = {
|
|
209
|
+
/**
|
|
210
|
+
* Explicitly request access to sensitive data.
|
|
211
|
+
* @param type The type of permission to request ('location' or 'profile').
|
|
212
|
+
* @param fields If requesting 'profile', the specific fields required.
|
|
213
|
+
*/
|
|
214
|
+
request: ((type, fields) => {
|
|
215
|
+
return this.bridge.send("REQUEST_PERMISSION", { fields, type });
|
|
216
|
+
})
|
|
217
|
+
};
|
|
218
|
+
/**
|
|
219
|
+
* Payments integration.
|
|
220
|
+
*/
|
|
221
|
+
payment = {
|
|
222
|
+
/**
|
|
223
|
+
* Triggers the native payment flow.
|
|
224
|
+
* @param payload Amount, currency, and itemized list for the payment.
|
|
225
|
+
*/
|
|
226
|
+
request: (payload) => this.bridge.send("PAYMENT_REQUEST", payload)
|
|
227
|
+
};
|
|
228
|
+
/**
|
|
229
|
+
* Live Activities & Notifications.
|
|
230
|
+
* Allows the Mini-App to display real-time updates in the host shell.
|
|
231
|
+
*/
|
|
232
|
+
activity = {
|
|
233
|
+
/**
|
|
234
|
+
* Starts a new live activity.
|
|
235
|
+
* @param id Unique identifier for the activity.
|
|
236
|
+
* @param title Display title for the activity.
|
|
237
|
+
* @param status Initial status message.
|
|
238
|
+
*/
|
|
239
|
+
start: (id, title, status) => this.bridge.send("START_ACTIVITY", { id, status, title })
|
|
240
|
+
};
|
|
241
|
+
/**
|
|
242
|
+
* Haptic feedback.
|
|
243
|
+
*/
|
|
244
|
+
haptic = {
|
|
245
|
+
/**
|
|
246
|
+
* Triggers a haptic vibration on the device.
|
|
247
|
+
* @param style The style of haptic feedback (e.g., 'light', 'medium', 'heavy', 'success', 'warning', 'error').
|
|
248
|
+
*/
|
|
249
|
+
trigger: (style) => this.bridge.send("TRIGGER_HAPTIC", { style })
|
|
250
|
+
};
|
|
251
|
+
/**
|
|
252
|
+
* Network Proxy.
|
|
253
|
+
* Allows the Mini-App to make network requests through the host shell to bypass CORS or use host-level authentication.
|
|
254
|
+
*/
|
|
255
|
+
network = {
|
|
256
|
+
/**
|
|
257
|
+
* Performs a network request via the host shell.
|
|
258
|
+
* @param options Request method, URL, headers, and body.
|
|
259
|
+
*/
|
|
260
|
+
request: (options) => this.bridge.send("NETWORK_REQUEST", options)
|
|
261
|
+
};
|
|
262
|
+
/**
|
|
263
|
+
* Fidelity & Rewards program integration.
|
|
264
|
+
*/
|
|
265
|
+
fidelity = {
|
|
266
|
+
/** Returns current fidelity balance. */
|
|
267
|
+
getFidelityBalance: () => this.bridge.send("GET_FIDELITY_BALANCE"),
|
|
268
|
+
/**
|
|
269
|
+
* Retrieves fidelity transaction history.
|
|
270
|
+
* @param params Filtering and pagination parameters.
|
|
271
|
+
*/
|
|
272
|
+
getFidelityHistory: (params) => this.bridge.send("GET_FIDELITY_HISTORY", params),
|
|
273
|
+
/**
|
|
274
|
+
* Authorize spending fidelity points (FPoints) via Two-Phase Authorization.
|
|
275
|
+
* @param intentUuid UUID generated by your backend for the transaction.
|
|
276
|
+
*/
|
|
277
|
+
spendFPoints: (intentUuid) => this.bridge.send("SPEND_FPOINTS", { intentUuid })
|
|
278
|
+
};
|
|
279
|
+
/**
|
|
280
|
+
* UI and Navigation controls.
|
|
281
|
+
*/
|
|
282
|
+
ui = {
|
|
283
|
+
/** Closes the Mini-App and returns to the host shell. */
|
|
284
|
+
exit: () => this.bridge.send("EXIT"),
|
|
285
|
+
/**
|
|
286
|
+
* Configures native scroll behaviors like Pull-to-Refresh and Infinite Scroll.
|
|
287
|
+
* @param config Scroll configuration for top/bottom detection.
|
|
288
|
+
*/
|
|
289
|
+
setScrollConfig: (config) => this.bridge.send("SET_SCROLL_CONFIG", config)
|
|
290
|
+
};
|
|
291
|
+
/**
|
|
292
|
+
* Debug controls
|
|
293
|
+
*/
|
|
294
|
+
debug = {
|
|
295
|
+
/**
|
|
296
|
+
* Log to the shell app
|
|
297
|
+
* @param message
|
|
298
|
+
*/
|
|
299
|
+
log: (...message) => this.bridge.send("DEBUG_LOG", { message })
|
|
300
|
+
};
|
|
301
|
+
/**
|
|
302
|
+
* Registers a callback for a specific event from the native shell.
|
|
303
|
+
* @param event The name of the event to listen for.
|
|
304
|
+
* @param callback The function to execute when the event is triggered.
|
|
305
|
+
* @returns A function to unregister the listener.
|
|
306
|
+
*/
|
|
307
|
+
on(event, callback) {
|
|
308
|
+
return this.bridge.on(event, callback);
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Unregisters a previously registered event listener.
|
|
312
|
+
* @param event The name of the event.
|
|
313
|
+
* @param callback The callback function to remove.
|
|
314
|
+
*/
|
|
315
|
+
off(event, callback) {
|
|
316
|
+
this.bridge.off(event, callback);
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
var sdk = new MiniAppSDK();
|
|
320
|
+
|
|
321
|
+
// src/types/types.ts
|
|
322
|
+
var UIEvent = /* @__PURE__ */ ((UIEvent2) => {
|
|
323
|
+
UIEvent2["TOP_SCROLL_MORE"] = "TOP_SCROLL_MORE";
|
|
324
|
+
UIEvent2["BOTTOM_SCROLL_MORE"] = "BOTTOM_SCROLL_MORE";
|
|
325
|
+
return UIEvent2;
|
|
326
|
+
})(UIEvent || {});
|
|
327
|
+
|
|
328
|
+
// src/index.ts
|
|
329
|
+
var index_default = sdk;
|
|
330
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
331
|
+
0 && (module.exports = {
|
|
332
|
+
MiniAppSDK,
|
|
333
|
+
UIEvent,
|
|
334
|
+
sdk
|
|
335
|
+
});
|
|
336
|
+
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/index.ts", "../src/bridge.ts", "../src/sdk.ts"],
|
|
4
|
-
"sourcesContent": ["export { MiniAppSDK, sdk } from \"@sdk/sdk\";\nexport * from \"@sdk/types\";\n\nimport { sdk } from \"@sdk/sdk\";\nexport default sdk;\n", "import type { BridgeEnvelope } from \"@sdk/types\";\n\nexport class Bridge {\n private callbacks: Record<\n string,\n { resolve: (val: unknown) => void; reject: (err: unknown) => void }\n > = {};\n private eventListeners: Record<string, ((data: unknown) => void)[]> = {};\n\n constructor() {\n if (typeof window !== \"undefined\") {\n // Set up the global bridge receiver for React Native WebView\n (window as unknown as { __MiniAppBridge: unknown }).__MiniAppBridge = {\n onNativeMessage: (envelope: BridgeEnvelope) =>\n this.handleNativeMessage(envelope),\n };\n\n // Also listen for postMessage events\n window.addEventListener(\"message\", (event) => {\n try {\n const data =\n typeof event.data === \"string\"\n ? JSON.parse(event.data)\n : event.data;\n this.handleNativeMessage(data);\n } catch (_e) {\n // Ignore non-JSON messages\n }\n });\n }\n }\n\n private handleNativeMessage(envelope: BridgeEnvelope) {\n if (!envelope || typeof envelope !== \"object\") return;\n\n // 1. Handle Response Callbacks\n if (\n envelope.callbackId &&\n typeof envelope.callbackId === \"string\" &&\n this.callbacks[envelope.callbackId]\n ) {\n const { callbackId } = envelope;\n const { resolve, reject } = this.callbacks[callbackId];\n\n if (envelope.success === false || envelope.error) {\n reject(envelope.error || \"Unknown error\");\n } else {\n resolve(\n envelope.value !== undefined\n ? envelope.value\n : envelope.payload || envelope,\n );\n }\n\n delete this.callbacks[callbackId];\n return;\n }\n\n // 2. Handle Pushed Events\n if (envelope.event && typeof envelope.event === \"string\") {\n const listeners = this.eventListeners[envelope.event];\n if (listeners) {\n for (const listener of listeners) {\n try {\n listener(envelope.payload || envelope.value);\n } catch (e) {\n console.error(`Error in event listener for ${envelope.event}:`, e);\n }\n }\n }\n }\n }\n\n public on(event: string, callback: (data: unknown) => void) {\n if (!this.eventListeners[event]) {\n this.eventListeners[event] = [];\n }\n this.eventListeners[event].push(callback);\n return () => this.off(event, callback);\n }\n\n public off(event: string, callback: (data: unknown) => void) {\n if (!this.eventListeners[event]) return;\n this.eventListeners[event] = this.eventListeners[event].filter(\n (cb) => cb !== callback,\n );\n }\n\n public send<T = unknown>(type: string, payload?: unknown): Promise<T> {\n return new Promise((resolve, reject) => {\n const callbackId = `${type}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;\n this.callbacks[callbackId] = {\n reject,\n resolve: resolve as (val: unknown) => void,\n };\n\n const message = {\n callbackId,\n payload,\n type,\n };\n\n const win = window as unknown as {\n ReactNativeWebView?: { postMessage: (msg: string) => void };\n };\n\n if (win.ReactNativeWebView?.postMessage) {\n win.ReactNativeWebView.postMessage(JSON.stringify(message));\n } else {\n console.warn(\n \"UP Bridge not available. Are you running inside the UP Shell?\",\n );\n delete this.callbacks[callbackId];\n reject(new Error(\"Bridge not available\"));\n }\n });\n }\n}\n", "import { Bridge } from \"@sdk/bridge\";\nimport type {\n FidelityBalance,\n FidelityHistoryParams,\n FidelityTransaction,\n HapticStyle,\n LocationData,\n NetworkOptions,\n NetworkResponse,\n PaymentRequest,\n UserProfile,\n} from \"@sdk/types\";\n\nexport class MiniAppSDK {\n private bridge: Bridge;\n\n constructor() {\n this.bridge = new Bridge();\n }\n\n /**\n * Local SQLite Storage (Isolated per Mini-App)\n */\n public storage = {\n get: (key: string): Promise<string | null> =>\n this.bridge.send(\"STORAGE_GET\", { key }),\n getAll: (): Promise<Record<string, string>> =>\n this.bridge.send(\"STORAGE_GET_ALL\"),\n set: (key: string, value: string): Promise<void> =>\n this.bridge.send(\"STORAGE_SET\", { key, value }),\n };\n\n /**\n * Hardware-level Secure Storage (Isolated per Mini-App)\n */\n public secureStore = {\n get: (key: string): Promise<string | null> =>\n this.bridge.send(\"SECURE_GET\", { key }),\n set: (key: string, value: string): Promise<void> =>\n this.bridge.send(\"SECURE_SET\", { key, value }),\n };\n\n /**\n * Device Location\n */\n public location = {\n getCurrentPosition: (): Promise<LocationData> =>\n this.bridge.send(\"GET_LOCATION\"),\n };\n\n /**\n * Identity & Profile\n */\n public user = {\n /**\n * Fetch a short-lived Scoped Identity Token (JWT) signed by the UP Hub.\n */\n getIdentityToken: (scopes?: string[]): Promise<string> =>\n this.bridge.send(\"GET_IDENTITY_TOKEN\", { scopes }),\n /**\n * Fetch user profile data.\n */\n getProfile: <T extends keyof UserProfile>(\n fields?: T[],\n ): Promise<Partial<UserProfile>> =>\n this.bridge.send(\"GET_USER_PROFILE\", { fields }),\n };\n\n /**\n * Explicit Permission Management\n */\n public permission = {\n request: ((type: \"location\" | \"profile\", fields?: string[]) => {\n return this.bridge.send(\"REQUEST_PERMISSION\", { fields, type });\n }) as {\n (type: \"location\"): Promise<boolean>;\n (type: \"profile\", fields: (keyof UserProfile)[]): Promise<boolean>;\n },\n };\n\n /**\n * Payments\n */\n public payment = {\n request: (\n payload: PaymentRequest,\n ): Promise<{ success: true; transactionId: string }> =>\n this.bridge.send(\"PAYMENT_REQUEST\", payload),\n };\n\n /**\n * Live Activities & Notifications\n */\n public activity = {\n start: (id: string, title: string, status: string): Promise<void> =>\n this.bridge.send(\"START_ACTIVITY\", { id, status, title }),\n };\n\n /**\n * Haptics\n */\n public haptic = {\n trigger: (style: HapticStyle): Promise<void> =>\n this.bridge.send(\"TRIGGER_HAPTIC\", { style }),\n };\n\n /**\n * Network Proxy\n */\n public network = {\n request: (options: NetworkOptions): Promise<NetworkResponse> =>\n this.bridge.send(\"NETWORK_REQUEST\", options),\n };\n\n /**\n * Fidelity & Rewards\n */\n public fidelity = {\n getFidelityBalance: (): Promise<FidelityBalance> =>\n this.bridge.send(\"GET_FIDELITY_BALANCE\"),\n getFidelityHistory: (\n params?: FidelityHistoryParams,\n ): Promise<FidelityTransaction[]> =>\n this.bridge.send(\"GET_FIDELITY_HISTORY\", params),\n spendFPoints: (\n intentUuid: string,\n ): Promise<{ success: boolean; transactionId: string }> =>\n this.bridge.send(\"SPEND_FPOINTS\", { intentUuid }),\n };\n\n /**\n * Navigation & UI\n */\n public ui = {\n exit: (): Promise<void> => this.bridge.send(\"EXIT\"),\n };\n\n /**\n * Event Listeners\n */\n public on(event: string, callback: (data: unknown) => void) {\n return this.bridge.on(event, callback);\n }\n\n public off(event: string, callback: (data: unknown) => void) {\n this.bridge.off(event, callback);\n }\n}\n\nexport const sdk = new MiniAppSDK();\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,EAAA,YAAAC,EAAA,QAAAC,IAAA,eAAAC,EAAAL,GCEO,IAAMM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GACjB,KAAK,OAAO,KAAK,qBAAsB,CAAE,OAAAA,CAAO,CAAC,EAInD,WACEC,GAEA,KAAK,OAAO,KAAK,mBAAoB,CAAE,OAAAA,CAAO,CAAC,CACnD,EAKO,WAAa,CAClB,QAAU,CAACC,EAA8BD,IAChC,KAAK,OAAO,KAAK,qBAAsB,CAAE,OAAAA,EAAQ,KAAAC,CAAK,CAAC,CAKlE,EAKO,QAAU,CACf,QACEC,GAEA,KAAK,OAAO,KAAK,kBAAmBA,CAAO,CAC/C,EAKO,SAAW,CAChB,MAAO,CAACC,EAAYC,EAAeC,IACjC,KAAK,OAAO,KAAK,iBAAkB,CAAE,GAAAF,EAAI,OAAAE,EAAQ,MAAAD,CAAM,CAAC,CAC5D,EAKO,OAAS,CACd,QAAUE,GACR,KAAK,OAAO,KAAK,iBAAkB,CAAE,MAAAA,CAAM,CAAC,CAChD,EAKO,QAAU,CACf,QAAUC,GACR,KAAK,OAAO,KAAK,kBAAmBA,CAAO,CAC/C,EAKO,SAAW,CAChB,mBAAoB,IAClB,KAAK,OAAO,KAAK,sBAAsB,EACzC,mBACEC,GAEA,KAAK,OAAO,KAAK,uBAAwBA,CAAM,EACjD,aACEC,GAEA,KAAK,OAAO,KAAK,gBAAiB,CAAE,WAAAA,CAAW,CAAC,CACpD,EAKO,GAAK,CACV,KAAM,IAAqB,KAAK,OAAO,KAAK,MAAM,CACpD,EAKO,GAAGC,EAAeC,EAAmC,CAC1D,OAAO,KAAK,OAAO,GAAGD,EAAOC,CAAQ,CACvC,CAEO,IAAID,EAAeC,EAAmC,CAC3D,KAAK,OAAO,IAAID,EAAOC,CAAQ,CACjC,CACF,EAEaC,EAAM,IAAIjB,EFjJvB,IAAOkB,EAAQC",
|
|
6
|
-
"names": ["src_exports", "__export", "MiniAppSDK", "src_default", "sdk", "__toCommonJS", "Bridge", "envelope", "event", "data", "callbackId", "resolve", "reject", "listeners", "listener", "e", "callback", "cb", "type", "payload", "message", "win", "MiniAppSDK", "Bridge", "key", "value", "scopes", "fields", "type", "payload", "id", "title", "status", "style", "options", "params", "intentUuid", "event", "callback", "sdk", "src_default", "sdk"]
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/bridge.ts","../src/sdk.ts","../src/types/types.ts"],"sourcesContent":["export { MiniAppSDK, sdk } from \"@miniapps-sdk/sdk\";\nexport * from \"@miniapps-sdk/types\";\n\nimport { sdk } from \"@miniapps-sdk/sdk\";\nexport default sdk;\n","import type { IBridgeEnvelope } from \"@miniapps-sdk/types\";\n\n/**\n * The Bridge handles low-level communication between the Mini-App WebView\n * and the Native Host Shell (iOS/Android).\n *\n * It manages asynchronous request-response cycles via callbacks and\n * supports subscription to pushed events from the native environment.\n */\nexport class Bridge {\n private callbacks: Record<\n string,\n { resolve: (val: unknown) => void; reject: (err: unknown) => void }\n > = {};\n private eventListeners: Record<string, ((data: unknown) => void)[]> = {};\n\n /**\n * Registers a global listener for messages coming from the native shell.\n * Also listens for standard browser `message` events to support multiple\n * communication channels (e.g., React Native WebView postMessage).\n */\n constructor() {\n if (typeof window !== \"undefined\") {\n // Set up the global bridge receiver for React Native WebView\n (window as unknown as { __MiniAppBridge: unknown }).__MiniAppBridge = {\n onNativeMessage: (envelope: IBridgeEnvelope) =>\n this.handleNativeMessage(envelope),\n };\n\n // Also listen for postMessage events\n window.addEventListener(\"message\", (event) => {\n try {\n const data =\n typeof event.data === \"string\"\n ? JSON.parse(event.data)\n : event.data;\n this.handleNativeMessage(data);\n } catch (_e) {\n // Ignore non-JSON messages\n }\n });\n }\n }\n\n /**\n * Internal handler for all incoming messages from the native shell.\n * Matches incoming payloads to either pending callbacks or event listeners.\n *\n * @internal\n * @param envelope The message envelope received from native code.\n */\n private handleNativeMessage(envelope: IBridgeEnvelope) {\n if (!envelope || typeof envelope !== \"object\") return;\n\n // 1. Handle Response Callbacks\n if (\n envelope.callbackId &&\n typeof envelope.callbackId === \"string\" &&\n this.callbacks[envelope.callbackId]\n ) {\n const { callbackId } = envelope;\n const { resolve, reject } = this.callbacks[callbackId];\n\n if (envelope.success === false || envelope.error) {\n reject(envelope.error || \"Unknown error\");\n } else {\n resolve(envelope.value ?? envelope.payload ?? envelope);\n }\n\n delete this.callbacks[callbackId];\n return;\n }\n\n // 2. Handle Pushed Events\n if (envelope.event && typeof envelope.event === \"string\") {\n const listeners = this.eventListeners[envelope.event];\n if (listeners) {\n for (const listener of listeners) {\n try {\n listener(envelope.payload || envelope.value);\n } catch (e) {\n console.error(`Error in event listener for ${envelope.event}:`, e);\n }\n }\n }\n }\n }\n\n /**\n * Subscribes to a pushed event from the native shell.\n *\n * @param event The event name to listen for.\n * @param callback Function to execute when the event occurs.\n * @returns An unsubscription function.\n */\n public on(event: string, callback: (data: unknown) => void) {\n if (!this.eventListeners[event]) {\n this.eventListeners[event] = [];\n }\n this.eventListeners[event].push(callback);\n return () => this.off(event, callback);\n }\n\n /**\n * Unsubscribes a specific callback from an event.\n *\n * @param event The event name.\n * @param callback The callback function to remove.\n */\n public off(event: string, callback: (data: unknown) => void) {\n if (!this.eventListeners[event]) return;\n this.eventListeners[event] = this.eventListeners[event].filter(\n (cb) => cb !== callback,\n );\n }\n\n /**\n * Sends a message to the native shell and waits for a response.\n *\n * @template T The expected response type.\n * @param type The action type (e.g., \"GET_LOCATION\").\n * @param payload Data associated with the action.\n * @returns A promise that resolves with the native response.\n */\n public send<T = unknown>(type: string, payload?: unknown): Promise<T> {\n return new Promise((resolve, reject) => {\n const callbackId = `${type}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;\n this.callbacks[callbackId] = {\n reject,\n resolve: resolve as (val: unknown) => void,\n };\n\n const message = {\n callbackId,\n payload,\n type,\n };\n\n const win = window as unknown as {\n ReactNativeWebView?: { postMessage: (msg: string) => void };\n };\n\n if (win.ReactNativeWebView?.postMessage) {\n win.ReactNativeWebView.postMessage(JSON.stringify(message));\n } else {\n console.warn(\n \"UP Bridge not available. Are you running inside the UP Shell?\",\n );\n delete this.callbacks[callbackId];\n reject(new Error(\"Bridge not available\"));\n }\n });\n }\n}\n","import { Bridge } from \"@miniapps-sdk/bridge\";\nimport type {\n HapticStyleType,\n IFidelityBalance,\n IFidelityHistoryParams,\n IFidelityTransaction,\n IInitializationOptions,\n IInitializationResponse,\n ILocationData,\n INetworkOptions,\n INetworkResponse,\n IPaymentRequest,\n IUserProfile,\n ScrollConfig,\n SDKEvent,\n} from \"@miniapps-sdk/types/types\";\n\n/**\n * Main SDK for UP Mini-Apps.\n * Provides access to native device features, storage, identity, and shell UI.\n */\nexport class MiniAppSDK {\n private bridge: Bridge;\n\n constructor() {\n this.bridge = new Bridge();\n }\n\n /**\n * The starting point for the Mini-App. Must be called before any other SDK methods.\n * @param options The options to provide to the shell app\n */\n public initialize(\n options: IInitializationOptions,\n ): Promise<IInitializationResponse> {\n return this.bridge.send(\"INITIALIZE\", options);\n }\n\n /**\n * Local SQLite Storage.\n * Data is persisted on the device and is isolated per Mini-App.\n */\n public storage = {\n /** Retrieves a value by key. */\n get: (key: string): Promise<string | null> =>\n this.bridge.send(\"STORAGE_GET\", { key }),\n /** Retrieves all key-value pairs stored for this Mini-App. */\n getAll: (): Promise<Record<string, string>> =>\n this.bridge.send(\"STORAGE_GET_ALL\"),\n /** Sets a value for a specific key. */\n set: (key: string, value: string): Promise<void> =>\n this.bridge.send(\"STORAGE_SET\", { key, value }),\n };\n\n /**\n * Hardware-level Secure Storage.\n * Data is stored in the device's secure enclave (Keychain/Keystore) and is isolated per Mini-App.\n */\n public secureStore = {\n /** Retrieves a value by key from secure storage. */\n get: (key: string): Promise<string | null> =>\n this.bridge.send(\"SECURE_GET\", { key }),\n /** Sets a value for a specific key in secure storage. */\n set: (key: string, value: string): Promise<void> =>\n this.bridge.send(\"SECURE_SET\", { key, value }),\n };\n\n /**\n * Device Location services.\n */\n public location = {\n /** Retrieves the current GPS position of the device. */\n getCurrentPosition: (): Promise<ILocationData> =>\n this.bridge.send(\"GET_LOCATION\"),\n };\n\n /**\n * Identity & Profile management.\n */\n public user = {\n /**\n * Fetch a short-lived Scoped Identity Token (JWT).\n * This token is signed by the UP Hub and can be verified by your backend.\n * @param scopes Optional list of scopes requested (e.g., ['profile', 'email']).\n */\n getIdentityToken: (scopes?: string[]): Promise<string> =>\n this.bridge.send(\"GET_IDENTITY_TOKEN\", { scopes }),\n /**\n * Fetch user profile data.\n * @param fields Optional list of specific fields to retrieve (e.g., ['fullName', 'username']).\n */\n getProfile: <T extends keyof IUserProfile>(\n fields?: T[],\n ): Promise<Partial<IUserProfile>> =>\n this.bridge.send(\"GET_USER_PROFILE\", { fields }),\n };\n\n /**\n * Explicit Permission Management.\n * Allows requesting access to sensitive device features or user data.\n */\n public permission = {\n /**\n * Explicitly request access to sensitive data.\n * @param type The type of permission to request ('location' or 'profile').\n * @param fields If requesting 'profile', the specific fields required.\n */\n request: ((type: \"location\" | \"profile\", fields?: string[]) => {\n return this.bridge.send(\"REQUEST_PERMISSION\", { fields, type });\n }) as {\n (type: \"location\"): Promise<boolean>;\n (type: \"profile\", fields: (keyof IUserProfile)[]): Promise<boolean>;\n },\n };\n\n /**\n * Payments integration.\n */\n public payment = {\n /**\n * Triggers the native payment flow.\n * @param payload Amount, currency, and itemized list for the payment.\n */\n request: (\n payload: IPaymentRequest,\n ): Promise<{ success: true; transactionId: string }> =>\n this.bridge.send(\"PAYMENT_REQUEST\", payload),\n };\n\n /**\n * Live Activities & Notifications.\n * Allows the Mini-App to display real-time updates in the host shell.\n */\n public activity = {\n /**\n * Starts a new live activity.\n * @param id Unique identifier for the activity.\n * @param title Display title for the activity.\n * @param status Initial status message.\n */\n start: (id: string, title: string, status: string): Promise<void> =>\n this.bridge.send(\"START_ACTIVITY\", { id, status, title }),\n };\n\n /**\n * Haptic feedback.\n */\n public haptic = {\n /**\n * Triggers a haptic vibration on the device.\n * @param style The style of haptic feedback (e.g., 'light', 'medium', 'heavy', 'success', 'warning', 'error').\n */\n trigger: (style: HapticStyleType): Promise<void> =>\n this.bridge.send(\"TRIGGER_HAPTIC\", { style }),\n };\n\n /**\n * Network Proxy.\n * Allows the Mini-App to make network requests through the host shell to bypass CORS or use host-level authentication.\n */\n public network = {\n /**\n * Performs a network request via the host shell.\n * @param options Request method, URL, headers, and body.\n */\n request: (options: INetworkOptions): Promise<INetworkResponse> =>\n this.bridge.send(\"NETWORK_REQUEST\", options),\n };\n\n /**\n * Fidelity & Rewards program integration.\n */\n public fidelity = {\n /** Returns current fidelity balance. */\n getFidelityBalance: (): Promise<IFidelityBalance> =>\n this.bridge.send(\"GET_FIDELITY_BALANCE\"),\n /**\n * Retrieves fidelity transaction history.\n * @param params Filtering and pagination parameters.\n */\n getFidelityHistory: (\n params?: IFidelityHistoryParams,\n ): Promise<IFidelityTransaction[]> =>\n this.bridge.send(\"GET_FIDELITY_HISTORY\", params),\n /**\n * Authorize spending fidelity points (FPoints) via Two-Phase Authorization.\n * @param intentUuid UUID generated by your backend for the transaction.\n */\n spendFPoints: (\n intentUuid: string,\n ): Promise<{ success: boolean; transactionId: string }> =>\n this.bridge.send(\"SPEND_FPOINTS\", { intentUuid }),\n };\n\n /**\n * UI and Navigation controls.\n */\n public ui = {\n /** Closes the Mini-App and returns to the host shell. */\n exit: (): Promise<void> => this.bridge.send(\"EXIT\"),\n /**\n * Configures native scroll behaviors like Pull-to-Refresh and Infinite Scroll.\n * @param config Scroll configuration for top/bottom detection.\n */\n setScrollConfig: (config: ScrollConfig): Promise<void> =>\n this.bridge.send(\"SET_SCROLL_CONFIG\", config),\n };\n\n /**\n * Debug controls\n */\n public debug = {\n /**\n * Log to the shell app\n * @param message\n */\n log: (...message: unknown[]) => this.bridge.send(\"DEBUG_LOG\", { message }),\n };\n\n /**\n * Registers a callback for a specific event from the native shell.\n * @param event The name of the event to listen for.\n * @param callback The function to execute when the event is triggered.\n * @returns A function to unregister the listener.\n */\n public on(event: SDKEvent, callback: (data: unknown) => void) {\n return this.bridge.on(event as string, callback);\n }\n\n /**\n * Unregisters a previously registered event listener.\n * @param event The name of the event.\n * @param callback The callback function to remove.\n */\n public off(event: SDKEvent, callback: (data: unknown) => void) {\n this.bridge.off(event as string, callback);\n }\n}\n\n/**\n * Singleton instance of the MiniAppSDK.\n */\nexport const sdk = new MiniAppSDK();\n","/**\n * UP Mini-App SDK Types\n */\n\n/**\n * Represents the user's profile information.\n */\nexport interface IUserProfile {\n /** Unique identifier for the user. */\n uuid: string;\n /** Full legal name of the user. */\n fullName: string;\n /** Primary email address. */\n email: string;\n /** Chosen username within the UP ecosystem. */\n username: string;\n /** ISO country code (e.g., \"FR\", \"US\"). */\n countryCode: string;\n /** Phone number without country code. */\n localNumber: string;\n}\n\n/**\n * Geographic location data.\n */\nexport interface ILocationData {\n coords: {\n /** Latitude in decimal degrees. */\n latitude: number;\n /** Longitude in decimal degrees. */\n longitude: number;\n /** Altitude in meters above the WGS 84 reference ellipsoid, or null if not available. */\n altitude: number | null;\n /** Accuracy of the latitude and longitude properties in meters. */\n accuracy: number | null;\n /** Accuracy of the altitude property in meters. */\n altitudeAccuracy: number | null;\n /** The direction in which the device is traveling, in degrees (0-360). */\n heading: number | null;\n /** The velocity of the device in meters per second. */\n speed: number | null;\n };\n /** The time at which the location was retrieved (Unix timestamp). */\n timestamp: number;\n}\n\n/**\n * Request payload for triggering a payment flow.\n */\nexport interface IPaymentRequest {\n /** The specific amount to charge. */\n amount: number;\n /** ISO currency code (e.g., \"EUR\", \"USD\"). */\n currency: string;\n /** Total amount including taxes/fees. */\n total: number;\n /** Itemized breakdown of the purchase. */\n items: Array<{\n /** Name or description of the item. */\n item: string;\n /** Price per unit. */\n price?: number;\n /** Number of units. */\n quantity?: number;\n }>;\n}\n\n/**\n * Style of haptic feedback.\n */\nexport type HapticStyleType =\n | \"light\"\n | \"medium\"\n | \"heavy\"\n | \"rigid\"\n | \"soft\"\n | \"success\"\n | \"warning\"\n | \"error\";\n\n/**\n * Network Proxy Types\n */\n\n/**\n * The HTTP method to use as request method\n */\nexport type NetworkMethodType = \"GET\" | \"POST\" | \"PUT\" | \"DELETE\" | \"PATCH\";\n\n/**\n * Configuration for network proxy requests.\n */\nexport interface INetworkOptions {\n /** Full URL for the request. */\n url: string;\n /** HTTP method to use. */\n method: NetworkMethodType;\n /** Request body for POST/PUT/PATCH. */\n body?: unknown;\n /** Custom HTTP headers. */\n headers?: Record<string, string>;\n}\n\n/**\n * Response from a network proxy request.\n */\nexport interface INetworkResponse<T = unknown> {\n /** HTTP status code. */\n status: number;\n /** Response data payload. */\n data: T;\n /** Response headers. */\n headers: Headers;\n}\n\n/**\n * Fidelity & Rewards Types\n */\n\n/**\n * Fidelity program balance information.\n */\nexport interface IFidelityBalance {\n /** Current point or currency balance. */\n balance: number;\n /** Name or symbol of the fidelity currency (e.g., \"FPoints\"). */\n currency: string;\n}\n\n/**\n * Parameters for retrieving fidelity transaction history.\n */\nexport interface IFidelityHistoryParams {\n /** Maximum number of records to return. */\n limit?: number;\n\n /** Cursor for pagination; null for the first page. */\n cursor?: string | null;\n}\n\n/** Type of transaction: credit (add) or debit (remove). */\nexport type FidelityTransactionTypeType = \"credit\" | \"debit\";\n\n/**\n * A single fidelity program transaction.\n */\nexport interface IFidelityTransaction {\n /** Unique identifier for the transaction. */\n id: string;\n /** Amount of the transaction. */\n amount: number;\n /** Human-readable description. */\n description: string;\n /** ISO 8601 date string. */\n date: string;\n /** Type of transaction */\n type: FidelityTransactionTypeType;\n}\n\n/**\n * The initialization options required to set up the Mini-App SDK.\n */\nexport type IInitializationOptions = {};\n\n/**\n * The post initialization response\n */\nexport interface IInitializationResponse {\n /** The name of the mini app */\n name: string;\n /** The uuid of the mini app */\n uuid: string;\n /** The description of the mini app */\n description: string;\n /** The authors of the mini app */\n authors?: string;\n /** The current version in the registry */\n version?: string;\n /** The identity token got from the shell's backend */\n identityToken: string;\n /** The scoped profile based on the requested fields during initialization or the getUserProfile call */\n profile: Partial<IUserProfile | null>;\n /** The environment variables defined for the mini app in the shell's backend */\n env: Record<string, unknown>;\n /** The user data passed during the initialization or the setUserData call */\n userData: Record<string, unknown>;\n}\n\n/**\n * Events emitted by the UI module.\n */\nexport enum UIEvent {\n /** Triggered when the user performs a native \"Pull-to-Refresh\". */\n TOP_SCROLL_MORE = \"TOP_SCROLL_MORE\",\n /** Triggered when the user scrolls near the bottom of the page (within 200px threshold). */\n BOTTOM_SCROLL_MORE = \"BOTTOM_SCROLL_MORE\",\n}\n\n/**\n * Union type for all SDK events, allowing for both known enums and custom strings.\n * The (string & {}) pattern preserves IntelliSense for enum members.\n */\nexport type SDKEvent = UIEvent | (string & {});\n\n/**\n * Configuration for native scroll interactions managed by the Host Shell.\n */\nexport interface ScrollConfig {\n /** Configuration for Pull-to-Refresh (Top). */\n topScrollMore?: {\n /** Show/hide the native RefreshControl. */\n enabled: boolean;\n /** Set to true to show the loading spinner, false to hide it. */\n refreshing?: boolean;\n };\n /** Configuration for Infinite Scroll (Bottom). */\n bottomScrollMore?: {\n /** Enable/disable bottom scroll detection. */\n enabled: boolean;\n /** If false, detection stops and the indicator is hidden. */\n hasMore?: boolean;\n /** Set to true to show the bottom ActivityIndicator. */\n loadingMore?: boolean;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACSO,IAAM,SAAN,MAAa;AAAA,EACV,YAGJ,CAAC;AAAA,EACG,iBAA8D,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOvE,cAAc;AACZ,QAAI,OAAO,WAAW,aAAa;AAEjC,MAAC,OAAmD,kBAAkB;AAAA,QACpE,iBAAiB,CAAC,aAChB,KAAK,oBAAoB,QAAQ;AAAA,MACrC;AAGA,aAAO,iBAAiB,WAAW,CAAC,UAAU;AAC5C,YAAI;AACF,gBAAM,OACJ,OAAO,MAAM,SAAS,WAClB,KAAK,MAAM,MAAM,IAAI,IACrB,MAAM;AACZ,eAAK,oBAAoB,IAAI;AAAA,QAC/B,SAAS,IAAI;AAAA,QAEb;AAAA,MACF,CAAC;AAAA,I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