@dereekb/firebase 13.12.4 → 13.12.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/firebase",
3
- "version": "13.12.4",
3
+ "version": "13.12.6",
4
4
  "sideEffects": false,
5
5
  "exports": {
6
6
  "./test": {
@@ -24,10 +24,10 @@
24
24
  }
25
25
  },
26
26
  "peerDependencies": {
27
- "@dereekb/date": "13.12.4",
28
- "@dereekb/model": "13.12.4",
29
- "@dereekb/rxjs": "13.12.4",
30
- "@dereekb/util": "13.12.4",
27
+ "@dereekb/date": "13.12.6",
28
+ "@dereekb/model": "13.12.6",
29
+ "@dereekb/rxjs": "13.12.6",
30
+ "@dereekb/util": "13.12.6",
31
31
  "@firebase/rules-unit-testing": "5.0.0",
32
32
  "@marcbachmann/cel-js": "^7.6.1",
33
33
  "@typescript-eslint/parser": "8.59.3",
@@ -9,6 +9,12 @@ import { type FirebaseError } from 'firebase/app';
9
9
  * @param error - The value to check.
10
10
  * @returns `true` if the input matches the shape of a client-side `FirebaseError`
11
11
  *
12
+ * @dbxUtil
13
+ * @dbxUtilCategory firebase-error
14
+ * @dbxUtilKind function
15
+ * @dbxUtilTags firebase, client, error, type-guard, callable
16
+ * @dbxUtilRelated convert-https-callable-error-to-readable-error, firebase-server-error
17
+ *
12
18
  * @example
13
19
  * ```ts
14
20
  * try {
@@ -10,6 +10,12 @@ import { type FirebaseError } from 'firebase/app';
10
10
  * Typically created via {@link convertHttpsCallableErrorToReadableError} when an `HttpsCallable`
11
11
  * invocation fails with a server-side error that includes structured details.
12
12
  *
13
+ * @dbxUtil
14
+ * @dbxUtilCategory firebase-error
15
+ * @dbxUtilKind class
16
+ * @dbxUtilTags firebase, https, callable, error, server-error, client, response, details
17
+ * @dbxUtilRelated convert-https-callable-error-to-readable-error, is-client-firebase-error
18
+ *
13
19
  * @example
14
20
  * ```ts
15
21
  * try {
@@ -71,5 +71,11 @@ export declare function directDataHttpsCallable<I, O, C extends HttpsCallable<I,
71
71
  *
72
72
  * @param error - The caught error from an `HttpsCallable` invocation.
73
73
  * @returns A {@link FirebaseServerError} if the error has structured details, or a generic readable error otherwise.
74
+ *
75
+ * @dbxUtil
76
+ * @dbxUtilCategory firebase-error
77
+ * @dbxUtilKind function
78
+ * @dbxUtilTags firebase, https, callable, error, decode, convert, readable, client, server
79
+ * @dbxUtilRelated firebase-server-error, is-client-firebase-error, firebase-auth-error-to-readable-error
74
80
  */
75
81
  export declare function convertHttpsCallableErrorToReadableError(error: unknown): unknown;
@@ -96,6 +96,65 @@ export type FirebaseAuthOobCode = string;
96
96
  * Password used for completing setup or resetting a user.
97
97
  */
98
98
  export type FirebaseAuthSetupPassword = PasswordString;
99
+ /**
100
+ * Delimiter used when encoding a {@link FirebaseAuthOobCodeDataPair} into a {@link FirebaseAuthOobCode}.
101
+ *
102
+ * The encoded form is `${code}-${uid}` and splitting happens on the first delimiter occurrence,
103
+ * so this only requires that the generated code/password not contain `-`. The uid is unrestricted
104
+ * and may itself contain `-`.
105
+ *
106
+ * @dbxUtil
107
+ * @dbxUtilCategory firebase-auth
108
+ * @dbxUtilTags firebase, auth, oob, code, delimiter, constant
109
+ * @dbxUtilRelated encode-firebase-auth-oob-code, decode-firebase-auth-oob-code
110
+ */
111
+ export declare const FIREBASE_AUTH_OOB_CODE_DATA_PAIR_DELIMITER = "-";
112
+ /**
113
+ * Data pair embedded in a {@link FirebaseAuthOobCode} for out-of-band auth flows.
114
+ *
115
+ * Pairs the Firebase user uid with the one-time setup/reset code so the server can
116
+ * identify the user and validate the code in a single round-trip without a
117
+ * separate lookup step.
118
+ */
119
+ export interface FirebaseAuthOobCodeDataPair {
120
+ readonly uid: FirebaseAuthUserId;
121
+ readonly code: FirebaseAuthSetupPassword;
122
+ }
123
+ /**
124
+ * Encodes a {@link FirebaseAuthOobCodeDataPair} into a URL-safe {@link FirebaseAuthOobCode}.
125
+ *
126
+ * The encoded form is `${code}-${uid}` — code first so that splitting on the first delimiter
127
+ * still works even when the uid itself contains `-` (Firebase uids occasionally do).
128
+ *
129
+ * @dbxUtil
130
+ * @dbxUtilCategory firebase-auth
131
+ * @dbxUtilTags firebase, auth, oob, code, encode, uid, password, reset, setup, serialize
132
+ * @dbxUtilRelated decode-firebase-auth-oob-code, firebase-auth-oob-code-data-pair-delimiter
133
+ *
134
+ * @example
135
+ * ```ts
136
+ * encodeFirebaseAuthOobCode({ uid: 'abc-123', code: 'xyz789' }); // 'xyz789-abc-123'
137
+ * ```
138
+ */
139
+ export declare function encodeFirebaseAuthOobCode(pair: FirebaseAuthOobCodeDataPair): FirebaseAuthOobCode;
140
+ /**
141
+ * Decodes a {@link FirebaseAuthOobCode} back into its {@link FirebaseAuthOobCodeDataPair}.
142
+ *
143
+ * Splits on the first `-` so uids containing additional `-` characters survive the round-trip
144
+ * intact. Returns null when the input is missing the delimiter or has empty parts.
145
+ *
146
+ * @dbxUtil
147
+ * @dbxUtilCategory firebase-auth
148
+ * @dbxUtilTags firebase, auth, oob, code, decode, parse, uid, password, reset, setup, deserialize
149
+ * @dbxUtilRelated encode-firebase-auth-oob-code, firebase-auth-oob-code-data-pair-delimiter
150
+ *
151
+ * @example
152
+ * ```ts
153
+ * decodeFirebaseAuthOobCode('xyz789-abc-123'); // { uid: 'abc-123', code: 'xyz789' }
154
+ * decodeFirebaseAuthOobCode('invalid'); // null
155
+ * ```
156
+ */
157
+ export declare function decodeFirebaseAuthOobCode(oobCode: FirebaseAuthOobCode): Maybe<FirebaseAuthOobCodeDataPair>;
99
158
  export declare const FIREBASE_SERVER_AUTH_CLAIMS_SETUP_PASSWORD_KEY = "setupPassword";
100
159
  export declare const FIREBASE_SERVER_AUTH_CLAIMS_SETUP_LAST_COM_DATE_KEY = "setupCommunicationAt";
101
160
  /**
@@ -64,6 +64,12 @@ export declare const FIREBASE_AUTH_QUOTA_EXCEEDED_ERROR = "auth/quota-exceeded";
64
64
  * @param inputError - The Firebase Auth error to convert.
65
65
  * @returns A {@link ReadableError} with a human-readable message suitable for display.
66
66
  *
67
+ * @dbxUtil
68
+ * @dbxUtilCategory firebase-auth
69
+ * @dbxUtilKind function
70
+ * @dbxUtilTags firebase, auth, error, readable, convert, decode, message, login, signin
71
+ * @dbxUtilRelated convert-https-callable-error-to-readable-error, firebase-server-error
72
+ *
67
73
  * @example
68
74
  * ```ts
69
75
  * try {
@@ -44,27 +44,114 @@ export type OidcScopeDetails<T extends OidcScope = OidcScope> = LabeledValueWith
44
44
  */
45
45
  export type OidcRedirectUri = string;
46
46
  /**
47
- * Supported values for `token_endpoint_auth_method` when creating an OIDC client.
47
+ * The `client_secret_basic` confidential-client auth method (RFC 6749 §2.3.1, the
48
+ * OAuth 2.0 default): the client sends its `client_id` and `client_secret` in the
49
+ * `Authorization: Basic` header on token-endpoint requests. Standard pick for
50
+ * server-side confidential clients.
48
51
  *
49
- * The four `client_secret_*` / `private_key_jwt` methods are for confidential clients.
52
+ * @example
53
+ * ```ts
54
+ * await oidcClientService.createClient({
55
+ * token_endpoint_auth_method: CLIENT_SECRET_BASIC_TOKEN_ENDPOINT_AUTH_METHOD,
56
+ * // ...
57
+ * });
58
+ * ```
59
+ */
60
+ export declare const CLIENT_SECRET_BASIC_TOKEN_ENDPOINT_AUTH_METHOD = "client_secret_basic";
61
+ /**
62
+ * The `client_secret_post` confidential-client auth method (RFC 6749 §2.3.1, the
63
+ * form-body variant): the client sends `client_id` and `client_secret` as form-encoded
64
+ * parameters in the token-endpoint request body. Equivalent in security to
65
+ * {@link CLIENT_SECRET_BASIC_TOKEN_ENDPOINT_AUTH_METHOD}; pick it for clients that
66
+ * cannot set the `Authorization` header (some older HTTP stacks).
50
67
  *
51
- * `'none'` designates a public client: it holds no secret and authenticates the
52
- * `authorization_code` flow with PKCE alone. This is the canonical pattern for clients
53
- * that cannot keep a secret (native apps, SPAs, CLIs) and is what the MCP / Claude
54
- * connector ecosystem (claude.ai connector, Claude Code CLI, mcp-inspector via DCR)
55
- * expects. oidc-provider enforces PKCE on the `authorization_code` flow for every
56
- * client regardless of auth method, so all clients get PKCE; `'none'` simply unlocks
57
- * the secret-less variant.
68
+ * @example
69
+ * ```ts
70
+ * await oidcClientService.createClient({
71
+ * token_endpoint_auth_method: CLIENT_SECRET_POST_TOKEN_ENDPOINT_AUTH_METHOD,
72
+ * // ...
73
+ * });
74
+ * ```
58
75
  */
59
- export type OidcTokenEndpointAuthMethod = 'client_secret_basic' | 'client_secret_post' | 'client_secret_jwt' | 'private_key_jwt' | 'none';
60
- export declare const PRIVATE_KEY_JWT_TOKEN_ENDPOINT_AUTH_METHOD: OidcTokenEndpointAuthMethod;
76
+ export declare const CLIENT_SECRET_POST_TOKEN_ENDPOINT_AUTH_METHOD = "client_secret_post";
61
77
  /**
62
- * The public-client auth method (`'none'`): no client secret, PKCE-only.
78
+ * The `client_secret_jwt` confidential-client auth method (OIDC Core §9): the client
79
+ * signs a JWT client assertion using its `client_secret` as the HMAC key (HS256/HS384/HS512)
80
+ * and sends it as `client_assertion` on token-endpoint requests. The secret never goes on
81
+ * the wire — only the signed assertion — which is the upgrade over the plain
82
+ * `client_secret_*` methods, without requiring asymmetric keys like
83
+ * {@link PRIVATE_KEY_JWT_TOKEN_ENDPOINT_AUTH_METHOD}.
63
84
  *
64
- * Mirrors {@link PRIVATE_KEY_JWT_TOKEN_ENDPOINT_AUTH_METHOD}. Use this when provisioning
65
- * public OAuth clients that cannot keep a secret.
85
+ * @example
86
+ * ```ts
87
+ * await oidcClientService.createClient({
88
+ * token_endpoint_auth_method: CLIENT_SECRET_JWT_TOKEN_ENDPOINT_AUTH_METHOD,
89
+ * // ...
90
+ * });
91
+ * ```
92
+ */
93
+ export declare const CLIENT_SECRET_JWT_TOKEN_ENDPOINT_AUTH_METHOD = "client_secret_jwt";
94
+ /**
95
+ * The `private_key_jwt` confidential-client auth method (OIDC Core §9): the client signs
96
+ * a JWT client assertion with its private key (RS256/ES256/PS256) and sends it as
97
+ * `client_assertion`; the server verifies via the client's published `jwks` / `jwks_uri`.
98
+ * Strongest of the confidential-client methods — no shared secret is ever held by the
99
+ * server — and the canonical pick for high-trust server-to-server integrations.
100
+ *
101
+ * @example
102
+ * ```ts
103
+ * await oidcClientService.createClient({
104
+ * token_endpoint_auth_method: PRIVATE_KEY_JWT_TOKEN_ENDPOINT_AUTH_METHOD,
105
+ * jwks: { keys: [publicJwk] },
106
+ * // ...
107
+ * });
108
+ * ```
109
+ */
110
+ export declare const PRIVATE_KEY_JWT_TOKEN_ENDPOINT_AUTH_METHOD = "private_key_jwt";
111
+ /**
112
+ * The public-client auth method (`'none'`): no client secret, PKCE-only. The client
113
+ * authenticates the `authorization_code` flow with PKCE (RFC 7636) alone — there is no
114
+ * shared secret and no client assertion. Canonical pick for clients that cannot keep a
115
+ * secret (native apps, SPAs, CLIs) and what the MCP / Claude connector ecosystem
116
+ * (claude.ai connector, Claude Code CLI, mcp-inspector via DCR) registers as.
117
+ *
118
+ * Mirrors {@link PRIVATE_KEY_JWT_TOKEN_ENDPOINT_AUTH_METHOD}. `oidc-provider` still
119
+ * enforces PKCE on the `authorization_code` flow for every client regardless of auth
120
+ * method, so `'none'` simply unlocks the secret-less variant rather than disabling any
121
+ * client authentication.
122
+ *
123
+ * @example
124
+ * ```ts
125
+ * await oidcClientService.createClient({
126
+ * token_endpoint_auth_method: PUBLIC_PKCE_TOKEN_ENDPOINT_AUTH_METHOD,
127
+ * // no client_secret — public PKCE client
128
+ * // ...
129
+ * });
130
+ * ```
131
+ */
132
+ export declare const PUBLIC_PKCE_TOKEN_ENDPOINT_AUTH_METHOD = "none";
133
+ /**
134
+ * Supported values for `token_endpoint_auth_method` when creating an OIDC client.
135
+ * Derived as the union of each `*_TOKEN_ENDPOINT_AUTH_METHOD` literal const so the
136
+ * type and the constants stay in lock-step — add a new const and it auto-joins
137
+ * the union.
138
+ *
139
+ * The four `client_secret_*` / `private_key_jwt` methods are for confidential clients:
140
+ * - {@link CLIENT_SECRET_BASIC_TOKEN_ENDPOINT_AUTH_METHOD}
141
+ * - {@link CLIENT_SECRET_POST_TOKEN_ENDPOINT_AUTH_METHOD}
142
+ * - {@link CLIENT_SECRET_JWT_TOKEN_ENDPOINT_AUTH_METHOD}
143
+ * - {@link PRIVATE_KEY_JWT_TOKEN_ENDPOINT_AUTH_METHOD}
144
+ *
145
+ * {@link PUBLIC_PKCE_TOKEN_ENDPOINT_AUTH_METHOD} (`'none'`) designates a public
146
+ * client: it holds no secret and authenticates the `authorization_code` flow with
147
+ * PKCE alone. This is the canonical pattern for clients that cannot keep a secret
148
+ * (native apps, SPAs, CLIs) and is what the MCP / Claude connector ecosystem
149
+ * (claude.ai connector, Claude Code CLI, mcp-inspector via DCR) expects.
150
+ * oidc-provider enforces PKCE on the `authorization_code` flow for every client
151
+ * regardless of auth method, so all clients get PKCE; `'none'` simply unlocks
152
+ * the secret-less variant.
66
153
  */
67
- export declare const PUBLIC_PKCE_TOKEN_ENDPOINT_AUTH_METHOD: OidcTokenEndpointAuthMethod;
154
+ export type OidcTokenEndpointAuthMethod = typeof CLIENT_SECRET_BASIC_TOKEN_ENDPOINT_AUTH_METHOD | typeof CLIENT_SECRET_POST_TOKEN_ENDPOINT_AUTH_METHOD | typeof CLIENT_SECRET_JWT_TOKEN_ENDPOINT_AUTH_METHOD | typeof PRIVATE_KEY_JWT_TOKEN_ENDPOINT_AUTH_METHOD | typeof PUBLIC_PKCE_TOKEN_ENDPOINT_AUTH_METHOD;
68
155
  /**
69
156
  * All available token endpoint auth method options with display labels.
70
157
  */
package/test/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@dereekb/firebase/test",
3
- "version": "13.12.4",
3
+ "version": "13.12.6",
4
4
  "peerDependencies": {
5
- "@dereekb/date": "13.12.4",
6
- "@dereekb/firebase": "13.12.4",
7
- "@dereekb/model": "13.12.4",
8
- "@dereekb/rxjs": "13.12.4",
9
- "@dereekb/util": "13.12.4",
5
+ "@dereekb/date": "13.12.6",
6
+ "@dereekb/firebase": "13.12.6",
7
+ "@dereekb/model": "13.12.6",
8
+ "@dereekb/rxjs": "13.12.6",
9
+ "@dereekb/util": "13.12.6",
10
10
  "@firebase/rules-unit-testing": "5.0.0",
11
11
  "date-fns": "^4.1.0",
12
12
  "firebase": "^12.12.1",