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";
5
5
const {
6
6
PIPEDREAM_PROJECT_SECRET_KEY ,
7
7
NEXT_PUBLIC_PIPEDREAM_APP_SLUG ,
8
+ PIPEDREAM_PROJECT_ID ,
8
9
} = process . env ;
9
10
10
11
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_
13
14
const pd = createClient ( {
14
15
secretKey : PIPEDREAM_PROJECT_SECRET_KEY ,
15
16
apiHost : process . env . PIPEDREAM_API_HOST ,
17
+ projectId : PIPEDREAM_PROJECT_ID ,
16
18
} ) ;
17
19
18
20
export async function serverConnectTokenCreate ( clientUserId : string ) {
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ type CreateServerClientOpts = {
2
2
environment ?: string ;
3
3
secretKey : string ;
4
4
apiHost ?: string ;
5
+ projectId ?: string ;
5
6
} ;
6
7
7
8
type ConnectTokenCreateOpts = {
@@ -22,16 +23,18 @@ export function createClient(opts: CreateServerClientOpts) {
22
23
class ServerClient {
23
24
environment ?: string ;
24
25
secretKey : string ;
26
+ projectId : string ;
25
27
baseURL : string ;
26
28
27
29
constructor ( opts : CreateServerClientOpts ) {
28
30
this . environment = opts . environment ;
29
31
this . secretKey = opts . secretKey ;
32
+ this . projectId = opts . projectId ;
30
33
this . baseURL = `https://${ opts . apiHost || "pipedream.com" } ` ;
31
34
}
32
35
33
36
private _authorizonHeader ( ) : string {
34
- return "Basic " + Buffer . from ( this . secretKey + ":" ) . toString ( "base64" ) ;
37
+ return "Basic " + Buffer . from ( ` ${ this . projectId } : ${ this . secretKey } ` ) . toString ( "base64" ) ;
35
38
}
36
39
37
40
// XXX move to REST API endpoint
@@ -43,17 +46,20 @@ class ServerClient {
43
46
} ,
44
47
body : JSON . stringify ( {
45
48
query : `mutation sdkConnectTokenCreate(
49
+ $projectId: String!
46
50
$secretKey: String!
47
51
$clientUserId: String!
48
52
) {
49
53
connectTokenCreate(
54
+ projectId: $projectId
50
55
secretKey: $secretKey
51
56
clientUserId: $clientUserId
52
57
) {
53
58
token
54
59
}
55
60
}` ,
56
61
variables : {
62
+ projectId : this . projectId ,
57
63
secretKey : this . secretKey ,
58
64
clientUserId : opts . clientUserId ,
59
65
} ,
You can’t perform that action at this time.
0 commit comments