Skip to content
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]: accept repository ids, names and permissions in getInstallationOctokit #414

Open
1 task done
safareli opened this issue Apr 20, 2023 · 0 comments
Open
1 task done
Labels
hacktoberfest Issues for participation in Hacktoberfest Status: Up for grabs Issues that are ready to be worked on by anyone Type: Feature New feature or request
Projects

Comments

@safareli
Copy link

Describe the need

getInstallationOctokit doesn't accept repository ids, names or permissions, while the rest api and createAppAuth from @octokit/auth-app both accept them.

Temporarily what I did was look into implementation of the getInstallationOctokit and created modified version of it that works for my needs. I'm happy to contribute with this changes if maintainers are ok with that.

async function getInstallationOctokitWithPermissions(
  app: OctokitApp,
  installationId: number,
  params: {
    repositoryIds?: number[];
    repositoryNames?: string[];
    // This type is not exhaustive there are more permissions this can accept see here:
    // https://docs.github.com/en/rest/apps/apps?apiVersion=2022-11-28#create-an-installation-access-token-for-an-app
    // type should be updated as we need more kinds of permissions
    permissions: {
      metadata?: "read";
      contents?: "read";
    };
  }
): ReturnType<OctokitApp["getInstallationOctokit"]> {
  return app.octokit.auth({
    type: "installation",
    installationId: installationId,
    factory(auth: any) {
      return new auth.octokit.constructor({
        ...auth.octokitOptions,
        authStrategy: AppAuth.createAppAuth,
        ...{
          auth: {
            ...auth,
            installationId: installationId,
            ...params,
          },
        },
      });
    },
  }) as ReturnType<OctokitApp["getInstallationOctokit"]>;
}

SDK Version

No response

API Version

No response

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@safareli safareli added Status: Triage This is being looked at and prioritized Type: Feature New feature or request labels Apr 20, 2023
@ghost ghost added this to Features in JS Apr 20, 2023
@kfcampbell kfcampbell added Priority: Normal Status: Up for grabs Issues that are ready to be worked on by anyone and removed Status: Triage This is being looked at and prioritized labels May 1, 2023
@nickfloyd nickfloyd added the hacktoberfest Issues for participation in Hacktoberfest label Sep 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest Issues for participation in Hacktoberfest Status: Up for grabs Issues that are ready to be worked on by anyone Type: Feature New feature or request
Projects
Status: 🔥 Backlog
JS
  
Features
Development

No branches or pull requests

3 participants