@t4h.framework/http 0.0.0-experimental-c0d4325
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/LICENSE +21 -0
- package/README.md +153 -0
- package/dist/activities/AbstractHttpRequestActivity.d.ts +63 -0
- package/dist/activities/AbstractHttpRequestActivity.d.ts.map +1 -0
- package/dist/activities/AbstractHttpRequestActivity.js +101 -0
- package/dist/activities/AbstractHttpRequestActivity.js.map +1 -0
- package/dist/activities/HttpRequestActivity.d.ts +11 -0
- package/dist/activities/HttpRequestActivity.d.ts.map +1 -0
- package/dist/activities/HttpRequestActivity.js +17 -0
- package/dist/activities/HttpRequestActivity.js.map +1 -0
- package/dist/errors/HttpError.d.ts +318 -0
- package/dist/errors/HttpError.d.ts.map +1 -0
- package/dist/errors/HttpError.js +53 -0
- package/dist/errors/HttpError.js.map +1 -0
- package/dist/http.d.ts +11 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +11 -0
- package/dist/http.js.map +1 -0
- package/dist/models/Body.d.ts +15 -0
- package/dist/models/Body.d.ts.map +1 -0
- package/dist/models/Body.js +37 -0
- package/dist/models/Body.js.map +1 -0
- package/dist/models/HttpAuth.d.ts +12 -0
- package/dist/models/HttpAuth.d.ts.map +1 -0
- package/dist/models/HttpAuth.js +10 -0
- package/dist/models/HttpAuth.js.map +1 -0
- package/dist/models/HttpClient.d.ts +25 -0
- package/dist/models/HttpClient.d.ts.map +1 -0
- package/dist/models/HttpClient.js +39 -0
- package/dist/models/HttpClient.js.map +1 -0
- package/dist/models/HttpClientRequestClaim.d.ts +20 -0
- package/dist/models/HttpClientRequestClaim.d.ts.map +1 -0
- package/dist/models/HttpClientRequestClaim.js +3 -0
- package/dist/models/HttpClientRequestClaim.js.map +1 -0
- package/dist/models/OAuth2.d.ts +44 -0
- package/dist/models/OAuth2.d.ts.map +1 -0
- package/dist/models/OAuth2.js +86 -0
- package/dist/models/OAuth2.js.map +1 -0
- package/dist/models/OAuth2GrantClientCredentials.d.ts +13 -0
- package/dist/models/OAuth2GrantClientCredentials.d.ts.map +1 -0
- package/dist/models/OAuth2GrantClientCredentials.js +11 -0
- package/dist/models/OAuth2GrantClientCredentials.js.map +1 -0
- package/dist/models/OAuth2GrantResourceOwnerPassword.d.ts +17 -0
- package/dist/models/OAuth2GrantResourceOwnerPassword.d.ts.map +1 -0
- package/dist/models/OAuth2GrantResourceOwnerPassword.js +13 -0
- package/dist/models/OAuth2GrantResourceOwnerPassword.js.map +1 -0
- package/dist/models/Response.d.ts +9 -0
- package/dist/models/Response.d.ts.map +1 -0
- package/dist/models/Response.js +11 -0
- package/dist/models/Response.js.map +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { CacheClaim } from '@t4h.framework/cache';
|
|
2
|
+
import { Claim, type PromiseLikeType } from '@t4h.framework/core';
|
|
3
|
+
import { HttpAuth } from './HttpAuth.js';
|
|
4
|
+
import { HttpClientRequestClaim } from './HttpClientRequestClaim.js';
|
|
5
|
+
export type OAuth2Token = {
|
|
6
|
+
access_token: string;
|
|
7
|
+
refresh_token?: string;
|
|
8
|
+
expires_in: number;
|
|
9
|
+
token_type: string;
|
|
10
|
+
};
|
|
11
|
+
export type OAuth2Config = {
|
|
12
|
+
tokenUrl: string;
|
|
13
|
+
clientId: string;
|
|
14
|
+
};
|
|
15
|
+
export declare abstract class OAuth2<TConfig extends OAuth2Config> extends HttpAuth {
|
|
16
|
+
readonly config: TConfig;
|
|
17
|
+
protected readonly claims: Claim<{
|
|
18
|
+
http: typeof HttpClientRequestClaim;
|
|
19
|
+
cache: typeof CacheClaim;
|
|
20
|
+
}>;
|
|
21
|
+
protected get tokenCacheKey(): string;
|
|
22
|
+
toSerializable(): TConfig;
|
|
23
|
+
protected fromSerializable(serializable: PromiseLikeType<TConfig>): void;
|
|
24
|
+
constructor(config: TConfig);
|
|
25
|
+
protected abstract toTokenBody(): Record<string, string>;
|
|
26
|
+
protected toToken(): Promise<OAuth2Token>;
|
|
27
|
+
protected refresh(refreshToken: string): Promise<{
|
|
28
|
+
expiresAt: number;
|
|
29
|
+
access_token: string;
|
|
30
|
+
refresh_token?: string;
|
|
31
|
+
expires_in: number;
|
|
32
|
+
token_type: string;
|
|
33
|
+
}>;
|
|
34
|
+
protected setToken(token: OAuth2Token): Promise<{
|
|
35
|
+
expiresAt: number;
|
|
36
|
+
access_token: string;
|
|
37
|
+
refresh_token?: string;
|
|
38
|
+
expires_in: number;
|
|
39
|
+
token_type: string;
|
|
40
|
+
}>;
|
|
41
|
+
protected getToken(): Promise<OAuth2Token>;
|
|
42
|
+
getAuthorizationHeader(): Promise<string>;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=OAuth2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OAuth2.d.ts","sourceRoot":"","sources":["../../src/models/OAuth2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAE,KAAK,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAEjE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AAEpE,MAAM,MAAM,WAAW,GAAG;IACxB,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAMD,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,8BAAsB,MAAM,CAAC,OAAO,SAAS,YAAY,CAAE,SAAQ,QAAQ;aAqB7C,MAAM,EAAE,OAAO;IApB3C,SAAS,CAAC,QAAQ,CAAC,MAAM;;;OAGvB;IAEF,SAAS,KAAK,aAAa,IAAI,MAAM,CAEpC;IAEM,cAAc,IAAI,OAAO;IAIhC,SAAS,CAAC,gBAAgB,CAAC,YAAY,EAAE,eAAe,CAAC,OAAO,CAAC;gBAOrC,MAAM,EAAE,OAAO;IAI3C,SAAS,CAAC,QAAQ,CAAC,WAAW,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;cAExC,OAAO;cAqBP,OAAO,CAAC,YAAY,EAAE,MAAM;;sBA/D9B,MAAM;wBACJ,MAAM;oBACV,MAAM;oBACN,MAAM;;cAoFF,QAAQ,CAAC,KAAK,EAAE,WAAW;;sBAvF7B,MAAM;wBACJ,MAAM;oBACV,MAAM;oBACN,MAAM;;cAiGF,QAAQ,IAAI,OAAO,CAAC,WAAW,CAAC;IAcnC,sBAAsB,IAAI,OAAO,CAAC,MAAM,CAAC;CAKvD"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { CacheClaim } from '@t4h.framework/cache';
|
|
2
|
+
import { Claim } from '@t4h.framework/core';
|
|
3
|
+
import { HttpAuth } from './HttpAuth.js';
|
|
4
|
+
import { HttpClientRequestClaim } from './HttpClientRequestClaim.js';
|
|
5
|
+
export class OAuth2 extends HttpAuth {
|
|
6
|
+
config;
|
|
7
|
+
claims = new Claim({
|
|
8
|
+
http: HttpClientRequestClaim,
|
|
9
|
+
cache: CacheClaim,
|
|
10
|
+
});
|
|
11
|
+
get tokenCacheKey() {
|
|
12
|
+
return `oauth2:token:${this.config.clientId}`;
|
|
13
|
+
}
|
|
14
|
+
toSerializable() {
|
|
15
|
+
return this.config;
|
|
16
|
+
}
|
|
17
|
+
fromSerializable(serializable) {
|
|
18
|
+
Object.defineProperty(this, 'config', {
|
|
19
|
+
value: serializable,
|
|
20
|
+
writable: false,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
constructor(config) {
|
|
24
|
+
super();
|
|
25
|
+
this.config = config;
|
|
26
|
+
}
|
|
27
|
+
async toToken() {
|
|
28
|
+
const response = await this.claims.http.request({
|
|
29
|
+
url: new URL(this.config.tokenUrl),
|
|
30
|
+
method: 'POST',
|
|
31
|
+
body: new URLSearchParams(this.toTokenBody()),
|
|
32
|
+
redirect: 'follow',
|
|
33
|
+
retry: true,
|
|
34
|
+
headers: {
|
|
35
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
const chunks = await response.body.toArray();
|
|
39
|
+
const buffer = Buffer.concat(chunks);
|
|
40
|
+
const token = JSON.parse(buffer.toString('utf-8'));
|
|
41
|
+
return token;
|
|
42
|
+
}
|
|
43
|
+
async refresh(refreshToken) {
|
|
44
|
+
const response = await this.claims.http.request({
|
|
45
|
+
url: new URL(this.config.tokenUrl),
|
|
46
|
+
method: 'POST',
|
|
47
|
+
body: new URLSearchParams({
|
|
48
|
+
grant_type: 'refresh_token',
|
|
49
|
+
refresh_token: refreshToken,
|
|
50
|
+
}),
|
|
51
|
+
redirect: 'follow',
|
|
52
|
+
retry: true,
|
|
53
|
+
headers: {
|
|
54
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
const chunks = await response.body.toArray();
|
|
58
|
+
const buffer = Buffer.concat(chunks);
|
|
59
|
+
const token = JSON.parse(buffer.toString('utf-8'));
|
|
60
|
+
return await this.setToken(token);
|
|
61
|
+
}
|
|
62
|
+
async setToken(token) {
|
|
63
|
+
const expiresIn = Math.floor(token.expires_in * 1000 * 0.9);
|
|
64
|
+
const expiresAt = Date.now() + expiresIn;
|
|
65
|
+
const value = { ...token, expiresAt };
|
|
66
|
+
await this.claims.cache.set(this.tokenCacheKey, value, {
|
|
67
|
+
ttl: expiresIn,
|
|
68
|
+
});
|
|
69
|
+
return value;
|
|
70
|
+
}
|
|
71
|
+
async getToken() {
|
|
72
|
+
const token = await this.claims.cache.get(this.tokenCacheKey);
|
|
73
|
+
if (!token)
|
|
74
|
+
return await this.setToken(await this.toToken());
|
|
75
|
+
if (token.expiresAt > Date.now())
|
|
76
|
+
return token;
|
|
77
|
+
if (!token.refresh_token)
|
|
78
|
+
return await this.setToken(await this.toToken());
|
|
79
|
+
return await this.refresh(token.refresh_token);
|
|
80
|
+
}
|
|
81
|
+
async getAuthorizationHeader() {
|
|
82
|
+
const token = await this.getToken();
|
|
83
|
+
return `${token.token_type} ${token.access_token}`;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=OAuth2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OAuth2.js","sourceRoot":"","sources":["../../src/models/OAuth2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAE,KAAK,EAAwB,MAAM,qBAAqB,CAAA;AAEjE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AAkBpE,MAAM,OAAgB,MAAqC,SAAQ,QAAQ;IAqB7C;IApBT,MAAM,GAAG,IAAI,KAAK,CAAC;QACpC,IAAI,EAAE,sBAAsB;QAC5B,KAAK,EAAE,UAAU;KAClB,CAAC,CAAA;IAEF,IAAc,aAAa;QACzB,OAAO,gBAAgB,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAA;IAC/C,CAAC;IAEM,cAAc;QACnB,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;IAES,gBAAgB,CAAC,YAAsC;QAC/D,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE;YACpC,KAAK,EAAE,YAAuB;YAC9B,QAAQ,EAAE,KAAK;SAChB,CAAC,CAAA;IACJ,CAAC;IAED,YAA4B,MAAe;QACzC,KAAK,EAAE,CAAA;QADmB,WAAM,GAAN,MAAM,CAAS;IAE3C,CAAC;IAIS,KAAK,CAAC,OAAO;QACrB,MAAM,QAAQ,GAAG,MAAM,IAAI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CAAC,YAAY,EAAE,CAAA;IACpD,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { OAuth2, type OAuth2Config } from './OAuth2.js';
|
|
2
|
+
export type OAuth2ClientCredentialsConfig = OAuth2Config & {
|
|
3
|
+
clientId: string;
|
|
4
|
+
clientSecret: string;
|
|
5
|
+
};
|
|
6
|
+
export declare class OAuth2ClientCredentials extends OAuth2<OAuth2ClientCredentialsConfig> {
|
|
7
|
+
protected toTokenBody(): {
|
|
8
|
+
grant_type: string;
|
|
9
|
+
client_id: string;
|
|
10
|
+
client_secret: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=OAuth2GrantClientCredentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OAuth2GrantClientCredentials.d.ts","sourceRoot":"","sources":["../../src/models/OAuth2GrantClientCredentials.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAA;AAEvD,MAAM,MAAM,6BAA6B,GAAG,YAAY,GAAG;IACzD,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,qBAAa,uBAAwB,SAAQ,MAAM,CAAC,6BAA6B,CAAC;IAChF,SAAS,CAAC,WAAW;;;;;CAOtB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { OAuth2 } from './OAuth2.js';
|
|
2
|
+
export class OAuth2ClientCredentials extends OAuth2 {
|
|
3
|
+
toTokenBody() {
|
|
4
|
+
return {
|
|
5
|
+
grant_type: 'client_credentials',
|
|
6
|
+
client_id: this.config.clientId,
|
|
7
|
+
client_secret: this.config.clientSecret,
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=OAuth2GrantClientCredentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OAuth2GrantClientCredentials.js","sourceRoot":"","sources":["../../src/models/OAuth2GrantClientCredentials.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAqB,MAAM,aAAa,CAAA;AAOvD,MAAM,OAAO,uBAAwB,SAAQ,MAAqC;IACtE,WAAW;QACnB,OAAO;YACL,UAAU,EAAE,oBAAoB;YAChC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ;YAC/B,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,YAAY;SACxC,CAAA;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { OAuth2, type OAuth2Config } from './OAuth2.js';
|
|
2
|
+
export type OAuth2GrantResourceOwnerPasswordConfig = OAuth2Config & {
|
|
3
|
+
clientId: string;
|
|
4
|
+
clientSecret: string;
|
|
5
|
+
username: string;
|
|
6
|
+
password: string;
|
|
7
|
+
};
|
|
8
|
+
export declare class OAuth2GrantResourceOwnerPassword extends OAuth2<OAuth2GrantResourceOwnerPasswordConfig> {
|
|
9
|
+
protected toTokenBody(): {
|
|
10
|
+
grant_type: string;
|
|
11
|
+
client_id: string;
|
|
12
|
+
client_secret: string;
|
|
13
|
+
username: string;
|
|
14
|
+
password: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=OAuth2GrantResourceOwnerPassword.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OAuth2GrantResourceOwnerPassword.d.ts","sourceRoot":"","sources":["../../src/models/OAuth2GrantResourceOwnerPassword.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAA;AAEvD,MAAM,MAAM,sCAAsC,GAAG,YAAY,GAAG;IAClE,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,qBAAa,gCAAiC,SAAQ,MAAM,CAAC,sCAAsC,CAAC;IAClG,SAAS,CAAC,WAAW;;;;;;;CAStB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { OAuth2 } from './OAuth2.js';
|
|
2
|
+
export class OAuth2GrantResourceOwnerPassword extends OAuth2 {
|
|
3
|
+
toTokenBody() {
|
|
4
|
+
return {
|
|
5
|
+
grant_type: 'password',
|
|
6
|
+
client_id: this.config.clientId,
|
|
7
|
+
client_secret: this.config.clientSecret,
|
|
8
|
+
username: this.config.username,
|
|
9
|
+
password: this.config.password,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=OAuth2GrantResourceOwnerPassword.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OAuth2GrantResourceOwnerPassword.js","sourceRoot":"","sources":["../../src/models/OAuth2GrantResourceOwnerPassword.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAqB,MAAM,aAAa,CAAA;AASvD,MAAM,OAAO,gCAAiC,SAAQ,MAA8C;IACxF,WAAW;QACnB,OAAO;YACL,UAAU,EAAE,UAAU;YACtB,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ;YAC/B,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,YAAY;YACvC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ;YAC9B,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ;SAC/B,CAAA;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { HttpRequestActivityOutput } from '../http.js';
|
|
2
|
+
import type { Body } from './Body.js';
|
|
3
|
+
export declare class Response {
|
|
4
|
+
readonly status: number;
|
|
5
|
+
readonly headers: Record<string, string | string[] | undefined>;
|
|
6
|
+
readonly body: Body;
|
|
7
|
+
constructor(output: HttpRequestActivityOutput);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=Response.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Response.d.ts","sourceRoot":"","sources":["../../src/models/Response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAA;AAC3D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAErC,qBAAa,QAAQ;IACnB,SAAgB,MAAM,EAAE,MAAM,CAAA;IAC9B,SAAgB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAA;IACtE,SAAgB,IAAI,EAAE,IAAI,CAAA;gBAEd,MAAM,EAAE,yBAAyB;CAK9C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Response.js","sourceRoot":"","sources":["../../src/models/Response.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,QAAQ;IACH,MAAM,CAAQ;IACd,OAAO,CAA+C;IACtD,IAAI,CAAM;IAE1B,YAAY,MAAiC;QAC3C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAA;QAC3B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAA;QAC7B,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAA;IACzB,CAAC;CACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@t4h.framework/http",
|
|
3
|
+
"version": "0.0.0-experimental-c0d4325",
|
|
4
|
+
"description": "HTTP module for the T4H Framework",
|
|
5
|
+
"homepage": "https://github.com/tech4humans-brasil/framework/tree/main/packages/http",
|
|
6
|
+
"bugs": "https://github.com/tech4humans-brasil/framework/issues",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/tech4humans-brasil/framework.git",
|
|
10
|
+
"directory": "packages/http"
|
|
11
|
+
},
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"author": "Tech4Humans <contact@tech4h.com.br> (https://tech4h.com.br)",
|
|
14
|
+
"type": "module",
|
|
15
|
+
"exports": {
|
|
16
|
+
"types": "./dist/http.d.ts",
|
|
17
|
+
"import": "./dist/http.js"
|
|
18
|
+
},
|
|
19
|
+
"module": "./dist/http.js",
|
|
20
|
+
"types": "./dist/http.d.ts",
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"LICENSE"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsc --project tsconfig.build.json",
|
|
27
|
+
"check-types": "tsc --noEmit",
|
|
28
|
+
"lint": "eslint .",
|
|
29
|
+
"prepublishOnly": "yarn build",
|
|
30
|
+
"test": "vitest run",
|
|
31
|
+
"test:coverage": "vitest run --coverage",
|
|
32
|
+
"test:watch": "vitest"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"mime": "^4.1.0",
|
|
36
|
+
"type-is": "^2.0.1",
|
|
37
|
+
"uuidv7": "^1.1.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@t4h.framework/cache": "workspace:^",
|
|
41
|
+
"@t4h.framework/core": "workspace:^",
|
|
42
|
+
"@t4h.framework/fs": "workspace:^",
|
|
43
|
+
"@types/type-is": "^1.6.7",
|
|
44
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
45
|
+
"typescript": "^5.9.3",
|
|
46
|
+
"vitest": "^4.0.18"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"@t4h.framework/cache": "workspace:^",
|
|
50
|
+
"@t4h.framework/core": "workspace:^",
|
|
51
|
+
"@t4h.framework/fs": "workspace:^"
|
|
52
|
+
},
|
|
53
|
+
"packageManager": "yarn@4.12.0",
|
|
54
|
+
"engines": {
|
|
55
|
+
"node": ">=22"
|
|
56
|
+
},
|
|
57
|
+
"stableVersion": "0.0.0"
|
|
58
|
+
}
|