@absolutejs/auth 0.55.1 → 0.55.2
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/authInstance.d.ts +1 -1
- package/dist/index.js +98 -95
- package/dist/index.js.map +5 -4
- package/dist/oidc/routes.d.ts +1 -1
- package/dist/server.js +98 -95
- package/dist/server.js.map +5 -4
- package/package.json +1 -1
package/dist/agents/routes.d.ts
CHANGED
|
@@ -1,55 +1,15 @@
|
|
|
1
|
-
import { Elysia } from 'elysia';
|
|
2
1
|
import { type AgentAuthConfig } from './config';
|
|
3
|
-
import
|
|
2
|
+
import { agentAuthChallenge } from './context';
|
|
4
3
|
import { agentRegistrationDiscoveryMetadata } from './registration';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
message: 'Agent is not authenticated' | 'Insufficient agent scopes';
|
|
8
|
-
};
|
|
9
|
-
export declare const agentAuthChallenge: ({ config, error, requiredScopes }: {
|
|
10
|
-
config: AgentAuthConfig;
|
|
11
|
-
error?: "invalid_token" | "insufficient_scope";
|
|
12
|
-
requiredScopes?: string[];
|
|
13
|
-
}) => string;
|
|
14
|
-
export declare const agentResourceMetadataUrl: (config: AgentAuthConfig) => string;
|
|
15
|
-
export { agentRegistrationDiscoveryMetadata };
|
|
16
|
-
export declare const agentAuthContextPlugin: (config?: AgentAuthConfig) => Elysia<"", {
|
|
17
|
-
decorator: {};
|
|
18
|
-
store: {};
|
|
19
|
-
derive: {};
|
|
20
|
-
resolve: {};
|
|
21
|
-
}, {
|
|
22
|
-
typebox: {};
|
|
23
|
-
error: {};
|
|
24
|
-
}, {
|
|
25
|
-
schema: {};
|
|
26
|
-
standaloneSchema: {};
|
|
27
|
-
macro: {};
|
|
28
|
-
macroFn: {};
|
|
29
|
-
parser: {};
|
|
30
|
-
response: {};
|
|
31
|
-
}, {}, {
|
|
32
|
-
derive: {};
|
|
33
|
-
resolve: {};
|
|
34
|
-
schema: {};
|
|
35
|
-
standaloneSchema: {};
|
|
36
|
-
response: {};
|
|
37
|
-
}, {
|
|
38
|
-
derive: {
|
|
39
|
-
readonly protectAgent: <AuthReturn, AuthFailReturn>(requiredScopes: string[], handleAuth: (principal: AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: AgentAuthFailure) => AuthFailReturn | Promise<AuthFailReturn>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn>>>;
|
|
40
|
-
};
|
|
41
|
-
resolve: {};
|
|
42
|
-
schema: {};
|
|
43
|
-
standaloneSchema: {};
|
|
44
|
-
response: import("elysia").ExtractErrorFromHandle<{
|
|
45
|
-
readonly protectAgent: <AuthReturn, AuthFailReturn>(requiredScopes: string[], handleAuth: (principal: AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: AgentAuthFailure) => AuthFailReturn | Promise<AuthFailReturn>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn>>>;
|
|
46
|
-
}>;
|
|
47
|
-
}>;
|
|
48
|
-
export declare const agentAuthPlugin: (config?: AgentAuthConfig) => Elysia<"", {
|
|
4
|
+
export { agentAuthChallenge, agentRegistrationDiscoveryMetadata };
|
|
5
|
+
export declare const agentAuthPlugin: (config?: AgentAuthConfig) => import("elysia").default<"", {
|
|
49
6
|
decorator: {};
|
|
50
7
|
store: {};
|
|
51
8
|
derive: {
|
|
52
|
-
readonly protectAgent: <AuthReturn, AuthFailReturn>(requiredScopes: string[], handleAuth: (principal: AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error:
|
|
9
|
+
readonly protectAgent: <AuthReturn, AuthFailReturn>(requiredScopes: string[], handleAuth: (principal: import("./types").AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: {
|
|
10
|
+
code: "Forbidden" | "Unauthorized";
|
|
11
|
+
message: "Agent is not authenticated" | "Insufficient agent scopes";
|
|
12
|
+
}) => AuthFailReturn | Promise<AuthFailReturn>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn>>>;
|
|
53
13
|
};
|
|
54
14
|
resolve: {};
|
|
55
15
|
}, {
|
|
@@ -62,7 +22,10 @@ export declare const agentAuthPlugin: (config?: AgentAuthConfig) => Elysia<"", {
|
|
|
62
22
|
macroFn: {};
|
|
63
23
|
parser: {};
|
|
64
24
|
response: import("elysia").ExtractErrorFromHandle<{
|
|
65
|
-
readonly protectAgent: <AuthReturn, AuthFailReturn>(requiredScopes: string[], handleAuth: (principal: AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error:
|
|
25
|
+
readonly protectAgent: <AuthReturn, AuthFailReturn>(requiredScopes: string[], handleAuth: (principal: import("./types").AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: {
|
|
26
|
+
code: "Forbidden" | "Unauthorized";
|
|
27
|
+
message: "Agent is not authenticated" | "Insufficient agent scopes";
|
|
28
|
+
}) => AuthFailReturn | Promise<AuthFailReturn>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn>>>;
|
|
66
29
|
}>;
|
|
67
30
|
}, {}, {
|
|
68
31
|
derive: {};
|
|
@@ -76,11 +39,14 @@ export declare const agentAuthPlugin: (config?: AgentAuthConfig) => Elysia<"", {
|
|
|
76
39
|
schema: {};
|
|
77
40
|
standaloneSchema: {};
|
|
78
41
|
response: {};
|
|
79
|
-
}> |
|
|
42
|
+
}> | import("elysia").default<"", {
|
|
80
43
|
decorator: {};
|
|
81
44
|
store: {};
|
|
82
45
|
derive: {
|
|
83
|
-
readonly protectAgent: <AuthReturn, AuthFailReturn>(requiredScopes: string[], handleAuth: (principal: AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error:
|
|
46
|
+
readonly protectAgent: <AuthReturn, AuthFailReturn>(requiredScopes: string[], handleAuth: (principal: import("./types").AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: {
|
|
47
|
+
code: "Forbidden" | "Unauthorized";
|
|
48
|
+
message: "Agent is not authenticated" | "Insufficient agent scopes";
|
|
49
|
+
}) => AuthFailReturn | Promise<AuthFailReturn>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn>>>;
|
|
84
50
|
};
|
|
85
51
|
resolve: {};
|
|
86
52
|
}, {
|
|
@@ -93,7 +59,10 @@ export declare const agentAuthPlugin: (config?: AgentAuthConfig) => Elysia<"", {
|
|
|
93
59
|
macroFn: {};
|
|
94
60
|
parser: {};
|
|
95
61
|
response: import("elysia").ExtractErrorFromHandle<{
|
|
96
|
-
readonly protectAgent: <AuthReturn, AuthFailReturn>(requiredScopes: string[], handleAuth: (principal: AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error:
|
|
62
|
+
readonly protectAgent: <AuthReturn, AuthFailReturn>(requiredScopes: string[], handleAuth: (principal: import("./types").AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: {
|
|
63
|
+
code: "Forbidden" | "Unauthorized";
|
|
64
|
+
message: "Agent is not authenticated" | "Insufficient agent scopes";
|
|
65
|
+
}) => AuthFailReturn | Promise<AuthFailReturn>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn>>>;
|
|
97
66
|
}>;
|
|
98
67
|
}, {
|
|
99
68
|
[x: string]: {
|
|
@@ -126,11 +95,14 @@ export declare const agentAuthPlugin: (config?: AgentAuthConfig) => Elysia<"", {
|
|
|
126
95
|
schema: {};
|
|
127
96
|
standaloneSchema: {};
|
|
128
97
|
response: {};
|
|
129
|
-
}> |
|
|
98
|
+
}> | import("elysia").default<"", {
|
|
130
99
|
decorator: {};
|
|
131
100
|
store: {};
|
|
132
101
|
derive: {
|
|
133
|
-
readonly protectAgent: <AuthReturn, AuthFailReturn>(requiredScopes: string[], handleAuth: (principal: AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error:
|
|
102
|
+
readonly protectAgent: <AuthReturn, AuthFailReturn>(requiredScopes: string[], handleAuth: (principal: import("./types").AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: {
|
|
103
|
+
code: "Forbidden" | "Unauthorized";
|
|
104
|
+
message: "Agent is not authenticated" | "Insufficient agent scopes";
|
|
105
|
+
}) => AuthFailReturn | Promise<AuthFailReturn>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn>>>;
|
|
134
106
|
};
|
|
135
107
|
resolve: {};
|
|
136
108
|
}, {
|
|
@@ -143,7 +115,10 @@ export declare const agentAuthPlugin: (config?: AgentAuthConfig) => Elysia<"", {
|
|
|
143
115
|
macroFn: {};
|
|
144
116
|
parser: {};
|
|
145
117
|
response: import("elysia").ExtractErrorFromHandle<{
|
|
146
|
-
readonly protectAgent: <AuthReturn, AuthFailReturn>(requiredScopes: string[], handleAuth: (principal: AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error:
|
|
118
|
+
readonly protectAgent: <AuthReturn, AuthFailReturn>(requiredScopes: string[], handleAuth: (principal: import("./types").AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: {
|
|
119
|
+
code: "Forbidden" | "Unauthorized";
|
|
120
|
+
message: "Agent is not authenticated" | "Insufficient agent scopes";
|
|
121
|
+
}) => AuthFailReturn | Promise<AuthFailReturn>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn>>>;
|
|
147
122
|
}>;
|
|
148
123
|
}, {
|
|
149
124
|
[x: string]: {
|
package/dist/authInstance.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Elysia } from 'elysia';
|
|
2
|
-
import type { agentAuthContextPlugin } from './agents/
|
|
2
|
+
import type { agentAuthContextPlugin } from './agents/context';
|
|
3
3
|
import type { protectRoutePlugin } from './routes/protectRoute';
|
|
4
4
|
import type { stepUpPlugin } from './routes/stepUp';
|
|
5
5
|
/** Merge the stable context contributed by independent Auth plugins without
|
package/dist/index.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
|
}
|
|
@@ -29826,5 +29829,5 @@ export {
|
|
|
29826
29829
|
AGENT_CLAIM_GRANT_TYPE
|
|
29827
29830
|
};
|
|
29828
29831
|
|
|
29829
|
-
//# debugId=
|
|
29832
|
+
//# debugId=394E6CA4C2DE944764756E2164756E21
|
|
29830
29833
|
//# sourceMappingURL=index.js.map
|