@venturekit/auth 0.0.0-dev.20260512121013 → 0.0.0-dev.20260514011201
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/dist/server/errors.d.ts.map +1 -1
- package/dist/server/errors.js +7 -0
- package/dist/server/errors.js.map +1 -1
- package/dist/server/forgot-password.d.ts +103 -0
- package/dist/server/forgot-password.d.ts.map +1 -0
- package/dist/server/forgot-password.js +107 -0
- package/dist/server/forgot-password.js.map +1 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +1 -0
- package/dist/server/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/server/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,qBAAa,SAAU,SAAQ,KAAK;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBACZ,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAM;CAMxD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,OAAO,EACZ,YAAY,EAAE,MAAM,EACpB,cAAc,SAAM,GACnB,SAAS,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/server/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,qBAAa,SAAU,SAAQ,KAAK;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBACZ,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAM;CAMxD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,OAAO,EACZ,YAAY,EAAE,MAAM,EACpB,cAAc,SAAM,GACnB,SAAS,CA8BX"}
|
package/dist/server/errors.js
CHANGED
|
@@ -40,7 +40,14 @@ export function mapProviderError(err, fallbackCode, fallbackStatus = 401) {
|
|
|
40
40
|
case 'TooManyFailedAttemptsException':
|
|
41
41
|
return new AuthError('too_many_requests', message, 429);
|
|
42
42
|
case 'InvalidParameterException':
|
|
43
|
+
case 'InvalidPasswordException':
|
|
43
44
|
return new AuthError('invalid_parameter', message, 422);
|
|
45
|
+
case 'CodeMismatchException':
|
|
46
|
+
return new AuthError('invalid_code', message, 400);
|
|
47
|
+
case 'ExpiredCodeException':
|
|
48
|
+
return new AuthError('expired_code', message, 400);
|
|
49
|
+
case 'LimitExceededException':
|
|
50
|
+
return new AuthError('too_many_requests', message, 429);
|
|
44
51
|
default:
|
|
45
52
|
return new AuthError(code, message, fallbackStatus);
|
|
46
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/server/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,OAAO,SAAU,SAAQ,KAAK;IACzB,IAAI,CAAS;IACb,MAAM,CAAS;IACxB,YAAY,IAAY,EAAE,OAAe,EAAE,MAAM,GAAG,GAAG;QACrD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAC9B,GAAY,EACZ,YAAoB,EACpB,cAAc,GAAG,GAAG;IAEpB,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5C,OAAO,IAAI,SAAS,CAAC,YAAY,EAAE,uBAAuB,EAAE,cAAc,CAAC,CAAC;IAC9E,CAAC;IACD,MAAM,CAAC,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+
/**
|
|
2
|
+
* Server-side "forgot password" flow against a Cognito User Pool.
|
|
3
|
+
*
|
|
4
|
+
* Two steps, mapping 1:1 to Cognito's user-facing endpoints:
|
|
5
|
+
*
|
|
6
|
+
* 1. {@link forgotPassword} — calls `ForgotPassword`. Cognito emails
|
|
7
|
+
* (or SMSes) a one-time confirmation code to the user's verified
|
|
8
|
+
* contact. The pool's app client must allow the unauthenticated
|
|
9
|
+
* `ForgotPassword` action (VentureKit's CDK stack does so by
|
|
10
|
+
* default — it's a public Cognito API).
|
|
11
|
+
* 2. {@link confirmForgotPassword} — calls `ConfirmForgotPassword`
|
|
12
|
+
* with the code + a new permanent password. On success the
|
|
13
|
+
* account password is rotated and the next sign-in succeeds.
|
|
14
|
+
*
|
|
15
|
+
* Errors are normalized via {@link mapProviderError} so route handlers
|
|
16
|
+
* can map them straight to typed responses without inspecting
|
|
17
|
+
* Cognito-specific error names. Notably:
|
|
18
|
+
* - `CodeMismatchException` → `invalid_code` (HTTP 400)
|
|
19
|
+
* - `ExpiredCodeException` → `expired_code` (HTTP 400)
|
|
20
|
+
* - `InvalidPasswordException` → `invalid_parameter` (HTTP 422)
|
|
21
|
+
* - `LimitExceededException` / `TooManyRequestsException`
|
|
22
|
+
* → `too_many_requests` (HTTP 429)
|
|
23
|
+
* - `UserNotFoundException` → `invalid_credentials` (HTTP 401)
|
|
24
|
+
*
|
|
25
|
+
* **Account-enumeration note.** Cognito leaks the existence of an
|
|
26
|
+
* account on the initiation step (it returns `UserNotFoundException`
|
|
27
|
+
* for unknown emails and a success for known ones, with measurable
|
|
28
|
+
* timing differences). Route handlers that care about enumeration
|
|
29
|
+
* resistance should catch `invalid_credentials` from
|
|
30
|
+
* {@link forgotPassword} and respond with the same opaque "if the
|
|
31
|
+
* account exists, a code has been sent" message they return on
|
|
32
|
+
* success. This helper deliberately surfaces the real outcome so the
|
|
33
|
+
* caller can decide.
|
|
34
|
+
*/
|
|
35
|
+
import type { AuthServerConfig } from './config.js';
|
|
36
|
+
export interface ForgotPasswordInput {
|
|
37
|
+
/** Email / username of the account whose password should be reset. */
|
|
38
|
+
email: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Where Cognito delivered (or claims to have delivered) the
|
|
42
|
+
* confirmation code. Mirrors Cognito's `CodeDeliveryDetailsType`
|
|
43
|
+
* shape so consumers don't need to import SDK types.
|
|
44
|
+
*/
|
|
45
|
+
export interface CodeDeliveryDetails {
|
|
46
|
+
/** Masked destination, e.g. `j***@example.com` or `+12******23`. */
|
|
47
|
+
destination?: string;
|
|
48
|
+
/** Delivery channel — `EMAIL` or `SMS`. */
|
|
49
|
+
deliveryMedium?: string;
|
|
50
|
+
/** User attribute the code was sent to — typically `email` or `phone_number`. */
|
|
51
|
+
attributeName?: string;
|
|
52
|
+
}
|
|
53
|
+
export interface ForgotPasswordResult {
|
|
54
|
+
/**
|
|
55
|
+
* Delivery hint Cognito returned with the OTP. `undefined` when
|
|
56
|
+
* Cognito withheld the details (e.g. some compliance regions) or
|
|
57
|
+
* when the user pool has no verified contact method — in which case
|
|
58
|
+
* Cognito would normally throw `InvalidParameterException` before
|
|
59
|
+
* reaching this point.
|
|
60
|
+
*/
|
|
61
|
+
codeDelivery?: CodeDeliveryDetails;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Initiate a password reset. Cognito sends a one-time code to the
|
|
65
|
+
* user's verified email or phone and the caller can then complete
|
|
66
|
+
* the flow via {@link confirmForgotPassword}.
|
|
67
|
+
*
|
|
68
|
+
* @param input Account identifier (email is lower-cased before send).
|
|
69
|
+
* @param config Optional explicit config; defaults to env vars via
|
|
70
|
+
* {@link loadAuthServerConfig}.
|
|
71
|
+
*
|
|
72
|
+
* @throws {AuthError}
|
|
73
|
+
* - `invalid_credentials` (HTTP 401) — unknown user.
|
|
74
|
+
* - `invalid_parameter` (HTTP 422) — the user has no verified
|
|
75
|
+
* contact method to receive the code.
|
|
76
|
+
* - `too_many_requests` (HTTP 429) — Cognito throttling.
|
|
77
|
+
*/
|
|
78
|
+
export declare function forgotPassword(input: ForgotPasswordInput, config?: AuthServerConfig): Promise<ForgotPasswordResult>;
|
|
79
|
+
export interface ConfirmForgotPasswordInput {
|
|
80
|
+
/** Email / username of the account whose password is being reset. */
|
|
81
|
+
email: string;
|
|
82
|
+
/** Confirmation code Cognito delivered in step 1. */
|
|
83
|
+
code: string;
|
|
84
|
+
/** Proposed new permanent password. Must satisfy the User Pool's password policy. */
|
|
85
|
+
newPassword: string;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Complete a password reset by supplying the OTP from
|
|
89
|
+
* {@link forgotPassword} together with a new permanent password.
|
|
90
|
+
*
|
|
91
|
+
* Resolves with `void` on success — the user can now sign in with
|
|
92
|
+
* the new password through {@link signInWithPassword}.
|
|
93
|
+
*
|
|
94
|
+
* @throws {AuthError}
|
|
95
|
+
* - `invalid_code` (HTTP 400) — wrong OTP.
|
|
96
|
+
* - `expired_code` (HTTP 400) — OTP past its TTL.
|
|
97
|
+
* - `invalid_parameter` (HTTP 422) — new password violates the
|
|
98
|
+
* User Pool's password policy.
|
|
99
|
+
* - `too_many_requests` (HTTP 429) — Cognito throttling.
|
|
100
|
+
* - `invalid_credentials` (HTTP 401) — unknown user.
|
|
101
|
+
*/
|
|
102
|
+
export declare function confirmForgotPassword(input: ConfirmForgotPasswordInput, config?: AuthServerConfig): Promise<void>;
|
|
103
|
+
//# sourceMappingURL=forgot-password.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forgot-password.d.ts","sourceRoot":"","sources":["../../src/server/forgot-password.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAOH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAKpD,MAAM,WAAW,mBAAmB;IAClC,sEAAsE;IACtE,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,oEAAoE;IACpE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2CAA2C;IAC3C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iFAAiF;IACjF,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,oBAAoB;IACnC;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,mBAAmB,CAAC;CACpC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,cAAc,CAClC,KAAK,EAAE,mBAAmB,EAC1B,MAAM,GAAE,gBAAyC,GAChD,OAAO,CAAC,oBAAoB,CAAC,CAqB/B;AAED,MAAM,WAAW,0BAA0B;IACzC,qEAAqE;IACrE,KAAK,EAAE,MAAM,CAAC;IACd,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,qFAAqF;IACrF,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,qBAAqB,CACzC,KAAK,EAAE,0BAA0B,EACjC,MAAM,GAAE,gBAAyC,GAChD,OAAO,CAAC,IAAI,CAAC,CAcf"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-side "forgot password" flow against a Cognito User Pool.
|
|
3
|
+
*
|
|
4
|
+
* Two steps, mapping 1:1 to Cognito's user-facing endpoints:
|
|
5
|
+
*
|
|
6
|
+
* 1. {@link forgotPassword} — calls `ForgotPassword`. Cognito emails
|
|
7
|
+
* (or SMSes) a one-time confirmation code to the user's verified
|
|
8
|
+
* contact. The pool's app client must allow the unauthenticated
|
|
9
|
+
* `ForgotPassword` action (VentureKit's CDK stack does so by
|
|
10
|
+
* default — it's a public Cognito API).
|
|
11
|
+
* 2. {@link confirmForgotPassword} — calls `ConfirmForgotPassword`
|
|
12
|
+
* with the code + a new permanent password. On success the
|
|
13
|
+
* account password is rotated and the next sign-in succeeds.
|
|
14
|
+
*
|
|
15
|
+
* Errors are normalized via {@link mapProviderError} so route handlers
|
|
16
|
+
* can map them straight to typed responses without inspecting
|
|
17
|
+
* Cognito-specific error names. Notably:
|
|
18
|
+
* - `CodeMismatchException` → `invalid_code` (HTTP 400)
|
|
19
|
+
* - `ExpiredCodeException` → `expired_code` (HTTP 400)
|
|
20
|
+
* - `InvalidPasswordException` → `invalid_parameter` (HTTP 422)
|
|
21
|
+
* - `LimitExceededException` / `TooManyRequestsException`
|
|
22
|
+
* → `too_many_requests` (HTTP 429)
|
|
23
|
+
* - `UserNotFoundException` → `invalid_credentials` (HTTP 401)
|
|
24
|
+
*
|
|
25
|
+
* **Account-enumeration note.** Cognito leaks the existence of an
|
|
26
|
+
* account on the initiation step (it returns `UserNotFoundException`
|
|
27
|
+
* for unknown emails and a success for known ones, with measurable
|
|
28
|
+
* timing differences). Route handlers that care about enumeration
|
|
29
|
+
* resistance should catch `invalid_credentials` from
|
|
30
|
+
* {@link forgotPassword} and respond with the same opaque "if the
|
|
31
|
+
* account exists, a code has been sent" message they return on
|
|
32
|
+
* success. This helper deliberately surfaces the real outcome so the
|
|
33
|
+
* caller can decide.
|
|
34
|
+
*/
|
|
35
|
+
import { ConfirmForgotPasswordCommand, ForgotPasswordCommand, } from '@aws-sdk/client-cognito-identity-provider';
|
|
36
|
+
import { loadAuthServerConfig } from './config.js';
|
|
37
|
+
import { getCognitoClient } from './cognito-client.js';
|
|
38
|
+
import { mapProviderError } from './errors.js';
|
|
39
|
+
/**
|
|
40
|
+
* Initiate a password reset. Cognito sends a one-time code to the
|
|
41
|
+
* user's verified email or phone and the caller can then complete
|
|
42
|
+
* the flow via {@link confirmForgotPassword}.
|
|
43
|
+
*
|
|
44
|
+
* @param input Account identifier (email is lower-cased before send).
|
|
45
|
+
* @param config Optional explicit config; defaults to env vars via
|
|
46
|
+
* {@link loadAuthServerConfig}.
|
|
47
|
+
*
|
|
48
|
+
* @throws {AuthError}
|
|
49
|
+
* - `invalid_credentials` (HTTP 401) — unknown user.
|
|
50
|
+
* - `invalid_parameter` (HTTP 422) — the user has no verified
|
|
51
|
+
* contact method to receive the code.
|
|
52
|
+
* - `too_many_requests` (HTTP 429) — Cognito throttling.
|
|
53
|
+
*/
|
|
54
|
+
export async function forgotPassword(input, config = loadAuthServerConfig()) {
|
|
55
|
+
const client = getCognitoClient(config.region, config.endpoint);
|
|
56
|
+
let res;
|
|
57
|
+
try {
|
|
58
|
+
res = await client.send(new ForgotPasswordCommand({
|
|
59
|
+
ClientId: config.appClientId,
|
|
60
|
+
Username: input.email.toLowerCase(),
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
throw mapProviderError(err, 'forgot_password_failed');
|
|
65
|
+
}
|
|
66
|
+
const d = res.CodeDeliveryDetails;
|
|
67
|
+
if (!d)
|
|
68
|
+
return {};
|
|
69
|
+
const codeDelivery = {};
|
|
70
|
+
if (d.Destination !== undefined)
|
|
71
|
+
codeDelivery.destination = d.Destination;
|
|
72
|
+
if (d.DeliveryMedium !== undefined)
|
|
73
|
+
codeDelivery.deliveryMedium = d.DeliveryMedium;
|
|
74
|
+
if (d.AttributeName !== undefined)
|
|
75
|
+
codeDelivery.attributeName = d.AttributeName;
|
|
76
|
+
return { codeDelivery };
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Complete a password reset by supplying the OTP from
|
|
80
|
+
* {@link forgotPassword} together with a new permanent password.
|
|
81
|
+
*
|
|
82
|
+
* Resolves with `void` on success — the user can now sign in with
|
|
83
|
+
* the new password through {@link signInWithPassword}.
|
|
84
|
+
*
|
|
85
|
+
* @throws {AuthError}
|
|
86
|
+
* - `invalid_code` (HTTP 400) — wrong OTP.
|
|
87
|
+
* - `expired_code` (HTTP 400) — OTP past its TTL.
|
|
88
|
+
* - `invalid_parameter` (HTTP 422) — new password violates the
|
|
89
|
+
* User Pool's password policy.
|
|
90
|
+
* - `too_many_requests` (HTTP 429) — Cognito throttling.
|
|
91
|
+
* - `invalid_credentials` (HTTP 401) — unknown user.
|
|
92
|
+
*/
|
|
93
|
+
export async function confirmForgotPassword(input, config = loadAuthServerConfig()) {
|
|
94
|
+
const client = getCognitoClient(config.region, config.endpoint);
|
|
95
|
+
try {
|
|
96
|
+
await client.send(new ConfirmForgotPasswordCommand({
|
|
97
|
+
ClientId: config.appClientId,
|
|
98
|
+
Username: input.email.toLowerCase(),
|
|
99
|
+
ConfirmationCode: input.code,
|
|
100
|
+
Password: input.newPassword,
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
catch (err) {
|
|
104
|
+
throw mapProviderError(err, 'confirm_forgot_password_failed');
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=forgot-password.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forgot-password.js","sourceRoot":"","sources":["../../src/server/forgot-password.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EACL,4BAA4B,EAC5B,qBAAqB,GAEtB,MAAM,2CAA2C,CAAC;AAEnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAgC/C;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,KAA0B,EAC1B,SAA2B,oBAAoB,EAAE;IAEjD,MAAM,MAAM,GAAG,gBAAgB,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IAChE,IAAI,GAAgC,CAAC;IACrC,IAAI,CAAC;QACH,GAAG,GAAG,MAAM,MAAM,CAAC,IAAI,CACrB,IAAI,qBAAqB,CAAC;YACxB,QAAQ,EAAE,MAAM,CAAC,WAAW;YAC5B,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,EAAE;SACpC,CAAC,CACH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 @@ export { refreshSession } from './refresh.js';
|
|
|
37
37
|
export { revokeRefreshToken } from './revoke.js';
|
|
38
38
|
export type { ChangePasswordInput } from './change-password.js';
|
|
39
39
|
export { changePassword } from './change-password.js';
|
|
40
|
+
export type { ForgotPasswordInput, ForgotPasswordResult, ConfirmForgotPasswordInput, CodeDeliveryDetails, } from './forgot-password.js';
|
|
41
|
+
export { forgotPassword, confirmForgotPassword } from './forgot-password.js';
|
|
40
42
|
export type { VerifyOptions } from './verify.js';
|
|
41
43
|
export { verifyAndDecode } from './verify.js';
|
|
42
44
|
export type { SessionTokens, CookieOptions } from './cookies.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,GAChB,MAAM,kBAAkB,CAAC;AAE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AAa,CAAC;AAE9C,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAEtB,YAAY,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAErE,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
|
@@ -30,6 +30,7 @@ export { adminInviteUser, adminUpdateUserAttributes, adminDisableUser, adminEnab
|
|
|
30
30
|
export { refreshSession } from './refresh.js';
|
|
31
31
|
export { revokeRefreshToken } from './revoke.js';
|
|
32
32
|
export { changePassword } from './change-password.js';
|
|
33
|
+
export { forgotPassword, confirmForgotPassword } from './forgot-password.js';
|
|
33
34
|
export { verifyAndDecode } from './verify.js';
|
|
34
35
|
export { ID_TOKEN_COOKIE, ACCESS_TOKEN_COOKIE, REFRESH_TOKEN_COOKIE, buildSessionCookies, buildClearSessionCookies, readCookieFromHeader, } from './cookies.js';
|
|
35
36
|
export { cookieAuthMiddleware, extractToken } from './middleware.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,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;
|
|
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,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;AAG9C,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAUrE,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@venturekit/auth",
|
|
3
|
-
"version": "0.0.0-dev.
|
|
3
|
+
"version": "0.0.0-dev.20260514011201",
|
|
4
4
|
"description": "Authentication and authorization for VentureKit",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@venturekit/core": "0.0.0-dev.
|
|
36
|
+
"@venturekit/core": "0.0.0-dev.20260514011201",
|
|
37
37
|
"@aws-sdk/client-cognito-identity-provider": "^3.668.0",
|
|
38
38
|
"@aws-sdk/client-secrets-manager": "^3.668.0",
|
|
39
39
|
"aws-jwt-verify": "^4.0.1"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@venturekit/runtime": "0.0.0-dev.
|
|
42
|
+
"@venturekit/runtime": "0.0.0-dev.20260514011201"
|
|
43
43
|
},
|
|
44
44
|
"peerDependenciesMeta": {
|
|
45
45
|
"@venturekit/runtime": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@venturekit/runtime": "0.0.0-dev.
|
|
50
|
+
"@venturekit/runtime": "0.0.0-dev.20260514011201",
|
|
51
51
|
"@types/aws-lambda": "^8.10.131",
|
|
52
52
|
"@types/node": "^25.6.0",
|
|
53
53
|
"typescript": "^5.3.0"
|