-
Notifications
You must be signed in to change notification settings - Fork 603
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
Add type definitions via index.d.ts #2514
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
interface Callback { | ||
(): void; | ||
} | ||
type Data = Record<string, unknown>; | ||
interface SessionData<T> { | ||
authenticated: T; | ||
} | ||
|
||
declare module 'ember-simple-auth/services/session' { | ||
import Evented from '@ember/object/evented'; | ||
import Service from '@ember/service'; | ||
import type BaseSessionStore from 'ember-simple-auth/session-stores/base'; | ||
import type Transition from '@ember/routing/-private/transition'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this could now be imported from the public transition type: -import type Transition from '@ember/routing/-private/transition';
+import type Transition from '@ember/routing/transition' |
||
|
||
export default class SessionService<T> extends Service.extend(Evented) { | ||
isAuthenticated: boolean; | ||
data: SessionData<T>; | ||
store: BaseSessionStore; | ||
attemptedTransition: Transition | null; | ||
|
||
authenticate(authenticator: string, ...args: unknown[]): Promise<void>; | ||
invalidate(...args: unknown[]): Promise<unknown>; | ||
requireAuthentication(transition: Transition, routeOrCallback: string | Callback): boolean; | ||
prohibitAuthentication(routeOrCallback: string | Callback): boolean; | ||
handleAuthentication(routeAfterAuthentication: string): void; | ||
handleInvalidation(routeAfterInvalidation: string): void; | ||
setup(): Promise<void>; | ||
} | ||
} | ||
|
||
declare module 'ember-simple-auth/authenticators/base' { | ||
import EmberObject from '@ember/object'; | ||
import Evented from '@ember/object/evented'; | ||
|
||
export default class extends EmberObject.extend(Evented) { | ||
restore(data: Data): Promise<unknown>; | ||
authenticate(...args: unknown[]): Promise<unknown>; | ||
Comment on lines
+36
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe |
||
invalidate(data: Data, ...args: unknown[]): Promise<unknown>; | ||
} | ||
} | ||
|
||
declare module 'ember-simple-auth/session-stores/base' { | ||
import EmberObject from '@ember/object'; | ||
import Evented from '@ember/object/evented'; | ||
|
||
export default class extends EmberObject.extend(Evented) { | ||
persist(data: SessionData<Data>): Promise<unknown>; | ||
restore(): Promise<SessionData<Data>>; | ||
clear(): Promise<void>; | ||
} | ||
} | ||
|
||
declare module 'ember-simple-auth/session-stores/local-storage' { | ||
import BaseSessionStore from 'ember-simple-auth/session-stores/base'; | ||
|
||
export default class extends BaseSessionStore { | ||
key: string; | ||
} | ||
} | ||
|
||
declare module 'ember-simple-auth/session-stores/cookie' { | ||
import BaseSessionStore from 'ember-simple-auth/session-stores/base'; | ||
|
||
export default class extends BaseSessionStore { | ||
cookieDomain: string; | ||
cookieExpirationTime: null | number; | ||
cookieName: string; | ||
cookiePath: string; | ||
sameSite: null | 'Strict' | 'Lax'; | ||
} | ||
} | ||
|
||
declare module 'ember-simple-auth/session-stores/adaptive' { | ||
import CookieSessionStore from 'ember-simple-auth/session-stores/base'; | ||
|
||
export default class extends CookieSessionStore { | ||
localStorageKey: string; | ||
} | ||
} | ||
|
||
declare module 'ember-simple-auth/session-stores/ephemeral' { | ||
import BaseSessionStore from 'ember-simple-auth/session-stores/base'; | ||
|
||
export default class extends BaseSessionStore { } | ||
} | ||
|
||
declare module 'ember-simple-auth/session-stores/session-storage' { | ||
import BaseSessionStore from 'ember-simple-auth/session-stores/base'; | ||
|
||
export default class extends BaseSessionStore { | ||
key: string; | ||
} | ||
} | ||
|
||
declare module 'ember-simple-auth/authenticators/test' { | ||
import BaseAuthenticator from 'ember-simple-auth/authenticators/base'; | ||
|
||
export default class extends BaseAuthenticator { } | ||
} | ||
|
||
declare module 'ember-simple-auth/authenticators/devise' { | ||
import BaseAuthenticator from 'ember-simple-auth/authenticators/base'; | ||
|
||
export default class extends BaseAuthenticator { | ||
serverTokenEndpoint: string; | ||
resourceName: string; | ||
tokenAttributeName: string; | ||
identificationAttributeName: string; | ||
} | ||
} | ||
|
||
declare module 'ember-simple-auth/authenticators/oauth2-implicit-grant' { | ||
import BaseAuthenticator from 'ember-simple-auth/authenticators/base'; | ||
|
||
export default class extends BaseAuthenticator { } | ||
} | ||
|
||
declare module 'ember-simple-auth/authenticators/oauth2-password-grant' { | ||
import BaseAuthenticator from 'ember-simple-auth/authenticators/base'; | ||
|
||
export default class extends BaseAuthenticator { | ||
clientId: string | null; | ||
serverTokenEndpoint: string; | ||
serverTokenRevocationEndpoint: string | null; | ||
refreshAccessTokens: boolean; | ||
} | ||
} | ||
|
||
declare module 'ember-simple-auth/authenticators/torii' { | ||
import BaseAuthenticator from 'ember-simple-auth/authenticators/base'; | ||
|
||
export default class extends BaseAuthenticator { } | ||
} | ||
|
||
declare module 'ember-simple-auth/test-support' { | ||
import SimpleAuthSessionService from 'ember-simple-auth/services/session'; | ||
export function currentSession(): SimpleAuthSessionService<Data>; | ||
export function authenticateSession(sessionData: Data): Promise<void>; | ||
export function invalidateSession(): Promise<void>; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of the imports could be
import type
, i guess: