auth0 / lock-passwordless

Auth0 Lock Passwordless [DEPRECATED]
MIT License
90 stars 29 forks source link

Typescript definitions #118

Open dinvlad opened 8 years ago

dinvlad commented 8 years ago

Is there a .d.ts for Auth0LockPasswordless, akin to that of https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/auth0.lock ?

If there isn't one, is it possible to adapt the one from the link with only a few minor modifications - in other words, are their APIs compatible (apart from the constructor and such)?

EDIT: Or would that even matter from a client's perspective - one only needs to call the constructor and a show-like method (.emailcode etc.), at least for basic use. So would it be sufficient to create abridged definitions only for these?

Thanks

dinvlad commented 8 years ago

The simplest case of type definitions from the above indeed seems to be sufficient (at least, Lock is loaded successfully from Typescript and there are no errors reported in the console):

interface Auth0LockPasswordlessStatic {
  new (clientId: string, domain: string): Auth0LockPasswordlessStatic;
  getProfile(token: string, callback: (error: Auth0Error, profile: Auth0UserProfile) => void) : void;

  close(): void;
  destroy(): void;
  parseHash(hash: string): Auth0DecodedHash;
  logout(query: any): void;

  requestGravatar(email: string): void;

  emailcode(options?: Auth0LockConstructorOptions): void;
  socialOrEmailcode(options?: Auth0LockConstructorOptions): void;
}

declare var Auth0LockPasswordless: Auth0LockPasswordlessStatic;

declare module "auth0-lock-passwordless" {
    export = Auth0LockPasswordless;
}

Are there any hidden gotchas to this use?