File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { createClient } from "../../../src";
55const {
66 PIPEDREAM_PROJECT_SECRET_KEY ,
77 NEXT_PUBLIC_PIPEDREAM_APP_SLUG ,
8+ PIPEDREAM_PROJECT_ID ,
89} = process . env ;
910
1011if ( ! 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_
1314const pd = createClient ( {
1415 secretKey : PIPEDREAM_PROJECT_SECRET_KEY ,
1516 apiHost : process . env . PIPEDREAM_API_HOST ,
17+ projectId : PIPEDREAM_PROJECT_ID ,
1618} ) ;
1719
1820export async function serverConnectTokenCreate ( clientUserId : string ) {
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ type CreateServerClientOpts = {
22 environment ?: string ;
33 secretKey : string ;
44 apiHost ?: string ;
5+ projectId ?: string ;
56} ;
67
78type ConnectTokenCreateOpts = {
@@ -22,16 +23,18 @@ export function createClient(opts: CreateServerClientOpts) {
2223class 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 } ,
You can’t perform that action at this time.
0 commit comments