Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 121x 30x 91x 91x 42x 31x 25x 38x 147x 145x 145x 145x 145x 69x 96x 90x 88x 88x 22x 20x 16x 15x 14x 14x 11x 8x 8x 11x 3x 11x 1x 10x 1x 1x 1x 9x 9x 9x 9x 47x 45x 17x 12x 15x 10x 15x 10x 109x 103x 73x 97x 91x 91x 158x 156x 155x 1485x 154x 153x 153x 3x 22x 18x 15x 14x 12x 12x 148x 12x 11x 9x 9x 9x 8x 8x 8x 8x 8x 8x 9x 3x 3x 8x 2x 6x 4x 4x 2x 2x 2x 2x 7x 4x 3x 2x 13x 11x 10x 1x 38x 37x 1x 4x 4x 1x 31x 30x 18x 14x 13x 7x 5x 4x 2x 54x 1x 1x 1x 6x 6x 6x 6x 6x 3x 3x 1x 1x 2x 2x 162x 162x 162x 18x 16x 14x 14x 14x 14x 14x 14x 14x 12x 12x 12x 12x 12x 9x 14x 5x 14x 14x 12x 11x 2x 11x 11x 11x 11x 11x 11x 11x 14x 14x 14x 19x 11x 11x 8x 14x 10x 4x 4x 4x 1x 1x 1x 5x 5x 5x 5x 4x 4x 4x 4x 4x 6x 6x 5x 3x 2x 2x 2x 1x 2x 47x 20x | "use strict";
/*
* Datona Blockchain Library
*
* datona-lib blockchain features
*
* Copyright (C) 2020 Datona Labs
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
const CONFIG = require('../config.json');
const crypto = require('./datona-crypto');
const errors = require('./errors');
const assert = require('./assertions');
const Web3 = (typeof window === 'undefined') ? require('web3') : window.Web3;
const Transaction = require('ethereumjs-tx').Transaction;
const sdacInterface = require("../contracts/SDAC.json");
/*
* Constants
*/
const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
const NO_PERMISSIONS = 0x00;
const ALL_PERMISSIONS = 0x07;
const READ_BIT = 0x04;
const WRITE_BIT = 0x02;
const APPEND_BIT = 0x01;
const DIRECTORY_BIT = 0x80;
const ROOT_DIRECTORY = "0x0000000000000000000000000000000000000000";
/*
* Classes
*/
class Permissions {
constructor (permissionsByte) {
if (toString.call(permissionsByte) === '[object Number]') {
this.permissions = permissionsByte;
}
else {
assert.matches(permissionsByte, '^0x[0-9A-Fa-f]{2}$', "invalid string representation of permissions byte",permissionsByte);
this.permissions = parseInt(permissionsByte);
}
}
canRead() { return (this.permissions & READ_BIT) > 0 }
canWrite() { return (this.permissions & WRITE_BIT) > 0 }
canAppend() { return (this.permissions & APPEND_BIT) > 0 }
isDirectory() { return (this.permissions & DIRECTORY_BIT) > 0 }
}
/*
* Represents a Smart Data Access Contract on the blockchain
*/
class Contract {
/*
* If the address is not given this represents a new contract to be deployed.
*/
constructor(abi, address) {
assert.isArray(abi, "Contract abi");
getProvider(); // constructs web3 if not yet constructed
this.web3Contract = new web3.eth.Contract(abi);
this.abi = abi;
if (address !== undefined) this.setAddress(address);
else this.address = undefined;
}
/*
* Sets the address of this contract on the blockchain. Can be used as an
* alternative to passing it in the constructor.
* @throws {BlockchainError} if the address is already set
*/
setAddress(address) {
assert.isAddress(address, "address");
if (this.address !== undefined) throw new errors.BlockchainError("address already set");
this.web3Contract.options.address = address;
this.address = address;
}
/*
* Promises to deploy this contract on the blockchain
*/
deploy(key, bytecode, constructorArgs) {
assert.isInstanceOf(key, "Contract.deploy key", crypto.Key);
assert.isHexString(bytecode, "Contract.deploy bytecode");
Eif (constructorArgs !== undefined) assert.isArray(constructorArgs, "constructorArgs");
if (this.address !== undefined) throw new errors.BlockchainError("contract already deployed");
try {
// create deployment transaction data from bytecode
const txnData = this.web3Contract.deploy({
data: '0x' + bytecode,
arguments: constructorArgs
}).encodeABI();
// create skeleton transaction
const transaction = {
data: txnData,
gas: web3.utils.toHex(6000000)
}
// function to set the address of this Contract instance once the receipt is received
function storeAddress(receipt) {
this.setAddress(receipt.contractAddress);
return receipt.contractAddress;
}
return sendTransaction(key, transaction)
.then(storeAddress.bind(this));
}
catch (error) {
throw (error instanceof errors.DatonaError) ? error : new errors.BlockchainError(error.message);
}
}
/*
* Promises to get the owner of this contract from the blockchain
*/
getOwner() {
if (this.address === undefined) {
throw new errors.BlockchainError("Contract.getOwner: contract has not been deployed or mapped to an existing contract");
}
if (this.owner !== undefined) {
const thisContract = this;
return new Promise(
function(resolve, reject) {
resolve(thisContract.owner);
});
} else {
const thisContract = this;
return this.call("owner")
.then(function(owner) {
thisContract.owner = owner;
return owner;
})
.catch( function(error){
throw new errors.BlockchainError("Failed to retrieve contract owner from the blockchain: "+error.message);
});
}
}
/*
* Promises to return the expiry status (boolean) of this contract
*/
hasExpired() {
if (this.address === undefined) throw new errors.BlockchainError("Contract.hasExpired: contract has not been deployed or mapped to an existing contract");
return this.call("hasExpired");
}
/*
* Promises to return whether the given requester is permitted to read the given vault file (boolean)
*/
canRead(requester, fileId) {
return this.getPermissions(requester, fileId)
.then( function(permissions){
return permissions.canRead();
});
}
/*
* Promises to return whether the given requester is permitted to write to the given vault file (boolean)
*/
canWrite(requester, fileId) {
return this.getPermissions(requester, fileId)
.then( function(permissions){
return permissions.canWrite();
});
}
/*
* Promises to return whether the given requester is permitted to append to the given vault file (boolean)
*/
canAppend(requester, fileId) {
return this.getPermissions(requester, fileId)
.then( function(permissions){
return permissions.canAppend();
});
}
/*
* Promises to return a byte with the d----rwa permissions of the given file for the given user address.
*/
getPermissions(requester, fileId) {
assert.isAddress(requester, "Contract getPermissions requester");
if (fileId === undefined) fileId = ROOT_DIRECTORY;
else assert.isAddress(fileId, "Contract getPermissions fileId");
if (this.address === undefined) throw new errors.BlockchainError("Contract.getPermissions: contract has not been deployed or mapped to an existing contract");
return this.call("getPermissions", [requester, fileId])
.then( function(permissions){
return new Permissions(permissions);
});
}
/*
* Promises to call the given view or pure method with the given arguments.
* Use 'transact' to call a state-modifying method.
*/
call(method, args = []) {
assert.isString(method, "Contract.call method");
assert.isArray(args, "Contract.call args");
if (this.address === undefined) throw new errors.BlockchainError("Contract.call: contract has not been deployed or mapped to an existing contract");
var methodAbi = this.abi.find(obj => { return obj.name === method; });
if (!methodAbi) throw new errors.BlockchainError("Contract.call method '"+method+"' does not exist");
try{
return this.web3Contract.methods[method](...args).call()
.catch(function(error) {
throw new errors.BlockchainError("Failed to call method " + method, error.message);
});
}
catch (error) {
throw new errors.BlockchainError(error.message);
}
}
/*
* Promises to call the given state-modifying method with the given arguments.
* Use 'call' to call a view or pure method.
*/
transact(key, method, args = [], options) {
assert.isInstanceOf(key, "Contract.transact key", crypto.Key);
assert.isString(method, "Contract.transact method");
assert.isArray(args, "Contract.call args");
if (this.address === undefined) throw new errors.BlockchainError("Contract.call: contract has not been deployed or mapped to an existing contract");
Iif (this.web3Contract === undefined) throw new errors.BlockchainError("contract does not exist on the blockchain");
try{
var methodAbi = this.abi.find(obj => { return obj.name === method; });
if (!methodAbi) throw new errors.BlockchainError("Contract.transact method '"+method+"' does not exist");
// create transaction data
const txnData = this.web3Contract.methods[method](...args).encodeABI();
var gasPrice = 0;
// function to get the transaction nonce of the signatory
function getTransactionCount(_gasPrice) {
gasPrice = _gasPrice;
return web3.eth.getTransactionCount(key.address, "pending");
}
// function to construct and sign the transaction once the nonce has been calculated
function createTransaction(nonce) {
const rawTxn = {
nonce: nonce,
gasPrice: web3.utils.toHex(gasPrice),
gas: web3.utils.toHex(3000000),
data: txnData,
to: this.address,
chainID: 42
};
for (const field in options) rawTxn[field] = options[field];
const txn = new Transaction(rawTxn, {'chain':chain});
txn.sign(key.privateKey);
const serializedTxn = txn.serialize();
return "0x"+serializedTxn.toString('hex');
}
// get the nonce, construct and sign the transaction then publish it on the blockchain
return web3.eth.getGasPrice()
.then(getTransactionCount)
.then(createTransaction.bind(this))
.then(web3.eth.sendSignedTransaction)
.catch(
function(error) {
throw (error instanceof errors.DatonaError) ? error : new errors.BlockchainError(error.message);
}
);
}
catch (error) {
throw new errors.BlockchainError(error.message);
}
}
/*
* Promises to get the runtime bytecode of this contract from the blockchain
*/
getBytecode() {
if (this.address === undefined) {
throw new errors.BlockchainError("Contract.getBytecode: contract has not been deployed or mapped to an existing contract");
}
else if (this.bytecode !== undefined) {
const thisContract = this;
return new Promise( function(resolve, reject) { resolve(thisContract.bytecode); });
}
else {
const thisContract = this;
return web3.eth.getCode(this.address)
.then(function(bytecode) {
thisContract.bytecode = bytecode.slice(2);
return thisContract.bytecode;
})
.catch(function(error) {
throw new errors.BlockchainError("Could not retrieve contract bytecode", error.message);
});
}
}
/*
* Promises to terminate this contract
*/
terminate(key){
return this.transact(key, "terminate");
}
/*
* Promises to reject if the contract's bytecode does not equal the expected bytecode given.
*/
assertBytecode(expectedBytecode) {
return this.getBytecode()
.then(function(bytecode) {
if (bytecode !== expectedBytecode) {
throw new errors.ContractTypeError("bytecode does not match");
}
});
}
/*
* Promises to reject if the contract's owner address does not equal the expected address given.
*/
assertOwner(expectedOwner) {
assert.isAddress(expectedOwner, "Contract.assertOwner expectedOwner");
return this.getOwner()
.then(function(owner) {
if (owner.toLowerCase() !== expectedOwner.toLowerCase()) {
throw new errors.ContractOwnerError("owner does not match");
}
});
}
/*
* Promises to reject if the contract has expired.
*/
assertNotExpired() {
return this.hasExpired()
.then(function(expired) {
if (expired) {
throw new errors.ContractExpiryError("contract has expired");
}
});
}
/*
* Promises to reject if the contract has not expired.
*/
assertHasExpired() {
return this.hasExpired()
.then(function(expired) {
if (!expired) {
throw new errors.ContractExpiryError("contract has not expired");
}
});
}
/*
* Promises to reject if the given requester does not have permission to access the given vault file.
* Also returns the permissions
*/
assertCanRead(requester, fileId) {
return this.getPermissions(requester, fileId)
.then( function(permissions){
_assertPermitted(permissions.canRead());
return permissions;
});
}
/*
* Promises to reject if the given requester does not have permission to write to the given vault file.
* Also returns the permissions
*/
assertCanWrite(requester, fileId) {
return this.getPermissions(requester, fileId)
.then( function(permissions){
_assertPermitted(permissions.canWrite());
return permissions;
});
}
/*
* Promises to reject if the given requester does not have permission to append to the given vault file.
* Also returns the permissions
*/
assertCanAppend(requester, fileId) {
return this.getPermissions(requester, fileId)
.then( function(permissions){
_assertPermitted(permissions.canAppend());
return permissions;
});
}
}
/*
* Instance of Contract, providing an interface to any SDAC already deployed on
* the blockchain. Maps to a contract at the given address using the standard
* SDAC interface abi
*/
class GenericSmartDataAccessContract extends Contract {
constructor(address) {
super(sdacInterface.abi,address);
}
}
/*
* Variables
*/
var web3;
var subscriptions = [];
var web3Subscribed = false;
var chain = CONFIG.blockchain || "kovan";
/*
* External Functions
*/
/*
* Overrides the default connection to the blockchain (that configured in config.json).
*/
function setProvider(url, blockchain) {
close();
try {
chain = blockchain || chain;
const urlStr = url.scheme+"://" + url.host+ (url.port === undefined || url.port === "" ? "" : ":"+url.port);
switch (url.scheme) {
case "ws":
case "wss":
web3 = new Web3(new Web3.providers.WebsocketProvider(urlStr));
break;
case "http":
case "https":
web3 = new Web3(new Web3.providers.HttpProvider(urlStr));
break;
default:
throw new errors.BlockchainError("Invalid url scheme for the blockchain provider. Valid schemes are ws, wss, http and https");
}
}
catch (error) {
throw new errors.BlockchainError("setProvider url is invalid: "+error.message);
}
}
/*
* Returns the web3 instance and the blockchain name
*/
function getProvider() {
try {
if (web3 === undefined) setProvider(CONFIG.blockchainURL);
}
catch (error) {
throw new errors.BlockchainError("Could not construct web3 provider: "+error.message);
}
return { web3: web3, chain: chain };
}
/*
* Promises to publish a transaction on the blockchain
*/
function sendTransaction(key, transaction) {
assert.isInstanceOf(key, "sendTransaction key", crypto.Key);
assert.isObject(transaction, "sendTransaction transaction");
getProvider();
try {
Eif (transaction.from === undefined ) transaction.from = key.address;
if (transaction.gas === undefined ) transaction.gas = web3.utils.toHex(6000000);
Eif (transaction.chainId === undefined ) transaction.chainId = 42;
// function to get the transaction nonce of the signatory
function getTransactionCount(gasPrice) {
Eif (transaction.gasPrice === undefined ) transaction.gasPrice = web3.utils.toHex(gasPrice);
return web3.eth.getTransactionCount(key.address, "pending");
}
// function to construct and sign the transaction once the nonce has been calculated
function createTransaction(nonce) {
Eif (transaction.nonce === undefined ) transaction.nonce = nonce;
const txn = new Transaction(transaction, {'chain': chain});
txn.sign(key.privateKey);
const serializedTxn = txn.serialize();
return "0x"+serializedTxn.toString('hex');
}
// function to reject the promise if the transaction was not successful
function checkReceiptStatus(receipt) {
Eif (receipt.status === true) return receipt;
else throw new errors.BlockchainError("Blockchain VM reverted the transaction", receipt);
}
// get the nonce, construct and sign the transaction then publish it on the blockchain
return getGasPrice()
.then(getTransactionCount)
.then(createTransaction)
.then(web3.eth.sendSignedTransaction)
.then(checkReceiptStatus)
.catch( error => {
throw (error instanceof errors.DatonaError) ? error : new errors.BlockchainError(error.message);
});
}
catch (error) {
throw (error instanceof errors.DatonaError) ? error : new errors.BlockchainError(error.message);
}
}
function getGasPrice() {
return web3.eth.getGasPrice();
}
/*
* Subscribes the client to receive notification of a new contract deployed to the
* blockchain with the given code hash. Optionally, the client can receive notification
* only if the given address is permitted to access the data controlled by the contract.
*/
function subscribe(bytecodeHash, callback, permittedAddress, fileId) {
assert.isHash(bytecodeHash, "subscribe bytecodeHash");
assert.isFunction(callback, "subscribe callback");
if (permittedAddress !== undefined) {
assert.isAddress(permittedAddress, "subscribe permittedAddress");
}
Iif (fileId !== undefined){
assert.isAddress(fileId, "subscribe fileId");
}
// subscribe to web3 if this is the first client subscription
if (!web3Subscribed) monitorForPendingTransactions();
// push the new bytecodeHash to the subscriptions
const subscription = {
bytecodeHash: bytecodeHash,
callback: callback,
permittedAddress: permittedAddress,
fileId: fileId
};
const subscriptionHash = crypto.hash(JSON.stringify(subscription));
subscription.hash = subscriptionHash;
subscriptions.push(subscription);
return subscriptionHash;
}
/*
* Unsubscribes a previously subscribed client. The client is identified by
* the hash returned from the original call to 'subscribe'
*/
function unsubscribe(subscriptionId) {
var numUnsubscribed = 0;
var i = 0;
while (i < subscriptions.length) {
if (subscriptions[i].hash === subscriptionId) {
subscriptions.splice(i,1);
numUnsubscribed++;
}
else i++;
}
return numUnsubscribed;
}
/*
* Closes any connections to the blockchain. Should be called on program exit
* if any blockchain functions have been used.
*/
function close(){
if (web3 !== undefined){
try{
if (web3.currentProvider.connection !== undefined) web3.currentProvider.connection.close();
web3 = undefined;
}
catch(error){
throw new errors.BlockchainError("Failed to close blockchain connection: "+error.message);
}
}
}
/*
* Exports
*/
module.exports = {
ZERO_ADDRESS: ZERO_ADDRESS,
NO_PERMISSIONS: NO_PERMISSIONS,
ALL_PERMISSIONS: ALL_PERMISSIONS,
READ_BIT: READ_BIT,
WRITE_BIT: WRITE_BIT,
APPEND_BIT: APPEND_BIT,
DIRECTORY_BIT: DIRECTORY_BIT,
ROOT_DIRECTORY: ROOT_DIRECTORY,
setProvider: setProvider,
getProvider: getProvider,
sendTransaction: sendTransaction,
Contract: Contract,
Permissions: Permissions,
GenericSmartDataAccessContract: GenericSmartDataAccessContract,
getGasPrice: getGasPrice,
subscribe: subscribe,
unsubscribe: unsubscribe,
close: close
};
/*
* Internal Functions
*/
/*
* Creates a web3 websocket interface to the blockchain node and subscribes to
* receive all new pending transactions
*/
function monitorForPendingTransactions() {
getProvider();
web3.eth
.subscribe('pendingTransactions', (error, result) => {
Iif (error) throw new errors.BlockchainError("Failed to subscribe to web3: "+error.message);
else web3Subscribed = true;
})
.on('data', monitorForNewContracts);
}
/*
* Web3 callback. Checks if the given transaction is a new contract and if so
* calls checkAndInformSubscriber to determine if it is a contract type that the
* client has subscribed to and has permission to access.
*/
function monitorForNewContracts(txHash) {
// Get the transaction details
// if the transaction's 'to' field is null then this is a contract creation
// so get the code hash and check if it is subscribed to
web3.eth.getTransaction(txHash)
.then( function(txn){
if (txn.to == null){
var transactionReceipt;
return web3.eth.getTransactionReceipt(txHash)
.then( function(txnReceipt){
transactionReceipt = txnReceipt;
return web3.eth.getCode(transactionReceipt.contractAddress);
})
.then( function(bytecode) {
checkAndInformSubscriber(crypto.hash(bytecode.slice(2)), transactionReceipt.contractAddress);
});
}
});
}
/*
* Checks the given code hash against all subscriptions and informs the client if found.
* If the subscription doesn't have a permittedAddress then the client is informed of the
* new contract. Otherwise the client is only informed if it is permitted to access the
* contract.
*/
function checkAndInformSubscriber(bytecodeHash, contractAddress) {
for ( var i = 0; i < subscriptions.length; i++) {
const subscription = subscriptions[i];
if (bytecodeHash === subscription.bytecodeHash) {
if (subscription.permittedAddress === undefined) {
subscription.callback(contractAddress, subscription.bytecodeHash);
} else {
const contract = new Contract(sdacInterface.abi, contractAddress);
contract.canRead(subscription.permittedAddress, subscription.fileId)
.then(function(result, error) {
if (result === true) {
subscription.callback(contractAddress, subscription.bytecodeHash);
}
Iif (error) {
console.log(error);
}
});
}
}
}
}
/*
* Local callback function to throw a PermissionError if permitted parameter is not true
*/
function _assertPermitted(permitted) {
if (!permitted) {
throw new errors.PermissionError("permission denied");
}
}
|