-
Notifications
You must be signed in to change notification settings - Fork 4
Bridge debugging Report #282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
5e5d83e
4927213
86cea46
bbb5a50
6a0a18e
b7177d3
253d109
6d5439a
94fad3b
99f432b
553736e
5df3b4d
41beb9c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,11 @@ import { | |
| createNativeRequest, | ||
| type BuilderConfig, | ||
| } from "./transports/native"; | ||
| import { | ||
| createIDKitDebugReport, | ||
| isDebug, | ||
| type IDKitDebugReport, | ||
| } from "./lib/debug"; | ||
|
|
||
| /** Options for pollUntilCompletion() */ | ||
| export interface WaitOptions { | ||
|
|
@@ -70,6 +75,8 @@ export interface IDKitRequest { | |
| pollOnce(): Promise<Status>; | ||
| /** Poll continuously until completion or timeout */ | ||
| pollUntilCompletion(options?: WaitOptions): Promise<IDKitCompletionResult>; | ||
| /** Debug report for this request when debug mode is enabled. May include sensitive data. */ | ||
| getDebugReport(): IDKitDebugReport | undefined; | ||
|
cursor[bot] marked this conversation as resolved.
|
||
| } | ||
|
|
||
| /** | ||
|
|
@@ -112,26 +119,51 @@ async function pollUntilCompletionLoop( | |
| } | ||
| } | ||
|
|
||
| type BridgeDebugPayloadSource = { | ||
| debugPayload?: () => unknown; | ||
| }; | ||
|
|
||
| function readBridgeDebugPayload( | ||
| wasmRequest: BridgeDebugPayloadSource, | ||
| ): unknown { | ||
| if (typeof wasmRequest.debugPayload !== "function") { | ||
| return undefined; | ||
| } | ||
|
|
||
| try { | ||
| return wasmRequest.debugPayload(); | ||
| } catch { | ||
| return undefined; | ||
| } | ||
| } | ||
|
|
||
| function createBridgeDebugReport( | ||
| wasmRequest: BridgeDebugPayloadSource, | ||
| requestId: string, | ||
| connectorURI: string, | ||
| ): IDKitDebugReport | undefined { | ||
| if (!isDebug()) return undefined; | ||
|
|
||
| return createIDKitDebugReport({ | ||
| transport: "bridge", | ||
| requestPayload: readBridgeDebugPayload(wasmRequest), | ||
| requestId, | ||
| connectorURI, | ||
| }); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bridge debug payload not cachedMedium Severity Bridge Additional Locations (1)Reviewed by Cursor Bugbot for commit 41beb9c. Configure here. |
||
| } | ||
|
|
||
| /** | ||
| * Internal request implementation (bridge/WASM path) | ||
| */ | ||
| class IDKitRequestImpl implements IDKitRequest { | ||
| private wasmRequest: WasmModule.IDKitRequest; | ||
| private _connectorURI: string; | ||
| private _requestId: string; | ||
| readonly connectorURI: string; | ||
| readonly requestId: string; | ||
|
|
||
| constructor(wasmRequest: WasmModule.IDKitRequest) { | ||
| this.wasmRequest = wasmRequest; | ||
| this._connectorURI = wasmRequest.connectUrl(); | ||
| this._requestId = wasmRequest.requestId(); | ||
| } | ||
|
|
||
| get connectorURI(): string { | ||
| return this._connectorURI; | ||
| } | ||
|
|
||
| get requestId(): string { | ||
| return this._requestId; | ||
| this.connectorURI = wasmRequest.connectUrl(); | ||
| this.requestId = wasmRequest.requestId(); | ||
| } | ||
|
|
||
| async pollOnce(): Promise<Status> { | ||
|
|
@@ -141,6 +173,14 @@ class IDKitRequestImpl implements IDKitRequest { | |
| pollUntilCompletion(options?: WaitOptions): Promise<IDKitCompletionResult> { | ||
| return pollUntilCompletionLoop(() => this.pollOnce(), options); | ||
| } | ||
|
|
||
| getDebugReport(): IDKitDebugReport | undefined { | ||
| return createBridgeDebugReport( | ||
| this.wasmRequest, | ||
| this.requestId, | ||
| this.connectorURI, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -163,6 +203,8 @@ export interface IDKitInviteCodeRequest { | |
| pollOnce(): Promise<Status>; | ||
| /** Poll continuously until completion or timeout */ | ||
| pollUntilCompletion(options?: WaitOptions): Promise<IDKitCompletionResult>; | ||
| /** Debug report for this request when debug mode is enabled. May include sensitive data. */ | ||
| getDebugReport(): IDKitDebugReport | undefined; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -172,27 +214,15 @@ export interface IDKitInviteCodeRequest { | |
| */ | ||
| class IDKitInviteCodeRequestImpl implements IDKitInviteCodeRequest { | ||
| private wasmRequest: WasmModule.IDKitInviteCodeRequest; | ||
| private _connectorURI: string; | ||
| private _expiresAt: number; | ||
| private _requestId: string; | ||
| readonly connectorURI: string; | ||
| readonly expiresAt: number; | ||
| readonly requestId: string; | ||
|
|
||
| constructor(wasmRequest: WasmModule.IDKitInviteCodeRequest) { | ||
| this.wasmRequest = wasmRequest; | ||
| this._connectorURI = wasmRequest.connectUrl(); | ||
| this._expiresAt = wasmRequest.expiresAt(); | ||
| this._requestId = wasmRequest.requestId(); | ||
| } | ||
|
|
||
| get connectorURI(): string { | ||
| return this._connectorURI; | ||
| } | ||
|
|
||
| get expiresAt(): number { | ||
| return this._expiresAt; | ||
| } | ||
|
|
||
| get requestId(): string { | ||
| return this._requestId; | ||
| this.connectorURI = wasmRequest.connectUrl(); | ||
| this.expiresAt = wasmRequest.expiresAt(); | ||
| this.requestId = wasmRequest.requestId(); | ||
| } | ||
|
|
||
| async pollOnce(): Promise<Status> { | ||
|
|
@@ -202,6 +232,14 @@ class IDKitInviteCodeRequestImpl implements IDKitInviteCodeRequest { | |
| pollUntilCompletion(options?: WaitOptions): Promise<IDKitCompletionResult> { | ||
| return pollUntilCompletionLoop(() => this.pollOnce(), options); | ||
| } | ||
|
|
||
| getDebugReport(): IDKitDebugReport | undefined { | ||
| return createBridgeDebugReport( | ||
| this.wasmRequest, | ||
| this.requestId, | ||
| this.connectorURI, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| // ───────────────────────────────────────────────────────────────────────────── | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this v1 i would avoid strong typing here, to start with you can try:
bridge | mini_app)window.WorldAppis defined