@venturekit/auth 0.0.44 → 0.0.46
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 +55 -0
- package/dist/server/cookies.d.ts +52 -0
- package/dist/server/cookies.d.ts.map +1 -1
- package/dist/server/cookies.js +55 -8
- package/dist/server/cookies.js.map +1 -1
- package/dist/server/index.d.ts +6 -2
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +3 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/middleware.d.ts +23 -3
- package/dist/server/middleware.d.ts.map +1 -1
- package/dist/server/middleware.js +8 -4
- package/dist/server/middleware.js.map +1 -1
- package/dist/server/password-reset.d.ts +56 -0
- package/dist/server/password-reset.d.ts.map +1 -0
- package/dist/server/password-reset.js +141 -0
- package/dist/server/password-reset.js.map +1 -0
- package/dist/server/session-routes.d.ts +63 -0
- package/dist/server/session-routes.d.ts.map +1 -0
- package/dist/server/session-routes.js +45 -0
- package/dist/server/session-routes.js.map +1 -0
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -122,6 +122,61 @@ submits cannot both create the account); an address that already has an
|
|
|
122
122
|
account gets `409 invitation_email_taken` and accepts with `existingUserSub`
|
|
123
123
|
after signing in. Table `vk_invitations` ships with the package migrations.
|
|
124
124
|
|
|
125
|
+
## One session per app
|
|
126
|
+
|
|
127
|
+
Several apps on one domain (a customer app, a partner portal, an admin
|
|
128
|
+
console) share every session cookie by default: signing in to one signs the
|
|
129
|
+
user in to all of them. Give each app its own cookie names and paths, read
|
|
130
|
+
only its own cookie, and serve refresh / sign-out for that session alone:
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
import {
|
|
134
|
+
buildSessionCookies, cookieAuthMiddleware, createSessionRoutes, sessionCookieNames,
|
|
135
|
+
} from '@venturekit/auth/server';
|
|
136
|
+
|
|
137
|
+
const ADMIN = { names: sessionCookieNames('admin'), path: '/admin', refreshPath: '/admin/auth', persistent: false };
|
|
138
|
+
|
|
139
|
+
// sign-in route of the admin app
|
|
140
|
+
for (const c of buildSessionCookies(tokens, { ...ADMIN, domain })) setCookie(ctx, c);
|
|
141
|
+
|
|
142
|
+
// every admin route: its own cookie only, never a Bearer token minted for another client,
|
|
143
|
+
// and never the user the default (customer) session resolved
|
|
144
|
+
middleware: [cookieAuthMiddleware({ cookieName: ADMIN.names.id, bearer: 'ignore', exclusive: true })];
|
|
145
|
+
|
|
146
|
+
// src/routes/admin/auth/refresh/post.ts + logout/post.ts
|
|
147
|
+
export const adminSession = createSessionRoutes({ cookieOptions: (ctx) => ({ ...ADMIN, domain: domainFor(ctx) }) });
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
`refresh` re-mints the id / access cookies (a dead refresh token clears the
|
|
151
|
+
session and answers 401); `logout` revokes the refresh token and clears only
|
|
152
|
+
that app's cookies. Without `names` / `path` everything stays as before
|
|
153
|
+
(`vk_id_token`, `Path=/`).
|
|
154
|
+
|
|
155
|
+
## Password reset with your own e-mail
|
|
156
|
+
|
|
157
|
+
`forgotPassword` uses Cognito's own e-mail. `requestPasswordReset` /
|
|
158
|
+
`resetPasswordWithCode` keep the code in your `VerificationCodeStore` and let
|
|
159
|
+
you send it — your template, your sender, a button to your reset page:
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
import { requestPasswordReset, resetPasswordWithCode, signInWithPassword } from '@venturekit/auth/server';
|
|
163
|
+
|
|
164
|
+
await requestPasswordReset({
|
|
165
|
+
email, store,
|
|
166
|
+
eligible: (e) => accounts.isActive(e), // nothing sent otherwise
|
|
167
|
+
send: ({ email, code }) => mail.passwordReset(email, code), // answer the client the same either way
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
await resetPasswordWithCode({ email, code, newPassword, store, eligible });
|
|
171
|
+
const tokens = await signInWithPassword({ email, password: newPassword });
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
The code is single-use, hashed, attempt-capped and in its own store slot.
|
|
175
|
+
Eligibility is checked again after the code is spent, and every session of
|
|
176
|
+
the account is signed out (`AdminUserGlobalSignOut`, granted by the app
|
|
177
|
+
stack). A wrong code, an ineligible address and an unknown account all fail
|
|
178
|
+
the same way (`invalid_code`, 400).
|
|
179
|
+
|
|
125
180
|
## Passkeys (WebAuthn)
|
|
126
181
|
|
|
127
182
|
Declare `passkeys: { relyingPartyId: 'example.com' }` on the auth intent (needs the
|
package/dist/server/cookies.d.ts
CHANGED
|
@@ -16,6 +16,15 @@
|
|
|
16
16
|
* so it never leaks to non-auth handlers.
|
|
17
17
|
* - `Path=/` for the id/access tokens, `Path=/auth` for refresh.
|
|
18
18
|
*
|
|
19
|
+
* **One session per app.** Several apps on one domain (a customer app,
|
|
20
|
+
* a partner portal, an admin console) share every cookie by default, so
|
|
21
|
+
* signing in to one signs the user in to all. Give each its own names
|
|
22
|
+
* and paths ({@link CookieOptions.names} — e.g. {@link sessionCookieNames}
|
|
23
|
+
* — {@link CookieOptions.path}, {@link CookieOptions.refreshPath}), read
|
|
24
|
+
* them with `cookieAuthMiddleware({ cookieName, bearer: 'ignore',
|
|
25
|
+
* exclusive: true })`, and serve refresh / sign-out with
|
|
26
|
+
* `createSessionRoutes` (session-routes.ts).
|
|
27
|
+
*
|
|
19
28
|
* The cookies are **host-only** (no `Domain` attribute) by default, so
|
|
20
29
|
* they're scoped to the host the response came from. The browser sends
|
|
21
30
|
* them on every request to that host, including cross-origin XHR from a
|
|
@@ -29,6 +38,22 @@
|
|
|
29
38
|
export declare const ID_TOKEN_COOKIE = "vk_id_token";
|
|
30
39
|
export declare const ACCESS_TOKEN_COOKIE = "vk_access_token";
|
|
31
40
|
export declare const REFRESH_TOKEN_COOKIE = "vk_refresh_token";
|
|
41
|
+
/** The names of the three session cookies. */
|
|
42
|
+
export interface SessionCookieNames {
|
|
43
|
+
id: string;
|
|
44
|
+
access: string;
|
|
45
|
+
refresh: string;
|
|
46
|
+
}
|
|
47
|
+
/** The default trio: `vk_id_token` / `vk_access_token` / `vk_refresh_token`. */
|
|
48
|
+
export declare const DEFAULT_SESSION_COOKIE_NAMES: Readonly<SessionCookieNames>;
|
|
49
|
+
/**
|
|
50
|
+
* Cookie names for a named session — one per app when several apps share
|
|
51
|
+
* a domain (a customer app, a partner portal, an admin console):
|
|
52
|
+
* `vk_<realm>_id_token`, `vk_<realm>_access_token`, `vk_<realm>_refresh_token`.
|
|
53
|
+
* Pass the result as {@link CookieOptions.names}, and the id name to
|
|
54
|
+
* `cookieAuthMiddleware({ cookieName })`.
|
|
55
|
+
*/
|
|
56
|
+
export declare function sessionCookieNames(realm: string): SessionCookieNames;
|
|
32
57
|
export interface SessionTokens {
|
|
33
58
|
idToken: string;
|
|
34
59
|
accessToken: string;
|
|
@@ -88,6 +113,21 @@ export interface CookieOptions {
|
|
|
88
113
|
* the same options to {@link buildClearSessionCookies}.
|
|
89
114
|
*/
|
|
90
115
|
domain?: string;
|
|
116
|
+
/**
|
|
117
|
+
* Cookie names. Defaults to {@link DEFAULT_SESSION_COOKIE_NAMES}. Give
|
|
118
|
+
* each app its own (e.g. {@link sessionCookieNames}`('admin')`) when
|
|
119
|
+
* several apps on one domain must NOT share a session: signing in to
|
|
120
|
+
* one then signs the user in to that one alone. Missing keys keep the
|
|
121
|
+
* default name.
|
|
122
|
+
*/
|
|
123
|
+
names?: Partial<SessionCookieNames>;
|
|
124
|
+
/**
|
|
125
|
+
* Path scope of the id / access cookies. Defaults to `/`. Narrow it to
|
|
126
|
+
* the prefix of the API routes that app calls (`/admin`) so its
|
|
127
|
+
* session token never rides another app's requests. Must cover every
|
|
128
|
+
* route that reads the cookie; {@link refreshPath} stays separate.
|
|
129
|
+
*/
|
|
130
|
+
path?: string;
|
|
91
131
|
}
|
|
92
132
|
/**
|
|
93
133
|
* Default value for the cookie `Secure` flag.
|
|
@@ -102,6 +142,8 @@ export interface CookieOptions {
|
|
|
102
142
|
* session cookies WITHOUT `Secure` in production.
|
|
103
143
|
*/
|
|
104
144
|
export declare function defaultSecure(): boolean;
|
|
145
|
+
/** The three cookie names {@link CookieOptions} resolves to (defaults filled in). */
|
|
146
|
+
export declare function resolveSessionCookieNames(opts?: Pick<CookieOptions, 'names'>): SessionCookieNames;
|
|
105
147
|
/**
|
|
106
148
|
* Build the `Set-Cookie` header values to attach to a sign-in / refresh
|
|
107
149
|
* response. Returns an array — API Gateway v2 supports multi-valued
|
|
@@ -119,6 +161,16 @@ export declare function buildSessionCookies(tokens: SessionTokens, options?: Coo
|
|
|
119
161
|
* terminally so the next attempt goes straight to sign-in.
|
|
120
162
|
*/
|
|
121
163
|
export declare function buildClearSessionCookies(options?: CookieOptions): string[];
|
|
164
|
+
/**
|
|
165
|
+
* The session tokens a request carries under the cookie names of
|
|
166
|
+
* `options` (`null` when absent). Same HTTP API v2 / REST v1 handling as
|
|
167
|
+
* {@link readCookieFromEvent}.
|
|
168
|
+
*/
|
|
169
|
+
export declare function readSessionCookies(event: Parameters<typeof readCookieFromEvent>[0], options?: Pick<CookieOptions, 'names'>): {
|
|
170
|
+
idToken: string | null;
|
|
171
|
+
accessToken: string | null;
|
|
172
|
+
refreshToken: string | null;
|
|
173
|
+
};
|
|
122
174
|
/**
|
|
123
175
|
* Cookie name carrying the OAuth `state` value between the
|
|
124
176
|
* `POST /auth/<provider>/start` and `POST /auth/<provider>/callback`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cookies.d.ts","sourceRoot":"","sources":["../../src/server/cookies.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"cookies.d.ts","sourceRoot":"","sources":["../../src/server/cookies.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,eAAO,MAAM,eAAe,gBAAgB,CAAC;AAC7C,eAAO,MAAM,mBAAmB,oBAAoB,CAAC;AACrD,eAAO,MAAM,oBAAoB,qBAAqB,CAAC;AAIvD,8CAA8C;AAC9C,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MA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G,SAAS,CAUpB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,eAAe,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,EAC1C,IAAI,EAAE,MAAM,GACX,MAAM,GAAG,IAAI,CAef;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EACD;IAAE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;CAAE,GACpE,SAAS,GACT,IAAI,EACR,IAAI,EAAE,MAAM,GACX,MAAM,GAAG,IAAI,CAQf"}
|
package/dist/server/cookies.js
CHANGED
|
@@ -16,6 +16,15 @@
|
|
|
16
16
|
* so it never leaks to non-auth handlers.
|
|
17
17
|
* - `Path=/` for the id/access tokens, `Path=/auth` for refresh.
|
|
18
18
|
*
|
|
19
|
+
* **One session per app.** Several apps on one domain (a customer app,
|
|
20
|
+
* a partner portal, an admin console) share every cookie by default, so
|
|
21
|
+
* signing in to one signs the user in to all. Give each its own names
|
|
22
|
+
* and paths ({@link CookieOptions.names} — e.g. {@link sessionCookieNames}
|
|
23
|
+
* — {@link CookieOptions.path}, {@link CookieOptions.refreshPath}), read
|
|
24
|
+
* them with `cookieAuthMiddleware({ cookieName, bearer: 'ignore',
|
|
25
|
+
* exclusive: true })`, and serve refresh / sign-out with
|
|
26
|
+
* `createSessionRoutes` (session-routes.ts).
|
|
27
|
+
*
|
|
19
28
|
* The cookies are **host-only** (no `Domain` attribute) by default, so
|
|
20
29
|
* they're scoped to the host the response came from. The browser sends
|
|
21
30
|
* them on every request to that host, including cross-origin XHR from a
|
|
@@ -30,6 +39,25 @@ export const ID_TOKEN_COOKIE = 'vk_id_token';
|
|
|
30
39
|
export const ACCESS_TOKEN_COOKIE = 'vk_access_token';
|
|
31
40
|
export const REFRESH_TOKEN_COOKIE = 'vk_refresh_token';
|
|
32
41
|
const REFRESH_MAX_AGE_SECONDS = 30 * 24 * 60 * 60; // 30 days
|
|
42
|
+
/** The default trio: `vk_id_token` / `vk_access_token` / `vk_refresh_token`. */
|
|
43
|
+
export const DEFAULT_SESSION_COOKIE_NAMES = Object.freeze({
|
|
44
|
+
id: ID_TOKEN_COOKIE,
|
|
45
|
+
access: ACCESS_TOKEN_COOKIE,
|
|
46
|
+
refresh: REFRESH_TOKEN_COOKIE,
|
|
47
|
+
});
|
|
48
|
+
/**
|
|
49
|
+
* Cookie names for a named session — one per app when several apps share
|
|
50
|
+
* a domain (a customer app, a partner portal, an admin console):
|
|
51
|
+
* `vk_<realm>_id_token`, `vk_<realm>_access_token`, `vk_<realm>_refresh_token`.
|
|
52
|
+
* Pass the result as {@link CookieOptions.names}, and the id name to
|
|
53
|
+
* `cookieAuthMiddleware({ cookieName })`.
|
|
54
|
+
*/
|
|
55
|
+
export function sessionCookieNames(realm) {
|
|
56
|
+
if (!/^[a-z0-9][a-z0-9_-]{0,31}$/.test(realm)) {
|
|
57
|
+
throw new Error(`[@venturekit/auth/server] session realm "${realm}" must be 1–32 chars of a-z, 0-9, '_' or '-'`);
|
|
58
|
+
}
|
|
59
|
+
return { id: `vk_${realm}_id_token`, access: `vk_${realm}_access_token`, refresh: `vk_${realm}_refresh_token` };
|
|
60
|
+
}
|
|
33
61
|
/**
|
|
34
62
|
* Default value for the cookie `Secure` flag.
|
|
35
63
|
*
|
|
@@ -52,8 +80,14 @@ function resolve(opts) {
|
|
|
52
80
|
refreshMaxAgeSeconds: opts?.refreshMaxAgeSeconds ?? REFRESH_MAX_AGE_SECONDS,
|
|
53
81
|
persistent: opts?.persistent ?? true,
|
|
54
82
|
domain: opts?.domain,
|
|
83
|
+
names: resolveSessionCookieNames(opts),
|
|
84
|
+
path: opts?.path ?? '/',
|
|
55
85
|
};
|
|
56
86
|
}
|
|
87
|
+
/** The three cookie names {@link CookieOptions} resolves to (defaults filled in). */
|
|
88
|
+
export function resolveSessionCookieNames(opts) {
|
|
89
|
+
return { ...DEFAULT_SESSION_COOKIE_NAMES, ...opts?.names };
|
|
90
|
+
}
|
|
57
91
|
function buildSetCookie(name, value, attrs, secure) {
|
|
58
92
|
const parts = [`${name}=${encodeURIComponent(value)}`];
|
|
59
93
|
parts.push(`Path=${attrs.path ?? '/'}`);
|
|
@@ -79,7 +113,7 @@ function buildSetCookie(name, value, attrs, secure) {
|
|
|
79
113
|
* `REFRESH_TOKEN_AUTH` doesn't rotate the refresh token).
|
|
80
114
|
*/
|
|
81
115
|
export function buildSessionCookies(tokens, options) {
|
|
82
|
-
const { secure, refreshPath, refreshMaxAgeSeconds, persistent, domain } = resolve(options);
|
|
116
|
+
const { secure, refreshPath, refreshMaxAgeSeconds, persistent, domain, names, path } = resolve(options);
|
|
83
117
|
// Session cookies (no Max-Age) when persistence is opted OUT — the
|
|
84
118
|
// browser then drops all three auth cookies on close. Persistent
|
|
85
119
|
// (default) keeps the token-expiry Max-Age on id/access and the
|
|
@@ -91,10 +125,10 @@ export function buildSessionCookies(tokens, options) {
|
|
|
91
125
|
: {};
|
|
92
126
|
const refreshMaxAge = persistent ? { maxAge: refreshMaxAgeSeconds } : {};
|
|
93
127
|
const headers = [];
|
|
94
|
-
headers.push(buildSetCookie(
|
|
95
|
-
headers.push(buildSetCookie(
|
|
128
|
+
headers.push(buildSetCookie(names.id, tokens.idToken, { path, ...accessMaxAge, ...(domain ? { domain } : {}) }, secure));
|
|
129
|
+
headers.push(buildSetCookie(names.access, tokens.accessToken, { path, ...accessMaxAge, ...(domain ? { domain } : {}) }, secure));
|
|
96
130
|
if (tokens.refreshToken) {
|
|
97
|
-
headers.push(buildSetCookie(
|
|
131
|
+
headers.push(buildSetCookie(names.refresh, tokens.refreshToken, {
|
|
98
132
|
path: refreshPath,
|
|
99
133
|
...refreshMaxAge,
|
|
100
134
|
sameSite: 'Strict',
|
|
@@ -109,13 +143,26 @@ export function buildSessionCookies(tokens, options) {
|
|
|
109
143
|
* terminally so the next attempt goes straight to sign-in.
|
|
110
144
|
*/
|
|
111
145
|
export function buildClearSessionCookies(options) {
|
|
112
|
-
const { secure, refreshPath, domain } = resolve(options);
|
|
146
|
+
const { secure, refreshPath, domain, names, path } = resolve(options);
|
|
113
147
|
return [
|
|
114
|
-
buildSetCookie(
|
|
115
|
-
buildSetCookie(
|
|
116
|
-
buildSetCookie(
|
|
148
|
+
buildSetCookie(names.id, '', { path, maxAge: 0, ...(domain ? { domain } : {}) }, secure),
|
|
149
|
+
buildSetCookie(names.access, '', { path, maxAge: 0, ...(domain ? { domain } : {}) }, secure),
|
|
150
|
+
buildSetCookie(names.refresh, '', { path: refreshPath, maxAge: 0, sameSite: 'Strict', ...(domain ? { domain } : {}) }, secure),
|
|
117
151
|
];
|
|
118
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* The session tokens a request carries under the cookie names of
|
|
155
|
+
* `options` (`null` when absent). Same HTTP API v2 / REST v1 handling as
|
|
156
|
+
* {@link readCookieFromEvent}.
|
|
157
|
+
*/
|
|
158
|
+
export function readSessionCookies(event, options) {
|
|
159
|
+
const names = resolveSessionCookieNames(options);
|
|
160
|
+
return {
|
|
161
|
+
idToken: readCookieFromEvent(event, names.id),
|
|
162
|
+
accessToken: readCookieFromEvent(event, names.access),
|
|
163
|
+
refreshToken: readCookieFromEvent(event, names.refresh),
|
|
164
|
+
};
|
|
165
|
+
}
|
|
119
166
|
/**
|
|
120
167
|
* Default lifetime of the OAuth `state` cookie set by
|
|
121
168
|
* {@link buildOAuthStateCookie}: 10 minutes is enough for the IdP
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cookies.js","sourceRoot":"","sources":["../../src/server/cookies.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"cookies.js","sourceRoot":"","sources":["../../src/server/cookies.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAC;AAC7C,MAAM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CAAC;IACxB,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC;IACnC,MAAM,YAAY,GAChB,YAAY,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC;QACrC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;QACzB,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC/D,OAAO,oBAAoB,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;AAClD,CAAC"}
|
package/dist/server/index.d.ts
CHANGED
|
@@ -43,13 +43,17 @@ export type { ChangePasswordInput } from './change-password.js';
|
|
|
43
43
|
export { changePassword } from './change-password.js';
|
|
44
44
|
export type { ForgotPasswordInput, ForgotPasswordResult, ConfirmForgotPasswordInput, CodeDeliveryDetails, } from './forgot-password.js';
|
|
45
45
|
export { forgotPassword, confirmForgotPassword } from './forgot-password.js';
|
|
46
|
+
export type { RequestPasswordResetInput, ResetPasswordWithCodeInput } from './password-reset.js';
|
|
47
|
+
export { requestPasswordReset, resetPasswordWithCode, passwordResetIdentifier } from './password-reset.js';
|
|
46
48
|
export type { VerifyOptions, VerifyOutcome } from './verify.js';
|
|
47
49
|
export { verifyAndDecode, verifyAndExplain } from './verify.js';
|
|
48
50
|
export { decodeJwtClaims } from './token-utils.js';
|
|
49
|
-
export type { SessionTokens, CookieOptions, CookieDomainOptions, OAuthStateCookieOptions, } from './cookies.js';
|
|
50
|
-
export { ID_TOKEN_COOKIE, ACCESS_TOKEN_COOKIE, REFRESH_TOKEN_COOKIE, buildSessionCookies, buildClearSessionCookies, readCookieFromHeader, readCookieFromEvent, buildOAuthStateCookie, clearOAuthStateCookie, oauthStateCookieName, resolveCookieDomain, } from './cookies.js';
|
|
51
|
+
export type { SessionTokens, CookieOptions, CookieDomainOptions, OAuthStateCookieOptions, SessionCookieNames, } from './cookies.js';
|
|
52
|
+
export { ID_TOKEN_COOKIE, ACCESS_TOKEN_COOKIE, REFRESH_TOKEN_COOKIE, DEFAULT_SESSION_COOKIE_NAMES, sessionCookieNames, resolveSessionCookieNames, readSessionCookies, buildSessionCookies, buildClearSessionCookies, readCookieFromHeader, readCookieFromEvent, buildOAuthStateCookie, clearOAuthStateCookie, oauthStateCookieName, resolveCookieDomain, } from './cookies.js';
|
|
51
53
|
export type { CookieAuthMiddlewareOptions } from './middleware.js';
|
|
52
54
|
export { cookieAuthMiddleware, extractToken, defaultScopeMapper, userIdFromClaims } from './middleware.js';
|
|
55
|
+
export type { SessionRoutes, SessionRoutesOptions } from './session-routes.js';
|
|
56
|
+
export { createSessionRoutes } from './session-routes.js';
|
|
53
57
|
export type { FederatedAuthRoutes, FederatedAuthRoutesOptions, FederatedCallbackBody, FederatedCallbackResult, FederatedOnSignInArgs, FederatedOnSignInResult, FederatedStartBody, } from './federated-routes.js';
|
|
54
58
|
export { createFederatedAuthRoutes } from './federated-routes.js';
|
|
55
59
|
export type { HandoffPayload, HandoffStore } from './handoff.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC1D,YAAY,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAExE,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD,YAAY,EACV,eAAe,EACf,mBAAmB,EACnB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,6BAA6B,EAC7B,4BAA4B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mB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,4BAA4B,EAC5B,6BAA6B,EAC7B,2BAA2B,GAC5B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,uBAAuB,EACvB,sBAAsB,EACtB,mCAAmC,GACpC,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,OAAO,IAAI,aAAa,GACzB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,0BAA0B,GAC3B,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,EAC1B,uBAAuB,EACvB,cAAc,EACd,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,kBAAkB,EAClB,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,UAAU,EACV,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,OAAO,IAAI,iBAAiB,GAC7B,MAAM,kBAAkB,CAAC"}
|
package/dist/server/index.js
CHANGED
|
@@ -33,12 +33,14 @@ export { revokeRefreshToken, globalSignOut } from './revoke.js';
|
|
|
33
33
|
export { ensureUserForVerifiedEmail, ensureUserForVerifiedPhone, mintSessionForVerifiedEmail, mintSessionForVerifiedPhone, } from './passwordless.js';
|
|
34
34
|
export { changePassword } from './change-password.js';
|
|
35
35
|
export { forgotPassword, confirmForgotPassword } from './forgot-password.js';
|
|
36
|
+
export { requestPasswordReset, resetPasswordWithCode, passwordResetIdentifier } from './password-reset.js';
|
|
36
37
|
export { verifyAndDecode, verifyAndExplain } from './verify.js';
|
|
37
38
|
// Unverified claim extraction — ONLY for tokens received directly
|
|
38
39
|
// from the provider (e.g. reading profile claims right after sign-in).
|
|
39
40
|
export { decodeJwtClaims } from './token-utils.js';
|
|
40
|
-
export { ID_TOKEN_COOKIE, ACCESS_TOKEN_COOKIE, REFRESH_TOKEN_COOKIE, buildSessionCookies, buildClearSessionCookies, readCookieFromHeader, readCookieFromEvent, buildOAuthStateCookie, clearOAuthStateCookie, oauthStateCookieName, resolveCookieDomain, } from './cookies.js';
|
|
41
|
+
export { ID_TOKEN_COOKIE, ACCESS_TOKEN_COOKIE, REFRESH_TOKEN_COOKIE, DEFAULT_SESSION_COOKIE_NAMES, sessionCookieNames, resolveSessionCookieNames, readSessionCookies, buildSessionCookies, buildClearSessionCookies, readCookieFromHeader, readCookieFromEvent, buildOAuthStateCookie, clearOAuthStateCookie, oauthStateCookieName, resolveCookieDomain, } from './cookies.js';
|
|
41
42
|
export { cookieAuthMiddleware, extractToken, defaultScopeMapper, userIdFromClaims } from './middleware.js';
|
|
43
|
+
export { createSessionRoutes } from './session-routes.js';
|
|
42
44
|
export { createFederatedAuthRoutes } from './federated-routes.js';
|
|
43
45
|
export { DEFAULT_HANDOFF_TTL_SECONDS, generateHandoffCode, hashHandoffCode, issueHandoffCode, redeemHandoffCode, } from './handoff.js';
|
|
44
46
|
export { createSessionHandoffRoutes, DEFAULT_HANDOFF_COMPLETE_PATH, } from './handoff-routes.js';
|
package/dist/server/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAQlD,OAAO,EACL,6BAA6B,EAC7B,4BAA4B,EAC5B,6BAA6B,GAC9B,MAAM,gBAAgB,CAAC;AAiBxB,OAAO,EACL,cAAc,EACd,0BAA0B,EAC1B,gBAAgB,EAChB,iBAAiB,EACjB,yBAAyB,EACzB,yBAAyB,EACzB,iBAAiB,EACjB,sBAAsB,EACtB,UAAU,GACX,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAO1C,OAAO,EACL,eAAe,EACf,yBAAyB,EACzB,gBAAgB,EAChB,eAAe,EACf,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAShE,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,EAC1B,2BAA2B,EAC3B,2BAA2B,GAC5B,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAQtD,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MA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MAAM,kBAAkB,CAAC"}
|
|
@@ -28,9 +28,28 @@ import type { AuthServerConfig } from './config.js';
|
|
|
28
28
|
export interface CookieAuthMiddlewareOptions {
|
|
29
29
|
/**
|
|
30
30
|
* Cookie name carrying the session JWT. Defaults to `vk_id_token`
|
|
31
|
-
* (matches the cookie `buildSessionCookies` sets).
|
|
31
|
+
* (matches the cookie `buildSessionCookies` sets). An app with its own
|
|
32
|
+
* session passes its id cookie's name (`sessionCookieNames('admin').id`).
|
|
32
33
|
*/
|
|
33
34
|
cookieName?: string;
|
|
35
|
+
/**
|
|
36
|
+
* What to do with an `Authorization: Bearer` header:
|
|
37
|
+
* - `'prefer'` (default) — the Bearer token wins over the cookie
|
|
38
|
+
* (mixed SPA + CLI / mobile clients);
|
|
39
|
+
* - `'ignore'` — read the cookie only. For an app whose session lives
|
|
40
|
+
* in its own cookie only: a Bearer token minted for ANOTHER client
|
|
41
|
+
* (a mobile app's session on the same pool) must not authenticate
|
|
42
|
+
* here.
|
|
43
|
+
*/
|
|
44
|
+
bearer?: 'prefer' | 'ignore';
|
|
45
|
+
/**
|
|
46
|
+
* This middleware alone decides `ctx.user`: whatever an earlier auth
|
|
47
|
+
* middleware resolved (e.g. the default session the runtime injects on
|
|
48
|
+
* every scoped route) is dropped first, so no token of this app's →
|
|
49
|
+
* no user → the scope gate answers 401. Default `false` (an absent or
|
|
50
|
+
* invalid token leaves `ctx.user` as it was).
|
|
51
|
+
*/
|
|
52
|
+
exclusive?: boolean;
|
|
34
53
|
/**
|
|
35
54
|
* Which token type to verify:
|
|
36
55
|
* - `'id'` (default) — matches id-token cookies which carry `email`
|
|
@@ -109,12 +128,13 @@ export declare function userIdFromClaims(claims: Record<string, unknown>, userId
|
|
|
109
128
|
export declare function cookieAuthMiddleware(options?: CookieAuthMiddlewareOptions): Middleware<RequestContext>;
|
|
110
129
|
/**
|
|
111
130
|
* Pull the session token out of the request. Bearer header wins over
|
|
112
|
-
* cookie so a mixed client (browser + CLI) stays predictable
|
|
131
|
+
* cookie so a mixed client (browser + CLI) stays predictable — unless
|
|
132
|
+
* `bearer` is `'ignore'`, which reads the cookie only.
|
|
113
133
|
*
|
|
114
134
|
* Exported for tests only — route handlers should use
|
|
115
135
|
* {@link cookieAuthMiddleware} instead.
|
|
116
136
|
*/
|
|
117
|
-
export declare function extractToken(event: APIGatewayProxyEventV2, cookieName?: string): string | null;
|
|
137
|
+
export declare function extractToken(event: APIGatewayProxyEventV2, cookieName?: string, bearer?: 'prefer' | 'ignore'): string | null;
|
|
118
138
|
/**
|
|
119
139
|
* Default claims→scopes mapper.
|
|
120
140
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/server/middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAKzD,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGpD,MAAM,WAAW,2BAA2B;IAC1C
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/server/middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAKzD,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGpD,MAAM,WAAW,2BAA2B;IAC1C;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC7B;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,IAAI,GAAG,QAAQ,CAAC;IAC3B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B;;;;;;;;;OASG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB;;;;;;;;OAQG;IACH,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,EAAE,CAAC;IAC5D;;;;;;;;;;;OAWG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAK9F;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,GAAE,2BAAgC,GACxC,UAAU,CAAC,cAAc,CAAC,CAmD5B;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,sBAAsB,EAC7B,UAAU,GAAE,MAAwB,EACpC,MAAM,GAAE,QAAQ,GAAG,QAAmB,GACrC,MAAM,GAAG,IAAI,CAaf;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,MAAM,EAAE,CAiBV"}
|
|
@@ -58,6 +58,7 @@ export function userIdFromClaims(claims, userIdClaim) {
|
|
|
58
58
|
*/
|
|
59
59
|
export function cookieAuthMiddleware(options = {}) {
|
|
60
60
|
const cookieName = options.cookieName ?? ID_TOKEN_COOKIE;
|
|
61
|
+
const bearer = options.bearer ?? 'prefer';
|
|
61
62
|
const tokenUse = options.tokenUse ?? 'id';
|
|
62
63
|
const scopeMapper = options.scopeMapper ?? defaultScopeMapper;
|
|
63
64
|
if (options.config && options.intents) {
|
|
@@ -83,7 +84,9 @@ export function cookieAuthMiddleware(options = {}) {
|
|
|
83
84
|
return {
|
|
84
85
|
name: 'cookieAuth',
|
|
85
86
|
fn: async (ctx, next) => {
|
|
86
|
-
|
|
87
|
+
if (options.exclusive)
|
|
88
|
+
ctx.user = null;
|
|
89
|
+
const token = extractToken(ctx.rawEvent, cookieName, bearer);
|
|
87
90
|
if (token) {
|
|
88
91
|
// Several pools: the first that accepts the token wins. A token
|
|
89
92
|
// names its issuer, so at most one verifier can succeed; the
|
|
@@ -107,15 +110,16 @@ export function cookieAuthMiddleware(options = {}) {
|
|
|
107
110
|
}
|
|
108
111
|
/**
|
|
109
112
|
* Pull the session token out of the request. Bearer header wins over
|
|
110
|
-
* cookie so a mixed client (browser + CLI) stays predictable
|
|
113
|
+
* cookie so a mixed client (browser + CLI) stays predictable — unless
|
|
114
|
+
* `bearer` is `'ignore'`, which reads the cookie only.
|
|
111
115
|
*
|
|
112
116
|
* Exported for tests only — route handlers should use
|
|
113
117
|
* {@link cookieAuthMiddleware} instead.
|
|
114
118
|
*/
|
|
115
|
-
export function extractToken(event, cookieName = ID_TOKEN_COOKIE) {
|
|
119
|
+
export function extractToken(event, cookieName = ID_TOKEN_COOKIE, bearer = 'prefer') {
|
|
116
120
|
const headers = event.headers ?? {};
|
|
117
121
|
const authHeader = (headers['authorization'] ?? headers['Authorization']);
|
|
118
|
-
if (authHeader) {
|
|
122
|
+
if (authHeader && bearer === 'prefer') {
|
|
119
123
|
const match = authHeader.match(/^Bearer\s+(.+)$/i);
|
|
120
124
|
if (match && match[1])
|
|
121
125
|
return match[1].trim();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../src/server/middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAQH,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACpE,O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verification.js';
|
|
3
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
4
|
+
/** Default store slot of a reset code — never the slot of a sign-up or sign-in code for the same address. */
|
|
5
|
+
export declare function passwordResetIdentifier(email: string): string;
|
|
6
|
+
interface PasswordResetCommon {
|
|
7
|
+
/** The account's address (the pool's username). Trimmed and lower-cased. */
|
|
8
|
+
email: string;
|
|
9
|
+
store: VerificationCodeStore;
|
|
10
|
+
/**
|
|
11
|
+
* May this address reset its password here? — it has an account, the
|
|
12
|
+
* account belongs to this app, it is not suspended… Default: any address.
|
|
13
|
+
* {@link resetPasswordWithCode} asks again after spending the code.
|
|
14
|
+
*/
|
|
15
|
+
eligible?: (email: string) => MaybePromise<boolean>;
|
|
16
|
+
/** The code's store slot. Default {@link passwordResetIdentifier}. */
|
|
17
|
+
identifier?: (email: string) => string;
|
|
18
|
+
}
|
|
19
|
+
export interface RequestPasswordResetInput extends PasswordResetCommon {
|
|
20
|
+
/** Deliver the code — called only for an eligible address. */
|
|
21
|
+
send: (args: {
|
|
22
|
+
email: string;
|
|
23
|
+
code: string;
|
|
24
|
+
expiresAt: number;
|
|
25
|
+
}) => MaybePromise<void>;
|
|
26
|
+
/** Code lifetime in seconds. Default 900 (15 minutes — long enough for greylisted mail). */
|
|
27
|
+
ttlSeconds?: number;
|
|
28
|
+
/** Wrong guesses before the code dies. Default 5. */
|
|
29
|
+
maxAttempts?: number;
|
|
30
|
+
/** Code length in digits. Default 6. */
|
|
31
|
+
length?: number;
|
|
32
|
+
}
|
|
33
|
+
export interface ResetPasswordWithCodeInput extends PasswordResetCommon {
|
|
34
|
+
/** The code from the e-mail. */
|
|
35
|
+
code: string;
|
|
36
|
+
/** The new permanent password — check it against the pool's policy first. */
|
|
37
|
+
newPassword: string;
|
|
38
|
+
/**
|
|
39
|
+
* Revoke every refresh token of the account after the change. Default
|
|
40
|
+
* `true`. Already-issued access tokens expire on their own (≤ 1 h).
|
|
41
|
+
*/
|
|
42
|
+
signOutEverywhere?: boolean;
|
|
43
|
+
config?: AuthServerConfig;
|
|
44
|
+
}
|
|
45
|
+
/** Step 1 — mint and deliver a code. `sent: false` = not eligible: answer the client the same way. */
|
|
46
|
+
export declare function requestPasswordReset(input: RequestPasswordResetInput): Promise<{
|
|
47
|
+
sent: boolean;
|
|
48
|
+
}>;
|
|
49
|
+
/**
|
|
50
|
+
* Step 2 — spend the code, set the new password, sign the account out
|
|
51
|
+
* everywhere. Throws `AuthError('invalid_code', 400)` for any refusal,
|
|
52
|
+
* `invalid_parameter` (422) for a password the pool refuses.
|
|
53
|
+
*/
|
|
54
|
+
export declare function resetPasswordWithCode(input: ResetPasswordWithCodeInput): Promise<void>;
|
|
55
|
+
export {};
|
|
56
|
+
//# sourceMappingURL=password-reset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"password-reset.d.ts","sourceRoot":"","sources":["../../src/server/password-reset.ts"],"names":[],"mappings":"AA6CA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAMpD,OAAO,EAAmD,KAAK,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAEhH,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAEtC,6GAA6G;AAC7G,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7D;AAMD,UAAU,mBAAmB;IAC3B,4EAA4E;IAC5E,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,qBAAqB,CAAC;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,YAAY,CAAC,OAAO,CAAC,CAAC;IACpD,sEAAsE;IACtE,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CACxC;AAED,MAAM,WAAW,yBAA0B,SAAQ,mBAAmB;IACpE,8DAA8D;IAC9D,IAAI,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;IACvF,4FAA4F;IAC5F,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qDAAqD;IACrD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wCAAwC;IACxC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,0BAA2B,SAAQ,mBAAmB;IACrE,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,6EAA6E;IAC7E,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,MAAM,CAAC,EAAE,gBAAgB,CAAC;CAC3B;AAKD,sGAAsG;AACtG,wBAAsB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC,CAavG;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,KAAK,EAAE,0BAA0B,GAAG,OAAO,CAAC,IAAI,CAAC,CAyB5F"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "Forgot password" with YOUR e-mail.
|
|
3
|
+
*
|
|
4
|
+
* {@link forgotPassword} / {@link confirmForgotPassword} (forgot-password.ts)
|
|
5
|
+
* use Cognito's own flow: Cognito picks the sender, the copy and the
|
|
6
|
+
* code, and the message cannot carry a link to the app's reset page.
|
|
7
|
+
* This flow keeps the code in a {@link VerificationCodeStore} (hashed,
|
|
8
|
+
* single-use, attempt-capped — verification.ts) and lets the app deliver
|
|
9
|
+
* it: its template, its sender, its locale, a button to
|
|
10
|
+
* `https://app.example.com/reset#email=…&code=…`. It also runs the same
|
|
11
|
+
* way under `vk dev` and in production.
|
|
12
|
+
*
|
|
13
|
+
* 1. {@link requestPasswordReset} — mints a code for an ELIGIBLE address
|
|
14
|
+
* and hands it to `send`. Answer the request the same whatever
|
|
15
|
+
* happens (`sent: false` is for logs, never for the client), so the
|
|
16
|
+
* route says nothing about which addresses have an account.
|
|
17
|
+
* 2. {@link resetPasswordWithCode} — spends the code, re-checks
|
|
18
|
+
* eligibility (the account may have changed since the code was
|
|
19
|
+
* mailed), sets the new password (`AdminSetUserPassword`, permanent)
|
|
20
|
+
* and signs EVERY session of the account out (`AdminUserGlobalSignOut`)
|
|
21
|
+
* — whoever knew the old password included. The caller then signs
|
|
22
|
+
* this browser in with the new password.
|
|
23
|
+
*
|
|
24
|
+
* Wrong, expired or used codes, an ineligible address and an address with
|
|
25
|
+
* no account all fail the same way — `AuthError('invalid_code', 400)` — so
|
|
26
|
+
* the confirm step reveals nothing either. A password the pool refuses is
|
|
27
|
+
* `invalid_parameter` (422) and does NOT spend the code twice: the policy
|
|
28
|
+
* is the caller's to pre-check before calling.
|
|
29
|
+
*
|
|
30
|
+
* ```ts
|
|
31
|
+
* // POST /auth/password-reset
|
|
32
|
+
* await requestPasswordReset({
|
|
33
|
+
* email: body.email,
|
|
34
|
+
* store,
|
|
35
|
+
* eligible: (email) => accounts.isActive(email),
|
|
36
|
+
* send: ({ email, code }) => notify.sendNow({ to: email, template: 'password_reset', data: { code, url: resetUrl(email, code) } }),
|
|
37
|
+
* });
|
|
38
|
+
* return { sent: true };
|
|
39
|
+
*
|
|
40
|
+
* // POST /auth/password-reset/confirm
|
|
41
|
+
* await resetPasswordWithCode({ email: body.email, code: body.code, newPassword: body.password, store, eligible });
|
|
42
|
+
* const tokens = await signInWithPassword({ email: body.email, password: body.password });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
import { AdminSetUserPasswordCommand, AdminUserGlobalSignOutCommand } from '@aws-sdk/client-cognito-identity-provider';
|
|
46
|
+
import { loadAuthServerConfig } from './config.js';
|
|
47
|
+
import { getCognitoClient } from './cognito-client.js';
|
|
48
|
+
import { AuthError, mapProviderError } from './errors.js';
|
|
49
|
+
import { globalSignOut } from './revoke.js';
|
|
50
|
+
import { signInWithPassword } from './sign-in.js';
|
|
51
|
+
import { requestVerificationCode, verifyVerificationCode } from './verification.js';
|
|
52
|
+
/** Default store slot of a reset code — never the slot of a sign-up or sign-in code for the same address. */
|
|
53
|
+
export function passwordResetIdentifier(email) {
|
|
54
|
+
return `password_reset:${email}`;
|
|
55
|
+
}
|
|
56
|
+
/** Codes are kept on the `email` channel (the stores' channel list is closed). */
|
|
57
|
+
const CHANNEL = 'email';
|
|
58
|
+
const DEFAULT_TTL_SECONDS = 15 * 60;
|
|
59
|
+
const normalize = (email) => email.trim().toLowerCase();
|
|
60
|
+
const refusal = () => new AuthError('invalid_code', 'Invalid or expired reset code', 400);
|
|
61
|
+
/** Step 1 — mint and deliver a code. `sent: false` = not eligible: answer the client the same way. */
|
|
62
|
+
export async function requestPasswordReset(input) {
|
|
63
|
+
const email = normalize(input.email);
|
|
64
|
+
if (input.eligible && !(await input.eligible(email)))
|
|
65
|
+
return { sent: false };
|
|
66
|
+
const { code, expiresAt } = await requestVerificationCode({
|
|
67
|
+
channel: CHANNEL,
|
|
68
|
+
identifier: (input.identifier ?? passwordResetIdentifier)(email),
|
|
69
|
+
store: input.store,
|
|
70
|
+
ttlSeconds: input.ttlSeconds ?? DEFAULT_TTL_SECONDS,
|
|
71
|
+
...(input.maxAttempts !== undefined ? { maxAttempts: input.maxAttempts } : {}),
|
|
72
|
+
...(input.length !== undefined ? { length: input.length } : {}),
|
|
73
|
+
});
|
|
74
|
+
await input.send({ email, code, expiresAt });
|
|
75
|
+
return { sent: true };
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Step 2 — spend the code, set the new password, sign the account out
|
|
79
|
+
* everywhere. Throws `AuthError('invalid_code', 400)` for any refusal,
|
|
80
|
+
* `invalid_parameter` (422) for a password the pool refuses.
|
|
81
|
+
*/
|
|
82
|
+
export async function resetPasswordWithCode(input) {
|
|
83
|
+
const email = normalize(input.email);
|
|
84
|
+
const code = input.code.trim();
|
|
85
|
+
// Before the code is spent — and garbage never burns an attempt.
|
|
86
|
+
if (!/^\d{4,10}$/.test(code))
|
|
87
|
+
throw refusal();
|
|
88
|
+
if (input.eligible && !(await input.eligible(email)))
|
|
89
|
+
throw refusal();
|
|
90
|
+
try {
|
|
91
|
+
await verifyVerificationCode({ channel: CHANNEL, identifier: (input.identifier ?? passwordResetIdentifier)(email), code, store: input.store });
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
throw refusal();
|
|
95
|
+
}
|
|
96
|
+
// The account may have changed since the code was mailed (suspended, moved to another app).
|
|
97
|
+
if (input.eligible && !(await input.eligible(email)))
|
|
98
|
+
throw refusal();
|
|
99
|
+
const config = input.config ?? loadAuthServerConfig();
|
|
100
|
+
const client = getCognitoClient(config.region, config.endpoint);
|
|
101
|
+
try {
|
|
102
|
+
await client.send(new AdminSetUserPasswordCommand({ UserPoolId: config.userPoolId, Username: email, Password: input.newPassword, Permanent: true }));
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
if (err?.name === 'UserNotFoundException')
|
|
106
|
+
throw refusal();
|
|
107
|
+
throw mapProviderError(err, 'reset_password_failed', 400);
|
|
108
|
+
}
|
|
109
|
+
if (input.signOutEverywhere !== false)
|
|
110
|
+
await signOutEverywhere(email, input.newPassword, config);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Revoke every refresh token of the account. `AdminUserGlobalSignOut`
|
|
114
|
+
* (granted to the Lambda role by VentureKit's app stack) works for any
|
|
115
|
+
* account, MFA included. A stack deployed before that grant answers
|
|
116
|
+
* AccessDenied: then sign in once with the new password and sign out with
|
|
117
|
+
* that access token. Best-effort, like every sign-out: the password has
|
|
118
|
+
* already changed.
|
|
119
|
+
*/
|
|
120
|
+
async function signOutEverywhere(email, password, config) {
|
|
121
|
+
const client = getCognitoClient(config.region, config.endpoint);
|
|
122
|
+
try {
|
|
123
|
+
await client.send(new AdminUserGlobalSignOutCommand({ UserPoolId: config.userPoolId, Username: email }));
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
catch (err) {
|
|
127
|
+
const name = err?.name ?? '';
|
|
128
|
+
if (!/AccessDenied|NotAuthorized/i.test(name)) {
|
|
129
|
+
console.warn('[@venturekit/auth/server] sign-out everywhere after a password reset failed (ignored):', err);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
try {
|
|
134
|
+
const tokens = await signInWithPassword({ email, password }, config);
|
|
135
|
+
await globalSignOut(tokens.accessToken, config);
|
|
136
|
+
}
|
|
137
|
+
catch (err) {
|
|
138
|
+
console.warn('[@venturekit/auth/server] sign-out everywhere after a password reset failed (ignored):', err);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=password-reset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"password-reset.js","sourceRoot":"","sources":["../../src/server/password-reset.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,OAAO,EAAE,2BAA2B,EAAE,6BAA6B,EAAE,MAAM,2CAA2C,CAAC;AAEvH,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAA8B,MAAM,mBAAmB,CAAC;AAIhH,6GAA6G;AAC7G,MAAM,UAAU,uBAAuB,CAAC,KAAa;IACnD,OAAO,kBAAkB,KAAK,EAAE,CAAC;AACnC,CAAC;AAED,kFAAkF;AAClF,MA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OAAO,CAAC,IAAI,CAAC,wFAAwF,EAAE,GAAG,CAAC,CAAC;IAC9G,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session refresh / sign-out route factory.
|
|
3
|
+
*
|
|
4
|
+
* Emits two Lambda handlers for ONE session — the default one, or an
|
|
5
|
+
* app's own (`CookieOptions.names` / `path` / `refreshPath`, see
|
|
6
|
+
* cookies.ts "One session per app"):
|
|
7
|
+
*
|
|
8
|
+
* - `refresh` — `POST <refreshPath>/refresh`. Swaps the refresh cookie
|
|
9
|
+
* for fresh id / access cookies (Cognito does not rotate the refresh
|
|
10
|
+
* token, so the refresh cookie keeps the lifetime sign-in gave it).
|
|
11
|
+
* No refresh cookie → `401`. A dead refresh token (expired, revoked,
|
|
12
|
+
* signed out everywhere) clears this session's cookies AND answers
|
|
13
|
+
* `401`, so the client goes straight to its sign-in page.
|
|
14
|
+
* - `logout` — `POST <refreshPath>/logout`. Revokes the refresh token
|
|
15
|
+
* (best-effort) and clears this session's cookies — and only this
|
|
16
|
+
* session's: another app's session in the same browser stays signed
|
|
17
|
+
* in. Always `200 { success: true }`.
|
|
18
|
+
*
|
|
19
|
+
* Both routes must live under the refresh cookie's Path, or the browser
|
|
20
|
+
* never sends it to them. They are public (no `scopes`): the refresh
|
|
21
|
+
* cookie is the credential. Add a rate limiter through `middleware`.
|
|
22
|
+
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* // src/lib/admin-session.ts
|
|
25
|
+
* export const adminSession = createSessionRoutes({
|
|
26
|
+
* cookieOptions: (ctx) => ({
|
|
27
|
+
* names: sessionCookieNames('admin'),
|
|
28
|
+
* path: '/admin',
|
|
29
|
+
* refreshPath: '/admin/auth',
|
|
30
|
+
* persistent: false,
|
|
31
|
+
* domain: cookieDomainFor(getRequestHost(ctx)),
|
|
32
|
+
* }),
|
|
33
|
+
* });
|
|
34
|
+
* // src/routes/admin/auth/refresh/post.ts
|
|
35
|
+
* export const main = adminSession.refresh;
|
|
36
|
+
* // src/routes/admin/auth/logout/post.ts
|
|
37
|
+
* export const main = adminSession.logout;
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
import type { APIGatewayProxyEventV2, APIGatewayProxyResultV2, Context as LambdaContext } from 'aws-lambda';
|
|
41
|
+
import { type Middleware, type RequestContext } from '@venturekit/runtime';
|
|
42
|
+
import { type CookieOptions } from './cookies.js';
|
|
43
|
+
import { type AuthServerConfig } from './config.js';
|
|
44
|
+
export interface SessionRoutesOptions {
|
|
45
|
+
/**
|
|
46
|
+
* The session's cookies — names, paths, Domain, persistence — exactly as
|
|
47
|
+
* sign-in sets them (a clear only deletes a cookie whose Domain + Path
|
|
48
|
+
* match). A function resolves them per request (Domain by host).
|
|
49
|
+
* `persistent` also decides whether refreshed id / access cookies keep
|
|
50
|
+
* a `Max-Age`.
|
|
51
|
+
*/
|
|
52
|
+
cookieOptions?: CookieOptions | ((ctx: RequestContext) => CookieOptions);
|
|
53
|
+
/** Explicit Cognito config; defaults to env-var loading per request. */
|
|
54
|
+
config?: AuthServerConfig;
|
|
55
|
+
/** Extra middleware for both routes (rate limiting, CORS, …). */
|
|
56
|
+
middleware?: Middleware<RequestContext>[];
|
|
57
|
+
}
|
|
58
|
+
export interface SessionRoutes {
|
|
59
|
+
refresh: (event: APIGatewayProxyEventV2, context: LambdaContext) => Promise<APIGatewayProxyResultV2>;
|
|
60
|
+
logout: (event: APIGatewayProxyEventV2, context: LambdaContext) => Promise<APIGatewayProxyResultV2>;
|
|
61
|
+
}
|
|
62
|
+
export declare function createSessionRoutes(options?: SessionRoutesOptions): SessionRoutes;
|
|
63
|
+
//# sourceMappingURL=session-routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-routes.d.ts","sourceRoot":"","sources":["../../src/server/session-routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,OAAO,KAAK,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,YAAY,CAAC;AAC5G,OAAO,EACL,KAAK,UAAU,EAEf,KAAK,cAAc,EAMpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,aAAa,EAAqE,MAAM,cAAc,CAAC;AACrH,OAAO,EAAwB,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAI1E,MAAM,WAAW,oBAAoB;IACnC;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,aAAa,GAAG,CAAC,CAAC,GAAG,EAAE,cAAc,KAAK,aAAa,CAAC,CAAC;IACzE,wEAAwE;IACxE,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,iEAAiE;IACjE,UAAU,CAAC,EAAE,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC;CAC3C;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,CAAC,KAAK,EAAE,sBAAsB,EAAE,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACrG,MAAM,EAAE,CAAC,KAAK,EAAE,sBAAsB,EAAE,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,uBAAuB,CAAC,CAAC;CACrG;AAED,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,oBAAyB,GAAG,aAAa,CA4CrF"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { UnauthorizedError, errorResponse, handler, rawResult, setCookie, } from '@venturekit/runtime';
|
|
2
|
+
import { buildClearSessionCookies, buildSessionCookies, readSessionCookies } from './cookies.js';
|
|
3
|
+
import { loadAuthServerConfig } from './config.js';
|
|
4
|
+
import { refreshSession } from './refresh.js';
|
|
5
|
+
import { revokeRefreshToken } from './revoke.js';
|
|
6
|
+
export function createSessionRoutes(options = {}) {
|
|
7
|
+
const cookieOptionsFor = (ctx) => typeof options.cookieOptions === 'function' ? options.cookieOptions(ctx) : (options.cookieOptions ?? {});
|
|
8
|
+
const configFor = () => options.config ?? loadAuthServerConfig();
|
|
9
|
+
const middleware = options.middleware ?? [];
|
|
10
|
+
const refresh = handler(async (_body, ctx) => {
|
|
11
|
+
const cookieOptions = cookieOptionsFor(ctx);
|
|
12
|
+
const { refreshToken } = readSessionCookies(ctx.rawEvent, cookieOptions);
|
|
13
|
+
if (!refreshToken)
|
|
14
|
+
throw new UnauthorizedError('No refresh token');
|
|
15
|
+
let tokens;
|
|
16
|
+
try {
|
|
17
|
+
tokens = await refreshSession(refreshToken, configFor());
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
// A thrown error drops the cookies set on `ctx`, so the clear rides
|
|
21
|
+
// a raw 401 in the runtime's error envelope instead.
|
|
22
|
+
for (const cookie of buildClearSessionCookies(cookieOptions))
|
|
23
|
+
setCookie(ctx, cookie);
|
|
24
|
+
return rawResult(errorResponse(new UnauthorizedError('Session expired — please sign in again'), {
|
|
25
|
+
requestId: ctx.requestId,
|
|
26
|
+
logError: false,
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
// `refreshToken: ''` → the refresh cookie is left as it is.
|
|
30
|
+
for (const cookie of buildSessionCookies({ ...tokens, refreshToken: '' }, cookieOptions))
|
|
31
|
+
setCookie(ctx, cookie);
|
|
32
|
+
return { expiresIn: tokens.expiresIn };
|
|
33
|
+
}, { status: 200, middleware });
|
|
34
|
+
const logout = handler(async (_body, ctx) => {
|
|
35
|
+
const cookieOptions = cookieOptionsFor(ctx);
|
|
36
|
+
const { refreshToken } = readSessionCookies(ctx.rawEvent, cookieOptions);
|
|
37
|
+
if (refreshToken)
|
|
38
|
+
await revokeRefreshToken(refreshToken, configFor());
|
|
39
|
+
for (const cookie of buildClearSessionCookies(cookieOptions))
|
|
40
|
+
setCookie(ctx, cookie);
|
|
41
|
+
return { success: true };
|
|
42
|
+
}, { status: 200, middleware });
|
|
43
|
+
return { refresh, logout };
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=session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IAEF,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AAC7B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@venturekit/auth",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.46",
|
|
4
4
|
"description": "Authentication and authorization for VentureKit",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -41,14 +41,14 @@
|
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@venturekit/core": "0.0.
|
|
44
|
+
"@venturekit/core": "0.0.46",
|
|
45
45
|
"@aws-sdk/client-cognito-identity-provider": "^3.1126.0",
|
|
46
46
|
"@aws-sdk/client-secrets-manager": "^3.1126.0",
|
|
47
47
|
"aws-jwt-verify": "^4.0.1"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@venturekit/data": "0.0.
|
|
51
|
-
"@venturekit/runtime": "0.0.
|
|
50
|
+
"@venturekit/data": "0.0.46",
|
|
51
|
+
"@venturekit/runtime": "0.0.46"
|
|
52
52
|
},
|
|
53
53
|
"peerDependenciesMeta": {
|
|
54
54
|
"@venturekit/data": {
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
}
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@venturekit/data": "0.0.
|
|
63
|
-
"@venturekit/runtime": "0.0.
|
|
62
|
+
"@venturekit/data": "0.0.46",
|
|
63
|
+
"@venturekit/runtime": "0.0.46",
|
|
64
64
|
"@types/aws-lambda": "^8.10.163",
|
|
65
65
|
"@types/node": "^26.5.1",
|
|
66
66
|
"typescript": "^5.3.0"
|