@axiumine/koa-utils 5.0.1 → 5.0.3

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.
@@ -10,7 +10,16 @@ export const getResetPwd = async function (session, email) {
10
10
  const resetDateReq = queryRet.account.resetDateReq;
11
11
  let resetHash = null;
12
12
  if (typeof resetDateReq !== 'undefined') {
13
- resetHash = '' + queryRet.account.email.hash;
13
+ const storedHash = queryRet.account.email.hash;
14
+ // Never stringify: account.email.hash is a slot shared with the email-verification and
15
+ // email-change flows, so enableEmailAccess / confirmNewEmail can clear it while
16
+ // account.resetDateReq survives. '' + undefined yields the literal string "undefined",
17
+ // which passed updatePassword's null check and then matched a caller sending that same
18
+ // literal as the hash argument — a reset with no secret at all. Absent hash => null,
19
+ // which updatePassword rejects with a 500.
20
+ if (typeof storedHash === 'string') {
21
+ resetHash = storedHash;
22
+ }
14
23
  }
15
24
  ret = {
16
25
  _id: queryRet._id,
@@ -1 +1 @@
1
- {"version":3,"file":"getResetPwd.mjs","sourceRoot":"","sources":["../../../../../src/private/lib/access/db/getResetPwd.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,wDAAoC;AAGvD,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,WAAW,OAAsB,EAAE,KAAa;IAC/E,IAAI,GAAG,GAAG,IAAI,CAAA;IAEd,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;SAC/D,MAAM,CAAC,+DAA+D,CAAC;SACvE,OAAO,CAAC,OAAO,CAAC;SAChB,IAAI,EAAE,CAAA;IAER,8BAA8B;IAC9B,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACvB,MAAM,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAA;QAClD,IAAI,SAAS,GAAG,IAAI,CAAA;QAEpB,IAAI,OAAO,YAAY,KAAK,WAAW,EAAE,CAAC;YACzC,SAAS,GAAG,EAAE,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAA;QAC7C,CAAC;QAED,GAAG,GAAG;YACL,GAAG,EAAE,QAAQ,CAAC,GAAG;YACjB,YAAY;YACZ,SAAS;YACT,IAAI,EAAE,QAAQ,CAAC,YAAY,EAAE,IAAI,IAAI,EAAE;SACvC,CAAA;IACF,CAAC;IACD,OAAO,GAAG,CAAA;AACX,CAAC,CAAA","sourcesContent":["import { UserBase } from '@models/MongoDB/UserBase.mjs'\nimport { ClientSession } from 'mongoose'\n\nexport const getResetPwd = async function (session: ClientSession, email: string) {\n\tlet ret = null\n\n\tconst queryRet = await UserBase.findOne({ 'login.email': email })\n\t\t.select('_id personalData.name account.resetDateReq account.email.hash')\n\t\t.session(session)\n\t\t.lean()\n\n\t// if a reset request is found\n\tif (queryRet !== null) {\n\t\tconst resetDateReq = queryRet.account.resetDateReq\n\t\tlet resetHash = null\n\n\t\tif (typeof resetDateReq !== 'undefined') {\n\t\t\tresetHash = '' + queryRet.account.email.hash\n\t\t}\n\n\t\tret = {\n\t\t\t_id: queryRet._id,\n\t\t\tresetDateReq,\n\t\t\tresetHash,\n\t\t\tname: queryRet.personalData?.name || ''\n\t\t}\n\t}\n\treturn ret\n}\n"]}
1
+ {"version":3,"file":"getResetPwd.mjs","sourceRoot":"","sources":["../../../../../src/private/lib/access/db/getResetPwd.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,wDAAoC;AAGvD,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,WAAW,OAAsB,EAAE,KAAa;IAC/E,IAAI,GAAG,GAAG,IAAI,CAAA;IAEd,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;SAC/D,MAAM,CAAC,+DAA+D,CAAC;SACvE,OAAO,CAAC,OAAO,CAAC;SAChB,IAAI,EAAE,CAAA;IAER,8BAA8B;IAC9B,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACvB,MAAM,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAA;QAClD,IAAI,SAAS,GAAG,IAAI,CAAA;QAEpB,IAAI,OAAO,YAAY,KAAK,WAAW,EAAE,CAAC;YACzC,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAA;YAE9C,uFAAuF;YACvF,gFAAgF;YAChF,uFAAuF;YACvF,uFAAuF;YACvF,qFAAqF;YACrF,2CAA2C;YAC3C,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE,CAAC;gBACpC,SAAS,GAAG,UAAU,CAAA;YACvB,CAAC;QACF,CAAC;QAED,GAAG,GAAG;YACL,GAAG,EAAE,QAAQ,CAAC,GAAG;YACjB,YAAY;YACZ,SAAS;YACT,IAAI,EAAE,QAAQ,CAAC,YAAY,EAAE,IAAI,IAAI,EAAE;SACvC,CAAA;IACF,CAAC;IACD,OAAO,GAAG,CAAA;AACX,CAAC,CAAA","sourcesContent":["import { UserBase } from '@models/MongoDB/UserBase.mjs'\nimport { ClientSession } from 'mongoose'\n\nexport const getResetPwd = async function (session: ClientSession, email: string) {\n\tlet ret = null\n\n\tconst queryRet = await UserBase.findOne({ 'login.email': email })\n\t\t.select('_id personalData.name account.resetDateReq account.email.hash')\n\t\t.session(session)\n\t\t.lean()\n\n\t// if a reset request is found\n\tif (queryRet !== null) {\n\t\tconst resetDateReq = queryRet.account.resetDateReq\n\t\tlet resetHash = null\n\n\t\tif (typeof resetDateReq !== 'undefined') {\n\t\t\tconst storedHash = queryRet.account.email.hash\n\n\t\t\t// Never stringify: account.email.hash is a slot shared with the email-verification and\n\t\t\t// email-change flows, so enableEmailAccess / confirmNewEmail can clear it while\n\t\t\t// account.resetDateReq survives. '' + undefined yields the literal string \"undefined\",\n\t\t\t// which passed updatePassword's null check and then matched a caller sending that same\n\t\t\t// literal as the hash argument — a reset with no secret at all. Absent hash => null,\n\t\t\t// which updatePassword rejects with a 500.\n\t\t\tif (typeof storedHash === 'string') {\n\t\t\t\tresetHash = storedHash\n\t\t\t}\n\t\t}\n\n\t\tret = {\n\t\t\t_id: queryRet._id,\n\t\t\tresetDateReq,\n\t\t\tresetHash,\n\t\t\tname: queryRet.personalData?.name || ''\n\t\t}\n\t}\n\treturn ret\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { UserBase } from "../../../../graphQL/models/MongoDB/UserBase.mjs";
2
2
  export default async function removeResetReq(session, email) {
3
- return UserBase.updateOne({ 'login.email': email }, { $unset: { 'account.resetDateReq': '', 'account.resetHash': '' } }, { upsert: true })
3
+ return UserBase.updateOne({ 'login.email': email }, { $unset: { 'account.resetDateReq': '', 'account.email.hash': '' } }, { upsert: true })
4
4
  .session(session)
5
5
  .exec();
6
6
  }
@@ -1 +1 @@
1
- {"version":3,"file":"removeResetReq.mjs","sourceRoot":"","sources":["../../../../../src/private/lib/access/db/removeResetReq.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,wDAAoC;AAGvD,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,cAAc,CAAC,OAAsB,EAAE,KAAa;IACjF,OAAO,QAAQ,CAAC,SAAS,CACxB,EAAE,aAAa,EAAE,KAAK,EAAE,EACxB,EAAE,MAAM,EAAE,EAAE,sBAAsB,EAAE,EAAE,EAAE,mBAAmB,EAAE,EAAE,EAAE,EAAE,EACnE,EAAE,MAAM,EAAE,IAAI,EAAE,CAChB;SACC,OAAO,CAAC,OAAO,CAAC;SAChB,IAAI,EAAE,CAAA;AACT,CAAC","sourcesContent":["import { UserBase } from '@models/MongoDB/UserBase.mjs'\nimport { ClientSession } from 'mongoose'\n\nexport default async function removeResetReq(session: ClientSession, email: string) {\n\treturn UserBase.updateOne(\n\t\t{ 'login.email': email },\n\t\t{ $unset: { 'account.resetDateReq': '', 'account.resetHash': '' } },\n\t\t{ upsert: true }\n\t)\n\t\t.session(session)\n\t\t.exec()\n}\n"]}
1
+ {"version":3,"file":"removeResetReq.mjs","sourceRoot":"","sources":["../../../../../src/private/lib/access/db/removeResetReq.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,wDAAoC;AAGvD,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,cAAc,CAAC,OAAsB,EAAE,KAAa;IACjF,OAAO,QAAQ,CAAC,SAAS,CACxB,EAAE,aAAa,EAAE,KAAK,EAAE,EACxB,EAAE,MAAM,EAAE,EAAE,sBAAsB,EAAE,EAAE,EAAE,oBAAoB,EAAE,EAAE,EAAE,EAAE,EACpE,EAAE,MAAM,EAAE,IAAI,EAAE,CAChB;SACC,OAAO,CAAC,OAAO,CAAC;SAChB,IAAI,EAAE,CAAA;AACT,CAAC","sourcesContent":["import { UserBase } from '@models/MongoDB/UserBase.mjs'\nimport { ClientSession } from 'mongoose'\n\nexport default async function removeResetReq(session: ClientSession, email: string) {\n\treturn UserBase.updateOne(\n\t\t{ 'login.email': email },\n\t\t{ $unset: { 'account.resetDateReq': '', 'account.email.hash': '' } },\n\t\t{ upsert: true }\n\t)\n\t\t.session(session)\n\t\t.exec()\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axiumine/koa-utils",
3
- "version": "5.0.1",
3
+ "version": "5.0.3",
4
4
  "description": "Koa Utils",
5
5
  "type": "module",
6
6
  "repository": {
@@ -32,7 +32,7 @@
32
32
  "semgrep": "./scripts/semgrep.sh",
33
33
  "semgrep:all": "./scripts/semgrep.sh --registry",
34
34
  "semgrep:canary": "./scripts/semgrep-canary.sh",
35
- "upload": "npm publish",
35
+ "upload": "npm publish --registry=https://registry.npmjs.org/",
36
36
  "update": "yarn upgrade-interactive --latest --network-timeout 100000",
37
37
  "cloc": "cloc . --exclude-dir=node_modules,dist,.git,upload",
38
38
  "scc": "scc . --exclude-dir=node_modules,dist,.git -w --sort --directory-walker-job-workers=8 --count-as=mts:TypeScript"