Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ethr-did-resolver

Package Overview
Dependencies
Maintainers
7
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ethr-did-resolver - npm Package Compare versions

Comparing version 3.1.0 to 4.0.0

src/__tests__/errors.test.ts

14

CHANGELOG.md

@@ -0,1 +1,15 @@

# [4.0.0](https://github.com/decentralized-identity/ethr-did-resolver/compare/3.1.0...4.0.0) (2021-03-15)
### Features
* upgrade to latest did core spec ([#99](https://github.com/decentralized-identity/ethr-did-resolver/issues/99)) ([#109](https://github.com/decentralized-identity/ethr-did-resolver/issues/109)) ([#111](https://github.com/decentralized-identity/ethr-did-resolver/issues/111)) ([2a023b1](https://github.com/decentralized-identity/ethr-did-resolver/commit/2a023b15a3a6cba1da05f8439dacb26e898104f1)), closes [#105](https://github.com/decentralized-identity/ethr-did-resolver/issues/105) [#95](https://github.com/decentralized-identity/ethr-did-resolver/issues/95) [#106](https://github.com/decentralized-identity/ethr-did-resolver/issues/106) [#83](https://github.com/decentralized-identity/ethr-did-resolver/issues/83) [#85](https://github.com/decentralized-identity/ethr-did-resolver/issues/85) [#83](https://github.com/decentralized-identity/ethr-did-resolver/issues/83) [#85](https://github.com/decentralized-identity/ethr-did-resolver/issues/85) [#95](https://github.com/decentralized-identity/ethr-did-resolver/issues/95) [#105](https://github.com/decentralized-identity/ethr-did-resolver/issues/105) [#106](https://github.com/decentralized-identity/ethr-did-resolver/issues/106)
### BREAKING CHANGES
* The return type is `DIDResolutionResult` which wraps a `DIDDocument`.
* No errors are thrown during DID resolution. Please check `result.didResolutionMetadata.error` instead.
* This DID core spec requirement will break for users expecting `publicKey`, `ethereumAddress`, `Secp256k1VerificationKey2018` entries in the DID document. They are replaced with `verificationMethod`, `blockchainAccountId` and `EcdsaSecp256k1VerificationKey2019` and `EcdsaSecp256k1RecoveryMethod2020` depending on the content.
# [3.1.0](https://github.com/decentralized-identity/ethr-did-resolver/compare/3.0.3...3.1.0) (2021-03-15)

@@ -2,0 +16,0 @@

@@ -59,2 +59,19 @@ import { BigNumber } from '@ethersproject/bignumber';

};
export declare const knownInfuraNetworks: Record<string, string>;
export declare const knownNetworks: Record<string, string>;
export declare enum Errors {
/**
* The resolver has failed to construct the DID document.
* This can be caused by a network issue, a wrong registry address or malformed logs while parsing the registry history.
* Please inspect the `DIDResolutionMetadata.message` to debug further.
*/
notFound = "notFound",
/**
* The resolver does not know how to resolve the given DID. Most likely it is not a `did:ethr`.
*/
invalidDid = "invalidDid",
/**
* The resolver is misconfigured or is being asked to resolve a DID anchored on an unknown network
*/
unknownNetwork = "unknownNetwork"
}

4

lib/index.d.ts
import { getResolver } from './resolver';
import { bytes32toString, DEFAULT_REGISTRY_ADDRESS, identifierMatcher, legacyAlgoMap, legacyAttrTypes, stringToBytes32, verificationMethodTypes } from './helpers';
import { bytes32toString, DEFAULT_REGISTRY_ADDRESS, identifierMatcher, legacyAlgoMap, legacyAttrTypes, stringToBytes32, verificationMethodTypes, Errors } from './helpers';
export { DEFAULT_REGISTRY_ADDRESS as REGISTRY, getResolver, bytes32toString, stringToBytes32,

@@ -7,2 +7,2 @@ /**@deprecated */

/**@deprecated */
legacyAttrTypes as attrTypes, verificationMethodTypes, identifierMatcher, };
legacyAttrTypes as attrTypes, verificationMethodTypes, identifierMatcher, Errors, };

@@ -1,2 +0,2 @@

var e=require("@ethersproject/basex"),t=require("@ethersproject/bignumber"),r=require("@ethersproject/contracts"),n=require("@ethersproject/providers"),o=require("ethr-did-registry"),i=require("@ethersproject/address"),c=require("@ethersproject/transactions");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=s(o);const u=/^(.*)?(0x[0-9a-fA-F]{40}|0x[0-9a-fA-F]{66})$/;var d,h;exports.verificationMethodTypes=void 0,(d=exports.verificationMethodTypes||(exports.verificationMethodTypes={})).EcdsaSecp256k1VerificationKey2019="EcdsaSecp256k1VerificationKey2019",d.EcdsaSecp256k1RecoveryMethod2020="EcdsaSecp256k1RecoveryMethod2020",d.Ed25519VerificationKey2018="Ed25519VerificationKey2018",d.RSAVerificationKey2018="RSAVerificationKey2018",d.X25519KeyAgreementKey2019="X25519KeyAgreementKey2019",function(e){e.DIDOwnerChanged="DIDOwnerChanged",e.DIDAttributeChanged="DIDAttributeChanged",e.DIDDelegateChanged="DIDDelegateChanged"}(h||(h={}));const f={sigAuth:"SignatureAuthentication2018",veriKey:"VerificationKey2018",enc:"KeyAgreementKey2019"},l={Secp256k1VerificationKey2018:exports.verificationMethodTypes.EcdsaSecp256k1VerificationKey2019,Ed25519SignatureAuthentication2018:exports.verificationMethodTypes.Ed25519VerificationKey2018,Secp256k1SignatureAuthentication2018:exports.verificationMethodTypes.EcdsaSecp256k1VerificationKey2019,RSAVerificationKey2018:exports.verificationMethodTypes.RSAVerificationKey2018,Ed25519VerificationKey2018:exports.verificationMethodTypes.Ed25519VerificationKey2018,X25519KeyAgreementKey2019:exports.verificationMethodTypes.X25519KeyAgreementKey2019};function v(e){return("string"==typeof e?Buffer.from(e.slice(2),"hex"):Buffer.from(e)).toString("utf8").replace(/\0+$/,"")}function m(e){const t="0x"+Buffer.from(e).slice(0,32).toString("hex");return t+"0".repeat(66-t.length)}function g(e){return e.length>42?{address:c.computeAddress(e),publicKey:e}:{address:i.getAddress(e)}}const p={mainnet:"0x1",ropsten:"0x3",rinkeby:"0x4",goerli:"0x5",kovan:"0x2a"};function y(e){var o;let i=e.provider||(null==(o=e.web3)?void 0:o.currentProvider);if(!i){if(!e.rpcUrl)throw new Error(`invalid_config: No web3 provider could be determined for network ${e.name||e.chainId}`);{var c;const r=e.chainId?t.BigNumber.from(e.chainId).toNumber():e.chainId,o=p[e.name||""]?null==(c=e.name)?void 0:c.replace("mainnet","homestead"):"any";i=new n.JsonRpcProvider(e.rpcUrl,r||o)}}return r.ContractFactory.fromSolidity(a.default).attach(e.registry||"0xdca7ef03e98e0dc2b855be647c39abe984fcf21b").connect(i)}function b(e){const t={},r=e.chainId||p[e.name||""];return r?(e.name&&(t[e.name]=y(e)),t["number"==typeof r?`0x${r.toString(16)}`:r]=y(e)):(e.provider||e.web3||e.rpcUrl)&&(t[e.name||""]=y(e)),t}function w(e){var t;return{...b(e),...null==(t=e.networks)?void 0:t.reduce((e,t)=>({...e,...b(t)}),{})}}class x{constructor(e,t,r){this.contract=t,this.signer=r;const{address:n}=g(e);this.address=n}getOwner(e,t){try{return Promise.resolve(this.contract.functions.identityOwner(e,{blockTag:t})).then(function(e){return e[0]})}catch(e){return Promise.reject(e)}}attachContract(e){try{const t=this;return Promise.resolve(e||t.getOwner(t.address,"latest")).then(function(e){const r=t.signer?t.signer:t.contract.provider.getSigner(e)||t.contract.signer;return t.contract.connect(r)})}catch(e){return Promise.reject(e)}}changeOwner(e,t={}){try{const r=this,n={gasLimit:123456,gasPrice:1e9,...t};return Promise.resolve(r.attachContract(n.from)).then(function(t){return delete n.from,Promise.resolve(t.functions.changeOwner(r.address,e,n)).then(function(e){return Promise.resolve(e.wait())})})}catch(e){return Promise.reject(e)}}addDelegate(e,t,r,n={}){try{const o=this,i={gasLimit:123456,gasPrice:1e9,...n};return Promise.resolve(o.attachContract(i.from)).then(function(n){delete i.from;const c=m(e);return Promise.resolve(n.functions.addDelegate(o.address,c,t,r,i)).then(function(e){return Promise.resolve(e.wait())})})}catch(e){return Promise.reject(e)}}revokeDelegate(e,t,r={}){try{const n=this,o={gasLimit:123456,gasPrice:1e9,...r};return e=e.startsWith("0x")?e:m(e),Promise.resolve(n.attachContract(o.from)).then(function(r){return delete o.from,Promise.resolve(r.functions.revokeDelegate(n.address,e,t,o)).then(function(e){return Promise.resolve(e.wait())})})}catch(e){return Promise.reject(e)}}setAttribute(e,t,r,n={}){try{const o=this,i={gasLimit:123456,gasPrice:1e9,controller:void 0,...n};return e=e.startsWith("0x")?e:m(e),t=t.startsWith("0x")?t:"0x"+Buffer.from(t,"utf-8").toString("hex"),Promise.resolve(o.attachContract(i.from)).then(function(n){return delete i.from,Promise.resolve(n.functions.setAttribute(o.address,e,t,r,i)).then(function(e){return Promise.resolve(e.wait())})})}catch(e){return Promise.reject(e)}}revokeAttribute(e,t,r={}){try{const n=this,o={gasLimit:123456,gasPrice:1e9,...r};return e=e.startsWith("0x")?e:m(e),t=t.startsWith("0x")?t:"0x"+Buffer.from(t,"utf-8").toString("hex"),Promise.resolve(n.attachContract(o.from)).then(function(r){return delete o.from,Promise.resolve(r.functions.revokeAttribute(n.address,e,t,o)).then(function(e){return Promise.resolve(e.wait())})})}catch(e){return Promise.reject(e)}}}function P(e,t,r){if(!e.s){if(r instanceof k){if(!r.s)return void(r.o=P.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(P.bind(null,e,t),P.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}const k=function(){function e(){}return e.prototype.then=function(t,r){const n=new e,o=this.s;if(o){const e=1&o?t:r;if(e){try{P(n,1,e(this.v))}catch(e){P(n,2,e)}return n}return this}return this.o=function(e){try{const o=e.v;1&e.s?P(n,1,t?t(o):o):r?P(n,1,r(o)):P(n,2,o)}catch(e){P(n,2,e)}},n},e}();function D(e){return e instanceof k&&1&e.s}class K{constructor(e){this.contracts=function(e={}){const t={...(r=e.infuraProjectId,r?w({networks:[{name:"mainnet",chainId:"0x1",provider:new n.InfuraProvider("homestead",r)},{name:"ropsten",chainId:"0x3",provider:new n.InfuraProvider("ropsten",r)},{name:"rinkeby",chainId:"0x4",provider:new n.InfuraProvider("rinkeby",r)},{name:"goerli",chainId:"0x5",provider:new n.InfuraProvider("goerli",r)},{name:"kovan",chainId:"0x2a",provider:new n.InfuraProvider("kovan",r)}]}):{}),...w(e)};var r;if(0===Object.keys(t).length)throw new Error("invalid_config: Please make sure to have at least one network");return t}(e)}getOwner(e,t,r){try{return Promise.resolve(new x(e,this.contracts[t]).getOwner(e,r))}catch(e){return Promise.reject(e)}}previousChange(e,r,n){try{return Promise.resolve(this.contracts[r].functions.changed(e,{blockTag:n})).then(function(e){return t.BigNumber.from(e[0])})}catch(e){return Promise.reject(e)}}changeLog(e,r,n="latest"){try{const o=this,i=o.contracts[r],c=i.provider,s=r.startsWith("0x")?r:p[r];return Promise.resolve(c.getNetwork()).then(function(a){const u=a.chainId,d=s?t.BigNumber.from(s).toNumber():u,h=[],{address:f,publicKey:l}=g(e);let m=l,p=f;return Promise.resolve(o.previousChange(f,r,n)).then(function(e){function s(){function r(){return{controller:p,history:h,controllerKey:m,chainId:d}}const n=function(e,t,r){for(var n;;){var o=e();if(D(o)&&(o=o.v),!o)return i;if(o.then){n=0;break}var i=r();if(i&&i.then){if(!D(i)){n=1;break}i=i.s}}var c=new k,s=P.bind(null,c,2);return(0===n?o.then(u):1===n?i.then(a):(void 0).then(function(){(o=e())?o.then?o.then(u).then(void 0,s):u(o):P(c,1,i)})).then(void 0,s),c;function a(t){i=t;do{if(!(o=e())||D(o)&&!o.v)return void P(c,1,i);if(o.then)return void o.then(u).then(void 0,s);D(i=r())&&(i=i.v)}while(!i||!i.then);i.then(a).then(void 0,s)}function u(e){e?(i=r())&&i.then?i.then(a).then(void 0,s):a(i):P(c,1,i)}}(function(){return!!e},0,function(){const r=e;return Promise.resolve(c.getLogs({address:i.address,topics:[null,`0x000000000000000000000000${f.slice(2)}`],fromBlock:e.toHexString(),toBlock:e.toHexString()})).then(function(n){const o=function(e,r){return r.map(r=>function(e){const r={};if(e.eventFragment.inputs.length!==e.args.length)throw new TypeError("malformed event input. wrong number of arguments");return e.eventFragment.inputs.forEach((n,o)=>{let i=e.args[o];"object"==typeof i&&(i=t.BigNumber.from(i)),"bytes32"===n.type&&(i=v(i)),r[n.name]=i}),r._eventName=e.name,r}(e.interface.parseLog(r)))}(i,n);o.reverse(),e=null;for(const t of o)h.unshift(t),t.previousChange.lt(r)&&(e=t.previousChange)})});return n&&n.then?n.then(r):r()}const a=function(){if(e)return Promise.resolve(o.getOwner(f,r,n)).then(function(e){e.toLowerCase()!==p.toLowerCase()&&(m=void 0),p=e})}();return a&&a.then?a.then(s):s()})})}catch(e){return Promise.reject(e)}}wrapDidDocument(r,n,o,i,c){const s={"@context":["https://www.w3.org/ns/did/v1","https://identity.foundation/EcdsaSecp256k1RecoverySignature2020/lds-ecdsa-secp256k1-recovery2020-0.0.jsonld"],id:r,verificationMethod:[],authentication:[]},a=t.BigNumber.from(Math.floor((new Date).getTime()/1e3)),u=[{id:`${r}#controller`,type:exports.verificationMethodTypes.EcdsaSecp256k1RecoveryMethod2020,controller:r,blockchainAccountId:`${n}@eip155:${c}`}],d=[`${r}#controller`];o&&(u.push({id:`${r}#controllerKey`,type:exports.verificationMethodTypes.EcdsaSecp256k1VerificationKey2019,controller:r,publicKeyHex:o}),d.push(`${r}#controllerKey`));let v=!1,m=0,g=0;const p={},y={},b={};for(const n of i){const o=n.validTo||t.BigNumber.from(0),i=`${n._eventName}-${n.delegateType||n.name}-${n.delegate||n.value}`;if(o&&o.gte(a)){if(n._eventName===h.DIDDelegateChanged){const e=n;switch(m++,e.delegateType){case"sigAuth":p[i]=`${r}#delegate-${m}`;case"veriKey":y[i]={id:`${r}#delegate-${m}`,type:exports.verificationMethodTypes.EcdsaSecp256k1RecoveryMethod2020,controller:r,blockchainAccountId:`${e.delegate}@eip155:${c}`}}}else if(n._eventName===h.DIDAttributeChanged){const t=n,o=t.name.match(/^did\/(pub|svc)\/(\w+)(\/(\w+))?(\/(\w+))?$/);if(o){const n=o[2],c=f[o[4]]||o[4],s=o[6];switch(o[1]){case"pub":{m++;const a={id:`${r}#delegate-${m}`,type:`${n}${c}`,controller:r};switch(a.type=l[a.type]||n,s){case null:case void 0:case"hex":a.publicKeyHex=t.value.slice(2);break;case"base64":a.publicKeyBase64=Buffer.from(t.value.slice(2),"hex").toString("base64");break;case"base58":a.publicKeyBase58=e.Base58.encode(Buffer.from(t.value.slice(2),"hex"));break;case"pem":a.publicKeyPem=Buffer.from(t.value.slice(2),"hex").toString();break;default:a.value=t.value}y[i]=a,"sigAuth"===o[4]&&(p[i]=a.id);break}case"svc":g++,b[i]={id:`${r}#service-${g}`,type:n,serviceEndpoint:Buffer.from(t.value.slice(2),"hex").toString()}}}}}else if(n._eventName===h.DIDDelegateChanged||n._eventName===h.DIDAttributeChanged&&n.name.match(/^did\/pub\//)?m++:n._eventName===h.DIDAttributeChanged&&n.name.match(/^did\/svc\//)&&g++,delete p[i],delete y[i],delete b[i],n._eventName===h.DIDOwnerChanged&&"0x0000000000000000000000000000000000000000"===n.owner){v=!0;break}}const w={...s,verificationMethod:u.concat(Object.values(y)),authentication:d.concat(Object.values(p))};return Object.values(b).length>0&&(w.service=Object.values(b)),v?{didDocument:{...s,"@context":"https://www.w3.org/ns/did/v1"},deactivated:v}:{didDocument:w,deactivated:v}}resolve(e,t,r,n){try{const r=this,o=t.id.match(u);if(!o)throw new Error(`Not a valid ethr DID: ${e}`);const i=o[2],c=o[1]?o[1].slice(0,-1):"mainnet";if(!r.contracts[c])throw new Error(`unknown_network: The DID resolver does not have a configuration for network: ${c}`);return Promise.resolve(r.changeLog(i,c,n.blockTag)).then(function({controller:t,history:n,controllerKey:o,chainId:i}){try{const{didDocument:c,deactivated:s}=r.wrapDidDocument(e,t,o,n,i);return{didDocumentMetadata:{...s?{deactivated:!0}:{}},didResolutionMetadata:{contentType:"application/did+ld+json"},didDocument:c}}catch(e){return{didResolutionMetadata:{error:"notFound",message:e.toString()},didDocumentMetadata:{},didDocument:null}}})}catch(e){return Promise.reject(e)}}build(){return{ethr:this.resolve.bind(this)}}}exports.REGISTRY="0xdca7ef03e98e0dc2b855be647c39abe984fcf21b",exports.attrTypes=f,exports.bytes32toString=v,exports.delegateTypes=l,exports.getResolver=function(e){return new K(e).build()},exports.identifierMatcher=u,exports.stringToBytes32=m;
var e=require("@ethersproject/basex"),t=require("@ethersproject/bignumber"),r=require("@ethersproject/contracts"),n=require("@ethersproject/providers"),o=require("ethr-did-registry"),i=require("@ethersproject/address"),c=require("@ethersproject/transactions");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=s(o);const d=/^(.*)?(0x[0-9a-fA-F]{40}|0x[0-9a-fA-F]{66})$/;var u,h;exports.verificationMethodTypes=void 0,(u=exports.verificationMethodTypes||(exports.verificationMethodTypes={})).EcdsaSecp256k1VerificationKey2019="EcdsaSecp256k1VerificationKey2019",u.EcdsaSecp256k1RecoveryMethod2020="EcdsaSecp256k1RecoveryMethod2020",u.Ed25519VerificationKey2018="Ed25519VerificationKey2018",u.RSAVerificationKey2018="RSAVerificationKey2018",u.X25519KeyAgreementKey2019="X25519KeyAgreementKey2019",function(e){e.DIDOwnerChanged="DIDOwnerChanged",e.DIDAttributeChanged="DIDAttributeChanged",e.DIDDelegateChanged="DIDDelegateChanged"}(h||(h={}));const f={sigAuth:"SignatureAuthentication2018",veriKey:"VerificationKey2018",enc:"KeyAgreementKey2019"},l={Secp256k1VerificationKey2018:exports.verificationMethodTypes.EcdsaSecp256k1VerificationKey2019,Ed25519SignatureAuthentication2018:exports.verificationMethodTypes.Ed25519VerificationKey2018,Secp256k1SignatureAuthentication2018:exports.verificationMethodTypes.EcdsaSecp256k1VerificationKey2019,RSAVerificationKey2018:exports.verificationMethodTypes.RSAVerificationKey2018,Ed25519VerificationKey2018:exports.verificationMethodTypes.Ed25519VerificationKey2018,X25519KeyAgreementKey2019:exports.verificationMethodTypes.X25519KeyAgreementKey2019};function v(e){return("string"==typeof e?Buffer.from(e.slice(2),"hex"):Buffer.from(e)).toString("utf8").replace(/\0+$/,"")}function m(e){const t="0x"+Buffer.from(e).slice(0,32).toString("hex");return t+"0".repeat(66-t.length)}function p(e){return e.length>42?{address:c.computeAddress(e),publicKey:e}:{address:i.getAddress(e)}}const g={mainnet:"0x1",ropsten:"0x3",rinkeby:"0x4",goerli:"0x5",kovan:"0x2a"},y={...g,rsk:"0x1e","rsk:testnet":"0x1f",artis_t1:"0x03c401",artis_s1:"0x03c301",matic:"0x89",maticmum:"0x13881"};var b;function x(e){var o;let i=e.provider||(null==(o=e.web3)?void 0:o.currentProvider);if(!i){if(!e.rpcUrl)throw new Error(`invalid_config: No web3 provider could be determined for network ${e.name||e.chainId}`);{var c;const r=e.chainId?e.chainId:y[e.name||""],o=r?t.BigNumber.from(r).toNumber():r,s=g[e.name||""]?null==(c=e.name)?void 0:c.replace("mainnet","homestead"):"any";i=new n.JsonRpcProvider(e.rpcUrl,o||s)}}return r.ContractFactory.fromSolidity(a.default).attach(e.registry||"0xdca7ef03e98e0dc2b855be647c39abe984fcf21b").connect(i)}function w(e){const t={},r=e.chainId||y[e.name||""];return r?(e.name&&(t[e.name]=x(e)),t["number"==typeof r?`0x${r.toString(16)}`:r]=x(e)):(e.provider||e.web3||e.rpcUrl)&&(t[e.name||""]=x(e)),t}function k(e){var t;return{...w(e),...null==(t=e.networks)?void 0:t.reduce((e,t)=>({...e,...w(t)}),{})}}exports.Errors=void 0,(b=exports.Errors||(exports.Errors={})).notFound="notFound",b.invalidDid="invalidDid",b.unknownNetwork="unknownNetwork";class D{constructor(e,t,r){this.contract=t,this.signer=r;const{address:n}=p(e);this.address=n}getOwner(e,t){try{return Promise.resolve(this.contract.functions.identityOwner(e,{blockTag:t})).then(function(e){return e[0]})}catch(e){return Promise.reject(e)}}attachContract(e){try{const t=this;return Promise.resolve(e||t.getOwner(t.address,"latest")).then(function(e){const r=t.signer?t.signer:t.contract.provider.getSigner(e)||t.contract.signer;return t.contract.connect(r)})}catch(e){return Promise.reject(e)}}changeOwner(e,t={}){try{const r=this,n={gasLimit:123456,gasPrice:1e9,...t};return Promise.resolve(r.attachContract(n.from)).then(function(t){return delete n.from,Promise.resolve(t.functions.changeOwner(r.address,e,n)).then(function(e){return Promise.resolve(e.wait())})})}catch(e){return Promise.reject(e)}}addDelegate(e,t,r,n={}){try{const o=this,i={gasLimit:123456,gasPrice:1e9,...n};return Promise.resolve(o.attachContract(i.from)).then(function(n){delete i.from;const c=m(e);return Promise.resolve(n.functions.addDelegate(o.address,c,t,r,i)).then(function(e){return Promise.resolve(e.wait())})})}catch(e){return Promise.reject(e)}}revokeDelegate(e,t,r={}){try{const n=this,o={gasLimit:123456,gasPrice:1e9,...r};return e=e.startsWith("0x")?e:m(e),Promise.resolve(n.attachContract(o.from)).then(function(r){return delete o.from,Promise.resolve(r.functions.revokeDelegate(n.address,e,t,o)).then(function(e){return Promise.resolve(e.wait())})})}catch(e){return Promise.reject(e)}}setAttribute(e,t,r,n={}){try{const o=this,i={gasLimit:123456,gasPrice:1e9,controller:void 0,...n};return e=e.startsWith("0x")?e:m(e),t=t.startsWith("0x")?t:"0x"+Buffer.from(t,"utf-8").toString("hex"),Promise.resolve(o.attachContract(i.from)).then(function(n){return delete i.from,Promise.resolve(n.functions.setAttribute(o.address,e,t,r,i)).then(function(e){return Promise.resolve(e.wait())})})}catch(e){return Promise.reject(e)}}revokeAttribute(e,t,r={}){try{const n=this,o={gasLimit:123456,gasPrice:1e9,...r};return e=e.startsWith("0x")?e:m(e),t=t.startsWith("0x")?t:"0x"+Buffer.from(t,"utf-8").toString("hex"),Promise.resolve(n.attachContract(o.from)).then(function(r){return delete o.from,Promise.resolve(r.functions.revokeAttribute(n.address,e,t,o)).then(function(e){return Promise.resolve(e.wait())})})}catch(e){return Promise.reject(e)}}}function P(e,t,r){if(!e.s){if(r instanceof K){if(!r.s)return void(r.o=P.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(P.bind(null,e,t),P.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}const K=function(){function e(){}return e.prototype.then=function(t,r){const n=new e,o=this.s;if(o){const e=1&o?t:r;if(e){try{P(n,1,e(this.v))}catch(e){P(n,2,e)}return n}return this}return this.o=function(e){try{const o=e.v;1&e.s?P(n,1,t?t(o):o):r?P(n,1,r(o)):P(n,2,o)}catch(e){P(n,2,e)}},n},e}();function S(e){return e instanceof K&&1&e.s}class I{constructor(e){this.contracts=function(e={}){const t={...(r=e.infuraProjectId,r?k({networks:[{name:"mainnet",chainId:"0x1",provider:new n.InfuraProvider("homestead",r)},{name:"ropsten",chainId:"0x3",provider:new n.InfuraProvider("ropsten",r)},{name:"rinkeby",chainId:"0x4",provider:new n.InfuraProvider("rinkeby",r)},{name:"goerli",chainId:"0x5",provider:new n.InfuraProvider("goerli",r)},{name:"kovan",chainId:"0x2a",provider:new n.InfuraProvider("kovan",r)}]}):{}),...k(e)};var r;if(0===Object.keys(t).length)throw new Error("invalid_config: Please make sure to have at least one network");return t}(e)}getOwner(e,t,r){try{return Promise.resolve(new D(e,this.contracts[t]).getOwner(e,r))}catch(e){return Promise.reject(e)}}previousChange(e,r,n){try{return Promise.resolve(this.contracts[r].functions.changed(e,{blockTag:n})).then(function(e){return t.BigNumber.from(e[0])})}catch(e){return Promise.reject(e)}}changeLog(e,r,n="latest"){try{const o=this,i=o.contracts[r],c=i.provider,s=r.startsWith("0x")?r:y[r];return Promise.resolve(c.getNetwork()).then(function(a){const d=a.chainId,u=s?t.BigNumber.from(s).toNumber():d,h=[],{address:f,publicKey:l}=p(e);let m=l,g=f;return Promise.resolve(o.previousChange(f,r,n)).then(function(e){function s(){function r(){return{controller:g,history:h,controllerKey:m,chainId:u}}const n=function(e,t,r){for(var n;;){var o=e();if(S(o)&&(o=o.v),!o)return i;if(o.then){n=0;break}var i=r();if(i&&i.then){if(!S(i)){n=1;break}i=i.s}}var c=new K,s=P.bind(null,c,2);return(0===n?o.then(d):1===n?i.then(a):(void 0).then(function(){(o=e())?o.then?o.then(d).then(void 0,s):d(o):P(c,1,i)})).then(void 0,s),c;function a(t){i=t;do{if(!(o=e())||S(o)&&!o.v)return void P(c,1,i);if(o.then)return void o.then(d).then(void 0,s);S(i=r())&&(i=i.v)}while(!i||!i.then);i.then(a).then(void 0,s)}function d(e){e?(i=r())&&i.then?i.then(a).then(void 0,s):a(i):P(c,1,i)}}(function(){return!!e},0,function(){const r=e;return Promise.resolve(c.getLogs({address:i.address,topics:[null,`0x000000000000000000000000${f.slice(2)}`],fromBlock:e.toHexString(),toBlock:e.toHexString()})).then(function(n){const o=function(e,r){return r.map(r=>function(e){const r={};if(e.eventFragment.inputs.length!==e.args.length)throw new TypeError("malformed event input. wrong number of arguments");return e.eventFragment.inputs.forEach((n,o)=>{let i=e.args[o];"object"==typeof i&&(i=t.BigNumber.from(i)),"bytes32"===n.type&&(i=v(i)),r[n.name]=i}),r._eventName=e.name,r}(e.interface.parseLog(r)))}(i,n);o.reverse(),e=null;for(const t of o)h.unshift(t),t.previousChange.lt(r)&&(e=t.previousChange)})});return n&&n.then?n.then(r):r()}const a=function(){if(e)return Promise.resolve(o.getOwner(f,r,n)).then(function(e){e.toLowerCase()!==g.toLowerCase()&&(m=void 0),g=e})}();return a&&a.then?a.then(s):s()})})}catch(e){return Promise.reject(e)}}wrapDidDocument(r,n,o,i,c){const s={"@context":["https://www.w3.org/ns/did/v1","https://identity.foundation/EcdsaSecp256k1RecoverySignature2020/lds-ecdsa-secp256k1-recovery2020-0.0.jsonld"],id:r,verificationMethod:[],authentication:[]},a=t.BigNumber.from(Math.floor((new Date).getTime()/1e3)),d=[{id:`${r}#controller`,type:exports.verificationMethodTypes.EcdsaSecp256k1RecoveryMethod2020,controller:r,blockchainAccountId:`${n}@eip155:${c}`}],u=[`${r}#controller`];o&&(d.push({id:`${r}#controllerKey`,type:exports.verificationMethodTypes.EcdsaSecp256k1VerificationKey2019,controller:r,publicKeyHex:o}),u.push(`${r}#controllerKey`));let v=!1,m=0,p=0;const g={},y={},b={};for(const n of i){const o=n.validTo||t.BigNumber.from(0),i=`${n._eventName}-${n.delegateType||n.name}-${n.delegate||n.value}`;if(o&&o.gte(a)){if(n._eventName===h.DIDDelegateChanged){const e=n;switch(m++,e.delegateType){case"sigAuth":g[i]=`${r}#delegate-${m}`;case"veriKey":y[i]={id:`${r}#delegate-${m}`,type:exports.verificationMethodTypes.EcdsaSecp256k1RecoveryMethod2020,controller:r,blockchainAccountId:`${e.delegate}@eip155:${c}`}}}else if(n._eventName===h.DIDAttributeChanged){const t=n,o=t.name.match(/^did\/(pub|svc)\/(\w+)(\/(\w+))?(\/(\w+))?$/);if(o){const n=o[2],c=f[o[4]]||o[4],s=o[6];switch(o[1]){case"pub":{m++;const a={id:`${r}#delegate-${m}`,type:`${n}${c}`,controller:r};switch(a.type=l[a.type]||n,s){case null:case void 0:case"hex":a.publicKeyHex=t.value.slice(2);break;case"base64":a.publicKeyBase64=Buffer.from(t.value.slice(2),"hex").toString("base64");break;case"base58":a.publicKeyBase58=e.Base58.encode(Buffer.from(t.value.slice(2),"hex"));break;case"pem":a.publicKeyPem=Buffer.from(t.value.slice(2),"hex").toString();break;default:a.value=t.value}y[i]=a,"sigAuth"===o[4]&&(g[i]=a.id);break}case"svc":p++,b[i]={id:`${r}#service-${p}`,type:n,serviceEndpoint:Buffer.from(t.value.slice(2),"hex").toString()}}}}}else if(n._eventName===h.DIDDelegateChanged||n._eventName===h.DIDAttributeChanged&&n.name.match(/^did\/pub\//)?m++:n._eventName===h.DIDAttributeChanged&&n.name.match(/^did\/svc\//)&&p++,delete g[i],delete y[i],delete b[i],n._eventName===h.DIDOwnerChanged&&"0x0000000000000000000000000000000000000000"===n.owner){v=!0;break}}const x={...s,verificationMethod:d.concat(Object.values(y)),authentication:u.concat(Object.values(g))};return Object.values(b).length>0&&(x.service=Object.values(b)),v?{didDocument:{...s,"@context":"https://www.w3.org/ns/did/v1"},deactivated:v}:{didDocument:x,deactivated:v}}resolve(e,t,r,n){try{const r=this,o=t.id.match(d);if(!o)return Promise.resolve({didResolutionMetadata:{error:exports.Errors.invalidDid,message:`Not a valid did:ethr: ${t.id}`},didDocumentMetadata:{},didDocument:null});const i=o[2],c=o[1]?o[1].slice(0,-1):"mainnet";return r.contracts[c]?Promise.resolve(r.changeLog(i,c,n.blockTag)).then(function({controller:t,history:n,controllerKey:o,chainId:i}){try{const{didDocument:c,deactivated:s}=r.wrapDidDocument(e,t,o,n,i);return{didDocumentMetadata:{...s?{deactivated:!0}:{}},didResolutionMetadata:{contentType:"application/did+ld+json"},didDocument:c}}catch(e){return{didResolutionMetadata:{error:exports.Errors.notFound,message:e.toString()},didDocumentMetadata:{},didDocument:null}}}):Promise.resolve({didResolutionMetadata:{error:exports.Errors.unknownNetwork,message:`The DID resolver does not have a configuration for network: ${c}`},didDocumentMetadata:{},didDocument:null})}catch(e){return Promise.reject(e)}}build(){return{ethr:this.resolve.bind(this)}}}exports.REGISTRY="0xdca7ef03e98e0dc2b855be647c39abe984fcf21b",exports.attrTypes=f,exports.bytes32toString=v,exports.delegateTypes=l,exports.getResolver=function(e){return new I(e).build()},exports.identifierMatcher=d,exports.stringToBytes32=m;
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

import{Base58 as e}from"@ethersproject/basex";import{BigNumber as t}from"@ethersproject/bignumber";import{ContractFactory as r}from"@ethersproject/contracts";import{InfuraProvider as n,JsonRpcProvider as a}from"@ethersproject/providers";import i from"ethr-did-registry";import{getAddress as o}from"@ethersproject/address";import{computeAddress as c}from"@ethersproject/transactions";function s(){return(s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}const d=/^(.*)?(0x[0-9a-fA-F]{40}|0x[0-9a-fA-F]{66})$/,u="0xdca7ef03e98e0dc2b855be647c39abe984fcf21b";var h,l;!function(e){e.EcdsaSecp256k1VerificationKey2019="EcdsaSecp256k1VerificationKey2019",e.EcdsaSecp256k1RecoveryMethod2020="EcdsaSecp256k1RecoveryMethod2020",e.Ed25519VerificationKey2018="Ed25519VerificationKey2018",e.RSAVerificationKey2018="RSAVerificationKey2018",e.X25519KeyAgreementKey2019="X25519KeyAgreementKey2019"}(h||(h={})),function(e){e.DIDOwnerChanged="DIDOwnerChanged",e.DIDAttributeChanged="DIDAttributeChanged",e.DIDDelegateChanged="DIDDelegateChanged"}(l||(l={}));const f={sigAuth:"SignatureAuthentication2018",veriKey:"VerificationKey2018",enc:"KeyAgreementKey2019"},g={Secp256k1VerificationKey2018:h.EcdsaSecp256k1VerificationKey2019,Ed25519SignatureAuthentication2018:h.Ed25519VerificationKey2018,Secp256k1SignatureAuthentication2018:h.EcdsaSecp256k1VerificationKey2019,RSAVerificationKey2018:h.RSAVerificationKey2018,Ed25519VerificationKey2018:h.Ed25519VerificationKey2018,X25519KeyAgreementKey2019:h.X25519KeyAgreementKey2019};function m(e){return("string"==typeof e?Buffer.from(e.slice(2),"hex"):Buffer.from(e)).toString("utf8").replace(/\0+$/,"")}function p(e){const t="0x"+Buffer.from(e).slice(0,32).toString("hex");return t+"0".repeat(66-t.length)}function v(e){return e.length>42?{address:c(e),publicKey:e}:{address:o(e)}}const w=s({},{mainnet:"0x1",ropsten:"0x3",rinkeby:"0x4",goerli:"0x5",kovan:"0x2a"});function y(e){var n;let o=e.provider||(null==(n=e.web3)?void 0:n.currentProvider);if(!o){if(!e.rpcUrl)throw new Error(`invalid_config: No web3 provider could be determined for network ${e.name||e.chainId}`);{var c;const r=e.chainId?t.from(e.chainId).toNumber():e.chainId,n=w[e.name||""]?null==(c=e.name)?void 0:c.replace("mainnet","homestead"):"any";o=new a(e.rpcUrl,r||n)}}return r.fromSolidity(i).attach(e.registry||"0xdca7ef03e98e0dc2b855be647c39abe984fcf21b").connect(o)}function b(e){const t={},r=e.chainId||w[e.name||""];return r?(e.name&&(t[e.name]=y(e)),t["number"==typeof r?`0x${r.toString(16)}`:r]=y(e)):(e.provider||e.web3||e.rpcUrl)&&(t[e.name||""]=y(e)),t}function D(e){var t;return s({},b(e),null==(t=e.networks)?void 0:t.reduce((e,t)=>s({},e,b(t)),{}))}class k{constructor(e,t,r){this.contract=t,this.signer=r;const{address:n}=v(e);this.address=n}async getOwner(e,t){return(await this.contract.functions.identityOwner(e,{blockTag:t}))[0]}async attachContract(e){const t=e?await e:await this.getOwner(this.address,"latest"),r=this.signer?this.signer:this.contract.provider.getSigner(t)||this.contract.signer;return this.contract.connect(r)}async changeOwner(e,t={}){const r=s({gasLimit:123456,gasPrice:1e9},t),n=await this.attachContract(r.from);delete r.from;const a=await n.functions.changeOwner(this.address,e,r);return await a.wait()}async addDelegate(e,t,r,n={}){const a=s({gasLimit:123456,gasPrice:1e9},n),i=await this.attachContract(a.from);delete a.from;const o=p(e),c=await i.functions.addDelegate(this.address,o,t,r,a);return await c.wait()}async revokeDelegate(e,t,r={}){const n=s({gasLimit:123456,gasPrice:1e9},r);e=e.startsWith("0x")?e:p(e);const a=await this.attachContract(n.from);delete n.from;const i=await a.functions.revokeDelegate(this.address,e,t,n);return await i.wait()}async setAttribute(e,t,r,n={}){const a=s({gasLimit:123456,gasPrice:1e9,controller:void 0},n);e=e.startsWith("0x")?e:p(e),t=t.startsWith("0x")?t:"0x"+Buffer.from(t,"utf-8").toString("hex");const i=await this.attachContract(a.from);delete a.from;const o=await i.functions.setAttribute(this.address,e,t,r,a);return await o.wait()}async revokeAttribute(e,t,r={}){const n=s({gasLimit:123456,gasPrice:1e9},r);e=e.startsWith("0x")?e:p(e),t=t.startsWith("0x")?t:"0x"+Buffer.from(t,"utf-8").toString("hex");const a=await this.attachContract(n.from);delete n.from;const i=await a.functions.revokeAttribute(this.address,e,t,n);return await i.wait()}}function x(e,r){return r.map(r=>function(e){const r={};if(e.eventFragment.inputs.length!==e.args.length)throw new TypeError("malformed event input. wrong number of arguments");return e.eventFragment.inputs.forEach((n,a)=>{let i=e.args[a];"object"==typeof i&&(i=t.from(i)),"bytes32"===n.type&&(i=m(i)),r[n.name]=i}),r._eventName=e.name,r}(e.interface.parseLog(r)))}function K(e){return new S(e).build()}class S{constructor(e){this.contracts=function(e={}){const t=s({},(r=e.infuraProjectId)?D({networks:[{name:"mainnet",chainId:"0x1",provider:new n("homestead",r)},{name:"ropsten",chainId:"0x3",provider:new n("ropsten",r)},{name:"rinkeby",chainId:"0x4",provider:new n("rinkeby",r)},{name:"goerli",chainId:"0x5",provider:new n("goerli",r)},{name:"kovan",chainId:"0x2a",provider:new n("kovan",r)}]}):{},D(e));var r;if(0===Object.keys(t).length)throw new Error("invalid_config: Please make sure to have at least one network");return t}(e)}async getOwner(e,t,r){return new k(e,this.contracts[t]).getOwner(e,r)}async previousChange(e,r,n){const a=await this.contracts[r].functions.changed(e,{blockTag:n});return t.from(a[0])}async changeLog(e,r,n="latest"){const a=this.contracts[r],i=a.provider,o=r.startsWith("0x")?r:w[r],c=(await i.getNetwork()).chainId,s=o?t.from(o).toNumber():c,d=[],{address:u,publicKey:h}=v(e);let l=h,f=u,g=await this.previousChange(u,r,n);if(g){const e=await this.getOwner(u,r,n);e.toLowerCase()!==f.toLowerCase()&&(l=void 0),f=e}for(;g;){const e=g,t=x(a,await i.getLogs({address:a.address,topics:[null,`0x000000000000000000000000${u.slice(2)}`],fromBlock:g.toHexString(),toBlock:g.toHexString()}));t.reverse(),g=null;for(const r of t)d.unshift(r),r.previousChange.lt(e)&&(g=r.previousChange)}return{controller:f,history:d,controllerKey:l,chainId:s}}wrapDidDocument(r,n,a,i,o){const c={"@context":["https://www.w3.org/ns/did/v1","https://identity.foundation/EcdsaSecp256k1RecoverySignature2020/lds-ecdsa-secp256k1-recovery2020-0.0.jsonld"],id:r,verificationMethod:[],authentication:[]},d=t.from(Math.floor((new Date).getTime()/1e3)),u=[{id:`${r}#controller`,type:h.EcdsaSecp256k1RecoveryMethod2020,controller:r,blockchainAccountId:`${n}@eip155:${o}`}],m=[`${r}#controller`];a&&(u.push({id:`${r}#controllerKey`,type:h.EcdsaSecp256k1VerificationKey2019,controller:r,publicKeyHex:a}),m.push(`${r}#controllerKey`));let p=!1,v=0,w=0;const y={},b={},D={};for(const n of i){const a=n.validTo||t.from(0),i=`${n._eventName}-${n.delegateType||n.name}-${n.delegate||n.value}`;if(a&&a.gte(d)){if(n._eventName===l.DIDDelegateChanged){const e=n;switch(v++,e.delegateType){case"sigAuth":y[i]=`${r}#delegate-${v}`;case"veriKey":b[i]={id:`${r}#delegate-${v}`,type:h.EcdsaSecp256k1RecoveryMethod2020,controller:r,blockchainAccountId:`${e.delegate}@eip155:${o}`}}}else if(n._eventName===l.DIDAttributeChanged){const t=n,a=t.name.match(/^did\/(pub|svc)\/(\w+)(\/(\w+))?(\/(\w+))?$/);if(a){const n=a[2],o=f[a[4]]||a[4],c=a[6];switch(a[1]){case"pub":{v++;const s={id:`${r}#delegate-${v}`,type:`${n}${o}`,controller:r};switch(s.type=g[s.type]||n,c){case null:case void 0:case"hex":s.publicKeyHex=t.value.slice(2);break;case"base64":s.publicKeyBase64=Buffer.from(t.value.slice(2),"hex").toString("base64");break;case"base58":s.publicKeyBase58=e.encode(Buffer.from(t.value.slice(2),"hex"));break;case"pem":s.publicKeyPem=Buffer.from(t.value.slice(2),"hex").toString();break;default:s.value=t.value}b[i]=s,"sigAuth"===a[4]&&(y[i]=s.id);break}case"svc":w++,D[i]={id:`${r}#service-${w}`,type:n,serviceEndpoint:Buffer.from(t.value.slice(2),"hex").toString()}}}}}else if(n._eventName===l.DIDDelegateChanged||n._eventName===l.DIDAttributeChanged&&n.name.match(/^did\/pub\//)?v++:n._eventName===l.DIDAttributeChanged&&n.name.match(/^did\/svc\//)&&w++,delete y[i],delete b[i],delete D[i],n._eventName===l.DIDOwnerChanged&&"0x0000000000000000000000000000000000000000"===n.owner){p=!0;break}}const k=s({},c,{verificationMethod:u.concat(Object.values(b)),authentication:m.concat(Object.values(y))});return Object.values(D).length>0&&(k.service=Object.values(D)),p?{didDocument:s({},c,{"@context":"https://www.w3.org/ns/did/v1"}),deactivated:p}:{didDocument:k,deactivated:p}}async resolve(e,t,r,n){const a=t.id.match(d);if(!a)throw new Error(`Not a valid ethr DID: ${e}`);const i=a[2],o=a[1]?a[1].slice(0,-1):"mainnet";if(!this.contracts[o])throw new Error(`unknown_network: The DID resolver does not have a configuration for network: ${o}`);const{controller:c,history:u,controllerKey:h,chainId:l}=await this.changeLog(i,o,n.blockTag);try{const{didDocument:t,deactivated:r}=this.wrapDidDocument(e,c,h,u,l);return{didDocumentMetadata:s({},r?{deactivated:!0}:{}),didResolutionMetadata:{contentType:"application/did+ld+json"},didDocument:t}}catch(e){return{didResolutionMetadata:{error:"notFound",message:e.toString()},didDocumentMetadata:{},didDocument:null}}}build(){return{ethr:this.resolve.bind(this)}}}export{u as REGISTRY,f as attrTypes,m as bytes32toString,g as delegateTypes,K as getResolver,d as identifierMatcher,p as stringToBytes32,h as verificationMethodTypes};
import{Base58 as e}from"@ethersproject/basex";import{BigNumber as t}from"@ethersproject/bignumber";import{ContractFactory as n}from"@ethersproject/contracts";import{InfuraProvider as r,JsonRpcProvider as a}from"@ethersproject/providers";import i from"ethr-did-registry";import{getAddress as o}from"@ethersproject/address";import{computeAddress as c}from"@ethersproject/transactions";function s(){return(s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}const d=/^(.*)?(0x[0-9a-fA-F]{40}|0x[0-9a-fA-F]{66})$/,u="0xdca7ef03e98e0dc2b855be647c39abe984fcf21b";var l,h;!function(e){e.EcdsaSecp256k1VerificationKey2019="EcdsaSecp256k1VerificationKey2019",e.EcdsaSecp256k1RecoveryMethod2020="EcdsaSecp256k1RecoveryMethod2020",e.Ed25519VerificationKey2018="Ed25519VerificationKey2018",e.RSAVerificationKey2018="RSAVerificationKey2018",e.X25519KeyAgreementKey2019="X25519KeyAgreementKey2019"}(l||(l={})),function(e){e.DIDOwnerChanged="DIDOwnerChanged",e.DIDAttributeChanged="DIDAttributeChanged",e.DIDDelegateChanged="DIDDelegateChanged"}(h||(h={}));const f={sigAuth:"SignatureAuthentication2018",veriKey:"VerificationKey2018",enc:"KeyAgreementKey2019"},m={Secp256k1VerificationKey2018:l.EcdsaSecp256k1VerificationKey2019,Ed25519SignatureAuthentication2018:l.Ed25519VerificationKey2018,Secp256k1SignatureAuthentication2018:l.EcdsaSecp256k1VerificationKey2019,RSAVerificationKey2018:l.RSAVerificationKey2018,Ed25519VerificationKey2018:l.Ed25519VerificationKey2018,X25519KeyAgreementKey2019:l.X25519KeyAgreementKey2019};function g(e){return("string"==typeof e?Buffer.from(e.slice(2),"hex"):Buffer.from(e)).toString("utf8").replace(/\0+$/,"")}function p(e){const t="0x"+Buffer.from(e).slice(0,32).toString("hex");return t+"0".repeat(66-t.length)}function v(e){return e.length>42?{address:c(e),publicKey:e}:{address:o(e)}}const w={mainnet:"0x1",ropsten:"0x3",rinkeby:"0x4",goerli:"0x5",kovan:"0x2a"},y=s({},w,{rsk:"0x1e","rsk:testnet":"0x1f",artis_t1:"0x03c401",artis_s1:"0x03c301",matic:"0x89",maticmum:"0x13881"});var b;function D(e){var r;let o=e.provider||(null==(r=e.web3)?void 0:r.currentProvider);if(!o){if(!e.rpcUrl)throw new Error(`invalid_config: No web3 provider could be determined for network ${e.name||e.chainId}`);{var c;const n=e.chainId?e.chainId:y[e.name||""],r=n?t.from(n).toNumber():n,i=w[e.name||""]?null==(c=e.name)?void 0:c.replace("mainnet","homestead"):"any";o=new a(e.rpcUrl,r||i)}}return n.fromSolidity(i).attach(e.registry||"0xdca7ef03e98e0dc2b855be647c39abe984fcf21b").connect(o)}function k(e){const t={},n=e.chainId||y[e.name||""];return n?(e.name&&(t[e.name]=D(e)),t["number"==typeof n?`0x${n.toString(16)}`:n]=D(e)):(e.provider||e.web3||e.rpcUrl)&&(t[e.name||""]=D(e)),t}function x(e){var t;return s({},k(e),null==(t=e.networks)?void 0:t.reduce((e,t)=>s({},e,k(t)),{}))}!function(e){e.notFound="notFound",e.invalidDid="invalidDid",e.unknownNetwork="unknownNetwork"}(b||(b={}));class K{constructor(e,t,n){this.contract=t,this.signer=n;const{address:r}=v(e);this.address=r}async getOwner(e,t){return(await this.contract.functions.identityOwner(e,{blockTag:t}))[0]}async attachContract(e){const t=e?await e:await this.getOwner(this.address,"latest"),n=this.signer?this.signer:this.contract.provider.getSigner(t)||this.contract.signer;return this.contract.connect(n)}async changeOwner(e,t={}){const n=s({gasLimit:123456,gasPrice:1e9},t),r=await this.attachContract(n.from);delete n.from;const a=await r.functions.changeOwner(this.address,e,n);return await a.wait()}async addDelegate(e,t,n,r={}){const a=s({gasLimit:123456,gasPrice:1e9},r),i=await this.attachContract(a.from);delete a.from;const o=p(e),c=await i.functions.addDelegate(this.address,o,t,n,a);return await c.wait()}async revokeDelegate(e,t,n={}){const r=s({gasLimit:123456,gasPrice:1e9},n);e=e.startsWith("0x")?e:p(e);const a=await this.attachContract(r.from);delete r.from;const i=await a.functions.revokeDelegate(this.address,e,t,r);return await i.wait()}async setAttribute(e,t,n,r={}){const a=s({gasLimit:123456,gasPrice:1e9,controller:void 0},r);e=e.startsWith("0x")?e:p(e),t=t.startsWith("0x")?t:"0x"+Buffer.from(t,"utf-8").toString("hex");const i=await this.attachContract(a.from);delete a.from;const o=await i.functions.setAttribute(this.address,e,t,n,a);return await o.wait()}async revokeAttribute(e,t,n={}){const r=s({gasLimit:123456,gasPrice:1e9},n);e=e.startsWith("0x")?e:p(e),t=t.startsWith("0x")?t:"0x"+Buffer.from(t,"utf-8").toString("hex");const a=await this.attachContract(r.from);delete r.from;const i=await a.functions.revokeAttribute(this.address,e,t,r);return await i.wait()}}function S(e,n){return n.map(n=>function(e){const n={};if(e.eventFragment.inputs.length!==e.args.length)throw new TypeError("malformed event input. wrong number of arguments");return e.eventFragment.inputs.forEach((r,a)=>{let i=e.args[a];"object"==typeof i&&(i=t.from(i)),"bytes32"===r.type&&(i=g(i)),n[r.name]=i}),n._eventName=e.name,n}(e.interface.parseLog(n)))}function I(e){return new $(e).build()}class ${constructor(e){this.contracts=function(e={}){const t=s({},(n=e.infuraProjectId)?x({networks:[{name:"mainnet",chainId:"0x1",provider:new r("homestead",n)},{name:"ropsten",chainId:"0x3",provider:new r("ropsten",n)},{name:"rinkeby",chainId:"0x4",provider:new r("rinkeby",n)},{name:"goerli",chainId:"0x5",provider:new r("goerli",n)},{name:"kovan",chainId:"0x2a",provider:new r("kovan",n)}]}):{},x(e));var n;if(0===Object.keys(t).length)throw new Error("invalid_config: Please make sure to have at least one network");return t}(e)}async getOwner(e,t,n){return new K(e,this.contracts[t]).getOwner(e,n)}async previousChange(e,n,r){const a=await this.contracts[n].functions.changed(e,{blockTag:r});return t.from(a[0])}async changeLog(e,n,r="latest"){const a=this.contracts[n],i=a.provider,o=n.startsWith("0x")?n:y[n],c=(await i.getNetwork()).chainId,s=o?t.from(o).toNumber():c,d=[],{address:u,publicKey:l}=v(e);let h=l,f=u,m=await this.previousChange(u,n,r);if(m){const e=await this.getOwner(u,n,r);e.toLowerCase()!==f.toLowerCase()&&(h=void 0),f=e}for(;m;){const e=m,t=S(a,await i.getLogs({address:a.address,topics:[null,`0x000000000000000000000000${u.slice(2)}`],fromBlock:m.toHexString(),toBlock:m.toHexString()}));t.reverse(),m=null;for(const n of t)d.unshift(n),n.previousChange.lt(e)&&(m=n.previousChange)}return{controller:f,history:d,controllerKey:h,chainId:s}}wrapDidDocument(n,r,a,i,o){const c={"@context":["https://www.w3.org/ns/did/v1","https://identity.foundation/EcdsaSecp256k1RecoverySignature2020/lds-ecdsa-secp256k1-recovery2020-0.0.jsonld"],id:n,verificationMethod:[],authentication:[]},d=t.from(Math.floor((new Date).getTime()/1e3)),u=[{id:`${n}#controller`,type:l.EcdsaSecp256k1RecoveryMethod2020,controller:n,blockchainAccountId:`${r}@eip155:${o}`}],g=[`${n}#controller`];a&&(u.push({id:`${n}#controllerKey`,type:l.EcdsaSecp256k1VerificationKey2019,controller:n,publicKeyHex:a}),g.push(`${n}#controllerKey`));let p=!1,v=0,w=0;const y={},b={},D={};for(const r of i){const a=r.validTo||t.from(0),i=`${r._eventName}-${r.delegateType||r.name}-${r.delegate||r.value}`;if(a&&a.gte(d)){if(r._eventName===h.DIDDelegateChanged){const e=r;switch(v++,e.delegateType){case"sigAuth":y[i]=`${n}#delegate-${v}`;case"veriKey":b[i]={id:`${n}#delegate-${v}`,type:l.EcdsaSecp256k1RecoveryMethod2020,controller:n,blockchainAccountId:`${e.delegate}@eip155:${o}`}}}else if(r._eventName===h.DIDAttributeChanged){const t=r,a=t.name.match(/^did\/(pub|svc)\/(\w+)(\/(\w+))?(\/(\w+))?$/);if(a){const r=a[2],o=f[a[4]]||a[4],c=a[6];switch(a[1]){case"pub":{v++;const s={id:`${n}#delegate-${v}`,type:`${r}${o}`,controller:n};switch(s.type=m[s.type]||r,c){case null:case void 0:case"hex":s.publicKeyHex=t.value.slice(2);break;case"base64":s.publicKeyBase64=Buffer.from(t.value.slice(2),"hex").toString("base64");break;case"base58":s.publicKeyBase58=e.encode(Buffer.from(t.value.slice(2),"hex"));break;case"pem":s.publicKeyPem=Buffer.from(t.value.slice(2),"hex").toString();break;default:s.value=t.value}b[i]=s,"sigAuth"===a[4]&&(y[i]=s.id);break}case"svc":w++,D[i]={id:`${n}#service-${w}`,type:r,serviceEndpoint:Buffer.from(t.value.slice(2),"hex").toString()}}}}}else if(r._eventName===h.DIDDelegateChanged||r._eventName===h.DIDAttributeChanged&&r.name.match(/^did\/pub\//)?v++:r._eventName===h.DIDAttributeChanged&&r.name.match(/^did\/svc\//)&&w++,delete y[i],delete b[i],delete D[i],r._eventName===h.DIDOwnerChanged&&"0x0000000000000000000000000000000000000000"===r.owner){p=!0;break}}const k=s({},c,{verificationMethod:u.concat(Object.values(b)),authentication:g.concat(Object.values(y))});return Object.values(D).length>0&&(k.service=Object.values(D)),p?{didDocument:s({},c,{"@context":"https://www.w3.org/ns/did/v1"}),deactivated:p}:{didDocument:k,deactivated:p}}async resolve(e,t,n,r){const a=t.id.match(d);if(!a)return{didResolutionMetadata:{error:b.invalidDid,message:`Not a valid did:ethr: ${t.id}`},didDocumentMetadata:{},didDocument:null};const i=a[2],o=a[1]?a[1].slice(0,-1):"mainnet";if(!this.contracts[o])return{didResolutionMetadata:{error:b.unknownNetwork,message:`The DID resolver does not have a configuration for network: ${o}`},didDocumentMetadata:{},didDocument:null};const{controller:c,history:u,controllerKey:l,chainId:h}=await this.changeLog(i,o,r.blockTag);try{const{didDocument:t,deactivated:n}=this.wrapDidDocument(e,c,l,u,h);return{didDocumentMetadata:s({},n?{deactivated:!0}:{}),didResolutionMetadata:{contentType:"application/did+ld+json"},didDocument:t}}catch(e){return{didResolutionMetadata:{error:b.notFound,message:e.toString()},didDocumentMetadata:{},didDocument:null}}}build(){return{ethr:this.resolve.bind(this)}}}export{b as Errors,u as REGISTRY,f as attrTypes,g as bytes32toString,m as delegateTypes,I as getResolver,d as identifierMatcher,p as stringToBytes32,l as verificationMethodTypes};
//# sourceMappingURL=index.modern.js.map

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@ethersproject/basex"),require("@ethersproject/bignumber"),require("@ethersproject/contracts"),require("@ethersproject/providers"),require("ethr-did-registry"),require("@ethersproject/address"),require("@ethersproject/transactions")):"function"==typeof define&&define.amd?define(["exports","@ethersproject/basex","@ethersproject/bignumber","@ethersproject/contracts","@ethersproject/providers","ethr-did-registry","@ethersproject/address","@ethersproject/transactions"],t):t((e||self).ethrDidResolver={},e.basex,e.bignumber,e.contracts,e.providers,e.ethrDidRegistry,e.address,e.transactions)}(this,function(e,t,r,n,o,i,c,s){function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=a(i);const u=/^(.*)?(0x[0-9a-fA-F]{40}|0x[0-9a-fA-F]{66})$/,h="0xdca7ef03e98e0dc2b855be647c39abe984fcf21b";var f,l;e.verificationMethodTypes=void 0,(f=e.verificationMethodTypes||(e.verificationMethodTypes={})).EcdsaSecp256k1VerificationKey2019="EcdsaSecp256k1VerificationKey2019",f.EcdsaSecp256k1RecoveryMethod2020="EcdsaSecp256k1RecoveryMethod2020",f.Ed25519VerificationKey2018="Ed25519VerificationKey2018",f.RSAVerificationKey2018="RSAVerificationKey2018",f.X25519KeyAgreementKey2019="X25519KeyAgreementKey2019",function(e){e.DIDOwnerChanged="DIDOwnerChanged",e.DIDAttributeChanged="DIDAttributeChanged",e.DIDDelegateChanged="DIDDelegateChanged"}(l||(l={}));const v={sigAuth:"SignatureAuthentication2018",veriKey:"VerificationKey2018",enc:"KeyAgreementKey2019"},m={Secp256k1VerificationKey2018:e.verificationMethodTypes.EcdsaSecp256k1VerificationKey2019,Ed25519SignatureAuthentication2018:e.verificationMethodTypes.Ed25519VerificationKey2018,Secp256k1SignatureAuthentication2018:e.verificationMethodTypes.EcdsaSecp256k1VerificationKey2019,RSAVerificationKey2018:e.verificationMethodTypes.RSAVerificationKey2018,Ed25519VerificationKey2018:e.verificationMethodTypes.Ed25519VerificationKey2018,X25519KeyAgreementKey2019:e.verificationMethodTypes.X25519KeyAgreementKey2019};function g(e){return("string"==typeof e?Buffer.from(e.slice(2),"hex"):Buffer.from(e)).toString("utf8").replace(/\0+$/,"")}function p(e){const t="0x"+Buffer.from(e).slice(0,32).toString("hex");return t+"0".repeat(66-t.length)}function y(e){return e.length>42?{address:s.computeAddress(e),publicKey:e}:{address:c.getAddress(e)}}const b={mainnet:"0x1",ropsten:"0x3",rinkeby:"0x4",goerli:"0x5",kovan:"0x2a"};function w(e){var t;let i=e.provider||(null==(t=e.web3)?void 0:t.currentProvider);if(!i){if(!e.rpcUrl)throw new Error(`invalid_config: No web3 provider could be determined for network ${e.name||e.chainId}`);{var c;const t=e.chainId?r.BigNumber.from(e.chainId).toNumber():e.chainId,n=b[e.name||""]?null==(c=e.name)?void 0:c.replace("mainnet","homestead"):"any";i=new o.JsonRpcProvider(e.rpcUrl,t||n)}}return n.ContractFactory.fromSolidity(d.default).attach(e.registry||h).connect(i)}function D(e){const t={},r=e.chainId||b[e.name||""];return r?(e.name&&(t[e.name]=w(e)),t["number"==typeof r?`0x${r.toString(16)}`:r]=w(e)):(e.provider||e.web3||e.rpcUrl)&&(t[e.name||""]=w(e)),t}function P(e){var t;return{...D(e),...null==(t=e.networks)?void 0:t.reduce((e,t)=>({...e,...D(t)}),{})}}class k{constructor(e,t,r){this.contract=t,this.signer=r;const{address:n}=y(e);this.address=n}getOwner(e,t){try{return Promise.resolve(this.contract.functions.identityOwner(e,{blockTag:t})).then(function(e){return e[0]})}catch(e){return Promise.reject(e)}}attachContract(e){try{const t=this;return Promise.resolve(e||t.getOwner(t.address,"latest")).then(function(e){const r=t.signer?t.signer:t.contract.provider.getSigner(e)||t.contract.signer;return t.contract.connect(r)})}catch(e){return Promise.reject(e)}}changeOwner(e,t={}){try{const r=this,n={gasLimit:123456,gasPrice:1e9,...t};return Promise.resolve(r.attachContract(n.from)).then(function(t){return delete n.from,Promise.resolve(t.functions.changeOwner(r.address,e,n)).then(function(e){return Promise.resolve(e.wait())})})}catch(e){return Promise.reject(e)}}addDelegate(e,t,r,n={}){try{const o=this,i={gasLimit:123456,gasPrice:1e9,...n};return Promise.resolve(o.attachContract(i.from)).then(function(n){delete i.from;const c=p(e);return Promise.resolve(n.functions.addDelegate(o.address,c,t,r,i)).then(function(e){return Promise.resolve(e.wait())})})}catch(e){return Promise.reject(e)}}revokeDelegate(e,t,r={}){try{const n=this,o={gasLimit:123456,gasPrice:1e9,...r};return e=e.startsWith("0x")?e:p(e),Promise.resolve(n.attachContract(o.from)).then(function(r){return delete o.from,Promise.resolve(r.functions.revokeDelegate(n.address,e,t,o)).then(function(e){return Promise.resolve(e.wait())})})}catch(e){return Promise.reject(e)}}setAttribute(e,t,r,n={}){try{const o=this,i={gasLimit:123456,gasPrice:1e9,controller:void 0,...n};return e=e.startsWith("0x")?e:p(e),t=t.startsWith("0x")?t:"0x"+Buffer.from(t,"utf-8").toString("hex"),Promise.resolve(o.attachContract(i.from)).then(function(n){return delete i.from,Promise.resolve(n.functions.setAttribute(o.address,e,t,r,i)).then(function(e){return Promise.resolve(e.wait())})})}catch(e){return Promise.reject(e)}}revokeAttribute(e,t,r={}){try{const n=this,o={gasLimit:123456,gasPrice:1e9,...r};return e=e.startsWith("0x")?e:p(e),t=t.startsWith("0x")?t:"0x"+Buffer.from(t,"utf-8").toString("hex"),Promise.resolve(n.attachContract(o.from)).then(function(r){return delete o.from,Promise.resolve(r.functions.revokeAttribute(n.address,e,t,o)).then(function(e){return Promise.resolve(e.wait())})})}catch(e){return Promise.reject(e)}}}function x(e,t,r){if(!e.s){if(r instanceof K){if(!r.s)return void(r.o=x.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(x.bind(null,e,t),x.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}const K=function(){function e(){}return e.prototype.then=function(t,r){const n=new e,o=this.s;if(o){const e=1&o?t:r;if(e){try{x(n,1,e(this.v))}catch(e){x(n,2,e)}return n}return this}return this.o=function(e){try{const o=e.v;1&e.s?x(n,1,t?t(o):o):r?x(n,1,r(o)):x(n,2,o)}catch(e){x(n,2,e)}},n},e}();function I(e){return e instanceof K&&1&e.s}class S{constructor(e){this.contracts=function(e={}){const t={...(r=e.infuraProjectId,r?P({networks:[{name:"mainnet",chainId:"0x1",provider:new o.InfuraProvider("homestead",r)},{name:"ropsten",chainId:"0x3",provider:new o.InfuraProvider("ropsten",r)},{name:"rinkeby",chainId:"0x4",provider:new o.InfuraProvider("rinkeby",r)},{name:"goerli",chainId:"0x5",provider:new o.InfuraProvider("goerli",r)},{name:"kovan",chainId:"0x2a",provider:new o.InfuraProvider("kovan",r)}]}):{}),...P(e)};var r;if(0===Object.keys(t).length)throw new Error("invalid_config: Please make sure to have at least one network");return t}(e)}getOwner(e,t,r){try{return Promise.resolve(new k(e,this.contracts[t]).getOwner(e,r))}catch(e){return Promise.reject(e)}}previousChange(e,t,n){try{return Promise.resolve(this.contracts[t].functions.changed(e,{blockTag:n})).then(function(e){return r.BigNumber.from(e[0])})}catch(e){return Promise.reject(e)}}changeLog(e,t,n="latest"){try{const o=this,i=o.contracts[t],c=i.provider,s=t.startsWith("0x")?t:b[t];return Promise.resolve(c.getNetwork()).then(function(a){const d=a.chainId,u=s?r.BigNumber.from(s).toNumber():d,h=[],{address:f,publicKey:l}=y(e);let v=l,m=f;return Promise.resolve(o.previousChange(f,t,n)).then(function(e){function s(){function t(){return{controller:m,history:h,controllerKey:v,chainId:u}}const n=function(e,t,r){for(var n;;){var o=e();if(I(o)&&(o=o.v),!o)return i;if(o.then){n=0;break}var i=r();if(i&&i.then){if(!I(i)){n=1;break}i=i.s}}var c=new K,s=x.bind(null,c,2);return(0===n?o.then(d):1===n?i.then(a):(void 0).then(function(){(o=e())?o.then?o.then(d).then(void 0,s):d(o):x(c,1,i)})).then(void 0,s),c;function a(t){i=t;do{if(!(o=e())||I(o)&&!o.v)return void x(c,1,i);if(o.then)return void o.then(d).then(void 0,s);I(i=r())&&(i=i.v)}while(!i||!i.then);i.then(a).then(void 0,s)}function d(e){e?(i=r())&&i.then?i.then(a).then(void 0,s):a(i):x(c,1,i)}}(function(){return!!e},0,function(){const t=e;return Promise.resolve(c.getLogs({address:i.address,topics:[null,`0x000000000000000000000000${f.slice(2)}`],fromBlock:e.toHexString(),toBlock:e.toHexString()})).then(function(n){const o=function(e,t){return t.map(t=>function(e){const t={};if(e.eventFragment.inputs.length!==e.args.length)throw new TypeError("malformed event input. wrong number of arguments");return e.eventFragment.inputs.forEach((n,o)=>{let i=e.args[o];"object"==typeof i&&(i=r.BigNumber.from(i)),"bytes32"===n.type&&(i=g(i)),t[n.name]=i}),t._eventName=e.name,t}(e.interface.parseLog(t)))}(i,n);o.reverse(),e=null;for(const r of o)h.unshift(r),r.previousChange.lt(t)&&(e=r.previousChange)})});return n&&n.then?n.then(t):t()}const a=function(){if(e)return Promise.resolve(o.getOwner(f,t,n)).then(function(e){e.toLowerCase()!==m.toLowerCase()&&(v=void 0),m=e})}();return a&&a.then?a.then(s):s()})})}catch(e){return Promise.reject(e)}}wrapDidDocument(n,o,i,c,s){const a={"@context":["https://www.w3.org/ns/did/v1","https://identity.foundation/EcdsaSecp256k1RecoverySignature2020/lds-ecdsa-secp256k1-recovery2020-0.0.jsonld"],id:n,verificationMethod:[],authentication:[]},d=r.BigNumber.from(Math.floor((new Date).getTime()/1e3)),u=[{id:`${n}#controller`,type:e.verificationMethodTypes.EcdsaSecp256k1RecoveryMethod2020,controller:n,blockchainAccountId:`${o}@eip155:${s}`}],h=[`${n}#controller`];i&&(u.push({id:`${n}#controllerKey`,type:e.verificationMethodTypes.EcdsaSecp256k1VerificationKey2019,controller:n,publicKeyHex:i}),h.push(`${n}#controllerKey`));let f=!1,g=0,p=0;const y={},b={},w={};for(const o of c){const i=o.validTo||r.BigNumber.from(0),c=`${o._eventName}-${o.delegateType||o.name}-${o.delegate||o.value}`;if(i&&i.gte(d)){if(o._eventName===l.DIDDelegateChanged){const t=o;switch(g++,t.delegateType){case"sigAuth":y[c]=`${n}#delegate-${g}`;case"veriKey":b[c]={id:`${n}#delegate-${g}`,type:e.verificationMethodTypes.EcdsaSecp256k1RecoveryMethod2020,controller:n,blockchainAccountId:`${t.delegate}@eip155:${s}`}}}else if(o._eventName===l.DIDAttributeChanged){const e=o,r=e.name.match(/^did\/(pub|svc)\/(\w+)(\/(\w+))?(\/(\w+))?$/);if(r){const o=r[2],i=v[r[4]]||r[4],s=r[6];switch(r[1]){case"pub":{g++;const a={id:`${n}#delegate-${g}`,type:`${o}${i}`,controller:n};switch(a.type=m[a.type]||o,s){case null:case void 0:case"hex":a.publicKeyHex=e.value.slice(2);break;case"base64":a.publicKeyBase64=Buffer.from(e.value.slice(2),"hex").toString("base64");break;case"base58":a.publicKeyBase58=t.Base58.encode(Buffer.from(e.value.slice(2),"hex"));break;case"pem":a.publicKeyPem=Buffer.from(e.value.slice(2),"hex").toString();break;default:a.value=e.value}b[c]=a,"sigAuth"===r[4]&&(y[c]=a.id);break}case"svc":p++,w[c]={id:`${n}#service-${p}`,type:o,serviceEndpoint:Buffer.from(e.value.slice(2),"hex").toString()}}}}}else if(o._eventName===l.DIDDelegateChanged||o._eventName===l.DIDAttributeChanged&&o.name.match(/^did\/pub\//)?g++:o._eventName===l.DIDAttributeChanged&&o.name.match(/^did\/svc\//)&&p++,delete y[c],delete b[c],delete w[c],o._eventName===l.DIDOwnerChanged&&"0x0000000000000000000000000000000000000000"===o.owner){f=!0;break}}const D={...a,verificationMethod:u.concat(Object.values(b)),authentication:h.concat(Object.values(y))};return Object.values(w).length>0&&(D.service=Object.values(w)),f?{didDocument:{...a,"@context":"https://www.w3.org/ns/did/v1"},deactivated:f}:{didDocument:D,deactivated:f}}resolve(e,t,r,n){try{const r=this,o=t.id.match(u);if(!o)throw new Error(`Not a valid ethr DID: ${e}`);const i=o[2],c=o[1]?o[1].slice(0,-1):"mainnet";if(!r.contracts[c])throw new Error(`unknown_network: The DID resolver does not have a configuration for network: ${c}`);return Promise.resolve(r.changeLog(i,c,n.blockTag)).then(function({controller:t,history:n,controllerKey:o,chainId:i}){try{const{didDocument:c,deactivated:s}=r.wrapDidDocument(e,t,o,n,i);return{didDocumentMetadata:{...s?{deactivated:!0}:{}},didResolutionMetadata:{contentType:"application/did+ld+json"},didDocument:c}}catch(e){return{didResolutionMetadata:{error:"notFound",message:e.toString()},didDocumentMetadata:{},didDocument:null}}})}catch(e){return Promise.reject(e)}}build(){return{ethr:this.resolve.bind(this)}}}e.REGISTRY=h,e.attrTypes=v,e.bytes32toString=g,e.delegateTypes=m,e.getResolver=function(e){return new S(e).build()},e.identifierMatcher=u,e.stringToBytes32=p});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@ethersproject/basex"),require("@ethersproject/bignumber"),require("@ethersproject/contracts"),require("@ethersproject/providers"),require("ethr-did-registry"),require("@ethersproject/address"),require("@ethersproject/transactions")):"function"==typeof define&&define.amd?define(["exports","@ethersproject/basex","@ethersproject/bignumber","@ethersproject/contracts","@ethersproject/providers","ethr-did-registry","@ethersproject/address","@ethersproject/transactions"],t):t((e||self).ethrDidResolver={},e.basex,e.bignumber,e.contracts,e.providers,e.ethrDidRegistry,e.address,e.transactions)}(this,function(e,t,r,n,o,i,c,s){function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=a(i);const u=/^(.*)?(0x[0-9a-fA-F]{40}|0x[0-9a-fA-F]{66})$/,h="0xdca7ef03e98e0dc2b855be647c39abe984fcf21b";var f,l;e.verificationMethodTypes=void 0,(f=e.verificationMethodTypes||(e.verificationMethodTypes={})).EcdsaSecp256k1VerificationKey2019="EcdsaSecp256k1VerificationKey2019",f.EcdsaSecp256k1RecoveryMethod2020="EcdsaSecp256k1RecoveryMethod2020",f.Ed25519VerificationKey2018="Ed25519VerificationKey2018",f.RSAVerificationKey2018="RSAVerificationKey2018",f.X25519KeyAgreementKey2019="X25519KeyAgreementKey2019",function(e){e.DIDOwnerChanged="DIDOwnerChanged",e.DIDAttributeChanged="DIDAttributeChanged",e.DIDDelegateChanged="DIDDelegateChanged"}(l||(l={}));const v={sigAuth:"SignatureAuthentication2018",veriKey:"VerificationKey2018",enc:"KeyAgreementKey2019"},m={Secp256k1VerificationKey2018:e.verificationMethodTypes.EcdsaSecp256k1VerificationKey2019,Ed25519SignatureAuthentication2018:e.verificationMethodTypes.Ed25519VerificationKey2018,Secp256k1SignatureAuthentication2018:e.verificationMethodTypes.EcdsaSecp256k1VerificationKey2019,RSAVerificationKey2018:e.verificationMethodTypes.RSAVerificationKey2018,Ed25519VerificationKey2018:e.verificationMethodTypes.Ed25519VerificationKey2018,X25519KeyAgreementKey2019:e.verificationMethodTypes.X25519KeyAgreementKey2019};function g(e){return("string"==typeof e?Buffer.from(e.slice(2),"hex"):Buffer.from(e)).toString("utf8").replace(/\0+$/,"")}function p(e){const t="0x"+Buffer.from(e).slice(0,32).toString("hex");return t+"0".repeat(66-t.length)}function y(e){return e.length>42?{address:s.computeAddress(e),publicKey:e}:{address:c.getAddress(e)}}const b={mainnet:"0x1",ropsten:"0x3",rinkeby:"0x4",goerli:"0x5",kovan:"0x2a"},w={...b,rsk:"0x1e","rsk:testnet":"0x1f",artis_t1:"0x03c401",artis_s1:"0x03c301",matic:"0x89",maticmum:"0x13881"};var D;function k(e){var t;let i=e.provider||(null==(t=e.web3)?void 0:t.currentProvider);if(!i){if(!e.rpcUrl)throw new Error(`invalid_config: No web3 provider could be determined for network ${e.name||e.chainId}`);{var c;const t=e.chainId?e.chainId:w[e.name||""],n=t?r.BigNumber.from(t).toNumber():t,s=b[e.name||""]?null==(c=e.name)?void 0:c.replace("mainnet","homestead"):"any";i=new o.JsonRpcProvider(e.rpcUrl,n||s)}}return n.ContractFactory.fromSolidity(d.default).attach(e.registry||h).connect(i)}function x(e){const t={},r=e.chainId||w[e.name||""];return r?(e.name&&(t[e.name]=k(e)),t["number"==typeof r?`0x${r.toString(16)}`:r]=k(e)):(e.provider||e.web3||e.rpcUrl)&&(t[e.name||""]=k(e)),t}function P(e){var t;return{...x(e),...null==(t=e.networks)?void 0:t.reduce((e,t)=>({...e,...x(t)}),{})}}e.Errors=void 0,(D=e.Errors||(e.Errors={})).notFound="notFound",D.invalidDid="invalidDid",D.unknownNetwork="unknownNetwork";class K{constructor(e,t,r){this.contract=t,this.signer=r;const{address:n}=y(e);this.address=n}getOwner(e,t){try{return Promise.resolve(this.contract.functions.identityOwner(e,{blockTag:t})).then(function(e){return e[0]})}catch(e){return Promise.reject(e)}}attachContract(e){try{const t=this;return Promise.resolve(e||t.getOwner(t.address,"latest")).then(function(e){const r=t.signer?t.signer:t.contract.provider.getSigner(e)||t.contract.signer;return t.contract.connect(r)})}catch(e){return Promise.reject(e)}}changeOwner(e,t={}){try{const r=this,n={gasLimit:123456,gasPrice:1e9,...t};return Promise.resolve(r.attachContract(n.from)).then(function(t){return delete n.from,Promise.resolve(t.functions.changeOwner(r.address,e,n)).then(function(e){return Promise.resolve(e.wait())})})}catch(e){return Promise.reject(e)}}addDelegate(e,t,r,n={}){try{const o=this,i={gasLimit:123456,gasPrice:1e9,...n};return Promise.resolve(o.attachContract(i.from)).then(function(n){delete i.from;const c=p(e);return Promise.resolve(n.functions.addDelegate(o.address,c,t,r,i)).then(function(e){return Promise.resolve(e.wait())})})}catch(e){return Promise.reject(e)}}revokeDelegate(e,t,r={}){try{const n=this,o={gasLimit:123456,gasPrice:1e9,...r};return e=e.startsWith("0x")?e:p(e),Promise.resolve(n.attachContract(o.from)).then(function(r){return delete o.from,Promise.resolve(r.functions.revokeDelegate(n.address,e,t,o)).then(function(e){return Promise.resolve(e.wait())})})}catch(e){return Promise.reject(e)}}setAttribute(e,t,r,n={}){try{const o=this,i={gasLimit:123456,gasPrice:1e9,controller:void 0,...n};return e=e.startsWith("0x")?e:p(e),t=t.startsWith("0x")?t:"0x"+Buffer.from(t,"utf-8").toString("hex"),Promise.resolve(o.attachContract(i.from)).then(function(n){return delete i.from,Promise.resolve(n.functions.setAttribute(o.address,e,t,r,i)).then(function(e){return Promise.resolve(e.wait())})})}catch(e){return Promise.reject(e)}}revokeAttribute(e,t,r={}){try{const n=this,o={gasLimit:123456,gasPrice:1e9,...r};return e=e.startsWith("0x")?e:p(e),t=t.startsWith("0x")?t:"0x"+Buffer.from(t,"utf-8").toString("hex"),Promise.resolve(n.attachContract(o.from)).then(function(r){return delete o.from,Promise.resolve(r.functions.revokeAttribute(n.address,e,t,o)).then(function(e){return Promise.resolve(e.wait())})})}catch(e){return Promise.reject(e)}}}function S(e,t,r){if(!e.s){if(r instanceof j){if(!r.s)return void(r.o=S.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(S.bind(null,e,t),S.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}const j=function(){function e(){}return e.prototype.then=function(t,r){const n=new e,o=this.s;if(o){const e=1&o?t:r;if(e){try{S(n,1,e(this.v))}catch(e){S(n,2,e)}return n}return this}return this.o=function(e){try{const o=e.v;1&e.s?S(n,1,t?t(o):o):r?S(n,1,r(o)):S(n,2,o)}catch(e){S(n,2,e)}},n},e}();function I(e){return e instanceof j&&1&e.s}class A{constructor(e){this.contracts=function(e={}){const t={...(r=e.infuraProjectId,r?P({networks:[{name:"mainnet",chainId:"0x1",provider:new o.InfuraProvider("homestead",r)},{name:"ropsten",chainId:"0x3",provider:new o.InfuraProvider("ropsten",r)},{name:"rinkeby",chainId:"0x4",provider:new o.InfuraProvider("rinkeby",r)},{name:"goerli",chainId:"0x5",provider:new o.InfuraProvider("goerli",r)},{name:"kovan",chainId:"0x2a",provider:new o.InfuraProvider("kovan",r)}]}):{}),...P(e)};var r;if(0===Object.keys(t).length)throw new Error("invalid_config: Please make sure to have at least one network");return t}(e)}getOwner(e,t,r){try{return Promise.resolve(new K(e,this.contracts[t]).getOwner(e,r))}catch(e){return Promise.reject(e)}}previousChange(e,t,n){try{return Promise.resolve(this.contracts[t].functions.changed(e,{blockTag:n})).then(function(e){return r.BigNumber.from(e[0])})}catch(e){return Promise.reject(e)}}changeLog(e,t,n="latest"){try{const o=this,i=o.contracts[t],c=i.provider,s=t.startsWith("0x")?t:w[t];return Promise.resolve(c.getNetwork()).then(function(a){const d=a.chainId,u=s?r.BigNumber.from(s).toNumber():d,h=[],{address:f,publicKey:l}=y(e);let v=l,m=f;return Promise.resolve(o.previousChange(f,t,n)).then(function(e){function s(){function t(){return{controller:m,history:h,controllerKey:v,chainId:u}}const n=function(e,t,r){for(var n;;){var o=e();if(I(o)&&(o=o.v),!o)return i;if(o.then){n=0;break}var i=r();if(i&&i.then){if(!I(i)){n=1;break}i=i.s}}var c=new j,s=S.bind(null,c,2);return(0===n?o.then(d):1===n?i.then(a):(void 0).then(function(){(o=e())?o.then?o.then(d).then(void 0,s):d(o):S(c,1,i)})).then(void 0,s),c;function a(t){i=t;do{if(!(o=e())||I(o)&&!o.v)return void S(c,1,i);if(o.then)return void o.then(d).then(void 0,s);I(i=r())&&(i=i.v)}while(!i||!i.then);i.then(a).then(void 0,s)}function d(e){e?(i=r())&&i.then?i.then(a).then(void 0,s):a(i):S(c,1,i)}}(function(){return!!e},0,function(){const t=e;return Promise.resolve(c.getLogs({address:i.address,topics:[null,`0x000000000000000000000000${f.slice(2)}`],fromBlock:e.toHexString(),toBlock:e.toHexString()})).then(function(n){const o=function(e,t){return t.map(t=>function(e){const t={};if(e.eventFragment.inputs.length!==e.args.length)throw new TypeError("malformed event input. wrong number of arguments");return e.eventFragment.inputs.forEach((n,o)=>{let i=e.args[o];"object"==typeof i&&(i=r.BigNumber.from(i)),"bytes32"===n.type&&(i=g(i)),t[n.name]=i}),t._eventName=e.name,t}(e.interface.parseLog(t)))}(i,n);o.reverse(),e=null;for(const r of o)h.unshift(r),r.previousChange.lt(t)&&(e=r.previousChange)})});return n&&n.then?n.then(t):t()}const a=function(){if(e)return Promise.resolve(o.getOwner(f,t,n)).then(function(e){e.toLowerCase()!==m.toLowerCase()&&(v=void 0),m=e})}();return a&&a.then?a.then(s):s()})})}catch(e){return Promise.reject(e)}}wrapDidDocument(n,o,i,c,s){const a={"@context":["https://www.w3.org/ns/did/v1","https://identity.foundation/EcdsaSecp256k1RecoverySignature2020/lds-ecdsa-secp256k1-recovery2020-0.0.jsonld"],id:n,verificationMethod:[],authentication:[]},d=r.BigNumber.from(Math.floor((new Date).getTime()/1e3)),u=[{id:`${n}#controller`,type:e.verificationMethodTypes.EcdsaSecp256k1RecoveryMethod2020,controller:n,blockchainAccountId:`${o}@eip155:${s}`}],h=[`${n}#controller`];i&&(u.push({id:`${n}#controllerKey`,type:e.verificationMethodTypes.EcdsaSecp256k1VerificationKey2019,controller:n,publicKeyHex:i}),h.push(`${n}#controllerKey`));let f=!1,g=0,p=0;const y={},b={},w={};for(const o of c){const i=o.validTo||r.BigNumber.from(0),c=`${o._eventName}-${o.delegateType||o.name}-${o.delegate||o.value}`;if(i&&i.gte(d)){if(o._eventName===l.DIDDelegateChanged){const t=o;switch(g++,t.delegateType){case"sigAuth":y[c]=`${n}#delegate-${g}`;case"veriKey":b[c]={id:`${n}#delegate-${g}`,type:e.verificationMethodTypes.EcdsaSecp256k1RecoveryMethod2020,controller:n,blockchainAccountId:`${t.delegate}@eip155:${s}`}}}else if(o._eventName===l.DIDAttributeChanged){const e=o,r=e.name.match(/^did\/(pub|svc)\/(\w+)(\/(\w+))?(\/(\w+))?$/);if(r){const o=r[2],i=v[r[4]]||r[4],s=r[6];switch(r[1]){case"pub":{g++;const a={id:`${n}#delegate-${g}`,type:`${o}${i}`,controller:n};switch(a.type=m[a.type]||o,s){case null:case void 0:case"hex":a.publicKeyHex=e.value.slice(2);break;case"base64":a.publicKeyBase64=Buffer.from(e.value.slice(2),"hex").toString("base64");break;case"base58":a.publicKeyBase58=t.Base58.encode(Buffer.from(e.value.slice(2),"hex"));break;case"pem":a.publicKeyPem=Buffer.from(e.value.slice(2),"hex").toString();break;default:a.value=e.value}b[c]=a,"sigAuth"===r[4]&&(y[c]=a.id);break}case"svc":p++,w[c]={id:`${n}#service-${p}`,type:o,serviceEndpoint:Buffer.from(e.value.slice(2),"hex").toString()}}}}}else if(o._eventName===l.DIDDelegateChanged||o._eventName===l.DIDAttributeChanged&&o.name.match(/^did\/pub\//)?g++:o._eventName===l.DIDAttributeChanged&&o.name.match(/^did\/svc\//)&&p++,delete y[c],delete b[c],delete w[c],o._eventName===l.DIDOwnerChanged&&"0x0000000000000000000000000000000000000000"===o.owner){f=!0;break}}const D={...a,verificationMethod:u.concat(Object.values(b)),authentication:h.concat(Object.values(y))};return Object.values(w).length>0&&(D.service=Object.values(w)),f?{didDocument:{...a,"@context":"https://www.w3.org/ns/did/v1"},deactivated:f}:{didDocument:D,deactivated:f}}resolve(t,r,n,o){try{const n=this,i=r.id.match(u);if(!i)return Promise.resolve({didResolutionMetadata:{error:e.Errors.invalidDid,message:`Not a valid did:ethr: ${r.id}`},didDocumentMetadata:{},didDocument:null});const c=i[2],s=i[1]?i[1].slice(0,-1):"mainnet";return n.contracts[s]?Promise.resolve(n.changeLog(c,s,o.blockTag)).then(function({controller:r,history:o,controllerKey:i,chainId:c}){try{const{didDocument:e,deactivated:s}=n.wrapDidDocument(t,r,i,o,c);return{didDocumentMetadata:{...s?{deactivated:!0}:{}},didResolutionMetadata:{contentType:"application/did+ld+json"},didDocument:e}}catch(t){return{didResolutionMetadata:{error:e.Errors.notFound,message:t.toString()},didDocumentMetadata:{},didDocument:null}}}):Promise.resolve({didResolutionMetadata:{error:e.Errors.unknownNetwork,message:`The DID resolver does not have a configuration for network: ${s}`},didDocumentMetadata:{},didDocument:null})}catch(e){return Promise.reject(e)}}build(){return{ethr:this.resolve.bind(this)}}}e.REGISTRY=h,e.attrTypes=v,e.bytes32toString=g,e.delegateTypes=m,e.getResolver=function(e){return new A(e).build()},e.identifierMatcher=u,e.stringToBytes32=p});
//# sourceMappingURL=index.umd.js.map
{
"name": "ethr-did-resolver",
"version": "3.1.0",
"version": "4.0.0",
"description": "Resolve DID documents around ethereum addresses",

@@ -56,25 +56,22 @@ "main": "lib/index.umd.js",

"devDependencies": {
"@babel/core": "^7.13.10",
"@babel/preset-env": "^7.13.10",
"@babel/preset-typescript": "^7.13.0",
"@commitlint/cli": "^12.0.1",
"@commitlint/config-conventional": "^12.0.1",
"@babel/core": "7.13.10",
"@babel/preset-env": "7.13.10",
"@babel/preset-typescript": "7.13.0",
"@semantic-release/changelog": "5.0.1",
"@semantic-release/git": "9.0.0",
"@types/jest": "^26.0.20",
"@typescript-eslint/eslint-plugin": "^4.17.0",
"@typescript-eslint/parser": "^4.17.0",
"babel-jest": "^26.6.3",
"@types/jest": "26.0.20",
"@typescript-eslint/eslint-plugin": "4.17.0",
"@typescript-eslint/parser": "4.17.0",
"babel-jest": "26.6.3",
"codecov": "3.8.1",
"eslint": "^7.21.0",
"eslint-config-prettier": "^8.1.0",
"ganache-cli": "^6.12.2",
"husky": "^5.1.3",
"eslint": "7.21.0",
"eslint-config-prettier": "8.1.0",
"ganache-cli": "6.12.2",
"jest": "26.6.3",
"microbundle": "^0.13.0",
"prettier": "^2.2.1",
"pretty-quick": "^3.1.0",
"semantic-release": "^17.4.1",
"typescript": "^4.2.3",
"uint8arrays": "^2.1.3"
"microbundle": "0.13.0",
"prettier": "2.2.1",
"pretty-quick": "3.1.0",
"semantic-release": "17.4.1",
"typescript": "4.2.3",
"uint8arrays": "2.1.3"
},

@@ -81,0 +78,0 @@ "dependencies": {

@@ -179,12 +179,3 @@ import { Resolver } from 'did-resolver'

})
it('throws on resolving unconfigured network', async () => {
expect.assertions(1)
const ethr = getResolver({ networks: [{ name: 'rsk', rpcUrl: 'https://did.rsk.co:4444' }] })
const resolver = new Resolver(ethr)
await expect(
resolver.resolve('did:ethr:zrx:0x03fdd57adec3d438ea237fe46b33ee1e016eda6b585c3e27ea66686c2ea5358479')
).rejects.toThrowError('unknown_network: The DID resolver does not have a configuration for network: zrx')
})
})
})

@@ -982,11 +982,2 @@ import { Contract, ContractFactory } from '@ethersproject/contracts'

})
describe('error handling', () => {
it('rejects promise', async () => {
expect.assertions(1)
await expect(didResolver.resolve('did:ethr:2nQtiQG6Cgm1GYTBaaKAgr76uY7iSexUkqX')).rejects.toEqual(
new Error('Not a valid ethr DID: did:ethr:2nQtiQG6Cgm1GYTBaaKAgr76uY7iSexUkqX')
)
})
})
})

@@ -5,3 +5,3 @@ import { BigNumber } from '@ethersproject/bignumber'

import DidRegistryContract from 'ethr-did-registry'
import { DEFAULT_REGISTRY_ADDRESS, knownNetworks } from './helpers'
import { DEFAULT_REGISTRY_ADDRESS, knownInfuraNetworks, knownNetworks } from './helpers'

@@ -61,4 +61,5 @@ /**

if (conf.rpcUrl) {
const chainId = conf.chainId ? BigNumber.from(conf.chainId).toNumber() : conf.chainId
const networkName = knownNetworks[conf.name || ''] ? conf.name?.replace('mainnet', 'homestead') : 'any'
const chainIdRaw = conf.chainId ? conf.chainId : knownNetworks[conf.name || '']
const chainId = chainIdRaw ? BigNumber.from(chainIdRaw).toNumber() : chainIdRaw
const networkName = knownInfuraNetworks[conf.name || ''] ? conf.name?.replace('mainnet', 'homestead') : 'any'
provider = new JsonRpcProvider(conf.rpcUrl, chainId || networkName)

@@ -65,0 +66,0 @@ } else {

@@ -101,3 +101,3 @@ import { getAddress } from '@ethersproject/address'

const knownInfuraNetworks: Record<string, string> = {
export const knownInfuraNetworks: Record<string, string> = {
mainnet: '0x1',

@@ -112,2 +112,27 @@ ropsten: '0x3',

...knownInfuraNetworks,
rsk: '0x1e',
'rsk:testnet': '0x1f',
artis_t1: '0x03c401',
artis_s1: '0x03c301',
matic: '0x89',
maticmum: '0x13881',
}
export enum Errors {
/**
* The resolver has failed to construct the DID document.
* This can be caused by a network issue, a wrong registry address or malformed logs while parsing the registry history.
* Please inspect the `DIDResolutionMetadata.message` to debug further.
*/
notFound = 'notFound',
/**
* The resolver does not know how to resolve the given DID. Most likely it is not a `did:ethr`.
*/
invalidDid = 'invalidDid',
/**
* The resolver is misconfigured or is being asked to resolve a DID anchored on an unknown network
*/
unknownNetwork = 'unknownNetwork',
}

@@ -10,2 +10,3 @@ import { getResolver } from './resolver'

verificationMethodTypes,
Errors,
} from './helpers'

@@ -24,2 +25,3 @@

identifierMatcher,
Errors,
}

@@ -30,2 +30,3 @@ import { Base58 } from '@ethersproject/basex'

knownNetworks,
Errors,
} from './helpers'

@@ -284,3 +285,10 @@ import { logDecoder } from './logParser'

if (!fullId) {
throw new Error(`Not a valid ethr DID: ${did}`)
return {
didResolutionMetadata: {
error: Errors.invalidDid,
message: `Not a valid did:ethr: ${parsed.id}`,
},
didDocumentMetadata: {},
didDocument: null,
}
}

@@ -290,4 +298,12 @@ const id = fullId[2]

if (!this.contracts[networkId])
throw new Error(`unknown_network: The DID resolver does not have a configuration for network: ${networkId}`)
if (!this.contracts[networkId]) {
return {
didResolutionMetadata: {
error: Errors.unknownNetwork,
message: `The DID resolver does not have a configuration for network: ${networkId}`,
},
didDocumentMetadata: {},
didDocument: null,
}
}

@@ -306,3 +322,3 @@ const { controller, history, controllerKey, chainId } = await this.changeLog(id, networkId, options.blockTag)

didResolutionMetadata: {
error: 'notFound',
error: Errors.notFound,
message: e.toString(), // This is not in spec, nut may be helpful

@@ -309,0 +325,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc