Skip to content

Commit 0e8aca6

Browse files
committed
Adding optional oauthAppId in the iframe call
1 parent e1e3cbb commit 0e8aca6

File tree

2 files changed

+6
-36
lines changed

2 files changed

+6
-36
lines changed

packages/sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/sdk",
3-
"version": "0.0.9",
3+
"version": "0.0.10",
44
"description": "Pipedream SDK",
55
"type": "module",
66
"main": "dist/server/index.js",

packages/sdk/src/browser/index.ts

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ type CreateBrowserClientOpts = {
2424
*/
2525
type AppId = string;
2626

27-
/**
28-
* A unique identifier for an oauth app.
29-
*/
30-
type OauthAppId = string;
31-
3227
/**
3328
* Object representing an app to start connecting with.
3429
*/
@@ -69,9 +64,10 @@ type StartConnectOpts = {
6964
app: AppId | StartConnectApp;
7065

7166
/**
72-
* The ID of the OAuth Client to connect.
67+
* The OAuth app ID to connect to.
7368
*/
74-
oauthAppId: OauthAppId;
69+
oauthAppId?: string;
70+
7571
/**
7672
* Callback function to be called upon successful connection.
7773
*
@@ -145,15 +141,7 @@ class BrowserClient {
145141
*/
146142
connectAccount(opts: StartConnectOpts) {
147143
const onMessage = (e: MessageEvent) => {
148-
if (e.origin !== this.baseURL || !this.iframe?.contentWindow) {
149-
console.warn("Untrusted origin or iframe not ready:", e.origin);
150-
return;
151-
}
152-
153144
switch (e.data?.type) {
154-
case "verify-domain":
155-
this.handleVerifyDomain(e);
156-
break;
157145
case "success":
158146
opts.onSuccess?.({
159147
id: e.data?.authProvisionId,
@@ -179,23 +167,6 @@ class BrowserClient {
179167
}
180168
}
181169

182-
/**
183-
* Handles the verification of the domain from the iframe.
184-
*
185-
* @param e - The message event containing the verification request.
186-
*/
187-
private handleVerifyDomain(e: MessageEvent) {
188-
if (this.iframe?.contentWindow) {
189-
this.iframe.contentWindow.postMessage(
190-
{
191-
type: "domain-response",
192-
origin: window.origin,
193-
},
194-
e.origin,
195-
);
196-
}
197-
}
198-
199170
/**
200171
* Cleans up the iframe and message event listener after the connection process is complete.
201172
*
@@ -227,10 +198,9 @@ class BrowserClient {
227198
} else {
228199
throw new ConnectError("Object app not yet supported");
229200
}
230-
if (typeof opts.oauthAppId === "string") {
201+
202+
if (opts.oauthAppId) {
231203
qp.set("oauthAppId", opts.oauthAppId);
232-
} else {
233-
throw new ConnectError("Object app not yet supported");
234204
}
235205

236206
const iframe = document.createElement("iframe");

0 commit comments

Comments
 (0)