@opengeni/connect 0.2.0-canary.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/LICENSE +190 -0
- package/README.md +112 -0
- package/dist/authorization.d.ts +16 -0
- package/dist/browser-navigation.d.ts +19 -0
- package/dist/device.d.ts +17 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.js +370 -0
- package/dist/index.js.map +1 -0
- package/dist/poll.d.ts +8 -0
- package/dist/recovery.d.ts +4 -0
- package/dist/types.d.ts +144 -0
- package/package.json +38 -0
- package/src/authorization.ts +51 -0
- package/src/browser-navigation.ts +52 -0
- package/src/device.ts +109 -0
- package/src/index.ts +210 -0
- package/src/poll.ts +78 -0
- package/src/recovery.ts +16 -0
- package/src/types.ts +134 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2026 Cloudgeni-ai
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Browser authorization handoff
|
|
2
|
+
|
|
3
|
+
Browser hosts can use `createBrowserConnectNavigation(window)` with the helper
|
|
4
|
+
below. Importing the package does not access `window`. Popup mode opens a fresh
|
|
5
|
+
blank window, clears its opener before provider navigation, and retains a close
|
|
6
|
+
handle. If isolation fails, it closes the blank window and reports a generic
|
|
7
|
+
error; a blocked popup does not silently redirect. Full redirect remains an
|
|
8
|
+
explicit host choice. Browser security policies may sever the popup handle;
|
|
9
|
+
completion is still obtained from the backend, never from that handle.
|
|
10
|
+
|
|
11
|
+
`authorizeConnectAttempt(transport, attempt, navigation, options)` accepts an
|
|
12
|
+
injected `ConnectNavigation` adapter and either `popup` or `redirect` mode.
|
|
13
|
+
Call popup mode directly from a user gesture: opening is synchronous, a blocked
|
|
14
|
+
popup throws explicitly, and only backend polling determines the result. The
|
|
15
|
+
popup is closed when polling settles. Cancellation stops polling, not the
|
|
16
|
+
durable server attempt; cancel that explicitly through the controller if desired.
|
|
17
|
+
|
|
18
|
+
For redirect mode, retain the opaque attempt ID in host-owned state before
|
|
19
|
+
calling the helper. It passes the authorization URL unchanged and returns `null`;
|
|
20
|
+
recover the attempt and poll after returning. No completion query parameters or
|
|
21
|
+
window messages are required or trusted. Authorization destinations must use
|
|
22
|
+
HTTPS without embedded credentials. Provider adapters run on the server;
|
|
23
|
+
optional setup and account presentation lives in `@opengeni/react/connect`.
|
|
24
|
+
|
|
25
|
+
# @opengeni/connect
|
|
26
|
+
|
|
27
|
+
Framework-neutral state for a durable OpenGeni connection setup attempt. This
|
|
28
|
+
package contains no React, browser storage, provider SDK, or server credentials.
|
|
29
|
+
Use `ConnectController` with an authenticated `ConnectTransport`; use
|
|
30
|
+
`@opengeni/react/connect` to observe that same controller from React.
|
|
31
|
+
|
|
32
|
+
The controller forwards the exact return URL, models credentials committed
|
|
33
|
+
separately from integration installed, preserves revision/idempotency fences,
|
|
34
|
+
and rejects responses for another workspace or attempt. Popup messages and
|
|
35
|
+
navigation are not proof of completion: recover or refresh the durable attempt
|
|
36
|
+
through the transport. List pending attempts through `transport.pending` when
|
|
37
|
+
the opener or browser state is lost.
|
|
38
|
+
|
|
39
|
+
Controller snapshots retain only a fixed generic transport-failure message, not
|
|
40
|
+
raw error messages, causes or request objects that could contain credentials.
|
|
41
|
+
Method rejections still reach the direct caller unchanged; hosts must redact
|
|
42
|
+
those errors before logging or displaying them. Backend attempt projections
|
|
43
|
+
must likewise remain credential-free.
|
|
44
|
+
|
|
45
|
+
Create one controller for the selected workspace and dispose it when the host
|
|
46
|
+
replaces that workspace or its authenticated user. Observer unmount is not
|
|
47
|
+
controller disposal. Secret form values go only to `advance`; snapshots never
|
|
48
|
+
retain submitted values. The transport must sanitize server error responses.
|
|
49
|
+
|
|
50
|
+
The implementation branch now has durable curated OAuth begin/read endpoints
|
|
51
|
+
and SDK `beginConnect`, `getConnectAttempt`, and `listPendingConnectAttempts`.
|
|
52
|
+
Use these on the trusted host backend through an `asUser` client. Retain the
|
|
53
|
+
attempt ID before navigation. The callback returns to the exact stored host URL
|
|
54
|
+
without appended parameters; querying the attempt distinguishes committed
|
|
55
|
+
credentials from finished integration installation. Repeated callbacks replay a
|
|
56
|
+
receipt without repeating the provider token exchange.
|
|
57
|
+
|
|
58
|
+
Curated attempts also support SDK `advanceConnectAttempt` and
|
|
59
|
+
`cancelConnectAttempt`. Advance with `retry` to obtain a preview after OAuth;
|
|
60
|
+
then install with its revision/content hash and explicitly selected operation
|
|
61
|
+
IDs. Changed source returns a fresh preview for review. Cancellation stops setup
|
|
62
|
+
without revoking credentials already saved. The unstyled setup form exposes
|
|
63
|
+
these review/install controls and labels each operation's risk category.
|
|
64
|
+
|
|
65
|
+
On the trusted host backend, `client.asUser(externalId).connectTransport()`
|
|
66
|
+
supplies the complete transport interface using the client's fixed actor,
|
|
67
|
+
contract checks, error handling and abort signal support. Never send that
|
|
68
|
+
organization-key client to the browser. A browser transport must call the host's
|
|
69
|
+
authenticated backend, which derives the actor from its own session and checks
|
|
70
|
+
workspace access; browser-supplied actor IDs are not proof of identity.
|
|
71
|
+
|
|
72
|
+
Catalog readiness reflects curated provider configuration and current access.
|
|
73
|
+
Accounts expose connection metadata, not credentials. `disconnect` uses the
|
|
74
|
+
existing local connection-revocation endpoint: it removes OpenGeni access, not
|
|
75
|
+
upstream provider consent. Aborting an in-flight mutation stops observation and
|
|
76
|
+
does not guarantee that the server rolled it back; recover durable attempts
|
|
77
|
+
before deciding whether to retry. A signal already aborted before dispatch
|
|
78
|
+
prevents the SDK request from being sent.
|
|
79
|
+
|
|
80
|
+
The server catalog reports provider readiness and ownership requirements. Native
|
|
81
|
+
setup and embedding products share the controller and React setup surface.
|
|
82
|
+
Reconnect uses an observed account/version; provider-specific installation and
|
|
83
|
+
resource selection remain explicit next actions. Controller tests alone do not
|
|
84
|
+
prove backend authorization or vendor OAuth conformance.
|
|
85
|
+
|
|
86
|
+
Model-account device flows retain their existing pool APIs and can share
|
|
87
|
+
`pollDeviceAuthorization` and the optional React `DeviceAuthorization` surface.
|
|
88
|
+
|
|
89
|
+
`findConnectRecoveryAccount(accounts, connectionId)` resolves timeline auth-needed
|
|
90
|
+
events to the exact fresh account, including social-domain IDs. It never guesses
|
|
91
|
+
by provider or label. Missing accounts need explicit user selection; host-managed
|
|
92
|
+
credentials recover through the product's own account flow.
|
|
93
|
+
|
|
94
|
+
`@opengeni/react/connect` also exports `ConnectSetup`, an unstyled setup form.
|
|
95
|
+
Pass the controller and an `onAuthorize(attempt)` callback (called directly from
|
|
96
|
+
the click handler, so it can open a popup). It labels ownership, requires explicit
|
|
97
|
+
account selection, clears credential inputs before awaiting submission, and
|
|
98
|
+
never preselects installation operations. `onBrowseResources` lets the host own
|
|
99
|
+
paginated selections; the built-in form refuses to submit an incomplete page.
|
|
100
|
+
`ConnectChooser` from the same React export supplies an optional unstyled
|
|
101
|
+
provider/ownership form. Pass `controller` and the exact `returnUrl`; it uses
|
|
102
|
+
`transport.catalog` readiness, disables unavailable providers and requires an
|
|
103
|
+
explicit ownership choice. Replace the controller on actor/workspace changes;
|
|
104
|
+
stale catalog responses are discarded. Hosts still provide navigation, account
|
|
105
|
+
management and pending-attempt recovery. Backend readiness and authorization
|
|
106
|
+
remain mandatory; browser-disabled options are not an access-control boundary.
|
|
107
|
+
|
|
108
|
+
`controller.waitForAction({ timeoutMs })` polls the selected attempt and publishes
|
|
109
|
+
the resulting action or terminal state to subscribers (also exposed by
|
|
110
|
+
`useConnect`). It rejects revisions older than the selected snapshot, never
|
|
111
|
+
retries mutations, and stops when the controller is disposed or another attempt
|
|
112
|
+
is selected. A timeout stops observation, not the durable server operation.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ConnectAttempt, ConnectTransport } from "./types.js";
|
|
2
|
+
/** Inject navigation so hosts own routing and this package needs no DOM globals. */
|
|
3
|
+
export type ConnectNavigation = {
|
|
4
|
+
openPopup(url: string): {
|
|
5
|
+
close(): void;
|
|
6
|
+
} | null;
|
|
7
|
+
redirect(url: string): void;
|
|
8
|
+
};
|
|
9
|
+
/** Invoke directly from a user gesture for popup mode. Persist the opaque
|
|
10
|
+
* attempt ID in host-owned state before redirect mode, then recover/poll on
|
|
11
|
+
* return. Neither URL parameters nor popup messages prove completion. */
|
|
12
|
+
export declare function authorizeConnectAttempt(transport: Pick<ConnectTransport, "get">, attempt: ConnectAttempt, navigation: ConnectNavigation, options: {
|
|
13
|
+
mode: "popup" | "redirect";
|
|
14
|
+
signal?: AbortSignal;
|
|
15
|
+
timeoutMs?: number;
|
|
16
|
+
}): Promise<ConnectAttempt | null>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ConnectNavigation } from "./authorization.js";
|
|
2
|
+
/** Structural browser surface so importing Connect never reads DOM globals. */
|
|
3
|
+
export type ConnectBrowserWindow = {
|
|
4
|
+
open(url: string, target: string, features: string): {
|
|
5
|
+
opener: unknown;
|
|
6
|
+
location: {
|
|
7
|
+
replace(url: string): void;
|
|
8
|
+
};
|
|
9
|
+
close(): void;
|
|
10
|
+
} | null;
|
|
11
|
+
location: {
|
|
12
|
+
assign(url: string): void;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
/** Pass window from the host's browser entry point. Opens a fresh blank window
|
|
16
|
+
* synchronously and severs its opener BEFORE any provider content can load.
|
|
17
|
+
* Never uses a reusable named target or relies on provider window messages.
|
|
18
|
+
* The caller retains only the close capability for backend-polling cleanup. */
|
|
19
|
+
export declare function createBrowserConnectNavigation(browser: ConnectBrowserWindow): ConnectNavigation;
|
package/dist/device.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Shared device-code behavior for model-account domains. These accounts keep
|
|
2
|
+
* their existing APIs and ownership semantics; they are not generic credentials.
|
|
3
|
+
* Keep opaque provider state on the host backend when reload recovery is needed. */
|
|
4
|
+
export declare function pollDeviceAuthorization<T extends {
|
|
5
|
+
status: string;
|
|
6
|
+
intervalSeconds?: number;
|
|
7
|
+
}>(options: {
|
|
8
|
+
poll: () => Promise<T>;
|
|
9
|
+
expired: T;
|
|
10
|
+
initialIntervalSeconds: number;
|
|
11
|
+
expiresAtMs: number;
|
|
12
|
+
signal: AbortSignal;
|
|
13
|
+
retryable?: (error: unknown) => boolean;
|
|
14
|
+
now?: () => number;
|
|
15
|
+
wait?: (delayMs: number, signal: AbortSignal) => Promise<boolean>;
|
|
16
|
+
maxRetryDelaySeconds?: number;
|
|
17
|
+
}): Promise<T | null>;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export * from "./types.js";
|
|
2
|
+
export { pollDeviceAuthorization } from "./device.js";
|
|
3
|
+
export { findConnectRecoveryAccount } from "./recovery.js";
|
|
4
|
+
export { pollConnectAttempt } from "./poll.js";
|
|
5
|
+
export { authorizeConnectAttempt, type ConnectNavigation } from "./authorization.js";
|
|
6
|
+
export { createBrowserConnectNavigation, type ConnectBrowserWindow } from "./browser-navigation.js";
|
|
7
|
+
import type { ConnectAdvance, ConnectAttempt, ConnectOwnership, ConnectTransport } from "./types.js";
|
|
8
|
+
export type ConnectSnapshot = {
|
|
9
|
+
attempt: ConnectAttempt | null;
|
|
10
|
+
busy: boolean;
|
|
11
|
+
error: Error | null;
|
|
12
|
+
};
|
|
13
|
+
/** A transport-injected, framework-neutral view of one durable setup attempt.
|
|
14
|
+
* OAuth redirects are hints to navigate; completion is read from the backend.
|
|
15
|
+
* Secret form values are never stored in a snapshot or browser persistence. */
|
|
16
|
+
export declare class ConnectController {
|
|
17
|
+
readonly transport: ConnectTransport;
|
|
18
|
+
readonly workspaceId: string;
|
|
19
|
+
private snapshot;
|
|
20
|
+
private readonly listeners;
|
|
21
|
+
private generation;
|
|
22
|
+
private request;
|
|
23
|
+
private disposed;
|
|
24
|
+
constructor(transport: ConnectTransport, workspaceId: string);
|
|
25
|
+
getSnapshot: () => ConnectSnapshot;
|
|
26
|
+
subscribe: (listener: () => void) => (() => void);
|
|
27
|
+
begin(input: {
|
|
28
|
+
providerId: string;
|
|
29
|
+
ownership: ConnectOwnership;
|
|
30
|
+
returnUrl: string;
|
|
31
|
+
idempotencyKey: string;
|
|
32
|
+
reconnectAccountId?: string;
|
|
33
|
+
installationTarget?: import("./types.js").ConnectInstallationTarget;
|
|
34
|
+
}): Promise<ConnectAttempt>;
|
|
35
|
+
recover(attemptId: string): Promise<ConnectAttempt>;
|
|
36
|
+
refresh(): Promise<ConnectAttempt>;
|
|
37
|
+
advance(action: ConnectAdvance, idempotencyKey: string): Promise<ConnectAttempt>;
|
|
38
|
+
/** Observe backend progress without replaying a setup mutation. Disposal or
|
|
39
|
+
* selecting another attempt aborts the read loop and fences its late result. */
|
|
40
|
+
waitForAction(options?: {
|
|
41
|
+
timeoutMs?: number;
|
|
42
|
+
}): Promise<ConnectAttempt>;
|
|
43
|
+
cancel(idempotencyKey: string): Promise<ConnectAttempt>;
|
|
44
|
+
dispose(): void;
|
|
45
|
+
private assertActive;
|
|
46
|
+
private requireAttempt;
|
|
47
|
+
private publish;
|
|
48
|
+
private run;
|
|
49
|
+
}
|