@faable/sdk-base 1.1.1 → 1.1.3
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.
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
name: Release
|
|
2
|
+
permissions:
|
|
3
|
+
contents: write # necesario para push de commits y tags
|
|
4
|
+
pull-requests: write
|
|
5
|
+
issues: write
|
|
6
|
+
id-token: write # OIDC: npm trusted publishing (sin NPM_TOKEN)
|
|
2
7
|
"on":
|
|
3
8
|
push:
|
|
4
9
|
branches:
|
|
@@ -7,15 +12,18 @@ jobs:
|
|
|
7
12
|
release:
|
|
8
13
|
name: release
|
|
9
14
|
runs-on: ubuntu-latest
|
|
15
|
+
timeout-minutes: 5
|
|
10
16
|
steps:
|
|
11
17
|
- uses: actions/checkout@v4
|
|
12
|
-
- uses: actions/setup-node@
|
|
18
|
+
- uses: actions/setup-node@v4
|
|
13
19
|
with:
|
|
14
|
-
cache: npm
|
|
15
20
|
node-version: lts/*
|
|
21
|
+
registry-url: https://registry.npmjs.org/
|
|
22
|
+
always-auth: true
|
|
16
23
|
- run: npm ci
|
|
17
24
|
- run: npm run build
|
|
18
|
-
- run: npm
|
|
25
|
+
- run: npm audit signatures
|
|
26
|
+
- name: Release
|
|
27
|
+
run: npx semantic-release
|
|
19
28
|
env:
|
|
20
29
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
21
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/dist/FaableApi.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export type ApiParams = {
|
|
|
9
9
|
paginator?: Partial<PaginatorOptions>;
|
|
10
10
|
};
|
|
11
11
|
export declare abstract class FaableApi<Params extends ApiParams = ApiParams> {
|
|
12
|
-
|
|
12
|
+
fetcher: Fetcher;
|
|
13
13
|
protected paginator: Paginator;
|
|
14
14
|
protected constructor(params?: Params);
|
|
15
15
|
static create<T extends abstract new (args: Params) => any, Params = any>(this: T, params?: Params): InstanceType<T>;
|
package/dist/FaableApi.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FaableApi.d.ts","sourceRoot":"","sources":["../src/FaableApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEpE,OAAO,EAEL,SAAS,EACT,gBAAgB,EACjB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,IAAI,CAAC,EAAE,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC/B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;CACvC,CAAC;AAEF,8BAAsB,SAAS,CAAC,MAAM,SAAS,SAAS,GAAG,SAAS;IAClE,
|
|
1
|
+
{"version":3,"file":"FaableApi.d.ts","sourceRoot":"","sources":["../src/FaableApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEpE,OAAO,EAEL,SAAS,EACT,gBAAgB,EACjB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,IAAI,CAAC,EAAE,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC/B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;CACvC,CAAC;AAEF,8BAAsB,SAAS,CAAC,MAAM,SAAS,SAAS,GAAG,SAAS;IAClE,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC;IAC/B,SAAS,aAAa,MAAM,CAAC,EAAE,MAAM;IAMrC,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,QAAQ,MAAM,IAAI,EAAE,MAAM,KAAK,GAAG,EAAE,MAAM,GAAG,GAAG,EACtE,IAAI,EAAE,CAAC,EACP,MAAM,CAAC,EAAE,MAAM,GACd,YAAY,CAAC,CAAC,CAAC;CAInB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client_credentials.d.ts","sourceRoot":"","sources":["../../../src/auth/client_credentials/client_credentials.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAKrE,KAAK,MAAM,GAAG;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG,OAAO,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"client_credentials.d.ts","sourceRoot":"","sources":["../../../src/auth/client_credentials/client_credentials.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAKrE,KAAK,MAAM,GAAG;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG,OAAO,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAWrE,eAAO,MAAM,uBAAuB,EAAE,iBAAiB,CACrD,2BAA2B,CAgG5B,CAAC"}
|
|
@@ -4,6 +4,10 @@ import PQueue from "p-queue";
|
|
|
4
4
|
const CLIENT_ID_ENV = "FAABLEAUTH_CLIENT_ID";
|
|
5
5
|
const CLIENT_SECRET_ENV = "FAABLEAUTH_CLIENT_SECRET";
|
|
6
6
|
const AUTH_DOMAIN = "FAABLEAUTH_DOMAIN";
|
|
7
|
+
// Refresh the cached token this many seconds before its real expiry, so a
|
|
8
|
+
// request that starts just before the boundary doesn't ship a token that
|
|
9
|
+
// expires mid-flight.
|
|
10
|
+
const EXPIRY_SKEW_SECONDS = 60;
|
|
7
11
|
export const createClientCredentials = (params) => {
|
|
8
12
|
const client_id = params?.client_id || process.env[CLIENT_ID_ENV];
|
|
9
13
|
const client_secret = params?.client_secret || process.env[CLIENT_SECRET_ENV];
|
|
@@ -22,7 +26,15 @@ export const createClientCredentials = (params) => {
|
|
|
22
26
|
const queue = new PQueue({ concurrency: 1, timeout: 20 * 1000 });
|
|
23
27
|
const isTokenExpired = (token, issued_at) => {
|
|
24
28
|
const { expires_in } = token;
|
|
25
|
-
|
|
29
|
+
// `expires_in` is in SECONDS (OAuth 2.0 §5.1), but `issued_at` and
|
|
30
|
+
// `Date.now()` are in MILLISECONDS. The previous code compared
|
|
31
|
+
// `issued_at + expires_in` (ms + s) against `Date.now()` (ms), so a
|
|
32
|
+
// 24h (86400s) token was treated as expired after ~86s — causing the
|
|
33
|
+
// SDK to re-request a token ~1000× more often than needed and hammer
|
|
34
|
+
// the /oauth/token endpoint. Convert to ms and refresh a bit early
|
|
35
|
+
// (skew) so an in-flight request never ships an about-to-expire token.
|
|
36
|
+
const expires_at = issued_at + (expires_in - EXPIRY_SKEW_SECONDS) * 1000;
|
|
37
|
+
return expires_at < Date.now();
|
|
26
38
|
};
|
|
27
39
|
const fetcher = fetcher_axios({
|
|
28
40
|
baseURL: auth_domain,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faable/sdk-base",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"author": "Marc Pomar <marc@faable.com>",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"nock": "^13.5.5",
|
|
25
25
|
"openapi-typescript": "^7.4.0",
|
|
26
26
|
"rimraf": "^6.0.1",
|
|
27
|
-
"semantic-release": "^
|
|
27
|
+
"semantic-release": "^25.0.3",
|
|
28
28
|
"tsimp": "^2.0.11",
|
|
29
29
|
"tsx": "^4.19.1",
|
|
30
30
|
"typescript": "^5.6.2",
|
|
@@ -42,10 +42,15 @@
|
|
|
42
42
|
"main"
|
|
43
43
|
],
|
|
44
44
|
"plugins": [
|
|
45
|
+
"@semantic-release/commit-analyzer",
|
|
45
46
|
"@semantic-release/release-notes-generator",
|
|
46
47
|
"@semantic-release/github",
|
|
47
48
|
[
|
|
48
|
-
"@semantic-release/npm"
|
|
49
|
+
"@semantic-release/npm",
|
|
50
|
+
{
|
|
51
|
+
"npmPublish": true,
|
|
52
|
+
"useOidc": true
|
|
53
|
+
}
|
|
49
54
|
]
|
|
50
55
|
]
|
|
51
56
|
}
|