@ab-org/sdk-core 0.3.0-beta.1 → 0.3.0-beta.3
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/{chunk-6MYKCH4B.js → chunk-AOCUWKMU.js} +1 -1
- package/dist/{chunk-ICBI4K6V.js → chunk-VOUTMV6J.js} +68 -2
- package/dist/{cubeSignerAuth-CPAFyY1y.d.ts → cubeSignerAuth-2hpyKGgW.d.ts} +3 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +3 -3
- package/dist/social-auth.d.ts +4 -3
- package/dist/social-auth.js +1 -1
- package/dist/{social-provider-Djlvwn3K.d.ts → social-provider-QTza4QD-.d.ts} +1 -1
- package/dist/social-provider.d.ts +2 -2
- package/dist/social-provider.js +2 -2
- package/dist/social.d.ts +2 -2
- package/dist/social.js +2 -2
- package/package.json +1 -1
|
@@ -716,6 +716,7 @@ var CubeSignerAuth = class {
|
|
|
716
716
|
this.env = resolveEnv(config.env);
|
|
717
717
|
this.orgId = config.orgId;
|
|
718
718
|
this.scopes = config.scopes ?? ["sign:*", "manage:*"];
|
|
719
|
+
this.lifetimes = config.lifetimes ?? { session: 60 * 60 * 24 * 30, auth: 60 * 60 * 24 * 30, refresh: 60 * 60 * 24 * 30 * 2 };
|
|
719
720
|
this.defaultSessionPolicy = config.defaultSessionPolicy;
|
|
720
721
|
this.oidcLoginHooks = config.oidcLoginHooks;
|
|
721
722
|
}
|
|
@@ -837,7 +838,8 @@ var CubeSignerAuth = class {
|
|
|
837
838
|
this.env,
|
|
838
839
|
this.orgId,
|
|
839
840
|
oidcToken,
|
|
840
|
-
this.scopes
|
|
841
|
+
this.scopes,
|
|
842
|
+
this.lifetimes
|
|
841
843
|
);
|
|
842
844
|
const sessionData = resp.data();
|
|
843
845
|
const client = await CubeSignerClient.create(sessionData);
|
|
@@ -854,6 +856,12 @@ var evmChainIdMap = {
|
|
|
854
856
|
ETH_TENDERLY: 3030,
|
|
855
857
|
BSC_TENDERLY: 3131
|
|
856
858
|
};
|
|
859
|
+
var evmRpcUrlMap = {
|
|
860
|
+
ETH: "https://wallet-test.tomo.inc/rpc/v1/eth",
|
|
861
|
+
BSC: "https://bsc-dataseed.binance.org",
|
|
862
|
+
ETH_TENDERLY: "https://virtual.mainnet.us-east.rpc.tenderly.co/f336429f-f6da-4443-bbce-327d086c11b3",
|
|
863
|
+
BSC_TENDERLY: "https://virtual.binance.eu.rpc.tenderly.co/e643ea28-32eb-4fb9-8116-90be24f7defa"
|
|
864
|
+
};
|
|
857
865
|
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
858
866
|
var toBigIntQuantity = (value) => {
|
|
859
867
|
if (typeof value === "bigint") return value;
|
|
@@ -964,10 +972,59 @@ var getTypedDataParam = (address, params) => {
|
|
|
964
972
|
}
|
|
965
973
|
return typeof second === "string" ? JSON.parse(second) : second ?? first ?? {};
|
|
966
974
|
};
|
|
975
|
+
var getRpcUrl = (chain, rpcUrl) => {
|
|
976
|
+
if (rpcUrl && rpcUrl.trim() !== "") {
|
|
977
|
+
return rpcUrl;
|
|
978
|
+
}
|
|
979
|
+
const resolvedRpcUrl = evmRpcUrlMap[chain];
|
|
980
|
+
if (!resolvedRpcUrl) {
|
|
981
|
+
throw new Error(`CubistProvider: chain ${chain} does not expose an EVM RPC url`);
|
|
982
|
+
}
|
|
983
|
+
return resolvedRpcUrl;
|
|
984
|
+
};
|
|
985
|
+
var rpcRequest = async (chain, rpcUrl, method, params) => {
|
|
986
|
+
const response = await fetch(getRpcUrl(chain, rpcUrl), {
|
|
987
|
+
method: "POST",
|
|
988
|
+
headers: { "Content-Type": "application/json" },
|
|
989
|
+
body: JSON.stringify({
|
|
990
|
+
id: Date.now(),
|
|
991
|
+
jsonrpc: "2.0",
|
|
992
|
+
method,
|
|
993
|
+
params
|
|
994
|
+
})
|
|
995
|
+
});
|
|
996
|
+
if (!response.ok) {
|
|
997
|
+
throw new Error(`CubistProvider: ${method} failed (${response.status})`);
|
|
998
|
+
}
|
|
999
|
+
const payload = await response.json();
|
|
1000
|
+
if (payload.error) {
|
|
1001
|
+
throw new Error(payload.error.message ?? `CubistProvider: ${method} failed`);
|
|
1002
|
+
}
|
|
1003
|
+
if (payload.result === void 0) {
|
|
1004
|
+
throw new Error(`CubistProvider: ${method} returned no result`);
|
|
1005
|
+
}
|
|
1006
|
+
return payload.result;
|
|
1007
|
+
};
|
|
1008
|
+
var withPendingNonce = async (address, chain, rpcUrl, transaction) => {
|
|
1009
|
+
if (transaction.nonce !== void 0) {
|
|
1010
|
+
return transaction;
|
|
1011
|
+
}
|
|
1012
|
+
const from = transaction.from ?? address;
|
|
1013
|
+
const nonce = await rpcRequest(chain, rpcUrl, "eth_getTransactionCount", [from, "pending"]);
|
|
1014
|
+
return {
|
|
1015
|
+
...transaction,
|
|
1016
|
+
from,
|
|
1017
|
+
nonce
|
|
1018
|
+
};
|
|
1019
|
+
};
|
|
1020
|
+
var sendRawTransaction = async (chain, rpcUrl, rawTransaction) => {
|
|
1021
|
+
return rpcRequest(chain, rpcUrl, "eth_sendRawTransaction", [rawTransaction]);
|
|
1022
|
+
};
|
|
967
1023
|
var createCubistEvmWalletProvider = ({
|
|
968
1024
|
session,
|
|
969
1025
|
address,
|
|
970
|
-
chain
|
|
1026
|
+
chain,
|
|
1027
|
+
rpcUrl
|
|
971
1028
|
}) => {
|
|
972
1029
|
const signer = new EvmSigner(address, session.client);
|
|
973
1030
|
return {
|
|
@@ -988,6 +1045,15 @@ var createCubistEvmWalletProvider = ({
|
|
|
988
1045
|
const signRequest = toCubistSignRequest(address, chain, transaction);
|
|
989
1046
|
return await signer.signTransaction(signRequest);
|
|
990
1047
|
}
|
|
1048
|
+
case "eth_sendTransaction": {
|
|
1049
|
+
const transaction = getTransactionParam(payload.params);
|
|
1050
|
+
const resolvedTransaction = await withPendingNonce(address, chain, rpcUrl, transaction);
|
|
1051
|
+
const signRequest = toCubistSignRequest(address, chain, resolvedTransaction);
|
|
1052
|
+
const rawTransaction = await signer.signTransaction(signRequest);
|
|
1053
|
+
return await sendRawTransaction(chain, rpcUrl, rawTransaction);
|
|
1054
|
+
}
|
|
1055
|
+
case "eth_call":
|
|
1056
|
+
return await rpcRequest(chain, rpcUrl, "eth_call", payload.params ?? []);
|
|
991
1057
|
case "personal_sign": {
|
|
992
1058
|
const message = getMessageParam(address, payload.params);
|
|
993
1059
|
return await signer.signEip191({
|
|
@@ -352,6 +352,8 @@ interface CubeSignerConfig {
|
|
|
352
352
|
orgId: string;
|
|
353
353
|
/** Session scopes (default: `["sign:*", "manage:*"]`). */
|
|
354
354
|
scopes?: string[];
|
|
355
|
+
/** Session lifetimes (default: `{ session: 60 * 60 * 24 * 30, auth: 60 * 60 * 24 * 30, refresh: 60 * 60 * 24 * 30*2 }`). */
|
|
356
|
+
lifetimes?: RatchetConfig;
|
|
355
357
|
/** Optional capability policy applied to smart-wallet sessions created from this auth flow. */
|
|
356
358
|
defaultSessionPolicy?: Partial<SessionCapabilityPolicy>;
|
|
357
359
|
/**
|
|
@@ -380,6 +382,7 @@ declare class CubeSignerAuth {
|
|
|
380
382
|
private readonly env;
|
|
381
383
|
private readonly orgId;
|
|
382
384
|
private readonly scopes;
|
|
385
|
+
private readonly lifetimes;
|
|
383
386
|
readonly defaultSessionPolicy?: Partial<SessionCapabilityPolicy>;
|
|
384
387
|
private readonly oidcLoginHooks?;
|
|
385
388
|
private _client;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { W as WalletState, c as WalletSession, B as BalanceInfo, d as WalletAdapter, e as WalletConnectArgs, f as WalletCapability, g as WalletProviderRequest, E as EvmTransactionRequest, S as SessionCapabilityCheck, h as SupportedChain, i as WalletProvider, j as ChainContext, k as SessionCapabilityPolicy } from './cubeSignerAuth-
|
|
2
|
-
export { l as ChainDescriptor, m as ChainNamespace, n as ChainRpcFamily, C as CubeSignerAuth, a as CubeSignerConfig, b as CubeSignerSession, o as EvmAccessListItem, p as EvmQuantity, O as OidcLoginHooks, P as ProviderCategory, q as SessionCapabilityError, s as SupportedToken, T as TwitterCodeExchangeParams, t as WalletAuthSource, u as WalletType, v as assertSessionCapability, w as createChainContext, x as createSessionCapabilityPolicy, y as describeSessionCapabilityPolicy, z as getAllChainDescriptors, A as getChainDescriptor, D as getSupportedChainFromEvmChainId, F as isCapabilityPolicyExpired, G as isSessionExpired, r as refreshCubeSignerSessionData, H as sessionSupportsCapability } from './cubeSignerAuth-
|
|
1
|
+
import { W as WalletState, c as WalletSession, B as BalanceInfo, d as WalletAdapter, e as WalletConnectArgs, f as WalletCapability, g as WalletProviderRequest, E as EvmTransactionRequest, S as SessionCapabilityCheck, h as SupportedChain, i as WalletProvider, j as ChainContext, k as SessionCapabilityPolicy } from './cubeSignerAuth-2hpyKGgW.js';
|
|
2
|
+
export { l as ChainDescriptor, m as ChainNamespace, n as ChainRpcFamily, C as CubeSignerAuth, a as CubeSignerConfig, b as CubeSignerSession, o as EvmAccessListItem, p as EvmQuantity, O as OidcLoginHooks, P as ProviderCategory, q as SessionCapabilityError, s as SupportedToken, T as TwitterCodeExchangeParams, t as WalletAuthSource, u as WalletType, v as assertSessionCapability, w as createChainContext, x as createSessionCapabilityPolicy, y as describeSessionCapabilityPolicy, z as getAllChainDescriptors, A as getChainDescriptor, D as getSupportedChainFromEvmChainId, F as isCapabilityPolicyExpired, G as isSessionExpired, r as refreshCubeSignerSessionData, H as sessionSupportsCapability } from './cubeSignerAuth-2hpyKGgW.js';
|
|
3
3
|
import EventEmitter from 'eventemitter3';
|
|
4
|
-
import { e as AbstractProvider } from './social-provider-
|
|
5
|
-
export { A as AbstractSocialProvider, C as CUBIST_CAPABILITIES, a as CubistLoginMethod, b as CubistSessionAdapter, c as CubistSocialProvider, S as SocialConnectArgs, d as SocialLoginOptions } from './social-provider-
|
|
4
|
+
import { e as AbstractProvider } from './social-provider-QTza4QD-.js';
|
|
5
|
+
export { A as AbstractSocialProvider, C as CUBIST_CAPABILITIES, a as CubistLoginMethod, b as CubistSessionAdapter, c as CubistSocialProvider, S as SocialConnectArgs, d as SocialLoginOptions } from './social-provider-QTza4QD-.js';
|
|
6
6
|
|
|
7
7
|
declare const EVM_TRANSACTION_SIGNING_UNSUPPORTED = "EVM_TRANSACTION_SIGNING_UNSUPPORTED";
|
|
8
8
|
declare class EvmTransactionSigningUnsupportedError extends Error {
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createChainContext, AbstractProvider, getSupportedChainFromEvmChainId, assertSessionCapability } from './chunk-
|
|
2
|
-
export { AbstractProvider, AbstractSocialProvider, CUBIST_CAPABILITIES, CubistSocialProvider, SessionCapabilityError, assertSessionCapability, createChainContext, createSessionCapabilityPolicy, describeSessionCapabilityPolicy, getAllChainDescriptors, getChainDescriptor, getSupportedChainFromEvmChainId, isCapabilityPolicyExpired, isSessionExpired, sessionSupportsCapability } from './chunk-
|
|
3
|
-
export { CubeSignerAuth, refreshCubeSignerSessionData } from './chunk-
|
|
1
|
+
import { createChainContext, AbstractProvider, getSupportedChainFromEvmChainId, assertSessionCapability } from './chunk-AOCUWKMU.js';
|
|
2
|
+
export { AbstractProvider, AbstractSocialProvider, CUBIST_CAPABILITIES, CubistSocialProvider, SessionCapabilityError, assertSessionCapability, createChainContext, createSessionCapabilityPolicy, describeSessionCapabilityPolicy, getAllChainDescriptors, getChainDescriptor, getSupportedChainFromEvmChainId, isCapabilityPolicyExpired, isSessionExpired, sessionSupportsCapability } from './chunk-AOCUWKMU.js';
|
|
3
|
+
export { CubeSignerAuth, refreshCubeSignerSessionData } from './chunk-VOUTMV6J.js';
|
|
4
4
|
import EventEmitter from 'eventemitter3';
|
|
5
5
|
|
|
6
6
|
// src/core/errors.ts
|
package/dist/social-auth.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { b as CubeSignerSession, h as SupportedChain, i as WalletProvider } from './cubeSignerAuth-
|
|
2
|
-
export { C as CubeSignerAuth, a as CubeSignerConfig, O as OidcLoginHooks, T as TwitterCodeExchangeParams, r as refreshCubeSignerSessionData } from './cubeSignerAuth-
|
|
1
|
+
import { b as CubeSignerSession, h as SupportedChain, i as WalletProvider } from './cubeSignerAuth-2hpyKGgW.js';
|
|
2
|
+
export { C as CubeSignerAuth, a as CubeSignerConfig, O as OidcLoginHooks, T as TwitterCodeExchangeParams, r as refreshCubeSignerSessionData } from './cubeSignerAuth-2hpyKGgW.js';
|
|
3
3
|
|
|
4
4
|
interface CreateCubistEvmWalletProviderArgs {
|
|
5
5
|
session: CubeSignerSession;
|
|
6
6
|
address: string;
|
|
7
7
|
chain: SupportedChain;
|
|
8
|
+
rpcUrl?: string;
|
|
8
9
|
}
|
|
9
|
-
declare const createCubistEvmWalletProvider: ({ session, address, chain, }: CreateCubistEvmWalletProviderArgs) => WalletProvider;
|
|
10
|
+
declare const createCubistEvmWalletProvider: ({ session, address, chain, rpcUrl, }: CreateCubistEvmWalletProviderArgs) => WalletProvider;
|
|
10
11
|
|
|
11
12
|
export { CubeSignerSession, createCubistEvmWalletProvider };
|
package/dist/social-auth.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { CubeSignerAuth, createCubistEvmWalletProvider, refreshCubeSignerSessionData } from './chunk-
|
|
1
|
+
export { CubeSignerAuth, createCubistEvmWalletProvider, refreshCubeSignerSessionData } from './chunk-VOUTMV6J.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as WalletAdapter, P as ProviderCategory, c as WalletSession, e as WalletConnectArgs, i as WalletProvider, f as WalletCapability, T as TwitterCodeExchangeParams, b as CubeSignerSession, a as CubeSignerConfig, C as CubeSignerAuth } from './cubeSignerAuth-
|
|
1
|
+
import { d as WalletAdapter, P as ProviderCategory, c as WalletSession, e as WalletConnectArgs, i as WalletProvider, f as WalletCapability, T as TwitterCodeExchangeParams, b as CubeSignerSession, a as CubeSignerConfig, C as CubeSignerAuth } from './cubeSignerAuth-2hpyKGgW.js';
|
|
2
2
|
|
|
3
3
|
declare abstract class AbstractProvider implements WalletAdapter {
|
|
4
4
|
abstract readonly id: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { A as AbstractSocialProvider, C as CUBIST_CAPABILITIES, a as CubistLoginMethod, b as CubistSessionAdapter, c as CubistSocialProvider, S as SocialConnectArgs, d as SocialLoginOptions } from './social-provider-
|
|
2
|
-
import './cubeSignerAuth-
|
|
1
|
+
export { A as AbstractSocialProvider, C as CUBIST_CAPABILITIES, a as CubistLoginMethod, b as CubistSessionAdapter, c as CubistSocialProvider, S as SocialConnectArgs, d as SocialLoginOptions } from './social-provider-QTza4QD-.js';
|
|
2
|
+
import './cubeSignerAuth-2hpyKGgW.js';
|
package/dist/social-provider.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { AbstractSocialProvider, CUBIST_CAPABILITIES, CubistSocialProvider } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { AbstractSocialProvider, CUBIST_CAPABILITIES, CubistSocialProvider } from './chunk-AOCUWKMU.js';
|
|
2
|
+
import './chunk-VOUTMV6J.js';
|
package/dist/social.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { C as CubeSignerAuth, a as CubeSignerConfig, b as CubeSignerSession, O as OidcLoginHooks, T as TwitterCodeExchangeParams, r as refreshCubeSignerSessionData } from './cubeSignerAuth-
|
|
1
|
+
export { C as CubeSignerAuth, a as CubeSignerConfig, b as CubeSignerSession, O as OidcLoginHooks, T as TwitterCodeExchangeParams, r as refreshCubeSignerSessionData } from './cubeSignerAuth-2hpyKGgW.js';
|
|
2
2
|
export { createCubistEvmWalletProvider } from './social-auth.js';
|
|
3
|
-
export { A as AbstractSocialProvider, C as CUBIST_CAPABILITIES, a as CubistLoginMethod, b as CubistSessionAdapter, c as CubistSocialProvider, S as SocialConnectArgs, d as SocialLoginOptions } from './social-provider-
|
|
3
|
+
export { A as AbstractSocialProvider, C as CUBIST_CAPABILITIES, a as CubistLoginMethod, b as CubistSessionAdapter, c as CubistSocialProvider, S as SocialConnectArgs, d as SocialLoginOptions } from './social-provider-QTza4QD-.js';
|
package/dist/social.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { AbstractSocialProvider, CUBIST_CAPABILITIES, CubistSocialProvider } from './chunk-
|
|
2
|
-
export { CubeSignerAuth, createCubistEvmWalletProvider, refreshCubeSignerSessionData } from './chunk-
|
|
1
|
+
export { AbstractSocialProvider, CUBIST_CAPABILITIES, CubistSocialProvider } from './chunk-AOCUWKMU.js';
|
|
2
|
+
export { CubeSignerAuth, createCubistEvmWalletProvider, refreshCubeSignerSessionData } from './chunk-VOUTMV6J.js';
|