@venturekit/auth 0.0.0-dev.20260506000649 → 0.0.0-dev.20260506001012

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.
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Server-side self-service password change against a Cognito User Pool.
3
+ *
4
+ * Wraps Cognito's `ChangePassword` API which derives the user from the
5
+ * supplied access token (no admin credentials required). The caller must
6
+ * therefore have a fresh access token in hand — typically read from the
7
+ * `vk_access_token` cookie populated by {@link buildSessionCookies}.
8
+ *
9
+ * Errors are normalized via {@link mapProviderError} so route handlers
10
+ * can map them straight to typed responses without inspecting
11
+ * Cognito-specific error names.
12
+ */
13
+ import type { AuthServerConfig } from './config.js';
14
+ export interface ChangePasswordInput {
15
+ /** Current Cognito access token for the authenticated user. */
16
+ accessToken: string;
17
+ /** Current password — Cognito will reject the request otherwise. */
18
+ previousPassword: string;
19
+ /** Proposed new permanent password. Must satisfy the User Pool's password policy. */
20
+ proposedPassword: string;
21
+ }
22
+ /**
23
+ * Change the password of the currently-authenticated user.
24
+ *
25
+ * @param input Access token + previous + proposed password.
26
+ * @param config Optional explicit config; defaults to env vars via
27
+ * {@link loadAuthServerConfig}.
28
+ *
29
+ * @throws {AuthError} `invalid_credentials` when the previous password
30
+ * is wrong, `invalid_parameter` when the proposed password violates
31
+ * the User Pool's password policy, `too_many_requests` when Cognito
32
+ * throttles the caller.
33
+ */
34
+ export declare function changePassword(input: ChangePasswordInput, config?: AuthServerConfig): Promise<void>;
35
+ //# sourceMappingURL=change-password.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"change-password.d.ts","sourceRoot":"","sources":["../../src/server/change-password.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAKpD,MAAM,WAAW,mBAAmB;IAClC,+DAA+D;IAC/D,WAAW,EAAE,MAAM,CAAC;IACpB,oEAAoE;IACpE,gBAAgB,EAAE,MAAM,CAAC;IACzB,qFAAqF;IACrF,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,cAAc,CAClC,KAAK,EAAE,mBAAmB,EAC1B,MAAM,GAAE,gBAAyC,GAChD,OAAO,CAAC,IAAI,CAAC,CAaf"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Server-side self-service password change against a Cognito User Pool.
3
+ *
4
+ * Wraps Cognito's `ChangePassword` API which derives the user from the
5
+ * supplied access token (no admin credentials required). The caller must
6
+ * therefore have a fresh access token in hand — typically read from the
7
+ * `vk_access_token` cookie populated by {@link buildSessionCookies}.
8
+ *
9
+ * Errors are normalized via {@link mapProviderError} so route handlers
10
+ * can map them straight to typed responses without inspecting
11
+ * Cognito-specific error names.
12
+ */
13
+ import { ChangePasswordCommand } from '@aws-sdk/client-cognito-identity-provider';
14
+ import { loadAuthServerConfig } from './config.js';
15
+ import { getCognitoClient } from './cognito-client.js';
16
+ import { mapProviderError } from './errors.js';
17
+ /**
18
+ * Change the password of the currently-authenticated user.
19
+ *
20
+ * @param input Access token + previous + proposed password.
21
+ * @param config Optional explicit config; defaults to env vars via
22
+ * {@link loadAuthServerConfig}.
23
+ *
24
+ * @throws {AuthError} `invalid_credentials` when the previous password
25
+ * is wrong, `invalid_parameter` when the proposed password violates
26
+ * the User Pool's password policy, `too_many_requests` when Cognito
27
+ * throttles the caller.
28
+ */
29
+ export async function changePassword(input, config = loadAuthServerConfig()) {
30
+ const client = getCognitoClient(config.region, config.endpoint);
31
+ try {
32
+ await client.send(new ChangePasswordCommand({
33
+ AccessToken: input.accessToken,
34
+ PreviousPassword: input.previousPassword,
35
+ ProposedPassword: input.proposedPassword,
36
+ }));
37
+ }
38
+ catch (err) {
39
+ throw mapProviderError(err, 'change_password_failed');
40
+ }
41
+ }
42
+ //# sourceMappingURL=change-password.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"change-password.js","sourceRoot":"","sources":["../../src/server/change-password.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,2CAA2C,CAAC;AAElF,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAW/C;;;;;;;;;;;GAWG;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,CAAC;QACH,MAAM,MAAM,CAAC,IAAI,CACf,IAAI,qBAAqB,CAAC;YACxB,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;YACxC,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;SACzC,CAAC,CACH,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,gBAAgB,CAAC,GAAG,EAAE,wBAAwB,CAAC,CAAC;IACxD,CAAC;AACH,CAAC"}
@@ -29,6 +29,8 @@ export { signInWithPassword } from './sign-in.js';
29
29
  export type { RefreshResult } from './refresh.js';
30
30
  export { refreshSession } from './refresh.js';
31
31
  export { revokeRefreshToken } from './revoke.js';
32
+ export type { ChangePasswordInput } from './change-password.js';
33
+ export { changePassword } from './change-password.js';
32
34
  export type { VerifyOptions } from './verify.js';
33
35
  export { verifyAndDecode } from './verify.js';
34
36
  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,EA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;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,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,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"}
@@ -26,6 +26,7 @@ export { loadAuthServerConfig } from './config.js';
26
26
  export { signInWithPassword } from './sign-in.js';
27
27
  export { refreshSession } from './refresh.js';
28
28
  export { revokeRefreshToken } from './revoke.js';
29
+ export { changePassword } from './change-password.js';
29
30
  export { verifyAndDecode } from './verify.js';
30
31
  export { ID_TOKEN_COOKIE, ACCESS_TOKEN_COOKIE, REFRESH_TOKEN_COOKIE, buildSessionCookies, buildClearSessionCookies, readCookieFromHeader, } from './cookies.js';
31
32
  export { cookieAuthMiddleware, extractToken } from './middleware.js';
@@ -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;AAGlD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGjD,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"}
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;AAGlD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGjD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@venturekit/auth",
3
- "version": "0.0.0-dev.20260506000649",
3
+ "version": "0.0.0-dev.20260506001012",
4
4
  "description": "Authentication and authorization for VentureKit",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -29,12 +29,12 @@
29
29
  }
30
30
  },
31
31
  "dependencies": {
32
- "@venturekit/core": "0.0.0-dev.20260506000649",
32
+ "@venturekit/core": "0.0.0-dev.20260506001012",
33
33
  "@aws-sdk/client-cognito-identity-provider": "^3.668.0",
34
34
  "aws-jwt-verify": "^4.0.1"
35
35
  },
36
36
  "peerDependencies": {
37
- "@venturekit/runtime": "0.0.0-dev.20260506000649"
37
+ "@venturekit/runtime": "0.0.0-dev.20260506001012"
38
38
  },
39
39
  "peerDependenciesMeta": {
40
40
  "@venturekit/runtime": {
@@ -42,7 +42,7 @@
42
42
  }
43
43
  },
44
44
  "devDependencies": {
45
- "@venturekit/runtime": "0.0.0-dev.20260506000649",
45
+ "@venturekit/runtime": "0.0.0-dev.20260506001012",
46
46
  "@types/aws-lambda": "^8.10.131",
47
47
  "@types/node": "^25.6.0",
48
48
  "typescript": "^5.3.0"