@monocloud/auth-core 0.1.4 → 0.1.5

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.d.cts DELETED
@@ -1,274 +0,0 @@
1
- import { A as ResponseTypes, C as ParResponse, D as RefreshGrantOptions, E as RefetchUserInfoOptions, M as UserinfoResponse, O as RefreshSessionOptions, S as OnSessionCreating, T as PushedAuthorizationParams, _ as Jwks, a as Authenticators, b as MonoCloudSession, c as ClientAuthMethod, d as EndSessionParameters, f as Group, g as Jwk, h as JWSAlgorithm, i as AuthenticateOptions, j as Tokens, k as ResponseModes, l as CodeChallengeMethod, m as IssuerMetadata, n as Address, o as AuthorizationParams, p as IdTokenClaims, r as AuthState, s as CallbackParams, t as AccessToken, u as DisplayOptions, v as JwsHeaderParameters, w as Prompt, x as MonoCloudUser, y as MonoCloudClientOptions } from "./types-BAE9nCpJ.cjs";
2
-
3
- //#region src/errors/monocloud-auth-base-error.d.ts
4
- declare class MonoCloudAuthBaseError extends Error {}
5
- //#endregion
6
- //#region src/errors/monocloud-op-error.d.ts
7
- declare class MonoCloudOPError extends MonoCloudAuthBaseError {
8
- error: string;
9
- errorDescription?: string;
10
- constructor(error: string, errorDescription?: string);
11
- }
12
- //#endregion
13
- //#region src/errors/monocloud-http-error.d.ts
14
- declare class MonoCloudHttpError extends MonoCloudAuthBaseError {}
15
- //#endregion
16
- //#region src/errors/monocloud-token-error.d.ts
17
- declare class MonoCloudTokenError extends MonoCloudAuthBaseError {}
18
- //#endregion
19
- //#region src/errors/monocloud-validation-error.d.ts
20
- declare class MonoCloudValidationError extends MonoCloudAuthBaseError {}
21
- //#endregion
22
- //#region src/monocloud-oidc-client.d.ts
23
- declare class MonoCloudOidcClient {
24
- private readonly tenantDomain;
25
- private readonly clientId;
26
- private readonly clientSecret?;
27
- private readonly authMethod;
28
- private readonly idTokenSigningAlgorithm;
29
- private jwks?;
30
- private jwksCacheExpiry;
31
- private jwksCacheDuration;
32
- private metadata?;
33
- private metadataCacheExpiry;
34
- private metadataCacheDuration;
35
- constructor(tenantDomain: string, clientId: string, options?: MonoCloudClientOptions);
36
- /**
37
- * Generates an authorization URL with specified parameters.
38
- *
39
- * If no values are provided for `responseType`, or `codeChallengeMethod`, they default to `code`, and `S256`, respectively.
40
- *
41
- * @param params Authorization URL parameters
42
- *
43
- * @returns Tenant's authorization url.
44
- *
45
- * @throws {@link MonoCloudHttpError} - Thrown if there is a network error during the request or
46
- * unexpected status code during the request or a serialization error while processing the response.
47
- *
48
- */
49
- authorizationUrl(params: AuthorizationParams): Promise<string>;
50
- /**
51
- * Fetches the authorization server metadata from the .well-known endpoint.
52
- * The metadata is cached for 1 minute.
53
- *
54
- * @param forceRefresh - If `true`, bypasses the cache and fetches fresh metadata from the server.
55
- *
56
- * @returns The issuer metadata for the tenant, retrieved from the OpenID Connect discovery endpoint.
57
- *
58
- * @throws {@link MonoCloudHttpError} - Thrown if there is a network error during the request or
59
- * unexpected status code during the request or a serialization error while processing the response.
60
- *
61
- */
62
- getMetadata(forceRefresh?: boolean): Promise<IssuerMetadata>;
63
- /**
64
- * Fetches the JSON Web Keys used to sign the id token.
65
- * The JWKS is cached for 1 minute.
66
- *
67
- * @param forceRefresh - If `true`, bypasses the cache and fetches fresh set of JWKS from the server.
68
- *
69
- * @returns The JSON Web Key Set containing the public keys for token verification.
70
- *
71
- * @throws {@link MonoCloudHttpError} - Thrown if there is a network error during the request or
72
- * unexpected status code during the request or a serialization error while processing the response.
73
- *
74
- */
75
- getJwks(forceRefresh?: boolean): Promise<Jwks>;
76
- /**
77
- * Performs a pushed authorization request.
78
- *
79
- * @param params - Authorization Parameters
80
- *
81
- * @returns Response from Pushed Authorization Request (PAR) endpoint
82
- *
83
- * @throws {@link MonoCloudOPError} - When the request is invalid.
84
- *
85
- * @throws {@link MonoCloudHttpError} - Thrown if there is a network error during the request or
86
- * unexpected status code during the request or a serialization error while processing the response.
87
- *
88
- */
89
- pushedAuthorizationRequest(params: PushedAuthorizationParams): Promise<ParResponse>;
90
- /**
91
- * Fetches userinfo associated with the provided access token.
92
- *
93
- * @param accessToken - A valid access token used to retrieve userinfo.
94
- *
95
- * @returns The authenticated user's claims.
96
- *
97
- * @throws {@link MonoCloudOPError} - When the OpenID Provider returns a standardized
98
- * OAuth 2.0 error (e.g., 'invalid_token') in the 'WWW-Authenticate' header
99
- * following a 401 Unauthorized response.
100
- *
101
- * @throws {@link MonoCloudHttpError} - Thrown if there is a network error during the request or
102
- * unexpected status code during the request or a serialization error while processing the response.
103
- *
104
- * @throws {@link MonoCloudValidationError} - When the access token is invalid.
105
- *
106
- */
107
- userinfo(accessToken: string): Promise<UserinfoResponse>;
108
- /**
109
- * Generates OpenID end session url for signing out.
110
- *
111
- * Note - The `state` is added only when `postLogoutRedirectUri` is present.
112
- *
113
- * @param params - Parameters to build end session url
114
- *
115
- * @returns Tenant's end session url
116
- *
117
- * @throws {@link MonoCloudHttpError} - Thrown if there is a network error during the request or
118
- * unexpected status code during the request or a serialization error while processing the response.
119
- *
120
- */
121
- endSessionUrl(params: EndSessionParameters): Promise<string>;
122
- /**
123
- * Exchanges an authorization code for tokens.
124
- *
125
- * @param code - The authorization code received from the authorization server.
126
- * @param redirectUri - The redirect URI used in the initial authorization request.
127
- * @param codeVerifier - Code verifier for PKCE.
128
- * @param resource - Space-separated list of resources the access token should be scoped to
129
- *
130
- * @returns Tokens obtained by exchanging an authorization code at the token endpoint.
131
- *
132
- * @throws {@link MonoCloudOPError} - When the OpenID Provider returns a standardized
133
- * OAuth 2.0 error response.
134
- *
135
- * @throws {@link MonoCloudHttpError} - Thrown if there is a network error during the request or
136
- * unexpected status code during the request or a serialization error while processing the response.
137
- *
138
- */
139
- exchangeAuthorizationCode(code: string, redirectUri: string, codeVerifier?: string, resource?: string): Promise<Tokens>;
140
- /**
141
- * Exchanges a refresh token for new tokens.
142
- *
143
- * @param refreshToken - The refresh token used to request new tokens.
144
- * @param options - Refresh grant options.
145
- *
146
- * @returns Tokens obtained by exchanging a refresh token at the token endpoint.
147
- *
148
- * @throws {@link MonoCloudOPError} - When the OpenID Provider returns a standardized
149
- * OAuth 2.0 error response.
150
- *
151
- * @throws {@link MonoCloudHttpError} - Thrown if there is a network error during the request or
152
- * unexpected status code during the request or a serialization error while processing the response.
153
- *
154
- */
155
- refreshGrant(refreshToken: string, options?: RefreshGrantOptions): Promise<Tokens>;
156
- /**
157
- * Generates a session with user and tokens by exchanging authorization code from callback params.
158
- *
159
- * @param code - The authorization code received from the callback
160
- * @param redirectUri - The redirect URI that was used in the authorization request
161
- * @param requestedScopes - A space-separated list of scopes originally requested via the `/authorize` endpoint.
162
- * This is stored in the session to ensure the correct access token can be identified and refreshed during `refreshSession()`.
163
- * @param resource - A space-separated list of resource indicators originally requested via the `/authorize` endpoint.
164
- * Used alongside scopes to uniquely identify and refresh the specific access token associated with these resources.
165
- * @param options - Options for authenticating a user with authorization code
166
- *
167
- * @returns The user's session containing authentication tokens and user information.
168
- *
169
- * @throws {@link MonoCloudValidationError} - When the token scope does not contain the openid scope,
170
- * or if 'expires_in' or 'scope' is missing from the token response.
171
- *
172
- * @throws {@link MonoCloudOPError} - When the OpenID Provider returns a standardized
173
- * OAuth 2.0 error response.
174
- *
175
- * @throws {@link MonoCloudTokenError} - If ID Token validation fails
176
- *
177
- * @throws {@link MonoCloudHttpError} - Thrown if there is a network error during the request or
178
- * unexpected status code during the request or a serialization error while processing the response.
179
- *
180
- */
181
- authenticate(code: string, redirectUri: string, requestedScopes: string, resource?: string, options?: AuthenticateOptions): Promise<MonoCloudSession>;
182
- /**
183
- * Refetches user information for an existing session using the userinfo endpoint.
184
- * Updates the session's user object with the latest user information while preserving existing properties.
185
- *
186
- * @param accessToken - Access token used to fetch the userinfo
187
- * @param session - The current MonoCloudSession
188
- * @param options - Userinfo refetch options
189
- *
190
- * @returns Updated session with the latest userinfo
191
- *
192
- * @throws {@link MonoCloudValidationError} - When the token scope does not contain openid scope
193
- *
194
- * @throws {@link MonoCloudOPError} - When the OpenID Provider returns a standardized
195
- * OAuth 2.0 error response.
196
- *
197
- * @throws {@link MonoCloudTokenError} - If ID Token validation fails
198
- *
199
- * @throws {@link MonoCloudHttpError} - Thrown if there is a network error during the request or
200
- * unexpected status code during the request or a serialization error while processing the response.
201
- *
202
- */
203
- refetchUserInfo(accessToken: AccessToken, session: MonoCloudSession, options?: RefetchUserInfoOptions): Promise<MonoCloudSession>;
204
- /**
205
- * Refreshes an existing session using the refresh token.
206
- * This function requests new tokens using the refresh token and optionally updates user information.
207
- *
208
- * @param session - The current MonoCloudSession containing the refresh token
209
- * @param options - Session refresh options
210
- *
211
- * @returns User's session containing refreshed authentication tokens and user information.
212
- *
213
- * @throws {@link MonoCloudValidationError} - If the refresh token is not present in the session,
214
- * or if 'expires_in' or 'scope' (including the openid scope) is missing from the token response.
215
- *
216
- * @throws {@link MonoCloudOPError} - When the OpenID Provider returns a standardized
217
- * OAuth 2.0 error response.
218
- *
219
- * @throws {@link MonoCloudTokenError} - If ID Token validation fails
220
- *
221
- * @throws {@link MonoCloudHttpError} - Thrown if there is a network error during the request or
222
- * unexpected status code during the request or a serialization error while processing the response.
223
- *
224
- */
225
- refreshSession(session: MonoCloudSession, options?: RefreshSessionOptions): Promise<MonoCloudSession>;
226
- /**
227
- * Revokes an access token or refresh token, rendering it invalid for future use.
228
- *
229
- * @param token - The token string to be revoked
230
- * @param tokenType - Hint about the token type ('access_token' or 'refresh_token')
231
- *
232
- * @returns If token revocation succeeded
233
- *
234
- * @throws {@link MonoCloudValidationError} - If token is invalid or unsupported token type
235
- *
236
- * @throws {@link MonoCloudOPError} - When the OpenID Provider returns a standardized
237
- * OAuth 2.0 error response.
238
- *
239
- * @throws {@link MonoCloudHttpError} - Thrown if there is a network error during the request or
240
- * unexpected status code during the request or a serialization error while processing the response.
241
- */
242
- revokeToken(token: string, tokenType?: string): Promise<void>;
243
- /**
244
- * Validates an ID Token.
245
- *
246
- * @param idToken - The ID Token JWT string to validate
247
- * @param jwks - Array of JSON Web Keys (JWK) used to verify the token's signature
248
- * @param clockSkew - Number of seconds to adjust the current time to account for clock differences
249
- * @param clockTolerance - Additional time tolerance in seconds for time-based claim validation
250
- * @param maxAge - maximum authentication age in seconds
251
- * @param nonce - nonce value to validate against the token's nonce claim
252
- *
253
- * @returns Validated ID Token claims
254
- *
255
- * @throws {@link MonoCloudTokenError} - If ID Token validation fails
256
- *
257
- */
258
- validateIdToken(idToken: string, jwks: Jwk[], clockSkew: number, clockTolerance: number, maxAge?: number, nonce?: string): Promise<IdTokenClaims>;
259
- /**
260
- * Decodes the payload of a JSON Web Token (JWT) and returns it as an object.
261
- * **THIS METHOD DOES NOT VERIFY JWT TOKENS**.
262
- *
263
- * @param jwt - JWT to decode
264
- *
265
- * @returns Decoded payload
266
- *
267
- * @throws {@link MonoCloudTokenError} - If decoding fails
268
- *
269
- */
270
- static decodeJwt(jwt: string): IdTokenClaims;
271
- }
272
- //#endregion
273
- export { type AccessToken, type Address, type AuthState, type AuthenticateOptions, type Authenticators, type AuthorizationParams, type CallbackParams, type ClientAuthMethod, type CodeChallengeMethod, type DisplayOptions, type EndSessionParameters, type Group, type IdTokenClaims, type IssuerMetadata, type JWSAlgorithm, type Jwk, type Jwks, type JwsHeaderParameters, MonoCloudAuthBaseError, type MonoCloudClientOptions, MonoCloudHttpError, MonoCloudOPError, MonoCloudOidcClient, type MonoCloudSession, MonoCloudTokenError, type MonoCloudUser, MonoCloudValidationError, type OnSessionCreating, type ParResponse, type Prompt, type PushedAuthorizationParams, type RefetchUserInfoOptions, type RefreshGrantOptions, type RefreshSessionOptions, type ResponseModes, type ResponseTypes, type Tokens, type UserinfoResponse };
274
- //# sourceMappingURL=index.d.cts.map