@poly-x/sdk 0.1.0 → 0.1.1
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/dist/index.cjs +19 -4
- package/dist/index.d.cts +7 -1
- package/dist/index.d.mts +7 -1
- package/dist/index.mjs +19 -4
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -19,14 +19,21 @@ function resolveServerConfig(options = {}) {
|
|
|
19
19
|
//#endregion
|
|
20
20
|
//#region src/endpoints.ts
|
|
21
21
|
/** Server-side PolyX endpoint paths (relative to the deployment base URL). */
|
|
22
|
-
const SERVER_ENDPOINTS = {
|
|
22
|
+
const SERVER_ENDPOINTS = {
|
|
23
|
+
/**
|
|
24
|
+
* poly-auth mounts this under the `/auth` router, so the `/auth` segment is part of
|
|
25
|
+
* the path — `/v1/authz/introspect` (shipped in 0.1.0) does not exist on the platform.
|
|
26
|
+
* Source of truth: poly-auth `api/routes/v1/auth.route.ts` and the in-platform caller
|
|
27
|
+
* poly-common `middlewares/poly-auth-authz.ts`.
|
|
28
|
+
*/
|
|
29
|
+
introspect: "/v1/auth/authz/introspect" };
|
|
23
30
|
/** Header carrying the App secret key — the v4 requireAppKey contract (ADR-0008). */
|
|
24
31
|
const SECRET_KEY_HEADER = "X-PolyX-Secret-Key";
|
|
25
32
|
//#endregion
|
|
26
33
|
//#region src/introspect.ts
|
|
27
34
|
/**
|
|
28
35
|
* Token introspection (F008) — the server-side "is this caller's session
|
|
29
|
-
* valid, and who are they" check. Wraps poly-auth's `POST /v1/authz/introspect`
|
|
36
|
+
* valid, and who are they" check. Wraps poly-auth's `POST /v1/auth/authz/introspect`
|
|
30
37
|
* and normalizes its authz body into a stable `IntrospectionResult`.
|
|
31
38
|
*/
|
|
32
39
|
function asRecord(value) {
|
|
@@ -57,8 +64,11 @@ async function introspectToken(deps, token) {
|
|
|
57
64
|
const response = await deps.transport.request({
|
|
58
65
|
method: "POST",
|
|
59
66
|
url: deps.config.baseUrl + SERVER_ENDPOINTS.introspect,
|
|
60
|
-
headers: {
|
|
61
|
-
|
|
67
|
+
headers: {
|
|
68
|
+
Authorization: `Bearer ${token}`,
|
|
69
|
+
[SECRET_KEY_HEADER]: deps.secretKey
|
|
70
|
+
},
|
|
71
|
+
body: { accessToken: token }
|
|
62
72
|
});
|
|
63
73
|
if (response.status === 200) return normalizeIntrospection(response.body);
|
|
64
74
|
if (response.status === 401) return {
|
|
@@ -66,6 +76,11 @@ async function introspectToken(deps, token) {
|
|
|
66
76
|
roles: [],
|
|
67
77
|
raw: response.body
|
|
68
78
|
};
|
|
79
|
+
if (response.status === 400) return {
|
|
80
|
+
active: false,
|
|
81
|
+
roles: [],
|
|
82
|
+
raw: response.body
|
|
83
|
+
};
|
|
69
84
|
const error = (0, _poly_x_core.mapPlatformError)({
|
|
70
85
|
status: response.status,
|
|
71
86
|
body: response.body,
|
package/dist/index.d.cts
CHANGED
|
@@ -72,7 +72,13 @@ declare function createPolyX(options?: PolyXOptions): PolyX;
|
|
|
72
72
|
//#region src/endpoints.d.ts
|
|
73
73
|
/** Server-side PolyX endpoint paths (relative to the deployment base URL). */
|
|
74
74
|
declare const SERVER_ENDPOINTS: {
|
|
75
|
-
|
|
75
|
+
/**
|
|
76
|
+
* poly-auth mounts this under the `/auth` router, so the `/auth` segment is part of
|
|
77
|
+
* the path — `/v1/authz/introspect` (shipped in 0.1.0) does not exist on the platform.
|
|
78
|
+
* Source of truth: poly-auth `api/routes/v1/auth.route.ts` and the in-platform caller
|
|
79
|
+
* poly-common `middlewares/poly-auth-authz.ts`.
|
|
80
|
+
*/
|
|
81
|
+
readonly introspect: "/v1/auth/authz/introspect";
|
|
76
82
|
};
|
|
77
83
|
/** Header carrying the App secret key — the v4 requireAppKey contract (ADR-0008). */
|
|
78
84
|
declare const SECRET_KEY_HEADER = "X-PolyX-Secret-Key";
|
package/dist/index.d.mts
CHANGED
|
@@ -72,7 +72,13 @@ declare function createPolyX(options?: PolyXOptions): PolyX;
|
|
|
72
72
|
//#region src/endpoints.d.ts
|
|
73
73
|
/** Server-side PolyX endpoint paths (relative to the deployment base URL). */
|
|
74
74
|
declare const SERVER_ENDPOINTS: {
|
|
75
|
-
|
|
75
|
+
/**
|
|
76
|
+
* poly-auth mounts this under the `/auth` router, so the `/auth` segment is part of
|
|
77
|
+
* the path — `/v1/authz/introspect` (shipped in 0.1.0) does not exist on the platform.
|
|
78
|
+
* Source of truth: poly-auth `api/routes/v1/auth.route.ts` and the in-platform caller
|
|
79
|
+
* poly-common `middlewares/poly-auth-authz.ts`.
|
|
80
|
+
*/
|
|
81
|
+
readonly introspect: "/v1/auth/authz/introspect";
|
|
76
82
|
};
|
|
77
83
|
/** Header carrying the App secret key — the v4 requireAppKey contract (ADR-0008). */
|
|
78
84
|
declare const SECRET_KEY_HEADER = "X-PolyX-Secret-Key";
|
package/dist/index.mjs
CHANGED
|
@@ -18,14 +18,21 @@ function resolveServerConfig(options = {}) {
|
|
|
18
18
|
//#endregion
|
|
19
19
|
//#region src/endpoints.ts
|
|
20
20
|
/** Server-side PolyX endpoint paths (relative to the deployment base URL). */
|
|
21
|
-
const SERVER_ENDPOINTS = {
|
|
21
|
+
const SERVER_ENDPOINTS = {
|
|
22
|
+
/**
|
|
23
|
+
* poly-auth mounts this under the `/auth` router, so the `/auth` segment is part of
|
|
24
|
+
* the path — `/v1/authz/introspect` (shipped in 0.1.0) does not exist on the platform.
|
|
25
|
+
* Source of truth: poly-auth `api/routes/v1/auth.route.ts` and the in-platform caller
|
|
26
|
+
* poly-common `middlewares/poly-auth-authz.ts`.
|
|
27
|
+
*/
|
|
28
|
+
introspect: "/v1/auth/authz/introspect" };
|
|
22
29
|
/** Header carrying the App secret key — the v4 requireAppKey contract (ADR-0008). */
|
|
23
30
|
const SECRET_KEY_HEADER = "X-PolyX-Secret-Key";
|
|
24
31
|
//#endregion
|
|
25
32
|
//#region src/introspect.ts
|
|
26
33
|
/**
|
|
27
34
|
* Token introspection (F008) — the server-side "is this caller's session
|
|
28
|
-
* valid, and who are they" check. Wraps poly-auth's `POST /v1/authz/introspect`
|
|
35
|
+
* valid, and who are they" check. Wraps poly-auth's `POST /v1/auth/authz/introspect`
|
|
29
36
|
* and normalizes its authz body into a stable `IntrospectionResult`.
|
|
30
37
|
*/
|
|
31
38
|
function asRecord(value) {
|
|
@@ -56,8 +63,11 @@ async function introspectToken(deps, token) {
|
|
|
56
63
|
const response = await deps.transport.request({
|
|
57
64
|
method: "POST",
|
|
58
65
|
url: deps.config.baseUrl + SERVER_ENDPOINTS.introspect,
|
|
59
|
-
headers: {
|
|
60
|
-
|
|
66
|
+
headers: {
|
|
67
|
+
Authorization: `Bearer ${token}`,
|
|
68
|
+
[SECRET_KEY_HEADER]: deps.secretKey
|
|
69
|
+
},
|
|
70
|
+
body: { accessToken: token }
|
|
61
71
|
});
|
|
62
72
|
if (response.status === 200) return normalizeIntrospection(response.body);
|
|
63
73
|
if (response.status === 401) return {
|
|
@@ -65,6 +75,11 @@ async function introspectToken(deps, token) {
|
|
|
65
75
|
roles: [],
|
|
66
76
|
raw: response.body
|
|
67
77
|
};
|
|
78
|
+
if (response.status === 400) return {
|
|
79
|
+
active: false,
|
|
80
|
+
roles: [],
|
|
81
|
+
raw: response.body
|
|
82
|
+
};
|
|
68
83
|
const error = mapPlatformError({
|
|
69
84
|
status: response.status,
|
|
70
85
|
body: response.body,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@poly-x/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "PolyX SDK for Node servers - unified client and framework adapters",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"module": "./dist/index.mjs",
|
|
25
25
|
"types": "./dist/index.d.cts",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@poly-x/core": "0.1.
|
|
27
|
+
"@poly-x/core": "0.1.1"
|
|
28
28
|
},
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|