@ab-org/sdk-core 0.3.0-beta.3 → 0.3.0-beta.4

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.
@@ -1,3 +1,5 @@
1
+ import { jwtDecode } from 'jwt-decode';
2
+
1
3
  var __typeError = (msg) => {
2
4
  throw TypeError(msg);
3
5
  };
@@ -699,11 +701,12 @@ _address = new WeakMap();
699
701
  _key = new WeakMap();
700
702
  _client = new WeakMap();
701
703
  _options = new WeakMap();
702
-
703
- // src/providers/social/cubeSignerAuth.ts
704
704
  function resolveEnv(env) {
705
705
  return typeof env === "string" ? envs[env] : env;
706
706
  }
707
+ function decodeJwtPayload(token) {
708
+ return jwtDecode(token);
709
+ }
707
710
  async function refreshCubeSignerSessionData(sessionData) {
708
711
  const client = await CubeSignerClient.create(sessionData);
709
712
  await client.sessionKeys();
@@ -845,7 +848,23 @@ var CubeSignerAuth = class {
845
848
  const client = await CubeSignerClient.create(sessionData);
846
849
  this._client = client;
847
850
  this._sessionData = sessionData;
848
- return { client, sessionData };
851
+ const userInfo = this.parseOidcUserInfo(oidcToken);
852
+ return { client, sessionData, userInfo };
853
+ }
854
+ parseOidcUserInfo(oidcToken) {
855
+ try {
856
+ const claims = decodeJwtPayload(oidcToken);
857
+ const preferredUsername = claims.preferred_username;
858
+ const name = claims.name;
859
+ const email = claims.email;
860
+ const username = typeof preferredUsername === "string" ? preferredUsername : typeof name === "string" ? name : void 0;
861
+ return {
862
+ username,
863
+ email: typeof email === "string" ? email : void 0
864
+ };
865
+ } catch {
866
+ return {};
867
+ }
849
868
  }
850
869
  };
851
870
 
@@ -1,4 +1,4 @@
1
- import { CubeSignerAuth, createCubistEvmWalletProvider } from './chunk-VOUTMV6J.js';
1
+ import { CubeSignerAuth, createCubistEvmWalletProvider } from './chunk-ADMEF7PF.js';
2
2
 
3
3
  // src/core/chains.ts
4
4
  var chainDescriptors = {
@@ -267,7 +267,8 @@ var CubistSocialProvider = class extends AbstractSocialProvider {
267
267
  capabilities: CUBIST_CAPABILITIES,
268
268
  sessionData: session.sessionData,
269
269
  chainContext: walletSession.chainContext ?? createChainContext(walletSession.chain),
270
- capabilityPolicy
270
+ capabilityPolicy,
271
+ userInfo: session.userInfo
271
272
  };
272
273
  }
273
274
  async authenticate(method) {
@@ -344,7 +345,8 @@ var CubistSocialProvider = class extends AbstractSocialProvider {
344
345
  capabilities: CUBIST_CAPABILITIES,
345
346
  sessionData: csSession.sessionData,
346
347
  chainContext: createChainContext(restoredChain),
347
- capabilityPolicy: persistedSession.capabilityPolicy
348
+ capabilityPolicy: persistedSession.capabilityPolicy,
349
+ userInfo: persistedSession.userInfo ?? csSession.userInfo
348
350
  });
349
351
  } catch {
350
352
  return null;
@@ -53,6 +53,11 @@ declare const getAllChainDescriptors: () => ChainDescriptor[];
53
53
  declare const getSupportedChainFromEvmChainId: (value: string | number | bigint) => SupportedChain;
54
54
  declare const createChainContext: (walletChain: SupportedChain, settlementChain?: SupportedChain) => ChainContext;
55
55
 
56
+ /** OIDC-style display claims (username / email) attached to a wallet session when available. */
57
+ interface UserInfo {
58
+ username?: string;
59
+ email?: string;
60
+ }
56
61
  type SupportedChain = "AB_CORE" | "ETH" | "BSC" | "SOL" | "ETH_TENDERLY" | "BSC_TENDERLY";
57
62
  type SupportedToken = "USD1" | "USDC" | "USDT" | "ETH" | "AB";
58
63
  type ProviderCategory = "plugin" | "social";
@@ -115,6 +120,8 @@ interface WalletSession {
115
120
  sessionData?: unknown;
116
121
  chainContext?: ChainContext;
117
122
  capabilityPolicy?: SessionCapabilityPolicy;
123
+ /** OIDC-derived profile when the session came from social login (e.g. Google). */
124
+ userInfo?: UserInfo;
118
125
  }
119
126
  interface BalanceInfo {
120
127
  formatted: string;
@@ -368,6 +375,8 @@ interface CubeSignerSession {
368
375
  client: CubeSignerClient;
369
376
  /** Raw session data (can be persisted / refreshed). */
370
377
  sessionData: SessionData;
378
+ /** OIDC user info. */
379
+ userInfo?: UserInfo;
371
380
  }
372
381
  interface TwitterCodeExchangeParams {
373
382
  /** Authorization code from Twitter OAuth 2.0 PKCE flow. */
@@ -427,6 +436,7 @@ declare class CubeSignerAuth {
427
436
  * Create a CubeSigner OIDC session from a generic OIDC id_token.
428
437
  */
429
438
  private createOidcSession;
439
+ private parseOidcUserInfo;
430
440
  }
431
441
 
432
- export { getChainDescriptor as A, type BalanceInfo as B, CubeSignerAuth as C, getSupportedChainFromEvmChainId as D, type EvmTransactionRequest as E, isCapabilityPolicyExpired as F, isSessionExpired as G, sessionSupportsCapability as H, type OidcLoginHooks as O, type ProviderCategory as P, type SessionCapabilityCheck as S, type TwitterCodeExchangeParams as T, type WalletState as W, type CubeSignerConfig as a, type CubeSignerSession as b, type WalletSession as c, type WalletAdapter as d, type WalletConnectArgs as e, type WalletCapability as f, type WalletProviderRequest as g, type SupportedChain as h, type WalletProvider as i, type ChainContext as j, type SessionCapabilityPolicy as k, type ChainDescriptor as l, type ChainNamespace as m, type ChainRpcFamily as n, type EvmAccessListItem as o, type EvmQuantity as p, SessionCapabilityError as q, refreshCubeSignerSessionData as r, type SupportedToken as s, type WalletAuthSource as t, type WalletType as u, assertSessionCapability as v, createChainContext as w, createSessionCapabilityPolicy as x, describeSessionCapabilityPolicy as y, getAllChainDescriptors as z };
442
+ export { getChainDescriptor as A, type BalanceInfo as B, CubeSignerAuth as C, getSupportedChainFromEvmChainId as D, type EvmTransactionRequest as E, isCapabilityPolicyExpired as F, isSessionExpired as G, sessionSupportsCapability as H, type OidcLoginHooks as O, type ProviderCategory as P, type SessionCapabilityCheck as S, type TwitterCodeExchangeParams as T, type UserInfo as U, type WalletState as W, type CubeSignerConfig as a, type CubeSignerSession as b, type WalletSession as c, type WalletAdapter as d, type WalletConnectArgs as e, type WalletCapability as f, type WalletProviderRequest as g, type SupportedChain as h, type WalletProvider as i, type ChainContext as j, type SessionCapabilityPolicy as k, type ChainDescriptor as l, type ChainNamespace as m, type ChainRpcFamily as n, type EvmAccessListItem as o, type EvmQuantity as p, SessionCapabilityError as q, refreshCubeSignerSessionData as r, type SupportedToken as s, type WalletAuthSource as t, type WalletType as u, assertSessionCapability as v, createChainContext as w, createSessionCapabilityPolicy as x, describeSessionCapabilityPolicy as y, getAllChainDescriptors as z };
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-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';
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-C3n7VgB8.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, U as UserInfo, 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-C3n7VgB8.js';
3
3
  import EventEmitter from 'eventemitter3';
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';
4
+ import { e as AbstractProvider } from './social-provider-B1XSe1Sr.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-B1XSe1Sr.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-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';
1
+ import { createChainContext, AbstractProvider, getSupportedChainFromEvmChainId, assertSessionCapability } from './chunk-SBOQGPRF.js';
2
+ export { AbstractProvider, AbstractSocialProvider, CUBIST_CAPABILITIES, CubistSocialProvider, SessionCapabilityError, assertSessionCapability, createChainContext, createSessionCapabilityPolicy, describeSessionCapabilityPolicy, getAllChainDescriptors, getChainDescriptor, getSupportedChainFromEvmChainId, isCapabilityPolicyExpired, isSessionExpired, sessionSupportsCapability } from './chunk-SBOQGPRF.js';
3
+ export { CubeSignerAuth, refreshCubeSignerSessionData } from './chunk-ADMEF7PF.js';
4
4
  import EventEmitter from 'eventemitter3';
5
5
 
6
6
  // src/core/errors.ts
@@ -79,6 +79,9 @@ function persistSession(session) {
79
79
  if (session.capabilityPolicy !== void 0) {
80
80
  serializable.capabilityPolicy = session.capabilityPolicy;
81
81
  }
82
+ if (session.userInfo !== void 0) {
83
+ serializable.userInfo = session.userInfo;
84
+ }
82
85
  try {
83
86
  storage.setItem(STORAGE_KEY, JSON.stringify(serializable));
84
87
  } catch {
@@ -1,5 +1,5 @@
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';
1
+ import { b as CubeSignerSession, h as SupportedChain, i as WalletProvider } from './cubeSignerAuth-C3n7VgB8.js';
2
+ export { C as CubeSignerAuth, a as CubeSignerConfig, O as OidcLoginHooks, T as TwitterCodeExchangeParams, r as refreshCubeSignerSessionData } from './cubeSignerAuth-C3n7VgB8.js';
3
3
 
4
4
  interface CreateCubistEvmWalletProviderArgs {
5
5
  session: CubeSignerSession;
@@ -1 +1 @@
1
- export { CubeSignerAuth, createCubistEvmWalletProvider, refreshCubeSignerSessionData } from './chunk-VOUTMV6J.js';
1
+ export { CubeSignerAuth, createCubistEvmWalletProvider, refreshCubeSignerSessionData } from './chunk-ADMEF7PF.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-2hpyKGgW.js';
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-C3n7VgB8.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-QTza4QD-.js';
2
- import './cubeSignerAuth-2hpyKGgW.js';
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-B1XSe1Sr.js';
2
+ import './cubeSignerAuth-C3n7VgB8.js';
@@ -1,2 +1,2 @@
1
- export { AbstractSocialProvider, CUBIST_CAPABILITIES, CubistSocialProvider } from './chunk-AOCUWKMU.js';
2
- import './chunk-VOUTMV6J.js';
1
+ export { AbstractSocialProvider, CUBIST_CAPABILITIES, CubistSocialProvider } from './chunk-SBOQGPRF.js';
2
+ import './chunk-ADMEF7PF.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-2hpyKGgW.js';
1
+ export { C as CubeSignerAuth, a as CubeSignerConfig, b as CubeSignerSession, O as OidcLoginHooks, T as TwitterCodeExchangeParams, r as refreshCubeSignerSessionData } from './cubeSignerAuth-C3n7VgB8.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-QTza4QD-.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-B1XSe1Sr.js';
package/dist/social.js CHANGED
@@ -1,2 +1,2 @@
1
- export { AbstractSocialProvider, CUBIST_CAPABILITIES, CubistSocialProvider } from './chunk-AOCUWKMU.js';
2
- export { CubeSignerAuth, createCubistEvmWalletProvider, refreshCubeSignerSessionData } from './chunk-VOUTMV6J.js';
1
+ export { AbstractSocialProvider, CUBIST_CAPABILITIES, CubistSocialProvider } from './chunk-SBOQGPRF.js';
2
+ export { CubeSignerAuth, createCubistEvmWalletProvider, refreshCubeSignerSessionData } from './chunk-ADMEF7PF.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ab-org/sdk-core",
3
- "version": "0.3.0-beta.3",
3
+ "version": "0.3.0-beta.4",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist/**/*",
@@ -31,7 +31,8 @@
31
31
  "registry": "https://registry.npmjs.org/"
32
32
  },
33
33
  "dependencies": {
34
- "eventemitter3": "^5.0.1"
34
+ "eventemitter3": "^5.0.1",
35
+ "jwt-decode": "^4.0.0"
35
36
  },
36
37
  "devDependencies": {
37
38
  "typescript": "^5.5.4",