Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: removes includeResponseHeaders from proxy service #20

Merged
merged 1 commit into from
Jul 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/BasisTheoryElements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ export class BasisTheoryElements {
apiKey: BasisTheoryElements.getApiKey(apiKey),
});

const result = BasisTheoryElements.replaceTokenData({ data: token.data });
const result = BasisTheoryElements.replaceSensitiveData({
data: token.data,
});

token.data = result.data as TokenData;

Expand All @@ -47,21 +49,23 @@ export class BasisTheoryElements {
{
method,
...proxyRequest
}: ProxyRequestOptions & { method: keyof BasisTheory['proxy'] },
}: Omit<ProxyRequestOptions, 'includeResponseHeaders'> & {
method: keyof BasisTheory['proxy'];
},
apiKey?: string
): Promise<unknown> {
const btInstance = await BasisTheoryElements.getBtInstance(apiKey);

proxyRequest.apiKey = apiKey;
const proxyResponse = await btInstance.proxy[method](proxyRequest);
const result = BasisTheoryElements.replaceTokenData({
const result = BasisTheoryElements.replaceSensitiveData({
data: proxyResponse,
});

return result.data;
}

private static replaceTokenData(
private static replaceSensitiveData(
token: Record<string, unknown>,
result: Record<string, unknown> = {},
parentObject: unknown = undefined
Expand Down Expand Up @@ -95,7 +99,7 @@ export class BasisTheoryElements {
[]
);
} else {
BasisTheoryElements.replaceTokenData(
BasisTheoryElements.replaceSensitiveData(
value as Record<string, unknown>,
result,
tokenDataPath
Expand Down