@netacea/captchafeedback 5.2.35 → 5.2.37
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/CHANGELOG.md +16 -0
- package/package.json +8 -8
- package/dist/captchafeedback/src/CaptchaFeedback.d.ts +0 -153
- package/dist/captchafeedback/src/CaptchaFeedback.js +0 -150
- package/dist/captchafeedback/src/CaptchaFeedback.js.map +0 -1
- package/dist/captchafeedback/src/cookieEncryption.d.ts +0 -2
- package/dist/captchafeedback/src/cookieEncryption.js +0 -23
- package/dist/captchafeedback/src/cookieEncryption.js.map +0 -1
- package/dist/captchafeedback/src/index.d.ts +0 -3
- package/dist/captchafeedback/src/index.js +0 -5
- package/dist/captchafeedback/src/index.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 5.2.37 (2024-05-16)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @netacea/captchafeedback
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## 5.2.36 (2024-05-15)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @netacea/captchafeedback
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
## 5.2.35 (2024-05-15)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @netacea/captchafeedback
|
package/package.json
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netacea/captchafeedback",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.37",
|
|
4
4
|
"description": "CAPTCHA feedback module to send CAPTCHA results back to Netacea.",
|
|
5
5
|
"main": "dist/captchafeedback/src/index.js",
|
|
6
6
|
"types": "dist/captchafeedback/src/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"test": "npx nyc tape -r ts-node/register
|
|
8
|
+
"test": "npx nyc tape -r ts-node/register './tests/*.test.ts'",
|
|
9
9
|
"lint": "npx eslint . --ext ts",
|
|
10
10
|
"lint:fix": "npx eslint . --ext ts --fix",
|
|
11
|
-
"prepublishOnly": "
|
|
11
|
+
"prepublishOnly": "npm run build",
|
|
12
12
|
"prepublishVersionBump": "node ./scripts/bump_package_version.js",
|
|
13
13
|
"aws-sso-setup": "node ./scripts/aws_sso_setup.js",
|
|
14
|
-
"code-artifact-login": "bash ./scripts/codeartifact_login.bash"
|
|
14
|
+
"code-artifact-login": "bash ./scripts/codeartifact_login.bash",
|
|
15
|
+
"build": "npx tsc --project tsconfig.build.json"
|
|
15
16
|
},
|
|
16
|
-
"author": "
|
|
17
|
+
"author": "Netacea <npm@netacea.com> (https://netacea.com)",
|
|
17
18
|
"publishConfig": {
|
|
18
19
|
"access": "public"
|
|
19
20
|
},
|
|
@@ -32,15 +33,14 @@
|
|
|
32
33
|
"sinon": "^9.2.4",
|
|
33
34
|
"tape": "^5.0.1",
|
|
34
35
|
"ts-node": "^9.0.0",
|
|
35
|
-
"tsconfig-paths": "^3.9.0",
|
|
36
36
|
"typescript": "^5.4.3"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"axios": "^0.21.1"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@netacea/netaceaintegrationbase": "^2.0.
|
|
42
|
+
"@netacea/netaceaintegrationbase": "^2.0.19",
|
|
43
43
|
"jose": "^4.11.2"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "398c01c89c8f25782e3c050c5a63ab9150129d18"
|
|
46
46
|
}
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { MitataCookie } from '@netacea/netaceaintegrationbase';
|
|
2
|
-
export type MakeRequest = (args: MakeRequestArgs) => Promise<MakeRequestResponse>;
|
|
3
|
-
export type CreateMitataCookie = (clientIP: string, userId: string | undefined, expiryTime: number, saltKey: string, mitCode: string) => string;
|
|
4
|
-
export type MatchMitataCookie = (cookie: string | undefined) => MitataCookie;
|
|
5
|
-
export interface CaptchaFeedbackArgs {
|
|
6
|
-
/**
|
|
7
|
-
* API Key provided by Netacea
|
|
8
|
-
*/
|
|
9
|
-
apiKey: string;
|
|
10
|
-
/**
|
|
11
|
-
* Secret Key provided by Netacea
|
|
12
|
-
*/
|
|
13
|
-
secretKey: string;
|
|
14
|
-
/**
|
|
15
|
-
* OPTIONAL - encryption key that will be used to decrypt cookies and encrypt new ones.
|
|
16
|
-
*/
|
|
17
|
-
cookieEncryptionKey?: string;
|
|
18
|
-
/**
|
|
19
|
-
* OPTIONAL - custom Mitata cookie name
|
|
20
|
-
*/
|
|
21
|
-
netaceaCookieName?: string;
|
|
22
|
-
/**
|
|
23
|
-
* OPTIONAL - custom Mitata Captcha cookie name
|
|
24
|
-
*/
|
|
25
|
-
netaceaCaptchaCookieName?: string;
|
|
26
|
-
/**
|
|
27
|
-
* OPTIONAL - Mitigation Service URL provided by Netacea
|
|
28
|
-
*/
|
|
29
|
-
mitigationServiceUrl?: string;
|
|
30
|
-
/**
|
|
31
|
-
* Overridable HTTP implementation
|
|
32
|
-
* If this is not provided - AXIOS shoulld be installed as a peer dependency.
|
|
33
|
-
* Error thrown if this is not provided and AXIOS is not installed.
|
|
34
|
-
* Install axios with `npm i axios --save`
|
|
35
|
-
*/
|
|
36
|
-
makeRequest?: MakeRequest;
|
|
37
|
-
createMitataCookie?: CreateMitataCookie;
|
|
38
|
-
matchMitataCookie?: MatchMitataCookie;
|
|
39
|
-
}
|
|
40
|
-
export interface UpdateCaptchaArgs {
|
|
41
|
-
/**
|
|
42
|
-
* Incoming clients IP Address
|
|
43
|
-
*/
|
|
44
|
-
clientIp: string;
|
|
45
|
-
/**
|
|
46
|
-
* Event ID that Netacea provided on the `x-netacea-event-id` header
|
|
47
|
-
* This should be the eventID in realtion to the event when a user was served captcha
|
|
48
|
-
*/
|
|
49
|
-
eventId: string;
|
|
50
|
-
/**
|
|
51
|
-
* The entire `cookie` header received from the client
|
|
52
|
-
*/
|
|
53
|
-
cookieHeader: string;
|
|
54
|
-
/**
|
|
55
|
-
* Client's user-agent header
|
|
56
|
-
*/
|
|
57
|
-
userAgent: string;
|
|
58
|
-
/**
|
|
59
|
-
* Result of the captcha
|
|
60
|
-
* Captcha Passed = true
|
|
61
|
-
* Captcha Failed = false
|
|
62
|
-
*/
|
|
63
|
-
result: boolean;
|
|
64
|
-
}
|
|
65
|
-
export interface MitSvcUpdateCaptchaArgs {
|
|
66
|
-
/**
|
|
67
|
-
* Incoming clients IP Address
|
|
68
|
-
*/
|
|
69
|
-
clientIp: string;
|
|
70
|
-
/**
|
|
71
|
-
* Event ID that Netacea provided on the `x-netacea-event-id` header
|
|
72
|
-
* This should be the eventID in realtion to the event when a user was served captcha
|
|
73
|
-
*/
|
|
74
|
-
eventId: string;
|
|
75
|
-
/**
|
|
76
|
-
* The entire `cookie` header received from the client
|
|
77
|
-
*/
|
|
78
|
-
cookieHeader: string;
|
|
79
|
-
/**
|
|
80
|
-
* Client's user-agent header
|
|
81
|
-
*/
|
|
82
|
-
userAgent: string;
|
|
83
|
-
/**
|
|
84
|
-
* Result of the captcha
|
|
85
|
-
* Captcha Passed = true
|
|
86
|
-
* Captcha Failed = false
|
|
87
|
-
*/
|
|
88
|
-
result: boolean;
|
|
89
|
-
/**
|
|
90
|
-
* Client's user ID, required so the mitata captcha cookie is generated correctly
|
|
91
|
-
*/
|
|
92
|
-
userId: string;
|
|
93
|
-
}
|
|
94
|
-
export interface UpdateCaptchaResponse {
|
|
95
|
-
/**
|
|
96
|
-
* The cookies object should be set as a set-cookie header in your origin server's response
|
|
97
|
-
* There will be a `_mitata` cookie and an optional `_mitatacaptcha` cookie set in this response.
|
|
98
|
-
* If you set the names of the cookies to some custom values then the cookies will be called different.
|
|
99
|
-
* They follow the standard set-cookie header format.
|
|
100
|
-
*/
|
|
101
|
-
cookies: string[];
|
|
102
|
-
}
|
|
103
|
-
export interface MakeRequestArgs {
|
|
104
|
-
/**
|
|
105
|
-
* The URL so send the request to. This includes the path.
|
|
106
|
-
*/
|
|
107
|
-
url: string;
|
|
108
|
-
/**
|
|
109
|
-
* HTTP Method
|
|
110
|
-
*/
|
|
111
|
-
method: 'POST';
|
|
112
|
-
/**
|
|
113
|
-
* Key, value of header values.
|
|
114
|
-
* These all need to be sent with the request.
|
|
115
|
-
*/
|
|
116
|
-
headers: {
|
|
117
|
-
[key: string]: string;
|
|
118
|
-
};
|
|
119
|
-
/**
|
|
120
|
-
* Request body to send with the request
|
|
121
|
-
*/
|
|
122
|
-
body: {
|
|
123
|
-
result: boolean;
|
|
124
|
-
eventId: string;
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
export interface MakeRequestResponse {
|
|
128
|
-
status: number;
|
|
129
|
-
headers: {
|
|
130
|
-
[key: string]: string;
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
export default class CaptchaFeedback {
|
|
134
|
-
private readonly apiKey;
|
|
135
|
-
private readonly secretKey;
|
|
136
|
-
private readonly netaceaCookieName;
|
|
137
|
-
private readonly netaceaCaptchaCookieName;
|
|
138
|
-
private readonly mitigationServiceUrl;
|
|
139
|
-
private readonly cookieEncryptionKey?;
|
|
140
|
-
private readonly makeRequest?;
|
|
141
|
-
private readonly createMitataCookie?;
|
|
142
|
-
private readonly matchMitataCookie?;
|
|
143
|
-
private axios;
|
|
144
|
-
constructor({ apiKey, secretKey, netaceaCookieName, netaceaCaptchaCookieName, mitigationServiceUrl, cookieEncryptionKey, makeRequest, createMitataCookie, matchMitataCookie }: CaptchaFeedbackArgs);
|
|
145
|
-
private makeUpdateCaptchaCall;
|
|
146
|
-
updateCaptcha({ clientIp, eventId, cookieHeader, result, userAgent }: UpdateCaptchaArgs): Promise<UpdateCaptchaResponse>;
|
|
147
|
-
private parseCookie;
|
|
148
|
-
private getAxios;
|
|
149
|
-
private makeAxiosRequest;
|
|
150
|
-
private makeOutboundCall;
|
|
151
|
-
private createCookie;
|
|
152
|
-
private matchCookie;
|
|
153
|
-
}
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const netaceaintegrationbase_1 = require("@netacea/netaceaintegrationbase");
|
|
4
|
-
const cookieEncryption_1 = require("./cookieEncryption");
|
|
5
|
-
class CaptchaFeedback {
|
|
6
|
-
constructor({ apiKey, secretKey, netaceaCookieName = '_mitata', netaceaCaptchaCookieName = '_mitatacaptcha', mitigationServiceUrl = 'https://mitigations.netacea.net', cookieEncryptionKey, makeRequest, createMitataCookie, matchMitataCookie }) {
|
|
7
|
-
if (apiKey === null || apiKey === undefined) {
|
|
8
|
-
throw new Error('Netacea: apiKey is a required parameter');
|
|
9
|
-
}
|
|
10
|
-
this.apiKey = apiKey;
|
|
11
|
-
this.secretKey = secretKey;
|
|
12
|
-
this.netaceaCookieName = netaceaCookieName;
|
|
13
|
-
this.netaceaCaptchaCookieName = netaceaCaptchaCookieName;
|
|
14
|
-
this.mitigationServiceUrl = mitigationServiceUrl;
|
|
15
|
-
this.cookieEncryptionKey = cookieEncryptionKey;
|
|
16
|
-
this.makeRequest = makeRequest;
|
|
17
|
-
this.createMitataCookie = createMitataCookie;
|
|
18
|
-
this.matchMitataCookie = matchMitataCookie;
|
|
19
|
-
}
|
|
20
|
-
async makeUpdateCaptchaCall({ eventId, result, clientIp, userAgent, cookieHeader, userId }) {
|
|
21
|
-
cookieHeader = cookieHeader.replace(`${this.netaceaCookieName}=`, '_mitata=');
|
|
22
|
-
const response = await this.makeOutboundCall({
|
|
23
|
-
body: {
|
|
24
|
-
eventId,
|
|
25
|
-
result
|
|
26
|
-
},
|
|
27
|
-
headers: {
|
|
28
|
-
'content-type': 'application/json; charset=utf-8',
|
|
29
|
-
'x-netacea-api-key': this.apiKey,
|
|
30
|
-
'x-netacea-client-ip': clientIp,
|
|
31
|
-
'user-agent': userAgent,
|
|
32
|
-
'cookie': cookieHeader,
|
|
33
|
-
'x-netacea-userId': userId
|
|
34
|
-
},
|
|
35
|
-
method: 'POST',
|
|
36
|
-
url: `${this.mitigationServiceUrl}/UpdateCaptcha`
|
|
37
|
-
});
|
|
38
|
-
if (response.status !== 200) {
|
|
39
|
-
throw new Error(`Netacea: Non-200 status code returned from XHR call. Code was ${response.status}`);
|
|
40
|
-
}
|
|
41
|
-
return response;
|
|
42
|
-
}
|
|
43
|
-
/* eslint-disable max-lines-per-function */
|
|
44
|
-
// disabling max line per function as a lot of these lines come
|
|
45
|
-
// from getting values out of headers which isn't adding complex logic
|
|
46
|
-
async updateCaptcha({ clientIp, eventId, cookieHeader, result, userAgent }) {
|
|
47
|
-
var _a;
|
|
48
|
-
if (cookieHeader === undefined ||
|
|
49
|
-
cookieHeader.length === 0 ||
|
|
50
|
-
!cookieHeader.includes(`${this.netaceaCookieName}=`)) {
|
|
51
|
-
throw new Error('The cookie header must have a mitata cookie');
|
|
52
|
-
}
|
|
53
|
-
try {
|
|
54
|
-
const trimedParsedCookieHeader = this.parseCookie(cookieHeader);
|
|
55
|
-
const cookieValue = this.cookieEncryptionKey !== undefined
|
|
56
|
-
? await (0, cookieEncryption_1.decrypt)(trimedParsedCookieHeader, this.cookieEncryptionKey)
|
|
57
|
-
: trimedParsedCookieHeader;
|
|
58
|
-
cookieHeader.replace(`=${trimedParsedCookieHeader}`, `=${cookieValue}`);
|
|
59
|
-
const { userId } = (_a = this.matchCookie(cookieValue)) !== null && _a !== void 0 ? _a : {};
|
|
60
|
-
if (userId === undefined) {
|
|
61
|
-
throw new Error('The cookie header must have a mitata cookie with a valid user Id');
|
|
62
|
-
}
|
|
63
|
-
const response = await this.makeUpdateCaptchaCall({
|
|
64
|
-
eventId,
|
|
65
|
-
result,
|
|
66
|
-
clientIp,
|
|
67
|
-
userAgent,
|
|
68
|
-
cookieHeader,
|
|
69
|
-
userId
|
|
70
|
-
});
|
|
71
|
-
const mitataExpiry = response.headers['x-netacea-mitata-expiry'];
|
|
72
|
-
const mitataCaptchaValue = response.headers['x-netacea-mitatacaptcha-value'];
|
|
73
|
-
const mitataCaptchaExpiry = response.headers['x-netacea-mitatacaptcha-expiry'];
|
|
74
|
-
const mitataMatch = response.headers['x-netacea-match'];
|
|
75
|
-
const mitataMitigate = response.headers['x-netacea-mitigate'];
|
|
76
|
-
const mitataCaptcha = response.headers['x-netacea-captcha'];
|
|
77
|
-
const newCookie = this.createCookie(clientIp, userId, Math.floor(Date.now() / 1000) + 60, this.secretKey, `${mitataMatch}${mitataMitigate}${mitataCaptcha}`);
|
|
78
|
-
const finalNewCookieValue = this.cookieEncryptionKey !== undefined
|
|
79
|
-
? await (0, cookieEncryption_1.encrypt)(newCookie, this.cookieEncryptionKey)
|
|
80
|
-
: newCookie;
|
|
81
|
-
const finalMitataCaptcha = this.cookieEncryptionKey !== undefined
|
|
82
|
-
? await (0, cookieEncryption_1.encrypt)(mitataCaptchaValue, this.cookieEncryptionKey)
|
|
83
|
-
: mitataCaptchaValue;
|
|
84
|
-
return {
|
|
85
|
-
cookies: [
|
|
86
|
-
`${this.netaceaCookieName}=${finalNewCookieValue}; Max-Age=${mitataExpiry}; Path=/;`,
|
|
87
|
-
`${this.netaceaCaptchaCookieName}=${finalMitataCaptcha}; Max-Age=${mitataCaptchaExpiry}; Path=/;`
|
|
88
|
-
]
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
catch (e) {
|
|
92
|
-
// eslint-disable-next-line no-console
|
|
93
|
-
console.error(e);
|
|
94
|
-
return { cookies: [] };
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
/* eslint-enable max-lines-per-function */
|
|
98
|
-
parseCookie(cookieHeader) {
|
|
99
|
-
const parsedCookieHeader = cookieHeader.substring(`${this.netaceaCookieName}=`.length);
|
|
100
|
-
const trimedParsedCookieHeader = parsedCookieHeader.includes('; Max-Age=')
|
|
101
|
-
? parsedCookieHeader.split(';')[0] : parsedCookieHeader;
|
|
102
|
-
return trimedParsedCookieHeader;
|
|
103
|
-
}
|
|
104
|
-
async getAxios() {
|
|
105
|
-
return await Promise.resolve().then(() => require('axios'));
|
|
106
|
-
}
|
|
107
|
-
async makeAxiosRequest({ body, headers, method, url }) {
|
|
108
|
-
if (this.axios === undefined) {
|
|
109
|
-
try {
|
|
110
|
-
// try to lazyload axios
|
|
111
|
-
this.axios = await this.getAxios();
|
|
112
|
-
}
|
|
113
|
-
catch {
|
|
114
|
-
// Throw error as axios req wasn't met by `peerDependencies` and makeRequest was not implemented
|
|
115
|
-
throw new Error(['Netacea: Axios must be installed `(npm i axios --save)`',
|
|
116
|
-
'or makeRequest must be provided to override the default of axios being used.'].join(' '));
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
if (method === 'POST') {
|
|
120
|
-
const response = await this.axios.post(url, body, {
|
|
121
|
-
headers
|
|
122
|
-
});
|
|
123
|
-
return {
|
|
124
|
-
status: response.status,
|
|
125
|
-
headers: response.headers
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
throw new Error('Netacea: method not supported');
|
|
129
|
-
}
|
|
130
|
-
async makeOutboundCall(args) {
|
|
131
|
-
if (this.makeRequest !== undefined) {
|
|
132
|
-
return await this.makeRequest(args);
|
|
133
|
-
}
|
|
134
|
-
return await this.makeAxiosRequest(args);
|
|
135
|
-
}
|
|
136
|
-
createCookie(clientIP, userId, expiryTime, saltKey, mitCode) {
|
|
137
|
-
if (this.createMitataCookie !== undefined) {
|
|
138
|
-
return this.createMitataCookie(clientIP, userId, expiryTime, saltKey, mitCode);
|
|
139
|
-
}
|
|
140
|
-
return (0, netaceaintegrationbase_1.createMitataCookie)(clientIP, userId, expiryTime, saltKey, mitCode);
|
|
141
|
-
}
|
|
142
|
-
matchCookie(cookie) {
|
|
143
|
-
if (this.matchMitataCookie !== undefined) {
|
|
144
|
-
return this.matchMitataCookie(cookie);
|
|
145
|
-
}
|
|
146
|
-
return (0, netaceaintegrationbase_1.matchMitataCookie)(cookie);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
exports.default = CaptchaFeedback;
|
|
150
|
-
//# sourceMappingURL=CaptchaFeedback.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CaptchaFeedback.js","sourceRoot":"","sources":["../../../src/CaptchaFeedback.ts"],"names":[],"mappings":";;AAGA,4EAAqG;AACrG,yDAAqD;AA8IrD,MAAqB,eAAe;IAWlC,YAAa,EACX,MAAM,EACN,SAAS,EACT,iBAAiB,GAAG,SAAS,EAC7B,wBAAwB,GAAG,gBAAgB,EAC3C,oBAAoB,GAAG,iCAAiC,EACxD,mBAAmB,EACnB,WAAW,EACX,kBAAkB,EAClB,iBAAiB,EACG;QACpB,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YAC5C,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAA;QAC5D,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAA;QAC1C,IAAI,CAAC,wBAAwB,GAAG,wBAAwB,CAAA;QACxD,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAA;QAChD,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAA;QAC9C,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAA;QAC5C,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAA;IAC5C,CAAC;IAEO,KAAK,CAAC,qBAAqB,CAAE,EACnC,OAAO,EACP,MAAM,EACN,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,MAAM,EACkB;QACxB,YAAY,GAAG,YAAY,CAAC,OAAO,CA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ACzC,OAAO,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAA;QACvC,CAAC;QACD,OAAO,IAAA,0CAAiB,EAAC,MAAM,CAAC,CAAA;IAClC,CAAC;CACF;AA3ND,kCA2NC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.decrypt = exports.encrypt = void 0;
|
|
4
|
-
const jose = require("jose");
|
|
5
|
-
async function encrypt(s, secret) {
|
|
6
|
-
const joseSecret = jose.base64url.decode(secret);
|
|
7
|
-
const payload = new TextEncoder().encode(s);
|
|
8
|
-
const jwt = await new jose.CompactEncrypt(payload)
|
|
9
|
-
.setProtectedHeader({ alg: 'dir', enc: 'A256GCM' })
|
|
10
|
-
.encrypt(joseSecret);
|
|
11
|
-
return jwt;
|
|
12
|
-
}
|
|
13
|
-
exports.encrypt = encrypt;
|
|
14
|
-
async function decrypt(jwe, secret) {
|
|
15
|
-
const joseSecret = jose.base64url.decode(secret);
|
|
16
|
-
const { plaintext } = await jose.compactDecrypt(jwe, joseSecret, {
|
|
17
|
-
keyManagementAlgorithms: ['dir'],
|
|
18
|
-
contentEncryptionAlgorithms: ['A256GCM']
|
|
19
|
-
});
|
|
20
|
-
return new TextDecoder().decode(plaintext);
|
|
21
|
-
}
|
|
22
|
-
exports.decrypt = decrypt;
|
|
23
|
-
//# sourceMappingURL=cookieEncryption.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cookieEncryption.js","sourceRoot":"","sources":["../../../src/cookieEncryption.ts"],"names":[],"mappings":";;;AAAA,6BAA4B;AAErB,KAAK,UAAU,OAAO,CAAE,CAAS,EAAE,MAAc;IACtD,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IAEhD,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;IAC3C,MAAM,GAAG,GAAG,MAAM,IAAI,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;SAC/C,kBAAkB,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;SAClD,OAAO,CAAC,UAAU,CAAC,CAAA;IAEtB,OAAO,GAAG,CAAA;AACZ,CAAC;AATD,0BASC;AAEM,KAAK,UAAU,OAAO,CAAE,GAAW,EAAE,MAAc;IACxD,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IAEhD,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,GAAG,EAAE,UAAU,EAAE;QAC/D,uBAAuB,EAAE,CAAC,KAAK,CAAC;QAChC,2BAA2B,EAAE,CAAC,SAAS,CAAC;KACzC,CAAC,CAAA;IAEF,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;AAC5C,CAAC;AATD,0BASC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":";;AAAA,uDAA+C;AAC/C,kBAAe,yBAAe,CAAA"}
|