@okta-dfuhriman/okta-auth-js
Version:
The Okta Auth SDK
35 lines (30 loc) • 838 B
text/typescript
import { OktaAuthHttpInterface } from '../../http/types';
import { TransactionLink } from '../request';
type TransactionOptions = {
// TODO: move res type to http module
res: {
headers: Record<string, string>;
_links?: Record<string, TransactionLink>;
[property: string]: unknown;
};
accessToken: string;
};
export default class BaseTransaction {
// Deprecated
headers?: Record<string, string>;
constructor(oktaAuth: OktaAuthHttpInterface, options: TransactionOptions) {
const { res } = options;
const { headers, ...rest } = res;
// assign required fields from res
if (headers) {
this.headers = headers;
}
// add all rest fields from res
Object.keys(rest).forEach(key => {
if (key === '_links') {
return;
}
this[key] = rest[key];
});
}
}