Updates from writing my own store
This commit is contained in:
		
							parent
							
								
									766eaa3eed
								
							
						
					
					
						commit
						c58785f6e3
					
				
							
								
								
									
										9
									
								
								index.js
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								index.js
									
									
									
									
									
								
							@ -257,18 +257,19 @@ module.exports.create = function (options) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Certificates
 | 
					    // Certificates
 | 
				
			||||||
  , set: function (opts, certs, cb) {
 | 
					  , set: function (opts, cb) {
 | 
				
			||||||
      // opts.domains
 | 
					      // opts.domains
 | 
				
			||||||
      // opts.email // optional
 | 
					      // opts.email // optional
 | 
				
			||||||
      // opts.accountId // optional
 | 
					      // opts.accountId // optional
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      // certs.privkey
 | 
					      // opts.certs.privkey
 | 
				
			||||||
      // certs.cert
 | 
					      // opts.certs.cert
 | 
				
			||||||
      // certs.chain
 | 
					      // opts.certs.chain
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      var index;
 | 
					      var index;
 | 
				
			||||||
      var accountId;
 | 
					      var accountId;
 | 
				
			||||||
      var account;
 | 
					      var account;
 | 
				
			||||||
 | 
					      var certs = opts.certs;
 | 
				
			||||||
      var subject = certs.subject || opts.domains[0];
 | 
					      var subject = certs.subject || opts.domains[0];
 | 
				
			||||||
      var altnames = certs.altnames || opts.domains;
 | 
					      var altnames = certs.altnames || opts.domains;
 | 
				
			||||||
      var accountCerts;
 | 
					      var accountCerts;
 | 
				
			||||||
 | 
				
			|||||||
@ -96,9 +96,8 @@ var tests = [
 | 
				
			|||||||
    var account = {
 | 
					    var account = {
 | 
				
			||||||
      agreeTos: true
 | 
					      agreeTos: true
 | 
				
			||||||
    , keypair: goodGuy.keypair
 | 
					    , keypair: goodGuy.keypair
 | 
				
			||||||
    , receipt: {}
 | 
					    , receipt: { foo: 'bar' }
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					 | 
				
			||||||
    return leStore.accounts.setAsync(goodGuy, account).then(function (account) {
 | 
					    return leStore.accounts.setAsync(goodGuy, account).then(function (account) {
 | 
				
			||||||
      if (!account || !account.id || !account.email) {
 | 
					      if (!account || !account.id || !account.email) {
 | 
				
			||||||
        throw new Error('accounts.set should return the object with its new `id` attached');
 | 
					        throw new Error('accounts.set should return the object with its new `id` attached');
 | 
				
			||||||
@ -113,7 +112,6 @@ var tests = [
 | 
				
			|||||||
    return leStore.accounts.checkAsync({
 | 
					    return leStore.accounts.checkAsync({
 | 
				
			||||||
      accountId: goodGuy.accountId
 | 
					      accountId: goodGuy.accountId
 | 
				
			||||||
    }).then(function (account) {
 | 
					    }).then(function (account) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
      if (!account) {
 | 
					      if (!account) {
 | 
				
			||||||
        throw new Error("Did not find account.");
 | 
					        throw new Error("Did not find account.");
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
@ -192,7 +190,6 @@ var tests = [
 | 
				
			|||||||
    account[rnd] = rnd;
 | 
					    account[rnd] = rnd;
 | 
				
			||||||
    return leStore.accounts.setKeypairAsync(opts, account.keypair).then(function () {
 | 
					    return leStore.accounts.setKeypairAsync(opts, account.keypair).then(function () {
 | 
				
			||||||
      return leStore.accounts.setAsync(opts, account).then(function (account) {
 | 
					      return leStore.accounts.setAsync(opts, account).then(function (account) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        if ('_account_id' === account.id || '__account_id' === account.id) {
 | 
					        if ('_account_id' === account.id || '__account_id' === account.id) {
 | 
				
			||||||
          throw new Error("Should create `id` deterministically from email or public key, not the given `accountId` or `id`.");
 | 
					          throw new Error("Should create `id` deterministically from email or public key, not the given `accountId` or `id`.");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -264,7 +261,7 @@ var tests = [
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return leStore.certificates.setAsync(certOpts, certOpts.certs);
 | 
					    return leStore.certificates.setAsync(certOpts);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  // and another
 | 
					  // and another
 | 
				
			||||||
, function () {
 | 
					, function () {
 | 
				
			||||||
@ -278,7 +275,7 @@ var tests = [
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return leStore.certificates.setAsync(certOpts, certOpts.certs);
 | 
					    return leStore.certificates.setAsync(certOpts);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // basic test (set by email)
 | 
					  // basic test (set by email)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user