@ab-org/predicate-market-sdk 2.2.0-beta.8 → 2.2.0-beta.9
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/{account-6PGNCFOX.js → account-SQGJZOF5.js} +1 -2
- package/dist/auth.d.ts +1 -1
- package/dist/{chunk-YX56ZGDB.js → chunk-BDZKYFL5.js} +12 -1
- package/dist/{chunk-BLUBNFON.js → chunk-IOAGWRWJ.js} +267 -53
- package/dist/core.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -4
- package/dist/react.d.ts +3 -2
- package/dist/react.js +2 -4
- package/dist/{signInTypes.d-DESvmgWG.d.ts → signInTypes.d-Cr3RzByV.d.ts} +1 -0
- package/package.json +3 -3
- package/dist/chunk-26R46ZBM.js +0 -81
- package/dist/chunk-SV3NR2LW.js +0 -14
- package/dist/dist-C3ENWBQI.js +0 -2
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { chainConfig } from './chunk-
|
|
1
|
+
import { chainConfig, getChainInfo } from './chunk-BDZKYFL5.js';
|
|
2
2
|
import { getSDKConfig } from './chunk-UPMVYXZ6.js';
|
|
3
|
-
import { getChainInfo } from './chunk-YX56ZGDB.js';
|
|
4
3
|
import { sessionStore, getSupportedChainFromEvmChainId } from '@ab-org/sdk-core';
|
|
5
4
|
import { CubeSignerAuth, createCubistEvmWalletProvider } from '@ab-org/sdk-core/social/auth';
|
|
6
5
|
|
package/dist/auth.d.ts
CHANGED
|
@@ -271,4 +271,15 @@ getFundingTokenAddress(DEFAULT_FUNDING_CHAIN_ID);
|
|
|
271
271
|
});
|
|
272
272
|
new TextEncoder();
|
|
273
273
|
|
|
274
|
-
|
|
274
|
+
// ../sign_in_sdk/dist/config.js
|
|
275
|
+
var stage = getEnv("STAGE") || "dev";
|
|
276
|
+
var clientIds = {
|
|
277
|
+
google: getEnv("GOOGLE_CLIENT_ID"),
|
|
278
|
+
x: getEnv("X_CLIENT_ID")
|
|
279
|
+
};
|
|
280
|
+
var chainConfig = {
|
|
281
|
+
chainType: "evm",
|
|
282
|
+
chainId: getChainInfo().chainId
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
export { cache_exports, chainConfig, clientIds, getChainInfo, getEnv, stage };
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { getExplorerUrl } from './chunk-XB2DFS2W.js';
|
|
2
2
|
import { getChains, registerPlatform, quote, getWithdrawOrder } from './chunk-E65LLR2W.js';
|
|
3
|
-
import { getEnv } from './chunk-R2D3SM4S.js';
|
|
4
|
-
import { clientIds, stage } from './chunk-
|
|
3
|
+
import { getEnv as getEnv$1 } from './chunk-R2D3SM4S.js';
|
|
4
|
+
import { getEnv, cache_exports, clientIds, stage } from './chunk-BDZKYFL5.js';
|
|
5
5
|
import { getSDKConfig } from './chunk-UPMVYXZ6.js';
|
|
6
|
-
import { Y } from './chunk-26R46ZBM.js';
|
|
7
|
-
import { cache_exports } from './chunk-YX56ZGDB.js';
|
|
8
6
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
9
7
|
import { useEffect, useState, useRef, useMemo, useCallback } from 'react';
|
|
10
8
|
import { sessionStore, getSupportedChainFromEvmChainId, createSessionCapabilityPolicy, createChainContext, CUBIST_CAPABILITIES, createDefaultInjectedWalletRegistry, WalletConnector } from '@ab-org/sdk-core';
|
|
@@ -20,6 +18,7 @@ var colors = {
|
|
|
20
18
|
accent: "#29FF9B",
|
|
21
19
|
danger: "#FF6B6B"};
|
|
22
20
|
var radii = {
|
|
21
|
+
md: "14px",
|
|
23
22
|
pill: "99px",
|
|
24
23
|
card: "12px"};
|
|
25
24
|
var fonts = {
|
|
@@ -222,38 +221,89 @@ var ModalFrame = ({ onClose, width = 500, cardStyle, contentStyle, children }) =
|
|
|
222
221
|
};
|
|
223
222
|
|
|
224
223
|
// ../sign_in_sdk/dist/ui/SignInModal.sections.js
|
|
225
|
-
|
|
226
|
-
return import('./account-6PGNCFOX.js');
|
|
227
|
-
}
|
|
228
|
-
async function loadOidcAuth() {
|
|
229
|
-
return import('./dist-C3ENWBQI.js');
|
|
230
|
-
}
|
|
231
|
-
var SignInModalFrame = ({ id, title, onClose, footer, children }) => {
|
|
224
|
+
var SignInModalFrame = ({ id, title, onClose, onBack, footer, children }) => {
|
|
232
225
|
const isMobile = useIsMobileViewport();
|
|
233
|
-
return jsx(ModalFrame, { onClose, cardStyle: { padding: isMobile ? "24px 16px" : "32px 24px" }, contentStyle: { alignItems: "center" }, children: jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: isMobile ? 20 : 24, alignItems: "center" }, id, className: `absdk-predicate-signin-modal ${isMobile ? "absdk-predicate-signin-modal--mobile" : "absdk-predicate-signin-modal--desktop"}`, children: [jsx("h2", { className: "absdk-predicate-signin-modal__title", style: { margin: 0, fontSize: isMobile ? 22 : 24, fontWeight: 600, lineHeight: 1.4, textAlign: "center" }, children: title }), jsx("div", { className: "absdk-predicate-signin-modal__content", style: { width: "100%", display: "flex", flexDirection: "column", gap: 12, alignItems: "center" }, children }), footer] }) });
|
|
226
|
+
return jsx(ModalFrame, { onClose, cardStyle: { padding: isMobile ? "24px 16px" : "32px 24px" }, contentStyle: { alignItems: "center" }, children: jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: isMobile ? 20 : 24, alignItems: "center" }, id, className: `absdk-predicate-signin-modal ${isMobile ? "absdk-predicate-signin-modal--mobile" : "absdk-predicate-signin-modal--desktop"}`, children: [jsxs("div", { style: { width: "100%", display: "flex", alignItems: "center", justifyContent: "center", position: "relative" }, children: [onBack && jsx("button", { type: "button", onClick: onBack, "aria-label": "Back", style: { position: "absolute", left: 0, background: "transparent", border: "none", cursor: "pointer", padding: 4, display: "flex", alignItems: "center", color: colors.textPrimary }, children: jsx("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", children: jsx("path", { d: "M12 4L6 10L12 16", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }) }), jsx("h2", { className: "absdk-predicate-signin-modal__title", style: { margin: 0, fontSize: isMobile ? 22 : 24, fontWeight: 600, lineHeight: 1.4, textAlign: "center" }, children: title })] }), jsx("div", { className: "absdk-predicate-signin-modal__content", style: { width: "100%", display: "flex", flexDirection: "column", gap: 12, alignItems: "center" }, children }), footer] }) });
|
|
234
227
|
};
|
|
235
|
-
var
|
|
228
|
+
var EmailIcon = () => jsxs("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", children: [jsx("path", { d: "M3 4h14c1.1 0 2 .9 2 2v8c0 1.1-.9 2-2 2H3c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z", stroke: "currentColor", strokeWidth: "1.5", fill: "none" }), jsx("path", { d: "M19 6l-9 5-9-5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", fill: "none" })] });
|
|
229
|
+
var SignInWithEmailSection = ({ isBusy, onSendCode, onVerifyCode, onEmailChange }) => {
|
|
236
230
|
const [email, setEmail] = useState("");
|
|
237
|
-
const [
|
|
238
|
-
const [
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
231
|
+
const [code, setCode] = useState("");
|
|
232
|
+
const [step, setStep] = useState("email");
|
|
233
|
+
const [loading, setLoading] = useState(false);
|
|
234
|
+
const handleEmailChange = (value) => {
|
|
235
|
+
setEmail(value);
|
|
236
|
+
onEmailChange?.(value);
|
|
237
|
+
};
|
|
238
|
+
const handleSendCode = async () => {
|
|
239
|
+
if (!email || loading)
|
|
240
|
+
return;
|
|
241
|
+
setLoading(true);
|
|
242
|
+
try {
|
|
243
|
+
await onSendCode(email);
|
|
244
|
+
setStep("code");
|
|
245
|
+
} catch (error) {
|
|
246
|
+
console.error("Send code failed:", error);
|
|
247
|
+
} finally {
|
|
248
|
+
setLoading(false);
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
const handleVerifyCode = async () => {
|
|
252
|
+
if (!code || loading)
|
|
253
|
+
return;
|
|
254
|
+
setLoading(true);
|
|
255
|
+
try {
|
|
256
|
+
await onVerifyCode(code);
|
|
257
|
+
} catch (error) {
|
|
258
|
+
console.error("Verify code failed:", error);
|
|
259
|
+
setLoading(false);
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
if (step === "code") {
|
|
263
|
+
return jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: 16 }, children: [jsx("input", { type: "text", placeholder: "Enter verification code", value: code, onChange: (e) => setCode(e.target.value), onKeyDown: (e) => e.key === "Enter" && handleVerifyCode(), disabled: isBusy || loading, style: {
|
|
264
|
+
width: "100%",
|
|
265
|
+
height: 48,
|
|
266
|
+
borderRadius: radii.md,
|
|
267
|
+
border: `1px solid ${colors.border}`,
|
|
268
|
+
background: colors.card,
|
|
269
|
+
color: colors.textPrimary,
|
|
270
|
+
fontSize: 16,
|
|
271
|
+
padding: "0 16px",
|
|
272
|
+
fontFamily: fonts.family,
|
|
273
|
+
outline: "none"
|
|
274
|
+
} }), jsxs("button", { onClick: handleVerifyCode, disabled: !code || isBusy || loading, style: {
|
|
275
|
+
width: "100%",
|
|
276
|
+
height: 48,
|
|
277
|
+
borderRadius: radii.pill,
|
|
278
|
+
border: `1px solid ${colors.border}`,
|
|
279
|
+
background: "transparent",
|
|
280
|
+
display: "flex",
|
|
281
|
+
alignItems: "center",
|
|
282
|
+
justifyContent: "center",
|
|
283
|
+
gap: 12,
|
|
284
|
+
cursor: isBusy || loading || !code ? "not-allowed" : "pointer",
|
|
285
|
+
opacity: isBusy || loading || !code ? 0.5 : 1
|
|
286
|
+
}, children: [loading ? jsx(SpinnerIcon, {}) : jsx(EmailIcon, {}), jsx("span", { style: { fontSize: 16, fontWeight: 500, color: colors.textPrimary, fontFamily: fonts.family }, children: loading ? "Verifying..." : "Verify Code" })] }), jsx("button", { onClick: () => setStep("email"), disabled: isBusy || loading, style: {
|
|
287
|
+
background: "transparent",
|
|
288
|
+
border: "none",
|
|
289
|
+
color: colors.textSecondary,
|
|
290
|
+
fontSize: 14,
|
|
291
|
+
cursor: "pointer",
|
|
292
|
+
fontFamily: fonts.family
|
|
293
|
+
}, children: "Back to email" })] });
|
|
294
|
+
}
|
|
295
|
+
return jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: 16 }, children: [jsx("input", { type: "email", placeholder: "Enter your email", value: email, onChange: (e) => handleEmailChange(e.target.value), onKeyDown: (e) => e.key === "Enter" && handleSendCode(), disabled: isBusy || loading, style: {
|
|
296
|
+
width: "100%",
|
|
297
|
+
height: 48,
|
|
298
|
+
borderRadius: radii.md,
|
|
299
|
+
border: `1px solid ${colors.border}`,
|
|
300
|
+
background: colors.card,
|
|
301
|
+
color: colors.textPrimary,
|
|
302
|
+
fontSize: 16,
|
|
303
|
+
padding: "0 16px",
|
|
304
|
+
fontFamily: fonts.family,
|
|
305
|
+
outline: "none"
|
|
306
|
+
} }), jsxs("button", { onClick: handleSendCode, disabled: !email || isBusy || loading, style: {
|
|
257
307
|
width: "100%",
|
|
258
308
|
height: 48,
|
|
259
309
|
borderRadius: radii.pill,
|
|
@@ -263,13 +313,30 @@ var SignInModalSocialSection = ({ id, socialProviders, isBusy, loadingProvider,
|
|
|
263
313
|
alignItems: "center",
|
|
264
314
|
justifyContent: "center",
|
|
265
315
|
gap: 12,
|
|
266
|
-
cursor: isBusy ? "
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
316
|
+
cursor: isBusy || loading || !email ? "not-allowed" : "pointer",
|
|
317
|
+
opacity: isBusy || loading || !email ? 0.5 : 1
|
|
318
|
+
}, children: [loading ? jsx(SpinnerIcon, {}) : jsx(EmailIcon, {}), jsx("span", { style: { fontSize: 16, fontWeight: 500, color: colors.textPrimary, fontFamily: fonts.family }, children: loading ? "Sending..." : "Continue with Email" })] })] });
|
|
319
|
+
};
|
|
320
|
+
var socialButtonStyle = (isBusy, isLoading) => ({
|
|
321
|
+
width: "100%",
|
|
322
|
+
height: 48,
|
|
323
|
+
borderRadius: radii.pill,
|
|
324
|
+
border: `1px solid ${colors.border}`,
|
|
325
|
+
background: "transparent",
|
|
326
|
+
display: "flex",
|
|
327
|
+
alignItems: "center",
|
|
328
|
+
justifyContent: "center",
|
|
329
|
+
gap: 12,
|
|
330
|
+
cursor: isBusy ? "wait" : "pointer",
|
|
331
|
+
padding: 12,
|
|
332
|
+
boxSizing: "border-box",
|
|
333
|
+
opacity: isLoading ? 0.6 : isBusy ? 0.8 : 1,
|
|
334
|
+
transition: "opacity .15s"
|
|
335
|
+
});
|
|
336
|
+
var SignInModalSocialSection = ({ id, socialProviders, isBusy, loadingProvider, onSocialClick, onEmailClick }) => jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: 24 }, id, className: "absdk-predicate-signin-modal__social", children: [jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 16 }, children: [socialProviders.map((provider) => {
|
|
337
|
+
const isLoading = loadingProvider === provider.id;
|
|
338
|
+
return jsxs("button", { id: `absdk-predicate-signin-modal-social-provider-${provider.id}`, className: `absdk-predicate-signin-modal__social-button absdk-predicate-signin-modal__social-button--${provider.id}`, type: "button", disabled: isBusy, onClick: () => onSocialClick(provider.id), style: socialButtonStyle(isBusy, isLoading), children: [isLoading ? jsx(SpinnerIcon, {}) : provider.icon, jsx("span", { style: { fontSize: 16, fontWeight: 500, lineHeight: 1.4, color: colors.textPrimary, fontFamily: fonts.family }, children: isLoading ? "Signing in..." : provider.label })] }, provider.id);
|
|
339
|
+
}), onEmailClick && jsxs("button", { id: "absdk-predicate-signin-modal-social-provider-email", className: "absdk-predicate-signin-modal__social-button absdk-predicate-signin-modal__social-button--email", type: "button", disabled: isBusy, onClick: onEmailClick, style: socialButtonStyle(isBusy, false), children: [jsx(EmailIcon, {}), jsx("span", { style: { fontSize: 16, fontWeight: 500, lineHeight: 1.4, color: colors.textPrimary, fontFamily: fonts.family }, children: "Continue with Email" })] })] }), jsxs("div", { style: { display: "flex", alignItems: "center", gap: 20, width: "100%" }, children: [jsx("div", { style: { flex: 1, height: 1, background: colors.border } }), jsx("span", { style: { fontSize: 14, lineHeight: 1.4, color: colors.textPrimary, opacity: 0.4, whiteSpace: "nowrap" }, children: "Or connect a wallet" }), jsx("div", { style: { flex: 1, height: 1, background: colors.border } })] })] });
|
|
273
340
|
var SignInModalWalletGrid = ({ wallets, isBusy, loadingWalletId, expanded, showExpandToggle, onWalletClick, onToggleExpanded }) => {
|
|
274
341
|
const isMobile = useIsMobileViewport();
|
|
275
342
|
return jsxs("div", { className: "absdk-predicate-signin-modal__wallets", style: { width: "100%", display: "flex", flexDirection: "column", gap: 8, alignItems: "center", paddingTop: 12 }, children: [jsx("div", { className: "absdk-predicate-signin-modal__wallet-grid", style: { width: "100%", display: "flex", flexWrap: "wrap", gap: "14px 0" }, children: wallets.map((wallet) => jsxs("button", { id: `absdk-predicate-signin-modal-wallet-${wallet.id}`, className: `absdk-predicate-signin-modal__wallet-button absdk-predicate-signin-modal__wallet-button--${wallet.id}`, type: "button", disabled: isBusy, onClick: () => onWalletClick(wallet.id), style: {
|
|
@@ -294,6 +361,90 @@ var SignInModalWalletGrid = ({ wallets, isBusy, loadingWalletId, expanded, showE
|
|
|
294
361
|
}, children: jsx(ExpandIcon, { expanded }) })] });
|
|
295
362
|
};
|
|
296
363
|
var SignInModalFooter = ({ privacyPolicyUrl, termsOfUseUrl }) => jsx("div", { className: "absdk-predicate-signin-modal__footer", style: { padding: "12px 0", display: "flex", justifyContent: "center", width: "100%" }, children: jsxs("p", { style: { margin: 0, fontSize: 14, lineHeight: 1.4, color: colors.textSecondary, fontFamily: fonts.family, textAlign: "center" }, children: ["By continuing, I agree to the", " ", jsx("a", { href: privacyPolicyUrl, style: { color: colors.textPrimary, textDecoration: "underline" }, target: "_blank", rel: "noopener noreferrer", children: "Privacy Policy" }), " ", "and", " ", jsx("a", { href: termsOfUseUrl, style: { color: colors.textPrimary, textDecoration: "underline" }, target: "_blank", rel: "noopener noreferrer", children: "Terms of Use" })] }) });
|
|
364
|
+
|
|
365
|
+
// ../oidc-auth/dist/index.js
|
|
366
|
+
var x = 60;
|
|
367
|
+
var S = { prod: "prod", dev: "gamma" };
|
|
368
|
+
var w = { prod: { SignerApiRoot: "https://prod.signer.cubist.dev" }, gamma: { SignerApiRoot: "https://gamma.signer.cubist.dev" } };
|
|
369
|
+
var C = L("CUBE_SIGNER_ORG_ID");
|
|
370
|
+
var v = getEnv("RELAY_ORIGIN");
|
|
371
|
+
function L(e) {
|
|
372
|
+
return getEnv(e) || "";
|
|
373
|
+
}
|
|
374
|
+
var f = ({ url: e, name: l, width: r, height: t }) => {
|
|
375
|
+
let i = (window.innerHeight - (t || 400)) / 2 + window.screenY, a = (window.innerWidth - (r || 400)) / 2 + window.screenX;
|
|
376
|
+
try {
|
|
377
|
+
let s = window.open(e, l, `dialog=yes,top=${i}px,left=${a},width=${r !== void 0 ? r : 400}px,height=${t !== void 0 ? t : 600}px`);
|
|
378
|
+
return s || null;
|
|
379
|
+
} catch (s) {
|
|
380
|
+
return console.error("Failed to open window:", s), null;
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
var R = (e) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e);
|
|
384
|
+
function $(e) {
|
|
385
|
+
if (e in w) return w[e].SignerApiRoot;
|
|
386
|
+
if (/^https?:\/\//.test(e)) return e.replace(/\/$/, "");
|
|
387
|
+
throw new Error(`Unsupported CubeSigner env: ${e}`);
|
|
388
|
+
}
|
|
389
|
+
var O = async (e, l, r) => {
|
|
390
|
+
let t = await fetch(`${$(l)}/v0/org/${encodeURIComponent(r)}/oidc/email-otp`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ email: e }) });
|
|
391
|
+
if (!t.ok) {
|
|
392
|
+
let a = await t.text().catch(() => "");
|
|
393
|
+
throw new Error(a ? `Email login failed (${t.status}): ${a}` : `Email login failed (${t.status})`);
|
|
394
|
+
}
|
|
395
|
+
let i = await t.json();
|
|
396
|
+
if (!i.partial_token) throw new Error("Email login response missing partial_token");
|
|
397
|
+
return i.partial_token;
|
|
398
|
+
};
|
|
399
|
+
var Y = ({ stage: e, xClientId: l, googleClientId: r }) => {
|
|
400
|
+
let t = window.location.origin || v;
|
|
401
|
+
if (!t) throw new Error("Invalid stage");
|
|
402
|
+
let i = `${t}/relay/x`, a = `${t}/relay/google`, s = S[e], E = C;
|
|
403
|
+
if (!E) throw new Error("Invalid cube stage");
|
|
404
|
+
let y = (o, g = 12e4) => new Promise((c, n) => {
|
|
405
|
+
if (!o) {
|
|
406
|
+
n(new Error("Failed to open popup"));
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
let m = setTimeout(() => {
|
|
410
|
+
o.close(), n(new Error("Login timeout"));
|
|
411
|
+
}, g), d = async (p) => {
|
|
412
|
+
if (p.origin !== t || p.data.action !== "login") return;
|
|
413
|
+
let { data: I } = p.data;
|
|
414
|
+
try {
|
|
415
|
+
let { oidcToken: u = "", error: b } = I || {};
|
|
416
|
+
if (b) {
|
|
417
|
+
clearTimeout(m), window.removeEventListener("message", d), o.close(), n(new Error(String(b)));
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
u && (clearTimeout(m), window.removeEventListener("message", d), o.close(), c(u));
|
|
421
|
+
} catch (u) {
|
|
422
|
+
clearTimeout(m), window.removeEventListener("message", d), o.close(), n(u);
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
window.addEventListener("message", d);
|
|
426
|
+
let T = setInterval(() => {
|
|
427
|
+
o.closed && (clearTimeout(m), clearInterval(T), window.removeEventListener("message", d), n(new Error("Login cancelled by user")));
|
|
428
|
+
}, 400);
|
|
429
|
+
});
|
|
430
|
+
return { loginByGoogle: async () => {
|
|
431
|
+
let g = { target: window.location.origin, stage: e, eventId: Date.now().toString(), action: "login", clientId: r }, c = `${a}?${new URLSearchParams(g).toString()}`, n = f({ url: c, name: "Google login" });
|
|
432
|
+
return await y(n);
|
|
433
|
+
}, loginByX: async () => {
|
|
434
|
+
let g = { target: window.location.origin, stage: e, eventId: Date.now().toString(), action: "login", clientId: l }, c = `${i}?${new URLSearchParams(g).toString()}`, n = f({ url: c, name: "X login" });
|
|
435
|
+
return await y(n);
|
|
436
|
+
}, loginByEmail: async (o) => {
|
|
437
|
+
if (!R(o)) throw new Error("Invalid email");
|
|
438
|
+
return { partialOidcToken: await O(o, s, E), lifeTime: x };
|
|
439
|
+
} };
|
|
440
|
+
};
|
|
441
|
+
var emailOtpCache = /* @__PURE__ */ new Map();
|
|
442
|
+
function clearEmailOtpCache(email) {
|
|
443
|
+
if (email)
|
|
444
|
+
emailOtpCache.delete(email);
|
|
445
|
+
else
|
|
446
|
+
emailOtpCache.clear();
|
|
447
|
+
}
|
|
297
448
|
var useSignInModalController = ({ wallets, initialVisibleCount, onGoogleLogin: _onGoogleLogin, onTwitterLogin: _onTwitterLogin, onCubeSignerSession: _onCubeSignerSession, onWalletConnected, onSocialLogin: _onSocialLogin, onWalletSelect }) => {
|
|
298
449
|
const [expanded, setExpanded] = useState(false);
|
|
299
450
|
const [loadingProvider, setLoadingProvider] = useState(null);
|
|
@@ -325,6 +476,21 @@ var useSignInModalController = ({ wallets, initialVisibleCount, onGoogleLogin: _
|
|
|
325
476
|
return oidcToken;
|
|
326
477
|
}
|
|
327
478
|
};
|
|
479
|
+
const handleEmailSendCode = async (email) => {
|
|
480
|
+
const cached = emailOtpCache.get(email);
|
|
481
|
+
if (cached && cached.expiresAt > Date.now()) {
|
|
482
|
+
return cached.partialOidcToken;
|
|
483
|
+
}
|
|
484
|
+
const cfg = getSDKConfig();
|
|
485
|
+
const { loginByEmail } = Y({
|
|
486
|
+
stage,
|
|
487
|
+
xClientId: cfg.twitterClientId ?? clientIds.x ?? "",
|
|
488
|
+
googleClientId: cfg.googleClientId ?? clientIds.google ?? ""
|
|
489
|
+
});
|
|
490
|
+
const { partialOidcToken } = await loginByEmail(email);
|
|
491
|
+
emailOtpCache.set(email, { partialOidcToken, expiresAt: Date.now() + 6e4 });
|
|
492
|
+
return partialOidcToken;
|
|
493
|
+
};
|
|
328
494
|
const clearSocialLoading = () => setLoadingProvider(null);
|
|
329
495
|
const handleWalletClick = async (walletId) => {
|
|
330
496
|
if (isBusy)
|
|
@@ -359,6 +525,7 @@ var useSignInModalController = ({ wallets, initialVisibleCount, onGoogleLogin: _
|
|
|
359
525
|
showExpandToggle,
|
|
360
526
|
isBusy,
|
|
361
527
|
handleSocialClick,
|
|
528
|
+
handleEmailSendCode,
|
|
362
529
|
handleWalletClick,
|
|
363
530
|
clearSocialLoading,
|
|
364
531
|
toggleExpanded: () => setExpanded((value) => !value)
|
|
@@ -414,8 +581,8 @@ var Toast = ({ message, variant = "info", duration, onClose }) => {
|
|
|
414
581
|
};
|
|
415
582
|
|
|
416
583
|
// ../sign_in_sdk/dist/ui/SignInModal.js
|
|
417
|
-
async function
|
|
418
|
-
return import('./account-
|
|
584
|
+
async function loadWalletAccount() {
|
|
585
|
+
return import('./account-SQGJZOF5.js');
|
|
419
586
|
}
|
|
420
587
|
var SOCIAL_ADAPTER_ID = "cubist";
|
|
421
588
|
function persistSocialAdapterId() {
|
|
@@ -425,14 +592,18 @@ function persistSocialAdapterId() {
|
|
|
425
592
|
} catch {
|
|
426
593
|
}
|
|
427
594
|
}
|
|
428
|
-
var SignInModal = ({ title = "Welcome to PredicateMarket", socialProviders, wallets, initialVisibleCount, privacyPolicyUrl = "#", termsOfUseUrl = "#", onGoogleLogin, onTwitterLogin, onCubeSignerSession, onWalletConnected, onSocialLogin, onWalletSelect, onDismiss, onSuccess }) => {
|
|
595
|
+
var SignInModal = ({ title = "Welcome to PredicateMarket", socialProviders, wallets, initialVisibleCount, emailLogin, privacyPolicyUrl = "#", termsOfUseUrl = "#", onGoogleLogin, onTwitterLogin, onCubeSignerSession, onWalletConnected, onSocialLogin, onWalletSelect, onDismiss, onSuccess }) => {
|
|
429
596
|
const sdkConfig = getSDKConfig();
|
|
430
597
|
const effectiveSocialProviders = resolveSocialProviders(socialProviders ?? sdkConfig.signIn?.socialProviders);
|
|
431
598
|
const effectiveWallets = wallets ?? sdkConfig.signIn?.wallets;
|
|
432
599
|
const effectiveInitialVisibleCount = initialVisibleCount ?? sdkConfig.signIn?.initialVisibleCount ?? 5;
|
|
600
|
+
const effectiveEmailLogin = emailLogin ?? sdkConfig.signIn?.emailLogin ?? false;
|
|
433
601
|
const [toastError, setToastError] = useState(null);
|
|
434
602
|
const [socialLoadingProvider, setSocialLoadingProvider] = useState(null);
|
|
435
|
-
const
|
|
603
|
+
const [view, setView] = useState("main");
|
|
604
|
+
const emailPartialTokenRef = useRef("");
|
|
605
|
+
const emailRef = useRef("");
|
|
606
|
+
const { expanded, loadingProvider, loadingWalletId, visibleWallets, showExpandToggle, isBusy, handleSocialClick, handleEmailSendCode, handleWalletClick, clearSocialLoading, toggleExpanded } = useSignInModalController({
|
|
436
607
|
wallets: effectiveWallets,
|
|
437
608
|
initialVisibleCount: effectiveInitialVisibleCount,
|
|
438
609
|
onGoogleLogin,
|
|
@@ -442,11 +613,56 @@ var SignInModal = ({ title = "Welcome to PredicateMarket", socialProviders, wall
|
|
|
442
613
|
onSocialLogin,
|
|
443
614
|
onWalletSelect
|
|
444
615
|
});
|
|
445
|
-
return jsxs(SignInModalFrame, { id: "absdk-predicate-signin-modal-frame", title, onClose: onDismiss, footer: jsx(SignInModalFooter, { privacyPolicyUrl, termsOfUseUrl }), children: [toastError && jsx(Toast, { message: toastError, variant: "error", duration: 5e3, onClose: () => setToastError(null) }),
|
|
616
|
+
return jsxs(SignInModalFrame, { id: "absdk-predicate-signin-modal-frame", title: view === "email" ? "Sign in with Email" : title, onClose: onDismiss, onBack: view === "email" ? () => setView("main") : void 0, footer: jsx(SignInModalFooter, { privacyPolicyUrl, termsOfUseUrl }), children: [toastError && jsx(Toast, { message: toastError, variant: "error", duration: 5e3, onClose: () => setToastError(null) }), view === "email" ? jsx(SignInWithEmailSection, { isBusy: false, onSendCode: async (email) => {
|
|
617
|
+
emailRef.current = email;
|
|
618
|
+
emailPartialTokenRef.current = await handleEmailSendCode(email);
|
|
619
|
+
}, onEmailChange: (email) => {
|
|
620
|
+
clearEmailOtpCache(emailRef.current);
|
|
621
|
+
emailRef.current = email;
|
|
622
|
+
}, onVerifyCode: async (code) => {
|
|
623
|
+
const oidcToken = `${emailPartialTokenRef.current}${code}`;
|
|
624
|
+
emailPartialTokenRef.current = "";
|
|
625
|
+
sessionStore.clearSession();
|
|
626
|
+
try {
|
|
627
|
+
const { default: WalletAccount2 } = await loadWalletAccount();
|
|
628
|
+
WalletAccount2.clearInstance();
|
|
629
|
+
const walletAccount = await WalletAccount2.getInstance(oidcToken);
|
|
630
|
+
const cubeSignerSession = walletAccount.getCubeSignerSession();
|
|
631
|
+
onCubeSignerSession?.(cubeSignerSession);
|
|
632
|
+
cache_exports.set("oidcToken", oidcToken, false);
|
|
633
|
+
const [address] = await walletAccount.eth_accounts();
|
|
634
|
+
if (!address)
|
|
635
|
+
throw new Error("Email wallet did not return an account");
|
|
636
|
+
const chainId = await walletAccount.eth_chainId();
|
|
637
|
+
const chain = getSupportedChainFromEvmChainId(chainId);
|
|
638
|
+
const capabilityPolicy = sdkConfig.cubeSigner?.defaultSessionPolicy ? createSessionCapabilityPolicy(sdkConfig.cubeSigner.defaultSessionPolicy) : void 0;
|
|
639
|
+
const session = {
|
|
640
|
+
address,
|
|
641
|
+
chain,
|
|
642
|
+
provider: walletAccount,
|
|
643
|
+
walletType: "social",
|
|
644
|
+
authSource: "email",
|
|
645
|
+
sessionId: `email:${address.toLowerCase()}`,
|
|
646
|
+
expiresAt: capabilityPolicy?.expiresAt,
|
|
647
|
+
capabilities: CUBIST_CAPABILITIES,
|
|
648
|
+
sessionData: cubeSignerSession.sessionData,
|
|
649
|
+
chainContext: createChainContext(chain),
|
|
650
|
+
capabilityPolicy,
|
|
651
|
+
userInfo: cubeSignerSession.userInfo
|
|
652
|
+
};
|
|
653
|
+
persistSocialAdapterId();
|
|
654
|
+
sessionStore.setSession(session);
|
|
655
|
+
clearEmailOtpCache(emailRef.current);
|
|
656
|
+
onSuccess?.(session);
|
|
657
|
+
} catch (error) {
|
|
658
|
+
setToastError(error?.message ?? "Email login failed, please try again");
|
|
659
|
+
throw error;
|
|
660
|
+
}
|
|
661
|
+
} }) : jsxs(Fragment, { children: [jsx(SignInModalSocialSection, { id: "absdk-predicate-signin-modal-social", socialProviders: effectiveSocialProviders, isBusy: isBusy || !!socialLoadingProvider, loadingProvider: loadingProvider ?? socialLoadingProvider, onEmailClick: effectiveEmailLogin ? () => setView("email") : void 0, onSocialClick: async (providerId) => {
|
|
446
662
|
setSocialLoadingProvider(providerId);
|
|
447
663
|
sessionStore.clearSession();
|
|
448
664
|
try {
|
|
449
|
-
const { default: WalletAccount2 } = await
|
|
665
|
+
const { default: WalletAccount2 } = await loadWalletAccount();
|
|
450
666
|
WalletAccount2.clearInstance();
|
|
451
667
|
const oidcToken = await handleSocialClick(providerId);
|
|
452
668
|
if (!oidcToken) {
|
|
@@ -458,9 +674,8 @@ var SignInModal = ({ title = "Welcome to PredicateMarket", socialProviders, wall
|
|
|
458
674
|
onCubeSignerSession?.(cubeSignerSession);
|
|
459
675
|
cache_exports.set("oidcToken", oidcToken, false);
|
|
460
676
|
const [address] = await walletAccount.eth_accounts();
|
|
461
|
-
if (!address)
|
|
677
|
+
if (!address)
|
|
462
678
|
throw new Error("Social wallet did not return an account");
|
|
463
|
-
}
|
|
464
679
|
const chainId = await walletAccount.eth_chainId();
|
|
465
680
|
const chain = getSupportedChainFromEvmChainId(chainId);
|
|
466
681
|
const authSource = providerId === "x" ? "twitter" : providerId;
|
|
@@ -484,12 +699,11 @@ var SignInModal = ({ title = "Welcome to PredicateMarket", socialProviders, wall
|
|
|
484
699
|
onSuccess?.(session);
|
|
485
700
|
} catch (error) {
|
|
486
701
|
setToastError(error?.message ?? "Failed to get wallet account, please try again");
|
|
487
|
-
return;
|
|
488
702
|
} finally {
|
|
489
703
|
setSocialLoadingProvider(null);
|
|
490
704
|
clearSocialLoading();
|
|
491
705
|
}
|
|
492
|
-
} }), jsx(SignInModalWalletGrid, { wallets: visibleWallets, isBusy, loadingWalletId, expanded, showExpandToggle, onWalletClick: handleWalletClick, onToggleExpanded: toggleExpanded })] });
|
|
706
|
+
} }), jsx(SignInModalWalletGrid, { wallets: visibleWallets, isBusy, loadingWalletId, expanded, showExpandToggle, onWalletClick: handleWalletClick, onToggleExpanded: toggleExpanded })] })] });
|
|
493
707
|
};
|
|
494
708
|
|
|
495
709
|
// src/ui/theme.ts
|
|
@@ -1515,7 +1729,7 @@ function getTokenAddressForChain(chains, chainId, tokenSymbol) {
|
|
|
1515
1729
|
const chain = chains.find((c) => c.chain_id === chainId);
|
|
1516
1730
|
return chain?.tokens.find((t) => t.symbol === tokenSymbol)?.address;
|
|
1517
1731
|
}
|
|
1518
|
-
var FUNDING_TOKEN_SYMBOL = getEnv("FUNDING_TOKEN_SYMBOL");
|
|
1732
|
+
var FUNDING_TOKEN_SYMBOL = getEnv$1("FUNDING_TOKEN_SYMBOL");
|
|
1519
1733
|
var DepositModal = ({
|
|
1520
1734
|
token,
|
|
1521
1735
|
chain,
|
|
@@ -2227,7 +2441,7 @@ function CopyIcon2() {
|
|
|
2227
2441
|
/* @__PURE__ */ jsx("path", { className: "absdk-predicate-withdraw-modal__copy-icon-path", d: "M3 11V3a1 1 0 0 1 1-1h8", stroke: "currentColor", strokeWidth: "1.2", fill: "none" })
|
|
2228
2442
|
] });
|
|
2229
2443
|
}
|
|
2230
|
-
var FUNDING_TOKEN_SYMBOL2 = getEnv("FUNDING_TOKEN_SYMBOL");
|
|
2444
|
+
var FUNDING_TOKEN_SYMBOL2 = getEnv$1("FUNDING_TOKEN_SYMBOL");
|
|
2231
2445
|
function chainsToTokenOptions2(chains) {
|
|
2232
2446
|
const bySymbol = /* @__PURE__ */ new Map();
|
|
2233
2447
|
for (const c of chains) {
|
|
@@ -3348,7 +3562,7 @@ var SubmitButton = ({ id, className, disabled, status, onClick }) => {
|
|
|
3348
3562
|
|
|
3349
3563
|
// src/react.ts
|
|
3350
3564
|
async function loadWalletAccountModule() {
|
|
3351
|
-
return import('./account-
|
|
3565
|
+
return import('./account-SQGJZOF5.js');
|
|
3352
3566
|
}
|
|
3353
3567
|
var WalletAccount = {
|
|
3354
3568
|
async getInstance(oidcToken) {
|
package/dist/core.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { C as ChainInfo, a as CustodyAdapter, D as DepositAddressResult, M as MarketDataProvider, b as ModalController, Q as QuoteRequest, c as QuoteResult, T as TokenInfo } from './types-BFidNjd9.js';
|
|
2
2
|
import { CubeSignerConfig } from '@ab-org/sdk-core/social/auth';
|
|
3
|
-
import { S as SignInUiConfig } from './signInTypes.d-
|
|
3
|
+
import { S as SignInUiConfig } from './signInTypes.d-Cr3RzByV.js';
|
|
4
4
|
import { WalletSession } from '@ab-org/sdk-core';
|
|
5
5
|
import 'react';
|
|
6
6
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { ClientIds, DEFAULT_FUNDING_CHAIN_ID, DEFAULT_FUNDING_TOKEN_ADDRESS, EvmChainInfo, PredicateSDKConfig, SDKConfig, getChainInfo, getEnv, getExplorerUrl, getFixedAuthConfig, getFundingTokenAddress, getSDKConfig, initSDK, tryAutoReconnect } from './core.js';
|
|
2
2
|
export { notifyTwitterCallback } from './auth.js';
|
|
3
|
-
export { G as GoogleCredential, S as SignInUiConfig, a as SocialProvider, T as TwitterAuthResult, W as WalletItem } from './signInTypes.d-
|
|
3
|
+
export { G as GoogleCredential, S as SignInUiConfig, a as SocialProvider, T as TwitterAuthResult, W as WalletItem } from './signInTypes.d-Cr3RzByV.js';
|
|
4
4
|
export { DepositDetailsPanel, DepositDetailsPanelProps, DepositModal, DepositModalProps, DropdownField, DropdownFieldProps, SelectOption, SignInModal, SignInModalProps, Toast, WalletAccount, WalletOption, WalletSelectionModal, WalletSelectionModalProps, WithdrawModal, WithdrawModalProps, WithdrawUiStatus, clearSocialAccountInstance } from './react.js';
|
|
5
5
|
export { DepositController, DepositModalConfig, DepositStatus, Erc20BalanceResult, FundingTokenBalanceOptions, FundingWithdrawExecutorOptions, PredicateMarketPolicyAdapterOptions, WithdrawController, WithdrawExecutor, WithdrawModalConfig, WithdrawRequest, WithdrawResult, WithdrawStatus, WithdrawTxRequest, createDepositController, createFundingWithdrawExecutor, createMarketDataProvider, createPredicateMarketPolicyAdapter, createWithdrawController, fetchErc20Balance, fetchFundingTokenBalance, findTokenDataFromChains, isUsdtWithdrawDirect, parseUnits } from './merchant.js';
|
|
6
6
|
export { A as ApiResponse, C as ChainData, a as ChainsResponseData, b as CreateOrderRequest, c as CreateOrderResponseData, D as DepositOrderResponseData, d as DepositOrderStatus, M as MerchantApiConfig, N as NativeSwapPayload, P as PaymentPairData, e as PaymentSessionResponseData, f as PaymentSessionStatus, g as PlatformRegisterRequest, h as PlatformRegisterResponseData, Q as QuoteDirection, i as QuoteResponseData, T as TokenData, W as WithdrawOrderResponseData, j as WithdrawOrderStatus, k as configureMerchantApi, l as createOrder, m as getChains, n as getDepositOrder, o as getMerchantApiClient, p as getWithdrawOrder, q as quote, r as registerPlatform } from './api-DyQAYQ0i.js';
|
package/dist/index.js
CHANGED
|
@@ -2,12 +2,10 @@ export { notifyTwitterCallback } from './chunk-ZS6FNG2D.js';
|
|
|
2
2
|
export { tryAutoReconnect } from './chunk-GIPWCNYS.js';
|
|
3
3
|
export { createDepositController, createFundingWithdrawExecutor, createMarketDataProvider, createPredicateMarketPolicyAdapter, createWithdrawController, fetchErc20Balance, fetchFundingTokenBalance, findTokenDataFromChains, isUsdtWithdrawDirect, parseUnits } from './chunk-4XO4Z5TC.js';
|
|
4
4
|
export { ClientIds, DEFAULT_FUNDING_CHAIN_ID, DEFAULT_FUNDING_TOKEN_ADDRESS, getChainInfo, getFundingTokenAddress } from './chunk-6AZQBNMY.js';
|
|
5
|
-
export { DepositDetailsPanel, DepositModal, DropdownField, SignInModal, Toast, WalletAccount, WalletSelectionModal, WithdrawModal, clearSocialAccountInstance } from './chunk-
|
|
5
|
+
export { DepositDetailsPanel, DepositModal, DropdownField, SignInModal, Toast, WalletAccount, WalletSelectionModal, WithdrawModal, clearSocialAccountInstance } from './chunk-IOAGWRWJ.js';
|
|
6
6
|
export { getExplorerUrl } from './chunk-XB2DFS2W.js';
|
|
7
7
|
export { configureMerchantApi, createOrder, getChains, getDepositOrder, getMerchantApiClient, getWithdrawOrder, quote, registerPlatform } from './chunk-E65LLR2W.js';
|
|
8
8
|
export { getFixedAuthConfig, getSDKConfig, initSDK } from './chunk-E3UPFA4K.js';
|
|
9
9
|
export { getEnv } from './chunk-R2D3SM4S.js';
|
|
10
|
-
import './chunk-
|
|
10
|
+
import './chunk-BDZKYFL5.js';
|
|
11
11
|
import './chunk-UPMVYXZ6.js';
|
|
12
|
-
import './chunk-26R46ZBM.js';
|
|
13
|
-
import './chunk-YX56ZGDB.js';
|
package/dist/react.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime_js from 'react/jsx-runtime.js';
|
|
2
|
-
import { a as SocialProvider, W as WalletItem, G as GoogleCredential, T as TwitterAuthResult } from './signInTypes.d-
|
|
2
|
+
import { a as SocialProvider, W as WalletItem, G as GoogleCredential, T as TwitterAuthResult } from './signInTypes.d-Cr3RzByV.js';
|
|
3
3
|
import { WalletSession, WalletProviderRequest } from '@ab-org/sdk-core';
|
|
4
4
|
import { CubeSignerSession } from '@ab-org/sdk-core/social/auth';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
@@ -12,6 +12,7 @@ interface SignInModalProps {
|
|
|
12
12
|
socialProviders?: SocialProvider[];
|
|
13
13
|
wallets?: WalletItem[];
|
|
14
14
|
initialVisibleCount?: number;
|
|
15
|
+
emailLogin?: boolean;
|
|
15
16
|
privacyPolicyUrl?: string;
|
|
16
17
|
termsOfUseUrl?: string;
|
|
17
18
|
onGoogleLogin?: (credential: GoogleCredential) => void;
|
|
@@ -25,7 +26,7 @@ interface SignInModalProps {
|
|
|
25
26
|
/** 登录成功后调用,传入 session;调用方在此回调里更新 session 并自行关闭弹窗 */
|
|
26
27
|
onSuccess?: (session: WalletSession) => void;
|
|
27
28
|
}
|
|
28
|
-
declare const SignInModal: ({ title, socialProviders, wallets, initialVisibleCount, privacyPolicyUrl, termsOfUseUrl, onGoogleLogin, onTwitterLogin, onCubeSignerSession, onWalletConnected, onSocialLogin, onWalletSelect, onDismiss, onSuccess, }: SignInModalProps) => react_jsx_runtime_js.JSX.Element;
|
|
29
|
+
declare const SignInModal: ({ title, socialProviders, wallets, initialVisibleCount, emailLogin, privacyPolicyUrl, termsOfUseUrl, onGoogleLogin, onTwitterLogin, onCubeSignerSession, onWalletConnected, onSocialLogin, onWalletSelect, onDismiss, onSuccess, }: SignInModalProps) => react_jsx_runtime_js.JSX.Element;
|
|
29
30
|
|
|
30
31
|
type ToastVariant = "success" | "error" | "info";
|
|
31
32
|
interface ToastProps {
|
package/dist/react.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
export { DepositDetailsPanel, DepositModal, DropdownField, SignInModal, Toast, WalletAccount, WalletSelectionModal, WithdrawModal, clearSocialAccountInstance } from './chunk-
|
|
1
|
+
export { DepositDetailsPanel, DepositModal, DropdownField, SignInModal, Toast, WalletAccount, WalletSelectionModal, WithdrawModal, clearSocialAccountInstance } from './chunk-IOAGWRWJ.js';
|
|
2
2
|
import './chunk-XB2DFS2W.js';
|
|
3
3
|
import './chunk-E65LLR2W.js';
|
|
4
4
|
import './chunk-R2D3SM4S.js';
|
|
5
|
-
import './chunk-
|
|
5
|
+
import './chunk-BDZKYFL5.js';
|
|
6
6
|
import './chunk-UPMVYXZ6.js';
|
|
7
|
-
import './chunk-26R46ZBM.js';
|
|
8
|
-
import './chunk-YX56ZGDB.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ab-org/predicate-market-sdk",
|
|
3
|
-
"version": "2.2.0-beta.
|
|
3
|
+
"version": "2.2.0-beta.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/**/*",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"axios": "^1.13.6",
|
|
40
40
|
"qrcode-generator": "^2.0.4",
|
|
41
41
|
"viem": "2.21.54",
|
|
42
|
-
"@ab-org/sdk-core": "0.3.0-beta.
|
|
42
|
+
"@ab-org/sdk-core": "0.3.0-beta.7"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"react": ">=18"
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"@types/react": "^18.2.66",
|
|
49
49
|
"typescript": "^5.5.4",
|
|
50
50
|
"tsup": "^8.5.1",
|
|
51
|
-
"@ab-org/oidc-auth": "0.0.16",
|
|
52
51
|
"@ab-org/chains-service": "0.0.8",
|
|
52
|
+
"@ab-org/oidc-auth": "0.0.16",
|
|
53
53
|
"@ab-org/sign-in-sdk": "0.1.0",
|
|
54
54
|
"@ab-org/wallet-utils": "0.1.0-beta.1"
|
|
55
55
|
},
|
package/dist/chunk-26R46ZBM.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { getEnv } from './chunk-YX56ZGDB.js';
|
|
2
|
-
|
|
3
|
-
// ../oidc-auth/dist/index.js
|
|
4
|
-
var _ = { googleAuth: "ab-google-authorized", xAuth: "ab-twitter-authorized", telegramAuth: "ab-telegram-authorized" };
|
|
5
|
-
var x = 60;
|
|
6
|
-
var S = { prod: "prod", dev: "gamma" };
|
|
7
|
-
var w = { prod: { SignerApiRoot: "https://prod.signer.cubist.dev" }, gamma: { SignerApiRoot: "https://gamma.signer.cubist.dev" } };
|
|
8
|
-
var C = L("CUBE_SIGNER_ORG_ID");
|
|
9
|
-
var v = getEnv("RELAY_ORIGIN");
|
|
10
|
-
function L(e) {
|
|
11
|
-
return getEnv(e) || "";
|
|
12
|
-
}
|
|
13
|
-
var f = ({ url: e, name: l, width: r, height: t }) => {
|
|
14
|
-
let i = (window.innerHeight - (t || 400)) / 2 + window.screenY, a = (window.innerWidth - (r || 400)) / 2 + window.screenX;
|
|
15
|
-
try {
|
|
16
|
-
let s = window.open(e, l, `dialog=yes,top=${i}px,left=${a},width=${r !== void 0 ? r : 400}px,height=${t !== void 0 ? t : 600}px`);
|
|
17
|
-
return s || null;
|
|
18
|
-
} catch (s) {
|
|
19
|
-
return console.error("Failed to open window:", s), null;
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
var R = (e) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e);
|
|
23
|
-
function $(e) {
|
|
24
|
-
if (e in w) return w[e].SignerApiRoot;
|
|
25
|
-
if (/^https?:\/\//.test(e)) return e.replace(/\/$/, "");
|
|
26
|
-
throw new Error(`Unsupported CubeSigner env: ${e}`);
|
|
27
|
-
}
|
|
28
|
-
var O = async (e, l, r) => {
|
|
29
|
-
let t = await fetch(`${$(l)}/v0/org/${encodeURIComponent(r)}/oidc/email-otp`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ email: e }) });
|
|
30
|
-
if (!t.ok) {
|
|
31
|
-
let a = await t.text().catch(() => "");
|
|
32
|
-
throw new Error(a ? `Email login failed (${t.status}): ${a}` : `Email login failed (${t.status})`);
|
|
33
|
-
}
|
|
34
|
-
let i = await t.json();
|
|
35
|
-
if (!i.partial_token) throw new Error("Email login response missing partial_token");
|
|
36
|
-
return i.partial_token;
|
|
37
|
-
};
|
|
38
|
-
var Y = ({ stage: e, xClientId: l, googleClientId: r }) => {
|
|
39
|
-
let t = window.location.origin || v;
|
|
40
|
-
if (!t) throw new Error("Invalid stage");
|
|
41
|
-
let i = `${t}/relay/x`, a = `${t}/relay/google`, s = S[e], E = C;
|
|
42
|
-
if (!E) throw new Error("Invalid cube stage");
|
|
43
|
-
let y = (o, g = 12e4) => new Promise((c, n) => {
|
|
44
|
-
if (!o) {
|
|
45
|
-
n(new Error("Failed to open popup"));
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
let m = setTimeout(() => {
|
|
49
|
-
o.close(), n(new Error("Login timeout"));
|
|
50
|
-
}, g), d = async (p) => {
|
|
51
|
-
if (p.origin !== t || p.data.action !== "login") return;
|
|
52
|
-
let { data: I } = p.data;
|
|
53
|
-
try {
|
|
54
|
-
let { oidcToken: u = "", error: b } = I || {};
|
|
55
|
-
if (b) {
|
|
56
|
-
clearTimeout(m), window.removeEventListener("message", d), o.close(), n(new Error(String(b)));
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
u && (clearTimeout(m), window.removeEventListener("message", d), o.close(), c(u));
|
|
60
|
-
} catch (u) {
|
|
61
|
-
clearTimeout(m), window.removeEventListener("message", d), o.close(), n(u);
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
window.addEventListener("message", d);
|
|
65
|
-
let T = setInterval(() => {
|
|
66
|
-
o.closed && (clearTimeout(m), clearInterval(T), window.removeEventListener("message", d), n(new Error("Login cancelled by user")));
|
|
67
|
-
}, 400);
|
|
68
|
-
});
|
|
69
|
-
return { loginByGoogle: async () => {
|
|
70
|
-
let g = { target: window.location.origin, stage: e, eventId: Date.now().toString(), action: "login", clientId: r }, c = `${a}?${new URLSearchParams(g).toString()}`, n = f({ url: c, name: "Google login" });
|
|
71
|
-
return await y(n);
|
|
72
|
-
}, loginByX: async () => {
|
|
73
|
-
let g = { target: window.location.origin, stage: e, eventId: Date.now().toString(), action: "login", clientId: l }, c = `${i}?${new URLSearchParams(g).toString()}`, n = f({ url: c, name: "X login" });
|
|
74
|
-
return await y(n);
|
|
75
|
-
}, loginByEmail: async (o) => {
|
|
76
|
-
if (!R(o)) throw new Error("Invalid email");
|
|
77
|
-
return { partialOidcToken: await O(o, s, E), lifeTime: x };
|
|
78
|
-
} };
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export { C, L, O, S, Y, _, v, w, x };
|
package/dist/chunk-SV3NR2LW.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { getEnv, getChainInfo } from './chunk-YX56ZGDB.js';
|
|
2
|
-
|
|
3
|
-
// ../sign_in_sdk/dist/config.js
|
|
4
|
-
var stage = getEnv("STAGE") || "dev";
|
|
5
|
-
var clientIds = {
|
|
6
|
-
google: getEnv("GOOGLE_CLIENT_ID"),
|
|
7
|
-
x: getEnv("X_CLIENT_ID")
|
|
8
|
-
};
|
|
9
|
-
var chainConfig = {
|
|
10
|
-
chainType: "evm",
|
|
11
|
-
chainId: getChainInfo().chainId
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export { chainConfig, clientIds, stage };
|
package/dist/dist-C3ENWBQI.js
DELETED