New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

uport-credentials

Package Overview
Dependencies
Maintainers
10
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uport-credentials - npm Package Compare versions

Comparing version 1.3.3 to 1.3.4

lib/index.esm.js

8

CHANGELOG.md

@@ -0,1 +1,9 @@

## [1.3.4](https://github.com/uport-project/uport-credentials/compare/1.3.3...1.3.4) (2020-08-07)
### Bug Fixes
* **deps:** update dependency elliptic to v6.5.3 [security] ([#241](https://github.com/uport-project/uport-credentials/issues/241)) ([b601c62](https://github.com/uport-project/uport-credentials/commit/b601c625ff3d7ae84ba2acc51e82aa6c5ef8ed21))
* make ClaimSpec.user_info and VerifiableClaimSpec.iss optional ([#251](https://github.com/uport-project/uport-credentials/issues/251)) ([d598623](https://github.com/uport-project/uport-credentials/commit/d598623d3a1c0d2dfbfd1b1ed0ad3756614016e4)), closes [#250](https://github.com/uport-project/uport-credentials/issues/250)
## [1.3.3](https://github.com/uport-project/uport-credentials/compare/1.3.2...1.3.3) (2020-06-11)

@@ -2,0 +10,0 @@

2

lib/Contract.d.ts

@@ -54,4 +54,4 @@ export interface TransactionRequest {

}
export declare const ContractFactory: (encoder?: (tx: any, params?: any) => any) => (contractABI: (AbiFunction | AbiEvent)[]) => Factory;
export declare const ContractFactory: (encoder?: (tx: any, params?: any) => any) => (contractABI: ContractABI) => Factory;
export {};
//# sourceMappingURL=Contract.d.ts.map

@@ -54,3 +54,3 @@ import { Signer } from 'did-jwt';

interface VerifiableClaimSpec extends ClaimSpec {
iss: IssuerSpec[];
iss?: IssuerSpec[];
}

@@ -65,3 +65,3 @@ interface VerifiableClaimsSpec {

verifiable: VerifiableClaimsSpec;
user_info: UserInfoSpec;
user_info?: UserInfoSpec;
}

@@ -266,8 +266,5 @@ interface DisclosureRequestParams {

* application's uPort identity)
* @param {Object} [settings.networks] DEPRECATED networks config object, ie. { '0x94365e3b': {
* rpcUrl: 'https://private.chain/rpc', address: '0x0101.... }}
* @param {UportLite} [settings.registry] DEPRECATED a registry object from UportLite
* @return {Credentials} self
*/
constructor({ did, address, privateKey, signer, networks, registry, ethrConfig, resolver }: Settings);
constructor({ did, address, privateKey, signer, ethrConfig, resolver }: Settings);
signJWT(payload: object, expiresIn?: number): Promise<string>;

@@ -274,0 +271,0 @@ /**

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

var e,r,t,i=require("elliptic"),n=require("did-jwt-vc"),o=(e=require("ethr-did-resolver"))&&"object"==typeof e&&"default"in e?e.default:e,s=require("web-did-resolver"),a=require("did-resolver"),c=require("mnid"),u=require("did-jwt");!function(e){e.Function="function",e.Event="event",e.Constructor="constructor",e.Fallback="fallback"}(r||(r={})),function(e){e.Pure="pure",e.View="view",e.NonPayable="nonpayable",e.Payable="payable"}(t||(t={}));var d,l=function(e,r){for(var t=e.name+"(",i=e.inputs||[],n=0;n<i.length;n++){var o=i[n],s=o.type+" ";t+=s+="string"===o.type?'"'+r[n]+'"':""+r[n],i.length-1!==n&&(t+=", ")}return t+")"},p=function(e){return function(t){return{at:function(i){var n={};return function(e){return e.filter(function(e){return e.type===r.Function&&e.name&&!e.constant})}(t).forEach(function(r){r.name&&(n[r.name]=function(){var t={},n=[].slice.call(arguments),o=(r.inputs||[]).length;(function(e){if("object"!=typeof e)return!1;if(0===Object.keys(e).length)return!0;for(var r=0,t=["from","to","data","value","gasPrice","gas"];r<t.length;r+=1)if(t[r]in e)return!0;return!1})(n[o])&&(t=n.splice(o,1)[0]);var s=Object.assign({},t,{to:i,function:l(r,n)});return e?e(s,n[n.length-1]):s})}),Object.assign({},n,{abi:t,address:i})}}}},v=new i.ec("secp256k1");!function(e){e.DISCLOSURE_REQUEST="shareReq",e.DISCLOSURE_RESPONSE="shareResp",e.TYPED_DATA_SIGNATURE_REQUEST="eip712Req",e.VERIFICATION_SIGNATURE_REQUEST="verReq",e.ETH_TX_REQUEST="ethtx",e.PERSONAL_SIGN_REQUEST="personalSigReq",e.PRESENTATION_REQUEST="presentationReq"}(d||(d={}));var f=function(e){var r=e.did,t=e.address,i=e.privateKey,n=e.signer,d=e.ethrConfig,l=e.resolver;if(n?this.signer=n:i&&(this.signer=u.SimpleSigner(i)),r)this.did=r;else if(t)c.isMNID(t)&&(this.did="did:uport:"+t),t.match("^0x[0-9a-fA-F]{40}$")&&(this.did="did:ethr:"+t);else if(i){var p=v.keyFromPrivate(i),f=u.toEthereumAddress(p.getPublic("hex"));this.did="did:ethr:"+f}if(l)this.resolver=l;else{var h=o.getResolver(d||{}),y=s.getResolver();this.resolver=new a.Resolver(Object.assign({},y,h))}};f.createIdentity=function(){var e=v.genKeyPair(),r=e.getPublic("hex"),t=e.getPrivate("hex");return{did:"did:ethr:"+u.toEthereumAddress(r),privateKey:t}},f.prototype.signJWT=function(e,r){return this.did&&this.signer?u.createJWT(e,{issuer:this.did,signer:this.signer,alg:this.did.match("^did:uport:")||c.isMNID(this.did)?"ES256K":"ES256K-R",expiresIn:r}):Promise.reject(new Error("No Signing Identity configured"))},f.prototype.createDisclosureRequest=function(e,r){void 0===e&&(e={}),void 0===r&&(r=600);var t={};if(e.requested&&(t.requested=e.requested),e.verified&&(t.verified=e.verified),e.claims&&(t.claims=e.claims),e.notifications&&(t.permissions=["notifications"]),e.callbackUrl&&(t.callback=e.callbackUrl),e.networkId&&(t.net=e.networkId),e.rpcUrl){if(!e.networkId)return Promise.reject(new Error("rpcUrl was specified but no networkId"));t.rpc=e.rpcUrl}if(e.vc&&(t.vc=e.vc),e.exp&&(t.exp=e.exp),e.accountType){if(!(["general","segregated","keypair","none"].indexOf(e.accountType)>=0))return Promise.reject(new Error("Unsupported accountType "+e.accountType));t.act=e.accountType}return e.boxPub&&(t.boxPub=e.boxPub),this.signJWT(Object.assign({},t,{type:d.DISCLOSURE_REQUEST}),e.exp?void 0:r)},f.prototype.createVerification=function(e){return this.signJWT({sub:e.sub,claim:e.claim,exp:e.exp,vc:e.vc,callbackUrl:e.callbackUrl})},f.prototype.createVerificationSignatureRequest=function(e,r){return this.signJWT({unsignedClaim:e,sub:r.sub,riss:r.riss,aud:r.aud,vc:r.vc,callback:r.callbackUrl,type:d.VERIFICATION_SIGNATURE_REQUEST,rexp:r.rexp},r.expiresIn)},f.prototype.createTypedDataSignatureRequest=function(e,r){void 0===r&&(r={});var t=r.from,i=r.net,n=r.callback;try{for(var o=0,s=["types","primaryType","message","domain"];o<s.length;o+=1){var a=s[o];if(!e[a])throw new Error("Invalid EIP712 Request, must include '"+a+"'")}return Promise.resolve(this.signJWT({typedData:e,from:t,net:i,callback:n,type:d.TYPED_DATA_SIGNATURE_REQUEST}))}catch(e){return Promise.reject(e)}},f.prototype.createPersonalSignRequest=function(e,r){return void 0===r&&(r={}),this.signJWT({data:e,from:r.from,net:r.net,callback:r.callback,type:d.PERSONAL_SIGN_REQUEST})},f.prototype.createTxRequest=function(e,r){void 0===r&&(r={});var t=r.callbackUrl,i=r.exp;void 0===i&&(i=600);var n=r.networkId,o=r.label,s={};return t&&(s.callback=t),n&&(s.net=n),o&&(s.label=o),this.signJWT(Object.assign({},s,e,{type:d.ETH_TX_REQUEST}),i)},f.prototype.createDisclosureResponse=function(e,r){void 0===e&&(e={}),void 0===r&&(r=600);try{var t=this;function i(){return t.signJWT(Object.assign({},e,{type:d.DISCLOSURE_RESPONSE}),r)}var n=function(){if(e.req)return Promise.resolve(u.verifyJWT(e.req,{resolver:t.resolver})).then(function(r){r.issuer&&(e.aud=r.issuer)})}();return Promise.resolve(n&&n.then?n.then(i):i())}catch(e){return Promise.reject(e)}},f.prototype.processDisclosurePayload=function(e){var r=e.doc,t=e.payload;try{var i=this,n=t.own;void 0===n&&(n={});var o=t.capabilities;void 0===o&&(o=[]);var s=t.nad,a=t.dad,d=t.iss,l=t.boxPub,p=t.verified,v=function(e,r){var t={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&-1===r.indexOf(i)&&(t[i]=e[i]);return t}(t,["own","capabilities","aud","req","iat","exp","type","nad","dad","iss","boxPub","verified"]),f=r.uportProfile;void 0===f&&(f={});var h=Object.assign({},{did:d,boxPub:l},n,f,v);a&&(h.deviceKey=a),s&&(h.mnid=s,h.address=c.decode(s).address),1===o.length&&(h.pushToken=o[0]);var y=function(){if(p){var e=[],r=p.map(function(r){return u.verifyJWT(r,{resolver:i.resolver,audience:i.did}).catch(function(){return e.push(r),Promise.resolve(void 0)})});return Promise.resolve(Promise.all(r)).then(function(r){var t=[];r.forEach(function(e){e&&t.push(Object.assign({},e.payload,{jwt:e.jwt}))}),h.verified=t,h.invalid=e})}}();return Promise.resolve(y&&y.then?y.then(function(){return h}):h)}catch(e){return Promise.reject(e)}},f.prototype.authenticateDisclosureResponse=function(e,r){try{var t=this;return Promise.resolve(u.verifyJWT(e,{resolver:t.resolver,audience:t.did,callbackUrl:r,auth:!0})).then(function(e){var r=e.payload,i=e.doc;if(r.req)return Promise.resolve(u.verifyJWT(r.req,{resolver:t.resolver,audience:t.did})).then(function(e){var n=e.payload;if(n.type!==d.DISCLOSURE_REQUEST)throw new Error("Challenge payload type invalid: "+n.type);return t.processDisclosurePayload({payload:r,doc:i})});throw new Error("Challenge was not included in response")})}catch(e){return Promise.reject(e)}},f.prototype.verifyDisclosure=function(e){try{var r=this;return Promise.resolve(u.verifyJWT(e,{resolver:r.resolver,audience:r.did})).then(function(e){return r.processDisclosurePayload({payload:e.payload,doc:e.doc})})}catch(e){return Promise.reject(e)}},f.prototype.issueVerifiableCredential=function(e){try{return this.did&&this.signer?Promise.resolve(n.createVerifiableCredential(e,{did:this.did,signer:this.signer})):Promise.reject(new Error("No Signing Identity configured"))}catch(e){return Promise.reject(e)}},f.prototype.verifyPresentation=function(e){try{return Promise.resolve(n.verifyPresentation(e,this.resolver))}catch(e){return Promise.reject(e)}},f.prototype.contract=function(e){var r=this;return p(function(e,t){return e.function&&(e.fn=e.function),delete e.function,r.createTxRequest(e,t)}.bind(this))(e)},exports.SimpleSigner=u.SimpleSigner,exports.Credentials=f,exports.ContractFactory=p;
var e,r,t,i=require("elliptic"),n=require("did-jwt"),o=require("did-jwt-vc"),s=(e=require("ethr-did-resolver"))&&"object"==typeof e&&"default"in e?e.default:e,a=require("web-did-resolver"),c=require("did-resolver"),u=require("mnid");function l(){return(l=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e}).apply(this,arguments)}!function(e){e.Function="function",e.Event="event",e.Constructor="constructor",e.Fallback="fallback"}(r||(r={})),function(e){e.Pure="pure",e.View="view",e.NonPayable="nonpayable",e.Payable="payable"}(t||(t={}));var d,f=function(e){if("object"!=typeof e)return!1;if(0===Object.keys(e).length)return!0;for(var r=0,t=["from","to","data","value","gasPrice","gas"];r<t.length;r++)if(t[r]in e)return!0;return!1},v=function(e,r){for(var t=e.name+"(",i=e.inputs||[],n=0;n<i.length;n++){var o=i[n],s=o.type+" ";t+=s+="string"===o.type?'"'+r[n]+'"':""+r[n],i.length-1!==n&&(t+=", ")}return t+")"},p=function(e){return function(t){return{at:function(i){var n={};return function(e){return e.filter(function(e){return e.type===r.Function&&e.name&&!e.constant})}(t).forEach(function(r){r.name&&(n[r.name]=function(){var t={},n=[].slice.call(arguments),o=(r.inputs||[]).length;f(n[o])&&(t=n.splice(o,1)[0]);var s=l({},t,{to:i,function:v(r,n)});if(!e)return s;var a=n[n.length-1];return e(s,a)})}),l({},n,{abi:t,address:i})}}}},h=new i.ec("secp256k1");!function(e){e.DISCLOSURE_REQUEST="shareReq",e.DISCLOSURE_RESPONSE="shareResp",e.TYPED_DATA_SIGNATURE_REQUEST="eip712Req",e.VERIFICATION_SIGNATURE_REQUEST="verReq",e.ETH_TX_REQUEST="ethtx",e.PERSONAL_SIGN_REQUEST="personalSigReq",e.PRESENTATION_REQUEST="presentationReq"}(d||(d={}));var y=function(){function e(e){var r=e.did,t=e.address,i=e.privateKey,o=e.signer,d=e.ethrConfig,f=e.resolver;if(o?this.signer=o:i&&(this.signer=n.SimpleSigner(i)),r)this.did=r;else if(t)u.isMNID(t)&&(this.did="did:uport:"+t),t.match("^0x[0-9a-fA-F]{40}$")&&(this.did="did:ethr:"+t);else if(i){var v=h.keyFromPrivate(i),p=n.toEthereumAddress(v.getPublic("hex"));this.did="did:ethr:"+p}if(f)this.resolver=f;else{var y=s.getResolver(d||{}),E=a.getResolver();this.resolver=new c.Resolver(l({},E,y,{https:E.web}))}}e.createIdentity=function(){var e=h.genKeyPair(),r=e.getPublic("hex"),t=e.getPrivate("hex");return{did:"did:ethr:"+n.toEthereumAddress(r),privateKey:t}};var r=e.prototype;return r.signJWT=function(e,r){return this.did&&this.signer?n.createJWT(e,{issuer:this.did,signer:this.signer,alg:this.did.match("^did:uport:")||u.isMNID(this.did)?"ES256K":"ES256K-R",expiresIn:r}):Promise.reject(new Error("No Signing Identity configured"))},r.createDisclosureRequest=function(e,r){void 0===e&&(e={}),void 0===r&&(r=600);var t={};if(e.requested&&(t.requested=e.requested),e.verified&&(t.verified=e.verified),e.claims&&(t.claims=e.claims),e.notifications&&(t.permissions=["notifications"]),e.callbackUrl&&(t.callback=e.callbackUrl),e.networkId&&(t.net=e.networkId),e.rpcUrl){if(!e.networkId)return Promise.reject(new Error("rpcUrl was specified but no networkId"));t.rpc=e.rpcUrl}if(e.vc&&(t.vc=e.vc),e.exp&&(t.exp=e.exp),e.accountType){if(!(["general","segregated","keypair","none"].indexOf(e.accountType)>=0))return Promise.reject(new Error("Unsupported accountType "+e.accountType));t.act=e.accountType}return e.boxPub&&(t.boxPub=e.boxPub),this.signJWT(l({},t,{type:d.DISCLOSURE_REQUEST}),e.exp?void 0:r)},r.createVerification=function(e){return this.signJWT({sub:e.sub,claim:e.claim,exp:e.exp,vc:e.vc,callbackUrl:e.callbackUrl})},r.createVerificationSignatureRequest=function(e,r){return this.signJWT({unsignedClaim:e,sub:r.sub,riss:r.riss,aud:r.aud,vc:r.vc,callback:r.callbackUrl,type:d.VERIFICATION_SIGNATURE_REQUEST,rexp:r.rexp},r.expiresIn)},r.createTypedDataSignatureRequest=function(e,r){var t=void 0===r?{}:r,i=t.from,n=t.net,o=t.callback;try{for(var s=0,a=["types","primaryType","message","domain"];s<a.length;s++){var c=a[s];if(!e[c])throw new Error("Invalid EIP712 Request, must include '"+c+"'")}return Promise.resolve(this.signJWT({typedData:e,from:i,net:n,callback:o,type:d.TYPED_DATA_SIGNATURE_REQUEST}))}catch(e){return Promise.reject(e)}},r.createPersonalSignRequest=function(e,r){var t=void 0===r?{}:r;return this.signJWT({data:e,from:t.from,net:t.net,callback:t.callback,type:d.PERSONAL_SIGN_REQUEST})},r.createTxRequest=function(e,r){var t=void 0===r?{}:r,i=t.callbackUrl,n=t.exp,o=void 0===n?600:n,s=t.networkId,a=t.label,c={};return i&&(c.callback=i),s&&(c.net=s),a&&(c.label=a),this.signJWT(l({},c,e,{type:d.ETH_TX_REQUEST}),o)},r.createDisclosureResponse=function(e,r){void 0===e&&(e={}),void 0===r&&(r=600);try{var t=function(){return i.signJWT(l({},e,{type:d.DISCLOSURE_RESPONSE}),r)},i=this,o=function(){if(e.req)return Promise.resolve(n.verifyJWT(e.req,{resolver:i.resolver})).then(function(r){r.issuer&&(e.aud=r.issuer)})}();return Promise.resolve(o&&o.then?o.then(t):t())}catch(e){return Promise.reject(e)}},r.processDisclosurePayload=function(e){var r=e.doc,t=e.payload;try{var i=this,o=t.own,s=void 0===o?{}:o,a=t.capabilities,c=void 0===a?[]:a,d=t.nad,f=t.dad,v=t.iss,p=t.boxPub,h=t.verified,y=function(e,r){if(null==e)return{};var t,i,n={},o=Object.keys(e);for(i=0;i<o.length;i++)r.indexOf(t=o[i])>=0||(n[t]=e[t]);return n}(t,["own","capabilities","aud","req","iat","exp","type","nad","dad","iss","boxPub","verified"]),E=r.uportProfile,g=l({did:v,boxPub:p},s,void 0===E?{}:E,y);f&&(g.deviceKey=f),d&&(g.mnid=d,g.address=u.decode(d).address),1===c.length&&(g.pushToken=c[0]);var b=function(){if(h){var e=[],r=h.map(function(r){return n.verifyJWT(r,{resolver:i.resolver,audience:i.did}).catch(function(){return e.push(r),Promise.resolve(void 0)})});return Promise.resolve(Promise.all(r)).then(function(r){var t=[];r.forEach(function(e){e&&t.push(l({},e.payload,{jwt:e.jwt}))}),g.verified=t,g.invalid=e})}}();return Promise.resolve(b&&b.then?b.then(function(){return g}):g)}catch(e){return Promise.reject(e)}},r.authenticateDisclosureResponse=function(e,r){try{var t=this;return Promise.resolve(n.verifyJWT(e,{resolver:t.resolver,audience:t.did,callbackUrl:r,auth:!0})).then(function(e){var r=e.payload,i=e.doc;if(r.req)return Promise.resolve(n.verifyJWT(r.req,{resolver:t.resolver,audience:t.did})).then(function(e){var n=e.payload;if(n.type!==d.DISCLOSURE_REQUEST)throw new Error("Challenge payload type invalid: "+n.type);return t.processDisclosurePayload({payload:r,doc:i})});throw new Error("Challenge was not included in response")})}catch(e){return Promise.reject(e)}},r.verifyDisclosure=function(e){try{var r=this;return Promise.resolve(n.verifyJWT(e,{resolver:r.resolver,audience:r.did})).then(function(e){return r.processDisclosurePayload({payload:e.payload,doc:e.doc})})}catch(e){return Promise.reject(e)}},r.issueVerifiableCredential=function(e){try{return this.did&&this.signer?Promise.resolve(o.createVerifiableCredential(e,{did:this.did,signer:this.signer})):Promise.reject(new Error("No Signing Identity configured"))}catch(e){return Promise.reject(e)}},r.verifyPresentation=function(e){try{return Promise.resolve(o.verifyPresentation(e,this.resolver))}catch(e){return Promise.reject(e)}},r.contract=function(e){var r=this;return p(function(e,t){return e.function&&(e.fn=e.function),delete e.function,r.createTxRequest(e,t)}.bind(this))(e)},e}();Object.defineProperty(exports,"SimpleSigner",{enumerable:!0,get:function(){return n.SimpleSigner}}),exports.ContractFactory=p,exports.Credentials=y;
//# sourceMappingURL=index.js.map

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

!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("elliptic"),require("did-jwt-vc"),require("ethr-did-resolver"),require("web-did-resolver"),require("did-resolver"),require("mnid"),require("did-jwt")):"function"==typeof define&&define.amd?define(["exports","elliptic","did-jwt-vc","ethr-did-resolver","web-did-resolver","did-resolver","mnid","did-jwt"],r):r(e.uportCredentials={},e.elliptic,e.didJwtVc,e.EthrDIDResolver,e.WebDidResolver,e.didResolver,e.mnid,e.didJwt)}(this,function(e,r,t,i,n,o,s,a){var c,d;i=i&&i.hasOwnProperty("default")?i.default:i,function(e){e.Function="function",e.Event="event",e.Constructor="constructor",e.Fallback="fallback"}(c||(c={})),function(e){e.Pure="pure",e.View="view",e.NonPayable="nonpayable",e.Payable="payable"}(d||(d={}));var u,l=function(e,r){for(var t=e.name+"(",i=e.inputs||[],n=0;n<i.length;n++){var o=i[n],s=o.type+" ";t+=s+="string"===o.type?'"'+r[n]+'"':""+r[n],i.length-1!==n&&(t+=", ")}return t+")"},p=function(e){return function(r){return{at:function(t){var i={};return function(e){return e.filter(function(e){return e.type===c.Function&&e.name&&!e.constant})}(r).forEach(function(r){r.name&&(i[r.name]=function(){var i={},n=[].slice.call(arguments),o=(r.inputs||[]).length;(function(e){if("object"!=typeof e)return!1;if(0===Object.keys(e).length)return!0;for(var r=0,t=["from","to","data","value","gasPrice","gas"];r<t.length;r+=1)if(t[r]in e)return!0;return!1})(n[o])&&(i=n.splice(o,1)[0]);var s=Object.assign({},i,{to:t,function:l(r,n)});return e?e(s,n[n.length-1]):s})}),Object.assign({},i,{abi:r,address:t})}}}},v=new r.ec("secp256k1");!function(e){e.DISCLOSURE_REQUEST="shareReq",e.DISCLOSURE_RESPONSE="shareResp",e.TYPED_DATA_SIGNATURE_REQUEST="eip712Req",e.VERIFICATION_SIGNATURE_REQUEST="verReq",e.ETH_TX_REQUEST="ethtx",e.PERSONAL_SIGN_REQUEST="personalSigReq",e.PRESENTATION_REQUEST="presentationReq"}(u||(u={}));var f=function(e){var r=e.did,t=e.address,c=e.privateKey,d=e.signer,u=e.ethrConfig,l=e.resolver;if(d?this.signer=d:c&&(this.signer=a.SimpleSigner(c)),r)this.did=r;else if(t)s.isMNID(t)&&(this.did="did:uport:"+t),t.match("^0x[0-9a-fA-F]{40}$")&&(this.did="did:ethr:"+t);else if(c){var p=v.keyFromPrivate(c),f=a.toEthereumAddress(p.getPublic("hex"));this.did="did:ethr:"+f}if(l)this.resolver=l;else{var h=i.getResolver(u||{}),y=n.getResolver();this.resolver=new o.Resolver(Object.assign({},y,h))}};f.createIdentity=function(){var e=v.genKeyPair(),r=e.getPublic("hex"),t=e.getPrivate("hex");return{did:"did:ethr:"+a.toEthereumAddress(r),privateKey:t}},f.prototype.signJWT=function(e,r){return this.did&&this.signer?a.createJWT(e,{issuer:this.did,signer:this.signer,alg:this.did.match("^did:uport:")||s.isMNID(this.did)?"ES256K":"ES256K-R",expiresIn:r}):Promise.reject(new Error("No Signing Identity configured"))},f.prototype.createDisclosureRequest=function(e,r){void 0===e&&(e={}),void 0===r&&(r=600);var t={};if(e.requested&&(t.requested=e.requested),e.verified&&(t.verified=e.verified),e.claims&&(t.claims=e.claims),e.notifications&&(t.permissions=["notifications"]),e.callbackUrl&&(t.callback=e.callbackUrl),e.networkId&&(t.net=e.networkId),e.rpcUrl){if(!e.networkId)return Promise.reject(new Error("rpcUrl was specified but no networkId"));t.rpc=e.rpcUrl}if(e.vc&&(t.vc=e.vc),e.exp&&(t.exp=e.exp),e.accountType){if(!(["general","segregated","keypair","none"].indexOf(e.accountType)>=0))return Promise.reject(new Error("Unsupported accountType "+e.accountType));t.act=e.accountType}return e.boxPub&&(t.boxPub=e.boxPub),this.signJWT(Object.assign({},t,{type:u.DISCLOSURE_REQUEST}),e.exp?void 0:r)},f.prototype.createVerification=function(e){return this.signJWT({sub:e.sub,claim:e.claim,exp:e.exp,vc:e.vc,callbackUrl:e.callbackUrl})},f.prototype.createVerificationSignatureRequest=function(e,r){return this.signJWT({unsignedClaim:e,sub:r.sub,riss:r.riss,aud:r.aud,vc:r.vc,callback:r.callbackUrl,type:u.VERIFICATION_SIGNATURE_REQUEST,rexp:r.rexp},r.expiresIn)},f.prototype.createTypedDataSignatureRequest=function(e,r){void 0===r&&(r={});var t=r.from,i=r.net,n=r.callback;try{for(var o=0,s=["types","primaryType","message","domain"];o<s.length;o+=1){var a=s[o];if(!e[a])throw new Error("Invalid EIP712 Request, must include '"+a+"'")}return Promise.resolve(this.signJWT({typedData:e,from:t,net:i,callback:n,type:u.TYPED_DATA_SIGNATURE_REQUEST}))}catch(e){return Promise.reject(e)}},f.prototype.createPersonalSignRequest=function(e,r){return void 0===r&&(r={}),this.signJWT({data:e,from:r.from,net:r.net,callback:r.callback,type:u.PERSONAL_SIGN_REQUEST})},f.prototype.createTxRequest=function(e,r){void 0===r&&(r={});var t=r.callbackUrl,i=r.exp;void 0===i&&(i=600);var n=r.networkId,o=r.label,s={};return t&&(s.callback=t),n&&(s.net=n),o&&(s.label=o),this.signJWT(Object.assign({},s,e,{type:u.ETH_TX_REQUEST}),i)},f.prototype.createDisclosureResponse=function(e,r){void 0===e&&(e={}),void 0===r&&(r=600);try{var t=this;function i(){return t.signJWT(Object.assign({},e,{type:u.DISCLOSURE_RESPONSE}),r)}var n=function(){if(e.req)return Promise.resolve(a.verifyJWT(e.req,{resolver:t.resolver})).then(function(r){r.issuer&&(e.aud=r.issuer)})}();return Promise.resolve(n&&n.then?n.then(i):i())}catch(e){return Promise.reject(e)}},f.prototype.processDisclosurePayload=function(e){var r=e.doc,t=e.payload;try{var i=this,n=t.own;void 0===n&&(n={});var o=t.capabilities;void 0===o&&(o=[]);var c=t.nad,d=t.dad,u=t.iss,l=t.boxPub,p=t.verified,v=function(e,r){var t={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&-1===r.indexOf(i)&&(t[i]=e[i]);return t}(t,["own","capabilities","aud","req","iat","exp","type","nad","dad","iss","boxPub","verified"]),f=r.uportProfile;void 0===f&&(f={});var h=Object.assign({},{did:u,boxPub:l},n,f,v);d&&(h.deviceKey=d),c&&(h.mnid=c,h.address=s.decode(c).address),1===o.length&&(h.pushToken=o[0]);var y=function(){if(p){var e=[],r=p.map(function(r){return a.verifyJWT(r,{resolver:i.resolver,audience:i.did}).catch(function(){return e.push(r),Promise.resolve(void 0)})});return Promise.resolve(Promise.all(r)).then(function(r){var t=[];r.forEach(function(e){e&&t.push(Object.assign({},e.payload,{jwt:e.jwt}))}),h.verified=t,h.invalid=e})}}();return Promise.resolve(y&&y.then?y.then(function(){return h}):h)}catch(e){return Promise.reject(e)}},f.prototype.authenticateDisclosureResponse=function(e,r){try{var t=this;return Promise.resolve(a.verifyJWT(e,{resolver:t.resolver,audience:t.did,callbackUrl:r,auth:!0})).then(function(e){var r=e.payload,i=e.doc;if(r.req)return Promise.resolve(a.verifyJWT(r.req,{resolver:t.resolver,audience:t.did})).then(function(e){var n=e.payload;if(n.type!==u.DISCLOSURE_REQUEST)throw new Error("Challenge payload type invalid: "+n.type);return t.processDisclosurePayload({payload:r,doc:i})});throw new Error("Challenge was not included in response")})}catch(e){return Promise.reject(e)}},f.prototype.verifyDisclosure=function(e){try{var r=this;return Promise.resolve(a.verifyJWT(e,{resolver:r.resolver,audience:r.did})).then(function(e){return r.processDisclosurePayload({payload:e.payload,doc:e.doc})})}catch(e){return Promise.reject(e)}},f.prototype.issueVerifiableCredential=function(e){try{return this.did&&this.signer?Promise.resolve(t.createVerifiableCredential(e,{did:this.did,signer:this.signer})):Promise.reject(new Error("No Signing Identity configured"))}catch(e){return Promise.reject(e)}},f.prototype.verifyPresentation=function(e){try{return Promise.resolve(t.verifyPresentation(e,this.resolver))}catch(e){return Promise.reject(e)}},f.prototype.contract=function(e){var r=this;return p(function(e,t){return e.function&&(e.fn=e.function),delete e.function,r.createTxRequest(e,t)}.bind(this))(e)},e.SimpleSigner=a.SimpleSigner,e.Credentials=f,e.ContractFactory=p});
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("elliptic"),require("did-jwt"),require("did-jwt-vc"),require("ethr-did-resolver"),require("web-did-resolver"),require("did-resolver"),require("mnid")):"function"==typeof define&&define.amd?define(["exports","elliptic","did-jwt","did-jwt-vc","ethr-did-resolver","web-did-resolver","did-resolver","mnid"],r):r((e=e||self).uportCredentials={},e.elliptic,e.didJwt,e.didJwtVc,e.ethrDidResolver,e.webDidResolver,e.didResolver,e.mnid)}(this,function(e,r,t,i,n,o,s,a){function c(){return(c=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e}).apply(this,arguments)}var u,d;n=n&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n,function(e){e.Function="function",e.Event="event",e.Constructor="constructor",e.Fallback="fallback"}(u||(u={})),function(e){e.Pure="pure",e.View="view",e.NonPayable="nonpayable",e.Payable="payable"}(d||(d={}));var l,f=function(e){if("object"!=typeof e)return!1;if(0===Object.keys(e).length)return!0;for(var r=0,t=["from","to","data","value","gasPrice","gas"];r<t.length;r++)if(t[r]in e)return!0;return!1},v=function(e,r){for(var t=e.name+"(",i=e.inputs||[],n=0;n<i.length;n++){var o=i[n],s=o.type+" ";t+=s+="string"===o.type?'"'+r[n]+'"':""+r[n],i.length-1!==n&&(t+=", ")}return t+")"},p=function(e){return function(r){return{at:function(t){var i={};return function(e){return e.filter(function(e){return e.type===u.Function&&e.name&&!e.constant})}(r).forEach(function(r){r.name&&(i[r.name]=function(){var i={},n=[].slice.call(arguments),o=(r.inputs||[]).length;f(n[o])&&(i=n.splice(o,1)[0]);var s=c({},i,{to:t,function:v(r,n)});if(!e)return s;var a=n[n.length-1];return e(s,a)})}),c({},i,{abi:r,address:t})}}}},h=new r.ec("secp256k1");!function(e){e.DISCLOSURE_REQUEST="shareReq",e.DISCLOSURE_RESPONSE="shareResp",e.TYPED_DATA_SIGNATURE_REQUEST="eip712Req",e.VERIFICATION_SIGNATURE_REQUEST="verReq",e.ETH_TX_REQUEST="ethtx",e.PERSONAL_SIGN_REQUEST="personalSigReq",e.PRESENTATION_REQUEST="presentationReq"}(l||(l={}));var y=function(){function e(e){var r=e.did,i=e.address,u=e.privateKey,d=e.signer,l=e.ethrConfig,f=e.resolver;if(d?this.signer=d:u&&(this.signer=t.SimpleSigner(u)),r)this.did=r;else if(i)a.isMNID(i)&&(this.did="did:uport:"+i),i.match("^0x[0-9a-fA-F]{40}$")&&(this.did="did:ethr:"+i);else if(u){var v=h.keyFromPrivate(u),p=t.toEthereumAddress(v.getPublic("hex"));this.did="did:ethr:"+p}if(f)this.resolver=f;else{var y=n.getResolver(l||{}),E=o.getResolver();this.resolver=new s.Resolver(c({},E,y,{https:E.web}))}}e.createIdentity=function(){var e=h.genKeyPair(),r=e.getPublic("hex"),i=e.getPrivate("hex");return{did:"did:ethr:"+t.toEthereumAddress(r),privateKey:i}};var r=e.prototype;return r.signJWT=function(e,r){return this.did&&this.signer?t.createJWT(e,{issuer:this.did,signer:this.signer,alg:this.did.match("^did:uport:")||a.isMNID(this.did)?"ES256K":"ES256K-R",expiresIn:r}):Promise.reject(new Error("No Signing Identity configured"))},r.createDisclosureRequest=function(e,r){void 0===e&&(e={}),void 0===r&&(r=600);var t={};if(e.requested&&(t.requested=e.requested),e.verified&&(t.verified=e.verified),e.claims&&(t.claims=e.claims),e.notifications&&(t.permissions=["notifications"]),e.callbackUrl&&(t.callback=e.callbackUrl),e.networkId&&(t.net=e.networkId),e.rpcUrl){if(!e.networkId)return Promise.reject(new Error("rpcUrl was specified but no networkId"));t.rpc=e.rpcUrl}if(e.vc&&(t.vc=e.vc),e.exp&&(t.exp=e.exp),e.accountType){if(!(["general","segregated","keypair","none"].indexOf(e.accountType)>=0))return Promise.reject(new Error("Unsupported accountType "+e.accountType));t.act=e.accountType}return e.boxPub&&(t.boxPub=e.boxPub),this.signJWT(c({},t,{type:l.DISCLOSURE_REQUEST}),e.exp?void 0:r)},r.createVerification=function(e){return this.signJWT({sub:e.sub,claim:e.claim,exp:e.exp,vc:e.vc,callbackUrl:e.callbackUrl})},r.createVerificationSignatureRequest=function(e,r){return this.signJWT({unsignedClaim:e,sub:r.sub,riss:r.riss,aud:r.aud,vc:r.vc,callback:r.callbackUrl,type:l.VERIFICATION_SIGNATURE_REQUEST,rexp:r.rexp},r.expiresIn)},r.createTypedDataSignatureRequest=function(e,r){var t=void 0===r?{}:r,i=t.from,n=t.net,o=t.callback;try{for(var s=0,a=["types","primaryType","message","domain"];s<a.length;s++){var c=a[s];if(!e[c])throw new Error("Invalid EIP712 Request, must include '"+c+"'")}return Promise.resolve(this.signJWT({typedData:e,from:i,net:n,callback:o,type:l.TYPED_DATA_SIGNATURE_REQUEST}))}catch(e){return Promise.reject(e)}},r.createPersonalSignRequest=function(e,r){var t=void 0===r?{}:r;return this.signJWT({data:e,from:t.from,net:t.net,callback:t.callback,type:l.PERSONAL_SIGN_REQUEST})},r.createTxRequest=function(e,r){var t=void 0===r?{}:r,i=t.callbackUrl,n=t.exp,o=void 0===n?600:n,s=t.networkId,a=t.label,u={};return i&&(u.callback=i),s&&(u.net=s),a&&(u.label=a),this.signJWT(c({},u,e,{type:l.ETH_TX_REQUEST}),o)},r.createDisclosureResponse=function(e,r){void 0===e&&(e={}),void 0===r&&(r=600);try{var i=function(){return n.signJWT(c({},e,{type:l.DISCLOSURE_RESPONSE}),r)},n=this,o=function(){if(e.req)return Promise.resolve(t.verifyJWT(e.req,{resolver:n.resolver})).then(function(r){r.issuer&&(e.aud=r.issuer)})}();return Promise.resolve(o&&o.then?o.then(i):i())}catch(e){return Promise.reject(e)}},r.processDisclosurePayload=function(e){var r=e.doc,i=e.payload;try{var n=this,o=i.own,s=void 0===o?{}:o,u=i.capabilities,d=void 0===u?[]:u,l=i.nad,f=i.dad,v=i.iss,p=i.boxPub,h=i.verified,y=function(e,r){if(null==e)return{};var t,i,n={},o=Object.keys(e);for(i=0;i<o.length;i++)r.indexOf(t=o[i])>=0||(n[t]=e[t]);return n}(i,["own","capabilities","aud","req","iat","exp","type","nad","dad","iss","boxPub","verified"]),E=r.uportProfile,b=c({did:v,boxPub:p},s,void 0===E?{}:E,y);f&&(b.deviceKey=f),l&&(b.mnid=l,b.address=a.decode(l).address),1===d.length&&(b.pushToken=d[0]);var g=function(){if(h){var e=[],r=h.map(function(r){return t.verifyJWT(r,{resolver:n.resolver,audience:n.did}).catch(function(){return e.push(r),Promise.resolve(void 0)})});return Promise.resolve(Promise.all(r)).then(function(r){var t=[];r.forEach(function(e){e&&t.push(c({},e.payload,{jwt:e.jwt}))}),b.verified=t,b.invalid=e})}}();return Promise.resolve(g&&g.then?g.then(function(){return b}):b)}catch(e){return Promise.reject(e)}},r.authenticateDisclosureResponse=function(e,r){try{var i=this;return Promise.resolve(t.verifyJWT(e,{resolver:i.resolver,audience:i.did,callbackUrl:r,auth:!0})).then(function(e){var r=e.payload,n=e.doc;if(r.req)return Promise.resolve(t.verifyJWT(r.req,{resolver:i.resolver,audience:i.did})).then(function(e){var t=e.payload;if(t.type!==l.DISCLOSURE_REQUEST)throw new Error("Challenge payload type invalid: "+t.type);return i.processDisclosurePayload({payload:r,doc:n})});throw new Error("Challenge was not included in response")})}catch(e){return Promise.reject(e)}},r.verifyDisclosure=function(e){try{var r=this;return Promise.resolve(t.verifyJWT(e,{resolver:r.resolver,audience:r.did})).then(function(e){return r.processDisclosurePayload({payload:e.payload,doc:e.doc})})}catch(e){return Promise.reject(e)}},r.issueVerifiableCredential=function(e){try{return this.did&&this.signer?Promise.resolve(i.createVerifiableCredential(e,{did:this.did,signer:this.signer})):Promise.reject(new Error("No Signing Identity configured"))}catch(e){return Promise.reject(e)}},r.verifyPresentation=function(e){try{return Promise.resolve(i.verifyPresentation(e,this.resolver))}catch(e){return Promise.reject(e)}},r.contract=function(e){var r=this;return p(function(e,t){return e.function&&(e.fn=e.function),delete e.function,r.createTxRequest(e,t)}.bind(this))(e)},e}();Object.defineProperty(e,"SimpleSigner",{enumerable:!0,get:function(){return t.SimpleSigner}}),e.ContractFactory=p,e.Credentials=y});
//# sourceMappingURL=index.umd.js.map
{
"name": "uport-credentials",
"version": "1.3.3",
"version": "1.3.4",
"description": "Library for interacting with uport profiles and attestations",

@@ -42,6 +42,3 @@ "main": "lib/index.js",

"ethr-did-resolver": "^2.0.0",
"https-did-resolver": "^0.1.0",
"mnid": "^0.1.1",
"uport-did-resolver": "^0.0.7",
"uport-lite": "^1.0.5",
"web-did-resolver": "^1.2.0"

@@ -78,32 +75,32 @@ },

"devDependencies": {
"@commitlint/cli": "8.3.5",
"@commitlint/config-conventional": "8.3.4",
"@commitlint/cli": "9.1.1",
"@commitlint/config-conventional": "9.1.1",
"@semantic-release/changelog": "5.0.1",
"@semantic-release/git": "9.0.0",
"@types/elliptic": "6.4.6",
"@types/jest": "24.0.11",
"@types/elliptic": "6.4.12",
"@types/jest": "26.0.9",
"@types/mockdate": "2.0.0",
"body-parser": "1.18.3",
"codecov": "3.7.0",
"express": "4.16.4",
"body-parser": "1.19.0",
"codecov": "3.7.2",
"express": "4.17.1",
"husky": "4.2.5",
"jest": "24.7.1",
"jest": "26.2.2",
"json-loader": "0.5.7",
"microbundle": "0.11.0",
"mockdate": "2.0.2",
"microbundle": "0.12.3",
"mockdate": "3.0.2",
"ngrok": "3.2.7",
"nock": "9.6.1",
"prettier": "1.19.1",
"semantic-release": "17.0.8",
"ts-jest": "24.0.2",
"tslint": "5.16.0",
"nock": "13.0.3",
"prettier": "2.0.5",
"semantic-release": "17.1.1",
"ts-jest": "26.1.4",
"tslint": "6.1.3",
"tslint-config-prettier": "1.18.0",
"tslint-eslint-rules": "5.4.0",
"typedoc": "0.16.9",
"typedoc-plugin-markdown": "1.2.0",
"typescript": "3.4.4",
"typedoc": "0.17.8",
"typedoc-plugin-markdown": "2.4.0",
"typescript": "3.9.7",
"uport-transports": "0.2.6",
"webpack": "4.30.0",
"webpack-cli": "3.3.0"
"webpack": "4.44.1",
"webpack-cli": "3.3.12"
}
}

@@ -6,7 +6,5 @@ import { ec as EC } from 'elliptic'

import { PresentationPayload } from 'did-jwt-vc/lib/types'
import UportDIDResolver from 'uport-did-resolver'
import EthrDIDResolver from 'ethr-did-resolver'
import * as WebDidResolver from 'web-did-resolver'
import { Resolver } from 'did-resolver'
import UportLite from 'uport-lite'
import { isMNID, decode as mnidDecode } from 'mnid'

@@ -74,3 +72,3 @@

interface VerifiableClaimSpec extends ClaimSpec {
iss: IssuerSpec[]
iss?: IssuerSpec[]
}

@@ -88,3 +86,3 @@

verifiable: VerifiableClaimsSpec
user_info: UserInfoSpec
user_info?: UserInfoSpec
}

@@ -344,8 +342,5 @@ interface DisclosureRequestParams {

* application's uPort identity)
* @param {Object} [settings.networks] DEPRECATED networks config object, ie. { '0x94365e3b': {
* rpcUrl: 'https://private.chain/rpc', address: '0x0101.... }}
* @param {UportLite} [settings.registry] DEPRECATED a registry object from UportLite
* @return {Credentials} self
*/
constructor({ did, address, privateKey, signer, networks, registry, ethrConfig, resolver }: Settings) {
constructor({ did, address, privateKey, signer, ethrConfig, resolver }: Settings) {
if (signer) {

@@ -377,3 +372,7 @@ this.signer = signer

const webResolver = WebDidResolver.getResolver()
this.resolver = new Resolver({ ...webResolver, ...ethrResolver })
this.resolver = new Resolver({
...webResolver,
...ethrResolver,
https: webResolver.web
})
}

@@ -380,0 +379,0 @@ }

@@ -10,9 +10,1 @@ declare module 'mnid' {

}
declare module 'ethr-did-resolver' {
export function getResolver(conf?: object): object
}
declare module 'uport-lite' {
export default function UportLite(conf: { networks: object }): (address: string) => Promise<object>
}

Sorry, the diff of this file is too big to display

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

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