-
Notifications
You must be signed in to change notification settings - Fork 67
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
[Typescript] Octokit "auth" option does not support example from docs for installation tokens #13
Comments
Thank you for reporting the bug Doug. v17 of So for now, I will set |
Could you have a glance at my PR at https://github.com/octokit/rest.js/pull/1563? It should remove the TypeScript error you are seeing? |
Thanks for the quick follow up @gr2m. I’ll try to review the PR this week. Just wanted to reply to say I saw your message and on my todo to follow up. Thanks — Yes, the addition of |
Thanks Doug, I'll go ahead and merge it then. I'd love to improve the Types for the auth option. Please let me know if you have any ideas |
fixed in v16.40.2 |
Thanks! |
@gr2m all you want is a union type for Something like
export interface AuthStrategyOne {
authStrategy: AnAuthStrategy;
auth: OptionsAnAuthStrategy;
}
export interface AuthStrategyTwo {
authStrategy: TheThing;
auth: OptionsForTheThing;
}
export interface NoAuthStrategy {
authStrategy?: undefined;
}
export type Options = BaseOptions & (AuthStrategyOne | AuthStrategyTwo | NoAuthStrategy);
export interface BaseOptions {
userAgent?: string;
previews?: string[];
baseUrl?: string;
log?: {
debug?: (message: string, info?: object) => void;
info?: (message: string, info?: object) => void;
warn?: (message: string, info?: object) => void;
error?: (message: string, info?: object) => void;
};
request?: {
agent?: http.Agent;
timeout?: number;
};
/**
* @deprecated Use {request: {timeout}} instead. See https://github.com/octokit/request.js#request
*/
timeout?: number;
/**
* @deprecated Use {userAgent, previews} instead. See https://github.com/octokit/request.js#request
*/
headers?: { [header: string]: any };
/**
* @deprecated Use {request: {agent}} instead. See https://github.com/octokit/request.js#request
*/
agent?: http.Agent;
[option: string]: any;
} |
Unfortunately we don't know the full set of authentication strategies. Users can build their own. But I guess we could have some kind of fallback if it doesn't fit any of the known strategies? |
Or you could make a sort of strategy registry; export interface OctokitAuthStrategies {
AuthStrategyOne: {
authStrategy: AnAuthStrategy;
auth: OptionsAnAuthStrategy;
}
AuthStrategyTwo: {
authStrategy: TheThing;
auth: OptionsForTheThing;
}
NoAuthStrategy: {
authStrategy?: undefined;
}
}
export type Options = BaseOptions & (OctokitAuthStrategies[keyof OctokitAuthStrategies]); which can then be augmented by consumers/strategy authors with declare module "@octokit/rest" {
export interface OctokitAuthStrategies {
MyCustomStrategy: {
authStrategy: CustomThing;
auth: CustomOptionsThing;
}
}
} |
I see, thank you! Didn't think about that possibility! |
This would need to be implemented in |
closing in favor of octokit/core.js#323 |
I recently updated the following octokit modules and began receiving a deprecation warning about not providing an
authStrategy
.Deprecation Warning
Octokit Modules
Code That Raises Deprecation Warning
Code I Would Like To Use
Discrepancy to Documentation
Per the example in the documentation, I should be able to specify the app
id
andprivateKey
as theauth
settings but those are not valid per the current typescript definition.Proposal
Not sure if this is on your roadmap to v17, but if not then here's my two cents.
Since the octokit rest module's authentication plugin just passes
options.auth
to the auth strategy viaconst auth = options.authStrategy(options.auth);
, should the typescript definition forauth
in this octokit rest module match StrategyOptions type as shown in the auth-app usages?Thanks!
The text was updated successfully, but these errors were encountered: