Skip to content

adds custom authenticator sample#154

Merged
abhigun merged 2 commits intomainfrom
abhishek/custom_auth_sample
Apr 17, 2026
Merged

adds custom authenticator sample#154
abhigun merged 2 commits intomainfrom
abhishek/custom_auth_sample

Conversation

@abhigun
Copy link
Copy Markdown
Contributor

@abhigun abhigun commented Apr 17, 2026

Pull Request Checklist

Please ensure that your PR meets the following requirements:

  • I have read the CONTRIBUTING guide.
  • I have updated the documentation (if applicable).
  • My code follows the style guidelines of this project.
  • I have performed a self-review of my own code.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.

Fixes # (issue number)

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Open with Devin

Copilot AI review requested due to automatic review settings April 17, 2026 02:37
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 17, 2026

CLA assistant check
All committers have signed the CLA.

github-advanced-security[bot]

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new JavaScript/TypeScript example intended to demonstrate a “custom authenticator” pattern (token vending from a backend + client-side token caching) to avoid exposing a long-lived projectKey to untrusted clients.

Changes:

  • Introduces a combined backend/client end-to-end script for token delegation.
  • Implements a BackendTokenAuthenticator with local token caching.
  • Adds an in-process HTTP token server used by the example client.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread examples/javascript/custom_authenticator_sample.ts
Comment thread examples/javascript/custom_authenticator_sample.ts
Comment on lines +78 to +82
// Delegate to MossClient — no need to re-implement the token exchange
const authToken = await mossClient.getAuthToken();

res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify(authToken)); // { token: string, expiresIn: number }
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MossClient currently has no getAuthToken() method in this repo’s JS SDK (sdks/javascript/sdk/src/client/mossClient.ts), so this backend token-vending endpoint won’t compile/run as written. Use the SDK’s actual authentication mechanism, or add a supported token-exchange API to the SDK and update the sample accordingly.

Copilot uses AI. Check for mistakes.
Comment thread examples/javascript/custom_authenticator_sample.ts
Comment thread examples/javascript/custom_authenticator_sample.ts Outdated
Comment thread examples/javascript/custom_authenticator_sample.ts Outdated
devin-ai-integration[bot]

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

Open in Devin Review

Comment thread examples/javascript/package.json
@abhigun abhigun merged commit 5809d1c into main Apr 17, 2026
18 checks passed
Atulsingh1155 pushed a commit to Atulsingh1155/moss that referenced this pull request Apr 30, 2026
## Pull Request Checklist

Please ensure that your PR meets the following requirements:

- [ ] I have read the [CONTRIBUTING](CONTRIBUTING.md) guide.
- [ ] I have updated the documentation (if applicable).
- [ ] My code follows the style guidelines of this project.
- [ ] I have performed a self-review of my own code.
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] New and existing unit tests pass locally with my changes.

## Description

Please include a summary of the change and which issue is fixed. Please
also include relevant motivation and context.

Fixes # (issue number)

## Type of Change

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update

<!-- devin-review-badge-begin -->

---

<a href="https://app.devin.ai/review/usemoss/moss/pull/154"
target="_blank">
  <picture>
<source media="(prefers-color-scheme: dark)"
srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1">
<img
src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1"
alt="Open with Devin">
  </picture>
</a>
<!-- devin-review-badge-end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants