@dereekb/firebase 13.29.0 → 13.31.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.
- package/eslint/package.json +3 -3
- package/index.cjs.js +370 -174
- package/index.esm.js +360 -175
- package/package.json +5 -5
- package/src/lib/common/auth/oidc/index.d.ts +3 -0
- package/src/lib/{model/oidcmodel/oidcmodel.interaction.d.ts → common/auth/oidc/oidc.base.d.ts} +9 -0
- package/src/lib/common/auth/oidc/oidc.d.ts +136 -0
- package/src/lib/{model/oidcmodel/oidcmodel.interaction.oauth.d.ts → common/auth/oidc/oidc.interaction.d.ts} +2 -3
- package/src/lib/common/auth/oidc/oidc.profile.d.ts +213 -0
- package/src/lib/model/oidcmodel/index.d.ts +0 -3
- package/src/lib/model/oidcmodel/oidcmodel.api.d.ts +2 -4
- package/src/lib/model/oidcmodel/oidcmodel.data.d.ts +1 -2
- package/src/lib/model/oidcmodel/oidcmodel.id.d.ts +0 -9
- package/test/package.json +6 -6
- package/src/lib/model/oidcmodel/oidc.profile.d.ts +0 -107
package/eslint/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/firebase/eslint",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.31.0",
|
|
4
4
|
"peerDependencies": {
|
|
5
|
-
"@dereekb/util": "13.
|
|
5
|
+
"@dereekb/util": "13.31.0",
|
|
6
6
|
"@marcbachmann/cel-js": "^7.6.1",
|
|
7
7
|
"@typescript-eslint/parser": "8.59.3",
|
|
8
8
|
"@typescript-eslint/utils": "8.59.3",
|
|
9
9
|
"typescript": "5.9.3"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"@dereekb/firebase": "13.
|
|
12
|
+
"@dereekb/firebase": "13.31.0",
|
|
13
13
|
"eslint": "10.4.0",
|
|
14
14
|
"firebase": "^12.12.1"
|
|
15
15
|
},
|
package/index.cjs.js
CHANGED
|
@@ -11904,6 +11904,271 @@ function _class_call_check$c(instance, Constructor) {
|
|
|
11904
11904
|
* `model.*` scope for a callModel CRUD operation.
|
|
11905
11905
|
*/ var CALL_MODEL_MISSING_OIDC_SCOPE_ERROR_CODE = 'CALL_MODEL_MISSING_OIDC_SCOPE';
|
|
11906
11906
|
|
|
11907
|
+
/**
|
|
11908
|
+
* The `client_secret_basic` confidential-client auth method (RFC 6749 §2.3.1, the
|
|
11909
|
+
* OAuth 2.0 default): the client sends its `client_id` and `client_secret` in the
|
|
11910
|
+
* `Authorization: Basic` header on token-endpoint requests. Standard pick for
|
|
11911
|
+
* server-side confidential clients.
|
|
11912
|
+
*
|
|
11913
|
+
* @example
|
|
11914
|
+
* ```ts
|
|
11915
|
+
* await oidcClientService.createClient({
|
|
11916
|
+
* token_endpoint_auth_method: CLIENT_SECRET_BASIC_TOKEN_ENDPOINT_AUTH_METHOD,
|
|
11917
|
+
* // ...
|
|
11918
|
+
* });
|
|
11919
|
+
* ```
|
|
11920
|
+
*/ var CLIENT_SECRET_BASIC_TOKEN_ENDPOINT_AUTH_METHOD = 'client_secret_basic';
|
|
11921
|
+
/**
|
|
11922
|
+
* The `client_secret_post` confidential-client auth method (RFC 6749 §2.3.1, the
|
|
11923
|
+
* form-body variant): the client sends `client_id` and `client_secret` as form-encoded
|
|
11924
|
+
* parameters in the token-endpoint request body. Equivalent in security to
|
|
11925
|
+
* {@link CLIENT_SECRET_BASIC_TOKEN_ENDPOINT_AUTH_METHOD}; pick it for clients that
|
|
11926
|
+
* cannot set the `Authorization` header (some older HTTP stacks).
|
|
11927
|
+
*
|
|
11928
|
+
* @example
|
|
11929
|
+
* ```ts
|
|
11930
|
+
* await oidcClientService.createClient({
|
|
11931
|
+
* token_endpoint_auth_method: CLIENT_SECRET_POST_TOKEN_ENDPOINT_AUTH_METHOD,
|
|
11932
|
+
* // ...
|
|
11933
|
+
* });
|
|
11934
|
+
* ```
|
|
11935
|
+
*/ var CLIENT_SECRET_POST_TOKEN_ENDPOINT_AUTH_METHOD = 'client_secret_post';
|
|
11936
|
+
/**
|
|
11937
|
+
* The `client_secret_jwt` confidential-client auth method (OIDC Core §9): the client
|
|
11938
|
+
* signs a JWT client assertion using its `client_secret` as the HMAC key (HS256/HS384/HS512)
|
|
11939
|
+
* and sends it as `client_assertion` on token-endpoint requests. The secret never goes on
|
|
11940
|
+
* the wire — only the signed assertion — which is the upgrade over the plain
|
|
11941
|
+
* `client_secret_*` methods, without requiring asymmetric keys like
|
|
11942
|
+
* {@link PRIVATE_KEY_JWT_TOKEN_ENDPOINT_AUTH_METHOD}.
|
|
11943
|
+
*
|
|
11944
|
+
* @example
|
|
11945
|
+
* ```ts
|
|
11946
|
+
* await oidcClientService.createClient({
|
|
11947
|
+
* token_endpoint_auth_method: CLIENT_SECRET_JWT_TOKEN_ENDPOINT_AUTH_METHOD,
|
|
11948
|
+
* // ...
|
|
11949
|
+
* });
|
|
11950
|
+
* ```
|
|
11951
|
+
*/ var CLIENT_SECRET_JWT_TOKEN_ENDPOINT_AUTH_METHOD = 'client_secret_jwt';
|
|
11952
|
+
/**
|
|
11953
|
+
* The `private_key_jwt` confidential-client auth method (OIDC Core §9): the client signs
|
|
11954
|
+
* a JWT client assertion with its private key (RS256/ES256/PS256) and sends it as
|
|
11955
|
+
* `client_assertion`; the server verifies via the client's published `jwks` / `jwks_uri`.
|
|
11956
|
+
* Strongest of the confidential-client methods — no shared secret is ever held by the
|
|
11957
|
+
* server — and the canonical pick for high-trust server-to-server integrations.
|
|
11958
|
+
*
|
|
11959
|
+
* @example
|
|
11960
|
+
* ```ts
|
|
11961
|
+
* await oidcClientService.createClient({
|
|
11962
|
+
* token_endpoint_auth_method: PRIVATE_KEY_JWT_TOKEN_ENDPOINT_AUTH_METHOD,
|
|
11963
|
+
* jwks: { keys: [publicJwk] },
|
|
11964
|
+
* // ...
|
|
11965
|
+
* });
|
|
11966
|
+
* ```
|
|
11967
|
+
*/ var PRIVATE_KEY_JWT_TOKEN_ENDPOINT_AUTH_METHOD = 'private_key_jwt';
|
|
11968
|
+
/**
|
|
11969
|
+
* The public-client auth method (`'none'`): no client secret, PKCE-only. The client
|
|
11970
|
+
* authenticates the `authorization_code` flow with PKCE (RFC 7636) alone — there is no
|
|
11971
|
+
* shared secret and no client assertion. Canonical pick for clients that cannot keep a
|
|
11972
|
+
* secret (native apps, SPAs, CLIs) and what the MCP / Claude connector ecosystem
|
|
11973
|
+
* (claude.ai connector, Claude Code CLI, mcp-inspector via DCR) registers as.
|
|
11974
|
+
*
|
|
11975
|
+
* Mirrors {@link PRIVATE_KEY_JWT_TOKEN_ENDPOINT_AUTH_METHOD}. `oidc-provider` still
|
|
11976
|
+
* enforces PKCE on the `authorization_code` flow for every client regardless of auth
|
|
11977
|
+
* method, so `'none'` simply unlocks the secret-less variant rather than disabling any
|
|
11978
|
+
* client authentication.
|
|
11979
|
+
*
|
|
11980
|
+
* @example
|
|
11981
|
+
* ```ts
|
|
11982
|
+
* await oidcClientService.createClient({
|
|
11983
|
+
* token_endpoint_auth_method: PUBLIC_PKCE_TOKEN_ENDPOINT_AUTH_METHOD,
|
|
11984
|
+
* // no client_secret — public PKCE client
|
|
11985
|
+
* // ...
|
|
11986
|
+
* });
|
|
11987
|
+
* ```
|
|
11988
|
+
*/ var PUBLIC_PKCE_TOKEN_ENDPOINT_AUTH_METHOD = 'none';
|
|
11989
|
+
/**
|
|
11990
|
+
* All available token endpoint auth method options with display labels.
|
|
11991
|
+
*/ var ALL_OIDC_TOKEN_ENDPOINT_AUTH_METHOD_OPTIONS = [
|
|
11992
|
+
{
|
|
11993
|
+
label: 'Client Secret Basic',
|
|
11994
|
+
value: CLIENT_SECRET_BASIC_TOKEN_ENDPOINT_AUTH_METHOD
|
|
11995
|
+
},
|
|
11996
|
+
{
|
|
11997
|
+
label: 'Client Secret Post',
|
|
11998
|
+
value: CLIENT_SECRET_POST_TOKEN_ENDPOINT_AUTH_METHOD
|
|
11999
|
+
},
|
|
12000
|
+
{
|
|
12001
|
+
label: 'Client Secret JWT',
|
|
12002
|
+
value: CLIENT_SECRET_JWT_TOKEN_ENDPOINT_AUTH_METHOD
|
|
12003
|
+
},
|
|
12004
|
+
{
|
|
12005
|
+
label: 'Private Key JWT',
|
|
12006
|
+
value: PRIVATE_KEY_JWT_TOKEN_ENDPOINT_AUTH_METHOD
|
|
12007
|
+
},
|
|
12008
|
+
{
|
|
12009
|
+
label: 'None (Public PKCE)',
|
|
12010
|
+
value: PUBLIC_PKCE_TOKEN_ENDPOINT_AUTH_METHOD
|
|
12011
|
+
}
|
|
12012
|
+
];
|
|
12013
|
+
/**
|
|
12014
|
+
* All available OIDC token endpoint auth methods for the demo app, suitable for use in auth method picker fields.
|
|
12015
|
+
*/ var ALL_OIDC_TOKEN_ENDPOINT_AUTH_METHODS = ALL_OIDC_TOKEN_ENDPOINT_AUTH_METHOD_OPTIONS.map(function(x) {
|
|
12016
|
+
return x.value;
|
|
12017
|
+
});
|
|
12018
|
+
|
|
12019
|
+
/**
|
|
12020
|
+
* Suffix appended to a default profile's description in {@link oidcProviderProfileDetails}, so an
|
|
12021
|
+
* admin viewing the picker sees that leaving the field empty still grants that profile's scopes.
|
|
12022
|
+
*/ var OIDC_PROVIDER_PROFILE_DEFAULT_DESCRIPTION_SUFFIX = 'Applied by default when no profiles are assigned.';
|
|
12023
|
+
// MARK: Utility
|
|
12024
|
+
/**
|
|
12025
|
+
* Filters the provider-profile registry to the profiles matching the given assigned keys.
|
|
12026
|
+
*
|
|
12027
|
+
* @param profiles - The full provider-profile registry.
|
|
12028
|
+
* @param keys - The profile keys assigned to a client (e.g. `OidcEntry` `dbx_provider_profiles`).
|
|
12029
|
+
* @returns The registry profiles whose key is in `keys`.
|
|
12030
|
+
*/ function oidcProviderProfilesForKeys(profiles, keys) {
|
|
12031
|
+
var keySet = new Set(keys !== null && keys !== void 0 ? keys : []);
|
|
12032
|
+
return profiles.filter(function(profile) {
|
|
12033
|
+
return keySet.has(profile.key);
|
|
12034
|
+
});
|
|
12035
|
+
}
|
|
12036
|
+
/**
|
|
12037
|
+
* Filters the provider-profile registry to the profiles marked {@link OidcProviderProfile.isDefault}.
|
|
12038
|
+
*
|
|
12039
|
+
* @param profiles - The full provider-profile registry.
|
|
12040
|
+
* @returns The registry profiles that apply to a client with no assigned profiles.
|
|
12041
|
+
*/ function defaultOidcProviderProfiles(profiles) {
|
|
12042
|
+
return profiles.filter(function(profile) {
|
|
12043
|
+
return profile.isDefault === true;
|
|
12044
|
+
});
|
|
12045
|
+
}
|
|
12046
|
+
/**
|
|
12047
|
+
* Resolves the profiles that apply to a client: its assigned profiles, or — when it has NO profiles
|
|
12048
|
+
* assigned — the registry's default profiles.
|
|
12049
|
+
*
|
|
12050
|
+
* The fallback is exclusive: a client with any assigned key resolves to exactly
|
|
12051
|
+
* {@link oidcProviderProfilesForKeys}, so a non-default assignment never additionally confers the
|
|
12052
|
+
* default profiles' scopes. A registry declaring no default behaves identically to
|
|
12053
|
+
* {@link oidcProviderProfilesForKeys}.
|
|
12054
|
+
*
|
|
12055
|
+
* The fallback keys off the assigned key list being empty/absent rather than off the resolved set
|
|
12056
|
+
* being empty, so a client whose assigned profile was later removed from the registry resolves to no
|
|
12057
|
+
* profiles (fail-closed) rather than silently picking up the default.
|
|
12058
|
+
*
|
|
12059
|
+
* @param profiles - The full provider-profile registry.
|
|
12060
|
+
* @param keys - The profile keys assigned to the client (its `dbx_provider_profiles`).
|
|
12061
|
+
* @returns The client's assigned profiles, or the default profiles when none are assigned.
|
|
12062
|
+
*/ function oidcProviderProfilesForClient(profiles, keys) {
|
|
12063
|
+
return (keys === null || keys === void 0 ? void 0 : keys.length) ? oidcProviderProfilesForKeys(profiles, keys) : defaultOidcProviderProfiles(profiles);
|
|
12064
|
+
}
|
|
12065
|
+
/**
|
|
12066
|
+
* Collects every scope referenced by the given profiles.
|
|
12067
|
+
*
|
|
12068
|
+
* Passed the full registry, this is the set of "profile-gated" scopes — scopes a client may only
|
|
12069
|
+
* obtain via a profile. Passed a client's assigned profiles, this is the set of scopes those
|
|
12070
|
+
* profiles unlock for that client.
|
|
12071
|
+
*
|
|
12072
|
+
* Note a gated scope is not necessarily unavailable to an unassigned client: a scope unlocked by a
|
|
12073
|
+
* default profile is gated yet reachable by every client. Use
|
|
12074
|
+
* {@link assignmentOnlyScopesForOidcProviderProfiles} for the "requires an explicit assignment"
|
|
12075
|
+
* subset (e.g. to exclude scopes from a general picker or from advertised scope metadata).
|
|
12076
|
+
*
|
|
12077
|
+
* @param profiles - The profiles to collect scopes from.
|
|
12078
|
+
* @returns The union of every profile's scopes.
|
|
12079
|
+
*/ function scopesForOidcProviderProfiles(profiles) {
|
|
12080
|
+
var result = new Set();
|
|
12081
|
+
profiles.forEach(function(profile) {
|
|
12082
|
+
return profile.scopes.forEach(function(scopeConfig) {
|
|
12083
|
+
return result.add(scopeConfig.scope);
|
|
12084
|
+
});
|
|
12085
|
+
});
|
|
12086
|
+
return result;
|
|
12087
|
+
}
|
|
12088
|
+
/**
|
|
12089
|
+
* Collects the scopes marked `require: 'required'` across the given profiles.
|
|
12090
|
+
*
|
|
12091
|
+
* @param profiles - The profiles to collect required scopes from (typically a client's assigned profiles).
|
|
12092
|
+
* @returns The union of every profile's `required` scopes.
|
|
12093
|
+
*/ function requiredScopesForOidcProviderProfiles(profiles) {
|
|
12094
|
+
var result = new Set();
|
|
12095
|
+
profiles.forEach(function(profile) {
|
|
12096
|
+
return profile.scopes.forEach(function(scopeConfig) {
|
|
12097
|
+
if (scopeConfig.require === 'required') {
|
|
12098
|
+
result.add(scopeConfig.scope);
|
|
12099
|
+
}
|
|
12100
|
+
});
|
|
12101
|
+
});
|
|
12102
|
+
return result;
|
|
12103
|
+
}
|
|
12104
|
+
/**
|
|
12105
|
+
* Collects the scopes unlocked by the registry's default profiles — the scopes every client can
|
|
12106
|
+
* obtain, including one with no profiles assigned.
|
|
12107
|
+
*
|
|
12108
|
+
* @param profiles - The full provider-profile registry.
|
|
12109
|
+
* @returns The union of every default profile's scopes. Empty when no profile is marked default.
|
|
12110
|
+
*/ function defaultUnlockedScopesForOidcProviderProfiles(profiles) {
|
|
12111
|
+
return scopesForOidcProviderProfiles(defaultOidcProviderProfiles(profiles));
|
|
12112
|
+
}
|
|
12113
|
+
/**
|
|
12114
|
+
* Collects the gated scopes that are NOT unlocked by default — the scopes a client can only obtain
|
|
12115
|
+
* via an explicit profile assignment.
|
|
12116
|
+
*
|
|
12117
|
+
* This is the set to exclude from a general scope picker or from advertised scope metadata (e.g. an
|
|
12118
|
+
* MCP protected-resource document's `scopes_supported`). Prefer it over
|
|
12119
|
+
* {@link scopesForOidcProviderProfiles} for that job: the full gated set would wrongly drop a
|
|
12120
|
+
* default-unlocked scope that every client can in fact obtain. With no default declared the two are
|
|
12121
|
+
* identical.
|
|
12122
|
+
*
|
|
12123
|
+
* @param profiles - The full provider-profile registry.
|
|
12124
|
+
* @returns Every profile-gated scope minus the default-unlocked ones.
|
|
12125
|
+
*/ function assignmentOnlyScopesForOidcProviderProfiles(profiles) {
|
|
12126
|
+
var defaultUnlockedScopes = defaultUnlockedScopesForOidcProviderProfiles(profiles);
|
|
12127
|
+
var result = new Set();
|
|
12128
|
+
scopesForOidcProviderProfiles(profiles).forEach(function(scope) {
|
|
12129
|
+
if (!defaultUnlockedScopes.has(scope)) {
|
|
12130
|
+
result.add(scope);
|
|
12131
|
+
}
|
|
12132
|
+
});
|
|
12133
|
+
return result;
|
|
12134
|
+
}
|
|
12135
|
+
/**
|
|
12136
|
+
* Collects the scopes of every profile marked {@link OidcProviderProfile.adminOnly}.
|
|
12137
|
+
*
|
|
12138
|
+
* Unioned with `OidcProviderConfig.adminOnlyScopes` by the consent admin-only gate: a consent
|
|
12139
|
+
* requesting one of these scopes is hard-rejected with `access_denied` when the resolving user is
|
|
12140
|
+
* not an admin.
|
|
12141
|
+
*
|
|
12142
|
+
* @param profiles - The full provider-profile registry.
|
|
12143
|
+
* @returns The union of every admin-only profile's scopes. Empty when no profile is marked admin-only.
|
|
12144
|
+
*/ function adminOnlyScopesForOidcProviderProfiles(profiles) {
|
|
12145
|
+
return scopesForOidcProviderProfiles(profiles.filter(function(profile) {
|
|
12146
|
+
return profile.adminOnly === true;
|
|
12147
|
+
}));
|
|
12148
|
+
}
|
|
12149
|
+
/**
|
|
12150
|
+
* Builds picker entries for the given provider profiles, suitable for an admin profile-selection field.
|
|
12151
|
+
*
|
|
12152
|
+
* A default profile's description carries {@link OIDC_PROVIDER_PROFILE_DEFAULT_DESCRIPTION_SUFFIX} so
|
|
12153
|
+
* an admin isn't surprised that an empty selection still grants scopes. Default profiles are
|
|
12154
|
+
* deliberately not pre-selected — persisting the default as an explicit assignment would opt the
|
|
12155
|
+
* client out of the fallback, so it would stop tracking the registry if the default later changed.
|
|
12156
|
+
*
|
|
12157
|
+
* @param profiles - The provider-profile registry.
|
|
12158
|
+
* @returns One {@link OidcProviderProfileDetails} per profile.
|
|
12159
|
+
*/ function oidcProviderProfileDetails(profiles) {
|
|
12160
|
+
return profiles.map(function(profile) {
|
|
12161
|
+
return {
|
|
12162
|
+
value: profile.key,
|
|
12163
|
+
label: profile.label,
|
|
12164
|
+
description: profile.isDefault ? [
|
|
12165
|
+
profile.description,
|
|
12166
|
+
OIDC_PROVIDER_PROFILE_DEFAULT_DESCRIPTION_SUFFIX
|
|
12167
|
+
].filter(Boolean).join(' ') : profile.description
|
|
12168
|
+
};
|
|
12169
|
+
});
|
|
12170
|
+
}
|
|
12171
|
+
|
|
11907
12172
|
/**
|
|
11908
12173
|
* Prefix shared by every callModel OIDC scope (e.g., `model.create`).
|
|
11909
12174
|
*
|
|
@@ -12074,6 +12339,100 @@ var OFFLINE_ACCESS_OIDC_SCOPE_DETAILS = {
|
|
|
12074
12339
|
value: SERVICE_TOKEN_OIDC_SCOPE,
|
|
12075
12340
|
description: 'Admin-only: issue a long-lived, non-rotating token for server/API use'
|
|
12076
12341
|
};
|
|
12342
|
+
/**
|
|
12343
|
+
* Parses a raw OIDC `scope` claim (a space-delimited string) into the granted scope set consumed by
|
|
12344
|
+
* {@link oidcScopeTermSatisfied} / {@link oidcScopeTermsSatisfied}.
|
|
12345
|
+
*
|
|
12346
|
+
* The single source of truth for scope-string parsing, shared by the server-side `getOidcScopesFromRequest`
|
|
12347
|
+
* (which reads `request.auth.token.scope`) and the model-api-layer enforcement (which reads the OIDC-validated
|
|
12348
|
+
* token off the request auth). Returns `undefined` when the claim is not a string — i.e. the caller is not
|
|
12349
|
+
* OIDC-authenticated (a regular Firebase ID token carries no `scope` claim) — so callers can distinguish
|
|
12350
|
+
* "no OIDC scopes to enforce against" (bypass) from "OIDC caller that was granted zero scopes" (empty set).
|
|
12351
|
+
*
|
|
12352
|
+
* @param scope - The raw `scope` claim value, typically a space-delimited string.
|
|
12353
|
+
* @returns A `Set` of the granted scopes, or `undefined` when `scope` is not a string.
|
|
12354
|
+
*/ function oidcScopesFromScopeClaim(scope) {
|
|
12355
|
+
var result = typeof scope === 'string' ? new Set(scope.split(' ').filter(function(value) {
|
|
12356
|
+
return value.length > 0;
|
|
12357
|
+
})) : undefined;
|
|
12358
|
+
return result;
|
|
12359
|
+
}
|
|
12360
|
+
/**
|
|
12361
|
+
* Returns whether a single {@link OidcScopeTerm} is satisfied by the granted scope set.
|
|
12362
|
+
*
|
|
12363
|
+
* A string term requires that exact scope; an array term is an OR-group satisfied by ANY member (an
|
|
12364
|
+
* empty group is vacuously satisfied — no requirement).
|
|
12365
|
+
*
|
|
12366
|
+
* @param term - The scope term to test.
|
|
12367
|
+
* @param grantedScopes - The scopes the caller holds.
|
|
12368
|
+
* @returns `true` when the caller satisfies the term.
|
|
12369
|
+
*/ function oidcScopeTermSatisfied(term, grantedScopes) {
|
|
12370
|
+
return typeof term === 'string' ? grantedScopes.has(term) : term.length === 0 || term.some(function(scope) {
|
|
12371
|
+
return grantedScopes.has(scope);
|
|
12372
|
+
});
|
|
12373
|
+
}
|
|
12374
|
+
/**
|
|
12375
|
+
* Returns whether EVERY {@link OidcScopeTerm} is satisfied by the granted scope set (AND-of-ORs).
|
|
12376
|
+
*
|
|
12377
|
+
* The single source of truth shared by the server-side callModel scope enforcement
|
|
12378
|
+
* (`assertModelApiOidcScope`) and the MCP tool-visibility filter, so enforcement and tool-list
|
|
12379
|
+
* visibility never drift. An empty term list is vacuously satisfied.
|
|
12380
|
+
*
|
|
12381
|
+
* @param terms - The AND-ed scope terms; each is a single scope or an OR-group.
|
|
12382
|
+
* @param grantedScopes - The scopes the caller holds.
|
|
12383
|
+
* @returns `true` when the caller satisfies every term.
|
|
12384
|
+
*/ function oidcScopeTermsSatisfied(terms, grantedScopes) {
|
|
12385
|
+
return terms.every(function(term) {
|
|
12386
|
+
return oidcScopeTermSatisfied(term, grantedScopes);
|
|
12387
|
+
});
|
|
12388
|
+
}
|
|
12389
|
+
/**
|
|
12390
|
+
* Resolves the effective {@link OidcScopeTerm} an {@link OidcModelScopeRequirement} imposes for a
|
|
12391
|
+
* given call verb.
|
|
12392
|
+
*
|
|
12393
|
+
* A single-term requirement applies to every verb; a verb-keyed requirement returns the matching
|
|
12394
|
+
* verb entry, falling back to its `default`. Returns `undefined` when the requirement imposes no
|
|
12395
|
+
* term for the verb.
|
|
12396
|
+
*
|
|
12397
|
+
* @param requirement - The per-model requirement.
|
|
12398
|
+
* @param call - The call verb being resolved.
|
|
12399
|
+
* @returns The effective term for the verb, or `undefined`.
|
|
12400
|
+
*/ function resolveOidcModelScopeRequirement(requirement, call) {
|
|
12401
|
+
var _verbMap_call;
|
|
12402
|
+
var isTerm = typeof requirement === 'string' || Array.isArray(requirement);
|
|
12403
|
+
var verbMap = requirement;
|
|
12404
|
+
return isTerm ? requirement : (_verbMap_call = verbMap[call]) !== null && _verbMap_call !== void 0 ? _verbMap_call : verbMap.default;
|
|
12405
|
+
}
|
|
12406
|
+
/**
|
|
12407
|
+
* Resolves the full AND-ed list of {@link OidcScopeTerm}s enforced for one callModel op — the single
|
|
12408
|
+
* composition rule shared by the server model-api scope gate and the MCP visibility filter (no drift).
|
|
12409
|
+
*
|
|
12410
|
+
* The list is the per-verb scope AND the effective GROUP term, where the group term is resolved by
|
|
12411
|
+
* precedence: per-function `requiredScope` (finest) > model-level requirement (verb-resolved; covers
|
|
12412
|
+
* plain reads) > configured default. Nullish and empty-OR-group terms are dropped, so an op with no
|
|
12413
|
+
* requirement yields an empty list (no scope gate — the caller can skip reading scopes). With no
|
|
12414
|
+
* config supplied and no per-function scope, the list is exactly `[perVerbScope]` (or empty), matching
|
|
12415
|
+
* the pre-grouping behavior.
|
|
12416
|
+
*
|
|
12417
|
+
* @param input - The per-verb scope, per-function scope, model requirement, verb, and default.
|
|
12418
|
+
* @returns The AND-ed scope terms to enforce (possibly empty).
|
|
12419
|
+
*/ function resolveEffectiveOidcScopeTerms(input) {
|
|
12420
|
+
var _ref;
|
|
12421
|
+
var perVerbScope = input.perVerbScope, requiredScope = input.requiredScope, modelRequirement = input.modelRequirement, call = input.call, defaultRequiredScope = input.defaultRequiredScope;
|
|
12422
|
+
var modelTerm = modelRequirement == null ? undefined : resolveOidcModelScopeRequirement(modelRequirement, call);
|
|
12423
|
+
var effectiveGroupTerm = (_ref = requiredScope !== null && requiredScope !== void 0 ? requiredScope : modelTerm) !== null && _ref !== void 0 ? _ref : defaultRequiredScope;
|
|
12424
|
+
var result = [];
|
|
12425
|
+
for(var _i = 0, _iter = [
|
|
12426
|
+
perVerbScope,
|
|
12427
|
+
effectiveGroupTerm
|
|
12428
|
+
]; _i < _iter.length; _i++){
|
|
12429
|
+
var term = _iter[_i];
|
|
12430
|
+
if (term != null && !(Array.isArray(term) && term.length === 0)) {
|
|
12431
|
+
result.push(term);
|
|
12432
|
+
}
|
|
12433
|
+
}
|
|
12434
|
+
return result;
|
|
12435
|
+
}
|
|
12077
12436
|
|
|
12078
12437
|
function _array_like_to_array$6(arr, len) {
|
|
12079
12438
|
if (len == null || len > arr.length) len = arr.length;
|
|
@@ -18858,180 +19217,6 @@ var OIDC_MODEL_CRUD_FUNCTIONS_CONFIG = {
|
|
|
18858
19217
|
* ```
|
|
18859
19218
|
*/ var oidcModelFunctionMap = callModelFirebaseFunctionMapFactory(OIDC_FUNCTION_TYPE_CONFIG_MAP, OIDC_MODEL_CRUD_FUNCTIONS_CONFIG);
|
|
18860
19219
|
|
|
18861
|
-
/**
|
|
18862
|
-
* The `client_secret_basic` confidential-client auth method (RFC 6749 §2.3.1, the
|
|
18863
|
-
* OAuth 2.0 default): the client sends its `client_id` and `client_secret` in the
|
|
18864
|
-
* `Authorization: Basic` header on token-endpoint requests. Standard pick for
|
|
18865
|
-
* server-side confidential clients.
|
|
18866
|
-
*
|
|
18867
|
-
* @example
|
|
18868
|
-
* ```ts
|
|
18869
|
-
* await oidcClientService.createClient({
|
|
18870
|
-
* token_endpoint_auth_method: CLIENT_SECRET_BASIC_TOKEN_ENDPOINT_AUTH_METHOD,
|
|
18871
|
-
* // ...
|
|
18872
|
-
* });
|
|
18873
|
-
* ```
|
|
18874
|
-
*/ var CLIENT_SECRET_BASIC_TOKEN_ENDPOINT_AUTH_METHOD = 'client_secret_basic';
|
|
18875
|
-
/**
|
|
18876
|
-
* The `client_secret_post` confidential-client auth method (RFC 6749 §2.3.1, the
|
|
18877
|
-
* form-body variant): the client sends `client_id` and `client_secret` as form-encoded
|
|
18878
|
-
* parameters in the token-endpoint request body. Equivalent in security to
|
|
18879
|
-
* {@link CLIENT_SECRET_BASIC_TOKEN_ENDPOINT_AUTH_METHOD}; pick it for clients that
|
|
18880
|
-
* cannot set the `Authorization` header (some older HTTP stacks).
|
|
18881
|
-
*
|
|
18882
|
-
* @example
|
|
18883
|
-
* ```ts
|
|
18884
|
-
* await oidcClientService.createClient({
|
|
18885
|
-
* token_endpoint_auth_method: CLIENT_SECRET_POST_TOKEN_ENDPOINT_AUTH_METHOD,
|
|
18886
|
-
* // ...
|
|
18887
|
-
* });
|
|
18888
|
-
* ```
|
|
18889
|
-
*/ var CLIENT_SECRET_POST_TOKEN_ENDPOINT_AUTH_METHOD = 'client_secret_post';
|
|
18890
|
-
/**
|
|
18891
|
-
* The `client_secret_jwt` confidential-client auth method (OIDC Core §9): the client
|
|
18892
|
-
* signs a JWT client assertion using its `client_secret` as the HMAC key (HS256/HS384/HS512)
|
|
18893
|
-
* and sends it as `client_assertion` on token-endpoint requests. The secret never goes on
|
|
18894
|
-
* the wire — only the signed assertion — which is the upgrade over the plain
|
|
18895
|
-
* `client_secret_*` methods, without requiring asymmetric keys like
|
|
18896
|
-
* {@link PRIVATE_KEY_JWT_TOKEN_ENDPOINT_AUTH_METHOD}.
|
|
18897
|
-
*
|
|
18898
|
-
* @example
|
|
18899
|
-
* ```ts
|
|
18900
|
-
* await oidcClientService.createClient({
|
|
18901
|
-
* token_endpoint_auth_method: CLIENT_SECRET_JWT_TOKEN_ENDPOINT_AUTH_METHOD,
|
|
18902
|
-
* // ...
|
|
18903
|
-
* });
|
|
18904
|
-
* ```
|
|
18905
|
-
*/ var CLIENT_SECRET_JWT_TOKEN_ENDPOINT_AUTH_METHOD = 'client_secret_jwt';
|
|
18906
|
-
/**
|
|
18907
|
-
* The `private_key_jwt` confidential-client auth method (OIDC Core §9): the client signs
|
|
18908
|
-
* a JWT client assertion with its private key (RS256/ES256/PS256) and sends it as
|
|
18909
|
-
* `client_assertion`; the server verifies via the client's published `jwks` / `jwks_uri`.
|
|
18910
|
-
* Strongest of the confidential-client methods — no shared secret is ever held by the
|
|
18911
|
-
* server — and the canonical pick for high-trust server-to-server integrations.
|
|
18912
|
-
*
|
|
18913
|
-
* @example
|
|
18914
|
-
* ```ts
|
|
18915
|
-
* await oidcClientService.createClient({
|
|
18916
|
-
* token_endpoint_auth_method: PRIVATE_KEY_JWT_TOKEN_ENDPOINT_AUTH_METHOD,
|
|
18917
|
-
* jwks: { keys: [publicJwk] },
|
|
18918
|
-
* // ...
|
|
18919
|
-
* });
|
|
18920
|
-
* ```
|
|
18921
|
-
*/ var PRIVATE_KEY_JWT_TOKEN_ENDPOINT_AUTH_METHOD = 'private_key_jwt';
|
|
18922
|
-
/**
|
|
18923
|
-
* The public-client auth method (`'none'`): no client secret, PKCE-only. The client
|
|
18924
|
-
* authenticates the `authorization_code` flow with PKCE (RFC 7636) alone — there is no
|
|
18925
|
-
* shared secret and no client assertion. Canonical pick for clients that cannot keep a
|
|
18926
|
-
* secret (native apps, SPAs, CLIs) and what the MCP / Claude connector ecosystem
|
|
18927
|
-
* (claude.ai connector, Claude Code CLI, mcp-inspector via DCR) registers as.
|
|
18928
|
-
*
|
|
18929
|
-
* Mirrors {@link PRIVATE_KEY_JWT_TOKEN_ENDPOINT_AUTH_METHOD}. `oidc-provider` still
|
|
18930
|
-
* enforces PKCE on the `authorization_code` flow for every client regardless of auth
|
|
18931
|
-
* method, so `'none'` simply unlocks the secret-less variant rather than disabling any
|
|
18932
|
-
* client authentication.
|
|
18933
|
-
*
|
|
18934
|
-
* @example
|
|
18935
|
-
* ```ts
|
|
18936
|
-
* await oidcClientService.createClient({
|
|
18937
|
-
* token_endpoint_auth_method: PUBLIC_PKCE_TOKEN_ENDPOINT_AUTH_METHOD,
|
|
18938
|
-
* // no client_secret — public PKCE client
|
|
18939
|
-
* // ...
|
|
18940
|
-
* });
|
|
18941
|
-
* ```
|
|
18942
|
-
*/ var PUBLIC_PKCE_TOKEN_ENDPOINT_AUTH_METHOD = 'none';
|
|
18943
|
-
/**
|
|
18944
|
-
* All available token endpoint auth method options with display labels.
|
|
18945
|
-
*/ var ALL_OIDC_TOKEN_ENDPOINT_AUTH_METHOD_OPTIONS = [
|
|
18946
|
-
{
|
|
18947
|
-
label: 'Client Secret Basic',
|
|
18948
|
-
value: CLIENT_SECRET_BASIC_TOKEN_ENDPOINT_AUTH_METHOD
|
|
18949
|
-
},
|
|
18950
|
-
{
|
|
18951
|
-
label: 'Client Secret Post',
|
|
18952
|
-
value: CLIENT_SECRET_POST_TOKEN_ENDPOINT_AUTH_METHOD
|
|
18953
|
-
},
|
|
18954
|
-
{
|
|
18955
|
-
label: 'Client Secret JWT',
|
|
18956
|
-
value: CLIENT_SECRET_JWT_TOKEN_ENDPOINT_AUTH_METHOD
|
|
18957
|
-
},
|
|
18958
|
-
{
|
|
18959
|
-
label: 'Private Key JWT',
|
|
18960
|
-
value: PRIVATE_KEY_JWT_TOKEN_ENDPOINT_AUTH_METHOD
|
|
18961
|
-
},
|
|
18962
|
-
{
|
|
18963
|
-
label: 'None (Public PKCE)',
|
|
18964
|
-
value: PUBLIC_PKCE_TOKEN_ENDPOINT_AUTH_METHOD
|
|
18965
|
-
}
|
|
18966
|
-
];
|
|
18967
|
-
/**
|
|
18968
|
-
* All available OIDC token endpoint auth methods for the demo app, suitable for use in auth method picker fields.
|
|
18969
|
-
*/ var ALL_OIDC_TOKEN_ENDPOINT_AUTH_METHODS = ALL_OIDC_TOKEN_ENDPOINT_AUTH_METHOD_OPTIONS.map(function(x) {
|
|
18970
|
-
return x.value;
|
|
18971
|
-
});
|
|
18972
|
-
|
|
18973
|
-
// MARK: Utility
|
|
18974
|
-
/**
|
|
18975
|
-
* Filters the provider-profile registry to the profiles matching the given assigned keys.
|
|
18976
|
-
*
|
|
18977
|
-
* @param profiles - The full provider-profile registry.
|
|
18978
|
-
* @param keys - The profile keys assigned to a client (e.g. `OidcEntry` `dbx_provider_profiles`).
|
|
18979
|
-
* @returns The registry profiles whose key is in `keys`.
|
|
18980
|
-
*/ function oidcProviderProfilesForKeys(profiles, keys) {
|
|
18981
|
-
var keySet = new Set(keys !== null && keys !== void 0 ? keys : []);
|
|
18982
|
-
return profiles.filter(function(profile) {
|
|
18983
|
-
return keySet.has(profile.key);
|
|
18984
|
-
});
|
|
18985
|
-
}
|
|
18986
|
-
/**
|
|
18987
|
-
* Collects every scope referenced by the given profiles.
|
|
18988
|
-
*
|
|
18989
|
-
* Passed the full registry, this is the set of "profile-gated" scopes — scopes a client may only
|
|
18990
|
-
* obtain via a profile. Passed a client's assigned profiles, this is the set of scopes those
|
|
18991
|
-
* profiles unlock for that client.
|
|
18992
|
-
*
|
|
18993
|
-
* @param profiles - The profiles to collect scopes from.
|
|
18994
|
-
* @returns The union of every profile's scopes.
|
|
18995
|
-
*/ function scopesForOidcProviderProfiles(profiles) {
|
|
18996
|
-
var result = new Set();
|
|
18997
|
-
profiles.forEach(function(profile) {
|
|
18998
|
-
return profile.scopes.forEach(function(scopeConfig) {
|
|
18999
|
-
return result.add(scopeConfig.scope);
|
|
19000
|
-
});
|
|
19001
|
-
});
|
|
19002
|
-
return result;
|
|
19003
|
-
}
|
|
19004
|
-
/**
|
|
19005
|
-
* Collects the scopes marked `require: 'required'` across the given profiles.
|
|
19006
|
-
*
|
|
19007
|
-
* @param profiles - The profiles to collect required scopes from (typically a client's assigned profiles).
|
|
19008
|
-
* @returns The union of every profile's `required` scopes.
|
|
19009
|
-
*/ function requiredScopesForOidcProviderProfiles(profiles) {
|
|
19010
|
-
var result = new Set();
|
|
19011
|
-
profiles.forEach(function(profile) {
|
|
19012
|
-
return profile.scopes.forEach(function(scopeConfig) {
|
|
19013
|
-
if (scopeConfig.require === 'required') {
|
|
19014
|
-
result.add(scopeConfig.scope);
|
|
19015
|
-
}
|
|
19016
|
-
});
|
|
19017
|
-
});
|
|
19018
|
-
return result;
|
|
19019
|
-
}
|
|
19020
|
-
/**
|
|
19021
|
-
* Builds picker entries for the given provider profiles, suitable for an admin profile-selection field.
|
|
19022
|
-
*
|
|
19023
|
-
* @param profiles - The provider-profile registry.
|
|
19024
|
-
* @returns One {@link OidcProviderProfileDetails} per profile.
|
|
19025
|
-
*/ function oidcProviderProfileDetails(profiles) {
|
|
19026
|
-
return profiles.map(function(profile) {
|
|
19027
|
-
return {
|
|
19028
|
-
value: profile.key,
|
|
19029
|
-
label: profile.label,
|
|
19030
|
-
description: profile.description
|
|
19031
|
-
};
|
|
19032
|
-
});
|
|
19033
|
-
}
|
|
19034
|
-
|
|
19035
19220
|
/**
|
|
19036
19221
|
* Thrown if the target uploaded file does not exist.
|
|
19037
19222
|
*/ var UPLOADED_FILE_DOES_NOT_EXIST_ERROR_CODE = 'UPLOADED_FILE_DOES_NOT_EXIST';
|
|
@@ -21739,6 +21924,7 @@ exports.OFFLINE_ACCESS_OIDC_SCOPE_DETAILS = OFFLINE_ACCESS_OIDC_SCOPE_DETAILS;
|
|
|
21739
21924
|
exports.OIDC_ENTRY_CLIENT_TYPE = OIDC_ENTRY_CLIENT_TYPE;
|
|
21740
21925
|
exports.OIDC_FUNCTION_TYPE_CONFIG_MAP = OIDC_FUNCTION_TYPE_CONFIG_MAP;
|
|
21741
21926
|
exports.OIDC_MODEL_CRUD_FUNCTIONS_CONFIG = OIDC_MODEL_CRUD_FUNCTIONS_CONFIG;
|
|
21927
|
+
exports.OIDC_PROVIDER_PROFILE_DEFAULT_DESCRIPTION_SUFFIX = OIDC_PROVIDER_PROFILE_DEFAULT_DESCRIPTION_SUFFIX;
|
|
21742
21928
|
exports.OPENID_OIDC_SCOPE = OPENID_OIDC_SCOPE;
|
|
21743
21929
|
exports.OPENID_OIDC_SCOPE_DETAILS = OPENID_OIDC_SCOPE_DETAILS;
|
|
21744
21930
|
exports.OidcEntryDocument = OidcEntryDocument;
|
|
@@ -21802,6 +21988,7 @@ exports.abstractSubscribeOrUnsubscribeToNotificationBoxParamsType = abstractSubs
|
|
|
21802
21988
|
exports.abstractSubscribeToNotificationBoxParamsType = abstractSubscribeToNotificationBoxParamsType;
|
|
21803
21989
|
exports.addConstraintToBuilder = addConstraintToBuilder;
|
|
21804
21990
|
exports.addOrReplaceLimitInConstraints = addOrReplaceLimitInConstraints;
|
|
21991
|
+
exports.adminOnlyScopesForOidcProviderProfiles = adminOnlyScopesForOidcProviderProfiles;
|
|
21805
21992
|
exports.allChildDocumentsUnderParent = allChildDocumentsUnderParent;
|
|
21806
21993
|
exports.allChildDocumentsUnderParentPath = allChildDocumentsUnderParentPath;
|
|
21807
21994
|
exports.allChildDocumentsUnderRelativePath = allChildDocumentsUnderRelativePath;
|
|
@@ -21819,6 +22006,7 @@ exports.assignDateCellScheduleFunction = assignDateCellScheduleFunction;
|
|
|
21819
22006
|
exports.assignUnitedStatesAddressFunction = assignUnitedStatesAddressFunction;
|
|
21820
22007
|
exports.assignWebsiteFileLinkFunction = assignWebsiteFileLinkFunction;
|
|
21821
22008
|
exports.assignWebsiteLinkFunction = assignWebsiteLinkFunction;
|
|
22009
|
+
exports.assignmentOnlyScopesForOidcProviderProfiles = assignmentOnlyScopesForOidcProviderProfiles;
|
|
21822
22010
|
exports.buildFirebaseCollectionTypeModelTypeMap = buildFirebaseCollectionTypeModelTypeMap;
|
|
21823
22011
|
exports.calculateNsForNotificationUserNotificationBoxRecipientConfigs = calculateNsForNotificationUserNotificationBoxRecipientConfigs;
|
|
21824
22012
|
exports.calculateStorageFileGroupEmbeddedFileUpdate = calculateStorageFileGroupEmbeddedFileUpdate;
|
|
@@ -21863,7 +22051,9 @@ exports.createStorageFileSignedUploadUrlParamsType = createStorageFileSignedUplo
|
|
|
21863
22051
|
exports.dataFromDocumentSnapshots = dataFromDocumentSnapshots;
|
|
21864
22052
|
exports.dataFromSnapshotStream = dataFromSnapshotStream;
|
|
21865
22053
|
exports.decodeFirebaseAuthOobCode = decodeFirebaseAuthOobCode;
|
|
22054
|
+
exports.defaultOidcProviderProfiles = defaultOidcProviderProfiles;
|
|
21866
22055
|
exports.defaultPagedItemPageDataConverter = defaultPagedItemPageDataConverter;
|
|
22056
|
+
exports.defaultUnlockedScopesForOidcProviderProfiles = defaultUnlockedScopesForOidcProviderProfiles;
|
|
21867
22057
|
exports.delayCompletion = delayCompletion;
|
|
21868
22058
|
exports.deleteAllQueuedStorageFilesParamsType = deleteAllQueuedStorageFilesParamsType;
|
|
21869
22059
|
exports.deleteOidcClientParamsType = targetModelParamsType;
|
|
@@ -22222,7 +22412,11 @@ exports.oidcEntryIdentity = oidcEntryIdentity;
|
|
|
22222
22412
|
exports.oidcGrantEntriesByUidQuery = oidcGrantEntriesByUidQuery;
|
|
22223
22413
|
exports.oidcModelFunctionMap = oidcModelFunctionMap;
|
|
22224
22414
|
exports.oidcProviderProfileDetails = oidcProviderProfileDetails;
|
|
22415
|
+
exports.oidcProviderProfilesForClient = oidcProviderProfilesForClient;
|
|
22225
22416
|
exports.oidcProviderProfilesForKeys = oidcProviderProfilesForKeys;
|
|
22417
|
+
exports.oidcScopeTermSatisfied = oidcScopeTermSatisfied;
|
|
22418
|
+
exports.oidcScopeTermsSatisfied = oidcScopeTermsSatisfied;
|
|
22419
|
+
exports.oidcScopesFromScopeClaim = oidcScopesFromScopeClaim;
|
|
22226
22420
|
exports.onCallCreateModelParams = onCallCreateModelParams;
|
|
22227
22421
|
exports.onCallCreateModelResult = onCallCreateModelResult;
|
|
22228
22422
|
exports.onCallCreateModelResultWithDocs = onCallCreateModelResultWithDocs;
|
|
@@ -22260,6 +22454,8 @@ exports.regenerateAllFlaggedStorageFileGroupsContentParamsType = regenerateAllFl
|
|
|
22260
22454
|
exports.regenerateStorageFileGroupContentParamsType = regenerateStorageFileGroupContentParamsType;
|
|
22261
22455
|
exports.replaceConstraints = replaceConstraints;
|
|
22262
22456
|
exports.requiredScopesForOidcProviderProfiles = requiredScopesForOidcProviderProfiles;
|
|
22457
|
+
exports.resolveEffectiveOidcScopeTerms = resolveEffectiveOidcScopeTerms;
|
|
22458
|
+
exports.resolveOidcModelScopeRequirement = resolveOidcModelScopeRequirement;
|
|
22263
22459
|
exports.resyncAllNotificationUserParamsType = resyncAllNotificationUserParamsType;
|
|
22264
22460
|
exports.resyncNotificationUserParamsType = targetModelParamsType;
|
|
22265
22461
|
exports.rotateOidcClientSecretParamsType = targetModelParamsType;
|