@comfyorg/comfyui-desktop-bridge-types 0.7.0 → 0.9.0
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 +21 -0
- package/comfyDesktopBridge.d.ts +38 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -39,6 +39,27 @@ async function openModelAccessPage(url: string): Promise<void> {
|
|
|
39
39
|
every top-level member required, so Desktop's preload cannot claim the contract
|
|
40
40
|
while omitting part of it.
|
|
41
41
|
|
|
42
|
+
## Comfy pages hosted in Desktop's Apps view
|
|
43
|
+
|
|
44
|
+
A Comfy page that Desktop shows in its Apps view gets `window.comfyDesktopAuth`
|
|
45
|
+
instead: Desktop's account session, and nothing else of the bridge above.
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import type { ComfyDesktopHostedAuthBridge } from '@comfyorg/comfyui-desktop-bridge-types'
|
|
49
|
+
|
|
50
|
+
declare global {
|
|
51
|
+
interface Window {
|
|
52
|
+
comfyDesktopAuth?: ComfyDesktopHostedAuthBridge
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The page reads the session with `getState()`, follows it with `onChanged()`,
|
|
58
|
+
asks for the workspace credential with `getWorkspaceToken(workspaceId)` each
|
|
59
|
+
time it calls Comfy Cloud, and starts a sign-in with `requestSignIn()`. It
|
|
60
|
+
cannot sign Desktop out or switch workspace. The object is absent in a
|
|
61
|
+
browser, so a page keeps its own sign-in as the fallback.
|
|
62
|
+
|
|
42
63
|
## Provenance
|
|
43
64
|
|
|
44
65
|
Generated from `src/types/comfyDesktopBridge.ts` in
|
package/comfyDesktopBridge.d.ts
CHANGED
|
@@ -124,6 +124,24 @@ export type ComfyDesktop2AuthState =
|
|
|
124
124
|
email?: string
|
|
125
125
|
workspaceId?: string
|
|
126
126
|
}
|
|
127
|
+
export type ComfyDesktop2BillingHandoffReceiver = 'billing_web' | 'platform'
|
|
128
|
+
export type ComfyDesktop2BillingHandoffIntent = 'top-up' | 'subscription'
|
|
129
|
+
export type ComfyDesktop2BillingHandoff =
|
|
130
|
+
| {
|
|
131
|
+
status: 'issued'
|
|
132
|
+
entryUrl: string
|
|
133
|
+
}
|
|
134
|
+
| {
|
|
135
|
+
status: 'sign_in_again'
|
|
136
|
+
}
|
|
137
|
+
| {
|
|
138
|
+
status: 'refused'
|
|
139
|
+
code?: string
|
|
140
|
+
message?: string
|
|
141
|
+
}
|
|
142
|
+
| {
|
|
143
|
+
status: 'disabled'
|
|
144
|
+
}
|
|
127
145
|
export interface ComfyDesktop2AuthBridge {
|
|
128
146
|
getState(): Promise<ComfyDesktop2AuthState>
|
|
129
147
|
/** The workspace credential, only for an exact workspace Desktop's session
|
|
@@ -148,7 +166,27 @@ export interface ComfyDesktop2AuthBridge {
|
|
|
148
166
|
switchWorkspace(workspaceId: string): Promise<ComfyDesktop2AuthState>
|
|
149
167
|
/** Fires when Desktop signs in, signs out or switches workspace. */
|
|
150
168
|
onChanged(callback: (state: ComfyDesktop2AuthState) => void): () => void
|
|
169
|
+
/** Issues a billing handoff with Desktop's credential and resolves with only its https entry URL; `intent` picks the landing page and `amountCents` the top-up amount. Absent on older Desktop builds. */
|
|
170
|
+
issueBillingHandoff?(
|
|
171
|
+
workspaceId: string,
|
|
172
|
+
receiver: ComfyDesktop2BillingHandoffReceiver,
|
|
173
|
+
intent?: ComfyDesktop2BillingHandoffIntent,
|
|
174
|
+
amountCents?: number
|
|
175
|
+
): Promise<ComfyDesktop2BillingHandoff>
|
|
151
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* Desktop's own Comfy account session, as a Comfy page hosted in Desktop's
|
|
179
|
+
* Apps view sees it. Desktop exposes it to that page as
|
|
180
|
+
* `window.comfyDesktopAuth`. The page can read the session, hold the
|
|
181
|
+
* workspace and partner-node credentials, and start a sign-in; it cannot sign
|
|
182
|
+
* Desktop out or switch workspace.
|
|
183
|
+
*/
|
|
184
|
+
export type ComfyDesktopHostedAuthBridge = Required<
|
|
185
|
+
Pick<
|
|
186
|
+
ComfyDesktop2AuthBridge,
|
|
187
|
+
'getState' | 'getWorkspaceToken' | 'getPartnerNodeToken' | 'requestSignIn' | 'onChanged'
|
|
188
|
+
>
|
|
189
|
+
>
|
|
152
190
|
export interface ComfyDesktop2TerminalBridge {
|
|
153
191
|
subscribe(installationId?: string): Promise<TerminalRestore>
|
|
154
192
|
unsubscribe(installationId?: string): Promise<void>
|