@dwn-protocol/id-sdk 0.2.5 → 0.2.6
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/package.json +2 -3
- package/src/agent/app-data-store.ts +0 -365
- package/src/agent/did-manager.ts +0 -393
- package/src/agent/dwn-manager.ts +0 -548
- package/src/agent/identity-manager.ts +0 -165
- package/src/agent/index.ts +0 -19
- package/src/agent/json-rpc.ts +0 -107
- package/src/agent/key-manager.ts +0 -302
- package/src/agent/kms-local.ts +0 -412
- package/src/agent/outbox.ts +0 -128
- package/src/agent/rpc-client.ts +0 -223
- package/src/agent/store-managed-did.ts +0 -295
- package/src/agent/store-managed-identity.ts +0 -243
- package/src/agent/store-managed-key.ts +0 -754
- package/src/agent/sync-manager.ts +0 -631
- package/src/agent/test-managed-agent.ts +0 -299
- package/src/agent/types/agent.ts +0 -145
- package/src/agent/types/managed-key.ts +0 -442
- package/src/agent/utils.ts +0 -190
- package/src/common/convert.ts +0 -424
- package/src/common/index.ts +0 -9
- package/src/common/multicodec.ts +0 -176
- package/src/common/object.ts +0 -43
- package/src/common/stores.ts +0 -125
- package/src/common/stream-node.ts +0 -381
- package/src/common/stream.ts +0 -406
- package/src/common/type-utils.ts +0 -117
- package/src/common/types.ts +0 -48
- package/src/credentials/credential-bbs.ts +0 -419
- package/src/credentials/credential.ts +0 -324
- package/src/credentials/index.ts +0 -5
- package/src/credentials/presentation.ts +0 -182
- package/src/credentials/status-list.ts +0 -365
- package/src/credentials/utils.ts +0 -58
- package/src/credentials/validators.ts +0 -52
- package/src/crypto/algorithms-api/aes/base.ts +0 -49
- package/src/crypto/algorithms-api/aes/ctr.ts +0 -51
- package/src/crypto/algorithms-api/aes/index.ts +0 -2
- package/src/crypto/algorithms-api/crypto-algorithm.ts +0 -127
- package/src/crypto/algorithms-api/crypto-key.ts +0 -56
- package/src/crypto/algorithms-api/ec/base.ts +0 -39
- package/src/crypto/algorithms-api/ec/ecdh.ts +0 -53
- package/src/crypto/algorithms-api/ec/ecdsa.ts +0 -37
- package/src/crypto/algorithms-api/ec/eddsa.ts +0 -30
- package/src/crypto/algorithms-api/ec/index.ts +0 -4
- package/src/crypto/algorithms-api/errors.ts +0 -29
- package/src/crypto/algorithms-api/index.ts +0 -6
- package/src/crypto/algorithms-api/pbkdf/index.ts +0 -1
- package/src/crypto/algorithms-api/pbkdf/pbkdf2.ts +0 -91
- package/src/crypto/crypto-algorithms/aes-ctr.ts +0 -70
- package/src/crypto/crypto-algorithms/bbs.ts +0 -110
- package/src/crypto/crypto-algorithms/ecdh.ts +0 -115
- package/src/crypto/crypto-algorithms/ecdsa.ts +0 -111
- package/src/crypto/crypto-algorithms/eddsa.ts +0 -110
- package/src/crypto/crypto-algorithms/index.ts +0 -6
- package/src/crypto/crypto-algorithms/pbkdf2.ts +0 -54
- package/src/crypto/crypto-primitives/aes-ctr.ts +0 -131
- package/src/crypto/crypto-primitives/aes-gcm.ts +0 -138
- package/src/crypto/crypto-primitives/bbs.ts +0 -183
- package/src/crypto/crypto-primitives/concat-kdf.ts +0 -207
- package/src/crypto/crypto-primitives/ed25519.ts +0 -201
- package/src/crypto/crypto-primitives/index.ts +0 -10
- package/src/crypto/crypto-primitives/pbkdf2.ts +0 -78
- package/src/crypto/crypto-primitives/secp256k1.ts +0 -322
- package/src/crypto/crypto-primitives/x25519.ts +0 -101
- package/src/crypto/crypto-primitives/xchacha20-poly1305.ts +0 -46
- package/src/crypto/crypto-primitives/xchacha20.ts +0 -34
- package/src/crypto/index.ts +0 -8
- package/src/crypto/jose.ts +0 -948
- package/src/crypto/types/crypto-key.ts +0 -4
- package/src/crypto/types/iddwn-crypto.ts +0 -119
- package/src/crypto/utils.ts +0 -200
- package/src/did-api.ts +0 -72
- package/src/dids/dht.ts +0 -412
- package/src/dids/did-dht.ts +0 -436
- package/src/dids/did-ion.ts +0 -613
- package/src/dids/did-key.ts +0 -791
- package/src/dids/did-resolver.ts +0 -107
- package/src/dids/index.ts +0 -9
- package/src/dids/resolver-cache-level.ts +0 -82
- package/src/dids/resolver-cache-noop.ts +0 -25
- package/src/dids/types.ts +0 -278
- package/src/dids/utils.ts +0 -129
- package/src/dwn-api.ts +0 -584
- package/src/iddwn.ts +0 -241
- package/src/identity-agent/index.ts +0 -270
- package/src/index.ts +0 -26
- package/src/interfaces/metadata.ts +0 -163
- package/src/interfaces/queue.ts +0 -108
- package/src/interfaces/services.ts +0 -122
- package/src/interfaces/transactions.ts +0 -220
- package/src/protocol.ts +0 -68
- package/src/proxy-agent/index.ts +0 -255
- package/src/record.ts +0 -521
- package/src/service-options.ts +0 -62
- package/src/typings/decentralized-identity__ion-pow-sdk.d.ts +0 -7
- package/src/user-agent/index.ts +0 -295
- package/src/utils.ts +0 -29
- package/src/vc-api.ts +0 -505
package/src/proxy-agent/index.ts
DELETED
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
IDRpc,
|
|
3
|
-
DidRequest,
|
|
4
|
-
VcResponse,
|
|
5
|
-
DidResponse,
|
|
6
|
-
DwnResponse,
|
|
7
|
-
SyncManager,
|
|
8
|
-
AppDataStore,
|
|
9
|
-
SendVcRequest,
|
|
10
|
-
SendDwnRequest,
|
|
11
|
-
ProcessVcRequest,
|
|
12
|
-
IDManagedAgent,
|
|
13
|
-
ProcessDwnRequest,
|
|
14
|
-
} from '../agent/index.js';
|
|
15
|
-
|
|
16
|
-
import { LevelStore } from '../common/index.js';
|
|
17
|
-
import { EdDsaAlgorithm } from '../crypto/index.js';
|
|
18
|
-
import { DidIonMethod, DidKeyMethod, DidResolver } from '../dids/index.js';
|
|
19
|
-
import {
|
|
20
|
-
LocalKms,
|
|
21
|
-
DidManager,
|
|
22
|
-
DwnManager,
|
|
23
|
-
KeyManager,
|
|
24
|
-
DidStoreDwn,
|
|
25
|
-
KeyStoreDwn,
|
|
26
|
-
AppDataVault,
|
|
27
|
-
IDRpcClient,
|
|
28
|
-
IdentityManager,
|
|
29
|
-
IdentityStoreDwn,
|
|
30
|
-
SyncManagerLevel,
|
|
31
|
-
PrivateKeyStoreDwn,
|
|
32
|
-
cryptoToPortableKeyPair,
|
|
33
|
-
} from '../agent/index.js';
|
|
34
|
-
|
|
35
|
-
export type IDProxyAgentOptions = {
|
|
36
|
-
agentDid: string;
|
|
37
|
-
appData: AppDataStore;
|
|
38
|
-
didManager: DidManager;
|
|
39
|
-
didResolver: DidResolver;
|
|
40
|
-
dwnManager: DwnManager;
|
|
41
|
-
identityManager: IdentityManager;
|
|
42
|
-
keyManager: KeyManager;
|
|
43
|
-
rpcClient: IDRpc;
|
|
44
|
-
syncManager: SyncManager;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export class IDProxyAgent implements IDManagedAgent {
|
|
48
|
-
agentDid: string;
|
|
49
|
-
appData: AppDataStore;
|
|
50
|
-
didManager: DidManager;
|
|
51
|
-
didResolver: DidResolver;
|
|
52
|
-
dwnManager: DwnManager;
|
|
53
|
-
identityManager: IdentityManager;
|
|
54
|
-
keyManager: KeyManager;
|
|
55
|
-
rpcClient: IDRpc;
|
|
56
|
-
syncManager: SyncManager;
|
|
57
|
-
|
|
58
|
-
constructor(options: IDProxyAgentOptions) {
|
|
59
|
-
this.agentDid = options.agentDid;
|
|
60
|
-
this.appData = options.appData;
|
|
61
|
-
this.keyManager = options.keyManager;
|
|
62
|
-
this.didManager = options.didManager;
|
|
63
|
-
this.didResolver = options.didResolver;
|
|
64
|
-
this.dwnManager = options.dwnManager;
|
|
65
|
-
this.identityManager = options.identityManager;
|
|
66
|
-
this.rpcClient = options.rpcClient;
|
|
67
|
-
this.syncManager = options.syncManager;
|
|
68
|
-
|
|
69
|
-
// Set this agent to be the default agent.
|
|
70
|
-
this.didManager.agent = this;
|
|
71
|
-
this.dwnManager.agent = this;
|
|
72
|
-
this.identityManager.agent = this;
|
|
73
|
-
this.keyManager.agent = this;
|
|
74
|
-
this.syncManager.agent = this;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
static async create(options: Partial<IDProxyAgentOptions> = {}): Promise<IDProxyAgent> {
|
|
78
|
-
let {
|
|
79
|
-
agentDid, appData, didManager, didResolver, dwnManager,
|
|
80
|
-
identityManager, keyManager, rpcClient, syncManager
|
|
81
|
-
} = options;
|
|
82
|
-
|
|
83
|
-
if (agentDid === undefined) {
|
|
84
|
-
// An Agent DID was not specified, so set to empty string.
|
|
85
|
-
agentDid = '';
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (appData === undefined) {
|
|
89
|
-
// A custom AppDataStore implementation was not specified, so
|
|
90
|
-
// instantiate a LevelDB backed secure AppDataVault.
|
|
91
|
-
appData = new AppDataVault({
|
|
92
|
-
store: new LevelStore('data/AGENT/VAULT')
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (didManager === undefined) {
|
|
97
|
-
// A custom DidManager implementation was not specified, so
|
|
98
|
-
// instantiate a default with in-memory store.
|
|
99
|
-
didManager = new DidManager({
|
|
100
|
-
didMethods : [DidIonMethod, DidKeyMethod],
|
|
101
|
-
store : new DidStoreDwn()
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (didResolver === undefined) {
|
|
106
|
-
// A custom DidManager implementation was not specified, so
|
|
107
|
-
// instantiate a default with in-memory store.
|
|
108
|
-
didResolver = new DidResolver({ didResolvers: [DidIonMethod, DidKeyMethod] });
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if (dwnManager === undefined) {
|
|
112
|
-
// A custom DwnManager implementation was not specified, so
|
|
113
|
-
// instantiate a default.
|
|
114
|
-
dwnManager = await DwnManager.create({ didResolver });
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (identityManager === undefined) {
|
|
118
|
-
// A custom IdentityManager implementation was not specified, so
|
|
119
|
-
// instantiate a default that uses a DWN store.
|
|
120
|
-
identityManager = new IdentityManager({
|
|
121
|
-
store: new IdentityStoreDwn()
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
if (keyManager === undefined) {
|
|
126
|
-
// A custom KeyManager implementation was not specified, so
|
|
127
|
-
// instantiate a default with KMSs.
|
|
128
|
-
const localKmsDwn = new LocalKms({
|
|
129
|
-
kmsName : 'local',
|
|
130
|
-
keyStore : new KeyStoreDwn({ schema: 'https://abaxx.tech/schemas/dwn/kms-key' }),
|
|
131
|
-
privateKeyStore : new PrivateKeyStoreDwn()
|
|
132
|
-
});
|
|
133
|
-
const localKmsMemory = new LocalKms({
|
|
134
|
-
kmsName: 'memory'
|
|
135
|
-
});
|
|
136
|
-
keyManager = new KeyManager({
|
|
137
|
-
kms: {
|
|
138
|
-
local : localKmsDwn,
|
|
139
|
-
memory : localKmsMemory
|
|
140
|
-
},
|
|
141
|
-
store: new KeyStoreDwn({ schema: 'https://abaxx.tech/schemas/dwn/managed-key' })
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if (rpcClient === undefined) {
|
|
146
|
-
// A custom RPC Client implementation was not specified, so
|
|
147
|
-
// instantiate a default.
|
|
148
|
-
rpcClient = new IDRpcClient();
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if (syncManager === undefined) {
|
|
152
|
-
// A custom SyncManager implementation was not specified, so
|
|
153
|
-
// instantiate a LevelDB-backed default.
|
|
154
|
-
syncManager = new SyncManagerLevel();
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// Instantiate the Identity Agent.
|
|
158
|
-
const agent = new IDProxyAgent({
|
|
159
|
-
agentDid,
|
|
160
|
-
appData,
|
|
161
|
-
didManager,
|
|
162
|
-
didResolver,
|
|
163
|
-
dwnManager,
|
|
164
|
-
keyManager,
|
|
165
|
-
identityManager,
|
|
166
|
-
rpcClient,
|
|
167
|
-
syncManager
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
return agent;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
async firstLaunch(): Promise<boolean> {
|
|
174
|
-
// Check whether data vault is already initialized.
|
|
175
|
-
const { initialized } = await this.appData.getStatus();
|
|
176
|
-
return initialized === false;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Executed once the first time the Identity Agent is launched.
|
|
181
|
-
* The passphrase should be input by the end-user.
|
|
182
|
-
*/
|
|
183
|
-
async initialize(options: { passphrase: string }) {
|
|
184
|
-
const { passphrase } = options;
|
|
185
|
-
|
|
186
|
-
// Generate an Ed25519 key pair for the Identity Agent.
|
|
187
|
-
const agentKeyPair = await new EdDsaAlgorithm().generateKey({
|
|
188
|
-
algorithm : { name: 'EdDSA', namedCurve: 'Ed25519' },
|
|
189
|
-
extractable : true,
|
|
190
|
-
keyUsages : ['sign', 'verify']
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
/** Initialize the AppDataStore with the Identity Agent's
|
|
194
|
-
* private key and passphrase, which also unlocks the data vault. */
|
|
195
|
-
await this.appData.initialize({
|
|
196
|
-
passphrase : passphrase,
|
|
197
|
-
keyPair : agentKeyPair,
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
async processDidRequest(_request: DidRequest): Promise<DidResponse> {
|
|
202
|
-
throw new Error('Not implemented');
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
async processDwnRequest(request: ProcessDwnRequest): Promise<DwnResponse> {
|
|
206
|
-
return this.dwnManager.processRequest(request);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
async processVcRequest(_request: ProcessVcRequest): Promise<VcResponse> {
|
|
210
|
-
throw new Error('Not implemented');
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
async sendDidRequest(_request: DidRequest): Promise<DidResponse> {
|
|
214
|
-
throw new Error('Not implemented');
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
async sendDwnRequest(request: SendDwnRequest): Promise<DwnResponse> {
|
|
218
|
-
return this.dwnManager.sendRequest(request);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
async sendVcRequest(_request: SendVcRequest): Promise<VcResponse> {
|
|
222
|
-
throw new Error('Not implemented');
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
async start(options: { passphrase: string }) {
|
|
226
|
-
const { passphrase } = options;
|
|
227
|
-
|
|
228
|
-
if (await this.firstLaunch()) {
|
|
229
|
-
// 1A. Agent's first launch so initialize.
|
|
230
|
-
await this.initialize({ passphrase });
|
|
231
|
-
} else {
|
|
232
|
-
// 1B. Agent was previously initialized.
|
|
233
|
-
// Unlock the data vault and cache the vault unlock key (VUK) in memory.
|
|
234
|
-
await this.appData.unlock({ passphrase });
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
// 2. Set the Identity Agent's root did:key identifier.
|
|
238
|
-
this.agentDid = await this.appData.getDid();
|
|
239
|
-
|
|
240
|
-
// 3. Import the Identity Agent's private key into the KeyManager.
|
|
241
|
-
const defaultSigningKey = cryptoToPortableKeyPair({
|
|
242
|
-
cryptoKeyPair: {
|
|
243
|
-
privateKey : await this.appData.getPrivateKey(),
|
|
244
|
-
publicKey : await this.appData.getPublicKey()
|
|
245
|
-
},
|
|
246
|
-
keyData: {
|
|
247
|
-
alias : await this.didManager.getDefaultSigningKey({ did: this.agentDid }),
|
|
248
|
-
kms : 'memory'
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
// Import the Agent's signing key pair to the in-memory KMS key stores.
|
|
253
|
-
await this.keyManager.setDefaultSigningKey({ key: defaultSigningKey });
|
|
254
|
-
}
|
|
255
|
-
}
|