-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Create BackenClient with static access token #16727
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
Create BackenClient with static access token #16727
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 3 Skipped Deployments
|
WalkthroughThe changes introduce support for initializing the Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant BackendClient
Caller->>BackendClient: new BackendClient({ credentials })
alt credentials has accessToken
BackendClient->>BackendClient: Store staticAccessToken
else credentials is OAuthCredentials
BackendClient->>BackendClient: Initialize oauthClient
end
Caller->>BackendClient: authHeaders()
alt staticAccessToken present
BackendClient-->>Caller: return Bearer staticAccessToken
else
BackendClient->>BackendClient: ensureValidOauthAccessToken()
BackendClient-->>Caller: return Bearer OAuth token
end
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
packages/sdk/src/server/index.tsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs Note ⚡️ AI Code Reviews for VS Code, Cursor, WindsurfCodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback. Note ⚡️ Faster reviews with cachingCodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure ✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/sdk/src/server/index.ts (2)
181-183: Update the documentation for createBackendClient function.The TSDoc comment for
createBackendClientonly shows an example with OAuth credentials but should also include an example with static access token for completeness.* Creates a new instance of BackendClient with the provided options. * * * @example * * * ```typescript const serverClient = createBackendClient({ environment: "development", projectId: "<project id>", credentials: { clientId: "<client id>", clientSecret: "<client secret>", }, }) * ``` +* +* @example +* +* ```typescript +* const serverClient = createBackendClient({ +* environment: "development", +* projectId: "<project id>", +* credentials: { +* accessToken: "<access token>", +* }, +* }) +* ``` * * @param opts - The options for creating the server client. * @returns A new instance of ServerClient.
29-42: Add documentation for the new credential type.The TSDoc comment for
BackendClientOpts.credentialsshould be updated to document both authentication options./** * The credentials to use for authentication against the Pipedream API. + * This can be either OAuth credentials (clientId and clientSecret) or a static access token. */ credentials: OAuthCredentials | { accessToken: string; };
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting
📒 Files selected for processing (3)
packages/sdk/CHANGELOG.md(1 hunks)packages/sdk/package.json(1 hunks)packages/sdk/src/server/index.ts(4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Lint Code Base
- GitHub Check: test
- GitHub Check: pnpm publish
🔇 Additional comments (8)
packages/sdk/CHANGELOG.md (1)
5-9: LGTM! The changelog entry clearly documents the new feature.The changelog entry accurately describes the new capability to create a
BackendClientwith just anAccessToken, which aligns with the implementation changes in the codebase.packages/sdk/package.json (1)
4-4: Version bump is appropriate for the feature addition.The version increment from 1.6.1 to 1.6.2 follows semantic versioning principles for adding a new feature in a backward-compatible manner.
packages/sdk/src/server/index.ts (6)
39-41: LGTM! The type definition is properly updated.The
BackendClientOpts.credentialstype now accepts either OAuth credentials or a static access token, which enables the new feature described in the changelog.
193-193: Good defensive programming - making oauthClient potentially undefined.Making the
oauthClientpotentially undefined is necessary since it may not be initialized when using a static access token.
199-199: LGTM! Required property for the new feature.Adding
staticAccessTokenas a class property is necessary to store the static access token when provided in the credentials.
212-216: Proper initialization logic for both auth methods.The constructor correctly initializes either the static access token or the OAuth client based on the provided credentials.
254-258: LGTM! Auth headers now support both authentication methods.The
authHeadersmethod now properly uses the static access token when available, falling back to OAuth authentication otherwise.
262-264: Good defensive check for OAuth client existence.Adding a check to throw an error if the OAuth client is not configured when trying to use OAuth authentication prevents cryptic errors later.
WHY
Summary by CodeRabbit
New Features
Documentation
Chores