Skip to content

Commit 031eb1b

Browse files
github-actions[bot]JasonCWanglightspark-ci-js-sdk[bot]Lightspark Engpengying
authored
Updates to core, ui, lightspark-sdk (#477)
* [penny test] Add pending state for name match (#19940) ## Reason In order to enforce name matching in the MX onboarding flow, we need to add a pending page and different landing pages depending on the name matching result. This PR adds the pending page when the GK is enabled. Design: https://www.figma.com/design/hb8mqsg0n3QKJHpJA0ahkI/MXN-Grid-Switch?node-id=17-15925&m=dev Screenshots below: ![Screenshot 2025-08-21 at 2.24.16 PM.png](https://app.graphite.dev/user-attachments/assets/555e2954-9675-4222-a33c-d91bd164cf3e.png) ![Screenshot 2025-08-21 at 2.24.32 PM.png](https://app.graphite.dev/user-attachments/assets/070c7fbb-4f54-4c13-a3da-dbb51d0077d2.png) GitOrigin-RevId: 16f902a477add267300b15f73f2420bbadccbd53 * Update from public js-sdk main branch (#19974) Update public `js` sources with the latest code from the [public repository](https://github.com/lightsparkdev/js-sdk) main branch. This typically happens when new versions of the SDK are released and version updates need to be synced. The PR should be merged as soon as possible to avoid updates to webdev overwriting the changes in the js-sdk develop branch. --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Lightspark Eng <[email protected]> Co-authored-by: Peng Ying <[email protected]> GitOrigin-RevId: e30a45111187be96d3583658bd02bb271521e53f * [penny test] Add other landing pages to name verification (#19968) ![Screenshot 2025-08-21 at 5.07.39 PM.png](https://app.graphite.dev/user-attachments/assets/00da5f22-8717-4364-b756-df21aad7488d.png) ![Screenshot 2025-08-21 at 5.07.58 PM.png](https://app.graphite.dev/user-attachments/assets/f7825e52-4fa7-450e-bfbc-5a3bac1c31da.png) GitOrigin-RevId: fd51392ec1ad6c61ea11a55e4810cf5ff0bce6df * Add new uma card status for pending name verification (#19996) ![Screenshot 2025-08-22 at 12.52.46 PM.png](https://app.graphite.dev/user-attachments/assets/fa2e9b48-d1e9-4ed1-9999-2ec91e297b02.png) ![Screenshot 2025-08-22 at 12.52.49 PM.png](https://app.graphite.dev/user-attachments/assets/f71dbeee-9947-4014-b63c-7d45e516d6b8.png) GitOrigin-RevId: 8a5e2a6ef5f2d08ce7ea2ce14fe9fc59a4cfb714 * switch to use fun facts wrapper and transitioning text (#20036) ## Reason Add "fun facts" while users wait for their kyc to complete ## Overview This re-uses the same fun facts component from LinkBankMX ## Test Plan KYC a user - while their kyc is in pending state, we should see the following screen, complete with fun facts ![Screenshot 2025-08-24 at 6.21.54 PM.png](https://app.graphite.dev/user-attachments/assets/cf729f5e-7ec8-4fb8-ae33-de2e10c63231.png) GitOrigin-RevId: fe6335c827bd3110d2915b288da66b6de04d3e11 * [Nage] Move CommandCenter to SideNav (#19881) ![Screenshot 2025-08-18 at 5.25.07 PM.png](https://app.graphite.dev/user-attachments/assets/0fb72900-d9b6-4010-9274-9cfafa4245c0.png) GitOrigin-RevId: 6388684ba3bcce5fad01df8fbbb3621f23691c04 * [core] Add circular-deps check and resolve issues (#20020) ## Reason Typically we have this circular-deps check for JS packages but it was never added to this one. I realized it's causing a downstream issue so this adds the check and resolves circular deps. GitOrigin-RevId: 1ea0bf0d6f3c7f48a38527f971cb9c32c90b6a7a * [lightspark-sdk] Add circular-deps check and resolve issues (#20022) ## Reason Typically we have this circular-deps check for JS packages but it was never added to this one. I realized it's causing a downstream issue so this adds the check and resolves circular deps. GitOrigin-RevId: cc9081a0419495600c89ebec1d9e4c8ff6b5c9b3 * CI update lock file for PR * [core] RN entrypoint to remove ws import in spark-sdk (#20021) ## Reason It's not exactly clear when this became an issue for spark-sdk on React Native because originally it was working fine with a dynamic import. Somewhere along the way, possibly due to an updated dependency in spark/js lock file, it started causing the following error: <img width="479" height="377" alt="Screenshot 2025-08-21 at 11 27 57 PM" src="https://github.com/user-attachments/assets/206d254b-b721-4c84-b93c-559f3039a042" /> We need to avoid referencing ws in React Native entrypoints which resolves the issue. GitOrigin-RevId: 8e9297ac7c1d096d90fd0f46096187cc92256c2b * Create shy-bugs-march.md * Create tame-sites-mate.md * Create short-parts-march.md --------- Co-authored-by: Jason Wang <[email protected]> Co-authored-by: lightspark-ci-js-sdk[bot] <134011073+lightspark-ci-js-sdk[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Lightspark Eng <[email protected]> Co-authored-by: Peng Ying <[email protected]> Co-authored-by: Matt Davis <[email protected]> Co-authored-by: Corey Martin <[email protected]>
1 parent 9d0ba52 commit 031eb1b

26 files changed

+315
-115
lines changed

.changeset/short-parts-march.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@lightsparkdev/lightspark-sdk": patch
3+
---
4+
5+
- Resolve circular dependencies

.changeset/shy-bugs-march.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@lightsparkdev/ui": patch
3+
---
4+
5+
- Icon, component updates

.changeset/tame-sites-mate.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@lightsparkdev/core": patch
3+
---
4+
5+
- Resolve circular dependencies
6+
- React Native compatible entrypoint

packages/core/package.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"types": "./dist/index.d.ts",
2525
"exports": {
2626
".": {
27+
"react-native": "./dist/react-native/index.js",
2728
"import": "./dist/index.js",
2829
"require": "./dist/index.cjs"
2930
},
@@ -39,6 +40,7 @@
3940
"src/*",
4041
"dist/*",
4142
"dist/utils/*",
43+
"dist/react-native/*",
4244
"CHANGELOG.md"
4345
],
4446
"scripts": {
@@ -51,6 +53,7 @@
5153
"lint:fix": "eslint --fix .",
5254
"lint:watch": "esw ./src -w --ext .ts,.tsx,.js --color",
5355
"lint": "eslint .",
56+
"circular-deps": "madge --circular --extensions ts,tsx src",
5457
"package:checks": "yarn publint && yarn attw --pack .",
5558
"postversion": "yarn build",
5659
"test-cmd": "node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --bail",
@@ -81,6 +84,7 @@
8184
"eslint-watch": "^8.0.0",
8285
"jest": "^29.6.2",
8386
"lodash-es": "^4.17.21",
87+
"madge": "^6.1.0",
8488
"prettier": "3.0.3",
8589
"prettier-plugin-organize-imports": "^3.2.4",
8690
"publint": "^0.3.9",
@@ -89,6 +93,16 @@
8993
"tsup": "^8.2.4",
9094
"typescript": "^5.6.2"
9195
},
96+
"madge": {
97+
"detectiveOptions": {
98+
"ts": {
99+
"skipTypeImports": true
100+
},
101+
"tsx": {
102+
"skipTypeImports": true
103+
}
104+
}
105+
},
92106
"engines": {
93107
"node": ">=18"
94108
}

packages/core/src/Logger.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { ConfigKeys, getLocalStorageConfigItem } from "./index.js";
1+
import { ConfigKeys } from "./constants/index.js";
22
import { isBrowser, isTest } from "./utils/environment.js";
3+
import { getLocalStorageConfigItem } from "./utils/localStorage.js";
34

45
type GetLoggingEnabled = (() => Promise<boolean> | boolean) | undefined;
56

packages/core/src/crypto/SigningKey.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import secp256k1 from "secp256k1";
2-
import { SigningKeyType, type CryptoInterface } from "../index.js";
3-
import { createSha256Hash, hexToBytes } from "../utils/index.js";
2+
import { createSha256Hash } from "../utils/createHash.js";
3+
import { hexToBytes } from "../utils/hex.js";
4+
import type { CryptoInterface } from "./crypto.js";
5+
import { SigningKeyType } from "./types.js";
46

57
interface Alias {
68
alias: string;

packages/core/src/index.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
22

3-
export * from "./auth/index.js";
4-
export * from "./constants/index.js";
5-
export * from "./crypto/index.js";
6-
export { default as LightsparkException } from "./LightsparkException.js";
7-
export { Logger, LoggingLevel, logger } from "./Logger.js";
8-
export * from "./requester/index.js";
9-
export {
10-
default as ServerEnvironment,
11-
apiDomainForEnvironment,
12-
} from "./ServerEnvironment.js";
13-
export * from "./utils/index.js";
3+
export { DefaultRequester as Requester } from "./requester/DefaultRequester.js";
4+
export { default as Query } from "./requester/Query.js";
5+
export * from "./shared.js";
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from "../requester/index.js";
2+
export * from "../shared.js";
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import type AuthProvider from "../auth/AuthProvider.js";
2+
import { isBare, isNode } from "../utils/environment.js";
3+
import Requester from "./Requester.js";
4+
5+
export class DefaultRequester extends Requester {
6+
protected async initWsClient(baseUrl: string, authProvider: AuthProvider) {
7+
if (!this.resolveWsClient) {
8+
/* If resolveWsClient is null assume already initialized: */
9+
return this.wsClient;
10+
}
11+
12+
if (isBare) {
13+
/* graphql-ws library is currently not supported in Bare environment, see LIG-7942 */
14+
return null;
15+
}
16+
17+
let websocketImpl;
18+
if (isNode && typeof WebSocket === "undefined") {
19+
const wsModule = await import("ws");
20+
websocketImpl = wsModule.default;
21+
}
22+
let websocketProtocol = "wss";
23+
if (baseUrl.startsWith("http://")) {
24+
websocketProtocol = "ws";
25+
}
26+
27+
const graphqlWsModule = await import("graphql-ws");
28+
const { createClient } = graphqlWsModule;
29+
30+
const wsClient = createClient({
31+
url: `${websocketProtocol}://${this.stripProtocol(this.baseUrl)}/${
32+
this.schemaEndpoint
33+
}`,
34+
connectionParams: () => authProvider.addWsConnectionParams({}),
35+
webSocketImpl: websocketImpl,
36+
});
37+
38+
if (this.resolveWsClient) {
39+
this.resolveWsClient(wsClient);
40+
this.resolveWsClient = null;
41+
}
42+
43+
return wsClient;
44+
}
45+
}
46+
export default DefaultRequester;

packages/core/src/requester/Requester.ts

Lines changed: 11 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import type { SigningKey } from "../crypto/SigningKey.js";
1717
import LightsparkException from "../LightsparkException.js";
1818
import { logger } from "../Logger.js";
1919
import { b64encode } from "../utils/base64.js";
20-
import { isBare, isNode } from "../utils/environment.js";
20+
import { isNode } from "../utils/environment.js";
2121

2222
const DEFAULT_BASE_URL = "api.lightspark.com";
2323
dayjs.extend(utc);
@@ -31,14 +31,14 @@ type BodyData = {
3131
};
3232

3333
class Requester {
34-
private wsClient: Promise<WsClient | null>;
35-
private resolveWsClient: ((value: WsClient | null) => void) | null = null;
34+
protected wsClient: Promise<WsClient | null>;
35+
protected resolveWsClient: ((value: WsClient | null) => void) | null = null;
3636
constructor(
3737
private readonly nodeKeyCache: NodeKeyCache,
38-
private readonly schemaEndpoint: string,
38+
protected readonly schemaEndpoint: string,
3939
private readonly sdkUserAgent: string,
4040
private readonly authProvider: AuthProvider = new StubAuthProvider(),
41-
private readonly baseUrl: string = DEFAULT_BASE_URL,
41+
protected readonly baseUrl: string = DEFAULT_BASE_URL,
4242
private readonly cryptoImpl: CryptoInterface = DefaultCrypto,
4343
private readonly signingKey?: SigningKey,
4444
private readonly fetchImpl: typeof fetch = fetch,
@@ -50,44 +50,11 @@ class Requester {
5050
autoBind(this);
5151
}
5252

53-
private async initWsClient(baseUrl: string, authProvider: AuthProvider) {
54-
if (!this.resolveWsClient) {
55-
/* If resolveWsClient is null assume already initialized: */
56-
return this.wsClient;
57-
}
58-
59-
if (isBare) {
60-
/* graphql-ws library is currently not supported in Bare environment, see LIG-7942 */
61-
return null;
62-
}
63-
64-
let websocketImpl;
65-
if (isNode && typeof WebSocket === "undefined") {
66-
const wsModule = await import("ws");
67-
websocketImpl = wsModule.default;
68-
}
69-
let websocketProtocol = "wss";
70-
if (baseUrl.startsWith("http://")) {
71-
websocketProtocol = "ws";
72-
}
73-
74-
const graphqlWsModule = await import("graphql-ws");
75-
const { createClient } = graphqlWsModule;
76-
77-
const wsClient = createClient({
78-
url: `${websocketProtocol}://${this.stripProtocol(this.baseUrl)}/${
79-
this.schemaEndpoint
80-
}`,
81-
connectionParams: () => authProvider.addWsConnectionParams({}),
82-
webSocketImpl: websocketImpl,
83-
});
84-
85-
if (this.resolveWsClient) {
86-
this.resolveWsClient(wsClient);
87-
this.resolveWsClient = null;
88-
}
89-
90-
return wsClient;
53+
protected initWsClient(
54+
baseUrl: string,
55+
authProvider: AuthProvider,
56+
): Promise<WsClient | null> {
57+
return Promise.resolve(null);
9158
}
9259

9360
public async executeQuery<T>(query: Query<T>): Promise<T | null> {
@@ -293,7 +260,7 @@ class Requester {
293260
return `${this.sdkUserAgent} ${platform}/${platformVersion}`;
294261
}
295262

296-
private stripProtocol(url: string): string {
263+
protected stripProtocol(url: string): string {
297264
return url.replace(/.*?:\/\//g, "");
298265
}
299266

0 commit comments

Comments
 (0)