-
Notifications
You must be signed in to change notification settings - Fork 9
Add OAuth PKCE auth for Apps uploads #393
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
Open
otorrillas
wants to merge
4
commits into
master
Choose a base branch
from
oriol.torrillas/apps-oauth-pkce-upload
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,631
−19
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+1.17 MB
.yarn/cache/@napi-rs-keyring-linux-arm64-gnu-npm-1.3.0-078668775d-10.zip
Binary file not shown.
Binary file added
BIN
+1.24 MB
.yarn/cache/@napi-rs-keyring-linux-x64-gnu-npm-1.3.0-54a406b5fe-10.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -245,9 +245,13 @@ export type GetWrappedPlugins = (arg: GetPluginsArg) => (PluginOptions | CustomP | |||||
| export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'none'; | ||||||
|
|
||||||
| export type Site = (typeof SITES)[number]; | ||||||
| export type AuthMethod = 'apiKey' | 'oauth'; | ||||||
|
|
||||||
| export type AuthOptions = { | ||||||
| apiKey?: string; | ||||||
| appKey?: string; | ||||||
| accessToken?: string; | ||||||
| method?: AuthMethod; | ||||||
| site?: string; | ||||||
| }; | ||||||
|
|
||||||
|
|
@@ -283,7 +287,7 @@ export type PluginName = `datadog-${Lowercase<string>}-plugin`; | |||||
| type Data = { data?: BodyInit; headers?: Record<string, string> }; | ||||||
| export type RequestOpts = { | ||||||
| url: string; | ||||||
| auth?: Pick<AuthOptions, 'apiKey' | 'appKey'>; | ||||||
| auth?: Pick<AuthOptions, 'apiKey' | 'appKey' | 'accessToken'>; | ||||||
|
Member
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. I believe this should be more of the form:
Suggested change
So |
||||||
| method?: string; | ||||||
| getData?: () => Promise<Data> | Data; | ||||||
| type?: 'json' | 'text'; | ||||||
|
|
||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // Unless explicitly stated otherwise all files in this repository are licensed under the MIT License. | ||
| // This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
| // Copyright 2019-Present Datadog, Inc. | ||
|
|
||
| export type OAuthAuthorizationServer = import('oauth4webapi').AuthorizationServer; | ||
| export type OAuthClient = import('oauth4webapi').Client; | ||
| export type OAuthModule = typeof import('oauth4webapi'); | ||
| export type OAuthTokenEndpointResponse = import('oauth4webapi').TokenEndpointResponse; | ||
|
|
||
| type KeyringModule = typeof import('@napi-rs/keyring'); | ||
|
|
||
| const OAUTH_PACKAGE_NAME = 'oauth4webapi'; | ||
| const KEYRING_PACKAGE_NAME = '@napi-rs/keyring'; | ||
|
|
||
| const memoizeAsync = <Value>(load: () => Promise<Value>) => { | ||
| let promise: Promise<Value> | undefined; | ||
|
|
||
| return () => { | ||
| if (!promise) { | ||
| promise = load().catch((error) => { | ||
| promise = undefined; | ||
| throw error; | ||
| }); | ||
| } | ||
| return promise; | ||
| }; | ||
| }; | ||
|
|
||
| export const loadOauth = memoizeAsync(() => import(OAUTH_PACKAGE_NAME) as Promise<OAuthModule>); | ||
|
|
||
| // `@napi-rs/keyring` has a CommonJS entry. Load it lazily so API-key uploads | ||
| // do not initialize the native credential binding. | ||
| export const loadKeyring = memoizeAsync( | ||
| () => import(KEYRING_PACKAGE_NAME) as Promise<KeyringModule>, | ||
| ); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why's this user facing? Not sure I understand the need for it, from the user's perspective.