Skip to content

Conversation

@janpieterz
Copy link
Contributor

Fixed #47

First time adding definitions to a package, worked locally. Let me know if you want anything changed.

@jevakallio
Copy link
Contributor

@kitten can you take a peek from TS good practices point of view when you have a moment.

@kadikraman These seem legit to me, though I'd check if the optionality of fields is correct - IIRC the revoke call actually requires fewer parameters in the config?

Only thing I'd change is the name AppAuthInput to something like AuthConfiguration.

index.d.ts Outdated

export function revoke(
properties: AppAuthInput,
{ tokenToRevoke: string, sendClientId: boolean }
Copy link
Contributor

Choose a reason for hiding this comment

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

  • The only properties needed for revoke are clientId and issuer. It doesn't matter if you pass in the whole configuration object, but it's not all used. I'm not sure if there's an easy way to reflect that in TypeScript?
  • sendClientId is optional, it defaults to false

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback!
As a proposal I made the clientId and issues in a separate interface that the AuthConfiguration extends, making it 1 definition.
If we don't extend it'll mean we'd need to have two instances of the config object.

sendClientId made optional

@janpieterz
Copy link
Contributor Author

Any idea for a name ( 😄 ) for the clientId and issuer revoke configuration different than BaseAuthConfiguration?

Changed name to AuthConfiguration as well.

Copy link
Contributor

@kadikraman kadikraman left a comment

Choose a reason for hiding this comment

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

Some minor suggestions, otherwise 👍

index.d.ts Outdated

export function refresh(config: AuthConfiguration, refreshConfig: RefreshConfiguration): Promise<AuthorizeResult>;

export function revoke(config: BaseAuthConfiguration, refreshConfig: RevokeConfiguration): Promise<void>; No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

Surely

revokeConfig: RevokeConfiguration

index.d.ts Outdated
export interface AuthConfiguration extends BaseAuthConfiguration {
scopes: string[];
redirectUrl: string;
aditionalParameters?: {[name: string]: any};
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you do

aditionalParameters?: {[name: string]: string};

as the values can technically only be strings?

index.d.ts Outdated
export interface AuthorizeResult {
accessToken: string;
accessTokenExpirationDate: string;
aditionalParameters?: {[name: string]: any};
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

@janpieterz
Copy link
Contributor Author

Done, cheers!

Copy link

@kitten kitten left a comment

Choose a reason for hiding this comment

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

some minor nits, otherwise lgtm

@@ -0,0 +1,39 @@
export interface AuthConfiguration extends BaseAuthConfiguration {
Copy link

Choose a reason for hiding this comment

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

Minor nit here, the indentation seems to be off

index.d.ts Outdated
aditionalParameters?: {[name: string]: string};
}

export interface BaseAuthConfiguration{
Copy link

Choose a reason for hiding this comment

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

can you move this to the top as AuthConfiguration extends it before it's being defined. Just for readability 👍

index.d.ts Outdated
export interface AuthConfiguration extends BaseAuthConfiguration {
scopes: string[];
redirectUrl: string;
aditionalParameters?: {[name: string]: string};
Copy link

Choose a reason for hiding this comment

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

small typo: additionalParameters

index.d.ts Outdated
clientId: string;
}

export interface RevokeConfiguration{
Copy link

Choose a reason for hiding this comment

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

can we make sure that there's a space before {?

@kadikraman: Can you point prettier—I think it's set up with lint-staged, right?—at all TS files as well?

index.d.ts Outdated
export interface AuthorizeResult {
accessToken: string;
accessTokenExpirationDate: string;
aditionalParameters?: {[name: string]: string};
Copy link

Choose a reason for hiding this comment

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

same typo

@janpieterz
Copy link
Contributor Author

Had disabled prettier locally because it kept massively reformatting the package.json on edit.

Now uses prettier formatting and added *.ts to lint-staged too.

@PeterKottas
Copy link
Contributor

Looks good to me! Gj

@jevakallio jevakallio merged commit 898cf39 into FormidableLabs:master Feb 20, 2018
@jevakallio
Copy link
Contributor

Looking good, landed this to master, will push it out in the next release. Thanks @janpieterz @kitten @kadikraman!

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