Skip to content

Commit e6593c4

Browse files
committed
add projectId
1 parent a35a318 commit e6593c4

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

packages/sdk/examples/next-app/app/server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { createClient } from "../../../src";
55
const {
66
PIPEDREAM_PROJECT_SECRET_KEY,
77
NEXT_PUBLIC_PIPEDREAM_APP_SLUG,
8+
PIPEDREAM_PROJECT_ID,
89
} = process.env;
910

1011
if (!PIPEDREAM_PROJECT_SECRET_KEY) throw new Error("PIPEDREAM_PROJECT_SECRET_KEY not set in environment");
@@ -13,6 +14,7 @@ if (!NEXT_PUBLIC_PIPEDREAM_APP_SLUG) throw new Error("NEXT_PUBLIC_PIPEDREAM_APP_
1314
const pd = createClient({
1415
secretKey: PIPEDREAM_PROJECT_SECRET_KEY,
1516
apiHost: process.env.PIPEDREAM_API_HOST,
17+
projectId: PIPEDREAM_PROJECT_ID,
1618
});
1719

1820
export async function serverConnectTokenCreate(clientUserId: string) {

packages/sdk/src/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ type CreateServerClientOpts = {
22
environment?: string;
33
secretKey: string;
44
apiHost?: string;
5+
projectId?: string;
56
};
67

78
type ConnectTokenCreateOpts = {
@@ -22,16 +23,18 @@ export function createClient(opts: CreateServerClientOpts) {
2223
class ServerClient {
2324
environment?: string;
2425
secretKey: string;
26+
projectId: string;
2527
baseURL: string;
2628

2729
constructor(opts: CreateServerClientOpts) {
2830
this.environment = opts.environment;
2931
this.secretKey = opts.secretKey;
32+
this.projectId = opts.projectId;
3033
this.baseURL = `https://${opts.apiHost || "pipedream.com"}`;
3134
}
3235

3336
private _authorizonHeader(): string {
34-
return "Basic " + Buffer.from(this.secretKey + ":").toString("base64");
37+
return "Basic " + Buffer.from(`${this.projectId}:${this.secretKey}`).toString("base64");
3538
}
3639

3740
// XXX move to REST API endpoint
@@ -43,17 +46,20 @@ class ServerClient {
4346
},
4447
body: JSON.stringify({
4548
query: `mutation sdkConnectTokenCreate(
49+
$projectId: String!
4650
$secretKey: String!
4751
$clientUserId: String!
4852
) {
4953
connectTokenCreate(
54+
projectId: $projectId
5055
secretKey: $secretKey
5156
clientUserId: $clientUserId
5257
) {
5358
token
5459
}
5560
}`,
5661
variables: {
62+
projectId: this.projectId,
5763
secretKey: this.secretKey,
5864
clientUserId: opts.clientUserId,
5965
},

0 commit comments

Comments
 (0)