@dereekb/firebase-server 13.2.1 → 13.3.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/index.cjs.js +7506 -1884
- package/index.esm.js +7505 -1890
- package/mailgun/index.cjs.js +333 -31
- package/mailgun/index.esm.js +333 -31
- package/mailgun/package.json +8 -8
- package/mailgun/src/lib/auth.mailgun.d.ts +22 -3
- package/model/index.cjs.js +11334 -3830
- package/model/index.esm.js +11338 -3834
- package/model/package.json +8 -8
- package/model/src/lib/mailgun/notification.send.service.mailgun.d.ts +27 -1
- package/model/src/lib/notification/notification.action.init.service.d.ts +93 -1
- package/model/src/lib/notification/notification.action.service.d.ts +151 -2
- package/model/src/lib/notification/notification.config.d.ts +19 -7
- package/model/src/lib/notification/notification.config.service.d.ts +44 -6
- package/model/src/lib/notification/notification.create.run.d.ts +33 -5
- package/model/src/lib/notification/notification.error.d.ts +63 -0
- package/model/src/lib/notification/notification.module.d.ts +11 -0
- package/model/src/lib/notification/notification.send.d.ts +8 -1
- package/model/src/lib/notification/notification.send.service.d.ts +7 -1
- package/model/src/lib/notification/notification.send.service.notificationsummary.d.ts +32 -2
- package/model/src/lib/notification/notification.send.service.text.d.ts +11 -3
- package/model/src/lib/notification/notification.task.service.d.ts +13 -1
- package/model/src/lib/notification/notification.task.service.handler.d.ts +27 -3
- package/model/src/lib/notification/notification.task.service.util.d.ts +16 -4
- package/model/src/lib/notification/notification.task.subtask.handler.d.ts +31 -1
- package/model/src/lib/notification/notification.util.d.ts +70 -0
- package/model/src/lib/storagefile/storagefile.action.init.service.d.ts +62 -1
- package/model/src/lib/storagefile/storagefile.action.server.d.ts +124 -2
- package/model/src/lib/storagefile/storagefile.error.d.ts +44 -0
- package/model/src/lib/storagefile/storagefile.module.d.ts +11 -0
- package/model/src/lib/storagefile/storagefile.task.service.handler.d.ts +4 -1
- package/model/src/lib/storagefile/storagefile.upload.service.d.ts +13 -1
- package/model/src/lib/storagefile/storagefile.upload.service.initializer.d.ts +43 -1
- package/model/src/lib/storagefile/storagefile.util.d.ts +8 -0
- package/oidc/index.cjs.default.js +1 -0
- package/oidc/index.cjs.js +5607 -0
- package/oidc/index.cjs.mjs +2 -0
- package/oidc/index.d.ts +1 -0
- package/oidc/index.esm.js +5560 -0
- package/oidc/package.json +26 -0
- package/oidc/src/index.d.ts +1 -0
- package/oidc/src/lib/controller/index.d.ts +3 -0
- package/oidc/src/lib/controller/oidc.interaction.controller.d.ts +54 -0
- package/oidc/src/lib/controller/oidc.provider.controller.d.ts +18 -0
- package/oidc/src/lib/controller/oidc.wellknown.controller.d.ts +36 -0
- package/oidc/src/lib/index.d.ts +6 -0
- package/oidc/src/lib/middleware/index.d.ts +3 -0
- package/oidc/src/lib/middleware/oauth-auth.decorator.d.ts +14 -0
- package/oidc/src/lib/middleware/oauth-auth.middleware.d.ts +21 -0
- package/oidc/src/lib/middleware/oauth-auth.module.d.ts +50 -0
- package/oidc/src/lib/model/index.d.ts +3 -0
- package/oidc/src/lib/model/jwks/index.d.ts +3 -0
- package/oidc/src/lib/model/jwks/jwks.d.ts +107 -0
- package/oidc/src/lib/model/jwks/jwks.id.d.ts +9 -0
- package/oidc/src/lib/model/jwks/jwks.query.d.ts +18 -0
- package/oidc/src/lib/model/model.d.ts +12 -0
- package/oidc/src/lib/model/oidc/index.d.ts +2 -0
- package/oidc/src/lib/model/oidc/oidcmodel.action.server.d.ts +62 -0
- package/oidc/src/lib/model/oidc/oidcmodel.module.d.ts +23 -0
- package/oidc/src/lib/oidc.config.d.ts +175 -0
- package/oidc/src/lib/oidc.module.d.ts +100 -0
- package/oidc/src/lib/service/index.d.ts +10 -0
- package/oidc/src/lib/service/oidc.account.d.ts +36 -0
- package/oidc/src/lib/service/oidc.account.service.d.ts +104 -0
- package/oidc/src/lib/service/oidc.adapter.service.d.ts +20 -0
- package/oidc/src/lib/service/oidc.auth.d.ts +26 -0
- package/oidc/src/lib/service/oidc.client.service.d.ts +57 -0
- package/oidc/src/lib/service/oidc.config.service.d.ts +100 -0
- package/oidc/src/lib/service/oidc.encryption.service.d.ts +53 -0
- package/oidc/src/lib/service/oidc.interaction.service.d.ts +44 -0
- package/oidc/src/lib/service/oidc.jwks.service.d.ts +105 -0
- package/oidc/src/lib/service/oidc.service.d.ts +55 -0
- package/package.json +15 -9
- package/src/lib/auth/auth.context.d.ts +22 -2
- package/src/lib/auth/auth.service.d.ts +5 -0
- package/src/lib/auth/auth.service.error.d.ts +2 -1
- package/src/lib/auth/auth.util.d.ts +15 -3
- package/src/lib/env/env.config.d.ts +42 -0
- package/src/lib/env/env.service.d.ts +17 -0
- package/src/lib/env/index.d.ts +1 -0
- package/src/lib/firestore/array.d.ts +11 -3
- package/src/lib/firestore/driver.accessor.batch.d.ts +27 -4
- package/src/lib/firestore/driver.accessor.d.ts +43 -0
- package/src/lib/firestore/driver.accessor.default.d.ts +20 -0
- package/src/lib/firestore/driver.accessor.transaction.d.ts +28 -4
- package/src/lib/firestore/driver.d.ts +14 -0
- package/src/lib/firestore/driver.query.d.ts +25 -0
- package/src/lib/firestore/increment.d.ts +13 -3
- package/src/lib/firestore/snapshot/index.d.ts +1 -1
- package/src/lib/firestore/snapshot/{snapshot.field.d.ts → snapshot.field.encrypt.d.ts} +13 -27
- package/src/lib/function/assert.d.ts +32 -16
- package/src/lib/function/context.d.ts +26 -0
- package/src/lib/function/error.auth.d.ts +15 -0
- package/src/lib/function/error.d.ts +68 -4
- package/src/lib/nest/app.d.ts +53 -9
- package/src/lib/nest/app.module.d.ts +90 -0
- package/src/lib/nest/auth/auth.module.d.ts +30 -4
- package/src/lib/nest/auth/auth.util.d.ts +38 -0
- package/src/lib/nest/controller/auth.context.server.d.ts +27 -0
- package/src/lib/nest/controller/index.d.ts +1 -0
- package/src/lib/nest/development/development.app.function.d.ts +45 -0
- package/src/lib/nest/development/development.assert.function.d.ts +19 -1
- package/src/lib/nest/development/development.function.d.ts +42 -3
- package/src/lib/nest/development/development.schedule.function.d.ts +29 -0
- package/src/lib/nest/development/development.schedule.function.error.d.ts +21 -0
- package/src/lib/nest/env/env.service.d.ts +9 -0
- package/src/lib/nest/env/env.util.d.ts +16 -0
- package/src/lib/nest/firebase/firebase.module.d.ts +13 -1
- package/src/lib/nest/firestore/firestore.module.d.ts +24 -8
- package/src/lib/nest/function/call.d.ts +75 -6
- package/src/lib/nest/function/context.d.ts +85 -2
- package/src/lib/nest/function/nest.d.ts +46 -0
- package/src/lib/nest/function/schedule.d.ts +49 -0
- package/src/lib/nest/function/v2/blocking.d.ts +92 -8
- package/src/lib/nest/function/v2/call.d.ts +38 -8
- package/src/lib/nest/function/v2/event.d.ts +67 -4
- package/src/lib/nest/function/v2/schedule.d.ts +36 -5
- package/src/lib/nest/index.d.ts +3 -0
- package/src/lib/nest/middleware/appcheck.d.ts +5 -0
- package/src/lib/nest/middleware/appcheck.middleware.d.ts +44 -14
- package/src/lib/nest/middleware/appcheck.module.d.ts +10 -1
- package/src/lib/nest/middleware/globalprefix.d.ts +31 -3
- package/src/lib/nest/middleware/index.d.ts +2 -1
- package/src/lib/nest/middleware/rawbody.middleware.d.ts +6 -0
- package/src/lib/nest/model/call.model.function.d.ts +69 -3
- package/src/lib/nest/model/create.model.function.d.ts +66 -0
- package/src/lib/nest/model/crud.assert.function.d.ts +27 -1
- package/src/lib/nest/model/delete.model.function.d.ts +55 -0
- package/src/lib/nest/model/permission.error.d.ts +15 -0
- package/src/lib/nest/model/read.model.function.d.ts +57 -0
- package/src/lib/nest/model/specifier.function.d.ts +58 -1
- package/src/lib/nest/model/update.model.function.d.ts +58 -0
- package/src/lib/nest/nest.provider.d.ts +24 -11
- package/src/lib/nest/nest.provider.server.d.ts +12 -0
- package/src/lib/nest/storage/storage.module.d.ts +30 -4
- package/src/lib/storage/driver.accessor.d.ts +33 -0
- package/src/lib/storage/driver.d.ts +14 -0
- package/src/lib/storage/storage.d.ts +11 -4
- package/src/lib/storage/storage.service.d.ts +10 -1
- package/src/lib/type.d.ts +7 -2
- package/test/index.cjs.js +4072 -757
- package/test/index.esm.js +4073 -761
- package/test/package.json +8 -8
- package/test/src/lib/firebase/firebase.admin.auth.d.ts +82 -1
- package/test/src/lib/firebase/firebase.admin.collection.d.ts +55 -3
- package/test/src/lib/firebase/firebase.admin.d.ts +64 -0
- package/test/src/lib/firebase/firebase.admin.function.d.ts +84 -0
- package/test/src/lib/firebase/firebase.admin.nest.d.ts +125 -17
- package/test/src/lib/firebase/firebase.admin.nest.function.callable.context.d.ts +44 -0
- package/test/src/lib/firebase/firebase.admin.nest.function.cloud.context.d.ts +41 -0
- package/test/src/lib/firebase/firebase.admin.nest.function.d.ts +98 -0
- package/test/src/lib/firebase/firebase.admin.test.server.d.ts +26 -0
- package/test/src/lib/firebase/firebase.d.ts +57 -2
- package/test/src/lib/firebase/firebase.function.d.ts +138 -0
- package/test/src/lib/firestore/firestore.admin.d.ts +6 -0
- package/test/src/lib/firestore/firestore.d.ts +30 -0
- package/test/src/lib/storage/storage.admin.d.ts +9 -3
- package/test/src/lib/storage/storage.d.ts +30 -0
- package/zoho/index.cjs.js +406 -73
- package/zoho/index.esm.js +406 -73
- package/zoho/package.json +8 -8
- package/zoho/src/lib/zoho.accounts.firebase.d.ts +13 -2
- package/zoho/src/lib/zoho.accounts.firebase.system.d.ts +29 -6
- package/index.cjs.js.map +0 -1
- package/index.esm.js.map +0 -1
- /package/src/lib/nest/middleware/{webhook.d.ts → webhook.module.d.ts} +0 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type OidcEntryClientId } from '@dereekb/firebase';
|
|
2
|
+
import { OidcModuleConfig } from '../oidc.config';
|
|
3
|
+
import { type SelectiveFieldEncryptor, type StringEncryptionProvider, type JsonSerializableObject } from '@dereekb/util';
|
|
4
|
+
import type { AdapterPayload } from 'oidc-provider';
|
|
5
|
+
/**
|
|
6
|
+
* Adapter payload fields that contain sensitive values and are selectively encrypted at rest.
|
|
7
|
+
*
|
|
8
|
+
* - `client_secret`: OAuth client secret (present on Client entries)
|
|
9
|
+
* - `registration_access_token`: DCR access token (present on Client entries)
|
|
10
|
+
*/
|
|
11
|
+
export declare const OIDC_ENCRYPTED_PAYLOAD_FIELDS: readonly ["client_secret", "registration_access_token"];
|
|
12
|
+
/**
|
|
13
|
+
* Union of adapter payload field names that are selectively encrypted.
|
|
14
|
+
*/
|
|
15
|
+
export type OidcEncryptedPayloadField = (typeof OIDC_ENCRYPTED_PAYLOAD_FIELDS)[number];
|
|
16
|
+
/**
|
|
17
|
+
* Loosely-typed adapter payload with known sensitive fields.
|
|
18
|
+
*/
|
|
19
|
+
export interface OidcClientPayload {
|
|
20
|
+
client_id: OidcEntryClientId;
|
|
21
|
+
client_secret?: string;
|
|
22
|
+
registration_access_token?: string;
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Selective field encryptor for oidc-provider adapter and client payloads.
|
|
27
|
+
*
|
|
28
|
+
* Both adapter payloads and client payloads share the same encrypted fields,
|
|
29
|
+
* so a single encryptor type is used for both.
|
|
30
|
+
*/
|
|
31
|
+
export type OidcAdapterPayloadEncryptor = SelectiveFieldEncryptor<AdapterPayload, OidcEncryptedPayloadField>;
|
|
32
|
+
/**
|
|
33
|
+
* Centralized encryption service for OIDC payload fields.
|
|
34
|
+
*
|
|
35
|
+
* Provides a single {@link StringEncryptionProvider} and pre-built selective field encryptors
|
|
36
|
+
* for both the oidc-provider adapter payloads and client CRUD payloads. This avoids
|
|
37
|
+
* duplicating encryption setup across {@link OidcService}, the adapter factory, and
|
|
38
|
+
* the OIDC model server actions.
|
|
39
|
+
*/
|
|
40
|
+
export declare class OidcEncryptionService {
|
|
41
|
+
readonly provider: StringEncryptionProvider;
|
|
42
|
+
readonly adapterPayloadEncryptor: OidcAdapterPayloadEncryptor;
|
|
43
|
+
constructor(config: OidcModuleConfig);
|
|
44
|
+
/**
|
|
45
|
+
* Encrypts sensitive fields in an adapter payload and returns it as a {@link JsonSerializableObject}
|
|
46
|
+
* suitable for storing directly in Firestore.
|
|
47
|
+
*/
|
|
48
|
+
encryptAdapterPayload(payload: AdapterPayload): JsonSerializableObject;
|
|
49
|
+
/**
|
|
50
|
+
* Decrypts sensitive fields in a Firestore-stored payload object back to an {@link AdapterPayload}.
|
|
51
|
+
*/
|
|
52
|
+
decryptAdapterPayload(payload: JsonSerializableObject): AdapterPayload;
|
|
53
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Request, Response } from 'express';
|
|
2
|
+
import type { Interaction, InteractionResults, Grant } from 'oidc-provider';
|
|
3
|
+
import { type OidcInteractionUid } from '@dereekb/firebase';
|
|
4
|
+
import { OidcClientService } from './oidc.client.service';
|
|
5
|
+
import { OidcService } from './oidc.service';
|
|
6
|
+
/**
|
|
7
|
+
* Service for handling OIDC interactions.
|
|
8
|
+
*/
|
|
9
|
+
export declare class OidcInteractionService {
|
|
10
|
+
private readonly oidcService;
|
|
11
|
+
private readonly clientService;
|
|
12
|
+
constructor(oidcService: OidcService, clientService: OidcClientService);
|
|
13
|
+
/**
|
|
14
|
+
* Loads the interaction details for a given request/response pair.
|
|
15
|
+
*
|
|
16
|
+
* Requires the oidc-provider interaction cookie to be present on the request.
|
|
17
|
+
*/
|
|
18
|
+
getInteractionDetails(req: Request, res: Response): Promise<Interaction>;
|
|
19
|
+
/**
|
|
20
|
+
* Finds an interaction by its UID directly from the adapter store.
|
|
21
|
+
*
|
|
22
|
+
* Bypasses the cookie-based lookup used by `provider.interactionDetails()`.
|
|
23
|
+
* This is necessary when the interaction cookie is scoped to a different path
|
|
24
|
+
* (e.g., the frontend) and is not sent with backend API requests.
|
|
25
|
+
*
|
|
26
|
+
* @throws {Error} When the interaction is not found or has expired.
|
|
27
|
+
*/
|
|
28
|
+
findInteractionByUid(uid: OidcInteractionUid): Promise<Interaction>;
|
|
29
|
+
/**
|
|
30
|
+
* Completes an interaction by UID without requiring the interaction cookie.
|
|
31
|
+
*
|
|
32
|
+
* Looks up the interaction directly by UID, applies the result, saves it,
|
|
33
|
+
* and returns the `returnTo` URL for the client to redirect to.
|
|
34
|
+
*
|
|
35
|
+
* @returns The `returnTo` URL that the client should redirect to.
|
|
36
|
+
*/
|
|
37
|
+
finishInteractionByUid(uid: OidcInteractionUid, result: InteractionResults, options?: {
|
|
38
|
+
mergeWithLastSubmission?: boolean;
|
|
39
|
+
}): Promise<string>;
|
|
40
|
+
/**
|
|
41
|
+
* Finds an existing grant by ID, or creates a new one.
|
|
42
|
+
*/
|
|
43
|
+
findOrCreateGrant(grantId: string | undefined, accountId: string, clientId: string): Promise<Grant>;
|
|
44
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { type AES256GCMEncryptionSecretSource } from '@dereekb/nestjs';
|
|
2
|
+
import { type FirebaseStorageAccessorFile } from '@dereekb/firebase';
|
|
3
|
+
import { type JwksKey, type JsonWebKeyWithKid } from '../model/jwks/jwks';
|
|
4
|
+
import { type WebsiteUrlWithPrefix, type Maybe } from '@dereekb/util';
|
|
5
|
+
import { OidcServerFirestoreCollections } from '../model/model';
|
|
6
|
+
/**
|
|
7
|
+
* Result of {@link JwksService.generateKeyPair}.
|
|
8
|
+
*/
|
|
9
|
+
export interface GenerateKeyPairResult {
|
|
10
|
+
/** The stored Firestore document data (private key is encrypted). */
|
|
11
|
+
readonly jwksKey: JwksKey;
|
|
12
|
+
/** The unencrypted private JWK, ready for use as a signing key. */
|
|
13
|
+
readonly signingKey: JsonWebKeyWithKid;
|
|
14
|
+
}
|
|
15
|
+
export declare abstract class JwksServiceConfig {
|
|
16
|
+
/**
|
|
17
|
+
* Encryption secret for private key storage.
|
|
18
|
+
*
|
|
19
|
+
* Supports all `AES256GCMEncryptionSecretSource` formats:
|
|
20
|
+
* direct hex string, getter function, or environment variable reference.
|
|
21
|
+
*/
|
|
22
|
+
abstract readonly encryptionSecret: AES256GCMEncryptionSecretSource;
|
|
23
|
+
/**
|
|
24
|
+
* Maximum age of a rotated key (in seconds) before it is retired.
|
|
25
|
+
* Defaults to 30 days (2592000).
|
|
26
|
+
*/
|
|
27
|
+
abstract readonly rotatedKeyMaxAge?: number;
|
|
28
|
+
/**
|
|
29
|
+
* If true, the JWKS will be written to storage when keys are rotated, if enabled.
|
|
30
|
+
*
|
|
31
|
+
* Defaults to true if `serveJwksFromStorage` is defined.
|
|
32
|
+
*/
|
|
33
|
+
abstract readonly enableSaveJwksToStorage?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* If true, this flag signals to the rest of the system that the JWKS will be served from storage.
|
|
36
|
+
*
|
|
37
|
+
* Defaults to true if `enableSaveJwksToStorage` is true.
|
|
38
|
+
*/
|
|
39
|
+
abstract readonly serveJwksFromStorage?: boolean;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* If provided, the JwksService will write the JWKS to this file when keys are rotated.
|
|
43
|
+
*/
|
|
44
|
+
export declare abstract class JwksServiceStorageConfig {
|
|
45
|
+
/**
|
|
46
|
+
* If provided, the JWKS will be written to this file when keys are rotated.
|
|
47
|
+
*/
|
|
48
|
+
abstract readonly jwksStorageAccessorFile?: Maybe<FirebaseStorageAccessorFile>;
|
|
49
|
+
}
|
|
50
|
+
export declare const DEFAULT_ROTATED_KEY_MAX_AGE: number;
|
|
51
|
+
export declare class JwksService {
|
|
52
|
+
private readonly config;
|
|
53
|
+
private readonly collections;
|
|
54
|
+
private readonly storageConfig?;
|
|
55
|
+
private readonly _jwksStoragePublicUrl;
|
|
56
|
+
private readonly rotatedKeyMaxAge;
|
|
57
|
+
/**
|
|
58
|
+
* Whether the JWKS is served from a public storage URL rather than the built-in endpoint.
|
|
59
|
+
*/
|
|
60
|
+
readonly serveJwksFromStorage: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Whether the JWKS should be saved to storage when keys are rotated.
|
|
63
|
+
*/
|
|
64
|
+
readonly saveJwksToStorage: boolean;
|
|
65
|
+
constructor(config: JwksServiceConfig, collections: OidcServerFirestoreCollections, storageConfig?: Maybe<JwksServiceStorageConfig>);
|
|
66
|
+
private get jwksKeyCollection();
|
|
67
|
+
/**
|
|
68
|
+
* Generates a new RS256 key pair and stores it in Firestore.
|
|
69
|
+
* The private key is encrypted at rest using AES-256-GCM.
|
|
70
|
+
*
|
|
71
|
+
* Returns both the stored {@link JwksKey} and the unencrypted private JWK
|
|
72
|
+
* so callers can use the signing key immediately without a decryption round-trip.
|
|
73
|
+
*/
|
|
74
|
+
generateKeyPair(): Promise<GenerateKeyPairResult>;
|
|
75
|
+
/**
|
|
76
|
+
* Returns the currently active signing key's private JWK.
|
|
77
|
+
*/
|
|
78
|
+
getActiveSigningKey(): Promise<JsonWebKeyWithKid | undefined>;
|
|
79
|
+
/**
|
|
80
|
+
* Returns the public URL for the JWKS stored in Cloud Storage, if configured.
|
|
81
|
+
*
|
|
82
|
+
* This call will also initialize/rotate the keys in the datastore and sync them
|
|
83
|
+
* to the cloud if they are currently not available.
|
|
84
|
+
*
|
|
85
|
+
* Returns undefined if storage is not configured or `serveJwksFromStorage` is false.
|
|
86
|
+
* Returns null if an error occured while trying to setup.
|
|
87
|
+
*/
|
|
88
|
+
getJwksStoragePublicUrl(): Promise<Maybe<WebsiteUrlWithPrefix>>;
|
|
89
|
+
/**
|
|
90
|
+
* Returns the public JWKS (all non-retired keys) by querying Firestore.
|
|
91
|
+
*/
|
|
92
|
+
getLatestPublicJwks(): Promise<{
|
|
93
|
+
keys: JsonWebKeyWithKid[];
|
|
94
|
+
}>;
|
|
95
|
+
/**
|
|
96
|
+
* Rotates keys: marks the current active key as rotated and generates a new active key.
|
|
97
|
+
*/
|
|
98
|
+
rotateKeys(): Promise<JwksKey>;
|
|
99
|
+
private _initializeKeysAndCloud;
|
|
100
|
+
private _syncKeysToCloud;
|
|
101
|
+
/**
|
|
102
|
+
* Retires rotated keys whose expiresAt has passed.
|
|
103
|
+
*/
|
|
104
|
+
retireExpiredKeys(): Promise<number>;
|
|
105
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type Provider from 'oidc-provider';
|
|
2
|
+
import { type Configuration } from 'oidc-provider';
|
|
3
|
+
import { OidcModuleConfig } from '../oidc.config';
|
|
4
|
+
import { JwksService } from './oidc.jwks.service';
|
|
5
|
+
import { OidcAccountService } from './oidc.account.service';
|
|
6
|
+
import { OidcServerFirestoreCollections } from '../model';
|
|
7
|
+
import { OidcEncryptionService } from './oidc.encryption.service';
|
|
8
|
+
import { OidcProviderConfigService } from './oidc.config.service';
|
|
9
|
+
import { type OidcEntryClientId, type OidcEntryOAuthClientPayloadData } from '@dereekb/firebase';
|
|
10
|
+
import { type Maybe } from '@dereekb/util';
|
|
11
|
+
import { type OidcAuthData } from './oidc.auth';
|
|
12
|
+
/**
|
|
13
|
+
* Core OIDC service that wraps the oidc-provider instance and exposes
|
|
14
|
+
* typed methods for interaction handling, provider initialization, and JWKS management.
|
|
15
|
+
*/
|
|
16
|
+
export declare class OidcService {
|
|
17
|
+
private readonly config;
|
|
18
|
+
private readonly providerConfigService;
|
|
19
|
+
private readonly jwksService;
|
|
20
|
+
private readonly accountService;
|
|
21
|
+
private readonly collections;
|
|
22
|
+
private readonly encryptionService;
|
|
23
|
+
private readonly _getProvider;
|
|
24
|
+
constructor(config: OidcModuleConfig, providerConfigService: OidcProviderConfigService, jwksService: JwksService, accountService: OidcAccountService, collections: OidcServerFirestoreCollections, encryptionService: OidcEncryptionService);
|
|
25
|
+
/**
|
|
26
|
+
* Returns the oidc-provider instance, initializing it on first access.
|
|
27
|
+
*/
|
|
28
|
+
getProvider(): Promise<Provider>;
|
|
29
|
+
/**
|
|
30
|
+
* Verifies an opaque access token and returns the {@link OidcAuthData}.
|
|
31
|
+
*
|
|
32
|
+
* Uses the provider's `AccessToken` model to look up the token and extract
|
|
33
|
+
* the account ID, scope, and client ID.
|
|
34
|
+
*
|
|
35
|
+
* @param token - The opaque access token string.
|
|
36
|
+
* @returns The auth context, or `undefined` if the token is invalid or expired.
|
|
37
|
+
*/
|
|
38
|
+
verifyAccessToken(rawToken: string): Promise<OidcAuthData | undefined>;
|
|
39
|
+
/**
|
|
40
|
+
* Finds a client payload by ID directly from the adapter store.
|
|
41
|
+
*
|
|
42
|
+
* @param clientId - The client's document/adapter entry ID.
|
|
43
|
+
* @returns The client payload data, or `undefined` if not found.
|
|
44
|
+
*/
|
|
45
|
+
findClientPayload(clientId: OidcEntryClientId): Promise<Maybe<OidcEntryOAuthClientPayloadData>>;
|
|
46
|
+
/**
|
|
47
|
+
* Builds the oidc-provider {@link Configuration} options that are spread into
|
|
48
|
+
* `new Provider(issuer, { ...options })`.
|
|
49
|
+
*
|
|
50
|
+
* Does NOT include `adapter`, `findAccount`, or `jwks` — those require async
|
|
51
|
+
* setup and are handled by {@link OidcService}.
|
|
52
|
+
*/
|
|
53
|
+
buildProviderConfiguration(cookieKeys: string[]): Configuration;
|
|
54
|
+
private _buildProvider;
|
|
55
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/firebase-server",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.3.0",
|
|
4
4
|
"exports": {
|
|
5
5
|
"./test": {
|
|
6
6
|
"module": "./test/index.esm.js",
|
|
@@ -26,6 +26,12 @@
|
|
|
26
26
|
"import": "./model/index.cjs.mjs",
|
|
27
27
|
"default": "./model/index.cjs.js"
|
|
28
28
|
},
|
|
29
|
+
"./oidc": {
|
|
30
|
+
"module": "./oidc/index.esm.js",
|
|
31
|
+
"types": "./oidc/index.d.ts",
|
|
32
|
+
"import": "./oidc/index.cjs.mjs",
|
|
33
|
+
"default": "./oidc/index.cjs.js"
|
|
34
|
+
},
|
|
29
35
|
"./package.json": "./package.json",
|
|
30
36
|
".": {
|
|
31
37
|
"module": "./index.esm.js",
|
|
@@ -37,14 +43,14 @@
|
|
|
37
43
|
"main": "./index.cjs.js",
|
|
38
44
|
"types": "./src/index.d.ts",
|
|
39
45
|
"peerDependencies": {
|
|
40
|
-
"@dereekb/date": "13.
|
|
41
|
-
"@dereekb/dbx-core": "13.
|
|
42
|
-
"@dereekb/firebase": "13.
|
|
43
|
-
"@dereekb/model": "13.
|
|
44
|
-
"@dereekb/nestjs": "13.
|
|
45
|
-
"@dereekb/rxjs": "13.
|
|
46
|
-
"@dereekb/util": "13.
|
|
47
|
-
"@dereekb/zoho": "13.
|
|
46
|
+
"@dereekb/date": "13.3.0",
|
|
47
|
+
"@dereekb/dbx-core": "13.3.0",
|
|
48
|
+
"@dereekb/firebase": "13.3.0",
|
|
49
|
+
"@dereekb/model": "13.3.0",
|
|
50
|
+
"@dereekb/nestjs": "13.3.0",
|
|
51
|
+
"@dereekb/rxjs": "13.3.0",
|
|
52
|
+
"@dereekb/util": "13.3.0",
|
|
53
|
+
"@dereekb/zoho": "13.3.0",
|
|
48
54
|
"@google-cloud/firestore": "^7.11.6",
|
|
49
55
|
"@google-cloud/storage": "^7.19.0",
|
|
50
56
|
"@nestjs/common": "^11.0.0",
|
|
@@ -1,7 +1,27 @@
|
|
|
1
1
|
import { type FirebaseAuthToken } from '@dereekb/firebase';
|
|
2
2
|
import type * as admin from 'firebase-admin';
|
|
3
3
|
import { type AuthData } from '../type';
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Reference to optional {@link AuthData} from a Firebase callable function request.
|
|
6
|
+
*
|
|
7
|
+
* Used by {@link FirebaseServerAuthService.authContextInfo} to build auth context
|
|
8
|
+
* from callable function requests where the caller may or may not be authenticated.
|
|
9
|
+
*/
|
|
10
|
+
export interface AuthDataRef<T extends AuthData = AuthData> {
|
|
11
|
+
readonly auth?: T;
|
|
6
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Converts a Firebase Admin {@link admin.auth.DecodedIdToken} into a normalized {@link FirebaseAuthToken}.
|
|
15
|
+
*
|
|
16
|
+
* Maps Firebase Admin token fields (snake_case) to the application's token interface (camelCase),
|
|
17
|
+
* including email, phone, and sign-in timestamps.
|
|
18
|
+
*
|
|
19
|
+
* @param token - The decoded ID token from Firebase Admin Auth.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const decodedToken = await admin.auth().verifyIdToken(idToken);
|
|
24
|
+
* const authToken = firebaseAuthTokenFromDecodedIdToken(decodedToken);
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
7
27
|
export declare function firebaseAuthTokenFromDecodedIdToken(token: admin.auth.DecodedIdToken): FirebaseAuthToken;
|
|
@@ -16,6 +16,11 @@ import { type CallableContext } from '../type';
|
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
18
|
export declare const DEFAULT_FIREBASE_PASSWORD_NUMBER_GENERATOR: import("@dereekb/util").NumberFactory;
|
|
19
|
+
/**
|
|
20
|
+
* Identifies a Firebase Auth user by UID within a server-side auth context.
|
|
21
|
+
*
|
|
22
|
+
* Base interface for {@link FirebaseServerAuthUserContext} and {@link FirebaseServerAuthContext}.
|
|
23
|
+
*/
|
|
19
24
|
export interface FirebaseServerAuthUserIdentifierContext {
|
|
20
25
|
/**
|
|
21
26
|
* UID of the user for this context.
|
|
@@ -13,7 +13,8 @@ export declare class FirebaseServerAuthNewUserSendSetupDetailsThrottleError exte
|
|
|
13
13
|
constructor(lastSentAt: Date);
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* Thrown by sendSetupDetails() if the user
|
|
16
|
+
* Thrown by sendSetupDetails() if the user has already been sent setup details
|
|
17
|
+
* and the `sendSetupDetailsOnce` option was enabled.
|
|
17
18
|
*/
|
|
18
19
|
export declare class FirebaseServerAuthNewUserSendSetupDetailsSendOnceError extends BaseError {
|
|
19
20
|
constructor();
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
import { type Maybe } from '@dereekb/util';
|
|
2
2
|
import type * as admin from 'firebase-admin';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Safely awaits a Firebase Admin Auth user lookup, returning `undefined` instead of throwing
|
|
5
|
+
* when the user is not found.
|
|
6
|
+
*
|
|
7
|
+
* Any error other than {@link FIREBASE_AUTH_USER_NOT_FOUND_ERROR} is re-thrown.
|
|
8
|
+
*
|
|
9
|
+
* @param promise - A promise resolving to a UserRecord (e.g., from `auth.getUser(uid)`).
|
|
10
|
+
* @returns The user record, or `undefined` if the user does not exist.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const user = await getAuthUserOrUndefined(admin.auth().getUser(uid));
|
|
15
|
+
* if (user) {
|
|
16
|
+
* console.log(user.email);
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
7
19
|
*/
|
|
8
20
|
export declare function getAuthUserOrUndefined(promise: Promise<admin.auth.UserRecord>): Promise<Maybe<admin.auth.UserRecord>>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type InjectionToken, type Provider } from '@nestjs/common';
|
|
2
|
+
import { type ServerEnvironmentConfig } from '@dereekb/nestjs';
|
|
3
|
+
/**
|
|
4
|
+
* Extension of ServerEnvironmentConfig for Firebase server applications.
|
|
5
|
+
*
|
|
6
|
+
* Requires appUrl to be provided.
|
|
7
|
+
*/
|
|
8
|
+
export interface FirebaseServerEnvironmentConfig extends ServerEnvironmentConfig {
|
|
9
|
+
readonly appUrl: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Token to access a configured FirebaseServerEnvironmentServiceConfig for the app.
|
|
13
|
+
*/
|
|
14
|
+
export declare const FIREBASE_SERVER_ENV_TOKEN: InjectionToken;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a NestJS provider that binds the given config to the {@link FIREBASE_SERVER_ENV_TOKEN} injection token.
|
|
17
|
+
*
|
|
18
|
+
* @param env - The Firebase server environment configuration.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const provider = firebaseServerEnvTokenProvider({ appUrl: 'https://myapp.com', ... });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function firebaseServerEnvTokenProvider<T extends FirebaseServerEnvironmentConfig = FirebaseServerEnvironmentConfig>(env: T): Provider;
|
|
26
|
+
/**
|
|
27
|
+
* Creates NestJS providers that bind the given config to both {@link FIREBASE_SERVER_ENV_TOKEN}
|
|
28
|
+
* and the base {@link SERVER_ENV_TOKEN} from `@dereekb/nestjs`.
|
|
29
|
+
*
|
|
30
|
+
* Use this when the NestJS app needs the config accessible via either token.
|
|
31
|
+
*
|
|
32
|
+
* @param env - The Firebase server environment configuration.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* @Module({
|
|
37
|
+
* providers: [...firebaseServerEnvTokenProviders(myEnvConfig)]
|
|
38
|
+
* })
|
|
39
|
+
* export class AppModule {}
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function firebaseServerEnvTokenProviders<T extends FirebaseServerEnvironmentConfig = FirebaseServerEnvironmentConfig>(env: T): Provider[];
|
|
@@ -1,13 +1,30 @@
|
|
|
1
|
+
import { type Maybe, type WebsiteUrlDetails } from '@dereekb/util';
|
|
1
2
|
/**
|
|
2
3
|
* Reference to a FirebaseServerEnvService
|
|
3
4
|
*/
|
|
4
5
|
export interface FirebaseServerEnvServiceRef<S extends FirebaseServerEnvService = FirebaseServerEnvService> {
|
|
5
6
|
readonly envService: S;
|
|
6
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* Abstract service providing Firebase server environment information such as deployment stage,
|
|
10
|
+
* feature flags, and app URL.
|
|
11
|
+
*
|
|
12
|
+
* Implementations are typically injected via {@link FIREBASE_SERVER_ENV_TOKEN} and
|
|
13
|
+
* backed by a {@link FirebaseServerEnvironmentConfig}.
|
|
14
|
+
*/
|
|
7
15
|
export declare abstract class FirebaseServerEnvService {
|
|
16
|
+
/** Whether the server is running in a test/CI environment. */
|
|
8
17
|
abstract readonly isTestingEnv: boolean;
|
|
18
|
+
/** Whether the server is running in production. */
|
|
9
19
|
abstract readonly isProduction: boolean;
|
|
20
|
+
/** Whether the server is running in a staging environment. */
|
|
10
21
|
abstract readonly isStaging: boolean;
|
|
22
|
+
/** Whether developer/debug tools are enabled for this environment. */
|
|
11
23
|
abstract readonly developerToolsEnabled: boolean;
|
|
24
|
+
/** Whether the development scheduler (for cron-like tasks) is enabled. */
|
|
12
25
|
abstract readonly developmentSchedulerEnabled: boolean;
|
|
26
|
+
/** The application's public URL, if configured. */
|
|
27
|
+
abstract readonly appUrl: Maybe<string>;
|
|
28
|
+
/** Parsed URL details for the application URL. */
|
|
29
|
+
abstract readonly appUrlDetails: Maybe<WebsiteUrlDetails>;
|
|
13
30
|
}
|
package/src/lib/env/index.d.ts
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { type UpdateData, type FirestoreAccessorArrayUpdate } from '@dereekb/firebase';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Converts a {@link FirestoreAccessorArrayUpdate} into Firestore {@link UpdateData} using
|
|
4
|
+
* Google Cloud Firestore's {@link FieldValue.arrayUnion} and {@link FieldValue.arrayRemove}.
|
|
4
5
|
*
|
|
5
|
-
* @param input
|
|
6
|
-
*
|
|
6
|
+
* @param input - The array update specification with `union` and/or `remove` field maps.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const updateData = firestoreServerArrayUpdateToUpdateData<User>({
|
|
11
|
+
* union: { tags: ['new-tag'] },
|
|
12
|
+
* remove: { tags: ['old-tag'] }
|
|
13
|
+
* });
|
|
14
|
+
* ```
|
|
7
15
|
*/
|
|
8
16
|
export declare function firestoreServerArrayUpdateToUpdateData<T extends object>(input: FirestoreAccessorArrayUpdate<T>): UpdateData<T>;
|
|
@@ -2,7 +2,11 @@ import { type DocumentReference, type WriteBatch as GoogleCloudWriteBatch, type
|
|
|
2
2
|
import { type Observable } from 'rxjs';
|
|
3
3
|
import { type WithFieldValue, type FirestoreDocumentContext, FirestoreDocumentContextType, type FirestoreDocumentDataAccessor, type FirestoreDocumentDataAccessorFactory, type FirestoreDocumentDeleteParams, type FirestoreDocumentUpdateParams, type UpdateData, type DocumentData, type FirestoreDataConverter, type FirestoreAccessorIncrementUpdate, type FirestoreAccessorArrayUpdate } from '@dereekb/firebase';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Google Cloud Firestore implementation of {@link FirestoreDocumentDataAccessor} that queues
|
|
6
|
+
* all write operations (create, set, update, delete) into a {@link WriteBatch}.
|
|
7
|
+
*
|
|
8
|
+
* Writes are not committed until the batch is explicitly committed. Read operations
|
|
9
|
+
* (get, exists) bypass the batch and read directly from Firestore.
|
|
6
10
|
*/
|
|
7
11
|
export declare class WriteBatchFirestoreDocumentDataAccessor<T> implements FirestoreDocumentDataAccessor<T> {
|
|
8
12
|
readonly documentRef: DocumentReference<T>;
|
|
@@ -21,12 +25,28 @@ export declare class WriteBatchFirestoreDocumentDataAccessor<T> implements Fires
|
|
|
21
25
|
update(data: UpdateData<object>, params?: FirestoreDocumentUpdateParams): Promise<void>;
|
|
22
26
|
}
|
|
23
27
|
/**
|
|
24
|
-
* Creates a
|
|
28
|
+
* Creates a {@link FirestoreDocumentDataAccessorFactory} that produces batch-backed accessors.
|
|
29
|
+
*
|
|
30
|
+
* All accessors created from this factory share the same {@link WriteBatch}, so committing
|
|
31
|
+
* the batch applies all queued writes atomically.
|
|
25
32
|
*
|
|
26
|
-
* @param
|
|
27
|
-
*
|
|
33
|
+
* @param writeBatch - The Google Cloud WriteBatch to queue operations into.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const batch = firestore.batch();
|
|
38
|
+
* const factory = writeBatchAccessorFactory<User>(batch);
|
|
39
|
+
* const accessor = factory.accessorFor(userDocRef);
|
|
40
|
+
* await accessor.set({ name: 'Alice' });
|
|
41
|
+
* await batch.commit();
|
|
42
|
+
* ```
|
|
28
43
|
*/
|
|
29
44
|
export declare function writeBatchAccessorFactory<T>(writeBatch: GoogleCloudWriteBatch): FirestoreDocumentDataAccessorFactory<T>;
|
|
45
|
+
/**
|
|
46
|
+
* A {@link FirestoreDocumentContext} backed by a Google Cloud {@link WriteBatch}.
|
|
47
|
+
*
|
|
48
|
+
* All document accessors created from this context queue writes into the same batch.
|
|
49
|
+
*/
|
|
30
50
|
export declare class WriteBatchFirestoreDocumentContext<T> implements FirestoreDocumentContext<T> {
|
|
31
51
|
private readonly _batch;
|
|
32
52
|
readonly contextType = FirestoreDocumentContextType.BATCH;
|
|
@@ -34,4 +54,7 @@ export declare class WriteBatchFirestoreDocumentContext<T> implements FirestoreD
|
|
|
34
54
|
constructor(batch: GoogleCloudWriteBatch);
|
|
35
55
|
get batch(): GoogleCloudWriteBatch;
|
|
36
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Creates a {@link WriteBatchFirestoreDocumentContext} wrapping the given batch.
|
|
59
|
+
*/
|
|
37
60
|
export declare function writeBatchDocumentContext<T>(batch: GoogleCloudWriteBatch): WriteBatchFirestoreDocumentContext<T>;
|
|
@@ -5,7 +5,50 @@ interface DocRefForPathInput {
|
|
|
5
5
|
interface CollectionRefForPathInput {
|
|
6
6
|
readonly collection: (path: string) => CollectionReference;
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* Resolves a Firestore {@link CollectionReference} from a starting point and optional additional path segments.
|
|
10
|
+
*
|
|
11
|
+
* Supports nested subcollection paths by processing segments in pairs (doc ID, collection name).
|
|
12
|
+
*
|
|
13
|
+
* @param start - A Firestore object that can resolve collection paths (e.g., Firestore instance, DocumentReference).
|
|
14
|
+
* @param path - The initial collection path.
|
|
15
|
+
* @param pathSegments - Optional pairs of [docId, collectionName] for subcollection traversal.
|
|
16
|
+
* @throws Error if pathSegments length is odd (segments must come in pairs).
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const ref = collectionRefForPath<User>(firestore, 'users');
|
|
21
|
+
* const subRef = collectionRefForPath<Comment>(firestore, 'users', ['user123', 'comments']);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
8
24
|
export declare function collectionRefForPath<T>(start: CollectionRefForPathInput, path: string, pathSegments?: string[]): CollectionReference<T>;
|
|
25
|
+
/**
|
|
26
|
+
* Resolves a Firestore {@link DocumentReference} from a starting point, optional document path, and additional path segments.
|
|
27
|
+
*
|
|
28
|
+
* If no path is provided, auto-generates a document ID. Supports nested subcollection
|
|
29
|
+
* traversal via path segment pairs.
|
|
30
|
+
*
|
|
31
|
+
* @param start - A Firestore object that can resolve document paths (e.g., CollectionReference).
|
|
32
|
+
* @param path - Optional document ID or path within the collection.
|
|
33
|
+
* @param pathSegments - Optional pairs of [collectionName, docId] for subcollection traversal.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const ref = docRefForPath<User>(usersCollection, 'user123');
|
|
38
|
+
* const autoRef = docRefForPath<User>(usersCollection); // auto-generated ID
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
9
41
|
export declare function docRefForPath<T>(start: DocRefForPathInput, path?: string, pathSegments?: string[]): DocumentReference<T>;
|
|
42
|
+
/**
|
|
43
|
+
* Creates a {@link FirestoreAccessorDriver} for Google Cloud Firestore (Admin SDK).
|
|
44
|
+
*
|
|
45
|
+
* Implements document/collection resolution, transaction/batch factories, and context factories
|
|
46
|
+
* using the `@google-cloud/firestore` library.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const accessorDriver = googleCloudFirestoreAccessorDriver();
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
10
53
|
export declare function googleCloudFirestoreAccessorDriver(): FirestoreAccessorDriver;
|
|
11
54
|
export {};
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { type DocumentReference, type WriteResult as GoogleCloudWriteResult, type DocumentSnapshot } from '@google-cloud/firestore';
|
|
2
2
|
import { type Observable } from 'rxjs';
|
|
3
3
|
import { type WithFieldValue, type UpdateData, type FirestoreDocumentContext, type FirestoreDocumentDataAccessor, type FirestoreDocumentDataAccessorFactory, type FirestoreDocumentDeleteParams, type FirestoreDocumentUpdateParams, type SetOptions, type FirestoreDataConverter, type DocumentData, type FirestoreAccessorIncrementUpdate, type FirestoreAccessorArrayUpdate } from '@dereekb/firebase';
|
|
4
|
+
/**
|
|
5
|
+
* Default Google Cloud Firestore implementation of {@link FirestoreDocumentDataAccessor}.
|
|
6
|
+
*
|
|
7
|
+
* Performs all operations directly against the Firestore document reference without
|
|
8
|
+
* batching or transactional context. Supports real-time streaming via `onSnapshot`.
|
|
9
|
+
*/
|
|
4
10
|
export declare class DefaultFirestoreDocumentDataAccessor<T> implements FirestoreDocumentDataAccessor<T> {
|
|
5
11
|
private readonly _documentRef;
|
|
6
12
|
constructor(documentRef: DocumentReference<T>);
|
|
@@ -16,5 +22,19 @@ export declare class DefaultFirestoreDocumentDataAccessor<T> implements Firestor
|
|
|
16
22
|
arrayUpdate(data: FirestoreAccessorArrayUpdate<T>, params?: FirestoreDocumentUpdateParams): Promise<GoogleCloudWriteResult>;
|
|
17
23
|
update(data: UpdateData<object>, params?: FirestoreDocumentUpdateParams): Promise<GoogleCloudWriteResult>;
|
|
18
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Creates a {@link FirestoreDocumentDataAccessorFactory} that produces default (non-batched, non-transactional) accessors.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* const factory = defaultFirestoreAccessorFactory<User>();
|
|
31
|
+
* const accessor = factory.accessorFor(userDocRef);
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
19
34
|
export declare function defaultFirestoreAccessorFactory<T>(): FirestoreDocumentDataAccessorFactory<T>;
|
|
35
|
+
/**
|
|
36
|
+
* Creates a {@link FirestoreDocumentContext} with no special execution context (no batch, no transaction).
|
|
37
|
+
*
|
|
38
|
+
* Operations performed through this context execute immediately against Firestore.
|
|
39
|
+
*/
|
|
20
40
|
export declare function defaultFirestoreDocumentContext<T>(): FirestoreDocumentContext<T>;
|