@gasboost/auth 0.2.1 → 0.3.0
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 +0 -54
- package/dist/AppsScriptAuth.d.ts +3 -16
- package/dist/AppsScriptAuth.js +4 -24
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -526,60 +526,6 @@ const pepper =
|
|
|
526
526
|
PropertiesService.getScriptProperties().getProperty("AUTH_PEPPER");
|
|
527
527
|
```
|
|
528
528
|
|
|
529
|
-
## `@gasboost/app` との連携
|
|
530
|
-
|
|
531
|
-
`AppsScriptAuth` は、RPC 登録用の handler collection を `auth.handlers` として公開します。
|
|
532
|
-
|
|
533
|
-
`@gasboost/app` の `.calls()` にそのまま渡すことで、認証用 RPC を一括登録できます。
|
|
534
|
-
|
|
535
|
-
```ts
|
|
536
|
-
import { AppsScript } from "@gasboost/app";
|
|
537
|
-
import { AppsScriptAuth } from "@gasboost/auth";
|
|
538
|
-
|
|
539
|
-
const auth = new AppsScriptAuth({
|
|
540
|
-
repository,
|
|
541
|
-
runtime,
|
|
542
|
-
session: {
|
|
543
|
-
storageType: "cache",
|
|
544
|
-
},
|
|
545
|
-
emailPassword: {
|
|
546
|
-
enabled: true,
|
|
547
|
-
pepper: "your-secret-pepper",
|
|
548
|
-
},
|
|
549
|
-
appsScript: {
|
|
550
|
-
enabled: true,
|
|
551
|
-
},
|
|
552
|
-
});
|
|
553
|
-
|
|
554
|
-
const app = new AppsScript().calls(auth.handlers);
|
|
555
|
-
|
|
556
|
-
export default app;
|
|
557
|
-
```
|
|
558
|
-
|
|
559
|
-
以下の RPC が登録されます。
|
|
560
|
-
|
|
561
|
-
- `signInEmail`
|
|
562
|
-
- `signInAppsScript`
|
|
563
|
-
- `signUpEmail`
|
|
564
|
-
- `signUpAppsScript`
|
|
565
|
-
- `getSession`
|
|
566
|
-
- `signOut`
|
|
567
|
-
|
|
568
|
-
`InferAppsScript` を利用するクライアントでは、これらの RPC がそのまま型推論されます。
|
|
569
|
-
|
|
570
|
-
```ts
|
|
571
|
-
client.signInEmail({
|
|
572
|
-
email: "user@example.com",
|
|
573
|
-
password: "password",
|
|
574
|
-
});
|
|
575
|
-
|
|
576
|
-
client.getSession("session-id");
|
|
577
|
-
|
|
578
|
-
client.signOut("session-id");
|
|
579
|
-
```
|
|
580
|
-
|
|
581
|
-
RPC endpoint 名は `@gasboost/auth` 側で管理されるため、利用側で個別に `.call()` を記述したり、endpoint 名を重複定義したりする必要はありません。
|
|
582
|
-
|
|
583
529
|
## Testing
|
|
584
530
|
|
|
585
531
|
GAS API を利用するテストでは `gasboost/fake` を使用できます。
|
package/dist/AppsScriptAuth.d.ts
CHANGED
|
@@ -26,28 +26,15 @@ type AppsScriptAuthConfig<TEmailPassword extends EmailPasswordAuthOptions | unde
|
|
|
26
26
|
appsScript?: AppsScriptAuthenticationOptions;
|
|
27
27
|
hooks?: AuthHooks<THookResult>;
|
|
28
28
|
};
|
|
29
|
-
type
|
|
30
|
-
signInEmail: AppsScriptAuthSignIn<THookResult>["email"];
|
|
31
|
-
signInAppsScript: AppsScriptAuthSignIn<THookResult>["appsScript"];
|
|
32
|
-
signUpEmail: AppsScriptAuthSignUp["email"];
|
|
33
|
-
signUpAppsScript: AppsScriptAuthSignUp["appsScript"];
|
|
34
|
-
getSession: AppsScriptAuthSession["get"];
|
|
35
|
-
signOut: AppsScriptAuthSignOut["execute"];
|
|
36
|
-
};
|
|
37
|
-
type PasswordHandlers = {
|
|
38
|
-
forgotPassword: AppsScriptAuthPassword["forgot"];
|
|
39
|
-
resetPassword: AppsScriptAuthPassword["reset"];
|
|
40
|
-
};
|
|
41
|
-
type AppsScriptAuthHandlers<TEmailPassword, THookResult> = TEmailPassword extends {
|
|
29
|
+
type AppsScriptAuthPasswordApi<TEmailPassword> = TEmailPassword extends {
|
|
42
30
|
passwordReset: unknown;
|
|
43
|
-
} ?
|
|
31
|
+
} ? AppsScriptAuthPassword : undefined;
|
|
44
32
|
export declare class AppsScriptAuth<TEmailPassword extends EmailPasswordAuthOptions | undefined = undefined, THookResult = undefined> {
|
|
45
33
|
readonly signIn: AppsScriptAuthSignIn<THookResult>;
|
|
46
34
|
readonly signUp: AppsScriptAuthSignUp;
|
|
47
35
|
readonly session: AppsScriptAuthSession;
|
|
48
36
|
readonly signOut: AppsScriptAuthSignOut;
|
|
49
|
-
readonly password:
|
|
37
|
+
readonly password: AppsScriptAuthPasswordApi<TEmailPassword>;
|
|
50
38
|
constructor({ repository, session, runtime, emailPassword, appsScript, hooks, }: AppsScriptAuthConfig<TEmailPassword, THookResult>);
|
|
51
|
-
get handlers(): AppsScriptAuthHandlers<TEmailPassword, THookResult>;
|
|
52
39
|
}
|
|
53
40
|
export {};
|
package/dist/AppsScriptAuth.js
CHANGED
|
@@ -51,32 +51,12 @@ export class AppsScriptAuth {
|
|
|
51
51
|
sessionStorage,
|
|
52
52
|
});
|
|
53
53
|
this.signOut = new AppsScriptAuthSignOut(sessionStorage);
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
this.password = (emailPasswordConfig?.passwordReset
|
|
55
|
+
? new AppsScriptAuthPassword({
|
|
56
56
|
repository,
|
|
57
57
|
utilities: runtime.utilities,
|
|
58
58
|
emailPassword: emailPasswordConfig,
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
else {
|
|
62
|
-
this.password = undefined;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
get handlers() {
|
|
66
|
-
const handlers = {
|
|
67
|
-
signInEmail: this.signIn.email,
|
|
68
|
-
signInAppsScript: this.signIn.appsScript,
|
|
69
|
-
signUpEmail: this.signUp.email,
|
|
70
|
-
signUpAppsScript: this.signUp.appsScript,
|
|
71
|
-
getSession: this.session.get.bind(this.session),
|
|
72
|
-
signOut: this.signOut.execute.bind(this.signOut),
|
|
73
|
-
...(this.password
|
|
74
|
-
? {
|
|
75
|
-
forgotPassword: this.password.forgot.bind(this.password),
|
|
76
|
-
resetPassword: this.password.reset.bind(this.password),
|
|
77
|
-
}
|
|
78
|
-
: {}),
|
|
79
|
-
};
|
|
80
|
-
return handlers;
|
|
59
|
+
})
|
|
60
|
+
: undefined);
|
|
81
61
|
}
|
|
82
62
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gasboost/auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Modern authentication for Google Apps Script with email/password, Apps Script authentication, sessions, and password reset.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"google-apps-script",
|
|
@@ -39,7 +39,6 @@
|
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@gasboost/app": "^1.3.0",
|
|
43
42
|
"@gasboost/fake-core": "^0.1.2",
|
|
44
43
|
"@gasboost/fake-node": "^0.1.2",
|
|
45
44
|
"@types/google-apps-script": "^2.0.13"
|