@credo-ts/node 0.6.0-alpha-20251010154241 → 0.6.0-alpha-20251010164336
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/build/NodeFileSystem.js +92 -126
- package/build/NodeFileSystem.mjs +86 -0
- package/build/NodeFileSystem.mjs.map +1 -0
- package/build/_virtual/_@oxc-project_runtime@0.94.0/helpers/assertClassBrand.js +9 -0
- package/build/_virtual/_@oxc-project_runtime@0.94.0/helpers/assertClassBrand.mjs +8 -0
- package/build/_virtual/_@oxc-project_runtime@0.94.0/helpers/checkPrivateRedeclaration.js +8 -0
- package/build/_virtual/_@oxc-project_runtime@0.94.0/helpers/checkPrivateRedeclaration.mjs +7 -0
- package/build/_virtual/_@oxc-project_runtime@0.94.0/helpers/classPrivateFieldGet2.js +9 -0
- package/build/_virtual/_@oxc-project_runtime@0.94.0/helpers/classPrivateFieldGet2.mjs +9 -0
- package/build/_virtual/_@oxc-project_runtime@0.94.0/helpers/classPrivateFieldInitSpec.js +9 -0
- package/build/_virtual/_@oxc-project_runtime@0.94.0/helpers/classPrivateFieldInitSpec.mjs +9 -0
- package/build/_virtual/_@oxc-project_runtime@0.94.0/helpers/classPrivateFieldSet2.js +9 -0
- package/build/_virtual/_@oxc-project_runtime@0.94.0/helpers/classPrivateFieldSet2.mjs +9 -0
- package/build/_virtual/rolldown_runtime.js +25 -0
- package/build/index.d.mts +12 -0
- package/build/index.d.mts.map +1 -0
- package/build/index.d.ts +11 -7
- package/build/index.d.ts.map +1 -0
- package/build/index.js +23 -20
- package/build/index.mjs +19 -0
- package/build/index.mjs.map +1 -0
- package/build/kms/NodeInMemoryKeyManagementStorage.d.mts +81 -0
- package/build/kms/NodeInMemoryKeyManagementStorage.d.mts.map +1 -0
- package/build/kms/NodeInMemoryKeyManagementStorage.d.ts +80 -74
- package/build/kms/NodeInMemoryKeyManagementStorage.d.ts.map +1 -0
- package/build/kms/NodeInMemoryKeyManagementStorage.js +32 -36
- package/build/kms/NodeInMemoryKeyManagementStorage.mjs +34 -0
- package/build/kms/NodeInMemoryKeyManagementStorage.mjs.map +1 -0
- package/build/kms/NodeKeyManagementService.d.mts +24 -0
- package/build/kms/NodeKeyManagementService.d.mts.map +1 -0
- package/build/kms/NodeKeyManagementService.d.ts +23 -19
- package/build/kms/NodeKeyManagementService.d.ts.map +1 -0
- package/build/kms/NodeKeyManagementService.js +280 -380
- package/build/kms/NodeKeyManagementService.mjs +279 -0
- package/build/kms/NodeKeyManagementService.mjs.map +1 -0
- package/build/kms/NodeKeyManagementStorage.d.mts +15 -0
- package/build/kms/NodeKeyManagementStorage.d.mts.map +1 -0
- package/build/kms/NodeKeyManagementStorage.d.ts +14 -9
- package/build/kms/NodeKeyManagementStorage.d.ts.map +1 -0
- package/build/kms/crypto/createKey.js +54 -73
- package/build/kms/crypto/createKey.mjs +59 -0
- package/build/kms/crypto/createKey.mjs.map +1 -0
- package/build/kms/crypto/decrypt.js +69 -82
- package/build/kms/crypto/decrypt.mjs +68 -0
- package/build/kms/crypto/decrypt.mjs.map +1 -0
- package/build/kms/crypto/deriveKey.js +141 -212
- package/build/kms/crypto/deriveKey.mjs +159 -0
- package/build/kms/crypto/deriveKey.mjs.map +1 -0
- package/build/kms/crypto/encrypt.js +99 -111
- package/build/kms/crypto/encrypt.mjs +98 -0
- package/build/kms/crypto/encrypt.mjs.map +1 -0
- package/build/kms/crypto/sign.js +63 -76
- package/build/kms/crypto/sign.mjs +63 -0
- package/build/kms/crypto/sign.mjs.map +1 -0
- package/build/kms/crypto/verify.js +32 -41
- package/build/kms/crypto/verify.mjs +30 -0
- package/build/kms/crypto/verify.mjs.map +1 -0
- package/build/transport/DidCommHttpInboundTransport.d.mts +31 -0
- package/build/transport/DidCommHttpInboundTransport.d.mts.map +1 -0
- package/build/transport/DidCommHttpInboundTransport.d.ts +30 -28
- package/build/transport/DidCommHttpInboundTransport.d.ts.map +1 -0
- package/build/transport/DidCommHttpInboundTransport.js +87 -143
- package/build/transport/DidCommHttpInboundTransport.mjs +83 -0
- package/build/transport/DidCommHttpInboundTransport.mjs.map +1 -0
- package/build/transport/DidCommWsInboundTransport.d.mts +26 -0
- package/build/transport/DidCommWsInboundTransport.d.mts.map +1 -0
- package/build/transport/DidCommWsInboundTransport.d.ts +25 -26
- package/build/transport/DidCommWsInboundTransport.d.ts.map +1 -0
- package/build/transport/DidCommWsInboundTransport.js +85 -132
- package/build/transport/DidCommWsInboundTransport.mjs +82 -0
- package/build/transport/DidCommWsInboundTransport.mjs.map +1 -0
- package/package.json +19 -11
- package/build/NodeFileSystem.d.ts +0 -28
- package/build/NodeFileSystem.js.map +0 -1
- package/build/index.js.map +0 -1
- package/build/kms/NodeInMemoryKeyManagementStorage.js.map +0 -1
- package/build/kms/NodeKeyManagementService.js.map +0 -1
- package/build/kms/NodeKeyManagementStorage.js +0 -3
- package/build/kms/NodeKeyManagementStorage.js.map +0 -1
- package/build/kms/crypto/createKey.d.ts +0 -39
- package/build/kms/crypto/createKey.js.map +0 -1
- package/build/kms/crypto/decrypt.d.ts +0 -4
- package/build/kms/crypto/decrypt.js.map +0 -1
- package/build/kms/crypto/deriveKey.d.ts +0 -41
- package/build/kms/crypto/deriveKey.js.map +0 -1
- package/build/kms/crypto/encrypt.d.ts +0 -7
- package/build/kms/crypto/encrypt.js.map +0 -1
- package/build/kms/crypto/sign.d.ts +0 -5
- package/build/kms/crypto/sign.js.map +0 -1
- package/build/kms/crypto/verify.d.ts +0 -2
- package/build/kms/crypto/verify.js.map +0 -1
- package/build/transport/DidCommHttpInboundTransport.js.map +0 -1
- package/build/transport/DidCommWsInboundTransport.js.map +0 -1
package/build/NodeFileSystem.js
CHANGED
|
@@ -1,127 +1,93 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.js');
|
|
2
|
+
let crypto = require("crypto");
|
|
3
|
+
crypto = require_rolldown_runtime.__toESM(crypto);
|
|
4
|
+
let fs = require("fs");
|
|
5
|
+
fs = require_rolldown_runtime.__toESM(fs);
|
|
6
|
+
let http = require("http");
|
|
7
|
+
http = require_rolldown_runtime.__toESM(http);
|
|
8
|
+
let https = require("https");
|
|
9
|
+
https = require_rolldown_runtime.__toESM(https);
|
|
10
|
+
let os = require("os");
|
|
11
|
+
os = require_rolldown_runtime.__toESM(os);
|
|
12
|
+
let path = require("path");
|
|
13
|
+
path = require_rolldown_runtime.__toESM(path);
|
|
14
|
+
let __credo_ts_core = require("@credo-ts/core");
|
|
15
|
+
__credo_ts_core = require_rolldown_runtime.__toESM(__credo_ts_core);
|
|
16
|
+
|
|
17
|
+
//#region src/NodeFileSystem.ts
|
|
18
|
+
const { access, readFile, writeFile, mkdir, rm, unlink, copyFile } = fs.promises;
|
|
19
|
+
var NodeFileSystem = class {
|
|
20
|
+
/**
|
|
21
|
+
* Create new NodeFileSystem class instance.
|
|
22
|
+
*
|
|
23
|
+
* @param baseDataPath The base path to use for reading and writing data files used within the framework.
|
|
24
|
+
* Files will be created under baseDataPath/.afj directory. If not specified, it will be set to homedir()
|
|
25
|
+
* @param baseCachePath The base path to use for reading and writing cache files used within the framework.
|
|
26
|
+
* Files will be created under baseCachePath/.afj directory. If not specified, it will be set to homedir()
|
|
27
|
+
* @param baseTempPath The base path to use for reading and writing temporary files within the framework.
|
|
28
|
+
* Files will be created under baseTempPath/.afj directory. If not specified, it will be set to tmpdir()
|
|
29
|
+
*/
|
|
30
|
+
constructor(options) {
|
|
31
|
+
this.dataPath = options?.baseDataPath ? `${options?.baseDataPath}/.afj` : `${(0, os.homedir)()}/.afj/data`;
|
|
32
|
+
this.cachePath = options?.baseCachePath ? `${options?.baseCachePath}/.afj` : `${(0, os.homedir)()}/.afj/cache`;
|
|
33
|
+
this.tempPath = `${options?.baseTempPath ?? (0, os.tmpdir)()}/.afj`;
|
|
34
|
+
}
|
|
35
|
+
async exists(path$1) {
|
|
36
|
+
try {
|
|
37
|
+
await access(path$1);
|
|
38
|
+
return true;
|
|
39
|
+
} catch {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async createDirectory(path$1) {
|
|
44
|
+
await mkdir((0, path.dirname)(path$1), { recursive: true });
|
|
45
|
+
}
|
|
46
|
+
async copyFile(sourcePath, destinationPath) {
|
|
47
|
+
await copyFile(sourcePath, destinationPath);
|
|
48
|
+
}
|
|
49
|
+
async write(path$1, data) {
|
|
50
|
+
await mkdir((0, path.dirname)(path$1), { recursive: true });
|
|
51
|
+
return writeFile(path$1, data, { encoding: "utf-8" });
|
|
52
|
+
}
|
|
53
|
+
async read(path$1) {
|
|
54
|
+
return readFile(path$1, { encoding: "utf-8" });
|
|
55
|
+
}
|
|
56
|
+
async delete(path$1) {
|
|
57
|
+
await rm(path$1, {
|
|
58
|
+
recursive: true,
|
|
59
|
+
force: true
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
async downloadToFile(url, path$1, options) {
|
|
63
|
+
const httpMethod = url.startsWith("https") ? https.default : http.default;
|
|
64
|
+
await mkdir((0, path.dirname)(path$1), { recursive: true });
|
|
65
|
+
const file = fs.default.createWriteStream(path$1);
|
|
66
|
+
const hash = options.verifyHash ? (0, crypto.createHash)("sha256") : void 0;
|
|
67
|
+
return new Promise((resolve, reject) => {
|
|
68
|
+
httpMethod.get(url, (response) => {
|
|
69
|
+
if (response.statusCode !== 200) reject(`Unable to download file from url: ${url}. Response status was ${response.statusCode}`);
|
|
70
|
+
hash && response.pipe(hash);
|
|
71
|
+
response.pipe(file);
|
|
72
|
+
file.on("finish", async () => {
|
|
73
|
+
file.close();
|
|
74
|
+
if (hash && options.verifyHash?.hash) {
|
|
75
|
+
hash.end();
|
|
76
|
+
const digest = hash.digest();
|
|
77
|
+
if (digest.compare(options.verifyHash.hash) !== 0) {
|
|
78
|
+
await fs.default.promises.unlink(path$1);
|
|
79
|
+
reject(new __credo_ts_core.CredoError(`Hash of downloaded file does not match expected hash. Expected: ${options.verifyHash.hash}, Actual: ${__credo_ts_core.TypedArrayEncoder.toUtf8String(digest)})}`));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
resolve();
|
|
83
|
+
});
|
|
84
|
+
}).on("error", async (error) => {
|
|
85
|
+
await unlink(path$1);
|
|
86
|
+
reject(`Unable to download file from url: ${url}. ${error.message}`);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
}
|
|
37
90
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const fs_1 = __importStar(require("fs"));
|
|
42
|
-
const http_1 = __importDefault(require("http"));
|
|
43
|
-
const https_1 = __importDefault(require("https"));
|
|
44
|
-
const os_1 = require("os");
|
|
45
|
-
const path_1 = require("path");
|
|
46
|
-
const core_1 = require("@credo-ts/core");
|
|
47
|
-
const { access, readFile, writeFile, mkdir, rm, unlink, copyFile } = fs_1.promises;
|
|
48
|
-
class NodeFileSystem {
|
|
49
|
-
/**
|
|
50
|
-
* Create new NodeFileSystem class instance.
|
|
51
|
-
*
|
|
52
|
-
* @param baseDataPath The base path to use for reading and writing data files used within the framework.
|
|
53
|
-
* Files will be created under baseDataPath/.afj directory. If not specified, it will be set to homedir()
|
|
54
|
-
* @param baseCachePath The base path to use for reading and writing cache files used within the framework.
|
|
55
|
-
* Files will be created under baseCachePath/.afj directory. If not specified, it will be set to homedir()
|
|
56
|
-
* @param baseTempPath The base path to use for reading and writing temporary files within the framework.
|
|
57
|
-
* Files will be created under baseTempPath/.afj directory. If not specified, it will be set to tmpdir()
|
|
58
|
-
*/
|
|
59
|
-
constructor(options) {
|
|
60
|
-
this.dataPath = options?.baseDataPath ? `${options?.baseDataPath}/.afj` : `${(0, os_1.homedir)()}/.afj/data`;
|
|
61
|
-
this.cachePath = options?.baseCachePath ? `${options?.baseCachePath}/.afj` : `${(0, os_1.homedir)()}/.afj/cache`;
|
|
62
|
-
this.tempPath = `${options?.baseTempPath ?? (0, os_1.tmpdir)()}/.afj`;
|
|
63
|
-
}
|
|
64
|
-
async exists(path) {
|
|
65
|
-
try {
|
|
66
|
-
await access(path);
|
|
67
|
-
return true;
|
|
68
|
-
}
|
|
69
|
-
catch {
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
async createDirectory(path) {
|
|
74
|
-
await mkdir((0, path_1.dirname)(path), { recursive: true });
|
|
75
|
-
}
|
|
76
|
-
async copyFile(sourcePath, destinationPath) {
|
|
77
|
-
await copyFile(sourcePath, destinationPath);
|
|
78
|
-
}
|
|
79
|
-
async write(path, data) {
|
|
80
|
-
// Make sure parent directories exist
|
|
81
|
-
await mkdir((0, path_1.dirname)(path), { recursive: true });
|
|
82
|
-
return writeFile(path, data, { encoding: 'utf-8' });
|
|
83
|
-
}
|
|
84
|
-
async read(path) {
|
|
85
|
-
return readFile(path, { encoding: 'utf-8' });
|
|
86
|
-
}
|
|
87
|
-
async delete(path) {
|
|
88
|
-
await rm(path, { recursive: true, force: true });
|
|
89
|
-
}
|
|
90
|
-
async downloadToFile(url, path, options) {
|
|
91
|
-
const httpMethod = url.startsWith('https') ? https_1.default : http_1.default;
|
|
92
|
-
// Make sure parent directories exist
|
|
93
|
-
await mkdir((0, path_1.dirname)(path), { recursive: true });
|
|
94
|
-
const file = fs_1.default.createWriteStream(path);
|
|
95
|
-
const hash = options.verifyHash ? (0, crypto_1.createHash)('sha256') : undefined;
|
|
96
|
-
return new Promise((resolve, reject) => {
|
|
97
|
-
httpMethod
|
|
98
|
-
.get(url, (response) => {
|
|
99
|
-
// check if response is success
|
|
100
|
-
if (response.statusCode !== 200) {
|
|
101
|
-
reject(`Unable to download file from url: ${url}. Response status was ${response.statusCode}`);
|
|
102
|
-
}
|
|
103
|
-
hash && response.pipe(hash);
|
|
104
|
-
response.pipe(file);
|
|
105
|
-
file.on('finish', async () => {
|
|
106
|
-
file.close();
|
|
107
|
-
if (hash && options.verifyHash?.hash) {
|
|
108
|
-
hash.end();
|
|
109
|
-
const digest = hash.digest();
|
|
110
|
-
if (digest.compare(options.verifyHash.hash) !== 0) {
|
|
111
|
-
await fs_1.default.promises.unlink(path);
|
|
112
|
-
reject(new core_1.CredoError(`Hash of downloaded file does not match expected hash. Expected: ${options.verifyHash.hash}, Actual: ${core_1.TypedArrayEncoder.toUtf8String(digest)})}`));
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
resolve();
|
|
116
|
-
});
|
|
117
|
-
})
|
|
118
|
-
.on('error', async (error) => {
|
|
119
|
-
// Handle errors
|
|
120
|
-
await unlink(path); // Delete the file async. (But we don't check the result)
|
|
121
|
-
reject(`Unable to download file from url: ${url}. ${error.message}`);
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
exports.NodeFileSystem = NodeFileSystem;
|
|
127
|
-
//# sourceMappingURL=NodeFileSystem.js.map
|
|
91
|
+
|
|
92
|
+
//#endregion
|
|
93
|
+
exports.NodeFileSystem = NodeFileSystem;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { createHash } from "crypto";
|
|
2
|
+
import fs, { promises } from "fs";
|
|
3
|
+
import http from "http";
|
|
4
|
+
import https from "https";
|
|
5
|
+
import { homedir, tmpdir } from "os";
|
|
6
|
+
import { dirname } from "path";
|
|
7
|
+
import { CredoError, TypedArrayEncoder } from "@credo-ts/core";
|
|
8
|
+
|
|
9
|
+
//#region src/NodeFileSystem.ts
|
|
10
|
+
const { access, readFile, writeFile, mkdir, rm, unlink, copyFile } = promises;
|
|
11
|
+
var NodeFileSystem = class {
|
|
12
|
+
/**
|
|
13
|
+
* Create new NodeFileSystem class instance.
|
|
14
|
+
*
|
|
15
|
+
* @param baseDataPath The base path to use for reading and writing data files used within the framework.
|
|
16
|
+
* Files will be created under baseDataPath/.afj directory. If not specified, it will be set to homedir()
|
|
17
|
+
* @param baseCachePath The base path to use for reading and writing cache files used within the framework.
|
|
18
|
+
* Files will be created under baseCachePath/.afj directory. If not specified, it will be set to homedir()
|
|
19
|
+
* @param baseTempPath The base path to use for reading and writing temporary files within the framework.
|
|
20
|
+
* Files will be created under baseTempPath/.afj directory. If not specified, it will be set to tmpdir()
|
|
21
|
+
*/
|
|
22
|
+
constructor(options) {
|
|
23
|
+
this.dataPath = options?.baseDataPath ? `${options?.baseDataPath}/.afj` : `${homedir()}/.afj/data`;
|
|
24
|
+
this.cachePath = options?.baseCachePath ? `${options?.baseCachePath}/.afj` : `${homedir()}/.afj/cache`;
|
|
25
|
+
this.tempPath = `${options?.baseTempPath ?? tmpdir()}/.afj`;
|
|
26
|
+
}
|
|
27
|
+
async exists(path) {
|
|
28
|
+
try {
|
|
29
|
+
await access(path);
|
|
30
|
+
return true;
|
|
31
|
+
} catch {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async createDirectory(path) {
|
|
36
|
+
await mkdir(dirname(path), { recursive: true });
|
|
37
|
+
}
|
|
38
|
+
async copyFile(sourcePath, destinationPath) {
|
|
39
|
+
await copyFile(sourcePath, destinationPath);
|
|
40
|
+
}
|
|
41
|
+
async write(path, data) {
|
|
42
|
+
await mkdir(dirname(path), { recursive: true });
|
|
43
|
+
return writeFile(path, data, { encoding: "utf-8" });
|
|
44
|
+
}
|
|
45
|
+
async read(path) {
|
|
46
|
+
return readFile(path, { encoding: "utf-8" });
|
|
47
|
+
}
|
|
48
|
+
async delete(path) {
|
|
49
|
+
await rm(path, {
|
|
50
|
+
recursive: true,
|
|
51
|
+
force: true
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
async downloadToFile(url, path, options) {
|
|
55
|
+
const httpMethod = url.startsWith("https") ? https : http;
|
|
56
|
+
await mkdir(dirname(path), { recursive: true });
|
|
57
|
+
const file = fs.createWriteStream(path);
|
|
58
|
+
const hash = options.verifyHash ? createHash("sha256") : void 0;
|
|
59
|
+
return new Promise((resolve, reject) => {
|
|
60
|
+
httpMethod.get(url, (response) => {
|
|
61
|
+
if (response.statusCode !== 200) reject(`Unable to download file from url: ${url}. Response status was ${response.statusCode}`);
|
|
62
|
+
hash && response.pipe(hash);
|
|
63
|
+
response.pipe(file);
|
|
64
|
+
file.on("finish", async () => {
|
|
65
|
+
file.close();
|
|
66
|
+
if (hash && options.verifyHash?.hash) {
|
|
67
|
+
hash.end();
|
|
68
|
+
const digest = hash.digest();
|
|
69
|
+
if (digest.compare(options.verifyHash.hash) !== 0) {
|
|
70
|
+
await fs.promises.unlink(path);
|
|
71
|
+
reject(new CredoError(`Hash of downloaded file does not match expected hash. Expected: ${options.verifyHash.hash}, Actual: ${TypedArrayEncoder.toUtf8String(digest)})}`));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
resolve();
|
|
75
|
+
});
|
|
76
|
+
}).on("error", async (error) => {
|
|
77
|
+
await unlink(path);
|
|
78
|
+
reject(`Unable to download file from url: ${url}. ${error.message}`);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
//#endregion
|
|
85
|
+
export { NodeFileSystem };
|
|
86
|
+
//# sourceMappingURL=NodeFileSystem.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NodeFileSystem.mjs","names":[],"sources":["../src/NodeFileSystem.ts"],"sourcesContent":["import type { DownloadToFileOptions, FileSystem } from '@credo-ts/core'\n\nimport { createHash } from 'crypto'\nimport fs, { promises } from 'fs'\nimport http from 'http'\nimport https from 'https'\nimport { homedir, tmpdir } from 'os'\nimport { dirname } from 'path'\nimport { CredoError, TypedArrayEncoder } from '@credo-ts/core'\n\nconst { access, readFile, writeFile, mkdir, rm, unlink, copyFile } = promises\n\nexport class NodeFileSystem implements FileSystem {\n public readonly dataPath\n public readonly cachePath\n public readonly tempPath\n\n /**\n * Create new NodeFileSystem class instance.\n *\n * @param baseDataPath The base path to use for reading and writing data files used within the framework.\n * Files will be created under baseDataPath/.afj directory. If not specified, it will be set to homedir()\n * @param baseCachePath The base path to use for reading and writing cache files used within the framework.\n * Files will be created under baseCachePath/.afj directory. If not specified, it will be set to homedir()\n * @param baseTempPath The base path to use for reading and writing temporary files within the framework.\n * Files will be created under baseTempPath/.afj directory. If not specified, it will be set to tmpdir()\n */\n public constructor(options?: { baseDataPath?: string; baseCachePath?: string; baseTempPath?: string }) {\n this.dataPath = options?.baseDataPath ? `${options?.baseDataPath}/.afj` : `${homedir()}/.afj/data`\n this.cachePath = options?.baseCachePath ? `${options?.baseCachePath}/.afj` : `${homedir()}/.afj/cache`\n this.tempPath = `${options?.baseTempPath ?? tmpdir()}/.afj`\n }\n\n public async exists(path: string) {\n try {\n await access(path)\n return true\n } catch {\n return false\n }\n }\n\n public async createDirectory(path: string): Promise<void> {\n await mkdir(dirname(path), { recursive: true })\n }\n\n public async copyFile(sourcePath: string, destinationPath: string): Promise<void> {\n await copyFile(sourcePath, destinationPath)\n }\n\n public async write(path: string, data: string): Promise<void> {\n // Make sure parent directories exist\n await mkdir(dirname(path), { recursive: true })\n\n return writeFile(path, data, { encoding: 'utf-8' })\n }\n\n public async read(path: string): Promise<string> {\n return readFile(path, { encoding: 'utf-8' })\n }\n\n public async delete(path: string): Promise<void> {\n await rm(path, { recursive: true, force: true })\n }\n\n public async downloadToFile(url: string, path: string, options: DownloadToFileOptions) {\n const httpMethod = url.startsWith('https') ? https : http\n\n // Make sure parent directories exist\n await mkdir(dirname(path), { recursive: true })\n\n const file = fs.createWriteStream(path)\n const hash = options.verifyHash ? createHash('sha256') : undefined\n\n return new Promise<void>((resolve, reject) => {\n httpMethod\n .get(url, (response) => {\n // check if response is success\n if (response.statusCode !== 200) {\n reject(`Unable to download file from url: ${url}. Response status was ${response.statusCode}`)\n }\n\n hash && response.pipe(hash)\n response.pipe(file)\n file.on('finish', async () => {\n file.close()\n\n if (hash && options.verifyHash?.hash) {\n hash.end()\n const digest = hash.digest()\n if (digest.compare(options.verifyHash.hash) !== 0) {\n await fs.promises.unlink(path)\n\n reject(\n new CredoError(\n `Hash of downloaded file does not match expected hash. Expected: ${\n options.verifyHash.hash\n }, Actual: ${TypedArrayEncoder.toUtf8String(digest)})}`\n )\n )\n }\n }\n resolve()\n })\n })\n .on('error', async (error) => {\n // Handle errors\n await unlink(path) // Delete the file async. (But we don't check the result)\n reject(`Unable to download file from url: ${url}. ${error.message}`)\n })\n })\n }\n}\n"],"mappings":";;;;;;;;;AAUA,MAAM,EAAE,QAAQ,UAAU,WAAW,OAAO,IAAI,QAAQ,aAAa;AAErE,IAAa,iBAAb,MAAkD;;;;;;;;;;;CAehD,AAAO,YAAY,SAAoF;AACrG,OAAK,WAAW,SAAS,eAAe,GAAG,SAAS,aAAa,SAAS,GAAG,SAAS,CAAC;AACvF,OAAK,YAAY,SAAS,gBAAgB,GAAG,SAAS,cAAc,SAAS,GAAG,SAAS,CAAC;AAC1F,OAAK,WAAW,GAAG,SAAS,gBAAgB,QAAQ,CAAC;;CAGvD,MAAa,OAAO,MAAc;AAChC,MAAI;AACF,SAAM,OAAO,KAAK;AAClB,UAAO;UACD;AACN,UAAO;;;CAIX,MAAa,gBAAgB,MAA6B;AACxD,QAAM,MAAM,QAAQ,KAAK,EAAE,EAAE,WAAW,MAAM,CAAC;;CAGjD,MAAa,SAAS,YAAoB,iBAAwC;AAChF,QAAM,SAAS,YAAY,gBAAgB;;CAG7C,MAAa,MAAM,MAAc,MAA6B;AAE5D,QAAM,MAAM,QAAQ,KAAK,EAAE,EAAE,WAAW,MAAM,CAAC;AAE/C,SAAO,UAAU,MAAM,MAAM,EAAE,UAAU,SAAS,CAAC;;CAGrD,MAAa,KAAK,MAA+B;AAC/C,SAAO,SAAS,MAAM,EAAE,UAAU,SAAS,CAAC;;CAG9C,MAAa,OAAO,MAA6B;AAC/C,QAAM,GAAG,MAAM;GAAE,WAAW;GAAM,OAAO;GAAM,CAAC;;CAGlD,MAAa,eAAe,KAAa,MAAc,SAAgC;EACrF,MAAM,aAAa,IAAI,WAAW,QAAQ,GAAG,QAAQ;AAGrD,QAAM,MAAM,QAAQ,KAAK,EAAE,EAAE,WAAW,MAAM,CAAC;EAE/C,MAAM,OAAO,GAAG,kBAAkB,KAAK;EACvC,MAAM,OAAO,QAAQ,aAAa,WAAW,SAAS,GAAG;AAEzD,SAAO,IAAI,SAAe,SAAS,WAAW;AAC5C,cACG,IAAI,MAAM,aAAa;AAEtB,QAAI,SAAS,eAAe,IAC1B,QAAO,qCAAqC,IAAI,wBAAwB,SAAS,aAAa;AAGhG,YAAQ,SAAS,KAAK,KAAK;AAC3B,aAAS,KAAK,KAAK;AACnB,SAAK,GAAG,UAAU,YAAY;AAC5B,UAAK,OAAO;AAEZ,SAAI,QAAQ,QAAQ,YAAY,MAAM;AACpC,WAAK,KAAK;MACV,MAAM,SAAS,KAAK,QAAQ;AAC5B,UAAI,OAAO,QAAQ,QAAQ,WAAW,KAAK,KAAK,GAAG;AACjD,aAAM,GAAG,SAAS,OAAO,KAAK;AAE9B,cACE,IAAI,WACF,mEACE,QAAQ,WAAW,KACpB,YAAY,kBAAkB,aAAa,OAAO,CAAC,IACrD,CACF;;;AAGL,cAAS;MACT;KACF,CACD,GAAG,SAAS,OAAO,UAAU;AAE5B,UAAM,OAAO,KAAK;AAClB,WAAO,qCAAqC,IAAI,IAAI,MAAM,UAAU;KACpE;IACJ"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
|
|
2
|
+
//#region \0@oxc-project+runtime@0.94.0/helpers/assertClassBrand.js
|
|
3
|
+
function _assertClassBrand(e, t, n) {
|
|
4
|
+
if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
|
|
5
|
+
throw new TypeError("Private element is not present on this object");
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
exports._assertClassBrand = _assertClassBrand;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region \0@oxc-project+runtime@0.94.0/helpers/assertClassBrand.js
|
|
2
|
+
function _assertClassBrand(e, t, n) {
|
|
3
|
+
if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
|
|
4
|
+
throw new TypeError("Private element is not present on this object");
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
export { _assertClassBrand };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
|
|
2
|
+
//#region \0@oxc-project+runtime@0.94.0/helpers/checkPrivateRedeclaration.js
|
|
3
|
+
function _checkPrivateRedeclaration(e, t) {
|
|
4
|
+
if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
exports._checkPrivateRedeclaration = _checkPrivateRedeclaration;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region \0@oxc-project+runtime@0.94.0/helpers/checkPrivateRedeclaration.js
|
|
2
|
+
function _checkPrivateRedeclaration(e, t) {
|
|
3
|
+
if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
//#endregion
|
|
7
|
+
export { _checkPrivateRedeclaration };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const require_assertClassBrand = require('./assertClassBrand.js');
|
|
2
|
+
|
|
3
|
+
//#region \0@oxc-project+runtime@0.94.0/helpers/classPrivateFieldGet2.js
|
|
4
|
+
function _classPrivateFieldGet2(s, a) {
|
|
5
|
+
return s.get(require_assertClassBrand._assertClassBrand(s, a));
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
exports._classPrivateFieldGet2 = _classPrivateFieldGet2;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { _assertClassBrand } from "./assertClassBrand.mjs";
|
|
2
|
+
|
|
3
|
+
//#region \0@oxc-project+runtime@0.94.0/helpers/classPrivateFieldGet2.js
|
|
4
|
+
function _classPrivateFieldGet2(s, a) {
|
|
5
|
+
return s.get(_assertClassBrand(s, a));
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
export { _classPrivateFieldGet2 };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const require_checkPrivateRedeclaration = require('./checkPrivateRedeclaration.js');
|
|
2
|
+
|
|
3
|
+
//#region \0@oxc-project+runtime@0.94.0/helpers/classPrivateFieldInitSpec.js
|
|
4
|
+
function _classPrivateFieldInitSpec(e, t, a) {
|
|
5
|
+
require_checkPrivateRedeclaration._checkPrivateRedeclaration(e, t), t.set(e, a);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
exports._classPrivateFieldInitSpec = _classPrivateFieldInitSpec;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { _checkPrivateRedeclaration } from "./checkPrivateRedeclaration.mjs";
|
|
2
|
+
|
|
3
|
+
//#region \0@oxc-project+runtime@0.94.0/helpers/classPrivateFieldInitSpec.js
|
|
4
|
+
function _classPrivateFieldInitSpec(e, t, a) {
|
|
5
|
+
_checkPrivateRedeclaration(e, t), t.set(e, a);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
export { _classPrivateFieldInitSpec };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const require_assertClassBrand = require('./assertClassBrand.js');
|
|
2
|
+
|
|
3
|
+
//#region \0@oxc-project+runtime@0.94.0/helpers/classPrivateFieldSet2.js
|
|
4
|
+
function _classPrivateFieldSet2(s, a, r) {
|
|
5
|
+
return s.set(require_assertClassBrand._assertClassBrand(s, a), r), r;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
exports._classPrivateFieldSet2 = _classPrivateFieldSet2;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { _assertClassBrand } from "./assertClassBrand.mjs";
|
|
2
|
+
|
|
3
|
+
//#region \0@oxc-project+runtime@0.94.0/helpers/classPrivateFieldSet2.js
|
|
4
|
+
function _classPrivateFieldSet2(s, a, r) {
|
|
5
|
+
return s.set(_assertClassBrand(s, a), r), r;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
export { _classPrivateFieldSet2 };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
|
|
25
|
+
exports.__toESM = __toESM;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DidCommHttpInboundTransport } from "./transport/DidCommHttpInboundTransport.mjs";
|
|
2
|
+
import { DidCommWsInboundTransport } from "./transport/DidCommWsInboundTransport.mjs";
|
|
3
|
+
import { NodeKeyManagementStorage } from "./kms/NodeKeyManagementStorage.mjs";
|
|
4
|
+
import { NodeInMemoryKeyManagementStorage } from "./kms/NodeInMemoryKeyManagementStorage.mjs";
|
|
5
|
+
import { NodeKeyManagementService } from "./kms/NodeKeyManagementService.mjs";
|
|
6
|
+
import { AgentDependencies } from "@credo-ts/core";
|
|
7
|
+
|
|
8
|
+
//#region src/index.d.ts
|
|
9
|
+
declare const agentDependencies: AgentDependencies;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { DidCommHttpInboundTransport, DidCommWsInboundTransport, NodeInMemoryKeyManagementStorage, NodeKeyManagementService, type NodeKeyManagementStorage, agentDependencies };
|
|
12
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;cAaM,mBAAmB"}
|
package/build/index.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { DidCommHttpInboundTransport } from "./transport/DidCommHttpInboundTransport.js";
|
|
2
|
+
import { DidCommWsInboundTransport } from "./transport/DidCommWsInboundTransport.js";
|
|
3
|
+
import { NodeKeyManagementStorage } from "./kms/NodeKeyManagementStorage.js";
|
|
4
|
+
import { NodeInMemoryKeyManagementStorage } from "./kms/NodeInMemoryKeyManagementStorage.js";
|
|
5
|
+
import { NodeKeyManagementService } from "./kms/NodeKeyManagementService.js";
|
|
6
|
+
import { AgentDependencies } from "@credo-ts/core";
|
|
7
|
+
|
|
8
|
+
//#region src/index.d.ts
|
|
7
9
|
declare const agentDependencies: AgentDependencies;
|
|
8
|
-
|
|
10
|
+
//#endregion
|
|
11
|
+
export { DidCommHttpInboundTransport, DidCommWsInboundTransport, NodeInMemoryKeyManagementStorage, NodeKeyManagementService, type NodeKeyManagementStorage, agentDependencies };
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;cAaM,mBAAmB"}
|
package/build/index.js
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var NodeKeyManagementService_1 = require("./kms/NodeKeyManagementService");
|
|
14
|
-
Object.defineProperty(exports, "NodeKeyManagementService", { enumerable: true, get: function () { return NodeKeyManagementService_1.NodeKeyManagementService; } });
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.js');
|
|
2
|
+
const require_NodeFileSystem = require('./NodeFileSystem.js');
|
|
3
|
+
const require_DidCommHttpInboundTransport = require('./transport/DidCommHttpInboundTransport.js');
|
|
4
|
+
const require_DidCommWsInboundTransport = require('./transport/DidCommWsInboundTransport.js');
|
|
5
|
+
const require_NodeInMemoryKeyManagementStorage = require('./kms/NodeInMemoryKeyManagementStorage.js');
|
|
6
|
+
const require_NodeKeyManagementService = require('./kms/NodeKeyManagementService.js');
|
|
7
|
+
let events = require("events");
|
|
8
|
+
events = require_rolldown_runtime.__toESM(events);
|
|
9
|
+
let ws = require("ws");
|
|
10
|
+
ws = require_rolldown_runtime.__toESM(ws);
|
|
11
|
+
|
|
12
|
+
//#region src/index.ts
|
|
15
13
|
const agentDependencies = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
FileSystem: require_NodeFileSystem.NodeFileSystem,
|
|
15
|
+
fetch,
|
|
16
|
+
EventEmitterClass: events.EventEmitter,
|
|
17
|
+
WebSocketClass: ws.WebSocket
|
|
20
18
|
};
|
|
21
|
-
|
|
22
|
-
//#
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
exports.DidCommHttpInboundTransport = require_DidCommHttpInboundTransport.DidCommHttpInboundTransport;
|
|
22
|
+
exports.DidCommWsInboundTransport = require_DidCommWsInboundTransport.DidCommWsInboundTransport;
|
|
23
|
+
exports.NodeInMemoryKeyManagementStorage = require_NodeInMemoryKeyManagementStorage.NodeInMemoryKeyManagementStorage;
|
|
24
|
+
exports.NodeKeyManagementService = require_NodeKeyManagementService.NodeKeyManagementService;
|
|
25
|
+
exports.agentDependencies = agentDependencies;
|
package/build/index.mjs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { NodeFileSystem } from "./NodeFileSystem.mjs";
|
|
2
|
+
import { DidCommHttpInboundTransport } from "./transport/DidCommHttpInboundTransport.mjs";
|
|
3
|
+
import { DidCommWsInboundTransport } from "./transport/DidCommWsInboundTransport.mjs";
|
|
4
|
+
import { NodeInMemoryKeyManagementStorage } from "./kms/NodeInMemoryKeyManagementStorage.mjs";
|
|
5
|
+
import { NodeKeyManagementService } from "./kms/NodeKeyManagementService.mjs";
|
|
6
|
+
import { EventEmitter } from "events";
|
|
7
|
+
import { WebSocket as WebSocket$1 } from "ws";
|
|
8
|
+
|
|
9
|
+
//#region src/index.ts
|
|
10
|
+
const agentDependencies = {
|
|
11
|
+
FileSystem: NodeFileSystem,
|
|
12
|
+
fetch,
|
|
13
|
+
EventEmitterClass: EventEmitter,
|
|
14
|
+
WebSocketClass: WebSocket$1
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { DidCommHttpInboundTransport, DidCommWsInboundTransport, NodeInMemoryKeyManagementStorage, NodeKeyManagementService, agentDependencies };
|
|
19
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["agentDependencies: AgentDependencies","WebSocket"],"sources":["../src/index.ts"],"sourcesContent":["import type { AgentDependencies } from '@credo-ts/core'\n\nimport { EventEmitter } from 'events'\nimport { WebSocket } from 'ws'\n\nimport { NodeFileSystem } from './NodeFileSystem'\nimport { DidCommHttpInboundTransport } from './transport/DidCommHttpInboundTransport'\nimport { DidCommWsInboundTransport } from './transport/DidCommWsInboundTransport'\n\nexport { NodeInMemoryKeyManagementStorage } from './kms/NodeInMemoryKeyManagementStorage'\nexport { NodeKeyManagementService } from './kms/NodeKeyManagementService'\nexport type { NodeKeyManagementStorage } from './kms/NodeKeyManagementStorage'\n\nconst agentDependencies: AgentDependencies = {\n FileSystem: NodeFileSystem,\n fetch,\n EventEmitterClass: EventEmitter,\n WebSocketClass: WebSocket,\n}\n\nexport { agentDependencies, DidCommHttpInboundTransport, DidCommWsInboundTransport }\n"],"mappings":";;;;;;;;;AAaA,MAAMA,oBAAuC;CAC3C,YAAY;CACZ;CACA,mBAAmB;CACnB,gBAAgBC;CACjB"}
|