a2a-did 0.1.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.
Files changed (95) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +180 -0
  3. package/dist/a2a/constants.d.ts +10 -0
  4. package/dist/a2a/constants.d.ts.map +1 -0
  5. package/dist/a2a/constants.js +10 -0
  6. package/dist/a2a/constants.js.map +1 -0
  7. package/dist/a2a/index.d.ts +23 -0
  8. package/dist/a2a/index.d.ts.map +1 -0
  9. package/dist/a2a/index.js +27 -0
  10. package/dist/a2a/index.js.map +1 -0
  11. package/dist/a2a/resolution.d.ts +20 -0
  12. package/dist/a2a/resolution.d.ts.map +1 -0
  13. package/dist/a2a/resolution.js +55 -0
  14. package/dist/a2a/resolution.js.map +1 -0
  15. package/dist/a2a/signing.d.ts +24 -0
  16. package/dist/a2a/signing.d.ts.map +1 -0
  17. package/dist/a2a/signing.js +31 -0
  18. package/dist/a2a/signing.js.map +1 -0
  19. package/dist/a2a/utils.d.ts +29 -0
  20. package/dist/a2a/utils.d.ts.map +1 -0
  21. package/dist/a2a/utils.js +70 -0
  22. package/dist/a2a/utils.js.map +1 -0
  23. package/dist/a2a/verification.d.ts +42 -0
  24. package/dist/a2a/verification.d.ts.map +1 -0
  25. package/dist/a2a/verification.js +156 -0
  26. package/dist/a2a/verification.js.map +1 -0
  27. package/dist/agent.d.ts +99 -0
  28. package/dist/agent.d.ts.map +1 -0
  29. package/dist/agent.js +149 -0
  30. package/dist/agent.js.map +1 -0
  31. package/dist/did/config-types.d.ts +37 -0
  32. package/dist/did/config-types.d.ts.map +1 -0
  33. package/dist/did/config-types.js +6 -0
  34. package/dist/did/config-types.js.map +1 -0
  35. package/dist/did/document.d.ts +20 -0
  36. package/dist/did/document.d.ts.map +1 -0
  37. package/dist/did/document.js +21 -0
  38. package/dist/did/document.js.map +1 -0
  39. package/dist/did/factory.d.ts +31 -0
  40. package/dist/did/factory.d.ts.map +1 -0
  41. package/dist/did/factory.js +46 -0
  42. package/dist/did/factory.js.map +1 -0
  43. package/dist/did/handlers/ethr-handler.d.ts +62 -0
  44. package/dist/did/handlers/ethr-handler.d.ts.map +1 -0
  45. package/dist/did/handlers/ethr-handler.js +184 -0
  46. package/dist/did/handlers/ethr-handler.js.map +1 -0
  47. package/dist/did/handlers/web-handler.d.ts +73 -0
  48. package/dist/did/handlers/web-handler.d.ts.map +1 -0
  49. package/dist/did/handlers/web-handler.js +170 -0
  50. package/dist/did/handlers/web-handler.js.map +1 -0
  51. package/dist/did/index.d.ts +10 -0
  52. package/dist/did/index.d.ts.map +1 -0
  53. package/dist/did/index.js +15 -0
  54. package/dist/did/index.js.map +1 -0
  55. package/dist/did/resolver.d.ts +85 -0
  56. package/dist/did/resolver.d.ts.map +1 -0
  57. package/dist/did/resolver.js +120 -0
  58. package/dist/did/resolver.js.map +1 -0
  59. package/dist/did/resolvers/ethr.d.ts +74 -0
  60. package/dist/did/resolvers/ethr.d.ts.map +1 -0
  61. package/dist/did/resolvers/ethr.js +67 -0
  62. package/dist/did/resolvers/ethr.js.map +1 -0
  63. package/dist/did/resolvers/index.d.ts +8 -0
  64. package/dist/did/resolvers/index.d.ts.map +1 -0
  65. package/dist/did/resolvers/index.js +8 -0
  66. package/dist/did/resolvers/index.js.map +1 -0
  67. package/dist/did/resolvers/web.d.ts +13 -0
  68. package/dist/did/resolvers/web.d.ts.map +1 -0
  69. package/dist/did/resolvers/web.js +97 -0
  70. package/dist/did/resolvers/web.js.map +1 -0
  71. package/dist/did/service-loader.d.ts +15 -0
  72. package/dist/did/service-loader.d.ts.map +1 -0
  73. package/dist/did/service-loader.js +20 -0
  74. package/dist/did/service-loader.js.map +1 -0
  75. package/dist/did/service.d.ts +99 -0
  76. package/dist/did/service.d.ts.map +1 -0
  77. package/dist/did/service.js +75 -0
  78. package/dist/did/service.js.map +1 -0
  79. package/dist/did/signing.d.ts +19 -0
  80. package/dist/did/signing.d.ts.map +1 -0
  81. package/dist/did/signing.js +37 -0
  82. package/dist/did/signing.js.map +1 -0
  83. package/dist/did/types.d.ts +134 -0
  84. package/dist/did/types.d.ts.map +1 -0
  85. package/dist/did/types.js +2 -0
  86. package/dist/did/types.js.map +1 -0
  87. package/dist/index.d.ts +15 -0
  88. package/dist/index.d.ts.map +1 -0
  89. package/dist/index.js +17 -0
  90. package/dist/index.js.map +1 -0
  91. package/dist/types.d.ts +25 -0
  92. package/dist/types.d.ts.map +1 -0
  93. package/dist/types.js +2 -0
  94. package/dist/types.js.map +1 -0
  95. package/package.json +70 -0
@@ -0,0 +1,62 @@
1
+ import type { DIDMethodHandler } from '../service.js';
2
+ import type { DIDIdentity, ServiceEndpoint } from '../types.js';
3
+ import type { DIDConfig } from '../config-types.js';
4
+ /**
5
+ * Ethereum DID Method Handler
6
+ * Implements DID operations for did:ethr method using EIP-1056 registry
7
+ * @implements {DIDMethodHandler}
8
+ */
9
+ export declare class DIDEthrMethodHandler implements DIDMethodHandler {
10
+ /**
11
+ * Create a new did:ethr identity
12
+ * @param options - Configuration options
13
+ * @param options.agentId - Agent unique identifier
14
+ * @param options.config - Ethereum DID configuration (network, rpcUrl)
15
+ * @param options.services - Optional service endpoints to register
16
+ * @returns Promise resolving to DID identity with document
17
+ * @throws {Error} When config type is not 'ethr' or rpcUrl is missing
18
+ */
19
+ createIdentity(options: {
20
+ agentId: string;
21
+ config: DIDConfig;
22
+ services?: ServiceEndpoint[];
23
+ }): Promise<DIDIdentity>;
24
+ /**
25
+ * Register a service endpoint on-chain for did:ethr
26
+ * Updates the EIP-1056 registry with the new service endpoint
27
+ * @param options - Registration options
28
+ * @param options.did - DID string (e.g., "did:ethr:sepolia:0x...")
29
+ * @param options.privateKey - Private key for signing transactions (hex string)
30
+ * @param options.serviceEndpoint - Service endpoint URI (e.g., "ipfs://...")
31
+ * @param options.config - Ethereum DID configuration (network, rpcUrl)
32
+ * @returns Promise resolving to array of transaction hashes
33
+ * @throws {Error} When config type is not 'ethr' or rpcUrl is missing
34
+ */
35
+ registerServiceEndpoint(options: {
36
+ did: string;
37
+ privateKey: string;
38
+ serviceEndpoint: string;
39
+ config: DIDConfig;
40
+ }): Promise<string[]>;
41
+ /**
42
+ * Extract wallet address from did:ethr
43
+ * @param did - DID string (e.g., "did:ethr:sepolia:0x1234...")
44
+ * @returns Ethereum wallet address (e.g., "0x1234...")
45
+ * @example
46
+ * extractWalletAddress("did:ethr:sepolia:0x1234...") // returns "0x1234..."
47
+ */
48
+ extractWalletAddress(did: string): string | undefined;
49
+ /**
50
+ * Get key ID for did:ethr
51
+ * @param did - DID string
52
+ * @returns Key identifier with #controller fragment
53
+ * @example
54
+ * getKeyId("did:ethr:sepolia:0x1234...") // returns "did:ethr:sepolia:0x1234...#controller"
55
+ */
56
+ getKeyId(did: string): string;
57
+ /**
58
+ * Get network name for DID format
59
+ */
60
+ private getNetworkName;
61
+ }
62
+ //# sourceMappingURL=ethr-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ethr-handler.d.ts","sourceRoot":"","sources":["../../../src/did/handlers/ethr-handler.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAOpD;;;;GAIG;AACH,qBAAa,oBAAqB,YAAW,gBAAgB;IAC3D;;;;;;;;OAQG;IACG,cAAc,CAAC,OAAO,EAAE;QAC5B,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,SAAS,CAAC;QAClB,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAC;KAC9B,GAAG,OAAO,CAAC,WAAW,CAAC;IA+DxB;;;;;;;;;;OAUG;IACG,uBAAuB,CAAC,OAAO,EAAE;QACrC,GAAG,EAAE,MAAM,CAAC;QACZ,UAAU,EAAE,MAAM,CAAC;QACnB,eAAe,EAAE,MAAM,CAAC;QACxB,MAAM,EAAE,SAAS,CAAC;KACnB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAkErB;;;;;;OAMG;IACH,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAKrD;;;;;;OAMG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAI7B;;OAEG;IACH,OAAO,CAAC,cAAc;CAevB"}
@@ -0,0 +1,184 @@
1
+ /**
2
+ * Ethereum DID Method Handler
3
+ * Handles DID operations for did:ethr
4
+ */
5
+ import { EthrDID } from 'ethr-did';
6
+ import { JsonRpcProvider, Wallet } from 'ethers';
7
+ import * as u8a from 'uint8arrays';
8
+ import { KNOWN_NETWORKS } from '../resolvers/ethr.js';
9
+ import { A2A_AGENT_CARD_SERVICE_TYPE } from '../../a2a/constants.js';
10
+ // Default validity period: 1 year in seconds
11
+ const DEFAULT_VALIDITY = 31536000;
12
+ /**
13
+ * Ethereum DID Method Handler
14
+ * Implements DID operations for did:ethr method using EIP-1056 registry
15
+ * @implements {DIDMethodHandler}
16
+ */
17
+ export class DIDEthrMethodHandler {
18
+ /**
19
+ * Create a new did:ethr identity
20
+ * @param options - Configuration options
21
+ * @param options.agentId - Agent unique identifier
22
+ * @param options.config - Ethereum DID configuration (network, rpcUrl)
23
+ * @param options.services - Optional service endpoints to register
24
+ * @returns Promise resolving to DID identity with document
25
+ * @throws {Error} When config type is not 'ethr' or rpcUrl is missing
26
+ */
27
+ async createIdentity(options) {
28
+ const config = options.config;
29
+ if (config.type !== 'ethr') {
30
+ throw new Error('Invalid config for did:ethr');
31
+ }
32
+ if (!config.rpcUrl) {
33
+ throw new Error(`rpcUrl is required for network: ${config.network}`);
34
+ }
35
+ // Get network configuration
36
+ const known = KNOWN_NETWORKS[config.network];
37
+ const chainId = config.chainId ?? known?.chainId;
38
+ const registry = config.registry ?? known?.registry;
39
+ if (!chainId || !registry) {
40
+ throw new Error(`Unknown network "${config.network}". Provide chainId and registry.`);
41
+ }
42
+ // Generate random Ethereum wallet
43
+ const wallet = Wallet.createRandom();
44
+ const privateKeyHex = wallet.privateKey.slice(2); // Remove '0x' prefix
45
+ const privateKey = u8a.fromString(privateKeyHex, 'base16');
46
+ // Create JSON RPC provider
47
+ const jsonRpcProvider = new JsonRpcProvider(config.rpcUrl);
48
+ // Connect wallet to provider for signing transactions
49
+ const connectedWallet = wallet.connect(jsonRpcProvider);
50
+ // Create EthrDID instance
51
+ const ethrDid = new EthrDID({
52
+ identifier: wallet.address,
53
+ privateKey: privateKeyHex,
54
+ provider: jsonRpcProvider,
55
+ txSigner: connectedWallet,
56
+ chainNameOrId: chainId,
57
+ registry: registry,
58
+ });
59
+ // Get network name for DID format
60
+ const networkName = this.getNetworkName(config.network, chainId);
61
+ // DID format: did:ethr:sepolia:0x...
62
+ const did = `did:ethr:${networkName}:${wallet.address}`;
63
+ const keyId = `${did}#controller`;
64
+ // EthrDID always has a signer when created with privateKey
65
+ if (!ethrDid.signer) {
66
+ throw new Error('EthrDID signer not available');
67
+ }
68
+ // Note: On-chain service registration is skipped during creation
69
+ // Call registerServiceEndpoint() separately after funding the wallet
70
+ return {
71
+ did,
72
+ keyId,
73
+ signer: ethrDid.signer,
74
+ privateKey: new Uint8Array(privateKey),
75
+ // document is undefined - did:ethr resolves from on-chain via resolveDID()
76
+ };
77
+ }
78
+ /**
79
+ * Register a service endpoint on-chain for did:ethr
80
+ * Updates the EIP-1056 registry with the new service endpoint
81
+ * @param options - Registration options
82
+ * @param options.did - DID string (e.g., "did:ethr:sepolia:0x...")
83
+ * @param options.privateKey - Private key for signing transactions (hex string)
84
+ * @param options.serviceEndpoint - Service endpoint URI (e.g., "ipfs://...")
85
+ * @param options.config - Ethereum DID configuration (network, rpcUrl)
86
+ * @returns Promise resolving to array of transaction hashes
87
+ * @throws {Error} When config type is not 'ethr' or rpcUrl is missing
88
+ */
89
+ async registerServiceEndpoint(options) {
90
+ const config = options.config;
91
+ if (config.type !== 'ethr') {
92
+ throw new Error('Invalid config for did:ethr');
93
+ }
94
+ // Resolve RPC URL
95
+ if (!config.rpcUrl) {
96
+ throw new Error(`rpcUrl is required for network: ${config.network}`);
97
+ }
98
+ // Get network configuration
99
+ const known = KNOWN_NETWORKS[config.network];
100
+ const chainId = config.chainId ?? known?.chainId;
101
+ const registry = config.registry ?? known?.registry;
102
+ if (!chainId || !registry) {
103
+ throw new Error(`Unknown network "${config.network}". Provide chainId and registry.`);
104
+ }
105
+ // Reconstruct wallet from private key
106
+ const privateKeyHex = options.privateKey.startsWith('0x')
107
+ ? options.privateKey
108
+ : `0x${options.privateKey}`;
109
+ const wallet = new Wallet(privateKeyHex);
110
+ // Create JSON RPC provider
111
+ const jsonRpcProvider = new JsonRpcProvider(config.rpcUrl);
112
+ const connectedWallet = wallet.connect(jsonRpcProvider);
113
+ // Create EthrDID instance
114
+ const ethrDid = new EthrDID({
115
+ identifier: wallet.address,
116
+ privateKey: privateKeyHex.slice(2),
117
+ provider: jsonRpcProvider,
118
+ txSigner: connectedWallet,
119
+ chainNameOrId: chainId,
120
+ registry: registry,
121
+ });
122
+ // Register service endpoint on-chain
123
+ // Note: Service id is auto-generated by resolver as ${did}#service-${eventIndex}
124
+ // Only type and serviceEndpoint are stored on-chain via EIP-1056
125
+ const serviceType = A2A_AGENT_CARD_SERVICE_TYPE;
126
+ const attributeKey = `did/svc/${serviceType}`;
127
+ const endpoint = typeof options.serviceEndpoint === 'string'
128
+ ? options.serviceEndpoint
129
+ : JSON.stringify(options.serviceEndpoint);
130
+ try {
131
+ // setAttribute() sends a transaction to the EthereumDIDRegistry
132
+ const tx = await ethrDid.setAttribute(attributeKey, endpoint, DEFAULT_VALIDITY);
133
+ return [tx];
134
+ }
135
+ catch (error) {
136
+ // If no ETH for gas, provide helpful message
137
+ if (error instanceof Error && error.message.includes('insufficient funds')) {
138
+ throw new Error(`Insufficient funds for on-chain registration. ` +
139
+ `Get Sepolia ETH from faucet for address: ${ethrDid.address}`);
140
+ }
141
+ throw error;
142
+ }
143
+ }
144
+ /**
145
+ * Extract wallet address from did:ethr
146
+ * @param did - DID string (e.g., "did:ethr:sepolia:0x1234...")
147
+ * @returns Ethereum wallet address (e.g., "0x1234...")
148
+ * @example
149
+ * extractWalletAddress("did:ethr:sepolia:0x1234...") // returns "0x1234..."
150
+ */
151
+ extractWalletAddress(did) {
152
+ const parts = did.split(':');
153
+ return parts[parts.length - 1];
154
+ }
155
+ /**
156
+ * Get key ID for did:ethr
157
+ * @param did - DID string
158
+ * @returns Key identifier with #controller fragment
159
+ * @example
160
+ * getKeyId("did:ethr:sepolia:0x1234...") // returns "did:ethr:sepolia:0x1234...#controller"
161
+ */
162
+ getKeyId(did) {
163
+ return `${did}#controller`;
164
+ }
165
+ /**
166
+ * Get network name for DID format
167
+ */
168
+ getNetworkName(network, chainId) {
169
+ if (network) {
170
+ return network;
171
+ }
172
+ switch (chainId) {
173
+ case 1:
174
+ return 'mainnet';
175
+ case 11155111:
176
+ return 'sepolia';
177
+ case 5:
178
+ return 'goerli';
179
+ default:
180
+ return `0x${chainId.toString(16)}`;
181
+ }
182
+ }
183
+ }
184
+ //# sourceMappingURL=ethr-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ethr-handler.js","sourceRoot":"","sources":["../../../src/did/handlers/ethr-handler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AAInC,OAAO,EAAE,cAAc,EAAqB,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAErE,6CAA6C;AAC7C,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;;;GAIG;AACH,MAAM,OAAO,oBAAoB;IAC/B;;;;;;;;OAQG;IACH,K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AC,YAAY,CAAC,YAAY,EAAE,QAAQ,EAAE,gBAAgB,CAAC,CAAC;YAChF,OAAO,CAAC,EAAE,CAAC,CAAC;QACd,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,6CAA6C;YAC7C,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,CAAC;gBAC3E,MAAM,IAAI,KAAK,CACb,gDAAgD;oBAC9C,4CAA4C,OAAO,CAAC,OAAO,EAAE,CAChE,CAAC;YACJ,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED;;;;;;OAMG;IACH,oBAAoB,CAAC,GAAW;QAC9B,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC7B,OAAO,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACjC,CAAC;IAED;;;;;;OAMG;IACH,QAAQ,CAAC,GAAW;QAClB,OAAO,GAAG,GAAG,aAAa,CAAC;IAC7B,CAAC;IAED;;OAEG;IACK,cAAc,CAAC,OAAe,EAAE,OAAe;QACrD,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,QAAQ,OAAO,EAAE,CAAC;YAChB,KAAK,CAAC;gBACJ,OAAO,SAAS,CAAC;YACnB,KAAK,QAAQ;gBACX,OAAO,SAAS,CAAC;YACnB,KAAK,CAAC;gBACJ,OAAO,QAAQ,CAAC;YAClB;gBACE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;QACvC,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,73 @@
1
+ import type { DIDMethodHandler } from '../service.js';
2
+ import type { DIDIdentity, ServiceEndpoint, DIDDocument } from '../types.js';
3
+ import type { DIDConfig } from '../config-types.js';
4
+ /**
5
+ * Web DID Method Handler
6
+ * Implements DID operations for did:web method
7
+ * did:web resolves DIDs through HTTPS to .well-known/did.json
8
+ * @implements {DIDMethodHandler}
9
+ */
10
+ export declare class DIDWebMethodHandler implements DIDMethodHandler {
11
+ /**
12
+ * Create a new did:web identity
13
+ * @param options - Configuration options
14
+ * @param options.agentId - Agent unique identifier
15
+ * @param options.config - Web DID configuration (domain, port)
16
+ * @param options.services - Optional service endpoints to include in DID Document
17
+ * @returns Promise resolving to DID identity with document
18
+ * @throws {Error} When config type is not 'web' or domain is missing
19
+ */
20
+ createIdentity(options: {
21
+ agentId: string;
22
+ config: DIDConfig;
23
+ services?: ServiceEndpoint[];
24
+ }): Promise<DIDIdentity>;
25
+ /**
26
+ * Register a service endpoint for did:web
27
+ * No-op for did:web as service endpoints are declared in the DID Document
28
+ * served at .well-known/did.json (handled during DID creation)
29
+ * @param _options - Registration options (unused)
30
+ * @returns Promise resolving to empty array (no transaction hashes)
31
+ */
32
+ registerServiceEndpoint(_options: {
33
+ did: string;
34
+ privateKey: string;
35
+ serviceEndpoint: string;
36
+ config: DIDConfig;
37
+ }): Promise<string[]>;
38
+ /**
39
+ * Extract wallet address from did:web
40
+ * @param _did - DID string (unused for did:web)
41
+ * @returns undefined (did:web has no wallet address concept)
42
+ */
43
+ extractWalletAddress(_did: string): string | undefined;
44
+ /**
45
+ * Get key ID for did:web
46
+ * @param did - DID string
47
+ * @returns Default key identifier with #key-1 fragment
48
+ * @example
49
+ * getKeyId("did:web:example.com") // returns "did:web:example.com#key-1"
50
+ */
51
+ getKeyId(did: string): string;
52
+ /**
53
+ * Build DID Document for an existing identity
54
+ * @param identity - The DID identity to build document for
55
+ * @param options - Optional creation options (controller, services)
56
+ * @returns The DID Document
57
+ */
58
+ buildDocumentForIdentity(identity: DIDIdentity, options?: {
59
+ controller?: string;
60
+ services?: ServiceEndpoint[];
61
+ }): DIDDocument;
62
+ /**
63
+ * Internal: Build DID Document
64
+ * @param did - The DID string
65
+ * @param keyId - The key ID
66
+ * @param publicKey - The public key bytes
67
+ * @param controller - Optional controller DID
68
+ * @param services - Optional service endpoints
69
+ * @returns The DID Document
70
+ */
71
+ private buildDocumentInternal;
72
+ }
73
+ //# sourceMappingURL=web-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-handler.d.ts","sourceRoot":"","sources":["../../../src/did/handlers/web-handler.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAc,MAAM,aAAa,CAAC;AACzF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AA+CpD;;;;;GAKG;AACH,qBAAa,mBAAoB,YAAW,gBAAgB;IAC1D;;;;;;;;OAQG;IACG,cAAc,CAAC,OAAO,EAAE;QAC5B,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,SAAS,CAAC;QAClB,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAC;KAC9B,GAAG,OAAO,CAAC,WAAW,CAAC;IAyCxB;;;;;;OAMG;IACG,uBAAuB,CAAC,QAAQ,EAAE;QACtC,GAAG,EAAE,MAAM,CAAC;QACZ,UAAU,EAAE,MAAM,CAAC;QACnB,eAAe,EAAE,MAAM,CAAC;QACxB,MAAM,EAAE,SAAS,CAAC;KACnB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAOrB;;;;OAIG;IACH,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAKtD;;;;;;OAMG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAI7B;;;;;OAKG;IACH,wBAAwB,CACtB,QAAQ,EAAE,WAAW,EACrB,OAAO,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAA;KAAE,GAC9D,WAAW;IAWd;;;;;;;;OAQG;IACH,OAAO,CAAC,qBAAqB;CAmC9B"}
@@ -0,0 +1,170 @@
1
+ /**
2
+ * Web DID Method Handler
3
+ * Handles DID operations for did:web
4
+ */
5
+ import { ES256KSigner } from 'did-jwt';
6
+ import { getPublicKey } from '@noble/secp256k1';
7
+ import * as u8a from 'uint8arrays';
8
+ /**
9
+ * Generate cryptographically secure random bytes
10
+ */
11
+ function randomBytes(size) {
12
+ const cryptoProvider = globalThis.crypto;
13
+ if (!cryptoProvider?.getRandomValues) {
14
+ throw new Error('crypto.getRandomValues is required for did:web key generation');
15
+ }
16
+ const bytes = new Uint8Array(size);
17
+ cryptoProvider.getRandomValues(bytes);
18
+ return bytes;
19
+ }
20
+ /**
21
+ * Convert public key to JWK format
22
+ * @param publicKey - The secp256k1 public key bytes (33 or 65 bytes)
23
+ * @returns The public key in JWK format
24
+ */
25
+ function publicKeyToJwk(publicKey) {
26
+ // For secp256k1, we need to handle compressed (33 bytes) or uncompressed (65 bytes) keys
27
+ // The compressed key starts with 0x02 or 0x03, uncompressed with 0x04
28
+ // For compressed key, we store it as-is and use crv: secp256k1
29
+ // JWK for secp256k1 uses x and y coordinates (32 bytes each)
30
+ if (publicKey.length === 33) {
31
+ // Compressed key - store as x coordinate with compressed flag
32
+ return {
33
+ kty: 'EC',
34
+ crv: 'secp256k1',
35
+ x: u8a.toString(publicKey.slice(1), 'base64url'),
36
+ };
37
+ }
38
+ // Uncompressed key (65 bytes: 04 || x || y)
39
+ const x = publicKey.slice(1, 33);
40
+ const y = publicKey.slice(33, 65);
41
+ return {
42
+ kty: 'EC',
43
+ crv: 'secp256k1',
44
+ x: u8a.toString(x, 'base64url'),
45
+ y: u8a.toString(y, 'base64url'),
46
+ };
47
+ }
48
+ /**
49
+ * Web DID Method Handler
50
+ * Implements DID operations for did:web method
51
+ * did:web resolves DIDs through HTTPS to .well-known/did.json
52
+ * @implements {DIDMethodHandler}
53
+ */
54
+ export class DIDWebMethodHandler {
55
+ /**
56
+ * Create a new did:web identity
57
+ * @param options - Configuration options
58
+ * @param options.agentId - Agent unique identifier
59
+ * @param options.config - Web DID configuration (domain, port)
60
+ * @param options.services - Optional service endpoints to include in DID Document
61
+ * @returns Promise resolving to DID identity with document
62
+ * @throws {Error} When config type is not 'web' or domain is missing
63
+ */
64
+ async createIdentity(options) {
65
+ const config = options.config;
66
+ if (config.type !== 'web') {
67
+ throw new Error('Invalid config for did:web');
68
+ }
69
+ if (!config.domain) {
70
+ throw new Error('Domain is required for did:web');
71
+ }
72
+ // Generate secp256k1 key pair
73
+ const privateKey = new Uint8Array(randomBytes(32));
74
+ const publicKey = getPublicKey(privateKey, false); // uncompressed
75
+ // Build DID string
76
+ // Encode special characters (: → %3A for port numbers)
77
+ const encodedDomain = `${config.domain}:${config.port}`.replace(/:/g, '%3A');
78
+ const path = `agents/${options.agentId}`;
79
+ const did = `did:web:${encodedDomain}:${path.split('/').join(':')}`;
80
+ const keyId = `${did}#key-1`;
81
+ const signer = ES256KSigner(privateKey);
82
+ // Build DID Document
83
+ const document = this.buildDocumentInternal(did, keyId, publicKey, config.controller, options.services);
84
+ return {
85
+ did,
86
+ keyId,
87
+ signer,
88
+ document,
89
+ privateKey,
90
+ };
91
+ }
92
+ /**
93
+ * Register a service endpoint for did:web
94
+ * No-op for did:web as service endpoints are declared in the DID Document
95
+ * served at .well-known/did.json (handled during DID creation)
96
+ * @param _options - Registration options (unused)
97
+ * @returns Promise resolving to empty array (no transaction hashes)
98
+ */
99
+ async registerServiceEndpoint(_options) {
100
+ // did:web does not require on-chain service registration
101
+ // Services are declared in the DID Document served at .well-known/did.json
102
+ // This is already handled during DID creation
103
+ return [];
104
+ }
105
+ /**
106
+ * Extract wallet address from did:web
107
+ * @param _did - DID string (unused for did:web)
108
+ * @returns undefined (did:web has no wallet address concept)
109
+ */
110
+ extractWalletAddress(_did) {
111
+ // did:web does not have a wallet address
112
+ return undefined;
113
+ }
114
+ /**
115
+ * Get key ID for did:web
116
+ * @param did - DID string
117
+ * @returns Default key identifier with #key-1 fragment
118
+ * @example
119
+ * getKeyId("did:web:example.com") // returns "did:web:example.com#key-1"
120
+ */
121
+ getKeyId(did) {
122
+ return `${did}#key-1`;
123
+ }
124
+ /**
125
+ * Build DID Document for an existing identity
126
+ * @param identity - The DID identity to build document for
127
+ * @param options - Optional creation options (controller, services)
128
+ * @returns The DID Document
129
+ */
130
+ buildDocumentForIdentity(identity, options) {
131
+ const publicKey = getPublicKey(identity.privateKey, false);
132
+ return this.buildDocumentInternal(identity.did, identity.keyId, publicKey, options?.controller, options?.services);
133
+ }
134
+ /**
135
+ * Internal: Build DID Document
136
+ * @param did - The DID string
137
+ * @param keyId - The key ID
138
+ * @param publicKey - The public key bytes
139
+ * @param controller - Optional controller DID
140
+ * @param services - Optional service endpoints
141
+ * @returns The DID Document
142
+ */
143
+ buildDocumentInternal(did, keyId, publicKey, controller, services) {
144
+ const doc = {
145
+ '@context': [
146
+ 'https://www.w3.org/ns/did/v1',
147
+ 'https://w3id.org/security/suites/jws-2020/v1',
148
+ ],
149
+ id: did,
150
+ verificationMethod: [
151
+ {
152
+ id: keyId,
153
+ type: 'JsonWebKey2020',
154
+ controller: did,
155
+ publicKeyJwk: publicKeyToJwk(publicKey),
156
+ },
157
+ ],
158
+ authentication: [keyId],
159
+ assertionMethod: [keyId],
160
+ };
161
+ if (controller) {
162
+ doc.controller = controller;
163
+ }
164
+ if (services && services.length > 0) {
165
+ doc.service = services;
166
+ }
167
+ return doc;
168
+ }
169
+ }
170
+ //# sourceMappingURL=web-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-handler.js","sourceRoot":"","sources":["../../../src/did/handlers/web-handler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AAKnC;;GAEG;AACH,SAAS,WAAW,CAAC,IAAY;IAC/B,MAAM,cA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AO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;;OAMG;IACH,QAAQ,CAAC,GAAW;QAClB,OAAO,GAAG,GAAG,QAAQ,CAAC;IACxB,CAAC;IAED;;;;;OAKG;IACH,wBAAwB,CACtB,QAAqB,EACrB,OAA+D;QAE/D,MAAM,SAAS,GAAG,YAAY,CAAC,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QAC3D,OAAO,IAAI,CAAC,qBAAqB,CAC/B,QAAQ,CAAC,GAAG,EACZ,QAAQ,CAAC,KAAK,EACd,SAAS,EACT,OAAO,EAAE,UAAU,EACnB,OAAO,EAAE,QAAQ,CAClB,CAAC;IACJ,CAAC;IAED;;;;;;;;OAQG;IACK,qBAAqB,CAC3B,GAAW,EACX,KAAa,EACb,SAAqB,EACrB,UAAmB,EACnB,QAA4B;QAE5B,MAAM,GAAG,GAAgB;YACvB,UAAU,EAAE;gBACV,8BAA8B;gBAC9B,8CAA8C;aAC/C;YACD,EAAE,EAAE,GAAG;YACP,kBAAkB,EAAE;gBAClB;oBACE,EAAE,EAAE,KAAK;oBACT,IAAI,EAAE,gBAAgB;oBACtB,UAAU,EAAE,GAAG;oBACf,YAAY,EAAE,cAAc,CAAC,SAAS,CAAC;iBACxC;aACF;YACD,cAAc,EAAE,CAAC,KAAK,CAAC;YACvB,eAAe,EAAE,CAAC,KAAK,CAAC;SACzB,CAAC;QAEF,IAAI,UAAU,EAAE,CAAC;YACf,GAAG,CAAC,UAAU,GAAG,UAAU,CAAC;QAC9B,CAAC;QAED,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACpC,GAAG,CAAC,OAAO,GAAG,QAAQ,CAAC;QACzB,CAAC;QAED,OAAO,GAAG,CAAC;IACb,CAAC;CACF"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * DID Module
3
+ * @module did
4
+ */
5
+ export * from './types.js';
6
+ export * from './service.js';
7
+ export * from './factory.js';
8
+ export * from './resolver.js';
9
+ export * from './signing.js';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/did/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,cAAc,YAAY,CAAC;AAG3B,cAAc,cAAc,CAAC;AAG7B,cAAc,cAAc,CAAC;AAG7B,cAAc,eAAe,CAAC;AAG9B,cAAc,cAAc,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * DID Module
3
+ * @module did
4
+ */
5
+ // Core types and interfaces
6
+ export * from './types.js';
7
+ // DID Service (requires explicit handler registration)
8
+ export * from './service.js';
9
+ // Factory helper (lazy loading with tree-shaking)
10
+ export * from './factory.js';
11
+ // Resolver
12
+ export * from './resolver.js';
13
+ // Signing utilities
14
+ export * from './signing.js';
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/did/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,4BAA4B;AAC5B,cAAc,YAAY,CAAC;AAE3B,uDAAuD;AACvD,cAAc,cAAc,CAAC;AAE7B,kDAAkD;AAClD,cAAc,cAAc,CAAC;AAE7B,WAAW;AACX,cAAc,eAAe,CAAC;AAE9B,oBAAoB;AACpB,cAAc,cAAc,CAAC"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * DID Resolver
3
+ * Combines modular resolvers for different DID methods
4
+ * @module did/resolver
5
+ */
6
+ import { Resolver } from 'did-resolver';
7
+ import { type EthrResolverConfig } from './resolvers/ethr.js';
8
+ import type { DIDDocument } from './types.js';
9
+ /**
10
+ * Resolver configuration
11
+ * Specify which DID methods to enable and their configurations
12
+ */
13
+ export interface ResolverConfig {
14
+ /** Enable did:web resolver (default: true) */
15
+ web?: boolean;
16
+ /** did:ethr configuration (omit to disable) */
17
+ ethr?: EthrResolverConfig;
18
+ }
19
+ /**
20
+ * Create a new DID resolver with specified configuration
21
+ * @param config - Resolver configuration
22
+ * @returns Configured Resolver instance
23
+ *
24
+ * @example
25
+ * // did:web only (no external dependencies)
26
+ * const resolver = createResolver({ web: true });
27
+ *
28
+ * @example
29
+ * // did:web + did:ethr
30
+ * const resolver = createResolver({
31
+ * web: true,
32
+ * ethr: {
33
+ * networks: [{
34
+ * name: 'sepolia',
35
+ * rpcUrl: 'https://sepolia.infura.io/v3/YOUR_KEY',
36
+ * }]
37
+ * }
38
+ * });
39
+ */
40
+ export declare function createResolver(config?: ResolverConfig): Resolver;
41
+ /**
42
+ * Configure the default resolver
43
+ * Call this at application startup to set up DID resolution
44
+ *
45
+ * IMPORTANT: If you use did:ethr, you MUST call this function before resolving did:ethr DIDs.
46
+ * Otherwise, did:ethr resolution will fail.
47
+ *
48
+ * @param config - Resolver configuration
49
+ *
50
+ * @example
51
+ * // In your app initialization (required for did:ethr)
52
+ * configureResolver({
53
+ * web: true,
54
+ * ethr: {
55
+ * networks: [{ name: 'sepolia', rpcUrl: process.env.SEPOLIA_RPC_URL }]
56
+ * }
57
+ * });
58
+ */
59
+ export declare function configureResolver(config: ResolverConfig): void;
60
+ /**
61
+ * Get the default resolver instance
62
+ * If not configured, creates a did:web-only resolver
63
+ * @returns The default Resolver instance
64
+ */
65
+ export declare function getResolver(): Resolver;
66
+ /**
67
+ * Get the current resolver configuration
68
+ * @returns Current configuration or null if using defaults
69
+ */
70
+ export declare function getResolverConfig(): ResolverConfig | null;
71
+ /**
72
+ * Check if a specific DID method is enabled
73
+ * @param method - DID method to check (e.g., 'web', 'ethr')
74
+ * @returns true if the method is enabled in the current configuration
75
+ */
76
+ export declare function isMethodEnabled(method: 'web' | 'ethr'): boolean;
77
+ /**
78
+ * Resolve a DID to its document
79
+ * @param did - The DID to resolve
80
+ * @returns The DID Document if found, null otherwise
81
+ */
82
+ export declare function resolveDID(did: string): Promise<DIDDocument | null>;
83
+ export { createWebResolver } from './resolvers/web.js';
84
+ export { createEthrResolver, createSepoliaResolver, KNOWN_NETWORKS, type EthrNetworkConfig, type EthrResolverConfig, type KnownNetwork, } from './resolvers/ethr.js';
85
+ //# sourceMappingURL=resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../src/did/resolver.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,QAAQ,EAAoB,MAAM,cAAc,CAAC;AAE1D,OAAO,EAAsB,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAClF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,8CAA8C;IAC9C,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,+CAA+C;IAC/C,IAAI,CAAC,EAAE,kBAAkB,CAAC;CAK3B;AAMD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,cAAc,CAAC,MAAM,GAAE,cAAmB,GAAG,QAAQ,CAgBpE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAG9D;AAED;;;;GAIG;AACH,wBAAgB,WAAW,IAAI,QAAQ,CAOtC;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,cAAc,GAAG,IAAI,CAEzD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,CAU/D;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAOzE;AAGD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,cAAc,EACd,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,YAAY,GAClB,MAAM,qBAAqB,CAAC"}