@venturekit/auth 0.0.0-dev.20260627215235 → 0.0.0-dev.20260701113915
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/{migrations → dist/migrations}/vk_auth_001_verification_codes.sql +7 -4
- package/dist/server/cookies.d.ts +21 -7
- package/dist/server/cookies.d.ts.map +1 -1
- package/dist/server/cookies.js +22 -6
- package/dist/server/cookies.js.map +1 -1
- package/dist/server/forgot-password.js +0 -1
- package/dist/server/forgot-password.js.map +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/middleware.d.ts +35 -0
- package/dist/server/middleware.d.ts.map +1 -1
- package/dist/server/middleware.js +50 -10
- package/dist/server/middleware.js.map +1 -1
- package/dist/server/revoke.js +0 -1
- package/dist/server/revoke.js.map +1 -1
- package/package.json +12 -8
- package/src/migrations/vk_auth_001_verification_codes.sql +55 -0
- package/LICENSE +0 -191
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
-- vk_auth_001_verification_codes.sql
|
|
2
2
|
--
|
|
3
|
-
-- Owned by `@venturekit/auth`.
|
|
4
|
-
--
|
|
3
|
+
-- Owned by `@venturekit/auth`. Creates the `vk_verification_codes`
|
|
4
|
+
-- table backing `VerificationCodeStore` (used by the OTP gating on
|
|
5
|
+
-- self-service sign-up + sign-in / passwordless). The table is
|
|
6
|
+
-- `vk_`-prefixed per VentureKit's "package-owned tables are prefixed"
|
|
7
|
+
-- convention; consumer-side stores must query `vk_verification_codes`.
|
|
5
8
|
--
|
|
6
9
|
-- Rows are pre-Cognito state — created BEFORE a user exists in either
|
|
7
10
|
-- Cognito or any consumer-side `users` mirror. The `identifier` is the
|
|
@@ -31,7 +34,7 @@
|
|
|
31
34
|
-- expectation is that those projects will then leave their old
|
|
32
35
|
-- migration file in place but stop hand-maintaining the schema here.
|
|
33
36
|
|
|
34
|
-
CREATE TABLE IF NOT EXISTS
|
|
37
|
+
CREATE TABLE IF NOT EXISTS vk_verification_codes (
|
|
35
38
|
channel TEXT NOT NULL,
|
|
36
39
|
identifier TEXT NOT NULL,
|
|
37
40
|
code_hash TEXT NOT NULL,
|
|
@@ -49,4 +52,4 @@ CREATE TABLE IF NOT EXISTS verification_codes (
|
|
|
49
52
|
);
|
|
50
53
|
|
|
51
54
|
CREATE INDEX IF NOT EXISTS idx_verification_codes_expires_at
|
|
52
|
-
ON
|
|
55
|
+
ON vk_verification_codes (expires_at);
|
package/dist/server/cookies.d.ts
CHANGED
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
* - `HttpOnly` — JS in the browser cannot read these. The browser
|
|
7
7
|
* attaches them automatically when fetching with
|
|
8
8
|
* `credentials: 'include'`.
|
|
9
|
-
* - `Secure` — set when {@link CookieOptions.secure} is true
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* - `Secure` — set when {@link CookieOptions.secure} is true. Defaults to
|
|
10
|
+
* ON everywhere except explicit local dev (`VENTURE_LOCAL === 'true'`,
|
|
11
|
+
* set by `vk dev`), so production cookies are always `Secure` while
|
|
12
|
+
* localhost over plain HTTP keeps working.
|
|
12
13
|
* - `SameSite=Lax` for the id/access cookies, `SameSite=Strict` for
|
|
13
14
|
* the refresh cookie. The refresh cookie is only ever sent to the
|
|
14
15
|
* paths under {@link CookieOptions.refreshPath} (default `/auth`)
|
|
@@ -34,8 +35,8 @@ export interface SessionTokens {
|
|
|
34
35
|
}
|
|
35
36
|
export interface CookieOptions {
|
|
36
37
|
/**
|
|
37
|
-
* Emit the `Secure` flag. Defaults to
|
|
38
|
-
* `
|
|
38
|
+
* Emit the `Secure` flag. Defaults to ON unless `VENTURE_LOCAL === 'true'`
|
|
39
|
+
* (local dev, set by `vk dev`).
|
|
39
40
|
*/
|
|
40
41
|
secure?: boolean;
|
|
41
42
|
/**
|
|
@@ -48,6 +49,19 @@ export interface CookieOptions {
|
|
|
48
49
|
*/
|
|
49
50
|
refreshMaxAgeSeconds?: number;
|
|
50
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Default value for the cookie `Secure` flag.
|
|
54
|
+
*
|
|
55
|
+
* Secure is ON everywhere EXCEPT explicit local development, detected via
|
|
56
|
+
* `VENTURE_LOCAL === 'true'` (set by `vk dev`). A deployed Lambda never sets
|
|
57
|
+
* `VENTURE_LOCAL`, so production cookies always get `Secure`.
|
|
58
|
+
*
|
|
59
|
+
* This deliberately does NOT key off `NODE_ENV`: the AWS Lambda runtime does
|
|
60
|
+
* not set `NODE_ENV=production`, and the infra layer historically did not
|
|
61
|
+
* inject it, so the old `NODE_ENV === 'production'` default silently shipped
|
|
62
|
+
* session cookies WITHOUT `Secure` in production.
|
|
63
|
+
*/
|
|
64
|
+
export declare function defaultSecure(): boolean;
|
|
51
65
|
/**
|
|
52
66
|
* Build the `Set-Cookie` header values to attach to a sign-in / refresh
|
|
53
67
|
* response. Returns an array — API Gateway v2 supports multi-valued
|
|
@@ -75,8 +89,8 @@ export declare function buildClearSessionCookies(options?: CookieOptions): strin
|
|
|
75
89
|
export declare function oauthStateCookieName(provider: string): string;
|
|
76
90
|
export interface OAuthStateCookieOptions {
|
|
77
91
|
/**
|
|
78
|
-
* Emit the `Secure` flag. Defaults to
|
|
79
|
-
* `
|
|
92
|
+
* Emit the `Secure` flag. Defaults to ON unless `VENTURE_LOCAL === 'true'`
|
|
93
|
+
* (local dev, set by `vk dev`).
|
|
80
94
|
*/
|
|
81
95
|
secure?: boolean;
|
|
82
96
|
/**
|
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,eAAO,MAAM,eAAe,gBAAgB,CAAC;AAC7C,e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AI,CAAC,uBAAuB,EAAE,QAAQ,GAAG,MAAM,CAAC,GACzD,MAAM,CAQR;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,eAAe,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,EAC1C,IAAI,EAAE,MAAM,GACX,MAAM,GAAG,IAAI,CAef"}
|
package/dist/server/cookies.js
CHANGED
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
* - `HttpOnly` — JS in the browser cannot read these. The browser
|
|
7
7
|
* attaches them automatically when fetching with
|
|
8
8
|
* `credentials: 'include'`.
|
|
9
|
-
* - `Secure` — set when {@link CookieOptions.secure} is true
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* - `Secure` — set when {@link CookieOptions.secure} is true. Defaults to
|
|
10
|
+
* ON everywhere except explicit local dev (`VENTURE_LOCAL === 'true'`,
|
|
11
|
+
* set by `vk dev`), so production cookies are always `Secure` while
|
|
12
|
+
* localhost over plain HTTP keeps working.
|
|
12
13
|
* - `SameSite=Lax` for the id/access cookies, `SameSite=Strict` for
|
|
13
14
|
* the refresh cookie. The refresh cookie is only ever sent to the
|
|
14
15
|
* paths under {@link CookieOptions.refreshPath} (default `/auth`)
|
|
@@ -25,9 +26,24 @@ export const ID_TOKEN_COOKIE = 'vk_id_token';
|
|
|
25
26
|
export const ACCESS_TOKEN_COOKIE = 'vk_access_token';
|
|
26
27
|
export const REFRESH_TOKEN_COOKIE = 'vk_refresh_token';
|
|
27
28
|
const REFRESH_MAX_AGE_SECONDS = 30 * 24 * 60 * 60; // 30 days
|
|
29
|
+
/**
|
|
30
|
+
* Default value for the cookie `Secure` flag.
|
|
31
|
+
*
|
|
32
|
+
* Secure is ON everywhere EXCEPT explicit local development, detected via
|
|
33
|
+
* `VENTURE_LOCAL === 'true'` (set by `vk dev`). A deployed Lambda never sets
|
|
34
|
+
* `VENTURE_LOCAL`, so production cookies always get `Secure`.
|
|
35
|
+
*
|
|
36
|
+
* This deliberately does NOT key off `NODE_ENV`: the AWS Lambda runtime does
|
|
37
|
+
* not set `NODE_ENV=production`, and the infra layer historically did not
|
|
38
|
+
* inject it, so the old `NODE_ENV === 'production'` default silently shipped
|
|
39
|
+
* session cookies WITHOUT `Secure` in production.
|
|
40
|
+
*/
|
|
41
|
+
export function defaultSecure() {
|
|
42
|
+
return process.env.VENTURE_LOCAL !== 'true';
|
|
43
|
+
}
|
|
28
44
|
function resolve(opts) {
|
|
29
45
|
return {
|
|
30
|
-
secure: opts?.secure ??
|
|
46
|
+
secure: opts?.secure ?? defaultSecure(),
|
|
31
47
|
refreshPath: opts?.refreshPath ?? '/auth',
|
|
32
48
|
refreshMaxAgeSeconds: opts?.refreshMaxAgeSeconds ?? REFRESH_MAX_AGE_SECONDS,
|
|
33
49
|
};
|
|
@@ -124,7 +140,7 @@ export function oauthStateCookieName(provider) {
|
|
|
124
140
|
* ```
|
|
125
141
|
*/
|
|
126
142
|
export function buildOAuthStateCookie(provider, value, options) {
|
|
127
|
-
const secure = options?.secure ??
|
|
143
|
+
const secure = options?.secure ?? defaultSecure();
|
|
128
144
|
return buildSetCookie(oauthStateCookieName(provider), value, {
|
|
129
145
|
path: options?.path ?? '/auth',
|
|
130
146
|
maxAge: options?.maxAgeSeconds ?? OAUTH_STATE_MAX_AGE_SECONDS,
|
|
@@ -136,7 +152,7 @@ export function buildOAuthStateCookie(provider, value, options) {
|
|
|
136
152
|
* flow so a stale `state` can't be replayed.
|
|
137
153
|
*/
|
|
138
154
|
export function clearOAuthStateCookie(provider, options) {
|
|
139
|
-
const secure = options?.secure ??
|
|
155
|
+
const secure = options?.secure ?? defaultSecure();
|
|
140
156
|
return buildSetCookie(oauthStateCookieName(provider), '', { path: options?.path ?? '/auth', maxAge: 0 }, secure);
|
|
141
157
|
}
|
|
142
158
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cookies.js","sourceRoot":"","sources":["../../src/server/cookies.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version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IAAI,CAAC,eAAe;QAAE,OAAO,IAAI,CAAC;IAClC,MAAM,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC;IAC1B,IAAI,KAAK,GAAkB,IAAI,CAAC;IAChC,KAAK,MAAM,IAAI,IAAI,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QAC9C,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAC5B,IAAI,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YAC/B,IAAI,CAAC;gBACH,KAAK,GAAG,kBAAkB,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;YAC3D,CAAC;YAAC,MAAM,CAAC;gBACP,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -88,7 +88,6 @@ export async function forgotPassword(input, config = loadAuthServerConfig()) {
|
|
|
88
88
|
await input.onSendCode(email, code);
|
|
89
89
|
}
|
|
90
90
|
else {
|
|
91
|
-
// eslint-disable-next-line no-console
|
|
92
91
|
console.log(`[dev] Forgot-password code for ${email}: ${code} (expires in 10 min)`);
|
|
93
92
|
}
|
|
94
93
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forgot-password.js","sourceRoot":"","sources":["../../src/server/forgot-password.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EACL,2BAA2B,EAC3B,4BAA4B,EAC5B,qBAAqB,GAEtB,MAAM,2CAA2C,CAAC;AAEnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB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;YACb,MAAM,gBAAgB,CAAC,GAAG,EAAE,gCAAgC,CAAC,CAAC;QAChE,CAAC;QACD,OAAO;IACT,CAAC;IAED,0DAA0D;IAC1D,MAAM,MAAM,GAAG,gBAAgB,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IAChE,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,IAAI,CACf,IAAI,4BAA4B,CAAC;YAC/B,QAAQ,EAAE,MAAM,CAAC,WAAW;YAC5B,QAAQ,EAAE,KAAK;YACf,gBAAgB,EAAE,KAAK,CAAC,IAAI;YAC5B,QAAQ,EAAE,KAAK,CAAC,WAAW;SAC5B,CAAC,CACH,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,gBAAgB,CAAC,GAAG,EAAE,gCAAgC,CAAC,CAAC;IAChE,CAAC;AACH,CAAC"}
|
package/dist/server/index.d.ts
CHANGED
|
@@ -44,7 +44,7 @@ export { verifyAndDecode } from './verify.js';
|
|
|
44
44
|
export type { SessionTokens, CookieOptions, OAuthStateCookieOptions, } from './cookies.js';
|
|
45
45
|
export { ID_TOKEN_COOKIE, ACCESS_TOKEN_COOKIE, REFRESH_TOKEN_COOKIE, buildSessionCookies, buildClearSessionCookies, readCookieFromHeader, buildOAuthStateCookie, clearOAuthStateCookie, oauthStateCookieName, } from './cookies.js';
|
|
46
46
|
export type { CookieAuthMiddlewareOptions } from './middleware.js';
|
|
47
|
-
export { cookieAuthMiddleware, extractToken } from './middleware.js';
|
|
47
|
+
export { cookieAuthMiddleware, extractToken, defaultScopeMapper } from './middleware.js';
|
|
48
48
|
export type { FederatedAuthRoutes, FederatedAuthRoutesOptions, FederatedCallbackBody, FederatedCallbackResult, FederatedOnSignInArgs, FederatedOnSignInResult, FederatedStartBody, } from './federated-routes.js';
|
|
49
49
|
export { createFederatedAuthRoutes } from './federated-routes.js';
|
|
50
50
|
export type { FederatedProvider, FederatedProfile, FederatedProviderCredentials, SignInAsFederatedUserInput, BuildAuthorizeUrlInput, ExchangeAuthorizationCodeInput, } from './federated.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,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD,YAAY,EACV,eAAe,EACf,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,6BAA6B,EAC7B,6BAA6B,GAC9B,MAAM,gBAAgB,CAAC;AAExB,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,YAAY,EACV,oBAAoB,EACpB,qBAAqB,EACrB,0BAA0B,GAC3B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,eAAe,EACf,yBAAyB,EACzB,gBAAgB,EAChB,eAAe,EACf,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAE1B,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,YAAY,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,YAAY,EACV,mBAAmB,EACnB,oBAAoB,EACpB,0BAA0B,E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AC;AAElE,YAAY,EACV,iBAAiB,EACjB,gBAAgB,EAChB,4BAA4B,EAC5B,0BAA0B,EAC1B,sBAAsB,EACtB,8BAA8B,GAC/B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,gCAAgC,EAChC,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AAExB,YAAY,EACV,mBAAmB,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"}
|
package/dist/server/index.js
CHANGED
|
@@ -33,7 +33,7 @@ export { changePassword } from './change-password.js';
|
|
|
33
33
|
export { forgotPassword, confirmForgotPassword } from './forgot-password.js';
|
|
34
34
|
export { verifyAndDecode } from './verify.js';
|
|
35
35
|
export { ID_TOKEN_COOKIE, ACCESS_TOKEN_COOKIE, REFRESH_TOKEN_COOKIE, buildSessionCookies, buildClearSessionCookies, readCookieFromHeader, buildOAuthStateCookie, clearOAuthStateCookie, oauthStateCookieName, } from './cookies.js';
|
|
36
|
-
export { cookieAuthMiddleware, extractToken } from './middleware.js';
|
|
36
|
+
export { cookieAuthMiddleware, extractToken, defaultScopeMapper } from './middleware.js';
|
|
37
37
|
export { createFederatedAuthRoutes } from './federated-routes.js';
|
|
38
38
|
export { loadFederatedProviderCredentials, generateOAuthState, verifyOAuthState, buildAuthorizeUrl, exchangeAuthorizationCode, signInAsFederatedUser, } from './federated.js';
|
|
39
39
|
export { generateVerificationCode, hashVerificationCode, requestVerificationCode, verifyVerificationCode, createInMemoryVerificationCodeStore, } from './verification.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,MAAM,aAAa,CAAC;AAGnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAOlD,OAAO,EACL,6BAA6B,EAC7B,6BAA6B,GAC9B,MAAM,gBAAgB,CAAC;AAGxB,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,MAAM,aAAa,CAAC;AAGjD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAQtD,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAG7E,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAO9C,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,wBAAwB,EACxB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,iBAAiB,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,MAAM,aAAa,CAAC;AAGnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAOlD,OAAO,EACL,6BAA6B,EAC7B,6BAA6B,GAC9B,MAAM,gBAAgB,CAAC;AAGxB,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,MAAM,aAAa,CAAC;AAGjD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAQtD,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAG7E,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAO9C,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,wBAAwB,EACxB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAWzF,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAUlE,OAAO,EACL,gCAAgC,EAChC,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AAUxB,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,uBAAuB,EACvB,sBAAsB,EACtB,mCAAmC,GACpC,MAAM,mBAAmB,CAAC"}
|
|
@@ -45,6 +45,16 @@ export interface CookieAuthMiddlewareOptions {
|
|
|
45
45
|
* tests lets you construct a middleware without touching env.
|
|
46
46
|
*/
|
|
47
47
|
config?: AuthServerConfig;
|
|
48
|
+
/**
|
|
49
|
+
* Map verified JWT claims to the scope strings the
|
|
50
|
+
* `handler({ scopes })` gate checks. Defaults to
|
|
51
|
+
* {@link defaultScopeMapper}, which unions the access-token `scope`
|
|
52
|
+
* claim with Cognito `cognito:groups` and a `custom:scopes`
|
|
53
|
+
* attribute — so id-token browser sessions (which carry no `scope`
|
|
54
|
+
* claim) can still satisfy scoped routes via group / attribute
|
|
55
|
+
* membership. Provide your own to map app-specific claims.
|
|
56
|
+
*/
|
|
57
|
+
scopeMapper?: (claims: Record<string, unknown>) => string[];
|
|
48
58
|
}
|
|
49
59
|
/**
|
|
50
60
|
* Build a `@venturekit/runtime` middleware that verifies a session JWT
|
|
@@ -73,4 +83,29 @@ export declare function cookieAuthMiddleware(options?: CookieAuthMiddlewareOptio
|
|
|
73
83
|
* {@link cookieAuthMiddleware} instead.
|
|
74
84
|
*/
|
|
75
85
|
export declare function extractToken(event: APIGatewayProxyEventV2, cookieName?: string): string | null;
|
|
86
|
+
/**
|
|
87
|
+
* Default claims→scopes mapper.
|
|
88
|
+
*
|
|
89
|
+
* Unions three sources so BOTH access-token and id-token sessions can
|
|
90
|
+
* satisfy the `handler({ scopes })` gate:
|
|
91
|
+
* - `scope` — space-separated, present on Cognito ACCESS tokens.
|
|
92
|
+
* - `cognito:groups` — `string[]` on both id and access tokens; group
|
|
93
|
+
* names double as coarse scopes (e.g. a `cms.admin` group satisfies
|
|
94
|
+
* `scopes: ['cms.admin']`).
|
|
95
|
+
* - `custom:scopes` — a custom user-pool attribute holding a space- or
|
|
96
|
+
* comma-separated scope list; the recommended way to attach scopes
|
|
97
|
+
* to id-token browser sessions, which otherwise carry no `scope`.
|
|
98
|
+
*
|
|
99
|
+
* De-duplicates and drops empties. Override via
|
|
100
|
+
* {@link CookieAuthMiddlewareOptions.scopeMapper} for app-specific claims.
|
|
101
|
+
*
|
|
102
|
+
* # id-token vs access-token (the A2 decision)
|
|
103
|
+
* The default {@link cookieAuthMiddleware} verifies ID tokens because the
|
|
104
|
+
* browser session cookie is an id token (it carries `email` + profile).
|
|
105
|
+
* ID tokens have no OAuth `scope`, so scope gating on id-token sessions
|
|
106
|
+
* MUST come from Cognito groups or a `custom:scopes` attribute — which
|
|
107
|
+
* this mapper reads out of the box. For service-to-service callers, use
|
|
108
|
+
* `cookieAuthMiddleware({ tokenUse: 'access' })` and the `scope` claim.
|
|
109
|
+
*/
|
|
110
|
+
export declare function defaultScopeMapper(claims: Record<string, unknown>): string[];
|
|
76
111
|
//# sourceMappingURL=middleware.d.ts.map
|
|
@@ -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;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,IAAI,GAAG,QAAQ,CAAC;IAC3B;;;;OAIG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAC;
|
|
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;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,IAAI,GAAG,QAAQ,CAAC;IAC3B;;;;OAIG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B;;;;;;;;OAQG;IACH,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,EAAE,CAAC;CAC7D;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,GAAE,2BAAgC,GACxC,UAAU,CAAC,cAAc,CAAC,CAkC5B;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,sBAAsB,EAC7B,UAAU,GAAE,MAAwB,GACnC,MAAM,GAAG,IAAI,CAoBf;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,MAAM,EAAE,CAiBV"}
|
|
@@ -46,6 +46,7 @@ import { loadAuthServerConfig } from './config.js';
|
|
|
46
46
|
export function cookieAuthMiddleware(options = {}) {
|
|
47
47
|
const cookieName = options.cookieName ?? ID_TOKEN_COOKIE;
|
|
48
48
|
const tokenUse = options.tokenUse ?? 'id';
|
|
49
|
+
const scopeMapper = options.scopeMapper ?? defaultScopeMapper;
|
|
49
50
|
// Resolve config lazily so a route module can import the middleware
|
|
50
51
|
// factory at file-load time without the env vars being set (tests,
|
|
51
52
|
// local type-only imports, etc.). The first actual request resolves
|
|
@@ -70,7 +71,7 @@ export function cookieAuthMiddleware(options = {}) {
|
|
|
70
71
|
...(cfg.endpoint ? { endpoint: cfg.endpoint } : {}),
|
|
71
72
|
});
|
|
72
73
|
if (claims) {
|
|
73
|
-
ctx.user = claimsToUserContext(claims);
|
|
74
|
+
ctx.user = claimsToUserContext(claims, scopeMapper);
|
|
74
75
|
}
|
|
75
76
|
}
|
|
76
77
|
return next();
|
|
@@ -103,17 +104,56 @@ export function extractToken(event, cookieName = ID_TOKEN_COOKIE) {
|
|
|
103
104
|
: (headers['cookie'] ?? headers['Cookie']);
|
|
104
105
|
return readCookieFromHeader(cookieHeader, cookieName);
|
|
105
106
|
}
|
|
106
|
-
|
|
107
|
+
/**
|
|
108
|
+
* Default claims→scopes mapper.
|
|
109
|
+
*
|
|
110
|
+
* Unions three sources so BOTH access-token and id-token sessions can
|
|
111
|
+
* satisfy the `handler({ scopes })` gate:
|
|
112
|
+
* - `scope` — space-separated, present on Cognito ACCESS tokens.
|
|
113
|
+
* - `cognito:groups` — `string[]` on both id and access tokens; group
|
|
114
|
+
* names double as coarse scopes (e.g. a `cms.admin` group satisfies
|
|
115
|
+
* `scopes: ['cms.admin']`).
|
|
116
|
+
* - `custom:scopes` — a custom user-pool attribute holding a space- or
|
|
117
|
+
* comma-separated scope list; the recommended way to attach scopes
|
|
118
|
+
* to id-token browser sessions, which otherwise carry no `scope`.
|
|
119
|
+
*
|
|
120
|
+
* De-duplicates and drops empties. Override via
|
|
121
|
+
* {@link CookieAuthMiddlewareOptions.scopeMapper} for app-specific claims.
|
|
122
|
+
*
|
|
123
|
+
* # id-token vs access-token (the A2 decision)
|
|
124
|
+
* The default {@link cookieAuthMiddleware} verifies ID tokens because the
|
|
125
|
+
* browser session cookie is an id token (it carries `email` + profile).
|
|
126
|
+
* ID tokens have no OAuth `scope`, so scope gating on id-token sessions
|
|
127
|
+
* MUST come from Cognito groups or a `custom:scopes` attribute — which
|
|
128
|
+
* this mapper reads out of the box. For service-to-service callers, use
|
|
129
|
+
* `cookieAuthMiddleware({ tokenUse: 'access' })` and the `scope` claim.
|
|
130
|
+
*/
|
|
131
|
+
export function defaultScopeMapper(claims) {
|
|
132
|
+
const out = new Set();
|
|
133
|
+
const addAll = (raw, splitter) => {
|
|
134
|
+
if (typeof raw === 'string') {
|
|
135
|
+
for (const s of raw.split(splitter))
|
|
136
|
+
if (s)
|
|
137
|
+
out.add(s);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
// Access-token scope claim (space-separated).
|
|
141
|
+
addAll(claims['scope'], / +/);
|
|
142
|
+
// Cognito groups (array on id + access tokens).
|
|
143
|
+
const groups = claims['cognito:groups'];
|
|
144
|
+
if (Array.isArray(groups)) {
|
|
145
|
+
for (const g of groups)
|
|
146
|
+
if (typeof g === 'string' && g)
|
|
147
|
+
out.add(g);
|
|
148
|
+
}
|
|
149
|
+
// custom:scopes attribute (space- or comma-separated).
|
|
150
|
+
addAll(claims['custom:scopes'], /[\s,]+/);
|
|
151
|
+
return [...out];
|
|
152
|
+
}
|
|
153
|
+
function claimsToUserContext(claims, scopeMapper = defaultScopeMapper) {
|
|
107
154
|
const sub = claims['sub'];
|
|
108
155
|
const email = claims['email'];
|
|
109
|
-
|
|
110
|
-
// carry scopes; if the app uses ID tokens, scope-based route gating
|
|
111
|
-
// should be backed by `custom:*` role/scope attributes on the user
|
|
112
|
-
// pool and mapped in a downstream mapper.
|
|
113
|
-
const scopeClaim = claims['scope'];
|
|
114
|
-
const scopes = typeof scopeClaim === 'string'
|
|
115
|
-
? scopeClaim.split(' ').filter(Boolean)
|
|
116
|
-
: [];
|
|
156
|
+
const scopes = scopeMapper(claims);
|
|
117
157
|
return {
|
|
118
158
|
id: typeof sub === 'string' ? sub : '',
|
|
119
159
|
email: typeof email === 'string' ? email : undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../src/server/middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAQH,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../src/server/middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAQH,OAAO,EAAE,eAAe,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{"version":3,"file":"revoke.js","sourceRoot":"","sources":["../../src/server/revoke.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAE/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,YAAoB,EACpB,SAA2B,oBAAoB,EAAE;IAEjD,MAAM,MAAM,GAAG,gBAAgB,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IAChE,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,IAAI,CACf,IAAI,kBAAkB,CAAC;YACrB,QAAQ,EAAE,MAAM,CAAC,WAAW;YAC5B,KAAK,EAAE,YAAY;SACpB,CAAC,CACH,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"revoke.js","sourceRoot":"","sources":["../../src/server/revoke.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAE/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,YAAoB,EACpB,SAA2B,oBAAoB,EAAE;IAEjD,MAAM,MAAM,GAAG,gBAAgB,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IAChE,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,IAAI,CACf,IAAI,kBAAkB,CAAC;YACrB,QAAQ,EAAE,MAAM,CAAC,WAAW;YAC5B,KAAK,EAAE,YAAY;SACpB,CAAC,CACH,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QAEb,OAAO,CAAC,IAAI,CAAC,kEAAkE,EAAE,GAAG,CAAC,CAAC;IACxF,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@venturekit/auth",
|
|
3
|
-
"version": "0.0.0-dev.
|
|
3
|
+
"version": "0.0.0-dev.20260701113915",
|
|
4
4
|
"description": "Authentication and authorization for VentureKit",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"files": [
|
|
9
9
|
"dist",
|
|
10
|
-
"migrations"
|
|
10
|
+
"src/migrations/*.sql"
|
|
11
11
|
],
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
|
-
"url": "https://github.com/venturekit-dev/venturekit.
|
|
14
|
+
"url": "https://github.com/venturekit-dev/venturekit.git",
|
|
15
15
|
"directory": "packages/auth"
|
|
16
16
|
},
|
|
17
|
+
"homepage": "https://venturekit.dev",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/venturekit-dev/venturekit/issues"
|
|
20
|
+
},
|
|
17
21
|
"publishConfig": {
|
|
18
22
|
"registry": "https://registry.npmjs.org",
|
|
19
23
|
"access": "public"
|
|
20
24
|
},
|
|
21
25
|
"license": "Apache-2.0",
|
|
22
26
|
"vk": {
|
|
23
|
-
"migrations": "migrations"
|
|
27
|
+
"migrations": "src/migrations"
|
|
24
28
|
},
|
|
25
29
|
"exports": {
|
|
26
30
|
".": {
|
|
@@ -33,13 +37,13 @@
|
|
|
33
37
|
}
|
|
34
38
|
},
|
|
35
39
|
"dependencies": {
|
|
36
|
-
"@venturekit/core": "0.0.0-dev.
|
|
40
|
+
"@venturekit/core": "0.0.0-dev.20260701113915",
|
|
37
41
|
"@aws-sdk/client-cognito-identity-provider": "^3.1068.0",
|
|
38
42
|
"@aws-sdk/client-secrets-manager": "^3.1068.0",
|
|
39
43
|
"aws-jwt-verify": "^4.0.1"
|
|
40
44
|
},
|
|
41
45
|
"peerDependencies": {
|
|
42
|
-
"@venturekit/runtime": "0.0.0-dev.
|
|
46
|
+
"@venturekit/runtime": "0.0.0-dev.20260701113915"
|
|
43
47
|
},
|
|
44
48
|
"peerDependenciesMeta": {
|
|
45
49
|
"@venturekit/runtime": {
|
|
@@ -47,13 +51,13 @@
|
|
|
47
51
|
}
|
|
48
52
|
},
|
|
49
53
|
"devDependencies": {
|
|
50
|
-
"@venturekit/runtime": "0.0.0-dev.
|
|
54
|
+
"@venturekit/runtime": "0.0.0-dev.20260701113915",
|
|
51
55
|
"@types/aws-lambda": "^8.10.131",
|
|
52
56
|
"@types/node": "^25.6.0",
|
|
53
57
|
"typescript": "^5.3.0"
|
|
54
58
|
},
|
|
55
59
|
"scripts": {
|
|
56
|
-
"build": "tsc",
|
|
60
|
+
"build": "tsc && node -e \"require('fs').cpSync('src/migrations','dist/migrations',{recursive:true})\"",
|
|
57
61
|
"dev": "tsc --watch",
|
|
58
62
|
"clean": "rm -rf dist"
|
|
59
63
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
-- vk_auth_001_verification_codes.sql
|
|
2
|
+
--
|
|
3
|
+
-- Owned by `@venturekit/auth`. Creates the `vk_verification_codes`
|
|
4
|
+
-- table backing `VerificationCodeStore` (used by the OTP gating on
|
|
5
|
+
-- self-service sign-up + sign-in / passwordless). The table is
|
|
6
|
+
-- `vk_`-prefixed per VentureKit's "package-owned tables are prefixed"
|
|
7
|
+
-- convention; consumer-side stores must query `vk_verification_codes`.
|
|
8
|
+
--
|
|
9
|
+
-- Rows are pre-Cognito state — created BEFORE a user exists in either
|
|
10
|
+
-- Cognito or any consumer-side `users` mirror. The `identifier` is the
|
|
11
|
+
-- email or E.164 phone number the code was sent to; `channel` is the
|
|
12
|
+
-- delivery surface.
|
|
13
|
+
--
|
|
14
|
+
-- Storage shape:
|
|
15
|
+
-- - `code_hash` is SHA-256 of the plaintext code (hex). Plaintext
|
|
16
|
+
-- never lands in the DB so a future leak still requires brute
|
|
17
|
+
-- force against the (short) TTL.
|
|
18
|
+
-- - `expires_at` is the wall-clock cutoff after which the
|
|
19
|
+
-- `verifyVerificationCode` helper deletes the row and surfaces
|
|
20
|
+
-- `verification_failed`.
|
|
21
|
+
-- - `attempts` is incremented on every wrong-code submission;
|
|
22
|
+
-- once it reaches `max_attempts` the row is deleted (forces the
|
|
23
|
+
-- user to request a fresh code).
|
|
24
|
+
--
|
|
25
|
+
-- Channel typing: stored as TEXT + CHECK rather than a Postgres enum
|
|
26
|
+
-- so this migration does not depend on `@venturekit/notify`'s
|
|
27
|
+
-- `notify_channel` enum (auth must be usable without notify — e.g. a
|
|
28
|
+
-- project that ships its own delivery layer). Add new values here when
|
|
29
|
+
-- the auth package learns to dispatch over them.
|
|
30
|
+
--
|
|
31
|
+
-- Idempotent: uses `CREATE TABLE IF NOT EXISTS` so projects that
|
|
32
|
+
-- previously created the table from their own migration (with a
|
|
33
|
+
-- compatible shape) can adopt this one without dropping data. The
|
|
34
|
+
-- expectation is that those projects will then leave their old
|
|
35
|
+
-- migration file in place but stop hand-maintaining the schema here.
|
|
36
|
+
|
|
37
|
+
CREATE TABLE IF NOT EXISTS vk_verification_codes (
|
|
38
|
+
channel TEXT NOT NULL,
|
|
39
|
+
identifier TEXT NOT NULL,
|
|
40
|
+
code_hash TEXT NOT NULL,
|
|
41
|
+
expires_at TIMESTAMPTZ NOT NULL,
|
|
42
|
+
attempts INT NOT NULL DEFAULT 0,
|
|
43
|
+
max_attempts INT NOT NULL DEFAULT 5,
|
|
44
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
45
|
+
PRIMARY KEY (channel, identifier),
|
|
46
|
+
CONSTRAINT verification_codes_channel_chk
|
|
47
|
+
CHECK (channel IN ('email', 'whatsapp', 'sms')),
|
|
48
|
+
CONSTRAINT verification_codes_attempts_chk
|
|
49
|
+
CHECK (attempts >= 0),
|
|
50
|
+
CONSTRAINT verification_codes_max_attempts_chk
|
|
51
|
+
CHECK (max_attempts >= 1)
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
CREATE INDEX IF NOT EXISTS idx_verification_codes_expires_at
|
|
55
|
+
ON vk_verification_codes (expires_at);
|
package/LICENSE
DELETED
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
Apache License
|
|
3
|
-
Version 2.0, January 2004
|
|
4
|
-
http://www.apache.org/licenses/
|
|
5
|
-
|
|
6
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
-
|
|
8
|
-
1. Definitions.
|
|
9
|
-
|
|
10
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
-
|
|
13
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
-
the copyright owner that is granting the License.
|
|
15
|
-
|
|
16
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
-
other entities that control, are controlled by, or are under common
|
|
18
|
-
control with that entity. For the purposes of this definition,
|
|
19
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
-
direction or management of such entity, whether by contract or
|
|
21
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
-
|
|
24
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
-
exercising permissions granted by this License.
|
|
26
|
-
|
|
27
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
-
including but not limited to software source code, documentation
|
|
29
|
-
source, and configuration files.
|
|
30
|
-
|
|
31
|
-
"Object" form shall mean any form resulting from mechanical
|
|
32
|
-
transformation or translation of a Source form, including but
|
|
33
|
-
not limited to compiled object code, generated documentation,
|
|
34
|
-
and conversions to other media types.
|
|
35
|
-
|
|
36
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
-
Object form, made available under the License, as indicated by a
|
|
38
|
-
copyright notice that is included in or attached to the work
|
|
39
|
-
(an example is provided in the Appendix below).
|
|
40
|
-
|
|
41
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
-
form, that is based on (or derived from) the Work and for which the
|
|
43
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
-
of this License, Derivative Works shall not include works that remain
|
|
46
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
-
the Work and Derivative Works thereof.
|
|
48
|
-
|
|
49
|
-
"Contribution" shall mean any work of authorship, including
|
|
50
|
-
the original version of the Work and any modifications or additions
|
|
51
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
-
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
53
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
-
means any form of electronic, verbal, or written communication sent
|
|
56
|
-
to the Licensor or its representatives, including but not limited to
|
|
57
|
-
communication on electronic mailing lists, source code control systems,
|
|
58
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
-
excluding communication that is conspicuously marked or otherwise
|
|
61
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
-
|
|
63
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
-
on behalf of whom a Contribution has been received by the Licensor and
|
|
65
|
-
subsequently incorporated within the Work.
|
|
66
|
-
|
|
67
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
-
Work and such Derivative Works in Source or Object form.
|
|
73
|
-
|
|
74
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
-
(except as stated in this section) patent license to make, have made,
|
|
78
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
-
where such license applies only to those patent claims licensable
|
|
80
|
-
by such Contributor that are necessarily infringed by their
|
|
81
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
-
institute patent litigation against any entity (including a
|
|
84
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
-
or contributory patent infringement, then any patent licenses
|
|
87
|
-
granted to You under this License for that Work shall terminate
|
|
88
|
-
as of the date such litigation is filed.
|
|
89
|
-
|
|
90
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
-
modifications, and in Source or Object form, provided that You
|
|
93
|
-
meet the following conditions:
|
|
94
|
-
|
|
95
|
-
(a) You must give any other recipients of the Work or
|
|
96
|
-
Derivative Works a copy of this License; and
|
|
97
|
-
|
|
98
|
-
(b) You must cause any modified files to carry prominent notices
|
|
99
|
-
stating that You changed the files; and
|
|
100
|
-
|
|
101
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
-
that You distribute, all copyright, patent, trademark, and
|
|
103
|
-
attribution notices from the Source form of the Work,
|
|
104
|
-
excluding those notices that do not pertain to any part of
|
|
105
|
-
the Derivative Works; and
|
|
106
|
-
|
|
107
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
-
distribution, then any Derivative Works that You distribute must
|
|
109
|
-
include a readable copy of the attribution notices contained
|
|
110
|
-
within such NOTICE file, excluding any notices that do not
|
|
111
|
-
pertain to any part of the Derivative Works, in at least one
|
|
112
|
-
of the following places: within a NOTICE text file distributed
|
|
113
|
-
as part of the Derivative Works; within the Source form or
|
|
114
|
-
documentation, if provided along with the Derivative Works; or,
|
|
115
|
-
within a display generated by the Derivative Works, if and
|
|
116
|
-
wherever such third-party notices normally appear. The contents
|
|
117
|
-
of the NOTICE file are for informational purposes only and
|
|
118
|
-
do not modify the License. You may add Your own attribution
|
|
119
|
-
notices within Derivative Works that You distribute, alongside
|
|
120
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
-
that such additional attribution notices cannot be construed
|
|
122
|
-
as modifying the License.
|
|
123
|
-
|
|
124
|
-
You may add Your own copyright statement to Your modifications and
|
|
125
|
-
may provide additional or different license terms and conditions
|
|
126
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
-
the conditions stated in this License.
|
|
130
|
-
|
|
131
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
-
this License, without any additional terms or conditions.
|
|
135
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
-
the terms of any separate license agreement you may have executed
|
|
137
|
-
with Licensor regarding such Contributions.
|
|
138
|
-
|
|
139
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
-
except as required for reasonable and customary use in describing the
|
|
142
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
-
|
|
144
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
-
implied, including, without limitation, any warranties or conditions
|
|
149
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
-
appropriateness of using or redistributing the Work and assume any
|
|
152
|
-
risks associated with Your exercise of permissions under this License.
|
|
153
|
-
|
|
154
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
-
unless required by applicable law (such as deliberate and grossly
|
|
157
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
-
liable to You for damages, including any direct, indirect, special,
|
|
159
|
-
incidental, or consequential damages of any character arising as a
|
|
160
|
-
result of this License or out of the use or inability to use the
|
|
161
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
-
other commercial damages or losses), even if such Contributor
|
|
164
|
-
has been advised of the possibility of such damages.
|
|
165
|
-
|
|
166
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
-
or other liability obligations and/or rights consistent with this
|
|
170
|
-
License. However, in accepting such obligations, You may act only
|
|
171
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
-
defend, and hold each Contributor harmless for any liability
|
|
174
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
-
of your accepting any such warranty or additional liability.
|
|
176
|
-
|
|
177
|
-
END OF TERMS AND CONDITIONS
|
|
178
|
-
|
|
179
|
-
Copyright 2025 VentureKit Contributors
|
|
180
|
-
|
|
181
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
182
|
-
you may not use this file except in compliance with the License.
|
|
183
|
-
You may obtain a copy of the License at
|
|
184
|
-
|
|
185
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
186
|
-
|
|
187
|
-
Unless required by applicable law or agreed to in writing, software
|
|
188
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
189
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
190
|
-
See the License for the specific language governing permissions and
|
|
191
|
-
limitations under the License.
|