@absolutejs/auth 0.55.0 → 0.55.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/README.md +7 -0
- package/dist/agents/index.js +43 -36
- package/dist/agents/index.js.map +3 -3
- package/dist/agents/routes.d.ts +32 -0
- package/dist/apikeys/routes.d.ts +2 -2
- package/dist/authInstance.d.ts +12 -0
- package/dist/authorization/protectPermission.d.ts +2 -2
- package/dist/credentials/login.d.ts +4 -4
- package/dist/credentials/routes.d.ts +4 -4
- package/dist/index.d.ts +3 -303
- package/dist/index.js +154 -143
- package/dist/index.js.map +5 -5
- package/dist/mfa/routes.d.ts +2 -2
- package/dist/mfa/sms.d.ts +2 -2
- package/dist/oidc/routes.d.ts +14 -14
- package/dist/organizations/routes.d.ts +1 -1
- package/dist/portal/routes.d.ts +3 -3
- package/dist/roles/routes.d.ts +1 -1
- package/dist/routes/protectRoute.d.ts +2 -2
- package/dist/routes/refresh.d.ts +1 -1
- package/dist/routes/revoke.d.ts +1 -1
- package/dist/routes/sessions.d.ts +3 -3
- package/dist/server.d.ts +18 -0
- package/dist/server.js +29362 -0
- package/dist/server.js.map +287 -0
- package/dist/sso/discoveryRoute.d.ts +1 -1
- package/dist/sso/oidcRoutes.d.ts +2 -2
- package/dist/sso/samlRoutes.d.ts +4 -4
- package/dist/utils.d.ts +1 -1
- package/package.json +9 -4
package/README.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Absolute Auth
|
|
2
2
|
|
|
3
|
+
Server applications should import the primary authentication contract from
|
|
4
|
+
`@absolutejs/auth/server`. This declaration-stable entry point exposes `auth`,
|
|
5
|
+
session types, route protection, provider configuration, and the other core
|
|
6
|
+
server utilities without loading declarations for every optional Auth feature.
|
|
7
|
+
The root entry point remains available for applications that need the complete
|
|
8
|
+
feature export surface.
|
|
9
|
+
|
|
3
10
|
## Overview
|
|
4
11
|
|
|
5
12
|
Absolute Auth is a TypeScript-based authentication system that provides a comprehensive solution for handling user authentication in web applications. It supports multiple authentication providers and offers features such as authorization, callback handling, token refresh, token revocation, and session management.
|
package/dist/agents/index.js
CHANGED
|
@@ -1425,10 +1425,16 @@ var resolveAgentPrincipal = async (request, config) => {
|
|
|
1425
1425
|
};
|
|
1426
1426
|
// src/agents/routes.ts
|
|
1427
1427
|
import { Elysia } from "elysia";
|
|
1428
|
+
var DELETE_CODE_POINT = 127;
|
|
1429
|
+
var HTTP_BAD_REQUEST = 400;
|
|
1430
|
+
var HTTP_FORBIDDEN = 403;
|
|
1431
|
+
var HTTP_OK = 200;
|
|
1432
|
+
var HTTP_UNAUTHORIZED = 401;
|
|
1433
|
+
var MINIMUM_PRINTABLE_CODE_POINT = 32;
|
|
1428
1434
|
var quoteHeaderValue = (value) => {
|
|
1429
1435
|
const printable = [...value].filter((character) => {
|
|
1430
1436
|
const codePoint = character.codePointAt(0) ?? 0;
|
|
1431
|
-
return codePoint >=
|
|
1437
|
+
return codePoint >= MINIMUM_PRINTABLE_CODE_POINT && codePoint !== DELETE_CODE_POINT;
|
|
1432
1438
|
}).join("");
|
|
1433
1439
|
return `"${printable.replace(/[\\"]/g, "\\$&")}"`;
|
|
1434
1440
|
};
|
|
@@ -1461,9 +1467,9 @@ var failureResponse = (config, failure, requiredScopes) => new Response(JSON.str
|
|
|
1461
1467
|
requiredScopes
|
|
1462
1468
|
})
|
|
1463
1469
|
},
|
|
1464
|
-
status: failure.code === "Forbidden" ?
|
|
1470
|
+
status: failure.code === "Forbidden" ? HTTP_FORBIDDEN : HTTP_UNAUTHORIZED
|
|
1465
1471
|
});
|
|
1466
|
-
var json = (value, status =
|
|
1472
|
+
var json = (value, status = HTTP_OK) => new Response(JSON.stringify(value), {
|
|
1467
1473
|
headers: {
|
|
1468
1474
|
"cache-control": "no-store",
|
|
1469
1475
|
"content-type": "application/json"
|
|
@@ -1497,7 +1503,7 @@ var registrationResponse = (result) => {
|
|
|
1497
1503
|
...body,
|
|
1498
1504
|
error: "interaction_required",
|
|
1499
1505
|
error_description: "Authenticate at the service and confirm the account link."
|
|
1500
|
-
},
|
|
1506
|
+
}, HTTP_UNAUTHORIZED);
|
|
1501
1507
|
}
|
|
1502
1508
|
return json(body);
|
|
1503
1509
|
};
|
|
@@ -1524,34 +1530,35 @@ var parseRegistrationInput = (value) => {
|
|
|
1524
1530
|
return input;
|
|
1525
1531
|
};
|
|
1526
1532
|
var escapeHtml = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """);
|
|
1527
|
-
var
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
return await handleAuthFail?.(failure) ?? new Response(failure.message, { status: 401 });
|
|
1536
|
-
}
|
|
1537
|
-
const principal = await resolveAgentPrincipal(request, config);
|
|
1538
|
-
if (principal === undefined) {
|
|
1539
|
-
const failure = {
|
|
1540
|
-
code: "Unauthorized",
|
|
1541
|
-
message: "Agent is not authenticated"
|
|
1542
|
-
};
|
|
1543
|
-
return await handleAuthFail?.(failure) ?? failureResponse(config, failure, requiredScopes);
|
|
1544
|
-
}
|
|
1545
|
-
if (!agentHasScopes(principal, requiredScopes)) {
|
|
1546
|
-
const failure = {
|
|
1547
|
-
code: "Forbidden",
|
|
1548
|
-
message: "Insufficient agent scopes"
|
|
1549
|
-
};
|
|
1550
|
-
return await handleAuthFail?.(failure) ?? failureResponse(config, failure, requiredScopes);
|
|
1551
|
-
}
|
|
1552
|
-
return handleAuth(principal);
|
|
1533
|
+
var agentAuthContextPlugin = (config) => new Elysia().derive(({ request }) => ({
|
|
1534
|
+
protectAgent: async (requiredScopes, handleAuth, handleAuthFail) => {
|
|
1535
|
+
if (config === undefined) {
|
|
1536
|
+
const failure = {
|
|
1537
|
+
code: "Unauthorized",
|
|
1538
|
+
message: "Agent is not authenticated"
|
|
1539
|
+
};
|
|
1540
|
+
return await handleAuthFail?.(failure) ?? new Response(failure.message, { status: 401 });
|
|
1553
1541
|
}
|
|
1554
|
-
|
|
1542
|
+
const principal = await resolveAgentPrincipal(request, config);
|
|
1543
|
+
if (principal === undefined) {
|
|
1544
|
+
const failure = {
|
|
1545
|
+
code: "Unauthorized",
|
|
1546
|
+
message: "Agent is not authenticated"
|
|
1547
|
+
};
|
|
1548
|
+
return await handleAuthFail?.(failure) ?? failureResponse(config, failure, requiredScopes);
|
|
1549
|
+
}
|
|
1550
|
+
if (!agentHasScopes(principal, requiredScopes)) {
|
|
1551
|
+
const failure = {
|
|
1552
|
+
code: "Forbidden",
|
|
1553
|
+
message: "Insufficient agent scopes"
|
|
1554
|
+
};
|
|
1555
|
+
return await handleAuthFail?.(failure) ?? failureResponse(config, failure, requiredScopes);
|
|
1556
|
+
}
|
|
1557
|
+
return handleAuth(principal);
|
|
1558
|
+
}
|
|
1559
|
+
}));
|
|
1560
|
+
var agentAuthPlugin = (config) => {
|
|
1561
|
+
const plugin = agentAuthContextPlugin(config);
|
|
1555
1562
|
if (config === undefined)
|
|
1556
1563
|
return plugin.as("global");
|
|
1557
1564
|
if (config.agentRegistration === undefined) {
|
|
@@ -1582,11 +1589,11 @@ var agentAuthPlugin = (config) => {
|
|
|
1582
1589
|
}).post(identityRoute, async ({ body }) => {
|
|
1583
1590
|
const value = recordBody(body);
|
|
1584
1591
|
if (value === undefined || typeof value.type !== "string") {
|
|
1585
|
-
return json({ error: "invalid_request" },
|
|
1592
|
+
return json({ error: "invalid_request" }, HTTP_BAD_REQUEST);
|
|
1586
1593
|
}
|
|
1587
1594
|
const input = parseRegistrationInput(value);
|
|
1588
1595
|
if (input === undefined)
|
|
1589
|
-
return json({ error: "invalid_request" },
|
|
1596
|
+
return json({ error: "invalid_request" }, HTTP_BAD_REQUEST);
|
|
1590
1597
|
const result = await startAgentRegistration(config, input);
|
|
1591
1598
|
if ("error" in result) {
|
|
1592
1599
|
return json({
|
|
@@ -1598,7 +1605,7 @@ var agentAuthPlugin = (config) => {
|
|
|
1598
1605
|
}).post(claimRoute, async ({ body }) => {
|
|
1599
1606
|
const value = recordBody(body);
|
|
1600
1607
|
if (value === undefined || typeof value.claim_token !== "string" || typeof value.email !== "string") {
|
|
1601
|
-
return json({ error: "invalid_request" },
|
|
1608
|
+
return json({ error: "invalid_request" }, HTTP_BAD_REQUEST);
|
|
1602
1609
|
}
|
|
1603
1610
|
const result = await beginAgentClaim(config, {
|
|
1604
1611
|
claimToken: value.claim_token,
|
|
@@ -1613,7 +1620,7 @@ var agentAuthPlugin = (config) => {
|
|
|
1613
1620
|
value = Object.fromEntries(new URLSearchParams(body));
|
|
1614
1621
|
}
|
|
1615
1622
|
if (value === undefined || typeof value.claim_attempt_token !== "string" || typeof value.user_code !== "string") {
|
|
1616
|
-
return json({ error: "invalid_request" },
|
|
1623
|
+
return json({ error: "invalid_request" }, HTTP_BAD_REQUEST);
|
|
1617
1624
|
}
|
|
1618
1625
|
const result = await completeAgentClaim(config, {
|
|
1619
1626
|
attemptToken: value.claim_attempt_token,
|
|
@@ -12826,5 +12833,5 @@ export {
|
|
|
12826
12833
|
AGENT_CLAIM_GRANT_TYPE
|
|
12827
12834
|
};
|
|
12828
12835
|
|
|
12829
|
-
//# debugId=
|
|
12836
|
+
//# debugId=05CB90C7C290284064756E2164756E21
|
|
12830
12837
|
//# sourceMappingURL=index.js.map
|