@dereekb/firebase-server 13.1.0 → 13.2.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 +137 -0
- package/index.cjs.js.map +1 -1
- package/index.esm.js +137 -2
- package/index.esm.js.map +1 -1
- package/mailgun/package.json +8 -8
- package/model/package.json +8 -8
- package/package.json +9 -9
- package/src/lib/firestore/index.d.ts +1 -0
- package/src/lib/firestore/snapshot/index.d.ts +1 -0
- package/src/lib/firestore/snapshot/snapshot.field.d.ts +80 -0
- package/test/package.json +8 -8
- package/zoho/package.json +8 -8
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { type Maybe, type Getter, type GetterOrValue } from '@dereekb/util';
|
|
2
|
+
import { type FirestoreModelFieldMapFunctionsConfig } from '@dereekb/firebase';
|
|
3
|
+
/**
|
|
4
|
+
* The source for the encryption secret.
|
|
5
|
+
*
|
|
6
|
+
* - If a string, it is used directly as the hex-encoded key (64 hex chars = 32 bytes).
|
|
7
|
+
* - If a Getter, it is called each time to retrieve the key (useful for rotation or lazy loading).
|
|
8
|
+
* - If an object with `env`, the key is read from the specified environment variable.
|
|
9
|
+
*/
|
|
10
|
+
export type FirestoreEncryptedFieldSecretSource = string | Getter<string> | {
|
|
11
|
+
env: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Configuration for encrypted Firestore fields.
|
|
15
|
+
*
|
|
16
|
+
* @template T - The JSON-serializable value type stored in the model.
|
|
17
|
+
*/
|
|
18
|
+
export interface FirestoreEncryptedFieldConfig<T> {
|
|
19
|
+
/**
|
|
20
|
+
* The encryption secret source.
|
|
21
|
+
*
|
|
22
|
+
* Expects a 64-character hex string representing a 32-byte AES-256 key.
|
|
23
|
+
*/
|
|
24
|
+
readonly secret: FirestoreEncryptedFieldSecretSource;
|
|
25
|
+
/**
|
|
26
|
+
* Default model value when the Firestore data is null/undefined.
|
|
27
|
+
*/
|
|
28
|
+
readonly default?: GetterOrValue<T>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Configuration for optional encrypted Firestore fields.
|
|
32
|
+
*
|
|
33
|
+
* @template T - The JSON-serializable value type stored in the model.
|
|
34
|
+
*/
|
|
35
|
+
export interface OptionalFirestoreEncryptedFieldConfig<T> {
|
|
36
|
+
/**
|
|
37
|
+
* The encryption secret source.
|
|
38
|
+
*
|
|
39
|
+
* Expects a 64-character hex string representing a 32-byte AES-256 key.
|
|
40
|
+
*/
|
|
41
|
+
readonly secret: FirestoreEncryptedFieldSecretSource;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Creates a Firestore field mapping that encrypts/decrypts a JSON-serializable value
|
|
45
|
+
* using AES-256-GCM. The value is stored in Firestore as a base64-encoded string.
|
|
46
|
+
*
|
|
47
|
+
* The encryption key is resolved from the configured secret source on each read/write,
|
|
48
|
+
* allowing for key rotation via environment variable changes.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* const jwksField = firestoreEncryptedField<JWKSet>({
|
|
53
|
+
* secret: { env: 'FIRESTORE_ENCRYPTION_KEY' },
|
|
54
|
+
* default: () => ({ keys: [] })
|
|
55
|
+
* });
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @template T - The JSON-serializable value type.
|
|
59
|
+
* @param config - Encryption field configuration.
|
|
60
|
+
* @returns A field mapping configuration for encrypted values.
|
|
61
|
+
*/
|
|
62
|
+
export declare function firestoreEncryptedField<T>(config: FirestoreEncryptedFieldConfig<T>): FirestoreModelFieldMapFunctionsConfig<T, string>;
|
|
63
|
+
/**
|
|
64
|
+
* Creates a Firestore field mapping for an optional encrypted field.
|
|
65
|
+
*
|
|
66
|
+
* When the value is null/undefined, it is stored/read as null. When present, it is
|
|
67
|
+
* encrypted/decrypted using AES-256-GCM.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* const optionalSecretField = optionalFirestoreEncryptedField<OAuthClientSecret>({
|
|
72
|
+
* secret: { env: 'FIRESTORE_ENCRYPTION_KEY' }
|
|
73
|
+
* });
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* @template T - The JSON-serializable value type.
|
|
77
|
+
* @param config - Encryption field configuration.
|
|
78
|
+
* @returns A field mapping configuration for optional encrypted values.
|
|
79
|
+
*/
|
|
80
|
+
export declare function optionalFirestoreEncryptedField<T>(config: OptionalFirestoreEncryptedFieldConfig<T>): FirestoreModelFieldMapFunctionsConfig<Maybe<T>, Maybe<string>>;
|
package/test/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/firebase-server/test",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.2.0",
|
|
4
4
|
"peerDependencies": {
|
|
5
|
-
"@dereekb/date": "13.
|
|
6
|
-
"@dereekb/firebase": "13.
|
|
7
|
-
"@dereekb/firebase-server": "13.
|
|
8
|
-
"@dereekb/model": "13.
|
|
9
|
-
"@dereekb/nestjs": "13.
|
|
10
|
-
"@dereekb/rxjs": "13.
|
|
11
|
-
"@dereekb/util": "13.
|
|
5
|
+
"@dereekb/date": "13.2.0",
|
|
6
|
+
"@dereekb/firebase": "13.2.0",
|
|
7
|
+
"@dereekb/firebase-server": "13.2.0",
|
|
8
|
+
"@dereekb/model": "13.2.0",
|
|
9
|
+
"@dereekb/nestjs": "13.2.0",
|
|
10
|
+
"@dereekb/rxjs": "13.2.0",
|
|
11
|
+
"@dereekb/util": "13.2.0",
|
|
12
12
|
"@google-cloud/firestore": "^7.11.6",
|
|
13
13
|
"@google-cloud/storage": "^7.19.0",
|
|
14
14
|
"@nestjs/common": "^11.0.0",
|
package/zoho/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/firebase-server/zoho",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.2.0",
|
|
4
4
|
"peerDependencies": {
|
|
5
|
-
"@dereekb/date": "13.
|
|
6
|
-
"@dereekb/model": "13.
|
|
7
|
-
"@dereekb/nestjs": "13.
|
|
8
|
-
"@dereekb/rxjs": "13.
|
|
9
|
-
"@dereekb/firebase": "13.
|
|
10
|
-
"@dereekb/util": "13.
|
|
11
|
-
"@dereekb/zoho": "13.
|
|
5
|
+
"@dereekb/date": "13.2.0",
|
|
6
|
+
"@dereekb/model": "13.2.0",
|
|
7
|
+
"@dereekb/nestjs": "13.2.0",
|
|
8
|
+
"@dereekb/rxjs": "13.2.0",
|
|
9
|
+
"@dereekb/firebase": "13.2.0",
|
|
10
|
+
"@dereekb/util": "13.2.0",
|
|
11
|
+
"@dereekb/zoho": "13.2.0"
|
|
12
12
|
},
|
|
13
13
|
"exports": {
|
|
14
14
|
"./package.json": "./package.json",
|