@de-otio/trellis 0.4.0 → 0.5.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/dist/lib/crypto/voting/hash-utils.d.ts +3 -49
- package/dist/lib/crypto/voting/hash-utils.d.ts.map +1 -1
- package/dist/lib/crypto/voting/hash-utils.js +12 -54
- package/dist/lib/crypto/voting/hash-utils.js.map +1 -1
- package/dist/lib/email-privacy.d.ts +6 -44
- package/dist/lib/email-privacy.d.ts.map +1 -1
- package/dist/lib/email-privacy.js +10 -50
- package/dist/lib/email-privacy.js.map +1 -1
- package/package.json +1 -1
- package/prisma/migrations/20260412075058_init_redesign_schema/migration.sql +1547 -0
- package/prisma/migrations/20260412080000_seed_role_metadata/migration.sql +15 -0
- package/prisma/migrations/migration_lock.toml +3 -0
- package/prisma/schema.prisma +1408 -0
- package/dist/lib/crypto/encryption-service.d.ts +0 -100
- package/dist/lib/crypto/encryption-service.d.ts.map +0 -1
- package/dist/lib/crypto/encryption-service.js +0 -293
- package/dist/lib/crypto/encryption-service.js.map +0 -1
- package/dist/lib/crypto/index.d.ts +0 -22
- package/dist/lib/crypto/index.d.ts.map +0 -1
- package/dist/lib/crypto/index.js +0 -28
- package/dist/lib/crypto/index.js.map +0 -1
- package/dist/lib/crypto/types.d.ts +0 -71
- package/dist/lib/crypto/types.d.ts.map +0 -1
- package/dist/lib/crypto/types.js +0 -3
- package/dist/lib/crypto/types.js.map +0 -1
- package/dist/lib/crypto/versioning.d.ts +0 -112
- package/dist/lib/crypto/versioning.d.ts.map +0 -1
- package/dist/lib/crypto/versioning.js +0 -148
- package/dist/lib/crypto/versioning.js.map +0 -1
- package/dist/lib/encryption-key-service.d.ts +0 -115
- package/dist/lib/encryption-key-service.d.ts.map +0 -1
- package/dist/lib/encryption-key-service.js +0 -272
- package/dist/lib/encryption-key-service.js.map +0 -1
- package/dist/lib/followers-handler.d.ts +0 -21
- package/dist/lib/followers-handler.d.ts.map +0 -1
- package/dist/lib/followers-handler.js +0 -35
- package/dist/lib/followers-handler.js.map +0 -1
- package/dist/lib/routes/followers.d.ts +0 -6
- package/dist/lib/routes/followers.d.ts.map +0 -1
- package/dist/lib/routes/followers.js +0 -405
- package/dist/lib/routes/followers.js.map +0 -1
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Parameter Versioning
|
|
4
|
-
*
|
|
5
|
-
* Manages versioning of cryptographic parameters to enable safe upgrades
|
|
6
|
-
* and maintain backward compatibility.
|
|
7
|
-
*
|
|
8
|
-
* Version Format: Semantic versioning (MAJOR.MINOR.PATCH)
|
|
9
|
-
* - Major: Breaking changes (algorithm change)
|
|
10
|
-
* - Minor: Parameter changes (iteration count increase)
|
|
11
|
-
* - Patch: Bug fixes
|
|
12
|
-
*
|
|
13
|
-
* @see doc/02-technical/architecture/cryptography/08-implementation-recommendations.md
|
|
14
|
-
*/
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.ParameterVersionManager = exports.MINIMUM_VERSION = exports.CURRENT_VERSION = exports.SUPPORTED_VERSIONS = void 0;
|
|
17
|
-
/**
|
|
18
|
-
* Supported parameter versions
|
|
19
|
-
*/
|
|
20
|
-
exports.SUPPORTED_VERSIONS = {
|
|
21
|
-
"1.0.0": {
|
|
22
|
-
version: "1.0.0",
|
|
23
|
-
deprecated: false,
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Current default version
|
|
28
|
-
*/
|
|
29
|
-
exports.CURRENT_VERSION = "1.0.0";
|
|
30
|
-
/**
|
|
31
|
-
* Minimum supported version (for backward compatibility)
|
|
32
|
-
*/
|
|
33
|
-
exports.MINIMUM_VERSION = "1.0.0";
|
|
34
|
-
/**
|
|
35
|
-
* Parameter version manager
|
|
36
|
-
*/
|
|
37
|
-
class ParameterVersionManager {
|
|
38
|
-
/**
|
|
39
|
-
* Validate version format
|
|
40
|
-
*
|
|
41
|
-
* @param version - Version string to validate
|
|
42
|
-
* @returns true if valid semantic version format
|
|
43
|
-
*/
|
|
44
|
-
static isValidVersion(version) {
|
|
45
|
-
// Semantic versioning: MAJOR.MINOR.PATCH
|
|
46
|
-
const versionRegex = /^\d+\.\d+\.\d+$/;
|
|
47
|
-
return versionRegex.test(version);
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Compare two versions
|
|
51
|
-
*
|
|
52
|
-
* @param version1 - First version
|
|
53
|
-
* @param version2 - Second version
|
|
54
|
-
* @returns -1 if version1 < version2, 0 if equal, 1 if version1 > version2
|
|
55
|
-
*/
|
|
56
|
-
static compareVersions(version1, version2) {
|
|
57
|
-
if (!this.isValidVersion(version1) || !this.isValidVersion(version2)) {
|
|
58
|
-
throw new Error("Invalid version format");
|
|
59
|
-
}
|
|
60
|
-
const v1Parts = version1.split(".").map(Number);
|
|
61
|
-
const v2Parts = version2.split(".").map(Number);
|
|
62
|
-
for (let i = 0; i < 3; i++) {
|
|
63
|
-
if (v1Parts[i] < v2Parts[i])
|
|
64
|
-
return -1;
|
|
65
|
-
if (v1Parts[i] > v2Parts[i])
|
|
66
|
-
return 1;
|
|
67
|
-
}
|
|
68
|
-
return 0;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Check if version is supported
|
|
72
|
-
*
|
|
73
|
-
* @param version - Version to check
|
|
74
|
-
* @returns true if version is supported
|
|
75
|
-
*/
|
|
76
|
-
static isSupported(version) {
|
|
77
|
-
if (!this.isValidVersion(version)) {
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
80
|
-
// Check if version is in supported versions
|
|
81
|
-
if (exports.SUPPORTED_VERSIONS[version]) {
|
|
82
|
-
return !exports.SUPPORTED_VERSIONS[version].deprecated;
|
|
83
|
-
}
|
|
84
|
-
// Check if version is between minimum and current
|
|
85
|
-
const minCompare = this.compareVersions(version, exports.MINIMUM_VERSION);
|
|
86
|
-
const currentCompare = this.compareVersions(version, exports.CURRENT_VERSION);
|
|
87
|
-
return minCompare >= 0 && currentCompare <= 0;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Check if version is deprecated
|
|
91
|
-
*
|
|
92
|
-
* @param version - Version to check
|
|
93
|
-
* @returns true if version is deprecated
|
|
94
|
-
*/
|
|
95
|
-
static isDeprecated(version) {
|
|
96
|
-
const versionInfo = exports.SUPPORTED_VERSIONS[version];
|
|
97
|
-
return versionInfo?.deprecated === true;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Get version information
|
|
101
|
-
*
|
|
102
|
-
* @param version - Version string
|
|
103
|
-
* @returns Version information or null if not found
|
|
104
|
-
*/
|
|
105
|
-
static getVersionInfo(version) {
|
|
106
|
-
return exports.SUPPORTED_VERSIONS[version] || null;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Get current default version
|
|
110
|
-
*
|
|
111
|
-
* @returns Current version string
|
|
112
|
-
*/
|
|
113
|
-
static getCurrentVersion() {
|
|
114
|
-
return exports.CURRENT_VERSION;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Get minimum supported version
|
|
118
|
-
*
|
|
119
|
-
* @returns Minimum version string
|
|
120
|
-
*/
|
|
121
|
-
static getMinimumVersion() {
|
|
122
|
-
return exports.MINIMUM_VERSION;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Validate and normalize version
|
|
126
|
-
*
|
|
127
|
-
* If version is not provided, returns current version.
|
|
128
|
-
* If version is invalid, throws error.
|
|
129
|
-
*
|
|
130
|
-
* @param version - Optional version string
|
|
131
|
-
* @returns Validated version string
|
|
132
|
-
* @throws Error if version is invalid
|
|
133
|
-
*/
|
|
134
|
-
static validateAndNormalize(version) {
|
|
135
|
-
if (!version) {
|
|
136
|
-
return exports.CURRENT_VERSION;
|
|
137
|
-
}
|
|
138
|
-
if (!this.isValidVersion(version)) {
|
|
139
|
-
throw new Error(`Invalid version format: ${version}. Expected MAJOR.MINOR.PATCH`);
|
|
140
|
-
}
|
|
141
|
-
if (!this.isSupported(version)) {
|
|
142
|
-
throw new Error(`Unsupported version: ${version}. Minimum: ${exports.MINIMUM_VERSION}, Current: ${exports.CURRENT_VERSION}`);
|
|
143
|
-
}
|
|
144
|
-
return version;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
exports.ParameterVersionManager = ParameterVersionManager;
|
|
148
|
-
//# sourceMappingURL=versioning.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"versioning.js","sourceRoot":"","sources":["../../../src/lib/crypto/versioning.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;AA4BH;;GAEG;AACU,QAAA,kBAAkB,GAAqC;IAClE,OAAO,EAAE;QACP,OAAO,EAAE,OAAO;QAChB,UAAU,EAAE,KAAK;KAClB;CACF,CAAC;AAEF;;GAEG;AACU,QAAA,eAAe,GAAG,OAAO,CAAC;AAEvC;;GAEG;AACU,QAAA,eAAe,GAAG,OAAO,CAAC;AAEvC;;GAEG;AACH,MAAa,uBAAuB;IAClC;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,OAAe;QACnC,yCAAyC;QACzC,MAAM,YAAY,GAAG,iBAAiB,CAAC;QACvC,OAAO,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,eAAe,CAAC,QAAgB,EAAE,QAAgB;QACvD,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC;YACrE,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC5C,CAAC;QAED,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAChD,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,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B;QACtB,OAAO,uBAAe,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,iBAAiB;QACtB,OAAO,uBAAe,CAAC;IACzB,CAAC;IAED;;;;;;;;;OASG;IACH,MAAM,CAAC,oBAAoB,CAAC,OAAgB;QAC1C,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,uBAAe,CAAC;QACzB,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,KAAK,CACb,2BAA2B,OAAO,8BAA8B,CACjE,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CACb,wBAAwB,OAAO,cAAc,uBAAe,cAAc,uBAAe,EAAE,CAC5F,CAAC;QACJ,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AA/HD,0DA+HC"}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* EncryptionKeyService
|
|
3
|
-
*
|
|
4
|
-
* Manages UserEncryptionKey records for Border Safety Mode and Encrypted DM.
|
|
5
|
-
* Provides unified key management using the shared cryptographic library.
|
|
6
|
-
*
|
|
7
|
-
* Features:
|
|
8
|
-
* - Key creation and retrieval
|
|
9
|
-
* - Key derivation from passwords (using shared crypto library)
|
|
10
|
-
* - Key rotation support
|
|
11
|
-
* - Multiple key types (border_safety, e2e_messages)
|
|
12
|
-
* - Multiple key purposes (data_encryption, backup, export, message_encryption)
|
|
13
|
-
*
|
|
14
|
-
* @see packages/crypto for shared cryptographic operations
|
|
15
|
-
* @see doc/02-technical/architecture/cryptography/ for design documentation
|
|
16
|
-
*/
|
|
17
|
-
import { PrismaClient, UserEncryptionKey } from "@prisma/client";
|
|
18
|
-
import type { KDFParams } from "./crypto/index.js";
|
|
19
|
-
import { type LoggerEnv } from "./logger";
|
|
20
|
-
/**
|
|
21
|
-
* Key type values
|
|
22
|
-
*/
|
|
23
|
-
export type KeyType = "border_safety" | "e2e_messages";
|
|
24
|
-
/**
|
|
25
|
-
* Key purpose values
|
|
26
|
-
*/
|
|
27
|
-
export type KeyPurpose = "data_encryption" | "backup" | "export" | "message_encryption";
|
|
28
|
-
/**
|
|
29
|
-
* EncryptionKeyService class for managing user encryption keys
|
|
30
|
-
*/
|
|
31
|
-
export declare class EncryptionKeyService {
|
|
32
|
-
private prisma;
|
|
33
|
-
private logger;
|
|
34
|
-
constructor(prisma: PrismaClient, env?: LoggerEnv);
|
|
35
|
-
/**
|
|
36
|
-
* Get or create an encryption key for a user
|
|
37
|
-
*
|
|
38
|
-
* If a key with the same userId, contextId, keyPurpose, and keyType exists,
|
|
39
|
-
* it is returned. Otherwise, a new key is created.
|
|
40
|
-
*
|
|
41
|
-
* Note: This method does NOT derive the key from a password. The key material
|
|
42
|
-
* should be derived client-side and passed as encryptedKey (encrypted with
|
|
43
|
-
* the user's password-derived key).
|
|
44
|
-
*
|
|
45
|
-
* @param userId - User ID
|
|
46
|
-
* @param contextId - Context ID ('primary' or 'decoy')
|
|
47
|
-
* @param keyPurpose - Key purpose ('data_encryption', 'backup', 'export', 'message_encryption')
|
|
48
|
-
* @param keyType - Key type ('border_safety' or 'e2e_messages')
|
|
49
|
-
* @param encryptedKey - Encrypted key material (encrypted with user's password-derived key)
|
|
50
|
-
* @param kdfParams - Key derivation parameters (JSON string)
|
|
51
|
-
* @param algorithm - Encryption algorithm (default: 'AES-256-GCM')
|
|
52
|
-
* @returns UserEncryptionKey record
|
|
53
|
-
* @throws Error if key creation fails
|
|
54
|
-
*/
|
|
55
|
-
getOrCreateKey(userId: string, contextId: string, keyPurpose: KeyPurpose, keyType: KeyType, encryptedKey: string, kdfParams: string, algorithm?: string): Promise<UserEncryptionKey>;
|
|
56
|
-
/**
|
|
57
|
-
* Derive encryption key from password using shared cryptographic library
|
|
58
|
-
*
|
|
59
|
-
* This is a convenience method that uses EncryptionService.deriveKey().
|
|
60
|
-
* The derived key is a CryptoKey and cannot be exported (for security).
|
|
61
|
-
*
|
|
62
|
-
* @param password - Password to derive key from
|
|
63
|
-
* @param salt - Salt (base64-encoded, minimum 128 bits / 16 bytes)
|
|
64
|
-
* @param kdfParams - Key derivation parameters
|
|
65
|
-
* @returns CryptoKey for AES-256-GCM
|
|
66
|
-
* @throws Error if key derivation fails
|
|
67
|
-
*/
|
|
68
|
-
deriveKeyFromPassword(password: string, salt: string, kdfParams: KDFParams): Promise<CryptoKey>;
|
|
69
|
-
/**
|
|
70
|
-
* Rotate an encryption key
|
|
71
|
-
*
|
|
72
|
-
* Updates the key record with new encrypted key material and sets rotatedAt timestamp.
|
|
73
|
-
* The old key material is replaced (not kept for backward compatibility).
|
|
74
|
-
*
|
|
75
|
-
* @param keyId - Key ID to rotate
|
|
76
|
-
* @param newEncryptedKey - New encrypted key material
|
|
77
|
-
* @param newKdfParams - New KDF parameters (optional, if key derivation changed)
|
|
78
|
-
* @returns Updated UserEncryptionKey record
|
|
79
|
-
* @throws Error if key rotation fails
|
|
80
|
-
*/
|
|
81
|
-
rotateKey(keyId: string, newEncryptedKey: string, newKdfParams?: string): Promise<UserEncryptionKey>;
|
|
82
|
-
/**
|
|
83
|
-
* Get encryption key by type for a user
|
|
84
|
-
*
|
|
85
|
-
* Returns the first key matching the userId and keyType.
|
|
86
|
-
* If multiple keys exist (different contexts or purposes), use getKeysByUser().
|
|
87
|
-
*
|
|
88
|
-
* @param userId - User ID
|
|
89
|
-
* @param keyType - Key type ('border_safety' or 'e2e_messages')
|
|
90
|
-
* @returns UserEncryptionKey or null if not found
|
|
91
|
-
*/
|
|
92
|
-
getKeyByType(userId: string, keyType: KeyType): Promise<UserEncryptionKey | null>;
|
|
93
|
-
/**
|
|
94
|
-
* Get all encryption keys for a user
|
|
95
|
-
*
|
|
96
|
-
* @param userId - User ID
|
|
97
|
-
* @returns Array of UserEncryptionKey records
|
|
98
|
-
*/
|
|
99
|
-
getKeysByUser(userId: string): Promise<UserEncryptionKey[]>;
|
|
100
|
-
/**
|
|
101
|
-
* Get encryption key by ID
|
|
102
|
-
*
|
|
103
|
-
* @param keyId - Key ID
|
|
104
|
-
* @returns UserEncryptionKey or null if not found
|
|
105
|
-
*/
|
|
106
|
-
getKeyById(keyId: string): Promise<UserEncryptionKey | null>;
|
|
107
|
-
/**
|
|
108
|
-
* Delete an encryption key
|
|
109
|
-
*
|
|
110
|
-
* @param keyId - Key ID
|
|
111
|
-
* @throws Error if key deletion fails
|
|
112
|
-
*/
|
|
113
|
-
deleteKey(keyId: string): Promise<void>;
|
|
114
|
-
}
|
|
115
|
-
//# sourceMappingURL=encryption-key-service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encryption-key-service.d.ts","sourceRoot":"","sources":["../../src/lib/encryption-key-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAU,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AAElD;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,eAAe,GAAG,cAAc,CAAC;AAEvD;;GAEG;AACH,MAAM,MAAM,UAAU,GAClB,iBAAiB,GACjB,QAAQ,GACR,QAAQ,GACR,oBAAoB,CAAC;AAEzB;;GAEG;AACH,qBAAa,oBAAoB;IAI7B,OAAO,CAAC,MAAM;IAHhB,OAAO,CAAC,MAAM,CAAS;gBAGb,MAAM,EAAE,YAAY,EAC5B,GAAG,CAAC,EAAE,SAAS;IAKjB;;;;;;;;;;;;;;;;;;;OAmBG;IACG,cAAc,CAClB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,EACjB,SAAS,GAAE,MAAsB,GAChC,OAAO,CAAC,iBAAiB,CAAC;IA6D7B;;;;;;;;;;;OAWG;IACG,qBAAqB,CACzB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,SAAS,GACnB,OAAO,CAAC,SAAS,CAAC;IAarB;;;;;;;;;;;OAWG;IACG,SAAS,CACb,KAAK,EAAE,MAAM,EACb,eAAe,EAAE,MAAM,EACvB,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,iBAAiB,CAAC;IAqC7B;;;;;;;;;OASG;IACG,YAAY,CAChB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAsBpC;;;;;OAKG;IACG,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAuBjE;;;;;OAKG;IACG,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAkBlE;;;;;OAKG;IACG,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAiB9C"}
|
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* EncryptionKeyService
|
|
4
|
-
*
|
|
5
|
-
* Manages UserEncryptionKey records for Border Safety Mode and Encrypted DM.
|
|
6
|
-
* Provides unified key management using the shared cryptographic library.
|
|
7
|
-
*
|
|
8
|
-
* Features:
|
|
9
|
-
* - Key creation and retrieval
|
|
10
|
-
* - Key derivation from passwords (using shared crypto library)
|
|
11
|
-
* - Key rotation support
|
|
12
|
-
* - Multiple key types (border_safety, e2e_messages)
|
|
13
|
-
* - Multiple key purposes (data_encryption, backup, export, message_encryption)
|
|
14
|
-
*
|
|
15
|
-
* @see packages/crypto for shared cryptographic operations
|
|
16
|
-
* @see doc/02-technical/architecture/cryptography/ for design documentation
|
|
17
|
-
*/
|
|
18
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.EncryptionKeyService = void 0;
|
|
20
|
-
const index_js_1 = require("./crypto/index.js");
|
|
21
|
-
const logger_1 = require("./logger");
|
|
22
|
-
/**
|
|
23
|
-
* EncryptionKeyService class for managing user encryption keys
|
|
24
|
-
*/
|
|
25
|
-
class EncryptionKeyService {
|
|
26
|
-
prisma;
|
|
27
|
-
logger;
|
|
28
|
-
constructor(prisma, env) {
|
|
29
|
-
this.prisma = prisma;
|
|
30
|
-
this.logger = logger_1.Logger.getInstance(env);
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Get or create an encryption key for a user
|
|
34
|
-
*
|
|
35
|
-
* If a key with the same userId, contextId, keyPurpose, and keyType exists,
|
|
36
|
-
* it is returned. Otherwise, a new key is created.
|
|
37
|
-
*
|
|
38
|
-
* Note: This method does NOT derive the key from a password. The key material
|
|
39
|
-
* should be derived client-side and passed as encryptedKey (encrypted with
|
|
40
|
-
* the user's password-derived key).
|
|
41
|
-
*
|
|
42
|
-
* @param userId - User ID
|
|
43
|
-
* @param contextId - Context ID ('primary' or 'decoy')
|
|
44
|
-
* @param keyPurpose - Key purpose ('data_encryption', 'backup', 'export', 'message_encryption')
|
|
45
|
-
* @param keyType - Key type ('border_safety' or 'e2e_messages')
|
|
46
|
-
* @param encryptedKey - Encrypted key material (encrypted with user's password-derived key)
|
|
47
|
-
* @param kdfParams - Key derivation parameters (JSON string)
|
|
48
|
-
* @param algorithm - Encryption algorithm (default: 'AES-256-GCM')
|
|
49
|
-
* @returns UserEncryptionKey record
|
|
50
|
-
* @throws Error if key creation fails
|
|
51
|
-
*/
|
|
52
|
-
async getOrCreateKey(userId, contextId, keyPurpose, keyType, encryptedKey, kdfParams, algorithm = "AES-256-GCM") {
|
|
53
|
-
try {
|
|
54
|
-
// Try to find existing key
|
|
55
|
-
const existing = await this.prisma.userEncryptionKey.findUnique({
|
|
56
|
-
where: {
|
|
57
|
-
userId_contextId_keyPurpose_keyType: {
|
|
58
|
-
userId,
|
|
59
|
-
contextId,
|
|
60
|
-
keyPurpose,
|
|
61
|
-
keyType,
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
if (existing) {
|
|
66
|
-
this.logger.debug("Encryption key found", {
|
|
67
|
-
keyId: existing.id,
|
|
68
|
-
userId,
|
|
69
|
-
contextId,
|
|
70
|
-
keyPurpose,
|
|
71
|
-
keyType,
|
|
72
|
-
});
|
|
73
|
-
return existing;
|
|
74
|
-
}
|
|
75
|
-
// Create new key
|
|
76
|
-
const newKey = await this.prisma.userEncryptionKey.create({
|
|
77
|
-
data: {
|
|
78
|
-
userId,
|
|
79
|
-
contextId,
|
|
80
|
-
keyPurpose,
|
|
81
|
-
keyType,
|
|
82
|
-
encryptedKey,
|
|
83
|
-
kdfParams,
|
|
84
|
-
algorithm,
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
this.logger.info("Encryption key created", {
|
|
88
|
-
keyId: newKey.id,
|
|
89
|
-
userId,
|
|
90
|
-
contextId,
|
|
91
|
-
keyPurpose,
|
|
92
|
-
keyType,
|
|
93
|
-
});
|
|
94
|
-
return newKey;
|
|
95
|
-
}
|
|
96
|
-
catch (error) {
|
|
97
|
-
this.logger.error("Failed to get or create encryption key", {
|
|
98
|
-
userId,
|
|
99
|
-
contextId,
|
|
100
|
-
keyPurpose,
|
|
101
|
-
keyType,
|
|
102
|
-
error: error instanceof Error ? error.message : String(error),
|
|
103
|
-
});
|
|
104
|
-
throw new Error(`Failed to get or create encryption key: ${error instanceof Error ? error.message : String(error)}`);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Derive encryption key from password using shared cryptographic library
|
|
109
|
-
*
|
|
110
|
-
* This is a convenience method that uses EncryptionService.deriveKey().
|
|
111
|
-
* The derived key is a CryptoKey and cannot be exported (for security).
|
|
112
|
-
*
|
|
113
|
-
* @param password - Password to derive key from
|
|
114
|
-
* @param salt - Salt (base64-encoded, minimum 128 bits / 16 bytes)
|
|
115
|
-
* @param kdfParams - Key derivation parameters
|
|
116
|
-
* @returns CryptoKey for AES-256-GCM
|
|
117
|
-
* @throws Error if key derivation fails
|
|
118
|
-
*/
|
|
119
|
-
async deriveKeyFromPassword(password, salt, kdfParams) {
|
|
120
|
-
try {
|
|
121
|
-
return await index_js_1.EncryptionService.deriveKey(password, salt, kdfParams);
|
|
122
|
-
}
|
|
123
|
-
catch (error) {
|
|
124
|
-
this.logger.error("Failed to derive key from password", {
|
|
125
|
-
error: error instanceof Error ? error.message : String(error),
|
|
126
|
-
});
|
|
127
|
-
throw new Error(`Failed to derive key from password: ${error instanceof Error ? error.message : String(error)}`);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Rotate an encryption key
|
|
132
|
-
*
|
|
133
|
-
* Updates the key record with new encrypted key material and sets rotatedAt timestamp.
|
|
134
|
-
* The old key material is replaced (not kept for backward compatibility).
|
|
135
|
-
*
|
|
136
|
-
* @param keyId - Key ID to rotate
|
|
137
|
-
* @param newEncryptedKey - New encrypted key material
|
|
138
|
-
* @param newKdfParams - New KDF parameters (optional, if key derivation changed)
|
|
139
|
-
* @returns Updated UserEncryptionKey record
|
|
140
|
-
* @throws Error if key rotation fails
|
|
141
|
-
*/
|
|
142
|
-
async rotateKey(keyId, newEncryptedKey, newKdfParams) {
|
|
143
|
-
try {
|
|
144
|
-
const existing = await this.prisma.userEncryptionKey.findUnique({
|
|
145
|
-
where: { id: keyId },
|
|
146
|
-
});
|
|
147
|
-
if (!existing) {
|
|
148
|
-
throw new Error(`Encryption key not found: ${keyId}`);
|
|
149
|
-
}
|
|
150
|
-
const updated = await this.prisma.userEncryptionKey.update({
|
|
151
|
-
where: { id: keyId },
|
|
152
|
-
data: {
|
|
153
|
-
encryptedKey: newEncryptedKey,
|
|
154
|
-
kdfParams: newKdfParams ?? existing.kdfParams,
|
|
155
|
-
rotatedAt: new Date(),
|
|
156
|
-
},
|
|
157
|
-
});
|
|
158
|
-
this.logger.info("Encryption key rotated", {
|
|
159
|
-
keyId,
|
|
160
|
-
userId: existing.userId,
|
|
161
|
-
rotatedAt: updated.rotatedAt,
|
|
162
|
-
});
|
|
163
|
-
return updated;
|
|
164
|
-
}
|
|
165
|
-
catch (error) {
|
|
166
|
-
this.logger.error("Failed to rotate encryption key", {
|
|
167
|
-
keyId,
|
|
168
|
-
error: error instanceof Error ? error.message : String(error),
|
|
169
|
-
});
|
|
170
|
-
throw new Error(`Failed to rotate encryption key: ${error instanceof Error ? error.message : String(error)}`);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Get encryption key by type for a user
|
|
175
|
-
*
|
|
176
|
-
* Returns the first key matching the userId and keyType.
|
|
177
|
-
* If multiple keys exist (different contexts or purposes), use getKeysByUser().
|
|
178
|
-
*
|
|
179
|
-
* @param userId - User ID
|
|
180
|
-
* @param keyType - Key type ('border_safety' or 'e2e_messages')
|
|
181
|
-
* @returns UserEncryptionKey or null if not found
|
|
182
|
-
*/
|
|
183
|
-
async getKeyByType(userId, keyType) {
|
|
184
|
-
try {
|
|
185
|
-
const key = await this.prisma.userEncryptionKey.findFirst({
|
|
186
|
-
where: {
|
|
187
|
-
userId,
|
|
188
|
-
keyType,
|
|
189
|
-
},
|
|
190
|
-
});
|
|
191
|
-
return key;
|
|
192
|
-
}
|
|
193
|
-
catch (error) {
|
|
194
|
-
this.logger.error("Failed to get key by type", {
|
|
195
|
-
userId,
|
|
196
|
-
keyType,
|
|
197
|
-
error: error instanceof Error ? error.message : String(error),
|
|
198
|
-
});
|
|
199
|
-
throw new Error(`Failed to get key by type: ${error instanceof Error ? error.message : String(error)}`);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Get all encryption keys for a user
|
|
204
|
-
*
|
|
205
|
-
* @param userId - User ID
|
|
206
|
-
* @returns Array of UserEncryptionKey records
|
|
207
|
-
*/
|
|
208
|
-
async getKeysByUser(userId) {
|
|
209
|
-
try {
|
|
210
|
-
const keys = await this.prisma.userEncryptionKey.findMany({
|
|
211
|
-
where: {
|
|
212
|
-
userId,
|
|
213
|
-
},
|
|
214
|
-
orderBy: {
|
|
215
|
-
createdAt: "desc",
|
|
216
|
-
},
|
|
217
|
-
});
|
|
218
|
-
return keys;
|
|
219
|
-
}
|
|
220
|
-
catch (error) {
|
|
221
|
-
this.logger.error("Failed to get keys by user", {
|
|
222
|
-
userId,
|
|
223
|
-
error: error instanceof Error ? error.message : String(error),
|
|
224
|
-
});
|
|
225
|
-
throw new Error(`Failed to get keys by user: ${error instanceof Error ? error.message : String(error)}`);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* Get encryption key by ID
|
|
230
|
-
*
|
|
231
|
-
* @param keyId - Key ID
|
|
232
|
-
* @returns UserEncryptionKey or null if not found
|
|
233
|
-
*/
|
|
234
|
-
async getKeyById(keyId) {
|
|
235
|
-
try {
|
|
236
|
-
const key = await this.prisma.userEncryptionKey.findUnique({
|
|
237
|
-
where: { id: keyId },
|
|
238
|
-
});
|
|
239
|
-
return key;
|
|
240
|
-
}
|
|
241
|
-
catch (error) {
|
|
242
|
-
this.logger.error("Failed to get key by ID", {
|
|
243
|
-
keyId,
|
|
244
|
-
error: error instanceof Error ? error.message : String(error),
|
|
245
|
-
});
|
|
246
|
-
throw new Error(`Failed to get key by ID: ${error instanceof Error ? error.message : String(error)}`);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Delete an encryption key
|
|
251
|
-
*
|
|
252
|
-
* @param keyId - Key ID
|
|
253
|
-
* @throws Error if key deletion fails
|
|
254
|
-
*/
|
|
255
|
-
async deleteKey(keyId) {
|
|
256
|
-
try {
|
|
257
|
-
await this.prisma.userEncryptionKey.delete({
|
|
258
|
-
where: { id: keyId },
|
|
259
|
-
});
|
|
260
|
-
this.logger.info("Encryption key deleted", { keyId });
|
|
261
|
-
}
|
|
262
|
-
catch (error) {
|
|
263
|
-
this.logger.error("Failed to delete encryption key", {
|
|
264
|
-
keyId,
|
|
265
|
-
error: error instanceof Error ? error.message : String(error),
|
|
266
|
-
});
|
|
267
|
-
throw new Error(`Failed to delete encryption key: ${error instanceof Error ? error.message : String(error)}`);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
exports.EncryptionKeyService = EncryptionKeyService;
|
|
272
|
-
//# sourceMappingURL=encryption-key-service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encryption-key-service.js","sourceRoot":"","sources":["../../src/lib/encryption-key-service.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAGH,gDAAsD;AAEtD,qCAAkD;AAgBlD;;GAEG;AACH,MAAa,oBAAoB;IAIrB;IAHF,MAAM,CAAS;IAEvB,YACU,MAAoB,EAC5B,GAAe;QADP,WAAM,GAAN,MAAM,CAAc;QAG5B,IAAI,CAAC,MAAM,GAAG,eAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACxC,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,KAAK,CAAC,cAAc,CAClB,MAAc,EACd,SAAiB,EACjB,UAAsB,EACtB,OAAgB,EAChB,YAAoB,EACpB,SAAiB,EACjB,YAAoB,aAAa;QAEjC,IAAI,CAAC;YACH,2BAA2B;YAC3B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,UAAU,CAAC;gBAC9D,KAAK,EAAE;oBACL,mCAAmC,EAAE;wBACnC,MAAM;wBACN,SAAS;wBACT,UAAU;wBACV,OAAO;qBACR;iBACF;aACF,CAAC,CAAC;YAEH,IAAI,QAAQ,EAAE,CAAC;gBACb,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,sBAAs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,CAAC,SAAS,CAAC,KAAa;QAC3B,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAAC;gBACzC,KAAK,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE;aACrB,CAAC,CAAC;YAEH,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,wBAAwB,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QACxD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,iCAAiC,EAAE;gBACnD,KAAK;gBACL,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;aAC9D,CAAC,CAAC;YACH,MAAM,IAAI,KAAK,CACb,oCAAoC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAC7F,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AApSD,oDAoSC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Followers Handler — STUBBED pending redesign
|
|
3
|
-
*
|
|
4
|
-
* The Follow model has been removed. Follow relationships are replaced by
|
|
5
|
-
* scored Relationships in the graph database (Neptune). This handler will
|
|
6
|
-
* be reimplemented as RelationshipHandler in Phase 3 of the redesign.
|
|
7
|
-
*
|
|
8
|
-
* All methods return 501 Not Implemented.
|
|
9
|
-
*/
|
|
10
|
-
import type { Env } from "../env";
|
|
11
|
-
import type { RequestContext } from "./request-context";
|
|
12
|
-
import type { Session } from "./session-manager";
|
|
13
|
-
export declare class FollowersHandler {
|
|
14
|
-
handleFollow(_request: Request, _session: Session, _env: Env, _requestContext: RequestContext): Promise<Response>;
|
|
15
|
-
handleUnfollow(_request: Request, _session: Session, _env: Env, _requestContext: RequestContext): Promise<Response>;
|
|
16
|
-
handleGetFollowing(_request: Request, _session: Session, _env: Env, _requestContext: RequestContext): Promise<Response>;
|
|
17
|
-
handleGetFollowers(_request: Request, _session: Session, _env: Env, _requestContext: RequestContext): Promise<Response>;
|
|
18
|
-
handleGetStatus(_request: Request, _session: Session, _env: Env, _requestContext: RequestContext): Promise<Response>;
|
|
19
|
-
handleGetCount(_request: Request, _session: Session, _env: Env, _requestContext: RequestContext): Promise<Response>;
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=followers-handler.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"followers-handler.d.ts","sourceRoot":"","sources":["../../src/lib/followers-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAOjD,qBAAa,gBAAgB;IACrB,YAAY,CAChB,QAAQ,EAAE,OAAO,EACjB,QAAQ,EAAE,OAAO,EACjB,IAAI,EAAE,GAAG,EACT,eAAe,EAAE,cAAc,GAC9B,OAAO,CAAC,QAAQ,CAAC;IAId,cAAc,CAClB,QAAQ,EAAE,OAAO,EACjB,QAAQ,EAAE,OAAO,EACjB,IAAI,EAAE,GAAG,EACT,eAAe,EAAE,cAAc,GAC9B,OAAO,CAAC,QAAQ,CAAC;IAId,kBAAkB,CACtB,QAAQ,EAAE,OAAO,EACjB,QAAQ,EAAE,OAAO,EACjB,IAAI,EAAE,GAAG,EACT,eAAe,EAAE,cAAc,GAC9B,OAAO,CAAC,QAAQ,CAAC;IAId,kBAAkB,CACtB,QAAQ,EAAE,OAAO,EACjB,QAAQ,EAAE,OAAO,EACjB,IAAI,EAAE,GAAG,EACT,eAAe,EAAE,cAAc,GAC9B,OAAO,CAAC,QAAQ,CAAC;IAId,eAAe,CACnB,QAAQ,EAAE,OAAO,EACjB,QAAQ,EAAE,OAAO,EACjB,IAAI,EAAE,GAAG,EACT,eAAe,EAAE,cAAc,GAC9B,OAAO,CAAC,QAAQ,CAAC;IAId,cAAc,CAClB,QAAQ,EAAE,OAAO,EACjB,QAAQ,EAAE,OAAO,EACjB,IAAI,EAAE,GAAG,EACT,eAAe,EAAE,cAAc,GAC9B,OAAO,CAAC,QAAQ,CAAC;CAGrB"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Followers Handler — STUBBED pending redesign
|
|
4
|
-
*
|
|
5
|
-
* The Follow model has been removed. Follow relationships are replaced by
|
|
6
|
-
* scored Relationships in the graph database (Neptune). This handler will
|
|
7
|
-
* be reimplemented as RelationshipHandler in Phase 3 of the redesign.
|
|
8
|
-
*
|
|
9
|
-
* All methods return 501 Not Implemented.
|
|
10
|
-
*/
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.FollowersHandler = void 0;
|
|
13
|
-
const NOT_IMPLEMENTED = new Response(JSON.stringify({ error: "Not implemented - pending redesign" }), { status: 501, headers: { "content-type": "application/json" } });
|
|
14
|
-
class FollowersHandler {
|
|
15
|
-
async handleFollow(_request, _session, _env, _requestContext) {
|
|
16
|
-
return NOT_IMPLEMENTED;
|
|
17
|
-
}
|
|
18
|
-
async handleUnfollow(_request, _session, _env, _requestContext) {
|
|
19
|
-
return NOT_IMPLEMENTED;
|
|
20
|
-
}
|
|
21
|
-
async handleGetFollowing(_request, _session, _env, _requestContext) {
|
|
22
|
-
return NOT_IMPLEMENTED;
|
|
23
|
-
}
|
|
24
|
-
async handleGetFollowers(_request, _session, _env, _requestContext) {
|
|
25
|
-
return NOT_IMPLEMENTED;
|
|
26
|
-
}
|
|
27
|
-
async handleGetStatus(_request, _session, _env, _requestContext) {
|
|
28
|
-
return NOT_IMPLEMENTED;
|
|
29
|
-
}
|
|
30
|
-
async handleGetCount(_request, _session, _env, _requestContext) {
|
|
31
|
-
return NOT_IMPLEMENTED;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
exports.FollowersHandler = FollowersHandler;
|
|
35
|
-
//# sourceMappingURL=followers-handler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"followers-handler.js","sourceRoot":"","sources":["../../src/lib/followers-handler.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAMH,MAAM,eAAe,GAAG,IAAI,QAAQ,CAClC,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,oCAAoC,EAAE,CAAC,EAC/D,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE,EAAE,CACjE,CAAC;AAEF,MAAa,gBAAgB;IAC3B,KAAK,CAAC,YAAY,CAChB,QAAiB,EACjB,QAAiB,EACjB,IAAS,EACT,eAA+B;QAE/B,OAAO,eAAe,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,QAAiB,EACjB,QAAiB,EACjB,IAAS,EACT,eAA+B;QAE/B,OAAO,eAAe,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,kBAAkB,CACtB,QAAiB,EACjB,QAAiB,EACjB,IAAS,EACT,eAA+B;QAE/B,OAAO,eAAe,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,kBAAkB,CACtB,QAAiB,EACjB,QAAiB,EACjB,IAAS,EACT,eAA+B;QAE/B,OAAO,eAAe,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,eAAe,CACnB,QAAiB,EACjB,QAAiB,EACjB,IAAS,EACT,eAA+B;QAE/B,OAAO,eAAe,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,QAAiB,EACjB,QAAiB,EACjB,IAAS,EACT,eAA+B;QAE/B,OAAO,eAAe,CAAC;IACzB,CAAC;CACF;AAtDD,4CAsDC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"followers.d.ts","sourceRoot":"","sources":["../../../src/lib/routes/followers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAaH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC,eAAO,MAAM,eAAe,EAAE,KAAK,EA8hBlC,CAAC"}
|