@dereekb/firebase-server 13.12.2 → 13.12.4
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/index.cjs.js +86 -18
- package/index.esm.js +85 -19
- package/mailgun/index.cjs.js +6 -3
- package/mailgun/index.esm.js +6 -3
- package/mailgun/package.json +9 -9
- package/mcp/index.cjs.js +526 -183
- package/mcp/index.esm.js +527 -186
- package/mcp/package.json +12 -11
- package/mcp/src/lib/service/analytics/mcp.analytics.config.d.ts +5 -3
- package/mcp/src/lib/service/analytics/mcp.analytics.service.d.ts +3 -2
- package/mcp/src/lib/service/tools/mcp.tool.model-info.d.ts +90 -10
- package/model/package.json +9 -9
- package/oidc/index.cjs.js +116 -8
- package/oidc/index.esm.js +115 -10
- package/oidc/package.json +10 -10
- package/oidc/src/lib/oidc.config.d.ts +40 -2
- package/oidc/src/lib/oidc.module.d.ts +39 -2
- package/oidc/src/lib/service/oidc.client.service.d.ts +12 -4
- package/package.json +13 -10
- package/src/lib/auth/auth.service.d.ts +84 -17
- package/src/lib/env/env.service.d.ts +2 -2
- package/test/index.cjs.js +29 -0
- package/test/index.esm.js +29 -0
- package/test/package.json +11 -11
- package/test/src/lib/firebase/firebase.admin.auth.d.ts +22 -0
- package/twilio/package.json +8 -8
- package/zoho/package.json +9 -9
package/oidc/index.esm.js
CHANGED
|
@@ -3,7 +3,7 @@ import { errors } from 'oidc-provider';
|
|
|
3
3
|
import { SECONDS_IN_MINUTE, SECONDS_IN_DAY, cachedGetter, unixDateTimeSecondsNumberToDate, unixDateTimeSecondsNumberForNow, selectiveFieldEncryptor, filterUndefinedValues, websiteUrlFromPaths, firstValue, hasHttpPrefix } from '@dereekb/util';
|
|
4
4
|
import { generateKeyPairSync, randomBytes } from 'node:crypto';
|
|
5
5
|
import { resolveEncryptionKey, encryptValue, decryptValue, createAesStringEncryptionProvider, isValidAES256GCMEncryptionSecret } from '@dereekb/nestjs';
|
|
6
|
-
import { where, iterateFirestoreDocumentSnapshotPairs, firestoreModelIdentity, snapshotConverterFunctions, optionalFirestoreDate, firestoreDate, firestoreEnum, firestorePassThroughField, AbstractFirestoreDocument, createOidcClientParamsType, deleteOidcClientParamsType, deleteOidcTokenParamsType, rotateOidcClientSecretParamsType, updateOidcClientParamsType, firestoreModelKey, oidcEntryIdentity, OIDC_ENTRY_CLIENT_TYPE, oidcEntriesByUserCodeQuery, oidcEntriesByUidQuery, oidcEntriesByGrantIdQuery, oidcEntryFirestoreCollection, callModelOidcScopeForCallType, CALL_MODEL_MISSING_OIDC_SCOPE_ERROR_CODE } from '@dereekb/firebase';
|
|
6
|
+
import { where, iterateFirestoreDocumentSnapshotPairs, firestoreModelIdentity, snapshotConverterFunctions, optionalFirestoreDate, firestoreDate, firestoreEnum, firestorePassThroughField, AbstractFirestoreDocument, createOidcClientParamsType, deleteOidcClientParamsType, deleteOidcTokenParamsType, rotateOidcClientSecretParamsType, updateOidcClientParamsType, firestoreModelKey, oidcEntryIdentity, PUBLIC_PKCE_TOKEN_ENDPOINT_AUTH_METHOD, OIDC_ENTRY_CLIENT_TYPE, oidcEntriesByUserCodeQuery, oidcEntriesByUidQuery, oidcEntriesByGrantIdQuery, oidcEntryFirestoreCollection, callModelOidcScopeForCallType, CALL_MODEL_MISSING_OIDC_SCOPE_ERROR_CODE } from '@dereekb/firebase';
|
|
7
7
|
import { firestoreEncryptedField, firebaseServerActionsContext, FirebaseServerEnvService, FIREBASE_FIRESTORE_CONTEXT_TOKEN, FirebaseServerFirestoreContextModule, forbiddenError } from '@dereekb/firebase-server';
|
|
8
8
|
import { nanoid } from 'nanoid';
|
|
9
9
|
import { safeToJsDate } from '@dereekb/date';
|
|
@@ -78,6 +78,31 @@ function _define_property$f(obj, key, value) {
|
|
|
78
78
|
}
|
|
79
79
|
return obj;
|
|
80
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Default {@link OidcRenderErrorFunction} that emits a JSON body with `error` and
|
|
83
|
+
* `error_description` fields, with `Content-Type: application/json`.
|
|
84
|
+
*
|
|
85
|
+
* Wired by {@link oidcModuleMetadata} when {@link OidcModuleConfig.renderError} is
|
|
86
|
+
* not provided. API-focused OIDC providers (the common case in dbx-components apps)
|
|
87
|
+
* want JSON errors rather than the HTML page oidc-provider renders by default.
|
|
88
|
+
*/ var OIDC_JSON_RENDER_ERROR_FUNCTION = function OIDC_JSON_RENDER_ERROR_FUNCTION(ctx, out) {
|
|
89
|
+
ctx.type = 'application/json';
|
|
90
|
+
ctx.body = JSON.stringify({
|
|
91
|
+
error: out.error,
|
|
92
|
+
error_description: out.error_description
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Returns the space-delimited list of every scope declared on `providerConfig.claims`.
|
|
97
|
+
*
|
|
98
|
+
* Suitable as the `scope` value on an {@link OidcResourceServerInfo} when the
|
|
99
|
+
* resource server should accept any scope the provider issues.
|
|
100
|
+
*
|
|
101
|
+
* @param providerConfig - The OIDC provider configuration whose scopes to enumerate.
|
|
102
|
+
* @returns Space-delimited string of all scope names from `providerConfig.claims`.
|
|
103
|
+
*/ function allOidcScopesStringForProviderConfig(providerConfig) {
|
|
104
|
+
return Object.keys(providerConfig.claims).join(' ');
|
|
105
|
+
}
|
|
81
106
|
/**
|
|
82
107
|
* Default global ceiling for a client-requested login duration, in seconds. 90 days.
|
|
83
108
|
*/ var DEFAULT_MAX_REQUESTED_LOGIN_DURATION_SECONDS = 90 * SECONDS_IN_DAY;
|
|
@@ -156,8 +181,10 @@ function _define_property$f(obj, key, value) {
|
|
|
156
181
|
/**
|
|
157
182
|
* Custom error rendering function for the oidc-provider.
|
|
158
183
|
*
|
|
159
|
-
* When not provided,
|
|
160
|
-
*
|
|
184
|
+
* When not provided, {@link OIDC_JSON_RENDER_ERROR_FUNCTION} is wired by
|
|
185
|
+
* {@link oidcModuleMetadata} so OIDC errors are returned as a JSON body with
|
|
186
|
+
* `error` and `error_description` fields. Set this to customize how OIDC
|
|
187
|
+
* errors are presented (e.g. redirect to an error page).
|
|
161
188
|
*
|
|
162
189
|
* The function signature matches oidc-provider's `renderError` configuration option.
|
|
163
190
|
*/ _define_property$f(this, "renderError", void 0);
|
|
@@ -203,6 +230,22 @@ function _define_property$f(obj, key, value) {
|
|
|
203
230
|
* ```
|
|
204
231
|
*/ _define_property$f(this, "resourceServers", void 0);
|
|
205
232
|
/**
|
|
233
|
+
* When `true`, {@link oidcModuleMetadata} automatically derives a resource-server
|
|
234
|
+
* entry from `envService.appMcpUrl` and the registered {@link OidcAccountService}'s
|
|
235
|
+
* provider config, then merges it into {@link resourceServers}. Any explicit entry
|
|
236
|
+
* supplied via {@link resourceServers} wins on key collisions.
|
|
237
|
+
*
|
|
238
|
+
* Required for OAuth-aware MCP clients (Claude, mcp-inspector) — they pass the
|
|
239
|
+
* MCP URL as the `resource` parameter on `/authorize` and `/token`, and oidc-provider
|
|
240
|
+
* rejects every such request with `invalid_target` unless that URL is registered.
|
|
241
|
+
*
|
|
242
|
+
* No effect when `envService.appMcpUrl` is unset.
|
|
243
|
+
*
|
|
244
|
+
* Defaults to `false`.
|
|
245
|
+
*
|
|
246
|
+
* @see buildFirebaseServerMcpResourceServer
|
|
247
|
+
*/ _define_property$f(this, "configureMcpResourceServer", void 0);
|
|
248
|
+
/**
|
|
206
249
|
* Absolute URL of the OAuth 2.0 Protected Resource Metadata document
|
|
207
250
|
* (RFC 9728) for the resources guarded by {@link protectedPaths}.
|
|
208
251
|
*
|
|
@@ -2201,14 +2244,19 @@ function _ts_generator$7(thisArg, body) {
|
|
|
2201
2244
|
value: /**
|
|
2202
2245
|
* Creates a new OIDC client through the oidc-provider.
|
|
2203
2246
|
*
|
|
2204
|
-
* Generates `client_id` and `client_secret` using the
|
|
2205
|
-
* registration flow, validates via `Client.validate`, and
|
|
2247
|
+
* Generates `client_id` (and, when the auth method requires one, a `client_secret`) using the
|
|
2248
|
+
* same defaults as oidc-provider's registration flow, validates via `Client.validate`, and
|
|
2249
|
+
* persists through the adapter.
|
|
2250
|
+
*
|
|
2251
|
+
* A secret is only generated when `ProviderClient.needsSecret()` returns `true`. The secret-less
|
|
2252
|
+
* methods `private_key_jwt` and `'none'` (public PKCE client) therefore persist no secret and the
|
|
2253
|
+
* returned `client_secret` is `undefined`.
|
|
2206
2254
|
*
|
|
2207
2255
|
* @param params - Client registration parameters.
|
|
2208
2256
|
* @param validatedMetadata - Optional pre-validated metadata to merge into the client properties.
|
|
2209
2257
|
* Use this for server-side fields (e.g., inline `jwks`) that have already been validated
|
|
2210
2258
|
* and should not be exposed through the API params.
|
|
2211
|
-
* @returns The generated client ID and secret (plaintext, returned only once).
|
|
2259
|
+
* @returns The generated client ID and, for secret-based methods, the secret (plaintext, returned only once).
|
|
2212
2260
|
*/ function createClient(params, validatedMetadata) {
|
|
2213
2261
|
return _async_to_generator$7(function() {
|
|
2214
2262
|
var provider, ProviderClient, clientId, firestoreOwnerKey, properties, clientSecret, client, payload;
|
|
@@ -2370,9 +2418,12 @@ function _ts_generator$7(thisArg, body) {
|
|
|
2370
2418
|
* Generates a new `client_secret`, re-validates via `Client.validate()`, and persists.
|
|
2371
2419
|
* The new secret is returned in plaintext — this is the only time it is available.
|
|
2372
2420
|
*
|
|
2421
|
+
* Rejects public PKCE clients (`token_endpoint_auth_method === 'none'`): they have no secret,
|
|
2422
|
+
* so there is nothing to rotate.
|
|
2423
|
+
*
|
|
2373
2424
|
* @param clientId - The client's document/adapter entry ID.
|
|
2374
2425
|
* @returns The client ID and new secret (plaintext, returned only once).
|
|
2375
|
-
* @throws {Error} When the client is not found.
|
|
2426
|
+
* @throws {Error} When the client is not found, or is a public PKCE (`none`) client.
|
|
2376
2427
|
*/ function rotateClientSecret(clientId) {
|
|
2377
2428
|
return _async_to_generator$7(function() {
|
|
2378
2429
|
var provider, ProviderClient, existing, newSecret, updatedMetadata, client;
|
|
@@ -2395,6 +2446,9 @@ function _ts_generator$7(thisArg, body) {
|
|
|
2395
2446
|
if (!existing) {
|
|
2396
2447
|
throw new Error('Client not found.');
|
|
2397
2448
|
}
|
|
2449
|
+
if (existing.token_endpoint_auth_method === PUBLIC_PKCE_TOKEN_ENDPOINT_AUTH_METHOD) {
|
|
2450
|
+
throw new Error('Cannot rotate a client secret for a public PKCE client (token_endpoint_auth_method "none"). Public clients have no secret.');
|
|
2451
|
+
}
|
|
2398
2452
|
newSecret = randomBytes(64).toString('base64url');
|
|
2399
2453
|
updatedMetadata = _object_spread_props$2(_object_spread$5({}, existing), {
|
|
2400
2454
|
client_secret: newSecret,
|
|
@@ -6573,6 +6627,40 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
6573
6627
|
var trimmedPath = parsed.pathname.replace(/\/[^/]*\/?$/, '');
|
|
6574
6628
|
return "".concat(parsed.origin).concat(trimmedPath, "/.well-known/oauth-protected-resource");
|
|
6575
6629
|
}
|
|
6630
|
+
/**
|
|
6631
|
+
* Builds a single-entry {@link OidcResourceServerInfo} map for the MCP endpoint
|
|
6632
|
+
* declared on `envService.appMcpUrl`, with `scope` set to every scope declared
|
|
6633
|
+
* on `providerConfig.claims` (so any scope the provider issues is valid on the
|
|
6634
|
+
* resource server) and `audience` set to the MCP URL.
|
|
6635
|
+
*
|
|
6636
|
+
* Returns `undefined` when no `appMcpUrl` is configured.
|
|
6637
|
+
*
|
|
6638
|
+
* Used internally by {@link oidcModuleMetadata} when {@link OidcModuleConfig.configureMcpResourceServer}
|
|
6639
|
+
* is enabled, and exported for apps that need to combine the MCP resource server
|
|
6640
|
+
* with additional app-specific entries:
|
|
6641
|
+
*
|
|
6642
|
+
* @example
|
|
6643
|
+
* ```ts
|
|
6644
|
+
* resourceServers: {
|
|
6645
|
+
* ...(buildFirebaseServerMcpResourceServer({ envService, providerConfig: APP_PROVIDER_CONFIG }) ?? {}),
|
|
6646
|
+
* 'https://api.example.com/extras': {
|
|
6647
|
+
* scope: 'openid profile',
|
|
6648
|
+
* audience: 'https://api.example.com/extras'
|
|
6649
|
+
* }
|
|
6650
|
+
* }
|
|
6651
|
+
* ```
|
|
6652
|
+
*/ function buildFirebaseServerMcpResourceServer(input) {
|
|
6653
|
+
var envService = input.envService, providerConfig = input.providerConfig;
|
|
6654
|
+
var mcpUrl = envService.appMcpUrl;
|
|
6655
|
+
var result;
|
|
6656
|
+
if (mcpUrl) {
|
|
6657
|
+
result = _define_property({}, mcpUrl, {
|
|
6658
|
+
scope: allOidcScopesStringForProviderConfig(providerConfig),
|
|
6659
|
+
audience: mcpUrl
|
|
6660
|
+
});
|
|
6661
|
+
}
|
|
6662
|
+
return result;
|
|
6663
|
+
}
|
|
6576
6664
|
/**
|
|
6577
6665
|
* Factory that creates {@link OidcServerFirestoreCollections} using the provided Firestore context
|
|
6578
6666
|
* and JWKS encryption config from {@link OidcModuleConfig}.
|
|
@@ -6629,9 +6717,10 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
6629
6717
|
provide: OidcModuleConfig,
|
|
6630
6718
|
inject: [
|
|
6631
6719
|
ConfigService,
|
|
6632
|
-
FirebaseServerEnvService
|
|
6720
|
+
FirebaseServerEnvService,
|
|
6721
|
+
OidcAccountService
|
|
6633
6722
|
],
|
|
6634
|
-
useFactory: function useFactory(configService, envService) {
|
|
6723
|
+
useFactory: function useFactory(configService, envService, oidcAccountService) {
|
|
6635
6724
|
var moduleConfig = oidcModuleConfigFactory(configService, envService);
|
|
6636
6725
|
var dynamicOverrides = configFactory ? configFactory(envService, configService) : undefined;
|
|
6637
6726
|
var merged = config || dynamicOverrides ? _object_spread({}, config, dynamicOverrides) : undefined;
|
|
@@ -6642,6 +6731,22 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
6642
6731
|
result.trustProxy = true;
|
|
6643
6732
|
}
|
|
6644
6733
|
}
|
|
6734
|
+
// Apply the default JSON error renderer when no custom renderError is configured.
|
|
6735
|
+
if (!result.renderError) {
|
|
6736
|
+
result.renderError = OIDC_JSON_RENDER_ERROR_FUNCTION;
|
|
6737
|
+
}
|
|
6738
|
+
// Auto-derive the MCP resource-server entry from envService.appMcpUrl and the
|
|
6739
|
+
// registered OidcAccountService's providerConfig. Any explicit resourceServers
|
|
6740
|
+
// entry from the consumer wins on key collisions.
|
|
6741
|
+
if (result.configureMcpResourceServer) {
|
|
6742
|
+
var mcpResourceServer = buildFirebaseServerMcpResourceServer({
|
|
6743
|
+
envService: envService,
|
|
6744
|
+
providerConfig: oidcAccountService.providerConfig
|
|
6745
|
+
});
|
|
6746
|
+
if (mcpResourceServer) {
|
|
6747
|
+
result.resourceServers = _object_spread({}, mcpResourceServer, result.resourceServers);
|
|
6748
|
+
}
|
|
6749
|
+
}
|
|
6645
6750
|
return result;
|
|
6646
6751
|
}
|
|
6647
6752
|
},
|
|
@@ -6728,4 +6833,4 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
6728
6833
|
return fn;
|
|
6729
6834
|
}
|
|
6730
6835
|
|
|
6731
|
-
export { DEFAULT_APP_OAUTH_CONSENT_PATH_PART, DEFAULT_APP_OAUTH_INTERACTION_PATH, DEFAULT_APP_OAUTH_LOGIN_PATH_PART, DEFAULT_MAX_REQUESTED_LOGIN_DURATION_SECONDS, DEFAULT_MIN_REQUESTED_LOGIN_DURATION_SECONDS, DEFAULT_OIDC_CODE_CHALLENGE_METHODS, DEFAULT_OIDC_ID_TOKEN_SIGNING_ALG_VALUES, DEFAULT_OIDC_ISSUER_PATH, DEFAULT_OIDC_ROUTES, DEFAULT_OIDC_SUBJECT_TYPES, DEFAULT_OIDC_TOKEN_ENDPOINT_AUTH_METHODS, DEFAULT_OIDC_TOKEN_LIFETIMES, DEFAULT_ROTATED_KEY_MAX_AGE, FIREBASE_SERVER_OIDC_ROUTES_FOR_GLOBAL_ROUTE_EXCLUDE, GRANTABLE_MODEL_NAMES, JwksFirestoreCollections, JwksKeyDocument, JwksService, JwksServiceConfig, JwksServiceStorageConfig, OIDC_ENCRYPTED_PAYLOAD_FIELDS, OIDC_JWKS_ENCRYPTION_SECRET_ENV_KEY, OidcAccountService, OidcAccountServiceDelegate, OidcAccountServiceUserContext, OidcAuth, OidcAuthBearerTokenMiddleware, OidcAuthMiddlewareConfig, OidcClientService, OidcEncryptionService, OidcInteractionController, OidcInteractionService, OidcModelServerActions, OidcModuleConfig, OidcProviderConfigService, OidcProviderController, OidcServerFirestoreCollections, OidcService, OidcWellKnownController, activeJwksKeysQuery, appOidcModelModuleMetadata, applyOidcAuthMiddleware, applyOidcCorsMiddleware, buildBearerChallenge, createAdapterFactory, createOidcClientFactory, deleteOidcClientFactory, deleteOidcTokenFactory, deriveResourceMetadataUrlFromEnv, getOidcScopesFromRequest, jwksKeyCollectionReference, jwksKeyConverter, jwksKeyFirestoreCollection, jwksKeyIdentity, jwksKeysWithStatusQuery, nonRetiredJwksKeysQuery, oidcCallModelScopePreAssert, oidcFirestoreCollectionsFactory, oidcModelServerActions, oidcModelServerActionsFactory, oidcModuleConfigFactory, oidcModuleMetadata, resolveEffectiveSubset, rotateOidcClientSecretFactory, rotatedJwksKeysQuery, updateOidcClientFactory };
|
|
6836
|
+
export { DEFAULT_APP_OAUTH_CONSENT_PATH_PART, DEFAULT_APP_OAUTH_INTERACTION_PATH, DEFAULT_APP_OAUTH_LOGIN_PATH_PART, DEFAULT_MAX_REQUESTED_LOGIN_DURATION_SECONDS, DEFAULT_MIN_REQUESTED_LOGIN_DURATION_SECONDS, DEFAULT_OIDC_CODE_CHALLENGE_METHODS, DEFAULT_OIDC_ID_TOKEN_SIGNING_ALG_VALUES, DEFAULT_OIDC_ISSUER_PATH, DEFAULT_OIDC_ROUTES, DEFAULT_OIDC_SUBJECT_TYPES, DEFAULT_OIDC_TOKEN_ENDPOINT_AUTH_METHODS, DEFAULT_OIDC_TOKEN_LIFETIMES, DEFAULT_ROTATED_KEY_MAX_AGE, FIREBASE_SERVER_OIDC_ROUTES_FOR_GLOBAL_ROUTE_EXCLUDE, GRANTABLE_MODEL_NAMES, JwksFirestoreCollections, JwksKeyDocument, JwksService, JwksServiceConfig, JwksServiceStorageConfig, OIDC_ENCRYPTED_PAYLOAD_FIELDS, OIDC_JSON_RENDER_ERROR_FUNCTION, OIDC_JWKS_ENCRYPTION_SECRET_ENV_KEY, OidcAccountService, OidcAccountServiceDelegate, OidcAccountServiceUserContext, OidcAuth, OidcAuthBearerTokenMiddleware, OidcAuthMiddlewareConfig, OidcClientService, OidcEncryptionService, OidcInteractionController, OidcInteractionService, OidcModelServerActions, OidcModuleConfig, OidcProviderConfigService, OidcProviderController, OidcServerFirestoreCollections, OidcService, OidcWellKnownController, activeJwksKeysQuery, allOidcScopesStringForProviderConfig, appOidcModelModuleMetadata, applyOidcAuthMiddleware, applyOidcCorsMiddleware, buildBearerChallenge, buildFirebaseServerMcpResourceServer, createAdapterFactory, createOidcClientFactory, deleteOidcClientFactory, deleteOidcTokenFactory, deriveResourceMetadataUrlFromEnv, getOidcScopesFromRequest, jwksKeyCollectionReference, jwksKeyConverter, jwksKeyFirestoreCollection, jwksKeyIdentity, jwksKeysWithStatusQuery, nonRetiredJwksKeysQuery, oidcCallModelScopePreAssert, oidcFirestoreCollectionsFactory, oidcModelServerActions, oidcModelServerActionsFactory, oidcModuleConfigFactory, oidcModuleMetadata, resolveEffectiveSubset, rotateOidcClientSecretFactory, rotatedJwksKeysQuery, updateOidcClientFactory };
|
package/oidc/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/firebase-server/oidc",
|
|
3
|
-
"version": "13.12.
|
|
3
|
+
"version": "13.12.4",
|
|
4
4
|
"peerDependencies": {
|
|
5
|
-
"@dereekb/analytics": "13.12.
|
|
6
|
-
"@dereekb/date": "13.12.
|
|
7
|
-
"@dereekb/firebase": "13.12.
|
|
8
|
-
"@dereekb/firebase-server": "13.12.
|
|
9
|
-
"@dereekb/model": "13.12.
|
|
10
|
-
"@dereekb/nestjs": "13.12.
|
|
11
|
-
"@dereekb/rxjs": "13.12.
|
|
12
|
-
"@dereekb/util": "13.12.
|
|
13
|
-
"@dereekb/zoho": "13.12.
|
|
5
|
+
"@dereekb/analytics": "13.12.4",
|
|
6
|
+
"@dereekb/date": "13.12.4",
|
|
7
|
+
"@dereekb/firebase": "13.12.4",
|
|
8
|
+
"@dereekb/firebase-server": "13.12.4",
|
|
9
|
+
"@dereekb/model": "13.12.4",
|
|
10
|
+
"@dereekb/nestjs": "13.12.4",
|
|
11
|
+
"@dereekb/rxjs": "13.12.4",
|
|
12
|
+
"@dereekb/util": "13.12.4",
|
|
13
|
+
"@dereekb/zoho": "13.12.4",
|
|
14
14
|
"@nestjs/common": "^11.1.19",
|
|
15
15
|
"@nestjs/config": "^4.0.4",
|
|
16
16
|
"express": "^5.2.1",
|
|
@@ -9,6 +9,15 @@ import { type JwksKeyConverterConfig } from './model';
|
|
|
9
9
|
* Matches the `renderError` option from the oidc-provider `Configuration` type.
|
|
10
10
|
*/
|
|
11
11
|
export type OidcRenderErrorFunction = Configuration['renderError'];
|
|
12
|
+
/**
|
|
13
|
+
* Default {@link OidcRenderErrorFunction} that emits a JSON body with `error` and
|
|
14
|
+
* `error_description` fields, with `Content-Type: application/json`.
|
|
15
|
+
*
|
|
16
|
+
* Wired by {@link oidcModuleMetadata} when {@link OidcModuleConfig.renderError} is
|
|
17
|
+
* not provided. API-focused OIDC providers (the common case in dbx-components apps)
|
|
18
|
+
* want JSON errors rather than the HTML page oidc-provider renders by default.
|
|
19
|
+
*/
|
|
20
|
+
export declare const OIDC_JSON_RENDER_ERROR_FUNCTION: OidcRenderErrorFunction;
|
|
12
21
|
/**
|
|
13
22
|
* Per-resource configuration returned by `features.resourceIndicators.getResourceServerInfo`
|
|
14
23
|
* to oidc-provider when a client requests an access token bound to a specific resource
|
|
@@ -78,6 +87,16 @@ export interface OidcProviderConfig<S extends OidcScope = OidcScope> {
|
|
|
78
87
|
*/
|
|
79
88
|
readonly grantTypes: string[];
|
|
80
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Returns the space-delimited list of every scope declared on `providerConfig.claims`.
|
|
92
|
+
*
|
|
93
|
+
* Suitable as the `scope` value on an {@link OidcResourceServerInfo} when the
|
|
94
|
+
* resource server should accept any scope the provider issues.
|
|
95
|
+
*
|
|
96
|
+
* @param providerConfig - The OIDC provider configuration whose scopes to enumerate.
|
|
97
|
+
* @returns Space-delimited string of all scope names from `providerConfig.claims`.
|
|
98
|
+
*/
|
|
99
|
+
export declare function allOidcScopesStringForProviderConfig<S extends OidcScope = OidcScope>(providerConfig: OidcProviderConfig<S>): string;
|
|
81
100
|
/**
|
|
82
101
|
* Configures the lifetime (in seconds) for each token type issued by the OIDC provider.
|
|
83
102
|
*
|
|
@@ -197,8 +216,10 @@ export declare abstract class OidcModuleConfig {
|
|
|
197
216
|
/**
|
|
198
217
|
* Custom error rendering function for the oidc-provider.
|
|
199
218
|
*
|
|
200
|
-
* When not provided,
|
|
201
|
-
*
|
|
219
|
+
* When not provided, {@link OIDC_JSON_RENDER_ERROR_FUNCTION} is wired by
|
|
220
|
+
* {@link oidcModuleMetadata} so OIDC errors are returned as a JSON body with
|
|
221
|
+
* `error` and `error_description` fields. Set this to customize how OIDC
|
|
222
|
+
* errors are presented (e.g. redirect to an error page).
|
|
202
223
|
*
|
|
203
224
|
* The function signature matches oidc-provider's `renderError` configuration option.
|
|
204
225
|
*/
|
|
@@ -247,6 +268,23 @@ export declare abstract class OidcModuleConfig {
|
|
|
247
268
|
* ```
|
|
248
269
|
*/
|
|
249
270
|
readonly resourceServers?: Readonly<Record<string, OidcResourceServerInfo>>;
|
|
271
|
+
/**
|
|
272
|
+
* When `true`, {@link oidcModuleMetadata} automatically derives a resource-server
|
|
273
|
+
* entry from `envService.appMcpUrl` and the registered {@link OidcAccountService}'s
|
|
274
|
+
* provider config, then merges it into {@link resourceServers}. Any explicit entry
|
|
275
|
+
* supplied via {@link resourceServers} wins on key collisions.
|
|
276
|
+
*
|
|
277
|
+
* Required for OAuth-aware MCP clients (Claude, mcp-inspector) — they pass the
|
|
278
|
+
* MCP URL as the `resource` parameter on `/authorize` and `/token`, and oidc-provider
|
|
279
|
+
* rejects every such request with `invalid_target` unless that URL is registered.
|
|
280
|
+
*
|
|
281
|
+
* No effect when `envService.appMcpUrl` is unset.
|
|
282
|
+
*
|
|
283
|
+
* Defaults to `false`.
|
|
284
|
+
*
|
|
285
|
+
* @see buildFirebaseServerMcpResourceServer
|
|
286
|
+
*/
|
|
287
|
+
readonly configureMcpResourceServer?: boolean;
|
|
250
288
|
/**
|
|
251
289
|
* Absolute URL of the OAuth 2.0 Protected Resource Metadata document
|
|
252
290
|
* (RFC 9728) for the resources guarded by {@link protectedPaths}.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ModuleMetadata } from '@nestjs/common';
|
|
2
2
|
import { ConfigService } from '@nestjs/config';
|
|
3
|
-
import { OidcModuleConfig } from './oidc.config';
|
|
3
|
+
import { OidcModuleConfig, type OidcProviderConfig, type OidcResourceServerInfo } from './oidc.config';
|
|
4
4
|
import { type FirestoreContext } from '@dereekb/firebase';
|
|
5
5
|
import { FirebaseServerEnvService } from '@dereekb/firebase-server';
|
|
6
6
|
import { OidcServerFirestoreCollections } from './model/model';
|
|
@@ -88,6 +88,43 @@ export declare function oidcModuleConfigFactory(configService: ConfigService, en
|
|
|
88
88
|
* @returns The discovery URL, or `undefined` if `appMcpUrl` is not set.
|
|
89
89
|
*/
|
|
90
90
|
export declare function deriveResourceMetadataUrlFromEnv(envService: FirebaseServerEnvService): string | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* Input for {@link buildFirebaseServerMcpResourceServer}.
|
|
93
|
+
*/
|
|
94
|
+
export interface BuildFirebaseServerMcpResourceServerInput {
|
|
95
|
+
/**
|
|
96
|
+
* The Firebase server environment service. The MCP URL is read from `envService.appMcpUrl`.
|
|
97
|
+
*/
|
|
98
|
+
readonly envService: FirebaseServerEnvService;
|
|
99
|
+
/**
|
|
100
|
+
* The OIDC provider config whose scopes back the resource server's `scope` value.
|
|
101
|
+
*/
|
|
102
|
+
readonly providerConfig: OidcProviderConfig;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Builds a single-entry {@link OidcResourceServerInfo} map for the MCP endpoint
|
|
106
|
+
* declared on `envService.appMcpUrl`, with `scope` set to every scope declared
|
|
107
|
+
* on `providerConfig.claims` (so any scope the provider issues is valid on the
|
|
108
|
+
* resource server) and `audience` set to the MCP URL.
|
|
109
|
+
*
|
|
110
|
+
* Returns `undefined` when no `appMcpUrl` is configured.
|
|
111
|
+
*
|
|
112
|
+
* Used internally by {@link oidcModuleMetadata} when {@link OidcModuleConfig.configureMcpResourceServer}
|
|
113
|
+
* is enabled, and exported for apps that need to combine the MCP resource server
|
|
114
|
+
* with additional app-specific entries:
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```ts
|
|
118
|
+
* resourceServers: {
|
|
119
|
+
* ...(buildFirebaseServerMcpResourceServer({ envService, providerConfig: APP_PROVIDER_CONFIG }) ?? {}),
|
|
120
|
+
* 'https://api.example.com/extras': {
|
|
121
|
+
* scope: 'openid profile',
|
|
122
|
+
* audience: 'https://api.example.com/extras'
|
|
123
|
+
* }
|
|
124
|
+
* }
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
export declare function buildFirebaseServerMcpResourceServer(input: BuildFirebaseServerMcpResourceServerInput): Record<string, OidcResourceServerInfo> | undefined;
|
|
91
128
|
/**
|
|
92
129
|
* Factory that creates {@link OidcServerFirestoreCollections} using the provided Firestore context
|
|
93
130
|
* and JWKS encryption config from {@link OidcModuleConfig}.
|
|
@@ -101,7 +138,7 @@ export declare function oidcFirestoreCollectionsFactory(firestoreContext: Firest
|
|
|
101
138
|
* Subset of {@link OidcModuleConfig} that consumers may override via
|
|
102
139
|
* `oidcModuleMetadata`'s `config` or `configFactory`.
|
|
103
140
|
*/
|
|
104
|
-
export type OidcModuleMetadataOverrides = Partial<Pick<OidcModuleConfig, 'issuer' | 'suppressBodyParserWarning' | 'renderError' | 'protectedPaths' | 'appOAuthInteractionPath' | 'appOAuthLoginUrlPart' | 'appOAuthConsentUrlPart' | 'tokenEndpointAuthMethods' | 'registrationEnabled' | 'trustProxy' | 'trustProxyInNonProduction' | 'tokenLifetimes' | 'maxRequestedLoginDuration' | 'minRequestedLoginDuration' | 'defaultRequestedLoginDuration' | 'resourceServers' | 'resourceMetadataUrl'>>;
|
|
141
|
+
export type OidcModuleMetadataOverrides = Partial<Pick<OidcModuleConfig, 'issuer' | 'suppressBodyParserWarning' | 'renderError' | 'protectedPaths' | 'appOAuthInteractionPath' | 'appOAuthLoginUrlPart' | 'appOAuthConsentUrlPart' | 'tokenEndpointAuthMethods' | 'registrationEnabled' | 'trustProxy' | 'trustProxyInNonProduction' | 'tokenLifetimes' | 'maxRequestedLoginDuration' | 'minRequestedLoginDuration' | 'defaultRequestedLoginDuration' | 'resourceServers' | 'resourceMetadataUrl' | 'configureMcpResourceServer'>>;
|
|
105
142
|
export interface ProvideAppOidcModuleMetadataConfig extends Pick<ModuleMetadata, 'imports' | 'exports' | 'providers'> {
|
|
106
143
|
/**
|
|
107
144
|
* Module that exports the required dependencies for this module.
|
|
@@ -13,14 +13,19 @@ export declare class OidcClientService {
|
|
|
13
13
|
/**
|
|
14
14
|
* Creates a new OIDC client through the oidc-provider.
|
|
15
15
|
*
|
|
16
|
-
* Generates `client_id` and `client_secret` using the
|
|
17
|
-
* registration flow, validates via `Client.validate`, and
|
|
16
|
+
* Generates `client_id` (and, when the auth method requires one, a `client_secret`) using the
|
|
17
|
+
* same defaults as oidc-provider's registration flow, validates via `Client.validate`, and
|
|
18
|
+
* persists through the adapter.
|
|
19
|
+
*
|
|
20
|
+
* A secret is only generated when `ProviderClient.needsSecret()` returns `true`. The secret-less
|
|
21
|
+
* methods `private_key_jwt` and `'none'` (public PKCE client) therefore persist no secret and the
|
|
22
|
+
* returned `client_secret` is `undefined`.
|
|
18
23
|
*
|
|
19
24
|
* @param params - Client registration parameters.
|
|
20
25
|
* @param validatedMetadata - Optional pre-validated metadata to merge into the client properties.
|
|
21
26
|
* Use this for server-side fields (e.g., inline `jwks`) that have already been validated
|
|
22
27
|
* and should not be exposed through the API params.
|
|
23
|
-
* @returns The generated client ID and secret (plaintext, returned only once).
|
|
28
|
+
* @returns The generated client ID and, for secret-based methods, the secret (plaintext, returned only once).
|
|
24
29
|
*/
|
|
25
30
|
createClient(params: CreateOidcClientParams, validatedMetadata?: Partial<Pick<ClientMetadata, 'jwks'>>): Promise<CreateOidcClientResult>;
|
|
26
31
|
/**
|
|
@@ -42,9 +47,12 @@ export declare class OidcClientService {
|
|
|
42
47
|
* Generates a new `client_secret`, re-validates via `Client.validate()`, and persists.
|
|
43
48
|
* The new secret is returned in plaintext — this is the only time it is available.
|
|
44
49
|
*
|
|
50
|
+
* Rejects public PKCE clients (`token_endpoint_auth_method === 'none'`): they have no secret,
|
|
51
|
+
* so there is nothing to rotate.
|
|
52
|
+
*
|
|
45
53
|
* @param clientId - The client's document/adapter entry ID.
|
|
46
54
|
* @returns The client ID and new secret (plaintext, returned only once).
|
|
47
|
-
* @throws {Error} When the client is not found.
|
|
55
|
+
* @throws {Error} When the client is not found, or is a public PKCE (`none`) client.
|
|
48
56
|
*/
|
|
49
57
|
rotateClientSecret(clientId: OidcEntryClientId): Promise<RotateOidcClientSecretResult>;
|
|
50
58
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/firebase-server",
|
|
3
|
-
"version": "13.12.
|
|
3
|
+
"version": "13.12.4",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"exports": {
|
|
6
6
|
"./test": {
|
|
@@ -56,17 +56,19 @@
|
|
|
56
56
|
"main": "./index.cjs.js",
|
|
57
57
|
"types": "./src/index.d.ts",
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@
|
|
60
|
-
"@dereekb/
|
|
61
|
-
"@dereekb/
|
|
62
|
-
"@dereekb/
|
|
63
|
-
"@dereekb/
|
|
64
|
-
"@dereekb/
|
|
65
|
-
"@dereekb/
|
|
66
|
-
"@dereekb/
|
|
67
|
-
"@dereekb/
|
|
59
|
+
"@cantoo/pdf-lib": "^2.6.5",
|
|
60
|
+
"@dereekb/analytics": "13.12.4",
|
|
61
|
+
"@dereekb/date": "13.12.4",
|
|
62
|
+
"@dereekb/dbx-core": "13.12.4",
|
|
63
|
+
"@dereekb/firebase": "13.12.4",
|
|
64
|
+
"@dereekb/model": "13.12.4",
|
|
65
|
+
"@dereekb/nestjs": "13.12.4",
|
|
66
|
+
"@dereekb/rxjs": "13.12.4",
|
|
67
|
+
"@dereekb/util": "13.12.4",
|
|
68
|
+
"@dereekb/zoho": "13.12.4",
|
|
68
69
|
"@google-cloud/firestore": "^7.11.6",
|
|
69
70
|
"@google-cloud/storage": "^7.19.0",
|
|
71
|
+
"@modelcontextprotocol/sdk": "1.29.0",
|
|
70
72
|
"@nestjs/common": "^11.1.19",
|
|
71
73
|
"@nestjs/config": "^4.0.4",
|
|
72
74
|
"@nestjs/core": "^11.1.19",
|
|
@@ -84,6 +86,7 @@
|
|
|
84
86
|
"nanoid": "^5.1.9",
|
|
85
87
|
"oidc-provider": "^9.8.2",
|
|
86
88
|
"rxjs": "^7.8.2",
|
|
89
|
+
"sharp": "0.34.5",
|
|
87
90
|
"supertest": "^7.2.2",
|
|
88
91
|
"ts-essentials": "^10.2.0"
|
|
89
92
|
},
|
|
@@ -669,23 +669,82 @@ export interface FirebaseServerAuthPasswordResetSendContentConfig<D = unknown> {
|
|
|
669
669
|
*/
|
|
670
670
|
readonly data?: Maybe<D>;
|
|
671
671
|
}
|
|
672
|
+
/**
|
|
673
|
+
* Opaque composite token returned to the user during a password reset. Encodes both
|
|
674
|
+
* the raw reset code and the target uid in a single value so the completion call does
|
|
675
|
+
* not need a separate uid argument (which a logged-out forgot-password flow cannot provide).
|
|
676
|
+
*
|
|
677
|
+
* The on-the-wire shape is `<code>-<uid>`. The raw code is the numeric string produced by
|
|
678
|
+
* {@link DEFAULT_FIREBASE_PASSWORD_NUMBER_GENERATOR}, so the first `-` cleanly splits the token.
|
|
679
|
+
* Do not split or mutate the token outside of {@link decodeFirebaseServerUserPasswordResetOobCode}.
|
|
680
|
+
*/
|
|
681
|
+
export type FirebaseServerUserPasswordResetOobCode = string & {
|
|
682
|
+
__firebaseServerUserPasswordResetOobCode: true;
|
|
683
|
+
};
|
|
684
|
+
/**
|
|
685
|
+
* Builds the composite oob code from a raw reset code (the numeric value stored in
|
|
686
|
+
* {@link FirebaseServerAuthResetUserPasswordClaims.resetPassword}) and the target user's uid.
|
|
687
|
+
*
|
|
688
|
+
* @param uid - The target user's UID.
|
|
689
|
+
* @param code - The raw reset code from the user's claims.
|
|
690
|
+
*
|
|
691
|
+
* @example
|
|
692
|
+
* ```typescript
|
|
693
|
+
* const oobCode = encodeFirebaseServerUserPasswordResetOobCode(user.uid, claims.resetPassword);
|
|
694
|
+
* // e.g. '482910-abcDEF123'
|
|
695
|
+
* ```
|
|
696
|
+
*/
|
|
697
|
+
export declare function encodeFirebaseServerUserPasswordResetOobCode(uid: FirebaseAuthUserId, code: string): FirebaseServerUserPasswordResetOobCode;
|
|
698
|
+
/**
|
|
699
|
+
* Decodes a composite oob code back into its `{ uid, code }` parts. Returns `undefined`
|
|
700
|
+
* when the token is malformed (missing separator, non-numeric code, empty uid).
|
|
701
|
+
*
|
|
702
|
+
* @param token - The composite oob token, typically received from the password-reset email.
|
|
703
|
+
*
|
|
704
|
+
* @example
|
|
705
|
+
* ```typescript
|
|
706
|
+
* const decoded = decodeFirebaseServerUserPasswordResetOobCode('482910-abcDEF123');
|
|
707
|
+
* // decoded = { uid: 'abcDEF123', code: '482910' }
|
|
708
|
+
* ```
|
|
709
|
+
*/
|
|
710
|
+
export declare function decodeFirebaseServerUserPasswordResetOobCode(token: string): {
|
|
711
|
+
uid: FirebaseAuthUserId;
|
|
712
|
+
code: string;
|
|
713
|
+
} | undefined;
|
|
672
714
|
/**
|
|
673
715
|
* Details about a user that is in the password reset phase, including their user context,
|
|
674
|
-
* reset claims data, and the send configuration that was used.
|
|
716
|
+
* reset claims data, the encoded oob code intended for the user, and the send configuration that was used.
|
|
675
717
|
*/
|
|
676
718
|
export interface FirebaseServerAuthPasswordResetDetails<U extends FirebaseServerAuthUserContext = FirebaseServerAuthUserContext, D = unknown> extends FirebaseServerAuthPasswordResetSendContentConfig<D> {
|
|
677
719
|
readonly userContext: U;
|
|
678
720
|
readonly claims: FirebaseAuthResetUserPasswordClaimsData;
|
|
721
|
+
/**
|
|
722
|
+
* The encoded oob code intended for the user (carries the raw reset code AND the target uid).
|
|
723
|
+
* Subclasses that send password-reset emails should embed this value, not `claims.resetPassword`.
|
|
724
|
+
*/
|
|
725
|
+
readonly oobCode: FirebaseServerUserPasswordResetOobCode;
|
|
679
726
|
}
|
|
680
727
|
/**
|
|
681
|
-
*
|
|
682
|
-
* and the
|
|
728
|
+
* Result of {@link FirebaseServerUserPasswordResetService.beginPasswordReset}, exposing both the
|
|
729
|
+
* stored reset claims and the encoded composite oob code intended for the user.
|
|
730
|
+
*/
|
|
731
|
+
export interface FirebaseServerAuthBeginPasswordResetResult {
|
|
732
|
+
readonly claims: FirebaseServerAuthResetUserPasswordClaims;
|
|
733
|
+
/**
|
|
734
|
+
* The encoded oob code that should be delivered to the user (e.g. embedded in the reset email).
|
|
735
|
+
*/
|
|
736
|
+
readonly oobCode: FirebaseServerUserPasswordResetOobCode;
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* Input for completing a password reset, containing the composite oob code from the recovery email
|
|
740
|
+
* (which encodes both the temporary reset code AND the target uid) and the desired new password.
|
|
683
741
|
*/
|
|
684
742
|
export interface FirebaseServerAuthCompletePasswordResetInput {
|
|
685
743
|
/**
|
|
686
|
-
* The
|
|
744
|
+
* The full oob token from the recovery email — encodes both the raw reset code AND the target uid.
|
|
745
|
+
* The service decodes this internally to resolve the user and verify the embedded code.
|
|
687
746
|
*/
|
|
688
|
-
readonly
|
|
747
|
+
readonly oobCode: FirebaseServerUserPasswordResetOobCode;
|
|
689
748
|
/**
|
|
690
749
|
* The new password to set after verification succeeds.
|
|
691
750
|
*/
|
|
@@ -700,9 +759,9 @@ export interface FirebaseServerAuthCompletePasswordResetInput {
|
|
|
700
759
|
* @example
|
|
701
760
|
* ```typescript
|
|
702
761
|
* const resetSvc = authService.passwordReset();
|
|
703
|
-
* const
|
|
704
|
-
* // Later, after user
|
|
705
|
-
* await resetSvc.completePasswordReset(
|
|
762
|
+
* const { oobCode } = await resetSvc.beginPasswordReset({ uid: 'some-uid', sendResetContent: true });
|
|
763
|
+
* // Later, after the user clicks the link in their reset email:
|
|
764
|
+
* await resetSvc.completePasswordReset({ oobCode, newPassword: 'newSecure' });
|
|
706
765
|
* ```
|
|
707
766
|
*/
|
|
708
767
|
export interface FirebaseServerUserPasswordResetService<D = unknown, U extends FirebaseServerAuthUserContext = FirebaseServerAuthUserContext> {
|
|
@@ -713,13 +772,16 @@ export interface FirebaseServerUserPasswordResetService<D = unknown, U extends F
|
|
|
713
772
|
* When `sendResetContent` is true, this method delegates to {@link sendResetContent} and
|
|
714
773
|
* may throw the same errors (throttle, send-once, no-config) depending on the configuration.
|
|
715
774
|
*
|
|
775
|
+
* Returns both the stored reset claims and the encoded composite oob code that should be
|
|
776
|
+
* delivered to the user (the value the user will later submit to {@link completePasswordReset}).
|
|
777
|
+
*
|
|
716
778
|
* @param input - Configuration for the reset, including user identification and send options.
|
|
717
779
|
* @throws {Error} Throws if neither uid nor email is provided.
|
|
718
780
|
* @throws {FirebaseServerAuthPasswordResetThrottleError} When send is throttled and `sendResetThrowErrors` is true.
|
|
719
781
|
* @throws {FirebaseServerAuthPasswordResetSendOnceError} When already sent and `sendResetDetailsOnce` + `sendResetThrowErrors` are true.
|
|
720
782
|
* @throws {FirebaseServerAuthPasswordResetNoResetConfigError} When no reset claims exist and `sendResetThrowErrors` is true.
|
|
721
783
|
*/
|
|
722
|
-
beginPasswordReset(input: FirebaseServerAuthInitiatePasswordReset<D>): Promise<
|
|
784
|
+
beginPasswordReset(input: FirebaseServerAuthInitiatePasswordReset<D>): Promise<FirebaseServerAuthBeginPasswordResetResult>;
|
|
723
785
|
/**
|
|
724
786
|
* Sends reset content (e.g., a reset email) to the user.
|
|
725
787
|
*
|
|
@@ -750,14 +812,19 @@ export interface FirebaseServerUserPasswordResetService<D = unknown, U extends F
|
|
|
750
812
|
*/
|
|
751
813
|
loadResetDetailsForUserContext(userContext: U, config?: FirebaseServerAuthPasswordResetSendContentConfig<D>): Promise<Maybe<FirebaseServerAuthPasswordResetDetails<U, D>>>;
|
|
752
814
|
/**
|
|
753
|
-
* Completes the password reset by
|
|
754
|
-
* claims and setting the new password.
|
|
815
|
+
* Completes the password reset by decoding the composite oob token, resolving the target user,
|
|
816
|
+
* verifying the embedded reset code against the user's claims, and setting the new password.
|
|
817
|
+
* Clears reset claims on success.
|
|
755
818
|
*
|
|
756
|
-
*
|
|
757
|
-
*
|
|
758
|
-
*
|
|
819
|
+
* The target uid is read from the encoded token — callers do not need to know it separately,
|
|
820
|
+
* which is what enables the logged-out "forgot password" flow.
|
|
821
|
+
*
|
|
822
|
+
* @param input - The encoded oob token and new password.
|
|
823
|
+
* @throws {FirebaseServerAuthPasswordResetInvalidCodeError} When the token is malformed, the
|
|
824
|
+
* embedded uid does not own an active reset, the code is expired, or the code does not match.
|
|
825
|
+
* The same opaque error is thrown for every failure mode.
|
|
759
826
|
*/
|
|
760
|
-
completePasswordReset(
|
|
827
|
+
completePasswordReset(input: FirebaseServerAuthCompletePasswordResetInput): Promise<admin.auth.UserRecord>;
|
|
761
828
|
}
|
|
762
829
|
/**
|
|
763
830
|
* Default throttle duration (60 seconds) between reset content re-sends to prevent spam while
|
|
@@ -798,7 +865,7 @@ export declare abstract class AbstractFirebaseServerUserPasswordResetService<U e
|
|
|
798
865
|
protected resetThrottleTime: Milliseconds;
|
|
799
866
|
constructor(authService: FirebaseServerAuthService<U, C>);
|
|
800
867
|
get authService(): FirebaseServerAuthService<U, C>;
|
|
801
|
-
beginPasswordReset(input: FirebaseServerAuthInitiatePasswordReset<D>): Promise<
|
|
868
|
+
beginPasswordReset(input: FirebaseServerAuthInitiatePasswordReset<D>): Promise<FirebaseServerAuthBeginPasswordResetResult>;
|
|
802
869
|
sendResetContent(uid: FirebaseAuthUserId, config?: FirebaseServerAuthPasswordResetSendContentConfig<D>): Promise<boolean>;
|
|
803
870
|
loadResetDetails(uid: FirebaseAuthUserId, config?: FirebaseServerAuthPasswordResetSendContentConfig<D>): Promise<Maybe<FirebaseServerAuthPasswordResetDetails<U, D>>>;
|
|
804
871
|
loadResetDetailsForUserContext(userContext: U, config?: FirebaseServerAuthPasswordResetSendContentConfig<D>): Promise<Maybe<FirebaseServerAuthPasswordResetDetails<U, D>>>;
|
|
@@ -808,7 +875,7 @@ export declare abstract class AbstractFirebaseServerUserPasswordResetService<U e
|
|
|
808
875
|
* @param details - The user's reset details containing the user context.
|
|
809
876
|
*/
|
|
810
877
|
protected updateResetContentSentTime(details: FirebaseServerAuthPasswordResetDetails<U, D>): Promise<void>;
|
|
811
|
-
completePasswordReset(
|
|
878
|
+
completePasswordReset(input: FirebaseServerAuthCompletePasswordResetInput): Promise<admin.auth.UserRecord>;
|
|
812
879
|
/**
|
|
813
880
|
* Delivers reset content (e.g., reset email, SMS) to the user.
|
|
814
881
|
*
|
|
@@ -18,11 +18,11 @@ export declare abstract class FirebaseServerEnvService {
|
|
|
18
18
|
*/
|
|
19
19
|
abstract readonly isTestingEnv: boolean;
|
|
20
20
|
/**
|
|
21
|
-
* Whether the server is running in production.
|
|
21
|
+
* Whether the server is running in production mode. (This may be true in both prod or a staging running as production).
|
|
22
22
|
*/
|
|
23
23
|
abstract readonly isProduction: boolean;
|
|
24
24
|
/**
|
|
25
|
-
* Whether the server is running in a staging environment.
|
|
25
|
+
* Whether the server is running in a staging environment. isProduction is also typically true when this is true.
|
|
26
26
|
*/
|
|
27
27
|
abstract readonly isStaging: boolean;
|
|
28
28
|
/**
|