hyperapp-is 0.1.38 → 0.1.40
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.
|
@@ -12,5 +12,5 @@ export type { CarouselState, CarouselController } from "./animationView/carousel
|
|
|
12
12
|
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
|
-
export type { GoogleAccountsId, GoogleTokenClient, GoogleAccountsOAuth2, GoogleAccounts, Google, GoogleAuthConfig, GoogleUser, GoogleAuthResult, GoogleScope, GetAccessTokenConfig } from "./services/google";
|
|
16
|
-
export { getGoogle, getGoogleAuthResult, getAccessToken
|
|
15
|
+
export type { GoogleAccountsId, GoogleTokenClient, GoogleAccountsOAuth2, GoogleAccounts, Google, GoogleAuthConfig, GoogleUser, GoogleAuthResult, GoogleScope, GetAccessTokenConfig, GoogleAuth } from "./services/google";
|
|
16
|
+
export { getGoogle, getGoogleAuthResult, 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, getGoogleAuthResult, getAccessToken
|
|
10
|
+
export { getGoogle, getGoogleAuthResult, getAccessToken } from "./services/google";
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Dispatch, Effect } from "hyperapp";
|
|
2
1
|
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 & {});
|
|
3
2
|
export interface GoogleAccountsId {
|
|
4
3
|
initialize(config: {
|
|
@@ -75,16 +74,17 @@ export declare const getGoogle: () => Promise<Google>;
|
|
|
75
74
|
*/
|
|
76
75
|
export declare const getGoogleAuthResult: (idToken: string) => GoogleAuthResult;
|
|
77
76
|
export declare const getAccessToken: (config: GetAccessTokenConfig) => Promise<string>;
|
|
78
|
-
|
|
79
|
-
state: S;
|
|
80
|
-
config: GoogleAuthConfig;
|
|
77
|
+
interface GoogleButtonOptions {
|
|
81
78
|
renderButton?: HTMLElement;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
79
|
+
theme?: "outline" | "filled_blue" | "filled_black";
|
|
80
|
+
size?: "large" | "medium" | "small";
|
|
81
|
+
text?: "signin_with" | "signup_with" | "continue_with";
|
|
82
|
+
shape?: "rectangular" | "pill" | "circle" | "square";
|
|
83
|
+
}
|
|
84
|
+
export declare class GoogleAuth {
|
|
85
|
+
#private;
|
|
86
|
+
constructor(config: GoogleAuthConfig, options?: GoogleButtonOptions);
|
|
87
|
+
initialize(): Promise<GoogleAuthResult | null>;
|
|
88
|
+
logout(hint: string): void;
|
|
89
|
+
}
|
|
90
|
+
export {};
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
// ========== ========== ========== ========== ==========
|
|
2
2
|
// import
|
|
3
3
|
// ========== ========== ========== ========== ==========
|
|
4
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
5
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
6
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
7
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
8
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
9
|
+
};
|
|
10
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
11
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
12
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
13
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
14
|
+
};
|
|
15
|
+
var _GoogleAuth_config, _GoogleAuth_options, _GoogleAuth_google, _GoogleAuth_initialized;
|
|
4
16
|
// ========== ========== ========== ========== ==========
|
|
5
17
|
// procedure
|
|
6
18
|
// ========== ========== ========== ========== ==========
|
|
@@ -99,53 +111,68 @@ export const getAccessToken = async (config) => {
|
|
|
99
111
|
tokenClient.requestAccessToken({ prompt }); // prompt == "none" のときには、事前にログインが必要
|
|
100
112
|
});
|
|
101
113
|
};
|
|
102
|
-
|
|
103
|
-
//
|
|
104
|
-
|
|
105
|
-
//
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
114
|
+
export class GoogleAuth {
|
|
115
|
+
// constructor
|
|
116
|
+
constructor(config, options) {
|
|
117
|
+
// field
|
|
118
|
+
_GoogleAuth_config.set(this, void 0);
|
|
119
|
+
_GoogleAuth_options.set(this, void 0);
|
|
120
|
+
_GoogleAuth_google.set(this, void 0);
|
|
121
|
+
_GoogleAuth_initialized.set(this, void 0);
|
|
122
|
+
__classPrivateFieldSet(this, _GoogleAuth_config, config, "f");
|
|
123
|
+
__classPrivateFieldSet(this, _GoogleAuth_options, options !== null && options !== void 0 ? options : {}, "f");
|
|
124
|
+
__classPrivateFieldSet(this, _GoogleAuth_initialized, false, "f");
|
|
125
|
+
}
|
|
126
|
+
// method: initialize
|
|
127
|
+
async initialize() {
|
|
128
|
+
var _a, _b, _c, _d, _e;
|
|
129
|
+
if (__classPrivateFieldGet(this, _GoogleAuth_initialized, "f")) {
|
|
130
|
+
throw new Error("Already initialized");
|
|
118
131
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
132
|
+
__classPrivateFieldSet(this, _GoogleAuth_initialized, true, "f");
|
|
133
|
+
__classPrivateFieldSet(this, _GoogleAuth_google, await getGoogle(), "f");
|
|
134
|
+
const client = __classPrivateFieldGet(this, _GoogleAuth_google, "f").accounts.id;
|
|
135
|
+
if ((_a = __classPrivateFieldGet(this, _GoogleAuth_options, "f")) === null || _a === void 0 ? void 0 : _a.renderButton) {
|
|
136
|
+
client.renderButton(__classPrivateFieldGet(this, _GoogleAuth_options, "f").renderButton, {
|
|
137
|
+
theme: (_b = __classPrivateFieldGet(this, _GoogleAuth_options, "f").theme) !== null && _b !== void 0 ? _b : "outline",
|
|
138
|
+
size: (_c = __classPrivateFieldGet(this, _GoogleAuth_options, "f").size) !== null && _c !== void 0 ? _c : "medium",
|
|
139
|
+
text: (_d = __classPrivateFieldGet(this, _GoogleAuth_options, "f").text) !== null && _d !== void 0 ? _d : "signin_with",
|
|
140
|
+
shape: (_e = __classPrivateFieldGet(this, _GoogleAuth_options, "f").shape) !== null && _e !== void 0 ? _e : "rectangular",
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
return new Promise(resolve => {
|
|
144
|
+
var _a, _b;
|
|
145
|
+
let resolved = false;
|
|
146
|
+
const callback = (response) => {
|
|
147
|
+
if (resolved)
|
|
148
|
+
return;
|
|
149
|
+
resolved = true;
|
|
150
|
+
resolve(getGoogleAuthResult(response.credential));
|
|
151
|
+
};
|
|
152
|
+
client.initialize({
|
|
153
|
+
client_id: __classPrivateFieldGet(this, _GoogleAuth_config, "f").clientId,
|
|
154
|
+
auto_select: (_a = __classPrivateFieldGet(this, _GoogleAuth_config, "f").autoSelect) !== null && _a !== void 0 ? _a : true,
|
|
155
|
+
ux_mode: (_b = __classPrivateFieldGet(this, _GoogleAuth_config, "f").uxMode) !== null && _b !== void 0 ? _b : "popup",
|
|
156
|
+
callback
|
|
157
|
+
});
|
|
158
|
+
client.prompt((notification) => {
|
|
159
|
+
if (!resolved && (notification.isNotDisplayed() ||
|
|
160
|
+
notification.isSkippedMoment())) {
|
|
161
|
+
resolved = true;
|
|
162
|
+
resolve(null);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
138
165
|
});
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
getGoogle().then(google => {
|
|
146
|
-
const client = google.accounts.id;
|
|
166
|
+
}
|
|
167
|
+
// method: logout
|
|
168
|
+
logout(hint) {
|
|
169
|
+
if (!__classPrivateFieldGet(this, _GoogleAuth_google, "f"))
|
|
170
|
+
return;
|
|
171
|
+
const client = __classPrivateFieldGet(this, _GoogleAuth_google, "f").accounts.id;
|
|
147
172
|
client.disableAutoSelect();
|
|
148
173
|
client.cancel();
|
|
149
174
|
client.revoke(hint, () => { });
|
|
150
|
-
|
|
151
|
-
}
|
|
175
|
+
__classPrivateFieldSet(this, _GoogleAuth_initialized, false, "f");
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
_GoogleAuth_config = new WeakMap(), _GoogleAuth_options = new WeakMap(), _GoogleAuth_google = new WeakMap(), _GoogleAuth_initialized = new WeakMap();
|