@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.
- package/LICENSE +201 -0
- package/README.md +585 -0
- package/dist/browser.js +2226 -0
- package/dist/browser.js.map +7 -0
- package/dist/browser.mjs +2226 -0
- package/dist/browser.mjs.map +7 -0
- package/dist/cjs/did-api.js +126 -0
- package/dist/cjs/did-api.js.map +1 -0
- package/dist/cjs/dwn-api.js +804 -0
- package/dist/cjs/dwn-api.js.map +1 -0
- package/dist/cjs/grant-revocation.js +183 -0
- package/dist/cjs/grant-revocation.js.map +1 -0
- package/dist/cjs/index.js +63 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/permission-grant.js +365 -0
- package/dist/cjs/permission-grant.js.map +1 -0
- package/dist/cjs/permission-request.js +272 -0
- package/dist/cjs/permission-request.js.map +1 -0
- package/dist/cjs/protocol.js +110 -0
- package/dist/cjs/protocol.js.map +1 -0
- package/dist/cjs/record.js +1127 -0
- package/dist/cjs/record.js.map +1 -0
- package/dist/cjs/subscription-util.js +86 -0
- package/dist/cjs/subscription-util.js.map +1 -0
- package/dist/cjs/utils.js +127 -0
- package/dist/cjs/utils.js.map +1 -0
- package/dist/cjs/vc-api.js +64 -0
- package/dist/cjs/vc-api.js.map +1 -0
- package/dist/cjs/web5.js +471 -0
- package/dist/cjs/web5.js.map +1 -0
- package/dist/esm/did-api.js +69 -0
- package/dist/esm/did-api.js.map +1 -0
- package/dist/esm/dwn-api.js +573 -0
- package/dist/esm/dwn-api.js.map +1 -0
- package/dist/esm/grant-revocation.js +109 -0
- package/dist/esm/grant-revocation.js.map +1 -0
- package/dist/esm/index.js +34 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/permission-grant.js +233 -0
- package/dist/esm/permission-grant.js.map +1 -0
- package/dist/esm/permission-request.js +166 -0
- package/dist/esm/permission-request.js.map +1 -0
- package/dist/esm/protocol.js +67 -0
- package/dist/esm/protocol.js.map +1 -0
- package/dist/esm/record.js +814 -0
- package/dist/esm/record.js.map +1 -0
- package/dist/esm/subscription-util.js +35 -0
- package/dist/esm/subscription-util.js.map +1 -0
- package/dist/esm/utils.js +120 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/esm/vc-api.js +30 -0
- package/dist/esm/vc-api.js.map +1 -0
- package/dist/esm/web5.js +281 -0
- package/dist/esm/web5.js.map +1 -0
- package/dist/types/did-api.d.ts +66 -0
- package/dist/types/did-api.d.ts.map +1 -0
- package/dist/types/dwn-api.d.ts +336 -0
- package/dist/types/dwn-api.d.ts.map +1 -0
- package/dist/types/grant-revocation.d.ts +66 -0
- package/dist/types/grant-revocation.d.ts.map +1 -0
- package/dist/types/index.d.ts +34 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/permission-grant.d.ts +157 -0
- package/dist/types/permission-grant.d.ts.map +1 -0
- package/dist/types/permission-request.d.ts +108 -0
- package/dist/types/permission-request.d.ts.map +1 -0
- package/dist/types/protocol.d.ts +59 -0
- package/dist/types/protocol.d.ts.map +1 -0
- package/dist/types/record.d.ts +441 -0
- package/dist/types/record.d.ts.map +1 -0
- package/dist/types/subscription-util.d.ts +19 -0
- package/dist/types/subscription-util.d.ts.map +1 -0
- package/dist/types/utils.d.ts +85 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/dist/types/vc-api.d.ts +24 -0
- package/dist/types/vc-api.d.ts.map +1 -0
- package/dist/types/web5.d.ts +219 -0
- package/dist/types/web5.d.ts.map +1 -0
- package/package.json +111 -0
- package/src/did-api.ts +90 -0
- package/src/dwn-api.ts +952 -0
- package/src/grant-revocation.ts +124 -0
- package/src/index.ts +35 -0
- package/src/permission-grant.ts +327 -0
- package/src/permission-request.ts +214 -0
- package/src/protocol.ts +87 -0
- package/src/record.ts +1125 -0
- package/src/subscription-util.ts +42 -0
- package/src/utils.ts +128 -0
- package/src/vc-api.ts +30 -0
- package/src/web5.ts +516 -0
|
@@ -0,0 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;wCACH,YAAY,EAAG,IAAI,CAAC,YAAY,EAChC,WAAW,EAAI,QAAQ,EACvB,WAAW,EAAI,IAAI,CAAC,WAAW,IAC5B,eAAe,CACnB,CAAC;oCAEF,MAAM,GAAG,IAAI,kBAAM,CAAC,IAAI,CAAC,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;iCACrE;gCAED,sBAAO,EAAE,MAAM,QAAA,EAAE,MAAM,QAAA,EAAE,EAAC;;;qBAC3B;aACF,CAAC;QACJ,CAAC;;;OAAA;IACH,aAAC;AAAD,CAAC,AAtpBD,IAspBC;AAtpBY,wBAAM"}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
50
|
+
var t = {};
|
|
51
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
52
|
+
t[p] = s[p];
|
|
53
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
54
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
55
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
56
|
+
t[p[i]] = s[p[i]];
|
|
57
|
+
}
|
|
58
|
+
return t;
|
|
59
|
+
};
|
|
60
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
61
|
+
exports.PermissionGrantRevocation = void 0;
|
|
62
|
+
var agent_1 = require("@enbox/agent");
|
|
63
|
+
var agent_2 = require("@enbox/agent");
|
|
64
|
+
var common_1 = require("@enbox/common");
|
|
65
|
+
/**
|
|
66
|
+
* The `PermissionGrantRevocation` class encapsulates a permissions protocol `grant/revocation` record, providing a more
|
|
67
|
+
* developer-friendly interface for working with Decentralized Web Node (DWN) records.
|
|
68
|
+
*
|
|
69
|
+
* Methods are provided to manage the grant revocation's lifecycle, including writing to remote DWNs.
|
|
70
|
+
*
|
|
71
|
+
* @beta
|
|
72
|
+
*/
|
|
73
|
+
var PermissionGrantRevocation = /** @class */ (function () {
|
|
74
|
+
function PermissionGrantRevocation(permissions, options) {
|
|
75
|
+
this._permissions = permissions;
|
|
76
|
+
this._connectedDid = options.connectedDid;
|
|
77
|
+
// Store the message that represents the grant.
|
|
78
|
+
this._message = options.message;
|
|
79
|
+
}
|
|
80
|
+
Object.defineProperty(PermissionGrantRevocation.prototype, "author", {
|
|
81
|
+
/** The author of the underlying revocation message */
|
|
82
|
+
get: function () {
|
|
83
|
+
return (0, agent_1.getRecordAuthor)(this._message);
|
|
84
|
+
},
|
|
85
|
+
enumerable: false,
|
|
86
|
+
configurable: true
|
|
87
|
+
});
|
|
88
|
+
/** parses the grant revocation given am agent, connectedDid and data encoded records write message */
|
|
89
|
+
PermissionGrantRevocation.parse = function (_a) {
|
|
90
|
+
var connectedDid = _a.connectedDid, agent = _a.agent, message = _a.message;
|
|
91
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
92
|
+
var permissions;
|
|
93
|
+
return __generator(this, function (_b) {
|
|
94
|
+
permissions = new agent_1.AgentPermissionsApi({ agent: agent });
|
|
95
|
+
return [2 /*return*/, new PermissionGrantRevocation(permissions, { connectedDid: connectedDid, message: message })];
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
Object.defineProperty(PermissionGrantRevocation.prototype, "agent", {
|
|
100
|
+
/** The agent to use for this instantiation of the grant revocation */
|
|
101
|
+
get: function () {
|
|
102
|
+
return this._permissions.agent;
|
|
103
|
+
},
|
|
104
|
+
enumerable: false,
|
|
105
|
+
configurable: true
|
|
106
|
+
});
|
|
107
|
+
Object.defineProperty(PermissionGrantRevocation.prototype, "rawMessage", {
|
|
108
|
+
/** The raw `RecordsWrite` DWN message with encoded data that was used to instantiate this grant revocation */
|
|
109
|
+
get: function () {
|
|
110
|
+
return this._message;
|
|
111
|
+
},
|
|
112
|
+
enumerable: false,
|
|
113
|
+
configurable: true
|
|
114
|
+
});
|
|
115
|
+
/**
|
|
116
|
+
* Send the current grant revocation to a remote DWN by specifying their DID
|
|
117
|
+
* If no DID is specified, the target is assumed to be the owner (connectedDID).
|
|
118
|
+
*
|
|
119
|
+
* @param target - the optional DID to send the grant revocation to, if none is set it is sent to the connectedDid
|
|
120
|
+
* @returns the status of the send grant revocation request
|
|
121
|
+
*
|
|
122
|
+
* @beta
|
|
123
|
+
*/
|
|
124
|
+
PermissionGrantRevocation.prototype.send = function (target) {
|
|
125
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
126
|
+
var _a, encodedData, rawMessage, dataStream, sendRequestOptions, reply;
|
|
127
|
+
return __generator(this, function (_b) {
|
|
128
|
+
switch (_b.label) {
|
|
129
|
+
case 0:
|
|
130
|
+
target !== null && target !== void 0 ? target : (target = this._connectedDid);
|
|
131
|
+
_a = this._message, encodedData = _a.encodedData, rawMessage = __rest(_a, ["encodedData"]);
|
|
132
|
+
dataStream = new Blob([common_1.Convert.base64Url(encodedData).toUint8Array()]);
|
|
133
|
+
sendRequestOptions = {
|
|
134
|
+
messageType: agent_2.DwnInterface.RecordsWrite,
|
|
135
|
+
author: this._connectedDid,
|
|
136
|
+
target: target,
|
|
137
|
+
dataStream: dataStream,
|
|
138
|
+
rawMessage: rawMessage,
|
|
139
|
+
};
|
|
140
|
+
return [4 /*yield*/, this.agent.sendDwnRequest(sendRequestOptions)];
|
|
141
|
+
case 1:
|
|
142
|
+
reply = (_b.sent()).reply;
|
|
143
|
+
return [2 /*return*/, reply];
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* Stores the current grant revocation to the owner's DWN.
|
|
150
|
+
*
|
|
151
|
+
* @param importGrant - if true, the grant revocation will signed by the owner before storing it to the owner's DWN. Defaults to false.
|
|
152
|
+
* @returns the status of the store request
|
|
153
|
+
*
|
|
154
|
+
* @beta
|
|
155
|
+
*/
|
|
156
|
+
PermissionGrantRevocation.prototype.store = function (importRevocation) {
|
|
157
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
158
|
+
var _a, encodedData, rawMessage, dataStream, _b, reply, message;
|
|
159
|
+
return __generator(this, function (_c) {
|
|
160
|
+
switch (_c.label) {
|
|
161
|
+
case 0:
|
|
162
|
+
_a = this.rawMessage, encodedData = _a.encodedData, rawMessage = __rest(_a, ["encodedData"]);
|
|
163
|
+
dataStream = new Blob([common_1.Convert.base64Url(encodedData).toUint8Array()]);
|
|
164
|
+
return [4 /*yield*/, this.agent.processDwnRequest({
|
|
165
|
+
author: this._connectedDid,
|
|
166
|
+
target: this._connectedDid,
|
|
167
|
+
messageType: agent_2.DwnInterface.RecordsWrite,
|
|
168
|
+
signAsOwner: importRevocation,
|
|
169
|
+
rawMessage: rawMessage,
|
|
170
|
+
dataStream: dataStream,
|
|
171
|
+
})];
|
|
172
|
+
case 1:
|
|
173
|
+
_b = _c.sent(), reply = _b.reply, message = _b.message;
|
|
174
|
+
this._message = __assign(__assign({}, message), { encodedData: encodedData });
|
|
175
|
+
return [2 /*return*/, { status: reply.status }];
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
return PermissionGrantRevocation;
|
|
181
|
+
}());
|
|
182
|
+
exports.PermissionGrantRevocation = PermissionGrantRevocation;
|
|
183
|
+
//# sourceMappingURL=grant-revocation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grant-revocation.js","sourceRoot":"","sources":["../../src/grant-revocation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sCAAqJ;AACrJ,sCAA4C;AAC5C,wCAAwC;AAoBxC;;;;;;;GAOG;AACH;IAQE,mCAAoB,WAAgC,EAAE,OAA+B;QACnF,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;QAE1C,+CAA+C;QAC/C,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;IAClC,CAAC;IAGD,sBAAI,6CAAM;QADV,sDAAsD;aACtD;YACE,OAAO,IAAA,uBAAe,EAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACxC,CAAC;;;OAAA;IAED,uGAAuG;IAC1F,+BAAK,GAAlB,UAAmB,EAIlB;YAJoB,YAAY,kBAAA,EAAE,KAAK,WAAA,EAAE,OAAO,aAAA;;;;gBAKzC,WAAW,GAAG,IAAI,2BAAmB,CAAC,EAAE,KAAK,OAAA,EAAE,CAAC,CAAC;gBACvD,sBAAO,IAAI,yBAAyB,CAAC,WAAW,EAAE,EAAE,YAAY,cAAA,EAAE,OAAO,SAAA,EAAE,CAAC,EAAC;;;KAC9E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,CAAC,aAAa;gCAChC,MAAM,EAAQ,IAAI,CAAC,aAAa;gCAChC,WAAW,EAAG,oBAAY,CAAC,YAAY;gCACvC,WAAW,EAAG,gBAAgB;gCAC9B,UAAU,YAAA;gCACV,UAAU,YAAA;6BACX,CAAC,EAAA;;wBAPI,KAAqB,SAOzB,EAPM,KAAK,WAAA,EAAE,OAAO,aAAA;wBAStB,IAAI,CAAC,QAAQ,yBAAQ,OAAO,KAAE,WAAW,EAAE,WAAW,GAAE,CAAC;wBACzD,sBAAO,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,EAAC;;;;KACjC;IACH,gCAAC;AAAD,CAAC,AA7FD,IA6FC;AA7FY,8DAAyB"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Making developing with Web5 components at least 5 times easier to work with.
|
|
4
|
+
*
|
|
5
|
+
* Web5 consists of the following components:
|
|
6
|
+
* - Decentralized Identifiers
|
|
7
|
+
* - Verifiable Credentials
|
|
8
|
+
* - DWeb Node personal datastores
|
|
9
|
+
*
|
|
10
|
+
* The SDK sets out to gather the most oft used functionality from all three of
|
|
11
|
+
* these pillar technologies to provide a simple library that is as close to
|
|
12
|
+
* effortless as possible.
|
|
13
|
+
*
|
|
14
|
+
* The SDK is currently still under active development, but having entered the
|
|
15
|
+
* Tech Preview phase there is now a drive to avoid unnecessary changes unless
|
|
16
|
+
* backwards compatibility is provided. Additional functionality will be added
|
|
17
|
+
* in the lead up to 1.0 final, and modifications will be made to address
|
|
18
|
+
* issues and community feedback.
|
|
19
|
+
*
|
|
20
|
+
* [Link to GitHub Repo](https://github.com/TBD54566975/web5-js)
|
|
21
|
+
*
|
|
22
|
+
* @packageDocumentation
|
|
23
|
+
*/
|
|
24
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
25
|
+
if (k2 === undefined) k2 = k;
|
|
26
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
27
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
28
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
29
|
+
}
|
|
30
|
+
Object.defineProperty(o, k2, desc);
|
|
31
|
+
}) : (function(o, m, k, k2) {
|
|
32
|
+
if (k2 === undefined) k2 = k;
|
|
33
|
+
o[k2] = m[k];
|
|
34
|
+
}));
|
|
35
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
36
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
37
|
+
}) : function(o, v) {
|
|
38
|
+
o["default"] = v;
|
|
39
|
+
});
|
|
40
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
41
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
42
|
+
};
|
|
43
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
44
|
+
if (mod && mod.__esModule) return mod;
|
|
45
|
+
var result = {};
|
|
46
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
47
|
+
__setModuleDefault(result, mod);
|
|
48
|
+
return result;
|
|
49
|
+
};
|
|
50
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
+
exports.utils = void 0;
|
|
52
|
+
__exportStar(require("./did-api.js"), exports);
|
|
53
|
+
__exportStar(require("./dwn-api.js"), exports);
|
|
54
|
+
__exportStar(require("./grant-revocation.js"), exports);
|
|
55
|
+
__exportStar(require("./permission-grant.js"), exports);
|
|
56
|
+
__exportStar(require("./permission-request.js"), exports);
|
|
57
|
+
__exportStar(require("./protocol.js"), exports);
|
|
58
|
+
__exportStar(require("./record.js"), exports);
|
|
59
|
+
__exportStar(require("./vc-api.js"), exports);
|
|
60
|
+
__exportStar(require("./web5.js"), exports);
|
|
61
|
+
var utils = __importStar(require("./utils.js"));
|
|
62
|
+
exports.utils = utils;
|
|
63
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,+CAA6B;AAC7B,+CAA6B;AAC7B,wDAAsC;AACtC,wDAAsC;AACtC,0DAAwC;AACxC,gDAA8B;AAC9B,8CAA4B;AAC5B,8CAA4B;AAC5B,4CAA0B;AAE1B,gDAAoC;AAC3B,sBAAK"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type": "commonjs"}
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
50
|
+
var t = {};
|
|
51
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
52
|
+
t[p] = s[p];
|
|
53
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
54
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
55
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
56
|
+
t[p[i]] = s[p[i]];
|
|
57
|
+
}
|
|
58
|
+
return t;
|
|
59
|
+
};
|
|
60
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
61
|
+
exports.PermissionGrant = void 0;
|
|
62
|
+
var common_1 = require("@enbox/common");
|
|
63
|
+
var agent_1 = require("@enbox/agent");
|
|
64
|
+
var grant_revocation_js_1 = require("./grant-revocation.js");
|
|
65
|
+
/**
|
|
66
|
+
* The `PermissionGrant` class encapsulates a permissions protocol `grant` record, providing a more
|
|
67
|
+
* developer-friendly interface for working with Decentralized Web Node (DWN) records.
|
|
68
|
+
*
|
|
69
|
+
* Methods are provided to revoke, check if isRevoked, and manage the grant's lifecycle, including writing to remote DWNs.
|
|
70
|
+
*
|
|
71
|
+
* @beta
|
|
72
|
+
*/
|
|
73
|
+
var PermissionGrant = /** @class */ (function () {
|
|
74
|
+
function PermissionGrant(_a) {
|
|
75
|
+
var api = _a.api, connectedDid = _a.connectedDid, message = _a.message, grant = _a.grant;
|
|
76
|
+
this._permissions = api;
|
|
77
|
+
// Store the connected DID for convenience.
|
|
78
|
+
this._connectedDid = connectedDid;
|
|
79
|
+
// Store the message that represents the grant.
|
|
80
|
+
this._message = message;
|
|
81
|
+
// Store the parsed grant object.
|
|
82
|
+
this._grant = grant;
|
|
83
|
+
}
|
|
84
|
+
/** parses the grant given an agent, connectedDid and data encoded records write message */
|
|
85
|
+
PermissionGrant.parse = function (options) {
|
|
86
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
87
|
+
var grant, api;
|
|
88
|
+
return __generator(this, function (_a) {
|
|
89
|
+
switch (_a.label) {
|
|
90
|
+
case 0: return [4 /*yield*/, agent_1.DwnPermissionGrant.parse(options.message)];
|
|
91
|
+
case 1:
|
|
92
|
+
grant = _a.sent();
|
|
93
|
+
api = new agent_1.AgentPermissionsApi({ agent: options.agent });
|
|
94
|
+
return [2 /*return*/, new PermissionGrant(__assign(__assign({}, options), { grant: grant, api: api }))];
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
Object.defineProperty(PermissionGrant.prototype, "agent", {
|
|
100
|
+
/** The agent to use for this instantiation of the grant */
|
|
101
|
+
get: function () {
|
|
102
|
+
return this._permissions.agent;
|
|
103
|
+
},
|
|
104
|
+
enumerable: false,
|
|
105
|
+
configurable: true
|
|
106
|
+
});
|
|
107
|
+
Object.defineProperty(PermissionGrant.prototype, "id", {
|
|
108
|
+
/** The grant's ID, which is also the underlying record's ID */
|
|
109
|
+
get: function () {
|
|
110
|
+
return this._grant.id;
|
|
111
|
+
},
|
|
112
|
+
enumerable: false,
|
|
113
|
+
configurable: true
|
|
114
|
+
});
|
|
115
|
+
Object.defineProperty(PermissionGrant.prototype, "grantor", {
|
|
116
|
+
/** The DID which granted the permission */
|
|
117
|
+
get: function () {
|
|
118
|
+
return this._grant.grantor;
|
|
119
|
+
},
|
|
120
|
+
enumerable: false,
|
|
121
|
+
configurable: true
|
|
122
|
+
});
|
|
123
|
+
Object.defineProperty(PermissionGrant.prototype, "grantee", {
|
|
124
|
+
/** The DID which the permission was granted to */
|
|
125
|
+
get: function () {
|
|
126
|
+
return this._grant.grantee;
|
|
127
|
+
},
|
|
128
|
+
enumerable: false,
|
|
129
|
+
configurable: true
|
|
130
|
+
});
|
|
131
|
+
Object.defineProperty(PermissionGrant.prototype, "dateGranted", {
|
|
132
|
+
/** The date the permission was granted */
|
|
133
|
+
get: function () {
|
|
134
|
+
return this._grant.dateGranted;
|
|
135
|
+
},
|
|
136
|
+
enumerable: false,
|
|
137
|
+
configurable: true
|
|
138
|
+
});
|
|
139
|
+
Object.defineProperty(PermissionGrant.prototype, "description", {
|
|
140
|
+
/** (optional) Description of the permission grant */
|
|
141
|
+
get: function () {
|
|
142
|
+
return this._grant.description;
|
|
143
|
+
},
|
|
144
|
+
enumerable: false,
|
|
145
|
+
configurable: true
|
|
146
|
+
});
|
|
147
|
+
Object.defineProperty(PermissionGrant.prototype, "requestId", {
|
|
148
|
+
/** (optional) The Id of the PermissionRequest if one was used */
|
|
149
|
+
get: function () {
|
|
150
|
+
return this._grant.requestId;
|
|
151
|
+
},
|
|
152
|
+
enumerable: false,
|
|
153
|
+
configurable: true
|
|
154
|
+
});
|
|
155
|
+
Object.defineProperty(PermissionGrant.prototype, "dateExpires", {
|
|
156
|
+
/** The date on which the permission expires */
|
|
157
|
+
get: function () {
|
|
158
|
+
return this._grant.dateExpires;
|
|
159
|
+
},
|
|
160
|
+
enumerable: false,
|
|
161
|
+
configurable: true
|
|
162
|
+
});
|
|
163
|
+
Object.defineProperty(PermissionGrant.prototype, "delegated", {
|
|
164
|
+
/** Whether or not the permission grant can be used to impersonate the grantor */
|
|
165
|
+
get: function () {
|
|
166
|
+
return this._grant.delegated;
|
|
167
|
+
},
|
|
168
|
+
enumerable: false,
|
|
169
|
+
configurable: true
|
|
170
|
+
});
|
|
171
|
+
Object.defineProperty(PermissionGrant.prototype, "scope", {
|
|
172
|
+
/** The permission scope under which the grant is valid */
|
|
173
|
+
get: function () {
|
|
174
|
+
return this._grant.scope;
|
|
175
|
+
},
|
|
176
|
+
enumerable: false,
|
|
177
|
+
configurable: true
|
|
178
|
+
});
|
|
179
|
+
Object.defineProperty(PermissionGrant.prototype, "conditions", {
|
|
180
|
+
/** The conditions under which the grant is valid */
|
|
181
|
+
get: function () {
|
|
182
|
+
return this._grant.conditions;
|
|
183
|
+
},
|
|
184
|
+
enumerable: false,
|
|
185
|
+
configurable: true
|
|
186
|
+
});
|
|
187
|
+
Object.defineProperty(PermissionGrant.prototype, "rawMessage", {
|
|
188
|
+
/** The raw `RecordsWrite` DWN message with encoded data that was used to instantiate this grant */
|
|
189
|
+
get: function () {
|
|
190
|
+
return this._message;
|
|
191
|
+
},
|
|
192
|
+
enumerable: false,
|
|
193
|
+
configurable: true
|
|
194
|
+
});
|
|
195
|
+
/**
|
|
196
|
+
* Send the current grant to a remote DWN by specifying their DID
|
|
197
|
+
* If no DID is specified, the target is assumed to be the owner (connectedDID).
|
|
198
|
+
*
|
|
199
|
+
* @param target - the optional DID to send the grant to, if none is set it is sent to the connectedDid
|
|
200
|
+
* @returns the status of the send grant request
|
|
201
|
+
*
|
|
202
|
+
* @beta
|
|
203
|
+
*/
|
|
204
|
+
PermissionGrant.prototype.send = function (target) {
|
|
205
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
206
|
+
var _a, encodedData, rawMessage, dataStream, sendRequestOptions, reply;
|
|
207
|
+
return __generator(this, function (_b) {
|
|
208
|
+
switch (_b.label) {
|
|
209
|
+
case 0:
|
|
210
|
+
target !== null && target !== void 0 ? target : (target = this._connectedDid);
|
|
211
|
+
_a = this._message, encodedData = _a.encodedData, rawMessage = __rest(_a, ["encodedData"]);
|
|
212
|
+
dataStream = new Blob([common_1.Convert.base64Url(encodedData).toUint8Array()]);
|
|
213
|
+
sendRequestOptions = {
|
|
214
|
+
messageType: agent_1.DwnInterface.RecordsWrite,
|
|
215
|
+
author: this._connectedDid,
|
|
216
|
+
target: target,
|
|
217
|
+
dataStream: dataStream,
|
|
218
|
+
rawMessage: rawMessage,
|
|
219
|
+
};
|
|
220
|
+
return [4 /*yield*/, this.agent.sendDwnRequest(sendRequestOptions)];
|
|
221
|
+
case 1:
|
|
222
|
+
reply = (_b.sent()).reply;
|
|
223
|
+
return [2 /*return*/, reply];
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
};
|
|
228
|
+
/**
|
|
229
|
+
* Stores the current grant to the owner's DWN.
|
|
230
|
+
*
|
|
231
|
+
* @param importGrant - if true, the grant will signed by the owner before storing it to the owner's DWN. Defaults to false.
|
|
232
|
+
* @returns the status of the store request
|
|
233
|
+
*
|
|
234
|
+
* @beta
|
|
235
|
+
*/
|
|
236
|
+
PermissionGrant.prototype.store = function (importGrant) {
|
|
237
|
+
if (importGrant === void 0) { importGrant = false; }
|
|
238
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
239
|
+
var _a, encodedData, rawMessage, dataStream, _b, reply, message;
|
|
240
|
+
return __generator(this, function (_c) {
|
|
241
|
+
switch (_c.label) {
|
|
242
|
+
case 0:
|
|
243
|
+
_a = this.rawMessage, encodedData = _a.encodedData, rawMessage = __rest(_a, ["encodedData"]);
|
|
244
|
+
dataStream = new Blob([common_1.Convert.base64Url(encodedData).toUint8Array()]);
|
|
245
|
+
return [4 /*yield*/, this.agent.processDwnRequest({
|
|
246
|
+
store: true,
|
|
247
|
+
author: this._connectedDid,
|
|
248
|
+
target: this._connectedDid,
|
|
249
|
+
messageType: agent_1.DwnInterface.RecordsWrite,
|
|
250
|
+
signAsOwner: importGrant,
|
|
251
|
+
rawMessage: rawMessage,
|
|
252
|
+
dataStream: dataStream,
|
|
253
|
+
})];
|
|
254
|
+
case 1:
|
|
255
|
+
_b = _c.sent(), reply = _b.reply, message = _b.message;
|
|
256
|
+
this._message = __assign(__assign({}, message), { encodedData: encodedData });
|
|
257
|
+
return [2 /*return*/, { status: reply.status }];
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
};
|
|
262
|
+
/**
|
|
263
|
+
* Signs the current grant as the owner and optionally stores it to the owner's DWN.
|
|
264
|
+
* This is useful when importing a grant that was signed by someone else into your own DWN.
|
|
265
|
+
*
|
|
266
|
+
* @param store - if true, the grant will be stored to the owner's DWN after signing. Defaults to true.
|
|
267
|
+
* @returns the status of the import request
|
|
268
|
+
*
|
|
269
|
+
* @beta
|
|
270
|
+
*/
|
|
271
|
+
PermissionGrant.prototype.import = function (store) {
|
|
272
|
+
if (store === void 0) { store = false; }
|
|
273
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
274
|
+
var _a, encodedData, rawMessage, dataStream, _b, reply, message;
|
|
275
|
+
return __generator(this, function (_c) {
|
|
276
|
+
switch (_c.label) {
|
|
277
|
+
case 0:
|
|
278
|
+
_a = this.rawMessage, encodedData = _a.encodedData, rawMessage = __rest(_a, ["encodedData"]);
|
|
279
|
+
dataStream = new Blob([common_1.Convert.base64Url(encodedData).toUint8Array()]);
|
|
280
|
+
return [4 /*yield*/, this.agent.processDwnRequest({
|
|
281
|
+
store: store,
|
|
282
|
+
author: this._connectedDid,
|
|
283
|
+
target: this._connectedDid,
|
|
284
|
+
messageType: agent_1.DwnInterface.RecordsWrite,
|
|
285
|
+
signAsOwner: true,
|
|
286
|
+
rawMessage: rawMessage,
|
|
287
|
+
dataStream: dataStream,
|
|
288
|
+
})];
|
|
289
|
+
case 1:
|
|
290
|
+
_b = _c.sent(), reply = _b.reply, message = _b.message;
|
|
291
|
+
this._message = __assign(__assign({}, message), { encodedData: encodedData });
|
|
292
|
+
return [2 /*return*/, { status: reply.status }];
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
};
|
|
297
|
+
/**
|
|
298
|
+
* Revokes the grant and optionally stores the revocation to the owner's DWN.
|
|
299
|
+
*
|
|
300
|
+
* @param store - if true, the revocation will be stored to the owner's DWN. Defaults to true.
|
|
301
|
+
* @returns {PermissionGrantRevocation} the grant revocation object
|
|
302
|
+
*
|
|
303
|
+
* @beta
|
|
304
|
+
*/
|
|
305
|
+
PermissionGrant.prototype.revoke = function (store) {
|
|
306
|
+
if (store === void 0) { store = true; }
|
|
307
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
308
|
+
var revocation;
|
|
309
|
+
return __generator(this, function (_a) {
|
|
310
|
+
switch (_a.label) {
|
|
311
|
+
case 0: return [4 /*yield*/, this._permissions.createRevocation({
|
|
312
|
+
store: store,
|
|
313
|
+
author: this._connectedDid,
|
|
314
|
+
grant: this._grant,
|
|
315
|
+
})];
|
|
316
|
+
case 1:
|
|
317
|
+
revocation = _a.sent();
|
|
318
|
+
return [2 /*return*/, grant_revocation_js_1.PermissionGrantRevocation.parse({
|
|
319
|
+
connectedDid: this._connectedDid,
|
|
320
|
+
agent: this.agent,
|
|
321
|
+
message: revocation.message,
|
|
322
|
+
})];
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
});
|
|
326
|
+
};
|
|
327
|
+
/**
|
|
328
|
+
* Checks if the grant has been revoked.
|
|
329
|
+
*
|
|
330
|
+
* @param remote - if true, the check will be made against the remote DWN. Defaults to false.
|
|
331
|
+
* @returns true if the grant has been revoked, false otherwise.
|
|
332
|
+
* @throws if there is an error checking the revocation status.
|
|
333
|
+
*
|
|
334
|
+
* @beta
|
|
335
|
+
*/
|
|
336
|
+
PermissionGrant.prototype.isRevoked = function (remote) {
|
|
337
|
+
if (remote === void 0) { remote = false; }
|
|
338
|
+
return this._permissions.isGrantRevoked({
|
|
339
|
+
author: this._connectedDid,
|
|
340
|
+
target: this.grantor,
|
|
341
|
+
grantRecordId: this.id,
|
|
342
|
+
remote: remote
|
|
343
|
+
});
|
|
344
|
+
};
|
|
345
|
+
/**
|
|
346
|
+
* @returns the JSON representation of the grant
|
|
347
|
+
*/
|
|
348
|
+
PermissionGrant.prototype.toJSON = function () {
|
|
349
|
+
return {
|
|
350
|
+
id: this.id,
|
|
351
|
+
grantor: this.grantor,
|
|
352
|
+
grantee: this.grantee,
|
|
353
|
+
dateGranted: this.dateGranted,
|
|
354
|
+
description: this.description,
|
|
355
|
+
requestId: this.requestId,
|
|
356
|
+
dateExpires: this.dateExpires,
|
|
357
|
+
delegated: this.delegated,
|
|
358
|
+
scope: this.scope,
|
|
359
|
+
conditions: this.conditions
|
|
360
|
+
};
|
|
361
|
+
};
|
|
362
|
+
return PermissionGrant;
|
|
363
|
+
}());
|
|
364
|
+
exports.PermissionGrant = PermissionGrant;
|
|
365
|
+
//# sourceMappingURL=permission-grant.js.map
|