-
Notifications
You must be signed in to change notification settings - Fork 83
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
feat: Added support for Authenticated Datafiles #498
Changes from 2 commits
2f712cb
1b092ff
176edb4
38be098
20dbd06
01931df
06e7e3e
a1dd322
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,4 +43,5 @@ export interface DatafileManagerConfig { | |
updateInterval?: number; | ||
urlTemplate?: string; | ||
cache?: PersistentKeyValueCache; | ||
authDatafileToken?: string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we want to isolate this functionality to Node, this shouldn't be added here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,9 +18,28 @@ import { makeGetRequest } from './nodeRequest'; | |
import HttpPollingDatafileManager from './httpPollingDatafileManager'; | ||
import { Headers, AbortableRequest } from './http'; | ||
import { DatafileManagerConfig } from './datafileManager'; | ||
import { | ||
DEFAULT_URL_TEMPLATE, | ||
DEFAULT_AUTHENTICATED_DATAFILE_URL_TEMPLATE, | ||
} from './config'; | ||
|
||
export default class NodeDatafileManager extends HttpPollingDatafileManager { | ||
|
||
private authToken?: string; | ||
|
||
constructor(config: DatafileManagerConfig) { | ||
const defaultUrlTemplate = config.authDatafileToken ? DEFAULT_AUTHENTICATED_DATAFILE_URL_TEMPLATE : DEFAULT_URL_TEMPLATE; | ||
super({ | ||
... config, | ||
urlTemplate: config.urlTemplate || defaultUrlTemplate, | ||
}); | ||
this.authToken = config.authDatafileToken; | ||
} | ||
|
||
protected makeGetRequest(reqUrl: string, headers: Headers): AbortableRequest { | ||
if (this.authToken) { | ||
headers['Authorization'] = `Bearer ${this.authToken}`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
} | ||
return makeGetRequest(reqUrl, headers); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest
DEFAULT_AUTHENTICATED_URL_TEMPLATE
- everything pertains to datafiles.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done