@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.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { VerifiablePresentation, VPRequest, Agent, DIDDocument, VCTemplate, ConnectorResponse, ToolPermissionRequest, OrganizationConfig, Grant, CreateGrantRequest, GrantStatus, CheckGrantPermissionRequest, CheckGrantPermissionResult, UpdateGrantRequest, CredentialType, IssueSDJWTVCRequest, IssueSDJWTVCResult, VerifySDJWTVCResult, GrantConstraints, EvaluationContext, ConstraintEvaluationResult, ConstraintViolation, ConstraintWarning, TimeWindowConstraint, RiskLevel } from '@vess-id/ai-identity-types';
|
|
2
2
|
export * from '@vess-id/ai-identity-types';
|
|
3
|
-
import Ajv from 'ajv';
|
|
4
3
|
import * as jose from 'jose';
|
|
5
4
|
import { JWK } from 'jose';
|
|
5
|
+
import Ajv from 'ajv';
|
|
6
6
|
import { SDJwtVcInstance } from '@sd-jwt/sd-jwt-vc';
|
|
7
7
|
import { DisclosureFrame } from '@sd-jwt/types';
|
|
8
8
|
|
|
@@ -730,6 +730,16 @@ declare class AgentDIDManager {
|
|
|
730
730
|
private deleteAgentDIDMapping;
|
|
731
731
|
}
|
|
732
732
|
|
|
733
|
+
interface KeyPairGenerationResult {
|
|
734
|
+
did: string;
|
|
735
|
+
publicKey: JWK;
|
|
736
|
+
privateKey: JWK;
|
|
737
|
+
}
|
|
738
|
+
declare class UserKeyPairManager {
|
|
739
|
+
generateKeyPair(): Promise<KeyPairGenerationResult>;
|
|
740
|
+
extractPublicKeyInfo(did: string): JWK;
|
|
741
|
+
}
|
|
742
|
+
|
|
733
743
|
interface OrganizationDisclosureConfig {
|
|
734
744
|
organizationDid: string;
|
|
735
745
|
defaultFields: string[];
|
|
@@ -3001,4 +3011,4 @@ declare function getKeyIdFromDid(did: string): string;
|
|
|
3001
3011
|
|
|
3002
3012
|
declare const version = "0.0.1";
|
|
3003
3013
|
|
|
3004
|
-
export { type ABACPolicyEngine, ACTION_REGISTRY, AIdentityClient, type AIdentityConfig, APIVCManager, type AbacDecision, type AbacInput, type ActionMeta, type ActionRegistry, AgentDIDManager, AgentManager, AllowAllAbac, type CapabilityMeta, type CheckPermissionInput, type CheckPermissionResult, ConstraintEvaluator, type ConstraintEvaluatorOptions, type CredentialDisclosureConfig, type CredentialRef, type CredentialStatusInfo, type CredentialStore, type DecisionTrace, DisclosureConfigManager, DummyCreds, DummyVpVerifier, FilesystemKeyStorage, type JsonSchema, KeyManager, type KeyRotationConfig, type KeyRotationInfo, KeyRotationManager, type KeyStorageConfig, type KeyStorageProvider, type MemoryDocument, MemoryKeyStorage, MemoryManager, type MemoryQuery, type MemoryQueryResult, MetricsManager, type OperationMetric, type OrganizationDisclosureConfig, type PlanDelegationInput, type PlanDelegationResult, type Provider, type ReBACChecker, type Relation, type ResourceRef, type ResourceScope, type ResourceType, type RevocationList, type RevocationListEntry, RevocationManager, type SDJWTMetrics, SDJwtClient, SimpleRebac, type ToolDefinition, ToolManager, UserIdentityManager, VCManager, VPManager, type VerifiedVcClaims, type VpVerifier, checkPermissionWithVP, configure, createAjv, createDidJwk, defaultConstraintEvaluator, evaluateConstraints, extractPublicKey, extractPublicKeyFromDid, generateKeyPair, generateNonce, getClient, getKeyIdFromDid, getRequiredRelations, getRequiredScopes, indexActions, indexCapabilities, isValidDidJwk, loadActionRegistryFromFile, loadActionRegistryFromObject, planDelegationForVC, resolveActionsFromSelection, signJWT, validateRegistryObject, verifyJWT, version };
|
|
3014
|
+
export { type ABACPolicyEngine, ACTION_REGISTRY, AIdentityClient, type AIdentityConfig, APIVCManager, type AbacDecision, type AbacInput, type ActionMeta, type ActionRegistry, AgentDIDManager, AgentManager, AllowAllAbac, type CapabilityMeta, type CheckPermissionInput, type CheckPermissionResult, ConstraintEvaluator, type ConstraintEvaluatorOptions, type CredentialDisclosureConfig, type CredentialRef, type CredentialStatusInfo, type CredentialStore, type DecisionTrace, DisclosureConfigManager, DummyCreds, DummyVpVerifier, FilesystemKeyStorage, type JsonSchema, KeyManager, type KeyPairGenerationResult, type KeyRotationConfig, type KeyRotationInfo, KeyRotationManager, type KeyStorageConfig, type KeyStorageProvider, type MemoryDocument, MemoryKeyStorage, MemoryManager, type MemoryQuery, type MemoryQueryResult, MetricsManager, type OperationMetric, type OrganizationDisclosureConfig, type PlanDelegationInput, type PlanDelegationResult, type Provider, type ReBACChecker, type Relation, type ResourceRef, type ResourceScope, type ResourceType, type RevocationList, type RevocationListEntry, RevocationManager, type SDJWTMetrics, SDJwtClient, SimpleRebac, type ToolDefinition, ToolManager, UserIdentityManager, UserKeyPairManager, VCManager, VPManager, type VerifiedVcClaims, type VpVerifier, checkPermissionWithVP, configure, createAjv, createDidJwk, defaultConstraintEvaluator, evaluateConstraints, extractPublicKey, extractPublicKeyFromDid, generateKeyPair, generateNonce, getClient, getKeyIdFromDid, getRequiredRelations, getRequiredScopes, indexActions, indexCapabilities, isValidDidJwk, loadActionRegistryFromFile, loadActionRegistryFromObject, planDelegationForVC, resolveActionsFromSelection, signJWT, validateRegistryObject, verifyJWT, version };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { VerifiablePresentation, VPRequest, Agent, DIDDocument, VCTemplate, ConnectorResponse, ToolPermissionRequest, OrganizationConfig, Grant, CreateGrantRequest, GrantStatus, CheckGrantPermissionRequest, CheckGrantPermissionResult, UpdateGrantRequest, CredentialType, IssueSDJWTVCRequest, IssueSDJWTVCResult, VerifySDJWTVCResult, GrantConstraints, EvaluationContext, ConstraintEvaluationResult, ConstraintViolation, ConstraintWarning, TimeWindowConstraint, RiskLevel } from '@vess-id/ai-identity-types';
|
|
2
2
|
export * from '@vess-id/ai-identity-types';
|
|
3
|
-
import Ajv from 'ajv';
|
|
4
3
|
import * as jose from 'jose';
|
|
5
4
|
import { JWK } from 'jose';
|
|
5
|
+
import Ajv from 'ajv';
|
|
6
6
|
import { SDJwtVcInstance } from '@sd-jwt/sd-jwt-vc';
|
|
7
7
|
import { DisclosureFrame } from '@sd-jwt/types';
|
|
8
8
|
|
|
@@ -730,6 +730,16 @@ declare class AgentDIDManager {
|
|
|
730
730
|
private deleteAgentDIDMapping;
|
|
731
731
|
}
|
|
732
732
|
|
|
733
|
+
interface KeyPairGenerationResult {
|
|
734
|
+
did: string;
|
|
735
|
+
publicKey: JWK;
|
|
736
|
+
privateKey: JWK;
|
|
737
|
+
}
|
|
738
|
+
declare class UserKeyPairManager {
|
|
739
|
+
generateKeyPair(): Promise<KeyPairGenerationResult>;
|
|
740
|
+
extractPublicKeyInfo(did: string): JWK;
|
|
741
|
+
}
|
|
742
|
+
|
|
733
743
|
interface OrganizationDisclosureConfig {
|
|
734
744
|
organizationDid: string;
|
|
735
745
|
defaultFields: string[];
|
|
@@ -3001,4 +3011,4 @@ declare function getKeyIdFromDid(did: string): string;
|
|
|
3001
3011
|
|
|
3002
3012
|
declare const version = "0.0.1";
|
|
3003
3013
|
|
|
3004
|
-
export { type ABACPolicyEngine, ACTION_REGISTRY, AIdentityClient, type AIdentityConfig, APIVCManager, type AbacDecision, type AbacInput, type ActionMeta, type ActionRegistry, AgentDIDManager, AgentManager, AllowAllAbac, type CapabilityMeta, type CheckPermissionInput, type CheckPermissionResult, ConstraintEvaluator, type ConstraintEvaluatorOptions, type CredentialDisclosureConfig, type CredentialRef, type CredentialStatusInfo, type CredentialStore, type DecisionTrace, DisclosureConfigManager, DummyCreds, DummyVpVerifier, FilesystemKeyStorage, type JsonSchema, KeyManager, type KeyRotationConfig, type KeyRotationInfo, KeyRotationManager, type KeyStorageConfig, type KeyStorageProvider, type MemoryDocument, MemoryKeyStorage, MemoryManager, type MemoryQuery, type MemoryQueryResult, MetricsManager, type OperationMetric, type OrganizationDisclosureConfig, type PlanDelegationInput, type PlanDelegationResult, type Provider, type ReBACChecker, type Relation, type ResourceRef, type ResourceScope, type ResourceType, type RevocationList, type RevocationListEntry, RevocationManager, type SDJWTMetrics, SDJwtClient, SimpleRebac, type ToolDefinition, ToolManager, UserIdentityManager, VCManager, VPManager, type VerifiedVcClaims, type VpVerifier, checkPermissionWithVP, configure, createAjv, createDidJwk, defaultConstraintEvaluator, evaluateConstraints, extractPublicKey, extractPublicKeyFromDid, generateKeyPair, generateNonce, getClient, getKeyIdFromDid, getRequiredRelations, getRequiredScopes, indexActions, indexCapabilities, isValidDidJwk, loadActionRegistryFromFile, loadActionRegistryFromObject, planDelegationForVC, resolveActionsFromSelection, signJWT, validateRegistryObject, verifyJWT, version };
|
|
3014
|
+
export { type ABACPolicyEngine, ACTION_REGISTRY, AIdentityClient, type AIdentityConfig, APIVCManager, type AbacDecision, type AbacInput, type ActionMeta, type ActionRegistry, AgentDIDManager, AgentManager, AllowAllAbac, type CapabilityMeta, type CheckPermissionInput, type CheckPermissionResult, ConstraintEvaluator, type ConstraintEvaluatorOptions, type CredentialDisclosureConfig, type CredentialRef, type CredentialStatusInfo, type CredentialStore, type DecisionTrace, DisclosureConfigManager, DummyCreds, DummyVpVerifier, FilesystemKeyStorage, type JsonSchema, KeyManager, type KeyPairGenerationResult, type KeyRotationConfig, type KeyRotationInfo, KeyRotationManager, type KeyStorageConfig, type KeyStorageProvider, type MemoryDocument, MemoryKeyStorage, MemoryManager, type MemoryQuery, type MemoryQueryResult, MetricsManager, type OperationMetric, type OrganizationDisclosureConfig, type PlanDelegationInput, type PlanDelegationResult, type Provider, type ReBACChecker, type Relation, type ResourceRef, type ResourceScope, type ResourceType, type RevocationList, type RevocationListEntry, RevocationManager, type SDJWTMetrics, SDJwtClient, SimpleRebac, type ToolDefinition, ToolManager, UserIdentityManager, UserKeyPairManager, VCManager, VPManager, type VerifiedVcClaims, type VpVerifier, checkPermissionWithVP, configure, createAjv, createDidJwk, defaultConstraintEvaluator, evaluateConstraints, extractPublicKey, extractPublicKeyFromDid, generateKeyPair, generateNonce, getClient, getKeyIdFromDid, getRequiredRelations, getRequiredScopes, indexActions, indexCapabilities, isValidDidJwk, loadActionRegistryFromFile, loadActionRegistryFromObject, planDelegationForVC, resolveActionsFromSelection, signJWT, validateRegistryObject, verifyJWT, version };
|
package/dist/index.js
CHANGED
|
@@ -52,6 +52,7 @@ __export(index_exports, {
|
|
|
52
52
|
SimpleRebac: () => SimpleRebac,
|
|
53
53
|
ToolManager: () => ToolManager,
|
|
54
54
|
UserIdentityManager: () => UserIdentityManager,
|
|
55
|
+
UserKeyPairManager: () => UserKeyPairManager,
|
|
55
56
|
VCManager: () => VCManager,
|
|
56
57
|
VPManager: () => VPManager,
|
|
57
58
|
checkPermissionWithVP: () => checkPermissionWithVP,
|
|
@@ -158,7 +159,7 @@ var os = __toESM(require("os"));
|
|
|
158
159
|
var FilesystemKeyStorage = class {
|
|
159
160
|
keyStorePath;
|
|
160
161
|
constructor(config) {
|
|
161
|
-
this.keyStorePath = config?.options?.path || path.join(os.homedir(), ".vess", "keys");
|
|
162
|
+
this.keyStorePath = config?.options?.path || path.join(os.homedir(), ".vess-aidentity", "keys");
|
|
162
163
|
}
|
|
163
164
|
async store(id, encryptedKey) {
|
|
164
165
|
await this.ensureKeyStoreExists();
|
|
@@ -967,7 +968,7 @@ var AgentDIDManager = class {
|
|
|
967
968
|
const fs3 = await import("fs/promises");
|
|
968
969
|
const path3 = await import("path");
|
|
969
970
|
const os2 = await import("os");
|
|
970
|
-
const mappingDir = path3.join(os2.homedir(), ".vess", "agent-dids");
|
|
971
|
+
const mappingDir = path3.join(os2.homedir(), ".vess-aidentity", "agent-dids");
|
|
971
972
|
try {
|
|
972
973
|
const files = await fs3.readdir(mappingDir);
|
|
973
974
|
const results = [];
|
|
@@ -993,7 +994,7 @@ var AgentDIDManager = class {
|
|
|
993
994
|
const fs3 = await import("fs/promises");
|
|
994
995
|
const path3 = await import("path");
|
|
995
996
|
const os2 = await import("os");
|
|
996
|
-
const mappingDir = path3.join(os2.homedir(), ".vess", "agent-dids");
|
|
997
|
+
const mappingDir = path3.join(os2.homedir(), ".vess-aidentity", "agent-dids");
|
|
997
998
|
await fs3.mkdir(mappingDir, { recursive: true });
|
|
998
999
|
const mappingFile = path3.join(mappingDir, `${agentId}.did`);
|
|
999
1000
|
await fs3.writeFile(mappingFile, did, "utf-8");
|
|
@@ -1296,7 +1297,7 @@ var UserIdentityManager = class {
|
|
|
1296
1297
|
const fs3 = await import("fs/promises");
|
|
1297
1298
|
const path3 = await import("path");
|
|
1298
1299
|
const os2 = await import("os");
|
|
1299
|
-
const configDir = path3.join(os2.homedir(), ".vess");
|
|
1300
|
+
const configDir = path3.join(os2.homedir(), ".vess-aidentity");
|
|
1300
1301
|
await fs3.mkdir(configDir, { recursive: true });
|
|
1301
1302
|
const userDIDFile = path3.join(configDir, "user-did.txt");
|
|
1302
1303
|
await fs3.writeFile(userDIDFile, did, "utf-8");
|
|
@@ -1308,7 +1309,7 @@ var UserIdentityManager = class {
|
|
|
1308
1309
|
const fs3 = await import("fs/promises");
|
|
1309
1310
|
const path3 = await import("path");
|
|
1310
1311
|
const os2 = await import("os");
|
|
1311
|
-
const userDIDFile = path3.join(os2.homedir(), ".vess", "user-did.txt");
|
|
1312
|
+
const userDIDFile = path3.join(os2.homedir(), ".vess-aidentity", "user-did.txt");
|
|
1312
1313
|
try {
|
|
1313
1314
|
return await fs3.readFile(userDIDFile, "utf-8");
|
|
1314
1315
|
} catch {
|
|
@@ -1322,7 +1323,7 @@ var UserIdentityManager = class {
|
|
|
1322
1323
|
const fs3 = await import("fs/promises");
|
|
1323
1324
|
const path3 = await import("path");
|
|
1324
1325
|
const os2 = await import("os");
|
|
1325
|
-
const userDIDFile = path3.join(os2.homedir(), ".vess", "user-did.txt");
|
|
1326
|
+
const userDIDFile = path3.join(os2.homedir(), ".vess-aidentity", "user-did.txt");
|
|
1326
1327
|
try {
|
|
1327
1328
|
await fs3.unlink(userDIDFile);
|
|
1328
1329
|
} catch {
|
|
@@ -2811,6 +2812,32 @@ function getClient(config, password) {
|
|
|
2811
2812
|
return defaultClient;
|
|
2812
2813
|
}
|
|
2813
2814
|
|
|
2815
|
+
// src/identity/user-key-pair-manager.ts
|
|
2816
|
+
var UserKeyPairManager = class {
|
|
2817
|
+
/**
|
|
2818
|
+
* Generate a new key pair and create a did:jwk DID
|
|
2819
|
+
*/
|
|
2820
|
+
async generateKeyPair() {
|
|
2821
|
+
const keyPair = await SDJwtClient.generateKeyPair();
|
|
2822
|
+
const did = createDidJwk(keyPair.publicKey);
|
|
2823
|
+
return {
|
|
2824
|
+
did,
|
|
2825
|
+
publicKey: keyPair.publicKey,
|
|
2826
|
+
privateKey: keyPair.privateKey
|
|
2827
|
+
};
|
|
2828
|
+
}
|
|
2829
|
+
/**
|
|
2830
|
+
* Extract public key info from a did:jwk DID
|
|
2831
|
+
* @throws Error if the DID is not in did:jwk format
|
|
2832
|
+
*/
|
|
2833
|
+
extractPublicKeyInfo(did) {
|
|
2834
|
+
if (!did.startsWith("did:jwk:")) {
|
|
2835
|
+
throw new Error("Only did:jwk format is supported");
|
|
2836
|
+
}
|
|
2837
|
+
return extractPublicKeyFromDid(did);
|
|
2838
|
+
}
|
|
2839
|
+
};
|
|
2840
|
+
|
|
2814
2841
|
// src/vc/api-vc-manager.ts
|
|
2815
2842
|
var import_ai_identity_types2 = require("@vess-id/ai-identity-types");
|
|
2816
2843
|
|
|
@@ -4753,6 +4780,7 @@ var version = "0.0.1";
|
|
|
4753
4780
|
SimpleRebac,
|
|
4754
4781
|
ToolManager,
|
|
4755
4782
|
UserIdentityManager,
|
|
4783
|
+
UserKeyPairManager,
|
|
4756
4784
|
VCManager,
|
|
4757
4785
|
VPManager,
|
|
4758
4786
|
checkPermissionWithVP,
|