hyperapp-is 0.1.36 → 0.1.37

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, getAccessToken } from "./services/google";
16
+ export { getGoogle, getGoogleAuthResult, 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, getAccessToken } from "./services/google";
10
+ export { getGoogle, getGoogleAuthResult, googleAuth, getAccessToken } from "./services/google";
@@ -55,6 +55,7 @@ export interface GoogleAuthResult {
55
55
  idToken: string;
56
56
  user: GoogleUser;
57
57
  }
58
+ export declare const getGoogleAuthResult: (idToken: string) => GoogleAuthResult;
58
59
  export declare const googleAuth: (config: GoogleAuthConfig) => Promise<GoogleAuthResult | null>;
59
60
  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 & {});
60
61
  export interface GetAccessTokenConfig {
@@ -35,6 +35,29 @@ export const getGoogle = async () => {
35
35
  return googlePromise;
36
36
  };
37
37
  // ---------- ---------- ---------- ---------- ----------
38
+ // getGoogleAuthResult
39
+ // ---------- ---------- ---------- ---------- ----------
40
+ export const getGoogleAuthResult = (idToken) => {
41
+ const base64 = idToken.split(".")[1]
42
+ .replace(/-/g, "+")
43
+ .replace(/_/g, "/");
44
+ const decode = (str) => decodeURIComponent(atob(str)
45
+ .split("")
46
+ .map(c => "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2))
47
+ .join(""));
48
+ const payload = JSON.parse(decode(base64));
49
+ const user = {
50
+ name: payload.name,
51
+ email: payload.email,
52
+ picture: payload.picture,
53
+ sub: payload.sub
54
+ };
55
+ return {
56
+ idToken,
57
+ user
58
+ };
59
+ };
60
+ // ---------- ---------- ---------- ---------- ----------
38
61
  // googleAuth
39
62
  // ---------- ---------- ---------- ---------- ----------
40
63
  export const googleAuth = async (config) => {
@@ -56,21 +79,7 @@ export const googleAuth = async (config) => {
56
79
  callback: (response) => {
57
80
  try {
58
81
  const idToken = response.credential;
59
- const base64 = idToken.split(".")[1]
60
- .replace(/-/g, "+")
61
- .replace(/_/g, "/");
62
- const decode = (str) => decodeURIComponent(atob(str)
63
- .split("")
64
- .map(c => "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2))
65
- .join(""));
66
- const payload = JSON.parse(decode(base64));
67
- const user = {
68
- name: payload.name,
69
- email: payload.email,
70
- picture: payload.picture,
71
- sub: payload.sub
72
- };
73
- resolve({ idToken, user });
82
+ resolve(getGoogleAuthResult(idToken));
74
83
  }
75
84
  catch (error) {
76
85
  reject(error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperapp-is",
3
- "version": "0.1.36",
3
+ "version": "0.1.37",
4
4
  "description": "UI foundation library for Hyperapp by is4416",
5
5
  "license": "MIT",
6
6
  "type": "module",