sst 3.0.36 → 3.0.38
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/bin/sst.mjs +28 -0
- package/dist/aws/client.js +3 -2
- package/dist/aws/realtime.d.ts +16 -10
- package/dist/aws/realtime.js +12 -6
- package/dist/resource.js +8 -1
- package/dist/vector/index.d.ts +81 -36
- package/dist/vector/index.js +9 -3
- package/package.json +23 -12
- package/dist/src/auth/adapter/adapter.d.ts +0 -24
- package/dist/src/auth/adapter/adapter.js +0 -4
- package/dist/src/auth/adapter/apple.d.ts +0 -5
- package/dist/src/auth/adapter/apple.js +0 -22
- package/dist/src/auth/adapter/code.d.ts +0 -8
- package/dist/src/auth/adapter/code.js +0 -47
- package/dist/src/auth/adapter/facebook.d.ts +0 -5
- package/dist/src/auth/adapter/facebook.js +0 -27
- package/dist/src/auth/adapter/github.d.ts +0 -12
- package/dist/src/auth/adapter/github.js +0 -23
- package/dist/src/auth/adapter/google.d.ts +0 -17
- package/dist/src/auth/adapter/google.js +0 -22
- package/dist/src/auth/adapter/index.d.ts +0 -11
- package/dist/src/auth/adapter/index.js +0 -10
- package/dist/src/auth/adapter/link.d.ts +0 -6
- package/dist/src/auth/adapter/link.js +0 -27
- package/dist/src/auth/adapter/microsoft.d.ts +0 -11
- package/dist/src/auth/adapter/microsoft.js +0 -16
- package/dist/src/auth/adapter/oauth.d.ts +0 -33
- package/dist/src/auth/adapter/oauth.js +0 -79
- package/dist/src/auth/adapter/oidc.d.ts +0 -19
- package/dist/src/auth/adapter/oidc.js +0 -45
- package/dist/src/auth/adapter/spotify.d.ts +0 -12
- package/dist/src/auth/adapter/spotify.js +0 -22
- package/dist/src/auth/example/bun.d.ts +0 -2
- package/dist/src/auth/example/bun.js +0 -46
- package/dist/src/auth/handler.d.ts +0 -58
- package/dist/src/auth/handler.js +0 -207
- package/dist/src/auth/index.d.ts +0 -10
- package/dist/src/auth/index.js +0 -10
- package/dist/src/auth/session.d.ts +0 -25
- package/dist/src/auth/session.js +0 -28
- package/dist/src/aws/bus.d.ts +0 -29
- package/dist/src/aws/bus.js +0 -67
- package/dist/src/aws/client.d.ts +0 -3
- package/dist/src/aws/client.js +0 -7
- package/dist/src/aws/realtime.d.ts +0 -61
- package/dist/src/aws/realtime.js +0 -76
- package/dist/src/event/index.d.ts +0 -74
- package/dist/src/event/index.js +0 -41
- package/dist/src/index.d.ts +0 -3
- package/dist/src/index.js +0 -3
- package/dist/src/realtime/index.d.ts +0 -25
- package/dist/src/realtime/index.js +0 -24
- package/dist/src/resource.d.ts +0 -9
- package/dist/src/resource.js +0 -50
- package/dist/src/util/prettify.d.ts +0 -3
- package/dist/src/util/prettify.js +0 -1
- package/dist/src/vector/index.d.ts +0 -193
- package/dist/src/vector/index.js +0 -62
- package/dist/test/event.test.d.ts +0 -1
- package/dist/test/event.test.js +0 -6
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Issuer } from "openid-client";
|
|
2
|
-
import { OauthAdapter } from "./oauth.js";
|
|
3
|
-
import { OidcAdapter } from "./oidc.js";
|
|
4
|
-
const issuer = new Issuer({
|
|
5
|
-
issuer: "https://github.com",
|
|
6
|
-
authorization_endpoint: "https://github.com/login/oauth/authorize",
|
|
7
|
-
token_endpoint: "https://github.com/login/oauth/access_token",
|
|
8
|
-
});
|
|
9
|
-
export const GithubAdapter =
|
|
10
|
-
/* @__PURE__ */
|
|
11
|
-
(config) => {
|
|
12
|
-
if (config.mode === "oauth") {
|
|
13
|
-
return OauthAdapter({
|
|
14
|
-
issuer,
|
|
15
|
-
...config,
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
return OidcAdapter({
|
|
19
|
-
issuer,
|
|
20
|
-
scope: "openid email profile",
|
|
21
|
-
...config,
|
|
22
|
-
});
|
|
23
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { OidcBasicConfig } from "./oidc.js";
|
|
2
|
-
import { OauthBasicConfig } from "./oauth.js";
|
|
3
|
-
type GooglePrompt = "none" | "consent" | "select_account";
|
|
4
|
-
type GoogleAccessType = "offline" | "online";
|
|
5
|
-
type GoogleConfig = (OauthBasicConfig & {
|
|
6
|
-
mode: "oauth";
|
|
7
|
-
prompt?: GooglePrompt;
|
|
8
|
-
accessType?: GoogleAccessType;
|
|
9
|
-
}) | (OidcBasicConfig & {
|
|
10
|
-
mode: "oidc";
|
|
11
|
-
prompt?: GooglePrompt;
|
|
12
|
-
});
|
|
13
|
-
export declare function GoogleAdapter(config: GoogleConfig): (routes: import("./adapter.js").AdapterRoute, ctx: import("./adapter.js").AdapterOptions<{
|
|
14
|
-
tokenset: import("openid-client").TokenSet;
|
|
15
|
-
client: import("openid-client").BaseClient;
|
|
16
|
-
}>) => Promise<void>;
|
|
17
|
-
export {};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Issuer } from "openid-client";
|
|
2
|
-
import { OidcAdapter } from "./oidc.js";
|
|
3
|
-
import { OauthAdapter } from "./oauth.js";
|
|
4
|
-
const issuer = await Issuer.discover("https://accounts.google.com");
|
|
5
|
-
export function GoogleAdapter(config) {
|
|
6
|
-
/* @__PURE__ */
|
|
7
|
-
if (config.mode === "oauth") {
|
|
8
|
-
return OauthAdapter({
|
|
9
|
-
issuer,
|
|
10
|
-
...config,
|
|
11
|
-
params: {
|
|
12
|
-
...(config.accessType && { access_type: config.accessType }),
|
|
13
|
-
...config.params,
|
|
14
|
-
},
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
return OidcAdapter({
|
|
18
|
-
issuer,
|
|
19
|
-
scope: "openid email profile",
|
|
20
|
-
...config,
|
|
21
|
-
});
|
|
22
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export * from "./oidc.js";
|
|
2
|
-
export * from "./google.js";
|
|
3
|
-
export * from "./link.js";
|
|
4
|
-
export * from "./github.js";
|
|
5
|
-
export * from "./facebook.js";
|
|
6
|
-
export * from "./microsoft.js";
|
|
7
|
-
export * from "./oauth.js";
|
|
8
|
-
export * from "./spotify.js";
|
|
9
|
-
export * from "./code.js";
|
|
10
|
-
export * from "./apple.js";
|
|
11
|
-
export type { Adapter } from "./adapter.js";
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from "./oidc.js";
|
|
2
|
-
export * from "./google.js";
|
|
3
|
-
export * from "./link.js";
|
|
4
|
-
export * from "./github.js";
|
|
5
|
-
export * from "./facebook.js";
|
|
6
|
-
export * from "./microsoft.js";
|
|
7
|
-
export * from "./oauth.js";
|
|
8
|
-
export * from "./spotify.js";
|
|
9
|
-
export * from "./code.js";
|
|
10
|
-
export * from "./apple.js";
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
export declare function LinkAdapter(config: {
|
|
3
|
-
onLink: (link: string, claims: Record<string, any>) => Promise<Response>;
|
|
4
|
-
}): (routes: import("./adapter.js").AdapterRoute, ctx: import("./adapter.js").AdapterOptions<{
|
|
5
|
-
claims: Record<string, string>;
|
|
6
|
-
}>) => void;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { SignJWT, jwtVerify } from "jose";
|
|
2
|
-
export function LinkAdapter(config) {
|
|
3
|
-
return function (routes, ctx) {
|
|
4
|
-
routes.get("/authorize", async (c) => {
|
|
5
|
-
const token = await new SignJWT(c.req.query())
|
|
6
|
-
.setProtectedHeader({ alg: ctx.algorithm })
|
|
7
|
-
.setExpirationTime("10m")
|
|
8
|
-
.sign(await ctx.signing.privateKey());
|
|
9
|
-
const url = new URL(new URL(c.req.url).origin);
|
|
10
|
-
url.pathname = `/${ctx.name}/callback`;
|
|
11
|
-
for (const key of url.searchParams.keys()) {
|
|
12
|
-
url.searchParams.delete(key);
|
|
13
|
-
}
|
|
14
|
-
url.searchParams.set("token", token);
|
|
15
|
-
const resp = ctx.forward(c, await config.onLink(url.toString(), c.req.query()));
|
|
16
|
-
return resp;
|
|
17
|
-
});
|
|
18
|
-
routes.get("/callback", async (c) => {
|
|
19
|
-
const token = c.req.query("token");
|
|
20
|
-
if (!token)
|
|
21
|
-
throw new Error("Missing token parameter");
|
|
22
|
-
const verified = await jwtVerify(token, await ctx.signing.publicKey());
|
|
23
|
-
const resp = await ctx.success(c, { claims: verified.payload });
|
|
24
|
-
return resp;
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { OidcBasicConfig } from "./oidc.js";
|
|
2
|
-
type MicrosoftConfig = OidcBasicConfig & {
|
|
3
|
-
mode: "oidc";
|
|
4
|
-
prompt?: "login" | "none" | "consent" | "select_account";
|
|
5
|
-
tenantID?: string;
|
|
6
|
-
};
|
|
7
|
-
export declare function MicrosoftAdapter(config: MicrosoftConfig): (routes: import("./adapter.js").AdapterRoute, ctx: import("./adapter.js").AdapterOptions<{
|
|
8
|
-
tokenset: import("openid-client").TokenSet;
|
|
9
|
-
client: import("openid-client").BaseClient;
|
|
10
|
-
}>) => Promise<void>;
|
|
11
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Issuer } from "openid-client";
|
|
2
|
-
import { OidcAdapter } from "./oidc.js";
|
|
3
|
-
export function MicrosoftAdapter(config) {
|
|
4
|
-
const authority = config?.tenantID ?? "common";
|
|
5
|
-
const issuer = `https://login.microsoftonline.com/${authority}`;
|
|
6
|
-
return OidcAdapter({
|
|
7
|
-
issuer: new Issuer({
|
|
8
|
-
issuer: `${issuer}/v2.0`,
|
|
9
|
-
authorization_endpoint: `${issuer}/oauth2/v2.0/authorize`,
|
|
10
|
-
token_endpoint: `${issuer}/oauth2/v2.0/token`,
|
|
11
|
-
jwks_uri: `${issuer}/discovery/v2.0/keys`,
|
|
12
|
-
}),
|
|
13
|
-
scope: "openid email profile",
|
|
14
|
-
...config,
|
|
15
|
-
});
|
|
16
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { BaseClient, Issuer, TokenSet } from "openid-client";
|
|
2
|
-
import { AdapterError } from "./adapter.js";
|
|
3
|
-
export interface OauthBasicConfig {
|
|
4
|
-
/**
|
|
5
|
-
* The clientID provided by the third party oauth service
|
|
6
|
-
*/
|
|
7
|
-
clientID: string;
|
|
8
|
-
/**
|
|
9
|
-
* The clientSecret provided by the third party oauth service
|
|
10
|
-
*/
|
|
11
|
-
clientSecret: string;
|
|
12
|
-
/**
|
|
13
|
-
* Various scopes requested for the access token
|
|
14
|
-
*/
|
|
15
|
-
scope: string;
|
|
16
|
-
/**
|
|
17
|
-
* Determines whether users will be prompted for reauthentication and consent
|
|
18
|
-
*/
|
|
19
|
-
prompt?: string;
|
|
20
|
-
/**
|
|
21
|
-
* Additional parameters to be passed to the authorization endpoint
|
|
22
|
-
*/
|
|
23
|
-
params?: Record<string, string>;
|
|
24
|
-
}
|
|
25
|
-
export interface OauthConfig extends OauthBasicConfig {
|
|
26
|
-
issuer: Issuer;
|
|
27
|
-
}
|
|
28
|
-
export declare class OauthError extends AdapterError {
|
|
29
|
-
}
|
|
30
|
-
export declare const OauthAdapter: (config: OauthConfig) => (routes: import("./adapter.js").AdapterRoute, ctx: import("./adapter.js").AdapterOptions<{
|
|
31
|
-
tokenset: TokenSet;
|
|
32
|
-
client: BaseClient;
|
|
33
|
-
}>) => Promise<void>;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { generators } from "openid-client";
|
|
2
|
-
import { AdapterError } from "./adapter.js";
|
|
3
|
-
import { getCookie } from "hono/cookie";
|
|
4
|
-
export class OauthError extends AdapterError {
|
|
5
|
-
}
|
|
6
|
-
export const OauthAdapter =
|
|
7
|
-
/* @__PURE__ */
|
|
8
|
-
(config) => {
|
|
9
|
-
return async function (routes, ctx) {
|
|
10
|
-
function getClient(c) {
|
|
11
|
-
const callback = c.req.url.replace(/authorize\/.*$/, "callback");
|
|
12
|
-
return [
|
|
13
|
-
callback,
|
|
14
|
-
new config.issuer.Client({
|
|
15
|
-
client_id: config.clientID,
|
|
16
|
-
client_secret: config.clientSecret,
|
|
17
|
-
redirect_uris: [callback],
|
|
18
|
-
response_types: ["code"],
|
|
19
|
-
}),
|
|
20
|
-
];
|
|
21
|
-
}
|
|
22
|
-
routes.get("/authorize", async (c) => {
|
|
23
|
-
const [_, client] = getClient(c);
|
|
24
|
-
const code_verifier = generators.codeVerifier();
|
|
25
|
-
const state = generators.state();
|
|
26
|
-
const code_challenge = generators.codeChallenge(code_verifier);
|
|
27
|
-
const url = client.authorizationUrl({
|
|
28
|
-
scope: config.scope,
|
|
29
|
-
code_challenge: code_challenge,
|
|
30
|
-
code_challenge_method: "S256",
|
|
31
|
-
state,
|
|
32
|
-
prompt: config.prompt,
|
|
33
|
-
...config.params,
|
|
34
|
-
});
|
|
35
|
-
ctx.cookie(c, "auth_code_verifier", code_verifier, 60 * 10);
|
|
36
|
-
ctx.cookie(c, "auth_state", state, 60 * 10);
|
|
37
|
-
return c.redirect(url);
|
|
38
|
-
});
|
|
39
|
-
routes.get("/callback", async (c) => {
|
|
40
|
-
const [callback, client] = getClient(c);
|
|
41
|
-
const query = c.req.query();
|
|
42
|
-
if (query.error) {
|
|
43
|
-
throw new OauthError(query.error);
|
|
44
|
-
}
|
|
45
|
-
const code_verifier = getCookie(c, "auth_code_verifier");
|
|
46
|
-
const state = getCookie(c, "auth_state");
|
|
47
|
-
const tokenset = await client[config.issuer.metadata.userinfo_endpoint
|
|
48
|
-
? "callback"
|
|
49
|
-
: "oauthCallback"](callback, query, {
|
|
50
|
-
code_verifier,
|
|
51
|
-
state,
|
|
52
|
-
});
|
|
53
|
-
return ctx.success(c, {
|
|
54
|
-
client,
|
|
55
|
-
tokenset,
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
// response_mode=form_post
|
|
59
|
-
routes.get("/callback", async (c) => {
|
|
60
|
-
const [callback, client] = getClient(c);
|
|
61
|
-
const form = await c.req.formData();
|
|
62
|
-
if (form.get("error")) {
|
|
63
|
-
throw new OauthError(form.get("error").toString());
|
|
64
|
-
}
|
|
65
|
-
const code_verifier = getCookie(c, "auth_code_verifier");
|
|
66
|
-
const state = getCookie(c, "auth_state");
|
|
67
|
-
const tokenset = await client[config.issuer.metadata.userinfo_endpoint
|
|
68
|
-
? "callback"
|
|
69
|
-
: "oauthCallback"](callback, Object.fromEntries(form), {
|
|
70
|
-
code_verifier,
|
|
71
|
-
state,
|
|
72
|
-
});
|
|
73
|
-
return ctx.success(c, {
|
|
74
|
-
client,
|
|
75
|
-
tokenset,
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { BaseClient, Issuer, TokenSet } from "openid-client";
|
|
2
|
-
export interface OidcBasicConfig {
|
|
3
|
-
/**
|
|
4
|
-
* The clientID provided by the third party oauth service
|
|
5
|
-
*/
|
|
6
|
-
clientID: string;
|
|
7
|
-
/**
|
|
8
|
-
* Determines whether users will be prompted for reauthentication and consent
|
|
9
|
-
*/
|
|
10
|
-
prompt?: string;
|
|
11
|
-
}
|
|
12
|
-
export interface OidcConfig extends OidcBasicConfig {
|
|
13
|
-
issuer: Issuer;
|
|
14
|
-
scope: string;
|
|
15
|
-
}
|
|
16
|
-
export declare const OidcAdapter: (config: OidcConfig) => (routes: import("./adapter.js").AdapterRoute, ctx: import("./adapter.js").AdapterOptions<{
|
|
17
|
-
tokenset: TokenSet;
|
|
18
|
-
client: BaseClient;
|
|
19
|
-
}>) => Promise<void>;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { generators } from "openid-client";
|
|
2
|
-
import { getCookie } from "hono/cookie";
|
|
3
|
-
export const OidcAdapter = /* @__PURE__ */ (config) => {
|
|
4
|
-
return async function (routes, ctx) {
|
|
5
|
-
routes.get("/authorize", async (c) => {
|
|
6
|
-
const callback = c.req.url.replace(/authorize\/.*$/, "callback");
|
|
7
|
-
const client = new config.issuer.Client({
|
|
8
|
-
client_id: config.clientID,
|
|
9
|
-
redirect_uris: [callback],
|
|
10
|
-
response_types: ["id_token"],
|
|
11
|
-
});
|
|
12
|
-
const nonce = generators.nonce();
|
|
13
|
-
const state = generators.state();
|
|
14
|
-
const url = client.authorizationUrl({
|
|
15
|
-
scope: config.scope,
|
|
16
|
-
response_mode: "form_post",
|
|
17
|
-
nonce,
|
|
18
|
-
state,
|
|
19
|
-
prompt: config.prompt,
|
|
20
|
-
});
|
|
21
|
-
ctx.cookie(c, "auth_nonce", nonce, 60 * 10);
|
|
22
|
-
ctx.cookie(c, "auth_state", state, 60 * 10);
|
|
23
|
-
return c.redirect(url);
|
|
24
|
-
});
|
|
25
|
-
routes.post("/callback", async (c) => {
|
|
26
|
-
const callback = c.req.url.replace(/authorize\/.*$/, "callback");
|
|
27
|
-
const client = new config.issuer.Client({
|
|
28
|
-
client_id: config.clientID,
|
|
29
|
-
redirect_uris: [callback],
|
|
30
|
-
response_types: ["id_token"],
|
|
31
|
-
});
|
|
32
|
-
const form = await c.req.formData();
|
|
33
|
-
const nonce = getCookie(c, "auth_nonce");
|
|
34
|
-
const state = getCookie(c, "auth_state");
|
|
35
|
-
const tokenset = await client.callback(callback, Object.fromEntries(form), {
|
|
36
|
-
nonce,
|
|
37
|
-
state,
|
|
38
|
-
});
|
|
39
|
-
return ctx.success(c, {
|
|
40
|
-
tokenset,
|
|
41
|
-
client,
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { OauthBasicConfig } from "./oauth.js";
|
|
2
|
-
/**
|
|
3
|
-
* The Spotify Adapter follows the PKCE flow outlined here:
|
|
4
|
-
* https://developer.spotify.com/documentation/web-api/tutorials/code-pkce-flow
|
|
5
|
-
*
|
|
6
|
-
* List of scopes available:
|
|
7
|
-
* https://developer.spotify.com/documentation/web-api/concepts/scopes
|
|
8
|
-
*/
|
|
9
|
-
export declare const SpotifyAdapter: (config: OauthBasicConfig) => (routes: import("./adapter.js").AdapterRoute, ctx: import("./adapter.js").AdapterOptions<{
|
|
10
|
-
tokenset: import("openid-client").TokenSet;
|
|
11
|
-
client: import("openid-client").BaseClient;
|
|
12
|
-
}>) => Promise<void>;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Issuer } from "openid-client";
|
|
2
|
-
import { OauthAdapter } from "./oauth.js";
|
|
3
|
-
const issuer = new Issuer({
|
|
4
|
-
issuer: "https://accounts.spotify.com",
|
|
5
|
-
authorization_endpoint: "https://accounts.spotify.com/authorize",
|
|
6
|
-
token_endpoint: "https://accounts.spotify.com/api/token",
|
|
7
|
-
});
|
|
8
|
-
/**
|
|
9
|
-
* The Spotify Adapter follows the PKCE flow outlined here:
|
|
10
|
-
* https://developer.spotify.com/documentation/web-api/tutorials/code-pkce-flow
|
|
11
|
-
*
|
|
12
|
-
* List of scopes available:
|
|
13
|
-
* https://developer.spotify.com/documentation/web-api/concepts/scopes
|
|
14
|
-
*/
|
|
15
|
-
export const SpotifyAdapter =
|
|
16
|
-
/* @__PURE__ */
|
|
17
|
-
(config) => {
|
|
18
|
-
return OauthAdapter({
|
|
19
|
-
issuer,
|
|
20
|
-
...config,
|
|
21
|
-
});
|
|
22
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { AuthHandler } from "../handler.js";
|
|
2
|
-
import { LinkAdapter } from "../adapter/link.js";
|
|
3
|
-
import { createSessionBuilder } from "../session.js";
|
|
4
|
-
import { CodeAdapter } from "../adapter/index.js";
|
|
5
|
-
const sessions = createSessionBuilder();
|
|
6
|
-
export default AuthHandler({
|
|
7
|
-
providers: {
|
|
8
|
-
link: LinkAdapter({
|
|
9
|
-
async onLink(link, claims) {
|
|
10
|
-
return new Response(link, {
|
|
11
|
-
status: 200,
|
|
12
|
-
headers: { "Content-Type": "text/plain" },
|
|
13
|
-
});
|
|
14
|
-
},
|
|
15
|
-
}),
|
|
16
|
-
code: CodeAdapter({
|
|
17
|
-
onCodeRequest: async (code, claims) => {
|
|
18
|
-
return new Response("Your code is " + code, {
|
|
19
|
-
status: 200,
|
|
20
|
-
headers: { "Content-Type": "text/plain" },
|
|
21
|
-
});
|
|
22
|
-
},
|
|
23
|
-
onCodeInvalid: async (code, claims) => {
|
|
24
|
-
return new Response("Code is invalid " + code, {
|
|
25
|
-
status: 200,
|
|
26
|
-
headers: { "Content-Type": "text/plain" },
|
|
27
|
-
});
|
|
28
|
-
},
|
|
29
|
-
}),
|
|
30
|
-
},
|
|
31
|
-
callbacks: {
|
|
32
|
-
auth: {
|
|
33
|
-
async allowClient(input) {
|
|
34
|
-
return true;
|
|
35
|
-
},
|
|
36
|
-
async success(ctx, input) {
|
|
37
|
-
return ctx.session({
|
|
38
|
-
type: "user",
|
|
39
|
-
properties: {
|
|
40
|
-
email: input.claims.email,
|
|
41
|
-
},
|
|
42
|
-
});
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
import { Adapter } from "./adapter/adapter.js";
|
|
3
|
-
import { JWTPayload } from "jose";
|
|
4
|
-
import { SessionBuilder } from "./session.js";
|
|
5
|
-
import { Hono } from "hono/tiny";
|
|
6
|
-
interface OnSuccessResponder<T extends {
|
|
7
|
-
type: any;
|
|
8
|
-
properties: any;
|
|
9
|
-
}> {
|
|
10
|
-
session(input: T & JWTPayload): Promise<Response>;
|
|
11
|
-
}
|
|
12
|
-
export declare class UnknownProviderError extends Error {
|
|
13
|
-
provider?: string | undefined;
|
|
14
|
-
constructor(provider?: string | undefined);
|
|
15
|
-
}
|
|
16
|
-
export declare class MissingParameterError extends Error {
|
|
17
|
-
parameter: string;
|
|
18
|
-
constructor(parameter: string);
|
|
19
|
-
}
|
|
20
|
-
export declare class UnknownStateError extends Error {
|
|
21
|
-
constructor();
|
|
22
|
-
}
|
|
23
|
-
export declare class UnauthorizedClientError extends Error {
|
|
24
|
-
client: string;
|
|
25
|
-
redirect_uri: string;
|
|
26
|
-
constructor(client: string, redirect_uri: string);
|
|
27
|
-
}
|
|
28
|
-
export declare class InvalidSessionError extends Error {
|
|
29
|
-
constructor();
|
|
30
|
-
}
|
|
31
|
-
export type Prettify<T> = {
|
|
32
|
-
[K in keyof T]: T[K];
|
|
33
|
-
} & {};
|
|
34
|
-
export declare const aws: <E extends import("hono").Env = import("hono").Env, S extends import("hono").Schema = {}, BasePath extends string = "/">(app: import("hono").Hono<E, S, BasePath>) => (event: import("hono/aws-lambda").LambdaEvent, lambdaContext?: import("hono/aws-lambda").LambdaContext | undefined) => Promise<import("hono/aws-lambda").APIGatewayProxyResult>;
|
|
35
|
-
export declare function AuthHandler<Providers extends Record<string, Adapter<any>>, Sessions extends SessionBuilder = SessionBuilder, Result = {
|
|
36
|
-
[key in keyof Providers]: Prettify<{
|
|
37
|
-
provider: key;
|
|
38
|
-
} & (Providers[key] extends Adapter<infer T> ? T : {})>;
|
|
39
|
-
}[keyof Providers]>(input: {
|
|
40
|
-
session?: Sessions;
|
|
41
|
-
providers: Providers;
|
|
42
|
-
callbacks: {
|
|
43
|
-
index?(req: Request): Promise<Response>;
|
|
44
|
-
error?(error: UnknownStateError, req: Request): Promise<Response | undefined>;
|
|
45
|
-
auth: {
|
|
46
|
-
error?(error: MissingParameterError | UnauthorizedClientError | UnknownProviderError, req: Request): Promise<Response>;
|
|
47
|
-
start?(event: Request): Promise<void>;
|
|
48
|
-
allowClient(clientID: string, redirect: string, req: Request): Promise<boolean>;
|
|
49
|
-
success(response: OnSuccessResponder<Sessions["$typeValues"]>, input: Result, req: Request): Promise<Response>;
|
|
50
|
-
};
|
|
51
|
-
connect?: {
|
|
52
|
-
error?(error: InvalidSessionError | UnknownProviderError, req: Request): Promise<Response | undefined>;
|
|
53
|
-
start?(session: Sessions["$typeValues"], req: Request): Promise<void>;
|
|
54
|
-
success?(session: Sessions["$typeValues"], input: {}): Promise<Response>;
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
}): Hono<import("hono").Env, import("hono/types").BlankSchema, "/">;
|
|
58
|
-
export {};
|