@t4h.framework/http 0.6.4 → 0.7.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/.ai/skills/framework-http/SKILL.md +15 -6
- package/CHANGELOG.md +42 -0
- package/dist/activities/AbstractHttpRequestActivity.d.ts +15 -5
- package/dist/activities/AbstractHttpRequestActivity.d.ts.map +1 -1
- package/dist/activities/AbstractHttpRequestActivity.js +16 -7
- package/dist/activities/AbstractHttpRequestActivity.js.map +1 -1
- package/dist/models/HttpClient.d.ts +2 -6
- package/dist/models/HttpClient.d.ts.map +1 -1
- package/dist/models/OAuth2.d.ts +3 -3
- package/dist/models/OAuth2.d.ts.map +1 -1
- package/dist/models/OAuth2.js +10 -5
- package/dist/models/OAuth2.js.map +1 -1
- package/dist/models/OAuth2GrantClientCredentials.d.ts +2 -1
- package/dist/models/OAuth2GrantClientCredentials.d.ts.map +1 -1
- package/dist/models/OAuth2GrantClientCredentials.js +2 -1
- package/dist/models/OAuth2GrantClientCredentials.js.map +1 -1
- package/dist/models/OAuth2GrantResourceOwnerPassword.d.ts +3 -2
- package/dist/models/OAuth2GrantResourceOwnerPassword.d.ts.map +1 -1
- package/dist/models/OAuth2GrantResourceOwnerPassword.js +3 -2
- package/dist/models/OAuth2GrantResourceOwnerPassword.js.map +1 -1
- package/package.json +7 -7
|
@@ -154,10 +154,10 @@ await http.post('https://api.example.com/users', {
|
|
|
154
154
|
const api = http.extend({ baseUrl: 'https://api.example.com' })
|
|
155
155
|
const list = await api.get('/users')
|
|
156
156
|
|
|
157
|
-
// Instance with default auth
|
|
157
|
+
// Instance with default auth (password is a Secret from the EnvDesign)
|
|
158
158
|
const client = new HttpClient({
|
|
159
159
|
baseUrl: 'https://api.example.com',
|
|
160
|
-
auth: { username: 'user', password:
|
|
160
|
+
auth: { username: 'user', password: environments.API_PASSWORD },
|
|
161
161
|
})
|
|
162
162
|
```
|
|
163
163
|
|
|
@@ -213,14 +213,23 @@ Serializable shape: `{ binary: ... }` via `toSerializable` / `fromSerializable`.
|
|
|
213
213
|
|
|
214
214
|
## Authentication
|
|
215
215
|
|
|
216
|
+
Every credential is a `Secret` from the project's `EnvDesign` (`type: Secret`), never a string — `tsc` rejects a string. The activity writes the header on the host, where the value is read, so neither the workflow nor the recorded input holds it. Do not build `Authorization` in `headers` yourself: a `Secret` throws when interpolated.
|
|
217
|
+
|
|
216
218
|
### Basic (inline)
|
|
217
219
|
|
|
218
220
|
```typescript
|
|
219
221
|
await http.get('https://api.example.com/data', {
|
|
220
|
-
auth: { username: 'user', password:
|
|
222
|
+
auth: { username: 'user', password: environments.API_PASSWORD },
|
|
221
223
|
})
|
|
222
224
|
```
|
|
223
225
|
|
|
226
|
+
### Bearer token / API key header
|
|
227
|
+
|
|
228
|
+
```typescript
|
|
229
|
+
await http.get('https://api.example.com/data', { auth: { bearer: environments.API_TOKEN } })
|
|
230
|
+
await http.get('https://api.example.com/data', { auth: { header: 'X-Api-Key', value: environments.API_KEY } })
|
|
231
|
+
```
|
|
232
|
+
|
|
224
233
|
### Custom HttpAuth
|
|
225
234
|
|
|
226
235
|
Subclass `HttpAuth` (extends `SerializableClass`), implement `getAuthorizationHeader()`, and optional `toSerializable` / `fromSerializable` for workflow persistence.
|
|
@@ -233,7 +242,7 @@ import { http, OAuth2ClientCredentials } from '@t4h.framework/http'
|
|
|
233
242
|
const auth = new OAuth2ClientCredentials({
|
|
234
243
|
tokenUrl: 'https://auth.example.com/token',
|
|
235
244
|
clientId: 'my-client-id',
|
|
236
|
-
clientSecret:
|
|
245
|
+
clientSecret: environments.OAUTH_CLIENT_SECRET, // Secret
|
|
237
246
|
})
|
|
238
247
|
|
|
239
248
|
await http.get('https://api.example.com/data', { auth })
|
|
@@ -247,9 +256,9 @@ import { OAuth2GrantResourceOwnerPassword } from '@t4h.framework/http'
|
|
|
247
256
|
const auth = new OAuth2GrantResourceOwnerPassword({
|
|
248
257
|
tokenUrl: 'https://auth.example.com/token',
|
|
249
258
|
clientId: 'my-client-id',
|
|
250
|
-
clientSecret:
|
|
259
|
+
clientSecret: environments.OAUTH_CLIENT_SECRET, // Secret
|
|
251
260
|
username: 'user',
|
|
252
|
-
password:
|
|
261
|
+
password: environments.OAUTH_PASSWORD, // Secret
|
|
253
262
|
})
|
|
254
263
|
```
|
|
255
264
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
# @t4h.framework/http
|
|
2
2
|
|
|
3
|
+
## 0.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#181](https://github.com/tech4humans-brasil/framework/pull/181) [`9449e4e`](https://github.com/tech4humans-brasil/framework/commit/9449e4e9889f42dea1d52418140f47d25dff0535) Thanks [@gusteycamargo](https://github.com/gusteycamargo)! - A credential is a `Secret`, never a string. An env entry declared with
|
|
8
|
+
`type: Secret` hands the workflow the name of the variable; the host binds the
|
|
9
|
+
value where the activity runs, so no input, output or history record holds it.
|
|
10
|
+
|
|
11
|
+
**Breaking**: every field that carries a credential now accepts only a
|
|
12
|
+
`Secret`. Declare the entry with `type: Secret` in your `EnvDesign` and pass it
|
|
13
|
+
whole; `tsc` points at each remaining string.
|
|
14
|
+
|
|
15
|
+
**core**: `Secret` (a `SerializableClass` whose `toString`, `valueOf` and
|
|
16
|
+
`toJSON` throw), `Secret.resolve` and `Secret.read` for hosts, `Secret.FORMAT`
|
|
17
|
+
for the manifest. `EnvDesign` accepts `type: Secret`, refuses a `defaultValue`
|
|
18
|
+
on a secret entry and throws when a `String` entry receives a secret.
|
|
19
|
+
`AsyncActivityCallbackAuth` carries a `Secret` in `secret`, `password`, `token`
|
|
20
|
+
and `value`.
|
|
21
|
+
|
|
22
|
+
**http**: `auth` accepts `{ username, password }`, `{ bearer }` or
|
|
23
|
+
`{ header, value }` besides an `HttpAuth`, all with a `Secret`, and the
|
|
24
|
+
activity writes the header on the host. `clientSecret` and `password` of the
|
|
25
|
+
OAuth2 grants are a `Secret`.
|
|
26
|
+
|
|
27
|
+
**smtp**, **sftp**, **orm**: `connectionString` is a `Secret`. The
|
|
28
|
+
`SftpConnectionString` and `ORMConnectionString` aliases are gone.
|
|
29
|
+
|
|
30
|
+
**hmac**: the callback authorizer reads the secret through `Secret.read`.
|
|
31
|
+
|
|
32
|
+
**dev**: the codec writes a `Secret` by name and binds the env value only where
|
|
33
|
+
an activity runs, reading the input back from the database as the runtime does.
|
|
34
|
+
The SFTP and SMTP claims read the value on connect.
|
|
35
|
+
|
|
36
|
+
**webhook**: documents the `Secret` in `auth`.
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- Updated dependencies [[`9449e4e`](https://github.com/tech4humans-brasil/framework/commit/9449e4e9889f42dea1d52418140f47d25dff0535), [`9449e4e`](https://github.com/tech4humans-brasil/framework/commit/9449e4e9889f42dea1d52418140f47d25dff0535), [`9449e4e`](https://github.com/tech4humans-brasil/framework/commit/9449e4e9889f42dea1d52418140f47d25dff0535)]:
|
|
41
|
+
- @t4h.framework/core@0.15.0
|
|
42
|
+
- @t4h.framework/fs@0.10.0
|
|
43
|
+
- @t4h.framework/cache@0.6.5
|
|
44
|
+
|
|
3
45
|
## 0.6.4
|
|
4
46
|
|
|
5
47
|
### Patch Changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SyncActivity, Binary, type Serializable } from '@t4h.framework/core';
|
|
1
|
+
import { SyncActivity, Binary, type Serializable, Secret } from '@t4h.framework/core';
|
|
2
2
|
import { Body } from '../models/Body.js';
|
|
3
3
|
import { HttpAuth } from '../models/HttpAuth.js';
|
|
4
4
|
export type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH';
|
|
@@ -34,6 +34,18 @@ export type HttpBody = {
|
|
|
34
34
|
form?: never;
|
|
35
35
|
binary: Binary;
|
|
36
36
|
};
|
|
37
|
+
export type HttpRequestBasicAuth = {
|
|
38
|
+
username: string;
|
|
39
|
+
password: Secret;
|
|
40
|
+
};
|
|
41
|
+
export type HttpRequestBearerAuth = {
|
|
42
|
+
bearer: Secret;
|
|
43
|
+
};
|
|
44
|
+
export type HttpRequestHeaderAuth = {
|
|
45
|
+
header: string;
|
|
46
|
+
value: Secret;
|
|
47
|
+
};
|
|
48
|
+
export type HttpRequestAuth = HttpAuth | HttpRequestBasicAuth | HttpRequestBearerAuth | HttpRequestHeaderAuth;
|
|
37
49
|
export type HttpRequestActivityInput = {
|
|
38
50
|
url: string;
|
|
39
51
|
baseUrl?: string;
|
|
@@ -41,10 +53,7 @@ export type HttpRequestActivityInput = {
|
|
|
41
53
|
body?: HttpBody;
|
|
42
54
|
headers?: Record<string, string | string[] | undefined>;
|
|
43
55
|
retry?: boolean | HttpRequestActivityInputRetryOptions;
|
|
44
|
-
auth?:
|
|
45
|
-
username: string;
|
|
46
|
-
password: string;
|
|
47
|
-
};
|
|
56
|
+
auth?: HttpRequestAuth;
|
|
48
57
|
redirect?: 'follow' | 'manual' | number;
|
|
49
58
|
};
|
|
50
59
|
export type HttpRequestActivityOutput = {
|
|
@@ -59,6 +68,7 @@ export declare abstract class AbstractHttpRequestActivity<TArgs extends readonly
|
|
|
59
68
|
protected abstract toHttpOutput(output: HttpRequestActivityOutput): TSerializableOutput | Promise<TSerializableOutput>;
|
|
60
69
|
static append(form: FormData, input: HttpRequestActivityInputBodyFormData, currentKey?: string): Promise<FormData>;
|
|
61
70
|
protected static getFormData(input: HttpRequestActivityInputBodyFormData): Promise<FormData>;
|
|
71
|
+
protected static getAuthHeaders(auth: HttpRequestAuth | undefined): Promise<Record<string, string>>;
|
|
62
72
|
protected static getContent(body: HttpRequestActivityInput['body']): Promise<{
|
|
63
73
|
body: undefined;
|
|
64
74
|
headers: undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractHttpRequestActivity.d.ts","sourceRoot":"","sources":["../../src/activities/AbstractHttpRequestActivity.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,YAAY,EACZ,MAAM,EACN,KAAK,YAAY,
|
|
1
|
+
{"version":3,"file":"AbstractHttpRequestActivity.d.ts","sourceRoot":"","sources":["../../src/activities/AbstractHttpRequestActivity.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,YAAY,EACZ,MAAM,EACN,KAAK,YAAY,EACjB,MAAM,EAEP,MAAM,qBAAqB,CAAA;AAK5B,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAKhD,MAAM,MAAM,UAAU,GAClB,KAAK,GACL,MAAM,GACN,MAAM,GACN,KAAK,GACL,QAAQ,GACR,SAAS,GACT,SAAS,GACT,OAAO,GACP,OAAO,CAAA;AAEX,MAAM,MAAM,oCAAoC,GAAG;IACjD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,UAAU,EAAE,CAAA;IACtB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB,aAAa,CAAC,EAAE,SAAS,CAAA;IACzB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,oCAAoC,GAAG;IACjD,CAAC,GAAG,EAAE,MAAM,GACR,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,GACT,MAAM,GACN,SAAS,oCAAoC,EAAE,GAC/C,oCAAoC,CAAA;CACzC,CAAA;AAED,MAAM,MAAM,QAAQ,GAChB;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,IAAI,CAAC,EAAE,KAAK,CAAC;IAAC,IAAI,CAAC,EAAE,KAAK,CAAC;IAAC,MAAM,CAAC,EAAE,KAAK,CAAA;CAAE,GAClE;IAAE,IAAI,CAAC,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,KA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
|
3
|
+
import { SyncActivity, Binary, Secret, Claim, } from '@t4h.framework/core';
|
|
4
4
|
import { FileSystemClaim } from '@t4h.framework/fs';
|
|
5
5
|
import mime from 'mime';
|
|
6
6
|
import { uuidv7 } from 'uuidv7';
|
|
@@ -39,6 +39,20 @@ export class AbstractHttpRequestActivity extends SyncActivity {
|
|
|
39
39
|
await this.append(formData, input);
|
|
40
40
|
return formData;
|
|
41
41
|
}
|
|
42
|
+
static async getAuthHeaders(auth) {
|
|
43
|
+
if (!auth)
|
|
44
|
+
return {};
|
|
45
|
+
if (auth instanceof HttpAuth)
|
|
46
|
+
return { Authorization: await auth.getAuthorizationHeader() };
|
|
47
|
+
if ('bearer' in auth)
|
|
48
|
+
return { Authorization: `Bearer ${Secret.read(auth.bearer)}` };
|
|
49
|
+
if ('header' in auth)
|
|
50
|
+
return { [auth.header]: Secret.read(auth.value) };
|
|
51
|
+
const credentials = `${auth.username}:${Secret.read(auth.password)}`;
|
|
52
|
+
return {
|
|
53
|
+
Authorization: `Basic ${Buffer.from(credentials).toString('base64')}`,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
42
56
|
static async getContent(body) {
|
|
43
57
|
if (typeof body !== 'object')
|
|
44
58
|
return {
|
|
@@ -82,12 +96,7 @@ export class AbstractHttpRequestActivity extends SyncActivity {
|
|
|
82
96
|
}
|
|
83
97
|
async run(input) {
|
|
84
98
|
const httpInput = await this.toHttpInput(input);
|
|
85
|
-
const headers =
|
|
86
|
-
if (httpInput.auth)
|
|
87
|
-
if (httpInput.auth instanceof HttpAuth)
|
|
88
|
-
headers.Authorization = await httpInput.auth.getAuthorizationHeader();
|
|
89
|
-
else
|
|
90
|
-
headers.Authorization = `Basic ${Buffer.from(`${httpInput.auth.username}:${httpInput.auth.password}`).toString('base64')}`;
|
|
99
|
+
const headers = await AbstractHttpRequestActivity.getAuthHeaders(httpInput.auth);
|
|
91
100
|
const content = await AbstractHttpRequestActivity.getContent(httpInput.body);
|
|
92
101
|
const response = await this[CLAIMS_KEY].http.request({
|
|
93
102
|
url: new URL(httpInput.url, httpInput.baseUrl),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractHttpRequestActivity.js","sourceRoot":"","sources":["../../src/activities/AbstractHttpRequestActivity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAE9B,OAAO,EACL,YAAY,EACZ,MAAM,EAEN,KAAK,GACN,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAA;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;
|
|
1
|
+
{"version":3,"file":"AbstractHttpRequestActivity.js","sourceRoot":"","sources":["../../src/activities/AbstractHttpRequestActivity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAE9B,OAAO,EACL,YAAY,EACZ,MAAM,EAEN,MAAM,EACN,KAAK,GACN,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;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AO,EAAE,QAAQ,CAAC,OAAO;YACzB,IAAI,EAAE,IAAI,IAAI,CAAC,MAAM,CAAC;SACvB,CAAC,CAAA;IACJ,CAAC;CACF"}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { HttpBody, HttpRequestActivityInput } from '../activities/AbstractHttpRequestActivity.js';
|
|
1
|
+
import type { HttpBody, HttpRequestActivityInput, HttpRequestAuth } from '../activities/AbstractHttpRequestActivity.js';
|
|
3
2
|
export interface HttpClientConfig {
|
|
4
3
|
baseUrl?: string;
|
|
5
|
-
auth?:
|
|
6
|
-
username: string;
|
|
7
|
-
password: string;
|
|
8
|
-
};
|
|
4
|
+
auth?: HttpRequestAuth;
|
|
9
5
|
}
|
|
10
6
|
export declare class HttpClient {
|
|
11
7
|
readonly config: HttpClientConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpClient.d.ts","sourceRoot":"","sources":["../../src/models/HttpClient.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"HttpClient.d.ts","sourceRoot":"","sources":["../../src/models/HttpClient.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,QAAQ,EACR,wBAAwB,EACxB,eAAe,EAChB,MAAM,8CAA8C,CAAA;AAGrD,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,eAAe,CAAA;CACvB;AAID,qBAAa,UAAU;aACO,MAAM,EAAE,gBAAgB;gBAAxB,MAAM,EAAE,gBAAgB;IAE7C,OAAO,CACZ,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,IAAI,CAAC,wBAAwB,EAAE,KAAK,GAAG,SAAS,CAAC;IAUrD,GAAG,CACR,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,IAAI,CACX,wBAAwB,EACxB,KAAK,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CACtC;IAKI,IAAI,CACT,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,QAAQ,EACd,MAAM,CAAC,EAAE,IAAI,CACX,wBAAwB,EACxB,KAAK,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CACtC;IAKI,GAAG,CACR,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,QAAQ,EACd,MAAM,CAAC,EAAE,IAAI,CACX,wBAAwB,EACxB,KAAK,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CACtC;IAKI,MAAM,CACX,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,IAAI,CACX,wBAAwB,EACxB,KAAK,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CACtC;IAKI,KAAK,CACV,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,QAAQ,EACd,MAAM,CAAC,EAAE,IAAI,CACX,wBAAwB,EACxB,KAAK,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CACtC;CAIJ;AAED,cAAM,IAAK,SAAQ,UAAU;IACpB,MAAM,CAAC,MAAM,EAAE,gBAAgB;CAGvC;AAED,eAAO,MAAM,IAAI,MAAe,CAAA"}
|
package/dist/models/OAuth2.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CacheClaim } from '@t4h.framework/cache';
|
|
2
|
-
import { Claim, type PromiseLikeType } from '@t4h.framework/core';
|
|
2
|
+
import { Claim, type Deserializer, type PromiseLikeType, type Serializer } from '@t4h.framework/core';
|
|
3
3
|
import { HttpAuth } from './HttpAuth.js';
|
|
4
4
|
import { HttpClientRequestClaim } from './HttpClientRequestClaim.js';
|
|
5
5
|
export type OAuth2Token = {
|
|
@@ -19,8 +19,8 @@ export declare abstract class OAuth2<TConfig extends OAuth2Config> extends HttpA
|
|
|
19
19
|
cache: typeof CacheClaim;
|
|
20
20
|
}>;
|
|
21
21
|
protected get tokenCacheKey(): string;
|
|
22
|
-
toSerializable(): TConfig
|
|
23
|
-
protected fromSerializable(serializable: PromiseLikeType<
|
|
22
|
+
toSerializable(serializer: Serializer): Promise<TConfig>;
|
|
23
|
+
protected fromSerializable(serializable: PromiseLikeType<ReturnType<this['toSerializable']>>, deserializer: Deserializer): Promise<void>;
|
|
24
24
|
constructor(config: TConfig);
|
|
25
25
|
protected abstract toTokenBody(): Record<string, string>;
|
|
26
26
|
private toTokenError;
|
|
@@ -1 +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,
|
|
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,EACL,KAAK,EAEL,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,UAAU,EAChB,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AAGpE,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;AAID,8BAAsB,MAAM,CAAC,OAAO,SAAS,YAAY,CAAE,SAAQ,QAAQ;aAuC7C,MAAM,EAAE,OAAO;IAtC3C,SAAS,CAAC,QAAQ,CAAC,MAAM;;;OAGvB;IAEF,SAAS,KAAK,aAAa,IAAI,MAAM,CAEpC;IAEY,cAAc,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC;cAarD,gBAAgB,CAC9B,YAAY,EAAE,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,EACjE,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,IAAI,CAAC;gBAaY,MAAM,EAAE,OAAO;IAI3C,SAAS,CAAC,QAAQ,CAAC,WAAW,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAExD,OAAO,CAAC,YAAY;YAON,YAAY;cAsCV,OAAO;cAIP,OAAO,CAAC,YAAY,EAAE,MAAM;;sBA/G9B,MAAM;wBACJ,MAAM;oBACV,MAAM;oBACN,MAAM;;cAqHF,QAAQ,CAAC,KAAK,EAAE,WAAW;;sBAxH7B,MAAM;wBACJ,MAAM;oBACV,MAAM;oBACN,MAAM;;cAkIF,QAAQ,IAAI,OAAO,CAAC,WAAW,CAAC;IAcnC,sBAAsB,IAAI,OAAO,CAAC,MAAM,CAAC;CAKvD"}
|
package/dist/models/OAuth2.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CacheClaim } from '@t4h.framework/cache';
|
|
2
|
-
import { Claim } from '@t4h.framework/core';
|
|
2
|
+
import { Claim, Secret, } from '@t4h.framework/core';
|
|
3
3
|
import { HttpAuth } from './HttpAuth.js';
|
|
4
4
|
import { HttpClientRequestClaim } from './HttpClientRequestClaim.js';
|
|
5
5
|
import { withDefaultUserAgent } from '../tools/with-default-user-agent.js';
|
|
@@ -13,12 +13,17 @@ export class OAuth2 extends HttpAuth {
|
|
|
13
13
|
get tokenCacheKey() {
|
|
14
14
|
return `oauth2:token:${this.config.clientId}`;
|
|
15
15
|
}
|
|
16
|
-
toSerializable() {
|
|
17
|
-
|
|
16
|
+
async toSerializable(serializer) {
|
|
17
|
+
const entries = await Promise.all(Object.entries(this.config).map(async ([key, value]) => [
|
|
18
|
+
key,
|
|
19
|
+
value instanceof Secret ? await serializer(value) : value,
|
|
20
|
+
]));
|
|
21
|
+
return Object.fromEntries(entries);
|
|
18
22
|
}
|
|
19
|
-
fromSerializable(serializable) {
|
|
23
|
+
async fromSerializable(serializable, deserializer) {
|
|
24
|
+
const entries = await Promise.all(Object.entries(serializable).map(async ([key, value]) => [key, await deserializer(value)]));
|
|
20
25
|
Object.defineProperty(this, 'config', {
|
|
21
|
-
value:
|
|
26
|
+
value: Object.fromEntries(entries),
|
|
22
27
|
writable: false,
|
|
23
28
|
});
|
|
24
29
|
}
|
|
@@ -1 +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,
|
|
1
|
+
{"version":3,"file":"OAuth2.js","sourceRoot":"","sources":["../../src/models/OAuth2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EACL,KAAK,EACL,MAAM,GAIP,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAkB1E,MAAM,sBAAsB,GAAG,GAAG,CAAA;AAElC,MAAM,OAAgB,MAAqC,SAAQ,QAAQ;IAuC7C;IAtCT,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,KAAK,CAAC,cAAc,CAAC,UAAsB;QAChD,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAC/B,MAAM,CAAC,OAAO,CAA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AAI,KAAK,CAAC,YAAY,EAAE,CAAA;IACpD,CAAC;CACF"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { Secret } from '@t4h.framework/core';
|
|
1
2
|
import { OAuth2, type OAuth2Config } from './OAuth2.js';
|
|
2
3
|
export type OAuth2ClientCredentialsConfig = OAuth2Config & {
|
|
3
4
|
clientId: string;
|
|
4
|
-
clientSecret:
|
|
5
|
+
clientSecret: Secret;
|
|
5
6
|
};
|
|
6
7
|
export declare class OAuth2ClientCredentials extends OAuth2<OAuth2ClientCredentialsConfig> {
|
|
7
8
|
protected toTokenBody(): {
|
|
@@ -1 +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"}
|
|
1
|
+
{"version":3,"file":"OAuth2GrantClientCredentials.d.ts","sourceRoot":"","sources":["../../src/models/OAuth2GrantClientCredentials.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAE5C,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"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { Secret } from '@t4h.framework/core';
|
|
1
2
|
import { OAuth2 } from './OAuth2.js';
|
|
2
3
|
export class OAuth2ClientCredentials extends OAuth2 {
|
|
3
4
|
toTokenBody() {
|
|
4
5
|
return {
|
|
5
6
|
grant_type: 'client_credentials',
|
|
6
7
|
client_id: this.config.clientId,
|
|
7
|
-
client_secret: this.config.clientSecret,
|
|
8
|
+
client_secret: Secret.read(this.config.clientSecret),
|
|
8
9
|
};
|
|
9
10
|
}
|
|
10
11
|
}
|
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"OAuth2GrantClientCredentials.js","sourceRoot":"","sources":["../../src/models/OAuth2GrantClientCredentials.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAE5C,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,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC;SACrD,CAAA;IACH,CAAC;CACF"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { Secret } from '@t4h.framework/core';
|
|
1
2
|
import { OAuth2, type OAuth2Config } from './OAuth2.js';
|
|
2
3
|
export type OAuth2GrantResourceOwnerPasswordConfig = OAuth2Config & {
|
|
3
4
|
clientId: string;
|
|
4
|
-
clientSecret:
|
|
5
|
+
clientSecret: Secret;
|
|
5
6
|
username: string;
|
|
6
|
-
password:
|
|
7
|
+
password: Secret;
|
|
7
8
|
};
|
|
8
9
|
export declare class OAuth2GrantResourceOwnerPassword extends OAuth2<OAuth2GrantResourceOwnerPasswordConfig> {
|
|
9
10
|
protected toTokenBody(): {
|
|
@@ -1 +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"}
|
|
1
|
+
{"version":3,"file":"OAuth2GrantResourceOwnerPassword.d.ts","sourceRoot":"","sources":["../../src/models/OAuth2GrantResourceOwnerPassword.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAE5C,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"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { Secret } from '@t4h.framework/core';
|
|
1
2
|
import { OAuth2 } from './OAuth2.js';
|
|
2
3
|
export class OAuth2GrantResourceOwnerPassword extends OAuth2 {
|
|
3
4
|
toTokenBody() {
|
|
4
5
|
return {
|
|
5
6
|
grant_type: 'password',
|
|
6
7
|
client_id: this.config.clientId,
|
|
7
|
-
client_secret: this.config.clientSecret,
|
|
8
|
+
client_secret: Secret.read(this.config.clientSecret),
|
|
8
9
|
username: this.config.username,
|
|
9
|
-
password: this.config.password,
|
|
10
|
+
password: Secret.read(this.config.password),
|
|
10
11
|
};
|
|
11
12
|
}
|
|
12
13
|
}
|
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"OAuth2GrantResourceOwnerPassword.js","sourceRoot":"","sources":["../../src/models/OAuth2GrantResourceOwnerPassword.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAE5C,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,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC;YACpD,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ;YAC9B,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;SAC5C,CAAA;IACH,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t4h.framework/http",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "HTTP module for the T4H Framework",
|
|
5
5
|
"homepage": "https://github.com/tech4humans-brasil/framework/tree/main/packages/http",
|
|
6
6
|
"bugs": "https://github.com/tech4humans-brasil/framework/issues",
|
|
@@ -38,18 +38,18 @@
|
|
|
38
38
|
"uuidv7": "^1.1.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@t4h.framework/cache": "^0.6.
|
|
42
|
-
"@t4h.framework/core": "^0.
|
|
43
|
-
"@t4h.framework/fs": "^0.
|
|
41
|
+
"@t4h.framework/cache": "^0.6.5",
|
|
42
|
+
"@t4h.framework/core": "^0.15.0",
|
|
43
|
+
"@t4h.framework/fs": "^0.10.0",
|
|
44
44
|
"@types/type-is": "^1.6.7",
|
|
45
45
|
"@vitest/coverage-v8": "^4.0.18",
|
|
46
46
|
"typescript": "^5.9.3",
|
|
47
47
|
"vitest": "^4.0.18"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@t4h.framework/cache": "^0.6.
|
|
51
|
-
"@t4h.framework/core": "^0.
|
|
52
|
-
"@t4h.framework/fs": "^0.
|
|
50
|
+
"@t4h.framework/cache": "^0.6.5",
|
|
51
|
+
"@t4h.framework/core": "^0.15.0",
|
|
52
|
+
"@t4h.framework/fs": "^0.10.0"
|
|
53
53
|
},
|
|
54
54
|
"packageManager": "yarn@4.12.0",
|
|
55
55
|
"engines": {
|