I have created Typescript definitions, and wanted to check if you wanted to include this in the package or if I should simply add them to DefinitelyTyped.
declare module "react-native-app-auth" {
interface IAppAuthProperties {
scopes: string[];
issuer: string;
clientId: string;
redirectUrl: string;
aditionalParameters?: object;
}
function authorize(
properties: IAppAuthProperties
): Promise<{
accessToken: string;
accessTokenExpirationDate: string;
additionalParameters: object;
idToken: string;
refreshToken: string;
tokenType: string;
}>;
function refresh(
properties: IAppAuthProperties,
{ refreshToken: string }
): Promise<AuthorizeResult>;
function revoke(
properties: IAppAuthProperties,
{ tokenToRevoke: string, sendClientId: boolean }
): Promise<void>;
}
I think due to the small size of the module and the low likelihood of extra exports, we shouldn't resort to declaring a module, but just create a d.ts with exports in parallel to the index file.
But in general this is looking fine, although I'd create another interface for the authorize result.
I'm also personally not a fan of starting all interfaces with I* as in IAppAuthProperties, and Properties could just be Input or Opts, without losing clarity.
/cc @kadikraman
Totally forgot I wanted to share mine as well ... Anyways, there are a few differences so we might join these 2 together. Here's what I have:
declare module 'react-native-app-auth' {
export interface AuthConfig {
issuer: string;
clientId: string;
redirectUrl: string;
scopes: string[];
additionalParameters?: { [name: string]: any };
}
export interface AuthorizeResult {
accessToken: string;
accessTokenExpirationDate: string;
additionalParameters?: { [name: string]: any };
idToken: string;
refreshToken: string;
tokenType: string;
}
export interface RevokeConfig {
tokenToRevoke: string;
sendClientId?: boolean;
}
export interface RefreshConfig {
refreshToken: string;
}
export function authorize(config: AuthConfig): Promise<AuthorizeResult>;
export function revoke(config: AuthConfig, revokeConfig: RevokeConfig): Promise<AuthorizeResult>;
export function refresh(config: AuthConfig, refreshConfig: RefreshConfig): Promise<AuthorizeResult>;
}
Almost the same, just notice few small things.
Just my 2 cents.
@PeterKottas nice! Was wondering about the additionalParameters. Have made a couple of changes (there's a pull request). Cheers.
Released as v2.1.0 馃帀
Most helpful comment
I think due to the small size of the module and the low likelihood of extra exports, we shouldn't resort to declaring a module, but just create a
d.tswith exports in parallel to the index file.But in general this is looking fine, although I'd create another interface for the
authorizeresult.I'm also personally not a fan of starting all interfaces with
I*as inIAppAuthProperties, andPropertiescould just beInputorOpts, without losing clarity./cc @kadikraman