@ab-org/predicate-market-sdk 2.1.2 → 2.2.0-beta.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 +1 -1
- package/dist/{autoReconnect-IFPVI2XU.js → autoReconnect-UEPGLSA7.js} +12 -3
- package/dist/{chunk-LOJTP47I.js → chunk-3AR6ZOML.js} +1 -1
- package/dist/{chunk-JFRRJXOJ.js → chunk-55FTUSW7.js} +48 -2
- package/dist/{chunk-F2UPP3YC.js → chunk-6MMOYCWR.js} +1 -1
- package/dist/{chunk-TPMI3XWV.js → chunk-AAFQWHHY.js} +1 -1
- package/dist/{chunk-VKONTJQE.js → chunk-FIDON2BY.js} +3 -3
- package/dist/chunk-FMFRUZS3.js +3770 -0
- package/dist/{chunk-SHLNBZBY.js → chunk-ITLN6GHC.js} +5 -0
- package/dist/core.js +4 -4
- package/dist/index.js +7 -7
- package/dist/merchant.js +4 -4
- package/dist/react.d.ts +4 -1
- package/dist/react.js +3 -3
- package/package.json +2 -2
- package/dist/chunk-KAMUFSZ7.js +0 -3193
package/README.md
CHANGED
|
@@ -97,7 +97,7 @@ const policy = createPredicateMarketPolicyAdapter({
|
|
|
97
97
|
|
|
98
98
|
## Configure SignInModal
|
|
99
99
|
|
|
100
|
-
The SDK ships with **bundled auth config** (Google client id, Twitter client id, CubeSigner env/org) so you can call `initSDK` with only `signIn`. Override via env (`NEXT_PUBLIC_*`) or by passing options to `initSDK`.
|
|
100
|
+
The SDK ships with **bundled auth config** (Google client id, Twitter client id, CubeSigner env/org) so you can call `initSDK` with only `signIn`. Override via env (`NEXT_PUBLIC_*`) or by passing options to `initSDK`. Cubist session keepalive also reads **`NEXT_PUBLIC_CUBE_KEEPALIVE_INTERVAL_MS`** and falls back to **`300000`** ms (5 minutes).
|
|
101
101
|
|
|
102
102
|
**Google / X in `SignInModal`** use the SDK's **bundled OIDC relay auth**: a **popup** opens your **`NEXT_PUBLIC_RELAY_ORIGIN`** routes **`/relay/google`** and **`/relay/x`**, then the SDK's built-in **WalletAccount** bridge turns the returned OIDC token into a CubeSigner-backed EVM session provider.
|
|
103
103
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getSDKConfig } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
import { getSDKConfig } from './chunk-55FTUSW7.js';
|
|
2
|
+
import './chunk-ITLN6GHC.js';
|
|
3
3
|
import './chunk-WHTI52FI.js';
|
|
4
4
|
import { sessionStore, createDefaultInjectedWalletRegistry, WalletConnector } from '@ab-org/sdk-core';
|
|
5
5
|
import { CubistSocialProvider } from '@ab-org/sdk-core/social/provider';
|
|
@@ -27,7 +27,16 @@ async function doAutoReconnect() {
|
|
|
27
27
|
);
|
|
28
28
|
}
|
|
29
29
|
const connector = new WalletConnector(adapters);
|
|
30
|
-
|
|
30
|
+
try {
|
|
31
|
+
const restoredSession = await connector.tryAutoReconnect();
|
|
32
|
+
if (!restoredSession) {
|
|
33
|
+
sessionStore.clearSession();
|
|
34
|
+
}
|
|
35
|
+
return restoredSession;
|
|
36
|
+
} catch {
|
|
37
|
+
sessionStore.clearSession();
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
31
40
|
}
|
|
32
41
|
|
|
33
42
|
export { tryAutoReconnect };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/core.ts
|
|
2
2
|
function tryAutoReconnect() {
|
|
3
|
-
return import('./autoReconnect-
|
|
3
|
+
return import('./autoReconnect-UEPGLSA7.js').then(({ tryAutoReconnect: reconnect }) => reconnect());
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
export { tryAutoReconnect };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { getOptionalEnv, setMerchantBaseUrl } from './chunk-
|
|
1
|
+
import { getOptionalEnv, setMerchantBaseUrl } from './chunk-ITLN6GHC.js';
|
|
2
2
|
import { getSDKConfig, initSDK } from './chunk-WHTI52FI.js';
|
|
3
|
+
import { sessionStore } from '@ab-org/sdk-core';
|
|
4
|
+
import { refreshCubeSignerSessionData } from '@ab-org/sdk-core/social/auth';
|
|
3
5
|
import axios from 'axios';
|
|
4
6
|
|
|
5
7
|
// src/auth/bundledConfig.ts
|
|
@@ -99,11 +101,54 @@ function getFixedAuthConfig() {
|
|
|
99
101
|
cubeSigner: cubeSignerFromEnv ?? bundled.cubeSigner
|
|
100
102
|
};
|
|
101
103
|
}
|
|
104
|
+
var CUBE_KEEPALIVE_INTERVAL_MS = 5 * 60 * 1e3;
|
|
105
|
+
function getCubistKeepAliveIntervalMs() {
|
|
106
|
+
const rawValue = getOptionalEnv("CUBE_KEEPALIVE_INTERVAL_MS");
|
|
107
|
+
if (!rawValue) return CUBE_KEEPALIVE_INTERVAL_MS;
|
|
108
|
+
const parsed = Number.parseInt(rawValue, 10);
|
|
109
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : CUBE_KEEPALIVE_INTERVAL_MS;
|
|
110
|
+
}
|
|
111
|
+
var cubistKeepAliveTimer = null;
|
|
112
|
+
var cubistKeepAlivePending = null;
|
|
113
|
+
function isCubistSession(session) {
|
|
114
|
+
if (!session?.sessionData) return false;
|
|
115
|
+
return session.walletType === "social" || session.authSource === "google" || session.authSource === "twitter";
|
|
116
|
+
}
|
|
117
|
+
function isAuthorizationError(error) {
|
|
118
|
+
return error instanceof Error && /\(401\)|\(403\)/.test(error.message);
|
|
119
|
+
}
|
|
120
|
+
async function refreshActiveCubistSession() {
|
|
121
|
+
const session = sessionStore.getState().session;
|
|
122
|
+
if (!isCubistSession(session)) return;
|
|
123
|
+
try {
|
|
124
|
+
const refreshedSessionData = await refreshCubeSignerSessionData(session.sessionData);
|
|
125
|
+
const latestSession = sessionStore.getState().session;
|
|
126
|
+
if (!latestSession || latestSession.sessionId !== session.sessionId) return;
|
|
127
|
+
sessionStore.setSession({
|
|
128
|
+
...latestSession,
|
|
129
|
+
sessionData: refreshedSessionData
|
|
130
|
+
});
|
|
131
|
+
} catch (error) {
|
|
132
|
+
if (isAuthorizationError(error)) {
|
|
133
|
+
sessionStore.clearSession();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
102
137
|
function scheduleAutoReconnect() {
|
|
103
138
|
if (typeof window === "undefined") return;
|
|
104
|
-
void import('./autoReconnect-
|
|
139
|
+
void import('./autoReconnect-UEPGLSA7.js').then(({ tryAutoReconnect }) => tryAutoReconnect()).catch(() => {
|
|
105
140
|
});
|
|
106
141
|
}
|
|
142
|
+
function scheduleCubistKeepAlive() {
|
|
143
|
+
if (typeof window === "undefined") return;
|
|
144
|
+
if (cubistKeepAliveTimer !== null) return;
|
|
145
|
+
const keepAliveIntervalMs = getCubistKeepAliveIntervalMs();
|
|
146
|
+
cubistKeepAliveTimer = window.setInterval(() => {
|
|
147
|
+
cubistKeepAlivePending ?? (cubistKeepAlivePending = refreshActiveCubistSession().finally(() => {
|
|
148
|
+
cubistKeepAlivePending = null;
|
|
149
|
+
}));
|
|
150
|
+
}, keepAliveIntervalMs);
|
|
151
|
+
}
|
|
107
152
|
function initSDK2(config = {}) {
|
|
108
153
|
const { merchantBaseUrl, registerUser, ...rest } = config;
|
|
109
154
|
const fixed = getFixedAuthConfig();
|
|
@@ -141,6 +186,7 @@ function initSDK2(config = {}) {
|
|
|
141
186
|
}
|
|
142
187
|
initSDK(merged);
|
|
143
188
|
scheduleAutoReconnect();
|
|
189
|
+
scheduleCubistKeepAlive();
|
|
144
190
|
}
|
|
145
191
|
function getSDKConfig2() {
|
|
146
192
|
return getSDKConfig();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getChainInfo, getFundingTokenAddress, DEFAULT_FUNDING_CHAIN_ID } from './chunk-
|
|
2
|
-
import { getChains, createOrder } from './chunk-
|
|
3
|
-
import { getEnv } from './chunk-
|
|
1
|
+
import { getChainInfo, getFundingTokenAddress, DEFAULT_FUNDING_CHAIN_ID } from './chunk-6MMOYCWR.js';
|
|
2
|
+
import { getChains, createOrder } from './chunk-AAFQWHHY.js';
|
|
3
|
+
import { getEnv } from './chunk-ITLN6GHC.js';
|
|
4
4
|
import { sessionStore, createSessionCapabilityPolicy } from '@ab-org/sdk-core';
|
|
5
5
|
import { formatUnits } from 'viem';
|
|
6
6
|
|