@agentxm/registry-auth 0.28.4-bootstrap.0

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.
Files changed (44) hide show
  1. package/LICENSE +110 -0
  2. package/dist/src/auth-client.d.ts +199 -0
  3. package/dist/src/auth-client.js +638 -0
  4. package/dist/src/auth-middleware.d.ts +28 -0
  5. package/dist/src/auth-middleware.js +105 -0
  6. package/dist/src/credential-store.d.ts +77 -0
  7. package/dist/src/credential-store.js +443 -0
  8. package/dist/src/device-login.d.ts +114 -0
  9. package/dist/src/device-login.js +300 -0
  10. package/dist/src/errors.d.ts +141 -0
  11. package/dist/src/errors.js +84 -0
  12. package/dist/src/guard.d.ts +24 -0
  13. package/dist/src/guard.js +62 -0
  14. package/dist/src/index.d.ts +36 -0
  15. package/dist/src/index.js +31 -0
  16. package/dist/src/internal/environment.d.ts +23 -0
  17. package/dist/src/internal/environment.js +45 -0
  18. package/dist/src/live.d.ts +13 -0
  19. package/dist/src/live.js +13 -0
  20. package/dist/src/login-interaction.d.ts +41 -0
  21. package/dist/src/login-interaction.js +108 -0
  22. package/dist/src/login-output.d.ts +22 -0
  23. package/dist/src/login-output.js +32 -0
  24. package/dist/src/login-presenter.d.ts +95 -0
  25. package/dist/src/login-presenter.js +58 -0
  26. package/dist/src/login-strategy.d.ts +21 -0
  27. package/dist/src/login-strategy.js +25 -0
  28. package/dist/src/loopback-login.d.ts +19 -0
  29. package/dist/src/loopback-login.js +91 -0
  30. package/dist/src/loopback-server.d.ts +40 -0
  31. package/dist/src/loopback-server.js +168 -0
  32. package/dist/src/oauth-contract.d.ts +7 -0
  33. package/dist/src/oauth-contract.js +2 -0
  34. package/dist/src/pending-device-login-store.d.ts +37 -0
  35. package/dist/src/pending-device-login-store.js +122 -0
  36. package/dist/src/publish-authorization.d.ts +11 -0
  37. package/dist/src/publish-authorization.js +79 -0
  38. package/dist/src/schema.d.ts +78 -0
  39. package/dist/src/schema.js +55 -0
  40. package/dist/src/testing.d.ts +14 -0
  41. package/dist/src/testing.js +14 -0
  42. package/dist/src/token-resolution.d.ts +79 -0
  43. package/dist/src/token-resolution.js +190 -0
  44. package/package.json +62 -0
package/LICENSE ADDED
@@ -0,0 +1,110 @@
1
+ # Functional Source License, Version 1.1, MIT Future License
2
+
3
+ ## Abbreviation
4
+
5
+ FSL-1.1-MIT
6
+
7
+ ## Notice
8
+
9
+ Copyright 2025-2026 AgentXM, Inc.
10
+
11
+ ## Terms and Conditions
12
+
13
+ ### Licensor ("We")
14
+
15
+ The party offering the Software under these Terms and Conditions.
16
+
17
+ ### The Software
18
+
19
+ The "Software" is each version of the software that we make available under
20
+ these Terms and Conditions, as indicated by our inclusion of these Terms and
21
+ Conditions with the Software.
22
+
23
+ ### License Grant
24
+
25
+ Subject to your compliance with this License Grant and the Patents,
26
+ Redistribution and Trademark clauses below, we hereby grant you the right to
27
+ use, copy, modify, create derivative works, publicly perform, publicly display
28
+ and redistribute the Software for any Permitted Purpose identified below.
29
+
30
+ ### Permitted Purpose
31
+
32
+ A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
33
+ means making the Software available to others in a commercial product or
34
+ service that:
35
+
36
+ 1. substitutes for the Software;
37
+
38
+ 2. substitutes for any other product or service we offer using the Software
39
+ that exists as of the date we make the Software available; or
40
+
41
+ 3. offers the same or substantially similar functionality as the Software.
42
+
43
+ Permitted Purposes specifically include using the Software:
44
+
45
+ 1. for your internal use and access;
46
+
47
+ 2. for non-commercial education;
48
+
49
+ 3. for non-commercial research; and
50
+
51
+ 4. in connection with professional services that you provide to a licensee
52
+ using the Software in accordance with these Terms and Conditions.
53
+
54
+ ### Patents
55
+
56
+ To the extent your use for a Permitted Purpose would necessarily infringe our
57
+ patents, the license grant above includes a license under our patents. If you
58
+ make a claim against any party that the Software infringes or contributes to
59
+ the infringement of any patent, then your patent license to the Software ends
60
+ immediately.
61
+
62
+ ### Redistribution
63
+
64
+ The Terms and Conditions apply to all copies, modifications and derivatives of
65
+ the Software.
66
+
67
+ If you redistribute any copies, modifications or derivatives of the Software,
68
+ you must include a copy of or a link to these Terms and Conditions and not
69
+ remove any copyright notices provided in or with the Software.
70
+
71
+ ### Disclaimer
72
+
73
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
74
+ IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
75
+ PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
76
+
77
+ IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
78
+ SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
79
+ EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
80
+
81
+ ### Trademarks
82
+
83
+ Except for displaying the License Details and identifying us as the origin of
84
+ the Software, you have no right under these Terms and Conditions to use our
85
+ trademarks, trade names, service marks or product names.
86
+
87
+ ## Grant of Future License
88
+
89
+ We hereby irrevocably grant you an additional license to use the Software under
90
+ the MIT license that is effective on the second anniversary of the date we make
91
+ the Software available. On or after that date, you may use the Software under
92
+ the MIT license, in which case the following will apply:
93
+
94
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
95
+ this software and associated documentation files (the "Software"), to deal in
96
+ the Software without restriction, including without limitation the rights to
97
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
98
+ of the Software, and to permit persons to whom the Software is furnished to do
99
+ so, subject to the following conditions:
100
+
101
+ The above copyright notice and this permission notice shall be included in all
102
+ copies or substantial portions of the Software.
103
+
104
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
105
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
106
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
107
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
108
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
109
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
110
+ SOFTWARE.
@@ -0,0 +1,199 @@
1
+ /**
2
+ * AuthClient Effect service — device flow login, token refresh, revocation, identity queries.
3
+ *
4
+ * Provides methods for the OAuth 2.0 Device Authorization Grant (RFC 8628)
5
+ * and related auth operations against the AgentXM registry API.
6
+ *
7
+ * Uses the generated registry client for HTTP transport and surfaces typed
8
+ * auth and registry failures; the application boundary owns envelope
9
+ * rendering.
10
+ *
11
+ * @experimental This API is unstable and may change without notice.
12
+ */
13
+ import * as HttpClient from "effect/unstable/http/HttpClient";
14
+ import * as DateTime from "effect/DateTime";
15
+ import * as ServiceMap from "effect/Context";
16
+ import * as Effect from "effect/Effect";
17
+ import * as Layer from "effect/Layer";
18
+ import { type Handle } from "@agentxm/extension-model/unstable/extensions/handle";
19
+ import { type PublishVisibility } from "@agentxm/registry-protocol/unstable/publish/visibility";
20
+ import { type PreviewPublicationSetRequest, type PreviewPublicationSetResponse, type Sha256Hex } from "@agentxm/registry-protocol/unstable/registry/publication-set";
21
+ import { type NormalizedTokenResponse } from "./oauth-contract.js";
22
+ import { RegistryUrl } from "@agentxm/registry-client";
23
+ import { type AuthError, type StepUpRequest } from "./errors.js";
24
+ export declare const OIDC_LOGIN_SCOPES: readonly ["openid", "profile", "email", "offline_access"];
25
+ export declare const BASELINE_REGISTRY_LOGIN_SCOPES: readonly ["extensions:read", "account:read"];
26
+ export declare const DEFAULT_LOGIN_SCOPES: readonly ["openid", "profile", "email", "offline_access", "extensions:read", "account:read"];
27
+ export interface DeviceFlowResponse {
28
+ readonly device_code: string;
29
+ readonly user_code: string;
30
+ readonly verification_uri: string;
31
+ readonly verification_uri_complete: string;
32
+ readonly interval: number;
33
+ readonly expires_in: number;
34
+ }
35
+ export declare const normalizeRequestedLoginScopes: (scopes?: ReadonlyArray<string>) => ReadonlyArray<string>;
36
+ export interface LoginScopeOptions {
37
+ readonly scopes?: ReadonlyArray<string>;
38
+ }
39
+ export interface MeResponse {
40
+ readonly userId: string;
41
+ readonly userHandle: Handle;
42
+ readonly email: string;
43
+ readonly tokenType: string;
44
+ readonly scopes: ReadonlyArray<string>;
45
+ readonly orgs: ReadonlyArray<{
46
+ readonly id: string;
47
+ readonly handle: Handle;
48
+ }>;
49
+ }
50
+ export interface WhoamiResponse {
51
+ readonly handle: Handle;
52
+ }
53
+ export interface TokenPermissionsRequest {
54
+ readonly owners?: ReadonlyArray<string>;
55
+ readonly extensions?: ReadonlyArray<string>;
56
+ readonly permission?: "read" | "publish" | "admin";
57
+ readonly org_permission?: "read" | "write" | "admin";
58
+ readonly cidr?: ReadonlyArray<string>;
59
+ readonly bypass_mfa?: boolean;
60
+ }
61
+ export interface CreateTokenParams {
62
+ readonly name: string;
63
+ readonly expiresIn: number;
64
+ readonly permissions: TokenPermissionsRequest;
65
+ }
66
+ export interface CreatedTokenResponse {
67
+ readonly id: string;
68
+ readonly token: string;
69
+ readonly name: string;
70
+ readonly scopes: ReadonlyArray<string>;
71
+ readonly permissions: unknown;
72
+ readonly createdAt: DateTime.Utc;
73
+ readonly expiresAt: DateTime.Utc;
74
+ }
75
+ export interface TokenListItem {
76
+ readonly id: string;
77
+ readonly name: string | null;
78
+ readonly type: string;
79
+ readonly scopes: ReadonlyArray<string>;
80
+ readonly permissions: unknown;
81
+ readonly createdAt: DateTime.Utc;
82
+ readonly expiresAt: DateTime.Utc;
83
+ readonly lastUsedAt: DateTime.Utc | null;
84
+ }
85
+ export interface TokenListResponse {
86
+ readonly tokens: ReadonlyArray<TokenListItem>;
87
+ readonly hasMore: boolean;
88
+ readonly cursor: string | null;
89
+ }
90
+ export interface DeleteTokenOptions {
91
+ readonly stepUpRequestId?: string;
92
+ }
93
+ export interface CreateTokenOptions {
94
+ readonly stepUpRequestId?: string;
95
+ }
96
+ export interface BuildAuthorizeUrlParams {
97
+ readonly challenge: string;
98
+ readonly expiresAt?: DateTime.Utc;
99
+ readonly state: string;
100
+ readonly redirectUri: string;
101
+ readonly scopes?: ReadonlyArray<string>;
102
+ }
103
+ export interface ExchangePkceCodeParams {
104
+ readonly code: string;
105
+ readonly verifier: string;
106
+ readonly redirectUri: string;
107
+ }
108
+ export interface CreatePublishAuthorizationRequestParams {
109
+ readonly registryUrl: string;
110
+ readonly redirectUri: string;
111
+ readonly state: string;
112
+ readonly codeChallenge: string;
113
+ readonly publicationSet: PreviewPublicationSetRequest;
114
+ }
115
+ export interface PublishAuthorizationRequestResponse {
116
+ readonly requestId: string;
117
+ readonly authorizationUrl: string;
118
+ readonly expiresAt: DateTime.Utc;
119
+ }
120
+ export interface ExchangePublishAuthorizationCodeParams {
121
+ readonly registryUrl: string;
122
+ readonly code: string;
123
+ readonly verifier: string;
124
+ readonly redirectUri: string;
125
+ }
126
+ export interface PublishCapabilityResponse {
127
+ readonly accessToken: string;
128
+ readonly expiresAt: DateTime.Utc;
129
+ readonly scope: string;
130
+ readonly publishRequestId: string;
131
+ readonly visibilityContract: "v2";
132
+ readonly visibility: PublishVisibility;
133
+ readonly condition: string;
134
+ readonly publicationSetDigest: Sha256Hex;
135
+ readonly publicationDescriptorDigest: Sha256Hex;
136
+ }
137
+ export type PublishAuthorizationExchangeResponse = {
138
+ readonly status: "admitted";
139
+ readonly preview: PreviewPublicationSetResponse;
140
+ readonly grants: ReadonlyArray<PublishCapabilityResponse>;
141
+ } | {
142
+ readonly status: "blocked";
143
+ readonly preview: PreviewPublicationSetResponse;
144
+ readonly grants: readonly [];
145
+ };
146
+ /** Result of a single poll iteration. */
147
+ export type PollResult = {
148
+ readonly _tag: "Pending";
149
+ } | {
150
+ readonly _tag: "SlowDown";
151
+ } | {
152
+ readonly _tag: "Success";
153
+ readonly token: NormalizedTokenResponse;
154
+ } | {
155
+ readonly _tag: "AccessDenied";
156
+ } | {
157
+ readonly _tag: "ExpiredToken";
158
+ };
159
+ export interface AuthClientService {
160
+ readonly buildAuthorizeUrl: (params: BuildAuthorizeUrlParams) => string;
161
+ readonly getAuthorizationIssuer: () => string;
162
+ readonly exchangePkceCode: (params: ExchangePkceCodeParams) => Effect.Effect<NormalizedTokenResponse, AuthError>;
163
+ readonly createPublishAuthorizationRequest: (params: CreatePublishAuthorizationRequestParams) => Effect.Effect<PublishAuthorizationRequestResponse, AuthError>;
164
+ readonly exchangePublishAuthorizationCode: (params: ExchangePublishAuthorizationCodeParams) => Effect.Effect<PublishAuthorizationExchangeResponse, AuthError>;
165
+ readonly initiateDeviceFlow: (options?: LoginScopeOptions) => Effect.Effect<DeviceFlowResponse, AuthError>;
166
+ readonly pollDeviceToken: (deviceCode: string, interval: number) => Effect.Effect<NormalizedTokenResponse, AuthError>;
167
+ readonly refreshToken: (refreshTokenValue: string) => Effect.Effect<NormalizedTokenResponse, AuthError>;
168
+ readonly revokeToken: (token: string) => Effect.Effect<void, AuthError>;
169
+ readonly getMe: (accessToken: string) => Effect.Effect<MeResponse, AuthError>;
170
+ readonly getWhoami: (accessToken: string) => Effect.Effect<WhoamiResponse, AuthError>;
171
+ readonly createToken: (accessToken: string, params: CreateTokenParams, options?: CreateTokenOptions) => Effect.Effect<CreatedTokenResponse, AuthError>;
172
+ readonly listTokens: (accessToken: string, params?: {
173
+ readonly limit?: number;
174
+ readonly cursor?: string;
175
+ }) => Effect.Effect<TokenListResponse, AuthError>;
176
+ readonly waitForStepUpRequest: (accessToken: string, statusUrl: string, intervalSeconds: number) => Effect.Effect<void, AuthError>;
177
+ readonly deleteToken: (accessToken: string, tokenId: string, options?: DeleteTokenOptions) => Effect.Effect<void, AuthError>;
178
+ }
179
+ declare const AuthClient_base: ServiceMap.ServiceClass<AuthClient, "@agentxm/registry-auth/auth-client/AuthClient", AuthClientService>;
180
+ export declare class AuthClient extends AuthClient_base {
181
+ }
182
+ export declare const readStepUpRequest: (error: {
183
+ readonly metadata?: {
184
+ readonly response?: {
185
+ readonly body?: unknown;
186
+ } | undefined;
187
+ } | undefined;
188
+ }) => StepUpRequest | null;
189
+ /**
190
+ * Execute a single device token poll (exported for testing).
191
+ *
192
+ * Transient HTTP failures are collapsed into AUTH_LOGIN_FAILED; this seam does
193
+ * not retry on its own. For the retrying variant, use `pollDeviceToken`.
194
+ */
195
+ export declare const pollOnce: (httpClient: HttpClient.HttpClient, registryUrl: string, deviceCode: string) => Effect.Effect<PollResult, AuthError>;
196
+ export declare const AuthClientLive: Layer.Layer<AuthClient, never, HttpClient.HttpClient | RegistryUrl>;
197
+ export declare const AuthClientTest: (overrides?: Partial<AuthClientService>) => Layer.Layer<AuthClient, never, never>;
198
+ export {};
199
+ //# sourceMappingURL=auth-client.d.ts.map