Skip to content

Commit

Permalink
Fix auth token override in sql promise (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
pffigueiredo authored Nov 6, 2024
1 parent 5a2a6aa commit 28c823d
Show file tree
Hide file tree
Showing 9 changed files with 2,137 additions and 2,119 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.10.3 (2024-11-06)

Fixes `authToken` overriding in `sql` HTTP request.

## 0.10.2 (2024-11-05)

Expose `types` property on public HTTPQueryOptions type
Expand Down
1,411 changes: 706 additions & 705 deletions dist/jsr/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/jsr/jsr.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@neon/serverless",
"version": "0.10.2",
"version": "0.10.3",
"exports": "./index.js",
"imports": {
"pg": "npm:@types/[email protected]"
Expand Down
4 changes: 4 additions & 0 deletions dist/npm/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.10.3 (2024-11-06)

Fixes `authToken` overriding in `sql` HTTP request.

## 0.10.2 (2024-11-05)

Expose `types` property on public HTTPQueryOptions type
Expand Down
1,409 changes: 705 additions & 704 deletions dist/npm/index.js

Large diffs are not rendered by default.

1,411 changes: 706 additions & 705 deletions dist/npm/index.mjs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/npm/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/npm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@neondatabase/serverless",
"version": "0.10.2",
"version": "0.10.3",
"author": "Neon",
"description": "node-postgres for serverless environments from neon.tech",
"exports": {
Expand Down
9 changes: 8 additions & 1 deletion export/httpQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,12 @@ export function neon(
};
}

// --- resolve auth token usage ---
let resolvedAuthToken = authToken;
if (!Array.isArray(allSqlOpts) && allSqlOpts?.authToken !== undefined) {
resolvedAuthToken = allSqlOpts.authToken;
}

// --- set headers ---

const headers: Record<string, string> = {
Expand All @@ -290,7 +296,8 @@ export function neon(
'Neon-Array-Mode': 'true', // this saves data and post-processing even if we return objects, not arrays
};

const validAuthToken = await getAuthToken(authToken);
// --- add auth token to headers ---
const validAuthToken = await getAuthToken(resolvedAuthToken);
if (validAuthToken) {
headers['Authorization'] = `Bearer ${validAuthToken}`;
}
Expand Down

0 comments on commit 28c823d

Please sign in to comment.