Skip to content

Commit

Permalink
Merge pull request #35 from syetalabs/global-types
Browse files Browse the repository at this point in the history
feat: Typings for GSI client
  • Loading branch information
kasvith authored Jan 27, 2023
2 parents 4d8d60e + 6a5bab5 commit 9c3f5ed
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 11 additions & 3 deletions src/@types/globals.d.ts → src/@types/globals.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import { CodeClient } from "../interfaces/oauth2";
import type {
CodeClient,
CodeClientConfig,
OverridableTokenClientConfig,
TokenClientConfig,
TokenResponse,
} from "../interfaces/oauth2";

import {
import type {
IdConfiguration,
MomentListener,
GsiButtonConfiguration,
RevocationCallback,
} from "@/interfaces/accounts";
} from "../interfaces/accounts";

declare global {
interface Window {
Expand Down Expand Up @@ -51,3 +57,5 @@ declare global {
};
}
}

export default {};
3 changes: 2 additions & 1 deletion src/composables/useCodeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ export default function useCodeClient(
});

client = window.google?.accounts.oauth2.initCodeClient({
client_id: clientId,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
client_id: clientId!,
scope: computedScopes,
callback: (response: CodeResponse) => {
if (response.error) return onError?.(response);
Expand Down
3 changes: 2 additions & 1 deletion src/composables/useTokenClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ export default function useTokenClient(
: scopeValue;

client = window.google?.accounts.oauth2.initTokenClient({
client_id: clientId,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
client_id: clientId!,
scope: `openid email profile ${scopes}`,
callback: (response: TokenResponse) => {
if (response.error) return onError?.(response);
Expand Down
1 change: 1 addition & 0 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,6 @@ export type {
AuthCodeFlowErrorResponse,
AuthCodeFlowSuccessResponse,
};
export * from "./@types/globals";

export default plugin;
3 changes: 3 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"DOM.Iterable",
"ESNext"
],
"typeRoots": [
"./src/@types"
],
"strict": true,
"removeComments": false
},
Expand Down

0 comments on commit 9c3f5ed

Please sign in to comment.