diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..cd3fc71 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,150 @@ +/// +/// + +import * as angular from 'angular'; + +declare var _: string; +export = _; + +declare module 'angular' { + + export namespace stormpath { + + /** + * STORMPATH_CONFIG + */ + + interface IStormpathConfig { + AUTHENTICATION_ENDPOINT: string; + AUTHENTICATION_FAILURE_EVENT_NAME: string; + AUTHENTICATION_SUCCESS_EVENT_NAME: string; + AUTH_SERVICE_NAME: string; + CHANGE_PASSWORD_ENDPOINT: string; + CURRENT_USER_URI: string; + DESTROY_SESSION_ENDPOINT: string; + EMAIL_VERIFICATION_ENDPOINT: string; + ENDPOINT_PREFIX: string; + FORGOT_PASSWORD_ENDPOINT: string; + FORM_CONTENT_TYPE: string; + GET_USER_EVENT: string; + NOT_LOGGED_IN_EVENT: string; + REGISTERED_EVENT_NAME: string; + REGISTER_URI: string; + ROUTE_CHANGE_UNAUTHENTICATED: string; + ROUTE_CHANGE_UNAUTHORIZED: string; + SESSION_END_EVENT: string; + SOCIAL_LOGIN_SERVICE_NAME: string; + STATE_CHANGE_UNAUTHENTICATED: string; + STATE_CHANGE_UNAUTHORIZED: string; + } + + /** + * $stormpath + */ + + interface IStormpathService { + ngRouter(config: INgRouterConfig): void; + uiRouter(config: IUiRouterConfig): void; + } + + interface IRouterConfig { + autoRedirect?: boolean; + defaultPostLoginState?: string; + forbiddenState?: string; + loginState?: string; + } + + interface INgRouterConfig extends IRouterConfig {} + + interface IUiRouterConfig extends IRouterConfig {} + + /** + * sp config + */ + + interface ISpConfig { + authenticate?: boolean; + authorize?: { + group: string; + }; + waitForUser?: boolean; + } + + interface ISpStateConfig extends ISpConfig {} + + interface ISpRouteConfig extends ISpConfig {} + + /** + * $auth + */ + + interface IAuthService { + authenticate(credentialData: any): angular.IPromise>; + endSession(): angular.IPromise>; + } + + interface IAuthProvider extends angular.IServiceProvider {} + + /** + * $user + */ + + interface IUserService { + currentUser: IUser; + create(accountData: IUserAccountData): angular.IPromise; + get(bypassCache: boolean): angular.IPromise; + passwordResetRequest(data: any): angular.IPromise>; + resendVerificationEmail(data: any): angular.IPromise>; + resetPassword(token: string, data: any): angular.IPromise>; + verify(sptoken: string): angular.IPromise>; + verifyPasswordResetToken(sptoken: string): angular.IPromise>; + } + + interface IUserProvider extends angular.IServiceProvider {} + + interface IUserAccountData { + givenName: string; + surname: string; + email: string; + password: string; + } + + interface IUser { + href: string; + username: string; + email: string; + givenName: string; + middleName: string; + surname: string; + fullName: string; + status: 'ENABLED' | 'UNVERIFIED'; + createdAt: string; + modifiedAt: string; + } + + /** + * $socialLogin + */ + + interface ISocialLoginService {} + + interface ISocialLoginProvider extends angular.IServiceProvider {} + + /** + * $spJsLoader + */ + + interface ISpJsLoader {} + + } + + /** + * Augment ui-router state + */ + export namespace ui { + interface IState { + sp?: stormpath.ISpStateConfig; + } + } + +} diff --git a/package.json b/package.json index 5cba79e..a2d1111 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "1.1.1", "description": "", "main": "index.js", + "types": "index.d.ts", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -14,6 +15,8 @@ "url": "https://github.com/stormpath/stormpath-sdk-angularjs.git" }, "devDependencies": { + "@types/angular": "^1.5.20", + "@types/angular-ui-router": "^1.1.34", "grunt-contrib-concat": "^0.5.1", "grunt": "^0.4.5", "load-grunt-tasks": "^3.4.0",