keycloak-aplcache

Merge pull request #3971 from ssilvert/KEYCLOAK-4396-ng2-wrapper KEYCLOAK-4396:

3/23/2017 10:12:03 AM

Details

diff --git a/adapters/oidc/js/src/main/resources/keycloak.d.ts b/adapters/oidc/js/src/main/resources/keycloak.d.ts
new file mode 100644
index 0000000..5579da1
--- /dev/null
+++ b/adapters/oidc/js/src/main/resources/keycloak.d.ts
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2017 Red Hat, Inc. and/or its affiliates
+ * and other contributors as indicated by the @author tags.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+declare module KeycloakModule {
+
+    export interface Promise {
+        success(callback: Function): Promise;
+        error(callback: Function): Promise;
+    }
+
+    export type ResponseModes = "query" | "fragment";
+    export type Flows = "standard" | "implicit" | "hybrid";
+    
+    export interface InitOptions {
+        checkLoginIframe?: boolean;
+        checkLoginIframeInterval?: number;
+        onLoad?: string;
+        adapter?: string;
+        responseMode?: ResponseModes;
+        flow?: Flows;
+        token?: string;
+        refreshToken?: string;
+        idToken?: string;
+        timeSkew?: number;
+    }
+
+    export interface LoginOptions {
+        redirectUri?: string;
+        prompt?: string;
+        maxAge?: number;
+        loginHint?: string;
+        action?: string;
+        locale?: string;
+    }
+
+    export interface RedirectUriOptions {
+        redirectUri?: string;
+    }
+
+    export interface KeycloakClient {
+        init(options?: InitOptions): Promise;
+        login(options?: LoginOptions): Promise;
+        createLoginUrl(options?: LoginOptions): string;
+        logout(options?: RedirectUriOptions): Promise;
+        createLogoutUrl(options?: RedirectUriOptions): string;
+        register(options?: LoginOptions): Promise;
+        createRegisterUrl(options?: RedirectUriOptions): string;
+        accountManagement(): Promise;
+        createAccountUrl(options?: RedirectUriOptions): string;
+        hasRealmRole(role: string): boolean;
+        hasResourceRole(role: string, resource?: string): boolean;
+        loadUserProfile(): Promise;
+        isTokenExpired(minValidity: number): boolean;
+        updateToken(minValidity: number): Promise;
+        clearToken(): any;
+
+        realm: string;
+        clientId: string;
+        authServerUrl: string;
+
+        token: string;
+        tokenParsed: any;
+        refreshToken: string;
+        refreshTokenParsed: any;
+        idToken: string;
+        idTokenParsed: any;
+        realmAccess: any;
+        resourceAccess: any;
+        authenticated: boolean;
+        subject: string;
+        timeSkew: number;
+        responseMode: ResponseModes;
+        flow: Flows;
+        responseType: string;
+
+        onReady: Function;
+        onAuthSuccess: Function;
+        onAuthError: Function;
+        onAuthRefreshSuccess: Function;
+        onAuthRefreshError: Function;
+        onAuthLogout: Function;
+        onTokenExpired: Function;
+    }
+}
+
+declare var Keycloak: {
+    new(config?: any): KeycloakModule.KeycloakClient;
+};
\ No newline at end of file
diff --git a/distribution/adapters/js-adapter-zip/assembly.xml b/distribution/adapters/js-adapter-zip/assembly.xml
index 5e6799b..14e0cc0 100755
--- a/distribution/adapters/js-adapter-zip/assembly.xml
+++ b/distribution/adapters/js-adapter-zip/assembly.xml
@@ -30,6 +30,7 @@
             <outputDirectory></outputDirectory>
             <includes>
                 <include>**/*.js</include>
+                <include>**/*.d.ts</include>
                 <include>**/*.html</include>
             </includes>
         </fileSet>
diff --git a/distribution/adapters/js-adapter-zip/pom.xml b/distribution/adapters/js-adapter-zip/pom.xml
index be59aa6..3dafa00 100755
--- a/distribution/adapters/js-adapter-zip/pom.xml
+++ b/distribution/adapters/js-adapter-zip/pom.xml
@@ -50,7 +50,7 @@
                                     <groupId>org.keycloak</groupId>
                                     <artifactId>keycloak-js-adapter</artifactId>
                                     <outputDirectory>${project.build.directory}/unpacked/js-adapter</outputDirectory>
-                                    <includes>*.js</includes>                                    
+                                    <includes>*.js,*.d.ts</includes>                                 
                                 </artifactItem>
                             </artifactItems>
                             <excludes>**/welcome-content/*</excludes>