hyperapp-is 0.1.40 → 0.1.42

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.
package/README.md CHANGED
@@ -206,8 +206,9 @@ npm で非公開の関数 (実験用)は、解説に記載します
206
206
 
207
207
  **services / google**
208
208
  - [getGoogle](#getgoogle)
209
- - [googleAuth](#googleauth)
209
+ - [getGoogleAuthResult](#getgoogleauthresult)
210
210
  - [getAccessToken](#getaccesstoken)
211
+ - [GoogleAuth](#googleauth)
211
212
 
212
213
  ## source file / ソースファイル
213
214
 
@@ -1601,29 +1602,15 @@ export const getGoogle = async (): Promise<Google>
1601
1602
 
1602
1603
  ---
1603
1604
 
1604
- ### googleAuth
1605
- グーグル認証を行い `{ idToken: string, user: GoogleUser }` を取得します
1605
+ ### getGoogleAuthResult
1606
+ ユーザートークンから、ユーザー情報を取得する
1606
1607
 
1607
1608
  ```ts
1608
- export const googleAuth = async (config: GoogleAuthConfig): Promise<GoogleAuthResult> =>
1609
- ```
1610
-
1611
- ```ts
1612
- export interface GoogleAuthConfig {
1613
- clientId : string
1614
- autoSelect?: boolean // default: true
1615
- uxMode ?: "popup" | "redirect" // default: "popup"
1616
- }
1617
- ```
1618
-
1619
- - clientId : アプリケーションのID (https://console.cloud.google.com で作成)
1620
- - autoSelect?: ユーザーが選択されていた場合、自動でログイン
1621
- - uxMode ?: ポップアップ、もしくはリダイレクトでログインします
1622
-
1609
+ export const getGoogleAuthResult = (idToken: string): GoogleAuthResult
1623
1610
  ---
1624
1611
 
1625
1612
  ### getAccessToken
1626
- Googleのaccess token を取得
1613
+ Googleのaccess token を取得
1627
1614
 
1628
1615
  ```ts
1629
1616
  export const getAccessToken = (config: GetAccessTokenConfig): Promise<string>
@@ -1640,3 +1627,52 @@ export interface GetAccessTokenConfig {
1640
1627
  - clientId: アプリケーションのID
1641
1628
  - scope : スコープの配列
1642
1629
  - prompt ?: ログイン制御 `none` の場合、先にログインしていなければエラーとなります
1630
+
1631
+ ---
1632
+
1633
+ ### GoogleAuth
1634
+ Google 認証をラップしたクラス
1635
+
1636
+ ```ts
1637
+ interface GoogleAuthConfig {
1638
+ clientId : string
1639
+ autoSelect?: boolean // default: true
1640
+ uxMode ?: "popup" | "redirect" // default: "popup"
1641
+ }
1642
+
1643
+ interface GoogleButtonOptions {
1644
+ renderButton?: HTMLElement
1645
+ theme ?: "outline" | "filled_blue" | "filled_black" // default: outline
1646
+ size ?: "large" | "medium" | "small" // default: medium
1647
+ text ?: "signin_with" | "signup_with" | "continue_with" // default: signin_with
1648
+ shape ?: "rectangular" | "pill" | "circle" | "square" // default: rectangular
1649
+ }
1650
+
1651
+ interface GoogleAuthResult {
1652
+ idToken: string
1653
+ user : GoogleUser
1654
+ }
1655
+
1656
+ interface GoogleUser {
1657
+ name : string
1658
+ email : string
1659
+ picture: string
1660
+ sub : string
1661
+ }
1662
+ ```
1663
+
1664
+ ```ts
1665
+ class GoogleAuth {
1666
+ constructor (config: GoogleAuthConfig, option?: GoogleButtonOptions)
1667
+ async initialize(): Promise<GoogleAuthResult | null>
1668
+ logout (hit: string): void
1669
+ }
1670
+ ```
1671
+
1672
+ *MEMO*
1673
+ 必ず一度だけ `initialize` を実行します
1674
+ プロンプトがスキップされた場合 `null` が返ります
1675
+ `logout` を実行したあとであれば `initialize` を再実行することが可能です
1676
+ `logout` 前に 2度 `initialize` を実行した場合は、エラーが発生します
1677
+ `logout` の `hit` は `email' か 'sub` を指定する必要があります
1678
+
@@ -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, GoogleAuth } from "./services/google";
16
- export { getGoogle, getGoogleAuthResult, getAccessToken } from "./services/google";
15
+ export type { GoogleAccountsId, GoogleTokenClient, GoogleAccountsOAuth2, GoogleAccounts, Google, GoogleAuthConfig, GoogleUser, GoogleAuthResult, GoogleScope, GetAccessTokenConfig } from "./services/google";
16
+ export { getGoogle, getGoogleAuthResult, getAccessToken, GoogleAuth } 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 } from "./services/google";
10
+ export { getGoogle, getGoogleAuthResult, getAccessToken, GoogleAuth } from "./services/google";
@@ -125,23 +125,14 @@ export class GoogleAuth {
125
125
  }
126
126
  // method: initialize
127
127
  async initialize() {
128
- var _a, _b, _c, _d, _e;
129
128
  if (__classPrivateFieldGet(this, _GoogleAuth_initialized, "f")) {
130
129
  throw new Error("Already initialized");
131
130
  }
132
- __classPrivateFieldSet(this, _GoogleAuth_initialized, true, "f");
133
131
  __classPrivateFieldSet(this, _GoogleAuth_google, await getGoogle(), "f");
132
+ __classPrivateFieldSet(this, _GoogleAuth_initialized, true, "f");
134
133
  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
134
  return new Promise(resolve => {
144
- var _a, _b;
135
+ var _a, _b, _c, _d, _e, _f, _g;
145
136
  let resolved = false;
146
137
  const callback = (response) => {
147
138
  if (resolved)
@@ -155,6 +146,14 @@ export class GoogleAuth {
155
146
  ux_mode: (_b = __classPrivateFieldGet(this, _GoogleAuth_config, "f").uxMode) !== null && _b !== void 0 ? _b : "popup",
156
147
  callback
157
148
  });
149
+ if ((_c = __classPrivateFieldGet(this, _GoogleAuth_options, "f")) === null || _c === void 0 ? void 0 : _c.renderButton) {
150
+ client.renderButton(__classPrivateFieldGet(this, _GoogleAuth_options, "f").renderButton, {
151
+ theme: (_d = __classPrivateFieldGet(this, _GoogleAuth_options, "f").theme) !== null && _d !== void 0 ? _d : "outline",
152
+ size: (_e = __classPrivateFieldGet(this, _GoogleAuth_options, "f").size) !== null && _e !== void 0 ? _e : "medium",
153
+ text: (_f = __classPrivateFieldGet(this, _GoogleAuth_options, "f").text) !== null && _f !== void 0 ? _f : "signin_with",
154
+ shape: (_g = __classPrivateFieldGet(this, _GoogleAuth_options, "f").shape) !== null && _g !== void 0 ? _g : "rectangular",
155
+ });
156
+ }
158
157
  client.prompt((notification) => {
159
158
  if (!resolved && (notification.isNotDisplayed() ||
160
159
  notification.isSkippedMoment())) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperapp-is",
3
- "version": "0.1.40",
3
+ "version": "0.1.42",
4
4
  "description": "UI foundation library for Hyperapp by is4416",
5
5
  "license": "MIT",
6
6
  "type": "module",