@vess-id/ai-identity 0.0.3 → 0.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/dist/index.d.mts +12 -2
- package/dist/index.d.ts +12 -2
- package/dist/index.js +34 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
package/dist/index.mjs
CHANGED
|
@@ -92,7 +92,7 @@ import * as os from "os";
|
|
|
92
92
|
var FilesystemKeyStorage = class {
|
|
93
93
|
keyStorePath;
|
|
94
94
|
constructor(config) {
|
|
95
|
-
this.keyStorePath = config?.options?.path || path.join(os.homedir(), ".vess", "keys");
|
|
95
|
+
this.keyStorePath = config?.options?.path || path.join(os.homedir(), ".vess-aidentity", "keys");
|
|
96
96
|
}
|
|
97
97
|
async store(id, encryptedKey) {
|
|
98
98
|
await this.ensureKeyStoreExists();
|
|
@@ -901,7 +901,7 @@ var AgentDIDManager = class {
|
|
|
901
901
|
const fs3 = await import("fs/promises");
|
|
902
902
|
const path3 = await import("path");
|
|
903
903
|
const os2 = await import("os");
|
|
904
|
-
const mappingDir = path3.join(os2.homedir(), ".vess", "agent-dids");
|
|
904
|
+
const mappingDir = path3.join(os2.homedir(), ".vess-aidentity", "agent-dids");
|
|
905
905
|
try {
|
|
906
906
|
const files = await fs3.readdir(mappingDir);
|
|
907
907
|
const results = [];
|
|
@@ -927,7 +927,7 @@ var AgentDIDManager = class {
|
|
|
927
927
|
const fs3 = await import("fs/promises");
|
|
928
928
|
const path3 = await import("path");
|
|
929
929
|
const os2 = await import("os");
|
|
930
|
-
const mappingDir = path3.join(os2.homedir(), ".vess", "agent-dids");
|
|
930
|
+
const mappingDir = path3.join(os2.homedir(), ".vess-aidentity", "agent-dids");
|
|
931
931
|
await fs3.mkdir(mappingDir, { recursive: true });
|
|
932
932
|
const mappingFile = path3.join(mappingDir, `${agentId}.did`);
|
|
933
933
|
await fs3.writeFile(mappingFile, did, "utf-8");
|
|
@@ -1230,7 +1230,7 @@ var UserIdentityManager = class {
|
|
|
1230
1230
|
const fs3 = await import("fs/promises");
|
|
1231
1231
|
const path3 = await import("path");
|
|
1232
1232
|
const os2 = await import("os");
|
|
1233
|
-
const configDir = path3.join(os2.homedir(), ".vess");
|
|
1233
|
+
const configDir = path3.join(os2.homedir(), ".vess-aidentity");
|
|
1234
1234
|
await fs3.mkdir(configDir, { recursive: true });
|
|
1235
1235
|
const userDIDFile = path3.join(configDir, "user-did.txt");
|
|
1236
1236
|
await fs3.writeFile(userDIDFile, did, "utf-8");
|
|
@@ -1242,7 +1242,7 @@ var UserIdentityManager = class {
|
|
|
1242
1242
|
const fs3 = await import("fs/promises");
|
|
1243
1243
|
const path3 = await import("path");
|
|
1244
1244
|
const os2 = await import("os");
|
|
1245
|
-
const userDIDFile = path3.join(os2.homedir(), ".vess", "user-did.txt");
|
|
1245
|
+
const userDIDFile = path3.join(os2.homedir(), ".vess-aidentity", "user-did.txt");
|
|
1246
1246
|
try {
|
|
1247
1247
|
return await fs3.readFile(userDIDFile, "utf-8");
|
|
1248
1248
|
} catch {
|
|
@@ -1256,7 +1256,7 @@ var UserIdentityManager = class {
|
|
|
1256
1256
|
const fs3 = await import("fs/promises");
|
|
1257
1257
|
const path3 = await import("path");
|
|
1258
1258
|
const os2 = await import("os");
|
|
1259
|
-
const userDIDFile = path3.join(os2.homedir(), ".vess", "user-did.txt");
|
|
1259
|
+
const userDIDFile = path3.join(os2.homedir(), ".vess-aidentity", "user-did.txt");
|
|
1260
1260
|
try {
|
|
1261
1261
|
await fs3.unlink(userDIDFile);
|
|
1262
1262
|
} catch {
|
|
@@ -2746,6 +2746,32 @@ function getClient(config, password) {
|
|
|
2746
2746
|
return defaultClient;
|
|
2747
2747
|
}
|
|
2748
2748
|
|
|
2749
|
+
// src/identity/user-key-pair-manager.ts
|
|
2750
|
+
var UserKeyPairManager = class {
|
|
2751
|
+
/**
|
|
2752
|
+
* Generate a new key pair and create a did:jwk DID
|
|
2753
|
+
*/
|
|
2754
|
+
async generateKeyPair() {
|
|
2755
|
+
const keyPair = await SDJwtClient.generateKeyPair();
|
|
2756
|
+
const did = createDidJwk(keyPair.publicKey);
|
|
2757
|
+
return {
|
|
2758
|
+
did,
|
|
2759
|
+
publicKey: keyPair.publicKey,
|
|
2760
|
+
privateKey: keyPair.privateKey
|
|
2761
|
+
};
|
|
2762
|
+
}
|
|
2763
|
+
/**
|
|
2764
|
+
* Extract public key info from a did:jwk DID
|
|
2765
|
+
* @throws Error if the DID is not in did:jwk format
|
|
2766
|
+
*/
|
|
2767
|
+
extractPublicKeyInfo(did) {
|
|
2768
|
+
if (!did.startsWith("did:jwk:")) {
|
|
2769
|
+
throw new Error("Only did:jwk format is supported");
|
|
2770
|
+
}
|
|
2771
|
+
return extractPublicKeyFromDid(did);
|
|
2772
|
+
}
|
|
2773
|
+
};
|
|
2774
|
+
|
|
2749
2775
|
// src/vc/api-vc-manager.ts
|
|
2750
2776
|
import {
|
|
2751
2777
|
CredentialType as CredentialType2
|
|
@@ -4689,6 +4715,7 @@ export {
|
|
|
4689
4715
|
SimpleRebac,
|
|
4690
4716
|
ToolManager,
|
|
4691
4717
|
UserIdentityManager,
|
|
4718
|
+
UserKeyPairManager,
|
|
4692
4719
|
VCManager,
|
|
4693
4720
|
VPManager,
|
|
4694
4721
|
checkPermissionWithVP,
|