@enbox/api 0.0.1

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 (92) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +585 -0
  3. package/dist/browser.js +2226 -0
  4. package/dist/browser.js.map +7 -0
  5. package/dist/browser.mjs +2226 -0
  6. package/dist/browser.mjs.map +7 -0
  7. package/dist/cjs/did-api.js +126 -0
  8. package/dist/cjs/did-api.js.map +1 -0
  9. package/dist/cjs/dwn-api.js +804 -0
  10. package/dist/cjs/dwn-api.js.map +1 -0
  11. package/dist/cjs/grant-revocation.js +183 -0
  12. package/dist/cjs/grant-revocation.js.map +1 -0
  13. package/dist/cjs/index.js +63 -0
  14. package/dist/cjs/index.js.map +1 -0
  15. package/dist/cjs/package.json +1 -0
  16. package/dist/cjs/permission-grant.js +365 -0
  17. package/dist/cjs/permission-grant.js.map +1 -0
  18. package/dist/cjs/permission-request.js +272 -0
  19. package/dist/cjs/permission-request.js.map +1 -0
  20. package/dist/cjs/protocol.js +110 -0
  21. package/dist/cjs/protocol.js.map +1 -0
  22. package/dist/cjs/record.js +1127 -0
  23. package/dist/cjs/record.js.map +1 -0
  24. package/dist/cjs/subscription-util.js +86 -0
  25. package/dist/cjs/subscription-util.js.map +1 -0
  26. package/dist/cjs/utils.js +127 -0
  27. package/dist/cjs/utils.js.map +1 -0
  28. package/dist/cjs/vc-api.js +64 -0
  29. package/dist/cjs/vc-api.js.map +1 -0
  30. package/dist/cjs/web5.js +471 -0
  31. package/dist/cjs/web5.js.map +1 -0
  32. package/dist/esm/did-api.js +69 -0
  33. package/dist/esm/did-api.js.map +1 -0
  34. package/dist/esm/dwn-api.js +573 -0
  35. package/dist/esm/dwn-api.js.map +1 -0
  36. package/dist/esm/grant-revocation.js +109 -0
  37. package/dist/esm/grant-revocation.js.map +1 -0
  38. package/dist/esm/index.js +34 -0
  39. package/dist/esm/index.js.map +1 -0
  40. package/dist/esm/permission-grant.js +233 -0
  41. package/dist/esm/permission-grant.js.map +1 -0
  42. package/dist/esm/permission-request.js +166 -0
  43. package/dist/esm/permission-request.js.map +1 -0
  44. package/dist/esm/protocol.js +67 -0
  45. package/dist/esm/protocol.js.map +1 -0
  46. package/dist/esm/record.js +814 -0
  47. package/dist/esm/record.js.map +1 -0
  48. package/dist/esm/subscription-util.js +35 -0
  49. package/dist/esm/subscription-util.js.map +1 -0
  50. package/dist/esm/utils.js +120 -0
  51. package/dist/esm/utils.js.map +1 -0
  52. package/dist/esm/vc-api.js +30 -0
  53. package/dist/esm/vc-api.js.map +1 -0
  54. package/dist/esm/web5.js +281 -0
  55. package/dist/esm/web5.js.map +1 -0
  56. package/dist/types/did-api.d.ts +66 -0
  57. package/dist/types/did-api.d.ts.map +1 -0
  58. package/dist/types/dwn-api.d.ts +336 -0
  59. package/dist/types/dwn-api.d.ts.map +1 -0
  60. package/dist/types/grant-revocation.d.ts +66 -0
  61. package/dist/types/grant-revocation.d.ts.map +1 -0
  62. package/dist/types/index.d.ts +34 -0
  63. package/dist/types/index.d.ts.map +1 -0
  64. package/dist/types/permission-grant.d.ts +157 -0
  65. package/dist/types/permission-grant.d.ts.map +1 -0
  66. package/dist/types/permission-request.d.ts +108 -0
  67. package/dist/types/permission-request.d.ts.map +1 -0
  68. package/dist/types/protocol.d.ts +59 -0
  69. package/dist/types/protocol.d.ts.map +1 -0
  70. package/dist/types/record.d.ts +441 -0
  71. package/dist/types/record.d.ts.map +1 -0
  72. package/dist/types/subscription-util.d.ts +19 -0
  73. package/dist/types/subscription-util.d.ts.map +1 -0
  74. package/dist/types/utils.d.ts +85 -0
  75. package/dist/types/utils.d.ts.map +1 -0
  76. package/dist/types/vc-api.d.ts +24 -0
  77. package/dist/types/vc-api.d.ts.map +1 -0
  78. package/dist/types/web5.d.ts +219 -0
  79. package/dist/types/web5.d.ts.map +1 -0
  80. package/package.json +111 -0
  81. package/src/did-api.ts +90 -0
  82. package/src/dwn-api.ts +952 -0
  83. package/src/grant-revocation.ts +124 -0
  84. package/src/index.ts +35 -0
  85. package/src/permission-grant.ts +327 -0
  86. package/src/permission-request.ts +214 -0
  87. package/src/protocol.ts +87 -0
  88. package/src/record.ts +1125 -0
  89. package/src/subscription-util.ts +42 -0
  90. package/src/utils.ts +128 -0
  91. package/src/vc-api.ts +30 -0
  92. package/src/web5.ts +516 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record.js","sourceRoot":"","sources":["../../src/record.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,2CAA2C;;;;;;;;;;;;;;;;;;;;;AAG3C,OAAO,EAEL,YAAY,EAMZ,mBAAmB,EACnB,eAAe,EAGf,YAAY,EAGZ,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,yBAAyB,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEtG,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAsKnD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,MAAM;IAmDjB,mFAAmF;IACnF,IAAY,uBAAuB;QACjC,IAAI,YAAY,CAAC,YAAY,CAAC,YAAY,EAAE,IAAI,CAAC,UAAU,CAAC,EAAE;YAC5D,OAAO,IAAI,CAAC,WAA8D,CAAC;SAC5E;QAED,OAAO,SAAS,CAAC,CAAC,iFAAiF;IACrG,CAAC;IAED,qHAAqH;IACrH,IAAY,oBAAoB;QAC9B,OAAO,IAAI,CAAC,uBAAuB,IAAI,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC;IACvE,CAAC;IAED,2CAA2C;IAC3C,kBAAkB;IAClB,IAAI,EAAE,KAAK,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAEnC,iGAAiG;IACjG,IAAI,SAAS,KAAK,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC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AAC,GAAG,QAAQ,yDAAyD,CAAC,CAAC;aACvF;SACF;IACH,CAAC;IAED;;;;OAIG;IACK,yBAAyB,CAAC,UAAwF;QACxH,OAAO,UAAU,CAAC,SAAS,GAAG,UAAU,CAAC,MAAM,KAAK,YAAY,CAAC,aAAa,CAAC;IACjF,CAAC;;AAh5BD;;;GAGG;AACY,iBAAU,GAAG,SAAS,CAAC"}
@@ -0,0 +1,35 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { getRecordAuthor } from '@enbox/agent';
11
+ import { Record } from './record.js';
12
+ /**
13
+ * Utility class for dealing with subscriptions.
14
+ */
15
+ export class SubscriptionUtil {
16
+ /**
17
+ * Creates a record subscription handler that can be used to process incoming {Record} messages.
18
+ */
19
+ static recordSubscriptionHandler({ agent, connectedDid, request, delegateDid, protocolRole, permissionsApi }) {
20
+ const { subscriptionHandler, from: remoteOrigin } = request;
21
+ return (event) => __awaiter(this, void 0, void 0, function* () {
22
+ const { message, initialWrite } = event;
23
+ const author = getRecordAuthor(message);
24
+ const recordOptions = {
25
+ author,
26
+ connectedDid,
27
+ remoteOrigin,
28
+ initialWrite
29
+ };
30
+ const record = new Record(agent, Object.assign(Object.assign(Object.assign({}, message), recordOptions), { protocolRole, delegateDid: delegateDid }), permissionsApi);
31
+ subscriptionHandler(record);
32
+ });
33
+ }
34
+ }
35
+ //# sourceMappingURL=subscription-util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscription-util.js","sourceRoot":"","sources":["../../src/subscription-util.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAgC,eAAe,EAA6B,MAAM,cAAc,CAAC;AAExG,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAC3B;;OAEG;IACH,MAAM,CAAC,yBAAyB,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,cAAc,EAOzG;QACC,MAAM,EAAE,mBAAmB,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;QAE5D,OAAO,CAAO,KAAK,EAAE,EAAE;YACrB,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC;YACxC,MAAM,MAAM,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;YACxC,MAAM,aAAa,GAAG;gBACpB,MAAM;gBACN,YAAY;gBACZ,YAAY;gBACZ,YAAY;aACb,CAAC;YAEF,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,KAAK,gDAC1B,OAAO,GACP,aAAa,KAChB,YAAY,EACZ,WAAW,EAAE,WAAW,KACvB,cAAc,CAAC,CAAC;YAEnB,mBAAmB,CAAC,MAAM,CAAC,CAAC;QAC9B,CAAC,CAAA,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,120 @@
1
+ import { Convert, universalTypeOf } from '@enbox/common';
2
+ /**
3
+ * Converts various data types to a `Blob` object, automatically detecting the data type or using
4
+ * the specified `dataFormat` to set the Blob's MIME type.
5
+ *
6
+ * This function supports plain text, JSON objects, binary data (Uint8Array, ArrayBuffer), and Blob
7
+ * inputs and will attempt to automatically detect the type of the data if `dataFormat` is not
8
+ * explicitly provided.
9
+ *
10
+ * @beta
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * // Convert a JSON object to a Blob
15
+ * const { dataBlob, dataFormat } = dataToBlob({ key: 'value' }, 'application/json');
16
+ *
17
+ * // Convert a plain text string to a Blob without specifying dataFormat
18
+ * const { dataBlob: textBlob } = dataToBlob('Hello, world!');
19
+ *
20
+ * // Convert binary data to a Blob
21
+ * const binaryData = new Uint8Array([0, 1, 2, 3]);
22
+ * const { dataBlob: binaryBlob } = dataToBlob(binaryData);
23
+ * ```
24
+ *
25
+ * @param data - The data to be converted into a `Blob`. This can be a string, an object, binary
26
+ * data (Uint8Array or ArrayBuffer), or a Blob.
27
+ * @param dataFormat - An optional MIME type string that specifies the format of the data. Common
28
+ * types include 'text/plain' for string data, 'application/json' for JSON
29
+ * objects, and 'application/octet-stream' for binary data. If not provided, the
30
+ * function will attempt to detect the format based on the data type or default
31
+ * to 'application/octet-stream'.
32
+ * @returns An object containing the `dataBlob`, a Blob representation of the input data, and
33
+ * `dataFormat`, the MIME type of the data as determined by the function or specified by the caller.
34
+ * @throws An error if the data type is not supported or cannot be converted to a Blob.
35
+ */
36
+ export function dataToBlob(data, dataFormat) {
37
+ let dataBlob;
38
+ // Check for Object or String, and if neither, assume bytes.
39
+ const detectedType = universalTypeOf(data);
40
+ if (dataFormat === 'text/plain' || detectedType === 'String') {
41
+ dataBlob = new Blob([data], { type: 'text/plain' });
42
+ }
43
+ else if (dataFormat === 'application/json' || detectedType === 'Object') {
44
+ const dataBytes = Convert.object(data).toUint8Array();
45
+ dataBlob = new Blob([dataBytes], { type: 'application/json' });
46
+ }
47
+ else if (detectedType === 'Uint8Array' || detectedType === 'ArrayBuffer') {
48
+ dataBlob = new Blob([data], { type: 'application/octet-stream' });
49
+ }
50
+ else if (detectedType === 'Blob') {
51
+ dataBlob = data;
52
+ }
53
+ else {
54
+ throw new Error('data type not supported.');
55
+ }
56
+ dataFormat = dataFormat || dataBlob.type || 'application/octet-stream';
57
+ return { dataBlob, dataFormat };
58
+ }
59
+ /**
60
+ * The `SendCache` class provides a static caching mechanism to optimize the process of sending
61
+ * records to remote DWN targets by minimizing redundant sends.
62
+ *
63
+ * It maintains a cache of record IDs and their associated target DIDs to which they have been sent.
64
+ * This helps in avoiding unnecessary network requests and ensures efficient data synchronization
65
+ * across Decentralized Web Nodes (DWNs).
66
+ *
67
+ * The cache employs a simple eviction policy to maintain a manageable size, ensuring that the cache
68
+ * does not grow indefinitely and consume excessive memory resources.
69
+ *
70
+ * @beta
71
+ */
72
+ export class SendCache {
73
+ /**
74
+ * Checks if a given record ID has been sent to a specified target DID. This method is used to
75
+ * determine whether a send operation is necessary or if it can be skipped to avoid redundancy.
76
+ *
77
+ * @param id - The unique identifier of the record.
78
+ * @param target - The DID of the target to check against.
79
+ * @returns A boolean indicating whether the record has been sent to the target.
80
+ */
81
+ static check(id, target) {
82
+ let targetCache = SendCache.cache.get(id);
83
+ return targetCache ? targetCache.has(target) : false;
84
+ }
85
+ /**
86
+ * Adds or updates an entry in the cache for a given record ID and target DID. If the cache
87
+ * exceeds its size limit, the oldest entry is removed. This method ensures that the cache
88
+ * reflects the most recent sends.
89
+ *
90
+ * @param id - The unique identifier of the record.
91
+ * @param target - The DID of the target to which the record has been sent.
92
+ */
93
+ static set(id, target) {
94
+ let targetCache = SendCache.cache.get(id) || new Set();
95
+ SendCache.cache.delete(id);
96
+ SendCache.cache.set(id, targetCache);
97
+ if (this.cache.size > SendCache.sendCacheLimit) {
98
+ const firstRecord = SendCache.cache.keys().next().value;
99
+ SendCache.cache.delete(firstRecord);
100
+ }
101
+ targetCache.delete(target);
102
+ targetCache.add(target);
103
+ if (targetCache.size > SendCache.sendCacheLimit) {
104
+ const firstTarget = targetCache.keys().next().value;
105
+ targetCache.delete(firstTarget);
106
+ }
107
+ }
108
+ }
109
+ /**
110
+ * A private static map that serves as the core storage mechanism for the cache. It maps record
111
+ * IDs to a set of target DIDs, indicating which records have been sent to which targets.
112
+ */
113
+ SendCache.cache = new Map();
114
+ /**
115
+ * The maximum number of entries allowed in the cache. Once this limit is exceeded, the oldest
116
+ * entries are evicted to make room for new ones. This limit applies both to the number of records
117
+ * and the number of targets per record.
118
+ */
119
+ SendCache.sendCacheLimit = 100;
120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IG;AACY,wBAAc,GAAG,GAAG,CAAC"}
@@ -0,0 +1,30 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ /**
11
+ * The VC API is used to issue, present and verify VCs
12
+ *
13
+ * @beta
14
+ */
15
+ export class VcApi {
16
+ constructor(options) {
17
+ this.agent = options.agent;
18
+ this.connectedDid = options.connectedDid;
19
+ }
20
+ /**
21
+ * Issues a VC (Not implemented yet)
22
+ */
23
+ create() {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ // TODO: implement
26
+ throw new Error('Not implemented.');
27
+ });
28
+ }
29
+ }
30
+ //# sourceMappingURL=vc-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vc-api.js","sourceRoot":"","sources":["../../src/vc-api.ts"],"names":[],"mappings":";;;;;;;;;AAEA;;;;GAIG;AACH,MAAM,OAAO,KAAK;IAUhB,YAAY,OAAmD;QAC7D,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IAC3C,CAAC;IAED;;OAEG;IACG,MAAM;;YACV,kBAAkB;YAClB,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;QACtC,CAAC;KAAA;CACF"}
@@ -0,0 +1,281 @@
1
+ /**
2
+ * NOTE: Added reference types here to avoid a `pnpm` bug during build.
3
+ * https://github.com/TBD54566975/web5-js/pull/507
4
+ */
5
+ /// <reference types="@enbox/dwn-sdk-js" />
6
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
7
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8
+ return new (P || (P = Promise))(function (resolve, reject) {
9
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
10
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
13
+ });
14
+ };
15
+ var __rest = (this && this.__rest) || function (s, e) {
16
+ var t = {};
17
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
18
+ t[p] = s[p];
19
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
20
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
21
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
22
+ t[p[i]] = s[p[i]];
23
+ }
24
+ return t;
25
+ };
26
+ import { Web5UserAgent } from '@enbox/user-agent';
27
+ import { DwnRegistrar, WalletConnect } from '@enbox/agent';
28
+ import { DidApi } from './did-api.js';
29
+ import { DwnApi } from './dwn-api.js';
30
+ import { VcApi } from './vc-api.js';
31
+ import { PermissionGrant } from './permission-grant.js';
32
+ /**
33
+ * The main Web5 API interface. It manages the creation of a DID if needed, the connection to the
34
+ * local DWN and all the web5 main foundational APIs such as VC, syncing, etc.
35
+ */
36
+ export class Web5 {
37
+ constructor({ agent, connectedDid, delegateDid }) {
38
+ this.agent = agent;
39
+ this.did = new DidApi({ agent, connectedDid });
40
+ this.dwn = new DwnApi({ agent, connectedDid, delegateDid });
41
+ this.vc = new VcApi({ agent, connectedDid });
42
+ }
43
+ /**
44
+ * Connects to a {@link Web5Agent}. Defaults to creating a local {@link Web5UserAgent} if one
45
+ * isn't provided.
46
+ *
47
+ * If `walletConnectOptions` are provided, a WalletConnect flow will be initiated to import a delegated DID from an external wallet.
48
+ * If there is a failure at any point during connecting and processing grants, all created DIDs and Identities as well as the provided grants
49
+ * will be cleaned up and an error thrown. This allows for subsequent Connect attempts to be made without any errors.
50
+ *
51
+ * @param options - Optional overrides that can be provided when calling {@link Web5.connect}.
52
+ * @returns A promise that resolves to a {@link Web5} instance and the connected DID.
53
+ */
54
+ static connect({ agent, agentVault, connectedDid, password, recoveryPhrase, sync, techPreview, didCreateOptions, registration, walletConnectOptions, } = {}) {
55
+ var _a, _b, _c;
56
+ return __awaiter(this, void 0, void 0, function* () {
57
+ let delegateDid;
58
+ if (agent === undefined) {
59
+ let registerSync = false;
60
+ // A custom Web5Agent implementation was not specified, so use default managed user agent.
61
+ const userAgent = yield Web5UserAgent.create({ agentVault });
62
+ agent = userAgent;
63
+ // Warn the developer and application user of the security risks of using a static password.
64
+ if (password === undefined) {
65
+ password = 'insecure-static-phrase';
66
+ console.warn('%cSECURITY WARNING:%c ' +
67
+ 'You have not set a password, which defaults to a static, guessable value. ' +
68
+ 'This significantly compromises the security of your data. ' +
69
+ 'Please configure a secure, unique password.', 'font-weight: bold; color: red;', 'font-weight: normal; color: inherit;');
70
+ }
71
+ // Use the specified DWN endpoints or the latest TBD hosted DWN
72
+ const serviceEndpointNodes = (_b = (_a = techPreview === null || techPreview === void 0 ? void 0 : techPreview.dwnEndpoints) !== null && _a !== void 0 ? _a : didCreateOptions === null || didCreateOptions === void 0 ? void 0 : didCreateOptions.dwnEndpoints) !== null && _b !== void 0 ? _b : ['https://enbox-production.up.railway.app'];
73
+ // Initialize, if necessary, and start the agent.
74
+ if (yield userAgent.firstLaunch()) {
75
+ recoveryPhrase = yield userAgent.initialize({ password, recoveryPhrase, dwnEndpoints: serviceEndpointNodes });
76
+ }
77
+ yield userAgent.start({ password });
78
+ // Attempt to retrieve the connected Identity if it exists.
79
+ const connectedIdentity = yield userAgent.identity.connectedIdentity();
80
+ let identity;
81
+ let connectedProtocols = [];
82
+ if (connectedIdentity) {
83
+ // if a connected identity is found, use it
84
+ // TODO: In the future, implement a way to re-connect an already connected identity and apply additional grants/protocols
85
+ identity = connectedIdentity;
86
+ }
87
+ else if (walletConnectOptions) {
88
+ if (sync === 'off') {
89
+ // Currently we require sync to be enabled when using WalletConnect
90
+ // This is to ensure a connected app is not in a disjointed state from any other clients/app using the connectedDid
91
+ throw new Error('Sync must not be disabled when using WalletConnect');
92
+ }
93
+ // Since we are connecting a new identity, we will want to register sync for the connectedDid
94
+ registerSync = true;
95
+ // No connected identity found and connectOptions are provided, attempt to import a delegated DID from an external wallet
96
+ try {
97
+ const { permissionRequests } = walletConnectOptions, connectOptions = __rest(walletConnectOptions, ["permissionRequests"]);
98
+ const walletPermissionRequests = permissionRequests.map(({ protocolDefinition, permissions }) => WalletConnect.createPermissionRequestForProtocol({
99
+ definition: protocolDefinition,
100
+ permissions: permissions !== null && permissions !== void 0 ? permissions : [
101
+ 'read', 'write', 'delete', 'query', 'subscribe'
102
+ ]
103
+ }));
104
+ const { delegatePortableDid, connectedDid, delegateGrants } = yield WalletConnect.initClient(Object.assign(Object.assign({}, connectOptions), { permissionRequests: walletPermissionRequests }));
105
+ // Import the delegated DID as an Identity in the User Agent.
106
+ // Setting the connectedDID in the metadata applies a relationship between the signer identity and the one it is impersonating.
107
+ identity = yield userAgent.identity.import({ portableIdentity: {
108
+ portableDid: delegatePortableDid,
109
+ metadata: {
110
+ connectedDid,
111
+ name: 'Default',
112
+ uri: delegatePortableDid.uri,
113
+ tenant: agent.agentDid.uri,
114
+ }
115
+ } });
116
+ // Attempts to process the connected grants to be used by the delegateDID
117
+ // If the process fails, we want to clean up the identity
118
+ // the connected grants will return a de-duped array of protocol URIs that are used to register sync for those protocols
119
+ connectedProtocols = yield this.processConnectedGrants({ agent, delegateDid: delegatePortableDid.uri, grants: delegateGrants });
120
+ }
121
+ catch (error) {
122
+ // clean up the DID and Identity if import fails and throw
123
+ // TODO: Implement the ability to purge all of our messages as a tenant
124
+ yield this.cleanUpIdentity({ identity, userAgent });
125
+ throw new Error(`Failed to connect to wallet: ${error.message}`);
126
+ }
127
+ }
128
+ else {
129
+ // No connected identity found and no connectOptions provided, use local Identities
130
+ // Query the Agent's DWN tenant for identity records.
131
+ const identities = yield userAgent.identity.list();
132
+ // If an existing identity is not found found, create a new one.
133
+ const existingIdentityCount = identities.length;
134
+ if (existingIdentityCount === 0) {
135
+ // since we are creating a new identity, we will want to register sync for the created Did
136
+ registerSync = true;
137
+ // Generate a new Identity for the end-user.
138
+ identity = yield userAgent.identity.create({
139
+ didMethod: 'dht',
140
+ metadata: { name: 'Default' },
141
+ didOptions: {
142
+ services: [
143
+ {
144
+ id: 'dwn',
145
+ type: 'DecentralizedWebNode',
146
+ serviceEndpoint: serviceEndpointNodes,
147
+ enc: '#enc',
148
+ sig: '#sig',
149
+ }
150
+ ],
151
+ verificationMethods: [
152
+ {
153
+ algorithm: 'Ed25519',
154
+ id: 'sig',
155
+ purposes: ['assertionMethod', 'authentication']
156
+ },
157
+ {
158
+ algorithm: 'secp256k1',
159
+ id: 'enc',
160
+ purposes: ['keyAgreement']
161
+ }
162
+ ]
163
+ }
164
+ });
165
+ }
166
+ else {
167
+ // If multiple identities are found, use the first one.
168
+ // TODO: Implement selecting a connectedDid from multiple identities
169
+ identity = identities[0];
170
+ }
171
+ }
172
+ // If the stored identity has a connected DID, use it as the connected DID, otherwise use the identity's DID.
173
+ connectedDid = (_c = identity.metadata.connectedDid) !== null && _c !== void 0 ? _c : identity.did.uri;
174
+ // If the stored identity has a connected DID, use the identity DID as the delegated DID, otherwise it is undefined.
175
+ delegateDid = identity.metadata.connectedDid ? identity.did.uri : undefined;
176
+ if (registration !== undefined) {
177
+ // If a registration object is passed, we attempt to register the AgentDID and the ConnectedDID with the DWN endpoints provided
178
+ try {
179
+ for (const dwnEndpoint of serviceEndpointNodes) {
180
+ // check if endpoint needs registration
181
+ const serverInfo = yield userAgent.rpc.getServerInfo(dwnEndpoint);
182
+ if (serverInfo.registrationRequirements.length === 0) {
183
+ // no registration required
184
+ continue;
185
+ }
186
+ // register the agent DID
187
+ yield DwnRegistrar.registerTenant(dwnEndpoint, agent.agentDid.uri);
188
+ // register the connected Identity DID
189
+ yield DwnRegistrar.registerTenant(dwnEndpoint, connectedDid);
190
+ }
191
+ // If no failures occurred, call the onSuccess callback
192
+ registration.onSuccess();
193
+ }
194
+ catch (error) {
195
+ // for any failure, call the onFailure callback with the error
196
+ registration.onFailure(error);
197
+ }
198
+ }
199
+ // Enable sync, unless explicitly disabled.
200
+ if (sync !== 'off') {
201
+ // First, register the user identity for sync.
202
+ // The connected protocols are used to register sync for only a subset of protocols from the connectedDid's DWN
203
+ if (registerSync) {
204
+ yield userAgent.sync.registerIdentity({
205
+ did: connectedDid,
206
+ options: {
207
+ delegateDid,
208
+ protocols: connectedProtocols
209
+ }
210
+ });
211
+ if (walletConnectOptions !== undefined) {
212
+ // If we are using WalletConnect, we should do a one-shot sync to pull down any messages that are associated with the connectedDid
213
+ yield userAgent.sync.sync('pull');
214
+ }
215
+ }
216
+ // Enable sync using the specified interval or default.
217
+ sync !== null && sync !== void 0 ? sync : (sync = '2m');
218
+ userAgent.sync.startSync({ interval: sync })
219
+ .catch((error) => {
220
+ console.error(`Sync failed: ${error}`);
221
+ });
222
+ }
223
+ }
224
+ const web5 = new Web5({ agent, connectedDid, delegateDid });
225
+ return { web5, did: connectedDid, delegateDid, recoveryPhrase };
226
+ });
227
+ }
228
+ /**
229
+ * Cleans up the DID, Keys and Identity. Primarily used by a failed WalletConnect import.
230
+ * Does not throw on error, but logs to console.
231
+ */
232
+ static cleanUpIdentity({ identity, userAgent }) {
233
+ return __awaiter(this, void 0, void 0, function* () {
234
+ try {
235
+ // Delete the DID and the Associated Keys
236
+ yield userAgent.did.delete({
237
+ didUri: identity.did.uri,
238
+ tenant: identity.metadata.tenant,
239
+ deleteKey: true,
240
+ });
241
+ }
242
+ catch (error) {
243
+ console.error(`Failed to delete DID ${identity.did.uri}: ${error.message}`);
244
+ }
245
+ try {
246
+ // Delete the Identity
247
+ yield userAgent.identity.delete({ didUri: identity.did.uri });
248
+ }
249
+ catch (error) {
250
+ console.error(`Failed to delete Identity ${identity.metadata.name}: ${error.message}`);
251
+ }
252
+ });
253
+ }
254
+ /**
255
+ * A static method to process connected grants for a delegate DID.
256
+ *
257
+ * This will store the grants as the DWN owner to be used later when impersonating the connected DID.
258
+ */
259
+ static processConnectedGrants({ grants, agent, delegateDid }) {
260
+ return __awaiter(this, void 0, void 0, function* () {
261
+ const connectedProtocols = new Set();
262
+ for (const grantMessage of grants) {
263
+ // use the delegateDid as the connectedDid of the grant as they do not yet support impersonation/delegation
264
+ const grant = yield PermissionGrant.parse({ connectedDid: delegateDid, agent, message: grantMessage });
265
+ // store the grant as the owner of the DWN, this will allow the delegateDid to use the grant when impersonating the connectedDid
266
+ const { status } = yield grant.store(true);
267
+ if (status.code !== 202) {
268
+ throw new Error(`AgentDwnApi: Failed to process connected grant: ${status.detail}`);
269
+ }
270
+ const protocol = grant.scope.protocol;
271
+ if (protocol) {
272
+ connectedProtocols.add(protocol);
273
+ }
274
+ }
275
+ // currently we return a de-duped set of protocols represented by these grants, this is used to register protocols for sync
276
+ // we expect that any connected protocols will include MessagesQuery and MessagesRead grants that will allow it to sync
277
+ return [...connectedProtocols];
278
+ });
279
+ }
280
+ }
281
+ //# sourceMappingURL=web5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web5.js","sourceRoot":"","sources":["../../src/web5.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,2CAA2C;;;;;;;;;;;;;;;;;;;;;AAc3C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAgB,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAEzE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM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,MAAM,EAAE,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAC3C,IAAI,MAAM,CAAC,IAAI,KAAK,GAAG,EAAE;oBACvB,MAAM,IAAI,KAAK,CAAC,mDAAmD,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;iBACrF;gBAED,MAAM,QAAQ,GAAI,KAAK,CAAC,KAAgE,CAAC,QAAQ,CAAC;gBAClG,IAAI,QAAQ,EAAE;oBACZ,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;iBAClC;aACF;YAED,2HAA2H;YAC3H,uHAAuH;YACvH,OAAO,CAAC,GAAG,kBAAkB,CAAC,CAAC;QACjC,CAAC;KAAA;CACF"}
@@ -0,0 +1,66 @@
1
+ import type { DidCreateParams, DidMessageResult, DidResolveParams, ResponseStatus, Web5Agent } from '@enbox/agent';
2
+ import { DidInterface } from '@enbox/agent';
3
+ /**
4
+ * Parameters for creating a DID, specifying the method, options for the DID method, and whether to
5
+ * store the DID.
6
+ *
7
+ * @typeParam method - The DID method to use for creating the DID.
8
+ * @typeParam options - Method-specific options for creating the DID.
9
+ * @typeParam store - Indicates whether the newly created DID should be stored.
10
+ */
11
+ export type DidCreateRequest = Pick<DidCreateParams, 'method' | 'options' | 'store'>;
12
+ /**
13
+ * The response from a DID creation request, including the operation's status and, if successful,
14
+ * the created DID.
15
+ */
16
+ export type DidCreateResponse = ResponseStatus & {
17
+ /** The result of the DID creation operation, containing the newly created DID, if successful */
18
+ did?: DidMessageResult[DidInterface.Create];
19
+ };
20
+ /**
21
+ * The response from resolving a DID, containing the DID Resolution Result.
22
+ *
23
+ * This type directly maps to the result of a DID resolution operation, providing detailed
24
+ * information about the DID document, including any DID document metadata and DID resolution
25
+ * metadata,
26
+ */
27
+ export type DidResolveResponse = DidMessageResult[DidInterface.Resolve];
28
+ /**
29
+ * The DID API is used to resolve DIDs.
30
+ *
31
+ * @beta
32
+ */
33
+ export declare class DidApi {
34
+ /**
35
+ * Holds the instance of a {@link Web5Agent} that represents the current execution context for
36
+ * the `DidApi`. This agent is used to process DID requests.
37
+ */
38
+ private agent;
39
+ /** The DID of the tenant under which DID operations are being performed. */
40
+ private connectedDid;
41
+ constructor(options: {
42
+ agent: Web5Agent;
43
+ connectedDid: string;
44
+ });
45
+ /**
46
+ * Initiates the creation of a Decentralized Identifier (DID) using the specified method, options,
47
+ * and storage preference.
48
+ *
49
+ * This method sends a request to the Web5 Agent to create a new DID based on the provided method,
50
+ * with method-specific options. It also specifies whether the newly created DID should be stored.
51
+ *
52
+ * @param request - The request parameters for creating a DID, including the method, options, and
53
+ * storage flag.
54
+ * @returns A promise that resolves to a `DidCreateResponse`, which includes the operation's
55
+ * status and, if successful, the newly created DID.
56
+ */
57
+ create(request: DidCreateRequest): Promise<DidCreateResponse>;
58
+ /**
59
+ * Resolves a DID to a DID Resolution Result.
60
+ *
61
+ * @param didUri - The DID or DID URL to resolve.
62
+ * @returns A promise that resolves to the DID Resolution Result.
63
+ */
64
+ resolve(didUri: DidResolveParams['didUri'], options?: DidResolveParams['options']): Promise<DidResolveResponse>;
65
+ }
66
+ //# sourceMappingURL=did-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"did-api.d.ts","sourceRoot":"","sources":["../../src/did-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEnH,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C;;;;;;;GAOG;AACH,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,eAAe,EAAE,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC,CAAC;AAErF;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,cAAc,GAAG;IAC/C,gGAAgG;IAChG,GAAG,CAAC,EAAE,gBAAgB,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;CAC7C,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;AAExE;;;;GAIG;AACH,qBAAa,MAAM;IACjB;;;OAGG;IACH,OAAO,CAAC,KAAK,CAAY;IAEzB,4EAA4E;IAC5E,OAAO,CAAC,YAAY,CAAS;gBAEjB,OAAO,EAAE;QAAE,KAAK,EAAE,SAAS,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE;IAK/D;;;;;;;;;;;OAWG;IACU,MAAM,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAS1E;;;;;OAKG;IACU,OAAO,CAClB,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,EAAE,gBAAgB,CAAC,SAAS,CAAC,GACxE,OAAO,CAAC,kBAAkB,CAAC;CAQ/B"}