@wabot-dev/framework 0.1.0-beta.61 → 0.1.0-beta.63
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.
|
@@ -2,7 +2,6 @@ import { __decorate, __metadata } from 'tslib';
|
|
|
2
2
|
import { Auth } from '../../../core/auth/Auth.js';
|
|
3
3
|
import { CustomError } from '../../../core/error/CustomError.js';
|
|
4
4
|
import { injectable } from '../../../core/injection/index.js';
|
|
5
|
-
import { ApiKey } from './ApiKey.js';
|
|
6
5
|
import { ApiKeyRepository } from './ApiKeyRepository.js';
|
|
7
6
|
|
|
8
7
|
let ApiKeyConnectionGuardMiddleware = class ApiKeyConnectionGuardMiddleware {
|
|
@@ -19,8 +18,8 @@ let ApiKeyConnectionGuardMiddleware = class ApiKeyConnectionGuardMiddleware {
|
|
|
19
18
|
authorization = authorization[0];
|
|
20
19
|
}
|
|
21
20
|
if (authorization) {
|
|
22
|
-
const [
|
|
23
|
-
if (
|
|
21
|
+
const [prefix, token] = authorization.split(' ');
|
|
22
|
+
if (prefix.toLowerCase() !== 'api-key' || !token) {
|
|
24
23
|
throw new CustomError({
|
|
25
24
|
httpCode: 401,
|
|
26
25
|
message: 'Authorization should be an Api-Key',
|
|
@@ -34,10 +33,8 @@ let ApiKeyConnectionGuardMiddleware = class ApiKeyConnectionGuardMiddleware {
|
|
|
34
33
|
throw new CustomError({ httpCode: 401, message: 'Token not available' });
|
|
35
34
|
}
|
|
36
35
|
try {
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
apiKey.validatePassword(keyData.pass);
|
|
40
|
-
this.auth.assign(apiKey.authInfo);
|
|
36
|
+
const authInfo = await this.apiKeyRepository.findAuthInfo(keySecret);
|
|
37
|
+
this.auth.assign(authInfo);
|
|
41
38
|
}
|
|
42
39
|
catch (err) {
|
|
43
40
|
throw new CustomError({
|
|
@@ -19,8 +19,8 @@ let JwtConnectionGuardMiddleware = class JwtConnectionGuardMiddleware {
|
|
|
19
19
|
authorization = authorization[0];
|
|
20
20
|
}
|
|
21
21
|
if (authorization) {
|
|
22
|
-
const [
|
|
23
|
-
if (
|
|
22
|
+
const [prefix, token] = authorization.split(' ');
|
|
23
|
+
if (prefix.toLowerCase() !== 'bearer' || !token) {
|
|
24
24
|
throw new CustomError({
|
|
25
25
|
httpCode: 401,
|
|
26
26
|
message: 'Authorization should be a bearer token',
|
|
@@ -19,7 +19,7 @@ let WabotChatAdapter = class WabotChatAdapter {
|
|
|
19
19
|
const response = await fetch(this.baseUrl + '/chat-bot/next-item', {
|
|
20
20
|
method: 'post',
|
|
21
21
|
headers: {
|
|
22
|
-
Authorization: `
|
|
22
|
+
Authorization: `Api-Key ${this.apiKey}`,
|
|
23
23
|
'Content-Type': 'application/json',
|
|
24
24
|
},
|
|
25
25
|
body: JSON.stringify(req),
|
package/dist/src/index.d.ts
CHANGED
|
@@ -262,7 +262,7 @@ declare function isDate(): (target: object, propertyKey: string | symbol) => voi
|
|
|
262
262
|
declare function validateIsDate(value: any): IValidationResult<Date>;
|
|
263
263
|
|
|
264
264
|
interface IValidateIsInOptions {
|
|
265
|
-
values: (number | string | boolean | null)[];
|
|
265
|
+
values: readonly (number | string | boolean | null)[];
|
|
266
266
|
}
|
|
267
267
|
declare function validateIsIn(value: any, options: IValidateIsInOptions): IValidationResult<any>;
|
|
268
268
|
|