@axiumine/koa-utils 5.7.2 → 5.8.0
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/dataSources/Redis.d.mts +1 -4627
- package/dist/email/SocketLabsLib.d.mts +22 -1
- package/dist/email/SocketLabsLib.mjs +25 -2
- package/package.json +30 -37
|
@@ -15,7 +15,28 @@ export declare class SocketLabsLib {
|
|
|
15
15
|
private readonly emailHtmlHeader2;
|
|
16
16
|
private readonly emailHtmlFooter;
|
|
17
17
|
constructor(htmlHeader1?: string, htmlHeader2?: string, htmlFooter?: string);
|
|
18
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Send the registration confirmation link.
|
|
20
|
+
*
|
|
21
|
+
* `linkBase` and `linkPath` exist because one process can serve more than one audience, and the
|
|
22
|
+
* confirmation link of each has to land on that audience's own domain. Every other link in this class
|
|
23
|
+
* is built from `APP_DOMAIN`, read once in the constructor — which is correct while a deployment has a
|
|
24
|
+
* single front-end, and wrong the moment a second one (a customer site next to an operator panel, say)
|
|
25
|
+
* registers accounts through the same backend. Passing the base per call is the smallest thing that
|
|
26
|
+
* makes both links expressible without a second process or a second env read.
|
|
27
|
+
*
|
|
28
|
+
* Both are optional and default to the previous behaviour exactly, so every existing caller is
|
|
29
|
+
* unaffected. A trailing slash on `linkBase` and a missing leading slash on `linkPath` are both
|
|
30
|
+
* normalised away — the caller supplies configuration, not a pre-joined URL, and `//check` or
|
|
31
|
+
* `example.comcheck` are not errors worth surfacing to a user mid-registration.
|
|
32
|
+
*
|
|
33
|
+
* @param emailTo recipient, also embedded in the link (URI-encoded)
|
|
34
|
+
* @param hash the activation hash stored on the account
|
|
35
|
+
* @param name optional greeting name
|
|
36
|
+
* @param linkBase scheme + host the link points at; defaults to `APP_DOMAIN`
|
|
37
|
+
* @param linkPath route prefix the receiving service listens on; defaults to `/check/verify-email`
|
|
38
|
+
*/
|
|
39
|
+
sendEmailVerify(emailTo: string, hash: string, name?: string, linkBase?: string, linkPath?: string): Promise<boolean>;
|
|
19
40
|
/**
|
|
20
41
|
* @fixme handle retry
|
|
21
42
|
*
|
|
@@ -26,11 +26,34 @@ export class SocketLabsLib {
|
|
|
26
26
|
this.emailHtmlHeader2 = htmlHeader2 === '' ? this.htmlHeader2() : htmlHeader2;
|
|
27
27
|
this.emailHtmlFooter = htmlFooter === '' ? this.htmlFooter() : htmlFooter;
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Send the registration confirmation link.
|
|
31
|
+
*
|
|
32
|
+
* `linkBase` and `linkPath` exist because one process can serve more than one audience, and the
|
|
33
|
+
* confirmation link of each has to land on that audience's own domain. Every other link in this class
|
|
34
|
+
* is built from `APP_DOMAIN`, read once in the constructor — which is correct while a deployment has a
|
|
35
|
+
* single front-end, and wrong the moment a second one (a customer site next to an operator panel, say)
|
|
36
|
+
* registers accounts through the same backend. Passing the base per call is the smallest thing that
|
|
37
|
+
* makes both links expressible without a second process or a second env read.
|
|
38
|
+
*
|
|
39
|
+
* Both are optional and default to the previous behaviour exactly, so every existing caller is
|
|
40
|
+
* unaffected. A trailing slash on `linkBase` and a missing leading slash on `linkPath` are both
|
|
41
|
+
* normalised away — the caller supplies configuration, not a pre-joined URL, and `//check` or
|
|
42
|
+
* `example.comcheck` are not errors worth surfacing to a user mid-registration.
|
|
43
|
+
*
|
|
44
|
+
* @param emailTo recipient, also embedded in the link (URI-encoded)
|
|
45
|
+
* @param hash the activation hash stored on the account
|
|
46
|
+
* @param name optional greeting name
|
|
47
|
+
* @param linkBase scheme + host the link points at; defaults to `APP_DOMAIN`
|
|
48
|
+
* @param linkPath route prefix the receiving service listens on; defaults to `/check/verify-email`
|
|
49
|
+
*/
|
|
50
|
+
async sendEmailVerify(emailTo, hash, name = '', linkBase = this.linkBase, linkPath = '/check/verify-email') {
|
|
30
51
|
const subject = `Confirm your email for ${this.platformName}`;
|
|
31
52
|
const encodedEmail = encodeURI(emailTo);
|
|
32
53
|
const nameFixed = this.fixName(name);
|
|
33
|
-
const
|
|
54
|
+
const base = linkBase.replace(/\/+$/, '');
|
|
55
|
+
const path = `/${linkPath.replace(/^\/+/, '')}`;
|
|
56
|
+
const link = `${base}${path}/${encodedEmail}/${hash}`;
|
|
34
57
|
const linkHtml = this.StringObj.makeLink(link);
|
|
35
58
|
const messageTxt = `Hi${nameFixed}, you or someone else is registering you on ${this.platformName}.
|
|
36
59
|
You can confirm the registration by copying this link ${link} into your browser. The Team`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axiumine/koa-utils",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.8.0",
|
|
4
4
|
"description": "Koa Utils",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"test": "yarn build && yarn build:tests && mocha",
|
|
28
28
|
"test:watch": "mocha --watch",
|
|
29
29
|
"test:coverage": "yarn build && yarn build:tests && c8 mocha",
|
|
30
|
-
"qodana": "yarn test:coverage && mkdir -p .qodana/results && docker run --rm --env-file .env -v \"$PWD\":/data/project -v \"$PWD\"/.qodana/results:/data/results jetbrains/qodana-js:2026.
|
|
30
|
+
"qodana": "yarn test:coverage && mkdir -p .qodana/results && docker run --rm --env-file .env -v \"$PWD\":/data/project -v \"$PWD\"/.qodana/results:/data/results jetbrains/qodana-js:2026.2 --show-report",
|
|
31
31
|
"qodana:cli": "yarn test:coverage && set -a && . ./.env && set +a && qodana scan --show-report",
|
|
32
32
|
"reindex": "node .gitnexus/run.cjs analyze --no-stats",
|
|
33
33
|
"semgrep": "./scripts/semgrep.sh",
|
|
@@ -711,60 +711,53 @@
|
|
|
711
711
|
}
|
|
712
712
|
},
|
|
713
713
|
"devDependencies": {
|
|
714
|
-
"@axiumine/eslint-config-be": "^2.0.
|
|
715
|
-
"@eslint/eslintrc": "^3.3.
|
|
714
|
+
"@axiumine/eslint-config-be": "^2.0.2",
|
|
715
|
+
"@eslint/eslintrc": "^3.3.6",
|
|
716
716
|
"@eslint/js": "^10.0.1",
|
|
717
|
-
"@node-rs/bcrypt": "^1.10.
|
|
718
|
-
"@sentry/node": "^10.
|
|
717
|
+
"@node-rs/bcrypt": "^1.10.7",
|
|
718
|
+
"@sentry/node": "^10.69.0",
|
|
719
719
|
"@socketlabs/email": "^1.4.4",
|
|
720
|
-
"@types/bcrypt": "^6.0.0",
|
|
721
720
|
"@types/chai": "^5.2.3",
|
|
722
|
-
"@types/clamscan": "^2.4.
|
|
721
|
+
"@types/clamscan": "^2.4.1",
|
|
723
722
|
"@types/fs-extra": "^11.0.4",
|
|
724
|
-
"@types/koa": "^3.0.
|
|
723
|
+
"@types/koa": "^3.0.3",
|
|
725
724
|
"@types/mocha": "^10.0.10",
|
|
726
|
-
"@types/node": "^
|
|
727
|
-
"@types/pg": "^8.
|
|
725
|
+
"@types/node": "^26.1.2",
|
|
726
|
+
"@types/pg": "^8.20.3",
|
|
728
727
|
"@types/sinon": "^21.0.1",
|
|
729
|
-
"@
|
|
730
|
-
"@typescript-eslint/
|
|
731
|
-
"@typescript-eslint/parser": "^8.57.0",
|
|
728
|
+
"@typescript-eslint/eslint-plugin": "^8.65.0",
|
|
729
|
+
"@typescript-eslint/parser": "^8.65.0",
|
|
732
730
|
"c8": "^11.0.0",
|
|
733
731
|
"chai": "^6.2.2",
|
|
734
732
|
"clamscan": "^2.4.0",
|
|
735
|
-
"dotenv": "^17.2
|
|
736
|
-
"eslint": "^10.
|
|
733
|
+
"dotenv": "^17.4.2",
|
|
734
|
+
"eslint": "^10.8.0",
|
|
737
735
|
"eslint-config-prettier": "^10.1.8",
|
|
738
|
-
"eslint-
|
|
739
|
-
"eslint-
|
|
740
|
-
"eslint-plugin-
|
|
741
|
-
"eslint-plugin-jest": "^29.12.1",
|
|
742
|
-
"eslint-plugin-n": "^18.0.1",
|
|
743
|
-
"eslint-plugin-promise": "^7.2.1",
|
|
736
|
+
"eslint-import-resolver-typescript": "^4.4.5",
|
|
737
|
+
"eslint-plugin-n": "^18.2.2",
|
|
738
|
+
"eslint-plugin-promise": "^7.3.0",
|
|
744
739
|
"eslint-plugin-simple-import-sort": "^13.0.0",
|
|
745
740
|
"file-type": "^22.0.1",
|
|
746
|
-
"fs-extra": "^11.
|
|
747
|
-
"graphql": "^16.
|
|
748
|
-
"koa": "^3.
|
|
749
|
-
"
|
|
750
|
-
"mariadb": "^3.5.2",
|
|
741
|
+
"fs-extra": "^11.4.0",
|
|
742
|
+
"graphql": "^16.14.2",
|
|
743
|
+
"koa": "^3.2.1",
|
|
744
|
+
"mariadb": "^3.5.3",
|
|
751
745
|
"mocha": "^11.7.6",
|
|
752
|
-
"
|
|
753
|
-
"
|
|
754
|
-
"
|
|
755
|
-
"
|
|
756
|
-
"
|
|
757
|
-
"redis": "^5.10.0",
|
|
746
|
+
"mongodb-memory-server": "^11.2.0",
|
|
747
|
+
"mongoose": "^9.9.1",
|
|
748
|
+
"pg": "^8.22.0",
|
|
749
|
+
"prettier": "^3.9.6",
|
|
750
|
+
"redis": "^6.2.0",
|
|
758
751
|
"reflect-metadata": "^0.2.2",
|
|
759
752
|
"sequelize": "^6.37.8",
|
|
760
753
|
"sequelize-typescript": "^2.1.6",
|
|
761
|
-
"sharp": "^0.
|
|
762
|
-
"sinon": "^22.
|
|
754
|
+
"sharp": "^0.35.3",
|
|
755
|
+
"sinon": "^22.1.0",
|
|
763
756
|
"ts-node": "^10.9.2",
|
|
764
757
|
"ts-patch": "^4.0.1",
|
|
765
|
-
"tsx": "^4.
|
|
758
|
+
"tsx": "^4.23.1",
|
|
766
759
|
"typescript": "^6.0.3",
|
|
767
760
|
"typescript-transform-paths": "^4.0.0",
|
|
768
|
-
"uuid": "^14.0.
|
|
761
|
+
"uuid": "^14.0.1"
|
|
769
762
|
}
|
|
770
763
|
}
|