@absolutejs/auth 0.55.1 → 0.55.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.
- package/dist/agents/context.d.ts +46 -0
- package/dist/agents/index.d.ts +2 -1
- package/dist/agents/index.js +35 -32
- package/dist/agents/index.js.map +5 -4
- package/dist/agents/routes.d.ts +29 -54
- package/dist/apikeys/routes.d.ts +2 -2
- package/dist/authInstance.d.ts +4 -9
- package/dist/credentials/login.d.ts +4 -4
- package/dist/credentials/routes.d.ts +4 -4
- package/dist/index.d.ts +0 -63
- package/dist/index.js +98 -95
- package/dist/index.js.map +5 -4
- 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/refresh.d.ts +1 -1
- package/dist/routes/revoke.d.ts +1 -1
- package/dist/routes/sessions.d.ts +3 -3
- package/dist/server.js +98 -95
- package/dist/server.js.map +5 -4
- 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/package.json +1 -1
package/dist/mfa/routes.d.ts
CHANGED
|
@@ -138,10 +138,10 @@ export declare const mfaRoutes: <UserType>(config: MfaRouteProps<UserType>) => E
|
|
|
138
138
|
response: {
|
|
139
139
|
400: "Phone must be in E.164 format";
|
|
140
140
|
401: "Authentication required";
|
|
141
|
-
501: "SMS MFA is not configured";
|
|
142
141
|
200: {
|
|
143
142
|
readonly phone: string;
|
|
144
143
|
};
|
|
144
|
+
501: "SMS MFA is not configured";
|
|
145
145
|
422: {
|
|
146
146
|
type: "validation";
|
|
147
147
|
on: string;
|
|
@@ -169,6 +169,7 @@ export declare const mfaRoutes: <UserType>(config: MfaRouteProps<UserType>) => E
|
|
|
169
169
|
200: {
|
|
170
170
|
readonly status: "enrolled";
|
|
171
171
|
};
|
|
172
|
+
429: "Too many attempts";
|
|
172
173
|
422: {
|
|
173
174
|
type: "validation";
|
|
174
175
|
on: string;
|
|
@@ -178,7 +179,6 @@ export declare const mfaRoutes: <UserType>(config: MfaRouteProps<UserType>) => E
|
|
|
178
179
|
property?: string;
|
|
179
180
|
expected?: string;
|
|
180
181
|
};
|
|
181
|
-
429: "Too many attempts";
|
|
182
182
|
};
|
|
183
183
|
};
|
|
184
184
|
};
|
package/dist/mfa/sms.d.ts
CHANGED
|
@@ -40,10 +40,10 @@ export declare const mfaSmsRoutes: <UserType>({ authSessionStore, getUserId, mfa
|
|
|
40
40
|
response: {
|
|
41
41
|
400: "Phone must be in E.164 format";
|
|
42
42
|
401: "Authentication required";
|
|
43
|
-
501: "SMS MFA is not configured";
|
|
44
43
|
200: {
|
|
45
44
|
readonly phone: string;
|
|
46
45
|
};
|
|
46
|
+
501: "SMS MFA is not configured";
|
|
47
47
|
422: {
|
|
48
48
|
type: "validation";
|
|
49
49
|
on: string;
|
|
@@ -71,6 +71,7 @@ export declare const mfaSmsRoutes: <UserType>({ authSessionStore, getUserId, mfa
|
|
|
71
71
|
200: {
|
|
72
72
|
readonly status: "enrolled";
|
|
73
73
|
};
|
|
74
|
+
429: "Too many attempts";
|
|
74
75
|
422: {
|
|
75
76
|
type: "validation";
|
|
76
77
|
on: string;
|
|
@@ -80,7 +81,6 @@ export declare const mfaSmsRoutes: <UserType>({ authSessionStore, getUserId, mfa
|
|
|
80
81
|
property?: string;
|
|
81
82
|
expected?: string;
|
|
82
83
|
};
|
|
83
|
-
429: "Too many attempts";
|
|
84
84
|
};
|
|
85
85
|
};
|
|
86
86
|
};
|
package/dist/oidc/routes.d.ts
CHANGED
|
@@ -27,8 +27,8 @@ export declare const oidcProviderRoutes: <UserType>(config: OidcProviderConfig<U
|
|
|
27
27
|
body: unknown;
|
|
28
28
|
params: {};
|
|
29
29
|
query: {
|
|
30
|
-
client_id?: string | undefined;
|
|
31
30
|
scope?: string | undefined;
|
|
31
|
+
client_id?: string | undefined;
|
|
32
32
|
nonce?: string | undefined;
|
|
33
33
|
claims?: string | undefined;
|
|
34
34
|
request?: string | undefined;
|
|
@@ -63,18 +63,18 @@ export declare const oidcProviderRoutes: <UserType>(config: OidcProviderConfig<U
|
|
|
63
63
|
[x: string]: {
|
|
64
64
|
post: {
|
|
65
65
|
body: {
|
|
66
|
-
|
|
66
|
+
grant_type?: string | undefined;
|
|
67
|
+
claim_token?: string | undefined;
|
|
67
68
|
scope?: string | undefined;
|
|
68
|
-
|
|
69
|
+
assertion?: string | undefined;
|
|
69
70
|
resource?: string | undefined;
|
|
71
|
+
client_id?: string | undefined;
|
|
72
|
+
audience?: string | undefined;
|
|
70
73
|
refresh_token?: string | undefined;
|
|
71
74
|
device_code?: string | undefined;
|
|
72
75
|
auth_req_id?: string | undefined;
|
|
73
|
-
grant_type?: string | undefined;
|
|
74
|
-
claim_token?: string | undefined;
|
|
75
|
-
assertion?: string | undefined;
|
|
76
|
-
code?: string | undefined;
|
|
77
76
|
client_secret?: string | undefined;
|
|
77
|
+
code?: string | undefined;
|
|
78
78
|
redirect_uri?: string | undefined;
|
|
79
79
|
client_assertion?: string | undefined;
|
|
80
80
|
client_assertion_type?: string | undefined;
|
|
@@ -104,12 +104,12 @@ export declare const oidcProviderRoutes: <UserType>(config: OidcProviderConfig<U
|
|
|
104
104
|
[x: string]: {
|
|
105
105
|
post: {
|
|
106
106
|
body: {
|
|
107
|
-
client_id?: string | undefined;
|
|
108
107
|
scope?: string | undefined;
|
|
108
|
+
resource?: string | undefined;
|
|
109
|
+
client_id?: string | undefined;
|
|
109
110
|
nonce?: string | undefined;
|
|
110
111
|
audience?: string | undefined;
|
|
111
112
|
claims?: string | undefined;
|
|
112
|
-
resource?: string | undefined;
|
|
113
113
|
client_secret?: string | undefined;
|
|
114
114
|
redirect_uri?: string | undefined;
|
|
115
115
|
acr_values?: string | undefined;
|
|
@@ -199,10 +199,10 @@ export declare const oidcProviderRoutes: <UserType>(config: OidcProviderConfig<U
|
|
|
199
199
|
[x: string]: {
|
|
200
200
|
post: {
|
|
201
201
|
body: {
|
|
202
|
-
client_id?: string | undefined;
|
|
203
202
|
scope?: string | undefined;
|
|
204
|
-
|
|
203
|
+
client_id?: string | undefined;
|
|
205
204
|
client_secret?: string | undefined;
|
|
205
|
+
login_hint?: string | undefined;
|
|
206
206
|
binding_message?: string | undefined;
|
|
207
207
|
};
|
|
208
208
|
params: {};
|
|
@@ -228,8 +228,8 @@ export declare const oidcProviderRoutes: <UserType>(config: OidcProviderConfig<U
|
|
|
228
228
|
[x: string]: {
|
|
229
229
|
post: {
|
|
230
230
|
body: {
|
|
231
|
-
client_id?: string | undefined;
|
|
232
231
|
scope?: string | undefined;
|
|
232
|
+
client_id?: string | undefined;
|
|
233
233
|
client_secret?: string | undefined;
|
|
234
234
|
};
|
|
235
235
|
params: {};
|
|
@@ -331,8 +331,8 @@ export declare const oidcProviderRoutes: <UserType>(config: OidcProviderConfig<U
|
|
|
331
331
|
[x: string]: {
|
|
332
332
|
post: {
|
|
333
333
|
body: {
|
|
334
|
-
jwks?: any;
|
|
335
334
|
scope?: string | undefined;
|
|
335
|
+
jwks?: any;
|
|
336
336
|
backchannel_logout_uri?: string | undefined;
|
|
337
337
|
client_name?: string | undefined;
|
|
338
338
|
grant_types?: string[] | undefined;
|
|
@@ -391,8 +391,8 @@ export declare const oidcProviderRoutes: <UserType>(config: OidcProviderConfig<U
|
|
|
391
391
|
":clientId": {
|
|
392
392
|
put: {
|
|
393
393
|
body: {
|
|
394
|
-
jwks?: any;
|
|
395
394
|
scope?: string | undefined;
|
|
395
|
+
jwks?: any;
|
|
396
396
|
backchannel_logout_uri?: string | undefined;
|
|
397
397
|
client_name?: string | undefined;
|
|
398
398
|
grant_types?: string[] | undefined;
|
|
@@ -162,10 +162,10 @@ export declare const organizationRoutes: <UserType>({ authSessionStore, canCreat
|
|
|
162
162
|
response: {
|
|
163
163
|
401: "Authentication required";
|
|
164
164
|
403: "Cannot manage members";
|
|
165
|
-
404: "Invitation not found";
|
|
166
165
|
200: {
|
|
167
166
|
readonly revoked: string;
|
|
168
167
|
};
|
|
168
|
+
404: "Invitation not found";
|
|
169
169
|
422: {
|
|
170
170
|
type: "validation";
|
|
171
171
|
on: string;
|
package/dist/portal/routes.d.ts
CHANGED
|
@@ -66,11 +66,11 @@ export declare const portalRoutes: ({ emit, onScimTokenCreated, onSsoConnectionC
|
|
|
66
66
|
response: {
|
|
67
67
|
401: "Invalid or expired setup link";
|
|
68
68
|
403: "This setup link cannot configure SAML";
|
|
69
|
-
501: "SSO is not configured";
|
|
70
69
|
200: {
|
|
71
70
|
readonly configured: true;
|
|
72
71
|
readonly type: "saml";
|
|
73
72
|
};
|
|
73
|
+
501: "SSO is not configured";
|
|
74
74
|
422: {
|
|
75
75
|
type: "validation";
|
|
76
76
|
on: string;
|
|
@@ -103,11 +103,11 @@ export declare const portalRoutes: ({ emit, onScimTokenCreated, onSsoConnectionC
|
|
|
103
103
|
response: {
|
|
104
104
|
401: "Invalid or expired setup link";
|
|
105
105
|
403: "This setup link cannot configure OIDC";
|
|
106
|
-
501: "SSO is not configured";
|
|
107
106
|
200: {
|
|
108
107
|
readonly configured: true;
|
|
109
108
|
readonly type: "oidc";
|
|
110
109
|
};
|
|
110
|
+
501: "SSO is not configured";
|
|
111
111
|
422: {
|
|
112
112
|
type: "validation";
|
|
113
113
|
on: string;
|
|
@@ -134,12 +134,12 @@ export declare const portalRoutes: ({ emit, onScimTokenCreated, onSsoConnectionC
|
|
|
134
134
|
response: {
|
|
135
135
|
401: "Invalid or expired setup link";
|
|
136
136
|
403: "This setup link cannot configure SCIM";
|
|
137
|
-
501: "SCIM is not configured";
|
|
138
137
|
200: {
|
|
139
138
|
readonly baseUrl: `${string}/${string}`;
|
|
140
139
|
readonly token: string;
|
|
141
140
|
readonly tokenId: string;
|
|
142
141
|
};
|
|
142
|
+
501: "SCIM is not configured";
|
|
143
143
|
};
|
|
144
144
|
};
|
|
145
145
|
};
|
package/dist/roles/routes.d.ts
CHANGED
|
@@ -66,10 +66,10 @@ export declare const roleRoutes: <UserType>({ authSessionStore, canManageRoles,
|
|
|
66
66
|
response: {
|
|
67
67
|
401: "Authentication required";
|
|
68
68
|
403: "Cannot manage roles";
|
|
69
|
-
404: "Membership not found";
|
|
70
69
|
200: {
|
|
71
70
|
readonly roles: string[];
|
|
72
71
|
};
|
|
72
|
+
404: "Membership not found";
|
|
73
73
|
422: {
|
|
74
74
|
type: "validation";
|
|
75
75
|
on: string;
|
package/dist/routes/refresh.d.ts
CHANGED
|
@@ -37,8 +37,8 @@ export declare const refresh: <UserType>({ authSessionStore, clientProviders, re
|
|
|
37
37
|
response: {
|
|
38
38
|
400: "Cookies are missing" | "Invalid provider" | "No refresh token found";
|
|
39
39
|
401: "Provider is required" | "Client provider not found" | "Client variant is required" | "Client variant not found" | "No auth provider found" | "No user session found";
|
|
40
|
-
501: "Provider is not refreshable";
|
|
41
40
|
200: Response;
|
|
41
|
+
501: "Provider is not refreshable";
|
|
42
42
|
422: {
|
|
43
43
|
type: "validation";
|
|
44
44
|
on: string;
|
package/dist/routes/revoke.d.ts
CHANGED
|
@@ -36,8 +36,8 @@ export declare const revoke: <UserType>({ authSessionStore, clientProviders, rev
|
|
|
36
36
|
response: {
|
|
37
37
|
400: "Cookies are missing" | "Invalid provider" | "Session has no access token to revoke";
|
|
38
38
|
401: "Provider is required" | "Client provider not found" | "Client variant is required" | "Client variant not found" | "No auth provider found" | "No user session found";
|
|
39
|
-
501: "Provider does not support revocation";
|
|
40
39
|
200: Response;
|
|
40
|
+
501: "Provider does not support revocation";
|
|
41
41
|
422: {
|
|
42
42
|
type: "validation";
|
|
43
43
|
on: string;
|
|
@@ -34,10 +34,10 @@ export declare const sessionRoutes: <UserType>({ authSessionStore, getUserId, se
|
|
|
34
34
|
headers: unknown;
|
|
35
35
|
response: {
|
|
36
36
|
401: "Authentication required";
|
|
37
|
-
501: "Session management requires an authSessionStore";
|
|
38
37
|
200: {
|
|
39
38
|
readonly sessions: SessionSummary[];
|
|
40
39
|
};
|
|
40
|
+
501: "Session management requires an authSessionStore";
|
|
41
41
|
422: {
|
|
42
42
|
type: "validation";
|
|
43
43
|
on: string;
|
|
@@ -63,11 +63,11 @@ export declare const sessionRoutes: <UserType>({ authSessionStore, getUserId, se
|
|
|
63
63
|
response: {
|
|
64
64
|
400: "Invalid session id";
|
|
65
65
|
401: "Authentication required";
|
|
66
|
-
501: "Session management requires an authSessionStore";
|
|
67
|
-
404: "Session not found";
|
|
68
66
|
200: {
|
|
69
67
|
readonly revoked: `${string}-${string}-${string}-${string}-${string}`;
|
|
70
68
|
};
|
|
69
|
+
501: "Session management requires an authSessionStore";
|
|
70
|
+
404: "Session not found";
|
|
71
71
|
422: {
|
|
72
72
|
type: "validation";
|
|
73
73
|
on: string;
|
package/dist/server.js
CHANGED
|
@@ -3044,9 +3044,6 @@ var apiKeysRoutes = ({
|
|
|
3044
3044
|
});
|
|
3045
3045
|
};
|
|
3046
3046
|
|
|
3047
|
-
// src/agents/routes.ts
|
|
3048
|
-
import { Elysia as Elysia2 } from "elysia";
|
|
3049
|
-
|
|
3050
3047
|
// src/agents/config.ts
|
|
3051
3048
|
var DEFAULT_AGENT_RESOURCE_METADATA_ROUTE = "/.well-known/oauth-protected-resource";
|
|
3052
3049
|
var agentProtectedResourceMetadata = (config) => ({
|
|
@@ -3058,6 +3055,9 @@ var agentProtectedResourceMetadata = (config) => ({
|
|
|
3058
3055
|
scopes_supported: config.scopes
|
|
3059
3056
|
});
|
|
3060
3057
|
|
|
3058
|
+
// src/agents/context.ts
|
|
3059
|
+
import { Elysia as Elysia2 } from "elysia";
|
|
3060
|
+
|
|
3061
3061
|
// src/agents/principal.ts
|
|
3062
3062
|
var intersectScopes = (...sets) => {
|
|
3063
3063
|
if (sets.length === 0)
|
|
@@ -3112,6 +3112,77 @@ var resolveAgentPrincipal = async (request, config) => {
|
|
|
3112
3112
|
};
|
|
3113
3113
|
};
|
|
3114
3114
|
|
|
3115
|
+
// src/agents/context.ts
|
|
3116
|
+
var DELETE_CODE_POINT = 127;
|
|
3117
|
+
var HTTP_FORBIDDEN = 403;
|
|
3118
|
+
var HTTP_UNAUTHORIZED2 = 401;
|
|
3119
|
+
var MINIMUM_PRINTABLE_CODE_POINT = 32;
|
|
3120
|
+
var quoteHeaderValue = (value) => {
|
|
3121
|
+
const printable = [...value].filter((character) => {
|
|
3122
|
+
const codePoint = character.codePointAt(0) ?? 0;
|
|
3123
|
+
return codePoint >= MINIMUM_PRINTABLE_CODE_POINT && codePoint !== DELETE_CODE_POINT;
|
|
3124
|
+
}).join("");
|
|
3125
|
+
return `"${printable.replace(/[\\"]/g, "\\$&")}"`;
|
|
3126
|
+
};
|
|
3127
|
+
var agentAuthChallenge = ({
|
|
3128
|
+
config,
|
|
3129
|
+
error,
|
|
3130
|
+
requiredScopes = []
|
|
3131
|
+
}) => {
|
|
3132
|
+
const parameters = [
|
|
3133
|
+
`resource_metadata=${quoteHeaderValue(agentResourceMetadataUrl(config))}`
|
|
3134
|
+
];
|
|
3135
|
+
if (requiredScopes.length > 0) {
|
|
3136
|
+
parameters.push(`scope=${quoteHeaderValue(requiredScopes.join(" "))}`);
|
|
3137
|
+
}
|
|
3138
|
+
if (error !== undefined) {
|
|
3139
|
+
parameters.push(`error=${quoteHeaderValue(error)}`);
|
|
3140
|
+
}
|
|
3141
|
+
return `Bearer ${parameters.join(", ")}`;
|
|
3142
|
+
};
|
|
3143
|
+
var agentResourceMetadataUrl = (config) => new URL(config.metadataRoute ?? DEFAULT_AGENT_RESOURCE_METADATA_ROUTE, config.resource).toString();
|
|
3144
|
+
var failureResponse = (config, failure, requiredScopes) => new Response(JSON.stringify({
|
|
3145
|
+
error: failure.code === "Forbidden" ? "insufficient_scope" : "invalid_token",
|
|
3146
|
+
error_description: failure.message
|
|
3147
|
+
}), {
|
|
3148
|
+
headers: {
|
|
3149
|
+
"content-type": "application/json",
|
|
3150
|
+
"www-authenticate": agentAuthChallenge({
|
|
3151
|
+
config,
|
|
3152
|
+
error: failure.code === "Forbidden" ? "insufficient_scope" : "invalid_token",
|
|
3153
|
+
requiredScopes
|
|
3154
|
+
})
|
|
3155
|
+
},
|
|
3156
|
+
status: failure.code === "Forbidden" ? HTTP_FORBIDDEN : HTTP_UNAUTHORIZED2
|
|
3157
|
+
});
|
|
3158
|
+
var agentAuthContextPlugin = (config) => new Elysia2().derive(({ request }) => ({
|
|
3159
|
+
protectAgent: async (requiredScopes, handleAuth, handleAuthFail) => {
|
|
3160
|
+
if (config === undefined) {
|
|
3161
|
+
const failure = {
|
|
3162
|
+
code: "Unauthorized",
|
|
3163
|
+
message: "Agent is not authenticated"
|
|
3164
|
+
};
|
|
3165
|
+
return await handleAuthFail?.(failure) ?? new Response(failure.message, { status: HTTP_UNAUTHORIZED2 });
|
|
3166
|
+
}
|
|
3167
|
+
const principal = await resolveAgentPrincipal(request, config);
|
|
3168
|
+
if (principal === undefined) {
|
|
3169
|
+
const failure = {
|
|
3170
|
+
code: "Unauthorized",
|
|
3171
|
+
message: "Agent is not authenticated"
|
|
3172
|
+
};
|
|
3173
|
+
return await handleAuthFail?.(failure) ?? failureResponse(config, failure, requiredScopes);
|
|
3174
|
+
}
|
|
3175
|
+
if (!agentHasScopes(principal, requiredScopes)) {
|
|
3176
|
+
const failure = {
|
|
3177
|
+
code: "Forbidden",
|
|
3178
|
+
message: "Insufficient agent scopes"
|
|
3179
|
+
};
|
|
3180
|
+
return await handleAuthFail?.(failure) ?? failureResponse(config, failure, requiredScopes);
|
|
3181
|
+
}
|
|
3182
|
+
return handleAuth(principal);
|
|
3183
|
+
}
|
|
3184
|
+
}));
|
|
3185
|
+
|
|
3115
3186
|
// src/agents/registration.ts
|
|
3116
3187
|
init_constants();
|
|
3117
3188
|
init_crypto();
|
|
@@ -3780,50 +3851,9 @@ var revokeAgentIdentityRegistration = async (config, registrationId, now = Date.
|
|
|
3780
3851
|
};
|
|
3781
3852
|
|
|
3782
3853
|
// src/agents/routes.ts
|
|
3783
|
-
var DELETE_CODE_POINT = 127;
|
|
3784
3854
|
var HTTP_BAD_REQUEST2 = 400;
|
|
3785
|
-
var HTTP_FORBIDDEN = 403;
|
|
3786
3855
|
var HTTP_OK2 = 200;
|
|
3787
|
-
var
|
|
3788
|
-
var MINIMUM_PRINTABLE_CODE_POINT = 32;
|
|
3789
|
-
var quoteHeaderValue = (value) => {
|
|
3790
|
-
const printable = [...value].filter((character) => {
|
|
3791
|
-
const codePoint = character.codePointAt(0) ?? 0;
|
|
3792
|
-
return codePoint >= MINIMUM_PRINTABLE_CODE_POINT && codePoint !== DELETE_CODE_POINT;
|
|
3793
|
-
}).join("");
|
|
3794
|
-
return `"${printable.replace(/[\\"]/g, "\\$&")}"`;
|
|
3795
|
-
};
|
|
3796
|
-
var agentAuthChallenge = ({
|
|
3797
|
-
config,
|
|
3798
|
-
error,
|
|
3799
|
-
requiredScopes = []
|
|
3800
|
-
}) => {
|
|
3801
|
-
const parameters = [
|
|
3802
|
-
`resource_metadata=${quoteHeaderValue(agentResourceMetadataUrl(config))}`
|
|
3803
|
-
];
|
|
3804
|
-
if (requiredScopes.length > 0) {
|
|
3805
|
-
parameters.push(`scope=${quoteHeaderValue(requiredScopes.join(" "))}`);
|
|
3806
|
-
}
|
|
3807
|
-
if (error !== undefined) {
|
|
3808
|
-
parameters.push(`error=${quoteHeaderValue(error)}`);
|
|
3809
|
-
}
|
|
3810
|
-
return `Bearer ${parameters.join(", ")}`;
|
|
3811
|
-
};
|
|
3812
|
-
var agentResourceMetadataUrl = (config) => new URL(config.metadataRoute ?? DEFAULT_AGENT_RESOURCE_METADATA_ROUTE, config.resource).toString();
|
|
3813
|
-
var failureResponse = (config, failure, requiredScopes) => new Response(JSON.stringify({
|
|
3814
|
-
error: failure.code === "Forbidden" ? "insufficient_scope" : "invalid_token",
|
|
3815
|
-
error_description: failure.message
|
|
3816
|
-
}), {
|
|
3817
|
-
headers: {
|
|
3818
|
-
"content-type": "application/json",
|
|
3819
|
-
"www-authenticate": agentAuthChallenge({
|
|
3820
|
-
config,
|
|
3821
|
-
error: failure.code === "Forbidden" ? "insufficient_scope" : "invalid_token",
|
|
3822
|
-
requiredScopes
|
|
3823
|
-
})
|
|
3824
|
-
},
|
|
3825
|
-
status: failure.code === "Forbidden" ? HTTP_FORBIDDEN : HTTP_UNAUTHORIZED2
|
|
3826
|
-
});
|
|
3856
|
+
var HTTP_UNAUTHORIZED3 = 401;
|
|
3827
3857
|
var json = (value, status = HTTP_OK2) => new Response(JSON.stringify(value), {
|
|
3828
3858
|
headers: {
|
|
3829
3859
|
"cache-control": "no-store",
|
|
@@ -3858,7 +3888,7 @@ var registrationResponse = (result) => {
|
|
|
3858
3888
|
...body,
|
|
3859
3889
|
error: "interaction_required",
|
|
3860
3890
|
error_description: "Authenticate at the service and confirm the account link."
|
|
3861
|
-
},
|
|
3891
|
+
}, HTTP_UNAUTHORIZED3);
|
|
3862
3892
|
}
|
|
3863
3893
|
return json(body);
|
|
3864
3894
|
};
|
|
@@ -3885,33 +3915,6 @@ var parseRegistrationInput = (value) => {
|
|
|
3885
3915
|
return input;
|
|
3886
3916
|
};
|
|
3887
3917
|
var escapeHtml = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """);
|
|
3888
|
-
var agentAuthContextPlugin = (config) => new Elysia2().derive(({ request }) => ({
|
|
3889
|
-
protectAgent: async (requiredScopes, handleAuth, handleAuthFail) => {
|
|
3890
|
-
if (config === undefined) {
|
|
3891
|
-
const failure = {
|
|
3892
|
-
code: "Unauthorized",
|
|
3893
|
-
message: "Agent is not authenticated"
|
|
3894
|
-
};
|
|
3895
|
-
return await handleAuthFail?.(failure) ?? new Response(failure.message, { status: 401 });
|
|
3896
|
-
}
|
|
3897
|
-
const principal = await resolveAgentPrincipal(request, config);
|
|
3898
|
-
if (principal === undefined) {
|
|
3899
|
-
const failure = {
|
|
3900
|
-
code: "Unauthorized",
|
|
3901
|
-
message: "Agent is not authenticated"
|
|
3902
|
-
};
|
|
3903
|
-
return await handleAuthFail?.(failure) ?? failureResponse(config, failure, requiredScopes);
|
|
3904
|
-
}
|
|
3905
|
-
if (!agentHasScopes(principal, requiredScopes)) {
|
|
3906
|
-
const failure = {
|
|
3907
|
-
code: "Forbidden",
|
|
3908
|
-
message: "Insufficient agent scopes"
|
|
3909
|
-
};
|
|
3910
|
-
return await handleAuthFail?.(failure) ?? failureResponse(config, failure, requiredScopes);
|
|
3911
|
-
}
|
|
3912
|
-
return handleAuth(principal);
|
|
3913
|
-
}
|
|
3914
|
-
}));
|
|
3915
3918
|
var agentAuthPlugin = (config) => {
|
|
3916
3919
|
const plugin = agentAuthContextPlugin(config);
|
|
3917
3920
|
if (config === undefined)
|
|
@@ -7460,7 +7463,7 @@ var HTTP_OK3 = 200;
|
|
|
7460
7463
|
var HTTP_NO_CONTENT = 204;
|
|
7461
7464
|
var HTTP_FOUND = 302;
|
|
7462
7465
|
var HTTP_BAD_REQUEST3 = 400;
|
|
7463
|
-
var
|
|
7466
|
+
var HTTP_UNAUTHORIZED4 = 401;
|
|
7464
7467
|
var HTTP_NOT_IMPLEMENTED = 501;
|
|
7465
7468
|
var CODE_TTL_MINUTES = 10;
|
|
7466
7469
|
var CODE_TTL_MS = MILLISECONDS_IN_A_MINUTE * CODE_TTL_MINUTES;
|
|
@@ -7634,7 +7637,7 @@ var oidcProviderRoutes = (config) => {
|
|
|
7634
7637
|
"dpop-nonce": fresh,
|
|
7635
7638
|
"www-authenticate": 'DPoP error="use_dpop_nonce"'
|
|
7636
7639
|
},
|
|
7637
|
-
status:
|
|
7640
|
+
status: HTTP_UNAUTHORIZED4
|
|
7638
7641
|
});
|
|
7639
7642
|
};
|
|
7640
7643
|
const grantAuthorizationCode = async (client, body, dpop, clientCertThumbprint) => {
|
|
@@ -8010,7 +8013,7 @@ var oidcProviderRoutes = (config) => {
|
|
|
8010
8013
|
if (wantsSilent) {
|
|
8011
8014
|
return errorRedirect(userSession === undefined ? "login_required" : "interaction_required");
|
|
8012
8015
|
}
|
|
8013
|
-
return loginUrl === undefined ? jsonResponse({ error: "login_required" },
|
|
8016
|
+
return loginUrl === undefined ? jsonResponse({ error: "login_required" }, HTTP_UNAUTHORIZED4) : redirectTo(`${loginUrl}?return_to=${encodeURIComponent(canonicalizeRequestUrl(request.url, issuer))}`);
|
|
8014
8017
|
}
|
|
8015
8018
|
const requested = scope === undefined || scope.length === 0 ? client.scopes : scope.split(" ").filter((entry) => client.scopes.includes(entry));
|
|
8016
8019
|
if (config.consentUrl !== undefined && await config.needsConsent?.({
|
|
@@ -8131,7 +8134,7 @@ var oidcProviderRoutes = (config) => {
|
|
|
8131
8134
|
requestHeaders: request.headers
|
|
8132
8135
|
});
|
|
8133
8136
|
if (auth === undefined) {
|
|
8134
|
-
return oauthError2(
|
|
8137
|
+
return oauthError2(HTTP_UNAUTHORIZED4, "invalid_client");
|
|
8135
8138
|
}
|
|
8136
8139
|
const { client, clientCertThumbprint } = auth;
|
|
8137
8140
|
const nonceChallenge = await dpopNonceChallenge(headers.dpop);
|
|
@@ -8190,7 +8193,7 @@ var oidcProviderRoutes = (config) => {
|
|
|
8190
8193
|
requestHeaders: request.headers
|
|
8191
8194
|
});
|
|
8192
8195
|
if (auth === undefined) {
|
|
8193
|
-
return oauthError2(
|
|
8196
|
+
return oauthError2(HTTP_UNAUTHORIZED4, "invalid_client");
|
|
8194
8197
|
}
|
|
8195
8198
|
const { client } = auth;
|
|
8196
8199
|
const isAuthField = (key) => key === "client_assertion" || key === "client_assertion_type" || key === "client_secret";
|
|
@@ -8228,11 +8231,11 @@ var oidcProviderRoutes = (config) => {
|
|
|
8228
8231
|
const clientId = body.client_id ?? basic.clientId;
|
|
8229
8232
|
const clientSecret = body.client_secret ?? basic.clientSecret;
|
|
8230
8233
|
if (clientId === undefined) {
|
|
8231
|
-
return oauthError2(
|
|
8234
|
+
return oauthError2(HTTP_UNAUTHORIZED4, "invalid_client");
|
|
8232
8235
|
}
|
|
8233
8236
|
const client = await authenticateClient(clientId, clientSecret);
|
|
8234
8237
|
if (client === undefined) {
|
|
8235
|
-
return oauthError2(
|
|
8238
|
+
return oauthError2(HTTP_UNAUTHORIZED4, "invalid_client");
|
|
8236
8239
|
}
|
|
8237
8240
|
const result = await introspectToken({
|
|
8238
8241
|
config,
|
|
@@ -8256,11 +8259,11 @@ var oidcProviderRoutes = (config) => {
|
|
|
8256
8259
|
const clientId = body.client_id ?? basic.clientId;
|
|
8257
8260
|
const clientSecret = body.client_secret ?? basic.clientSecret;
|
|
8258
8261
|
if (clientId === undefined) {
|
|
8259
|
-
return oauthError2(
|
|
8262
|
+
return oauthError2(HTTP_UNAUTHORIZED4, "invalid_client");
|
|
8260
8263
|
}
|
|
8261
8264
|
const client = await authenticateClient(clientId, clientSecret);
|
|
8262
8265
|
if (client === undefined) {
|
|
8263
|
-
return oauthError2(
|
|
8266
|
+
return oauthError2(HTTP_UNAUTHORIZED4, "invalid_client");
|
|
8264
8267
|
}
|
|
8265
8268
|
if (body.token_type_hint !== "access_token") {
|
|
8266
8269
|
await revokeRefreshToken(config, body.token);
|
|
@@ -8284,11 +8287,11 @@ var oidcProviderRoutes = (config) => {
|
|
|
8284
8287
|
const clientId = body.client_id ?? basic.clientId;
|
|
8285
8288
|
const clientSecret = body.client_secret ?? basic.clientSecret;
|
|
8286
8289
|
if (clientId === undefined) {
|
|
8287
|
-
return oauthError2(
|
|
8290
|
+
return oauthError2(HTTP_UNAUTHORIZED4, "invalid_client");
|
|
8288
8291
|
}
|
|
8289
8292
|
const client = await authenticateClient(clientId, clientSecret);
|
|
8290
8293
|
if (client === undefined) {
|
|
8291
|
-
return oauthError2(
|
|
8294
|
+
return oauthError2(HTTP_UNAUTHORIZED4, "invalid_client");
|
|
8292
8295
|
}
|
|
8293
8296
|
if (body.login_hint === undefined) {
|
|
8294
8297
|
return oauthError2(HTTP_BAD_REQUEST3, "invalid_request");
|
|
@@ -8328,11 +8331,11 @@ var oidcProviderRoutes = (config) => {
|
|
|
8328
8331
|
const clientId = body.client_id ?? basic.clientId;
|
|
8329
8332
|
const clientSecret = body.client_secret ?? basic.clientSecret;
|
|
8330
8333
|
if (clientId === undefined) {
|
|
8331
|
-
return oauthError2(
|
|
8334
|
+
return oauthError2(HTTP_UNAUTHORIZED4, "invalid_client");
|
|
8332
8335
|
}
|
|
8333
8336
|
const client = await authenticateClient(clientId, clientSecret);
|
|
8334
8337
|
if (client === undefined) {
|
|
8335
|
-
return oauthError2(
|
|
8338
|
+
return oauthError2(HTTP_UNAUTHORIZED4, "invalid_client");
|
|
8336
8339
|
}
|
|
8337
8340
|
const requested = body.scope === undefined || body.scope.length === 0 ? client.scopes : body.scope.split(" ").filter((entry) => client.scopes.includes(entry));
|
|
8338
8341
|
const response = await issueDeviceAuthorization({
|
|
@@ -8361,7 +8364,7 @@ var oidcProviderRoutes = (config) => {
|
|
|
8361
8364
|
userSessionId: user_session_id.value
|
|
8362
8365
|
});
|
|
8363
8366
|
if (userSession === undefined) {
|
|
8364
|
-
return oauthError2(
|
|
8367
|
+
return oauthError2(HTTP_UNAUTHORIZED4, "login_required");
|
|
8365
8368
|
}
|
|
8366
8369
|
const result = body.action === "deny" ? await denyDeviceAuthorization({
|
|
8367
8370
|
config,
|
|
@@ -8512,7 +8515,7 @@ var oidcProviderRoutes = (config) => {
|
|
|
8512
8515
|
"content-type": "application/json",
|
|
8513
8516
|
"www-authenticate": userInfoChallengeHeader(result.error)
|
|
8514
8517
|
},
|
|
8515
|
-
status:
|
|
8518
|
+
status: HTTP_UNAUTHORIZED4
|
|
8516
8519
|
});
|
|
8517
8520
|
}
|
|
8518
8521
|
return jsonResponse(result.body, HTTP_OK3);
|
|
@@ -8529,7 +8532,7 @@ var oidcProviderRoutes = (config) => {
|
|
|
8529
8532
|
"content-type": "application/json",
|
|
8530
8533
|
"www-authenticate": userInfoChallengeHeader(result.error)
|
|
8531
8534
|
},
|
|
8532
|
-
status:
|
|
8535
|
+
status: HTTP_UNAUTHORIZED4
|
|
8533
8536
|
});
|
|
8534
8537
|
}
|
|
8535
8538
|
return jsonResponse(result.body, HTTP_OK3);
|
|
@@ -25052,7 +25055,7 @@ var createInMemoryCredentialOfferStore = () => {
|
|
|
25052
25055
|
import { Elysia as Elysia38, t as t33 } from "elysia";
|
|
25053
25056
|
var HTTP_OK4 = 200;
|
|
25054
25057
|
var HTTP_BAD_REQUEST4 = 400;
|
|
25055
|
-
var
|
|
25058
|
+
var HTTP_UNAUTHORIZED5 = 401;
|
|
25056
25059
|
var BEARER_PREFIX5 = "Bearer ";
|
|
25057
25060
|
var errorBody = (error, status) => new Response(JSON.stringify({ error }), {
|
|
25058
25061
|
headers: { "content-type": "application/json" },
|
|
@@ -25081,7 +25084,7 @@ var vciRoutes = ({
|
|
|
25081
25084
|
}))).post(credentialRoute, async ({ body, headers }) => {
|
|
25082
25085
|
const accessToken = extractBearer(headers.authorization);
|
|
25083
25086
|
if (accessToken === undefined) {
|
|
25084
|
-
return errorBody("invalid_token",
|
|
25087
|
+
return errorBody("invalid_token", HTTP_UNAUTHORIZED5);
|
|
25085
25088
|
}
|
|
25086
25089
|
const result = await issueCredential({
|
|
25087
25090
|
config: vciConfig,
|
|
@@ -28652,7 +28655,7 @@ var blockMigrations = {
|
|
|
28652
28655
|
// src/sso/samlIdpRoutes.ts
|
|
28653
28656
|
import { Elysia as Elysia41, t as t36 } from "elysia";
|
|
28654
28657
|
var HTTP_BAD_REQUEST6 = 400;
|
|
28655
|
-
var
|
|
28658
|
+
var HTTP_UNAUTHORIZED6 = 401;
|
|
28656
28659
|
var HTTP_FOUND2 = 302;
|
|
28657
28660
|
var HTTP_OK7 = 200;
|
|
28658
28661
|
var xmlResponse = (body) => new Response(body, {
|
|
@@ -28748,7 +28751,7 @@ var samlIdpRoutes = ({
|
|
|
28748
28751
|
});
|
|
28749
28752
|
if (userSession === undefined || parsed.forceAuthn === true) {
|
|
28750
28753
|
if (loginUrl === undefined) {
|
|
28751
|
-
return errorJson(
|
|
28754
|
+
return errorJson(HTTP_UNAUTHORIZED6, "login_required");
|
|
28752
28755
|
}
|
|
28753
28756
|
return redirectTo2(`${loginUrl}?return_to=${encodeURIComponent(request.url)}`);
|
|
28754
28757
|
}
|
|
@@ -28813,7 +28816,7 @@ var samlIdpRoutes = ({
|
|
|
28813
28816
|
});
|
|
28814
28817
|
if (userSession === undefined) {
|
|
28815
28818
|
if (loginUrl === undefined) {
|
|
28816
|
-
return errorJson(
|
|
28819
|
+
return errorJson(HTTP_UNAUTHORIZED6, "login_required");
|
|
28817
28820
|
}
|
|
28818
28821
|
return redirectTo2(`${loginUrl}?return_to=${encodeURIComponent(request.url)}`);
|
|
28819
28822
|
}
|
|
@@ -29358,5 +29361,5 @@ export {
|
|
|
29358
29361
|
auth2 as auth
|
|
29359
29362
|
};
|
|
29360
29363
|
|
|
29361
|
-
//# debugId=
|
|
29364
|
+
//# debugId=1844495EF9D2CC3164756E2164756E21
|
|
29362
29365
|
//# sourceMappingURL=server.js.map
|