Add comprehensive installation and setup documentation

- Add GETTING_STARTED.md with quick start guide and development modes
- Add INSTALL.sh automated installation script
- Add INSTALLATION_CHECKLIST.md, INSTALLATION_SUCCESS.md, and INSTALLATION_SUMMARY.md
- Add QUICK_REFERENCE.md for common commands
- Add SETUP_GUIDE.md with detailed setup instructions
- Update README.md with improved project overview
- Add did-wallet app dependencies and node_modules
This commit is contained in:
Dorian
2026-01-27 17:18:21 +00:00
parent a81f655133
commit 0d073fa89e
22658 changed files with 4494151 additions and 6 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+18
View File
@@ -0,0 +1,18 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./user-agent.js"), exports);
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC"}
+1
View File
@@ -0,0 +1 @@
{"type": "commonjs"}
+235
View File
@@ -0,0 +1,235 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Web5UserAgent = void 0;
var common_1 = require("@web5/common");
var dids_1 = require("@web5/dids");
var agent_1 = require("@web5/agent");
var Web5UserAgent = /** @class */ (function () {
function Web5UserAgent(params) {
this._agentDid = params.agentDid;
this.crypto = params.cryptoApi;
this.did = params.didApi;
this.dwn = params.dwnApi;
this.identity = params.identityApi;
this.keyManager = params.keyManager;
this.rpc = params.rpcClient;
this.sync = params.syncApi;
this.vault = params.agentVault;
// Set this agent to be the default agent.
this.did.agent = this;
this.dwn.agent = this;
this.identity.agent = this;
this.keyManager.agent = this;
this.sync.agent = this;
}
Object.defineProperty(Web5UserAgent.prototype, "agentDid", {
get: function () {
if (this._agentDid === undefined) {
throw new Error('Web5UserAgent: The "agentDid" property is not set. Ensure the agent is properly ' +
'initialized and a DID is assigned.');
}
return this._agentDid;
},
set: function (did) {
this._agentDid = did;
},
enumerable: false,
configurable: true
});
/**
* If any of the required agent components are not provided, instantiate default implementations.
*/
Web5UserAgent.create = function (_a) {
var _b = _a === void 0 ? {} : _a, _c = _b.dataPath, dataPath = _c === void 0 ? 'DATA/AGENT' : _c, agentDid = _b.agentDid, agentVault = _b.agentVault, cryptoApi = _b.cryptoApi, didApi = _b.didApi, dwnApi = _b.dwnApi, identityApi = _b.identityApi, keyManager = _b.keyManager, rpcClient = _b.rpcClient, syncApi = _b.syncApi;
return __awaiter(this, void 0, void 0, function () {
var _d, _e;
var _f;
return __generator(this, function (_g) {
switch (_g.label) {
case 0:
agentVault !== null && agentVault !== void 0 ? agentVault : (agentVault = new agent_1.HdIdentityVault({
keyDerivationWorkFactor: 210000,
store: new common_1.LevelStore({ location: "".concat(dataPath, "/VAULT_STORE") })
}));
cryptoApi !== null && cryptoApi !== void 0 ? cryptoApi : (cryptoApi = new agent_1.AgentCryptoApi());
didApi !== null && didApi !== void 0 ? didApi : (didApi = new agent_1.AgentDidApi({
didMethods: [dids_1.DidDht, dids_1.DidJwk],
resolverCache: new dids_1.DidResolverCacheLevel({ location: "".concat(dataPath, "/DID_RESOLVERCACHE") }),
store: new agent_1.DwnDidStore()
}));
if (!(dwnApi !== null && dwnApi !== void 0)) return [3 /*break*/, 1];
_d = dwnApi;
return [3 /*break*/, 3];
case 1:
_e = agent_1.AgentDwnApi.bind;
_f = {};
return [4 /*yield*/, agent_1.AgentDwnApi.createDwn({ dataPath: dataPath, didResolver: didApi })];
case 2:
_d = (dwnApi = new (_e.apply(agent_1.AgentDwnApi, [void 0, (_f.dwn = _g.sent(),
_f)]))());
_g.label = 3;
case 3:
_d;
identityApi !== null && identityApi !== void 0 ? identityApi : (identityApi = new agent_1.AgentIdentityApi({ store: new agent_1.DwnIdentityStore() }));
keyManager !== null && keyManager !== void 0 ? keyManager : (keyManager = new agent_1.LocalKeyManager({ keyStore: new agent_1.DwnKeyStore() }));
rpcClient !== null && rpcClient !== void 0 ? rpcClient : (rpcClient = new agent_1.Web5RpcClient());
syncApi !== null && syncApi !== void 0 ? syncApi : (syncApi = new agent_1.AgentSyncApi({ syncEngine: new agent_1.SyncEngineLevel({ dataPath: dataPath }) }));
// Instantiate the Agent using the provided or default components.
return [2 /*return*/, new Web5UserAgent({
agentDid: agentDid,
agentVault: agentVault,
cryptoApi: cryptoApi,
didApi: didApi,
dwnApi: dwnApi,
keyManager: keyManager,
identityApi: identityApi,
rpcClient: rpcClient,
syncApi: syncApi
})];
}
});
});
};
Web5UserAgent.prototype.firstLaunch = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.vault.isInitialized()];
case 1:
// Check whether data vault is already initialize
return [2 /*return*/, (_a.sent()) === false];
}
});
});
};
/**
* Initializes the User Agent with a password, and optionally a recovery phrase.
*
* This method is typically called once, the first time the Agent is launched, and is responsible
* for setting up the agent's operational environment, cryptographic key material, and readiness
* for processing Web5 requests.
*
* The password is used to secure the Agent vault, and the recovery phrase is used to derive the
* cryptographic keys for the vault. If a recovery phrase is not provided, a new recovery phrase
* will be generated and returned. The password should be chosen and entered by the end-user.
*/
Web5UserAgent.prototype.initialize = function (_a) {
var password = _a.password, recoveryPhrase = _a.recoveryPhrase;
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_b) {
switch (_b.label) {
case 0: return [4 /*yield*/, this.vault.initialize({ password: password, recoveryPhrase: recoveryPhrase })];
case 1:
// Initialize the Agent vault.
recoveryPhrase = _b.sent();
return [2 /*return*/, recoveryPhrase];
}
});
});
};
Web5UserAgent.prototype.processDidRequest = function (request) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this.did.processRequest(request)];
});
});
};
Web5UserAgent.prototype.processDwnRequest = function (request) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this.dwn.processRequest(request)];
});
});
};
Web5UserAgent.prototype.processVcRequest = function (_request) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
throw new Error('Not implemented');
});
});
};
Web5UserAgent.prototype.sendDidRequest = function (_request) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
throw new Error('Not implemented');
});
});
};
Web5UserAgent.prototype.sendDwnRequest = function (request) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this.dwn.sendRequest(request)];
});
});
};
Web5UserAgent.prototype.sendVcRequest = function (_request) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
throw new Error('Not implemented');
});
});
};
Web5UserAgent.prototype.start = function (_a) {
var password = _a.password;
return __awaiter(this, void 0, void 0, function () {
var _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
if (!this.vault.isLocked()) return [3 /*break*/, 2];
return [4 /*yield*/, this.vault.unlock({ password: password })];
case 1:
_c.sent();
_c.label = 2;
case 2:
// Set the Agent's DID.
_b = this;
return [4 /*yield*/, this.vault.getDid()];
case 3:
// Set the Agent's DID.
_b.agentDid = _c.sent();
return [2 /*return*/];
}
});
});
};
return Web5UserAgent;
}());
exports.Web5UserAgent = Web5UserAgent;
//# sourceMappingURL=user-agent.js.map
@@ -0,0 +1 @@
{"version":3,"file":"user-agent.js","sourceRoot":"","sources":["../../src/user-agent.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AEY,wCAAgB,GAA7B,UAA8B,QAA0B;;;gBACtD,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;;;KACpC;IAEY,sCAAc,GAA3B,UACE,QAAuB;;;gBAEvB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;;;KACpC;IAEY,sCAAc,GAA3B,UACE,OAA0B;;;gBAE1B,sBAAO,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,OAAO,CAAC,EAAC;;;KACtC;IAEY,qCAAa,GAA1B,UAA2B,QAAuB;;;gBAChD,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;;;KACpC;IAEY,6BAAK,GAAlB,UAAmB,EAAmC;YAAjC,QAAQ,cAAA;;;;;;6BAEvB,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,EAArB,wBAAqB;wBACvB,qBAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,QAAQ,UAAA,EAAE,CAAC,EAAA;;wBAArC,SAAqC,CAAC;;;wBAGxC,uBAAuB;wBACvB,KAAA,IAAI,CAAA;wBAAY,qBAAM,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAA;;wBADzC,uBAAuB;wBACvB,GAAK,QAAQ,GAAG,SAAyB,CAAC;;;;;KAC3C;IACH,oBAAC;AAAD,CAAC,AA7JD,IA6JC;AA7JY,sCAAa"}
+2
View File
@@ -0,0 +1,2 @@
export * from './user-agent.js';
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
+142
View File
@@ -0,0 +1,142 @@
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import { LevelStore } from '@web5/common';
import { DidDht, DidJwk, DidResolverCacheLevel } from '@web5/dids';
import { AgentDidApi, AgentDwnApi, DwnDidStore, DwnKeyStore, AgentSyncApi, Web5RpcClient, AgentCryptoApi, HdIdentityVault, LocalKeyManager, SyncEngineLevel, AgentIdentityApi, DwnIdentityStore, } from '@web5/agent';
export class Web5UserAgent {
constructor(params) {
this._agentDid = params.agentDid;
this.crypto = params.cryptoApi;
this.did = params.didApi;
this.dwn = params.dwnApi;
this.identity = params.identityApi;
this.keyManager = params.keyManager;
this.rpc = params.rpcClient;
this.sync = params.syncApi;
this.vault = params.agentVault;
// Set this agent to be the default agent.
this.did.agent = this;
this.dwn.agent = this;
this.identity.agent = this;
this.keyManager.agent = this;
this.sync.agent = this;
}
get agentDid() {
if (this._agentDid === undefined) {
throw new Error('Web5UserAgent: The "agentDid" property is not set. Ensure the agent is properly ' +
'initialized and a DID is assigned.');
}
return this._agentDid;
}
set agentDid(did) {
this._agentDid = did;
}
/**
* If any of the required agent components are not provided, instantiate default implementations.
*/
static create({ dataPath = 'DATA/AGENT', agentDid, agentVault, cryptoApi, didApi, dwnApi, identityApi, keyManager, rpcClient, syncApi } = {}) {
return __awaiter(this, void 0, void 0, function* () {
agentVault !== null && agentVault !== void 0 ? agentVault : (agentVault = new HdIdentityVault({
keyDerivationWorkFactor: 210000,
store: new LevelStore({ location: `${dataPath}/VAULT_STORE` })
}));
cryptoApi !== null && cryptoApi !== void 0 ? cryptoApi : (cryptoApi = new AgentCryptoApi());
didApi !== null && didApi !== void 0 ? didApi : (didApi = new AgentDidApi({
didMethods: [DidDht, DidJwk],
resolverCache: new DidResolverCacheLevel({ location: `${dataPath}/DID_RESOLVERCACHE` }),
store: new DwnDidStore()
}));
dwnApi !== null && dwnApi !== void 0 ? dwnApi : (dwnApi = new AgentDwnApi({
dwn: yield AgentDwnApi.createDwn({ dataPath, didResolver: didApi })
}));
identityApi !== null && identityApi !== void 0 ? identityApi : (identityApi = new AgentIdentityApi({ store: new DwnIdentityStore() }));
keyManager !== null && keyManager !== void 0 ? keyManager : (keyManager = new LocalKeyManager({ keyStore: new DwnKeyStore() }));
rpcClient !== null && rpcClient !== void 0 ? rpcClient : (rpcClient = new Web5RpcClient());
syncApi !== null && syncApi !== void 0 ? syncApi : (syncApi = new AgentSyncApi({ syncEngine: new SyncEngineLevel({ dataPath }) }));
// Instantiate the Agent using the provided or default components.
return new Web5UserAgent({
agentDid,
agentVault,
cryptoApi,
didApi,
dwnApi,
keyManager,
identityApi,
rpcClient,
syncApi
});
});
}
firstLaunch() {
return __awaiter(this, void 0, void 0, function* () {
// Check whether data vault is already initialize
return (yield this.vault.isInitialized()) === false;
});
}
/**
* Initializes the User Agent with a password, and optionally a recovery phrase.
*
* This method is typically called once, the first time the Agent is launched, and is responsible
* for setting up the agent's operational environment, cryptographic key material, and readiness
* for processing Web5 requests.
*
* The password is used to secure the Agent vault, and the recovery phrase is used to derive the
* cryptographic keys for the vault. If a recovery phrase is not provided, a new recovery phrase
* will be generated and returned. The password should be chosen and entered by the end-user.
*/
initialize({ password, recoveryPhrase }) {
return __awaiter(this, void 0, void 0, function* () {
// Initialize the Agent vault.
recoveryPhrase = yield this.vault.initialize({ password, recoveryPhrase });
return recoveryPhrase;
});
}
processDidRequest(request) {
return __awaiter(this, void 0, void 0, function* () {
return this.did.processRequest(request);
});
}
processDwnRequest(request) {
return __awaiter(this, void 0, void 0, function* () {
return this.dwn.processRequest(request);
});
}
processVcRequest(_request) {
return __awaiter(this, void 0, void 0, function* () {
throw new Error('Not implemented');
});
}
sendDidRequest(_request) {
return __awaiter(this, void 0, void 0, function* () {
throw new Error('Not implemented');
});
}
sendDwnRequest(request) {
return __awaiter(this, void 0, void 0, function* () {
return this.dwn.sendRequest(request);
});
}
sendVcRequest(_request) {
return __awaiter(this, void 0, void 0, function* () {
throw new Error('Not implemented');
});
}
start({ password }) {
return __awaiter(this, void 0, void 0, function* () {
// If the Agent vault is locked, unlock it.
if (this.vault.isLocked()) {
yield this.vault.unlock({ password });
}
// Set the Agent's DID.
this.agentDid = yield this.vault.getDid();
});
}
}
//# sourceMappingURL=user-agent.js.map
@@ -0,0 +1 @@
{"version":3,"file":"user-agent.js","sourceRoot":"","sources":["../../src/user-agent.ts"],"names":[],"mappings":";;;;;;;;;AAeA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAa,MAAM,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAC9E,OAAO,EACL,WAAW,EACX,WAAW,EACX,WAAW,EACX,WAAW,EACX,YAAY,EACZ,aAAa,EACb,cAAc,EAEd,eAAe,EACf,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAsDrB,MAAM,OAAO,aAAa;IAYxB,YAAY,MAAgC;QAC1C,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC;QAC/B,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC;QACzB,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,WAAW,CAAC;QACnC,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QACpC,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC;QAC3B,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC;QAE/B,0CAA0C;QAC1C,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC;QACtB,IAAI,CA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iBAAiB,CACrB,OAAsB;;YAEtB,OAAO,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAC1C,CAAC;KAAA;IAEY,iBAAiB,CAC5B,OAA6B;;YAE7B,OAAO,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAC1C,CAAC;KAAA;IAEY,gBAAgB,CAAC,QAA0B;;YACtD,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;QACrC,CAAC;KAAA;IAEY,cAAc,CACzB,QAAuB;;YAEvB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;QACrC,CAAC;KAAA;IAEY,cAAc,CACzB,OAA0B;;YAE1B,OAAO,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QACvC,CAAC;KAAA;IAEY,aAAa,CAAC,QAAuB;;YAChD,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;QACrC,CAAC;KAAA;IAEY,KAAK,CAAC,EAAE,QAAQ,EAAyB;;YACpD,2CAA2C;YAC3C,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE;gBACzB,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;aACvC;YAED,uBAAuB;YACvB,IAAI,CAAC,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;QAC5C,CAAC;KAAA;CACF"}
+2
View File
@@ -0,0 +1,2 @@
export * from './user-agent.js';
//# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
+90
View File
@@ -0,0 +1,90 @@
import type { Web5Rpc, DidRequest, VcResponse, DidResponse, DwnResponse, DidInterface, DwnInterface, SendVcRequest, SendDwnRequest, ProcessVcRequest, ProcessDwnRequest, Web5PlatformAgent } from '@web5/agent';
import { BearerDid } from '@web5/dids';
import { AgentDidApi, AgentDwnApi, AgentSyncApi, AgentCryptoApi, AgentKeyManager, HdIdentityVault, LocalKeyManager, AgentIdentityApi } from '@web5/agent';
/**
* Initialization parameters for {@link Web5UserAgent}, including an optional recovery phrase that
* can be used to derive keys to encrypt the vault and generate a DID.
*/
export type AgentInitializeParams = {
/**
* The password used to secure the Agent vault.
*
* The password selected should be strong and securely managed to prevent unauthorized access.
*/
password: string;
/**
* An optional recovery phrase used to deterministically generate the cryptographic keys for the
* Agent vault.
*
* Supplying this phrase enables the vault's contents to be restored or replicated across devices.
* If omitted, a new phrase is generated, which should be securely recorded for future recovery needs.
*/
recoveryPhrase?: string;
};
export type AgentStartParams = {
/**
* The password used to unlock the previously initialized Agent vault.
*/
password: string;
};
export type AgentParams<TKeyManager extends AgentKeyManager = LocalKeyManager> = {
/** Optional. The Decentralized Identifier (DID) representing this Web5 User Agent. */
agentDid?: BearerDid;
/** Encrypted vault used for managing the Agent's DID and associated keys. */
agentVault: HdIdentityVault;
/** Provides cryptographic capabilties like signing, encryption, hashing and key derivation. */
cryptoApi: AgentCryptoApi;
/** Specifies the local path to be used by the Agent's persistent data stores. */
dataPath?: string;
/** Facilitates DID operations including create, update, and resolve. */
didApi: AgentDidApi<TKeyManager>;
/** Facilitates DWN operations including processing and sending requests. */
dwnApi: AgentDwnApi;
/** Facilitates decentralized Identity operations including create, import, and export. */
identityApi: AgentIdentityApi<TKeyManager>;
/** Responsible for securely managing the cryptographic keys of the agent. */
keyManager: TKeyManager;
/** Remote procedure call (RPC) client used to communicate with other Web5 services. */
rpcClient: Web5Rpc;
/** Facilitates data synchronization of DWN records between nodes. */
syncApi: AgentSyncApi;
};
export declare class Web5UserAgent<TKeyManager extends AgentKeyManager = LocalKeyManager> implements Web5PlatformAgent<TKeyManager> {
crypto: AgentCryptoApi;
did: AgentDidApi<TKeyManager>;
dwn: AgentDwnApi;
identity: AgentIdentityApi<TKeyManager>;
keyManager: TKeyManager;
rpc: Web5Rpc;
sync: AgentSyncApi;
vault: HdIdentityVault;
private _agentDid?;
constructor(params: AgentParams<TKeyManager>);
get agentDid(): BearerDid;
set agentDid(did: BearerDid);
/**
* If any of the required agent components are not provided, instantiate default implementations.
*/
static create({ dataPath, agentDid, agentVault, cryptoApi, didApi, dwnApi, identityApi, keyManager, rpcClient, syncApi }?: Partial<AgentParams>): Promise<Web5UserAgent>;
firstLaunch(): Promise<boolean>;
/**
* Initializes the User Agent with a password, and optionally a recovery phrase.
*
* This method is typically called once, the first time the Agent is launched, and is responsible
* for setting up the agent's operational environment, cryptographic key material, and readiness
* for processing Web5 requests.
*
* The password is used to secure the Agent vault, and the recovery phrase is used to derive the
* cryptographic keys for the vault. If a recovery phrase is not provided, a new recovery phrase
* will be generated and returned. The password should be chosen and entered by the end-user.
*/
initialize({ password, recoveryPhrase }: AgentInitializeParams): Promise<string>;
processDidRequest<T extends DidInterface>(request: DidRequest<T>): Promise<DidResponse<T>>;
processDwnRequest<T extends DwnInterface>(request: ProcessDwnRequest<T>): Promise<DwnResponse<T>>;
processVcRequest(_request: ProcessVcRequest): Promise<VcResponse>;
sendDidRequest<T extends DidInterface>(_request: DidRequest<T>): Promise<DidResponse<T>>;
sendDwnRequest<T extends DwnInterface>(request: SendDwnRequest<T>): Promise<DwnResponse<T>>;
sendVcRequest(_request: SendVcRequest): Promise<VcResponse>;
start({ password }: AgentInitializeParams): Promise<void>;
}
//# sourceMappingURL=user-agent.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"user-agent.d.ts","sourceRoot":"","sources":["../../src/user-agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,UAAU,EACV,UAAU,EACV,WAAW,EACX,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,aAAa,CAAC;AAGrB,OAAO,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