-
Notifications
You must be signed in to change notification settings - Fork 13
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
🚧 Initial version #1
base: main
Are you sure you want to change the base?
Conversation
Any chance this initial version will be published and supported? |
I'm not working on it right now. I only ran the setup script If you'd like to work on it yourself let me know |
Aha! Thanks for the information! Is this client (and the authentication flow) compatible with your Cloudflare Worker? |
It should be, if it's not I can help make it so. I'll have a look at https://github.com/gr2m/cloudflare-worker-github-oauth-login today to make sure it updated to the latest of everything. If you get stuck with anything please let me know :) |
so actually https://github.com/gr2m/cloudflare-worker-github-oauth-login is not a good backend for it. What you should use for the backend is It should be straight forward to deploy an OAuth app using |
there you go: https://glitch.com/edit/#!/github-oauth-app-example |
I’d like try Cloudflare Worker (the first time) for my next project. I haven’t dive deep yet, but do you think it is possible to create a Cloudflare Worker which is compatible with Thanks :) |
Yes it’s absolutely possible. You can use the |
Can the (to be implemented) Cloudflare middleware benefit from I guess some of the code in I believe Thanks again for your patience. |
Yes, they are!
I built https://github.com/gr2m/cloudflare-worker-github-oauth-login before
Yes, you should be able to use it. But I think Cloudflare workers work like serverless functions in that they don't keep state between requests? I'm not 100% sure about that. If they keep state, I'd use
Both the code and the types of
My longer term goal is to server both a pre-configured Right now,
import { createOAuth } from "/api/github/auth.js"
const auth = createOAuth() It would work just like the usage example but all configuration is preset for you, as it's tailored to your server instance. And even simpler, you can load the import { Octokit } from "/api/github/auth.js"
const octokit = Octokit() and it would just work™️ To circle back about the benefit: expiring OAuth tokens will become the norm in future. They are already enabled for new GitHub Apps by default. After 8h a token expires and is no longer valid. |
Hi, Gregor! It's been a long week. Do you have some time to review the Cloudflare worker? I’ve drafted two commits:
Do you think it makes sense? Do I need to look at For Sorry for being lazy. |
wow, thanks a lot for taking it on Baoshan!
I need to find a bigger chunk of time to review your changes. Could you start a pull request? That will make it easier to discuss the changes
Can you start a pull request as well, maybe against the branch of the first pull request, so it would only show the relevant changes?
I do not think so, the types in there are more for the
Yes. I'd say the default implementation should be something like function getSession () {
throw new Error("[@octokit/auth-oauth-user-client] getSession implementation is not set")
}
> I see two versions: the standalone version uses Fetch APIs and the other uses on `@octokit/request` (and the hook mechanism in `core` to provide authorization header I guess)
The way the other authentication strategies are implemented is to use [`@octokit/request`](https://github.com/octokit/request.js) (which is a slight wrapper around `fetch`). The default `request` from `@octokit/requst` can be overwritten by a strategy option `request`, which is how an `Octokit` constructor can hook into the requests done by an authentication strategy. See for example the [strategy options for `@octokit/auth-oauth-client`](https://github.com/octokit/auth-oauth-user.js#createoauthuserauthoptions-or-new-octokit-auth-). Passing `octokit.request` as the `request` option to the authentication strategy set as `authStrategy` option on the `Octokit` constructor is implemented in `@octokit/core`:
https://github.com/octokit/core.js/blob/5e85e828d01e95eaffd82016dc580c5ae065c305/src/index.ts#L141-L156
That's a mouth full 🤣 What it means when you do this
```js
const octokit = new Octokit({
authStrategy: createOAuthUserClientAuth,
auth: { getSession, /* ... /* }
}) Then So in the
|
Thanks @baoshan, I'll need a moment to review the pull request. One thing I've seen is that you've used conditional chaining ( |
Given that this library is not meant to be used in Node we can also remove the tests in Node 12 altogether. We should probably add tests using real browsers as part of the CI, but I'd say we can look into that later |
Thanks for the suggestions! I’m ready to help when you’ve reviewed the PR. |
@baoshan hey just checking in to make sure you are not blocked by something? Anything I can help with? |
Are you expecting me to fix the conditional chaining issue? Is it fine to use Sorry for the delay anyway, I’ll submit a PR later. |
no need, as it's a new package and we don't need to support Node 10.
Yes Jest is fine
No worries at all, no rush. I just realized I meant to do a thorough review of this PR, I'll do that tomorrow |
@gr2m Hello. Do you need any help on this? I have managed to fix test errors on my fork (by removing I have tested it locally with the POC project I was working on, it works :) |
@ArtemMelnychenko Any help is much appreciated! Can you send a PR against the I'm focused on https://github.com/octokit/octokit-next.js right now and for the coming weeks and months, but I'd love to get |
Hi @ArtemMelnychenko! Thanks for testing the draft! I’m not sure why you need to set Could you let me know why the current implementation fails on your POC project? Thanks. |
Personally I hope the nullish coalescing operator ( |
@baoshan thanks for the clarification. Indeed, it's covered by a test and there was a link to the regarding coalescing operator (??) and optional chaining (?.) - I have tested inside docker node:12 image and can confirm that setting the target to es2019 allows jest tests to succeed. However, Should I proceed with reverting the previous commits and add es2019 target in my pull request? Edit: alternatively, we could override target in the global jest config as described here. I have tested it too, then we can avoid the warning. |
Thanks very much @Plazmius for letting me know the details. I’m fine with removing node 12 from the matrix. I guess I think @gr2m is too busy to review the code. If that is the case, could you kindly help him by giving BTW, will this be compatible with |
@baoshan I will submit the review with pleasure. Should I create a PR for removing test matrix for node 12 first, or go ahead with the review? Is there any guidelines/requirements for submitting the review, because I didn't find any? Thanks |
I'm okay with that, too. I'd rather unblock us here and change things later :)
Sorry for the delay, I'm trying to catch up soon
Don't worry about that right now, I'll do once we get there. I cannot think of a reason why it shouldn't |
There’re several known issues in my draft implementation (the For anybody who needs this strategy now, you can use my fork. |
@baoshan hey I'm interested in moving this forward :) What's the latest status with your port? We are in the process of removing the pika build tools and replacing them with esbuild and tsc (see for example octokit/app.js#420). I'd also be interested in figuring out how to build a React Provider for Octokit using this plugin. Do you know if there is any prior art in that direction? |
It has no known issue but I may be the only user.
I do not currently have time to rewrite the tests in Jest (which is heavy IMHO) or make an esbuild script. PS: I know little about React. |
Sounds good, I'll see if I can find the time this weekend to merge your changes and adapt them to the @octokit conventions
yeah I replaced Jest with ava in https://github.com/octokit/octokit-next.js for that reason. |
initial-version |
feat: ...
commits for each feature of the initial version