Skip to content

Commit

Permalink
bugfix: ts-sdk default behavior with omitCredentials includes them
Browse files Browse the repository at this point in the history
  • Loading branch information
skeptrunedev committed Dec 19, 2024
1 parent 52b5c00 commit a7f7919
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion clients/search-component/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"import": "./dist/vanilla/index.js"
}
},
"version": "0.2.31",
"version": "0.2.32",
"license": "MIT",
"homepage": "https://github.com/devflowinc/trieve/tree/main/clients/search-component",
"scripts": {
Expand Down
7 changes: 6 additions & 1 deletion clients/search-component/src/utils/hooks/modal-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ export type ModalProps = {
}[];
zIndex?: number;
showFloatingButton?: boolean;
floatingButtonPosition?: "top-left" | "top-right" | "bottom-left" | "bottom-right";
floatingButtonPosition?:
| "top-left"
| "top-right"
| "bottom-left"
| "bottom-right";
};

const defaultProps = {
Expand Down Expand Up @@ -219,6 +223,7 @@ const ModalProvider = ({
baseUrl: props.baseUrl,
apiKey: props.apiKey,
datasetId: props.datasetId,
omitCredentials: true,
});

const search = async (abortController: AbortController) => {
Expand Down
1 change: 1 addition & 0 deletions clients/trieve-fern-adapter/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ export const trieve = new TrieveSDK({
apiKey: trieveApiKey,
datasetId: trieveDatasetTrackingId,
organizationId: trieveOrganizationId,
omitCredentials: true,
});

try {
Expand Down
2 changes: 1 addition & 1 deletion clients/ts-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"files": [
"dist"
],
"version": "0.0.46",
"version": "0.0.48",
"license": "MIT",
"scripts": {
"lint": "eslint 'src/**/*.ts'",
Expand Down
5 changes: 4 additions & 1 deletion clients/ts-sdk/src/fetch-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,22 @@ interface TrieveOpts {
baseUrl: string;
debug?: boolean;
organizationId?: string;
omitCredentials?: boolean;
}

export class TrieveFetchClient {
apiKey?: string;
baseUrl: string;
debug: boolean = false;
organizationId?: string;
omitCredentials?: boolean;

constructor(opts: TrieveOpts) {
this.apiKey = opts.apiKey;
this.baseUrl = opts.baseUrl;
this.debug = opts.debug || false;
this.organizationId = opts.organizationId;
this.omitCredentials = opts.omitCredentials;
}

async fetch<
Expand Down Expand Up @@ -166,7 +169,7 @@ export class TrieveFetchClient {
}

const response = await fetch(this.baseUrl + updatedPath, {
credentials: "omit",
credentials: this.omitCredentials ? "omit" : "include",
method,
headers: headers,
body: requestBody ? JSON.stringify(requestBody) : undefined,
Expand Down
1 change: 1 addition & 0 deletions frontends/dashboard/src/utils/createCodeSnippets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export const reactSearchComponentRequest = (dataset: string, apiKey: string) =>
`export const trieve = new TrieveSDK({
apiKey: "${apiKey}",
datasetId: "${dataset}",
omitCredentials: true,
});
function MyComponent() {
Expand Down

0 comments on commit a7f7919

Please sign in to comment.