hyperapp-is 0.1.34 → 0.1.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -13,4 +13,4 @@ export { Carousel, effect_InitCarousel } from "./animationView/carousel";
|
|
|
13
13
|
export type { ScrollMargin, MatrixState } from "./dom/utils";
|
|
14
14
|
export { getScrollMargin, getMatrixState } from "./dom/utils";
|
|
15
15
|
export type { GoogleAccountsId, GoogleTokenClient, GoogleAccountsOAuth2, GoogleAccounts, Google, GoogleAuthConfig, GoogleUser, GoogleAuthResult, GoogleScope, GetAccessTokenConfig } from "./services/google";
|
|
16
|
-
export { getGoogle, googleAuth,
|
|
16
|
+
export { getGoogle, googleAuth, getAccessToken } from "./services/google";
|
|
@@ -7,4 +7,4 @@ export { progress_easing } from "./animation/easing";
|
|
|
7
7
|
export { createUnits, createRAFProperties, effect_RAFProperties } from "./animation/properties";
|
|
8
8
|
export { Carousel, effect_InitCarousel } from "./animationView/carousel";
|
|
9
9
|
export { getScrollMargin, getMatrixState } from "./dom/utils";
|
|
10
|
-
export { getGoogle, googleAuth,
|
|
10
|
+
export { getGoogle, googleAuth, getAccessToken } from "./services/google";
|
|
@@ -10,6 +10,12 @@ export interface GoogleAccountsId {
|
|
|
10
10
|
disableAutoSelect(): void;
|
|
11
11
|
cancel(): void;
|
|
12
12
|
prompt(callback?: (notification: any) => void): void;
|
|
13
|
+
renderButton(parent: HTMLElement, options?: {
|
|
14
|
+
theme?: "outline" | "filled_blue" | "filled_black";
|
|
15
|
+
size?: "large" | "medium" | "small";
|
|
16
|
+
text?: "signin_with" | "signup_with" | "continue_with";
|
|
17
|
+
shape?: "rectangular" | "pill" | "circle" | "square";
|
|
18
|
+
}): void;
|
|
13
19
|
}
|
|
14
20
|
export interface GoogleTokenClient {
|
|
15
21
|
requestAccessToken(options?: {
|
|
@@ -49,8 +55,7 @@ export interface GoogleAuthResult {
|
|
|
49
55
|
idToken: string;
|
|
50
56
|
user: GoogleUser;
|
|
51
57
|
}
|
|
52
|
-
export declare const googleAuth: (config: GoogleAuthConfig) => Promise<GoogleAuthResult>;
|
|
53
|
-
export declare const googleLogout: () => Promise<void>;
|
|
58
|
+
export declare const googleAuth: (config: GoogleAuthConfig) => Promise<GoogleAuthResult | null>;
|
|
54
59
|
export type GoogleScope = "openid" | "email" | "profile" | "https://www.googleapis.com/auth/drive" | "https://www.googleapis.com/auth/drive.readonly" | "https://www.googleapis.com/auth/drive.file" | "https://www.googleapis.com/auth/drive.metadata.readonly" | "https://www.googleapis.com/auth/drive.appdata" | "https://www.googleapis.com/auth/calendar" | "https://www.googleapis.com/auth/calendar.readonly" | "https://www.googleapis.com/auth/calendar.events" | "https://www.googleapis.com/auth/calendar.events.readonly" | "https://www.googleapis.com/auth/gmail.readonly" | "https://www.googleapis.com/auth/gmail.modify" | "https://www.googleapis.com/auth/gmail.send" | "https://www.googleapis.com/auth/gmail.compose" | "https://www.googleapis.com/auth/gmail.labels" | "https://www.googleapis.com/auth/spreadsheets" | "https://www.googleapis.com/auth/spreadsheets.readonly" | "https://www.googleapis.com/auth/documents" | "https://www.googleapis.com/auth/documents.readonly" | "https://www.googleapis.com/auth/presentations" | "https://www.googleapis.com/auth/presentations.readonly" | "https://www.googleapis.com/auth/forms" | "https://www.googleapis.com/auth/forms.responses.readonly" | "https://www.googleapis.com/auth/youtube.readonly" | "https://www.googleapis.com/auth/youtube" | "https://www.googleapis.com/auth/youtube.upload" | "https://www.googleapis.com/auth/youtube.force-ssl" | "https://www.googleapis.com/auth/userinfo.email" | "https://www.googleapis.com/auth/userinfo.profile" | (string & {});
|
|
55
60
|
export interface GetAccessTokenConfig {
|
|
56
61
|
clientId: string;
|
|
@@ -78,50 +78,41 @@ export const googleAuth = async (config) => {
|
|
|
78
78
|
}
|
|
79
79
|
}); // end initialize
|
|
80
80
|
// show prompt
|
|
81
|
-
client.prompt()
|
|
81
|
+
client.prompt((notification) => {
|
|
82
|
+
if (notification.isNotDisplayed() || notification.isSkippedMoment()) {
|
|
83
|
+
resolve(null);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
82
86
|
}); // end result
|
|
83
87
|
};
|
|
84
88
|
// ---------- ---------- ---------- ---------- ----------
|
|
85
|
-
// googleLogout
|
|
86
|
-
// ---------- ---------- ---------- ---------- ----------
|
|
87
|
-
export const googleLogout = async () => {
|
|
88
|
-
const google = await getGoogle();
|
|
89
|
-
// 自動ログインを無効化
|
|
90
|
-
google.accounts.id.disableAutoSelect();
|
|
91
|
-
// セッション的なものをクリア(念のため)
|
|
92
|
-
google.accounts.id.cancel();
|
|
93
|
-
};
|
|
94
|
-
// ---------- ---------- ---------- ---------- ----------
|
|
95
89
|
// getAccessToken
|
|
96
90
|
// ---------- ---------- ---------- ---------- ----------
|
|
97
|
-
export const getAccessToken = (config) =>
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
scope: config.scope.join(" "),
|
|
111
|
-
callback: (response) => {
|
|
112
|
-
if (response.error) {
|
|
113
|
-
reject(response);
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
if (response.access_token) {
|
|
117
|
-
resolve(response.access_token);
|
|
91
|
+
export const getAccessToken = async (config) => {
|
|
92
|
+
const google = await getGoogle();
|
|
93
|
+
return new Promise((resolve, reject) => {
|
|
94
|
+
var _a;
|
|
95
|
+
// variable
|
|
96
|
+
const prompt = (_a = config.prompt) !== null && _a !== void 0 ? _a : "select_account";
|
|
97
|
+
// initialize
|
|
98
|
+
const tokenClient = google.accounts.oauth2.initTokenClient({
|
|
99
|
+
client_id: config.clientId,
|
|
100
|
+
scope: config.scope.join(" "),
|
|
101
|
+
callback: (response) => {
|
|
102
|
+
if (response.error) {
|
|
103
|
+
reject(response);
|
|
118
104
|
}
|
|
119
105
|
else {
|
|
120
|
-
|
|
106
|
+
if (response.access_token) {
|
|
107
|
+
resolve(response.access_token);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
reject(new Error("No access_token"));
|
|
111
|
+
}
|
|
121
112
|
}
|
|
122
113
|
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
114
|
+
}); // end initialize
|
|
115
|
+
// request AccessToken
|
|
116
|
+
tokenClient.requestAccessToken({ prompt }); // prompt == "none" のときには、事前にログインが必要
|
|
117
|
+
});
|
|
118
|
+
};
|