Error Trace activating invitation

If there is no signingKey in localStorage, that probably means you didn’t call User.createWithCurrentUser - is that true?

Hey @hank

I am getting the same error and I did call User.createWithCurrentUser. I believe that is the call that is causing the error:

Here is my order of events.

1). After I am logged in and handlePendingSignIn , I call User.createWithCurrentUser.. Radiks hits this endpoint:

https://blockusign-radiks.azurewebsites.net/radiks/models/find?_id=nicktee.id

and returns my personalSigningKeyId, radiksSignature and all the other profile info

2). Then it hits this endpoint

https://blockusign-radiks.azurewebsites.net/radiks/models/find?_id[iv]=8a8d09d4d0bf9fcccb5ff0a577b41e8f&_id[ephemeralPK]=037e7cee26d5c83722dc583adf16be90186acac365ba3d80f5e289f9f94e3858a8&_id[cipherText]=b6155bc9760675eb54260ee92cc2a0bf689c2af1bf726ec91b4c4895dd32e7443bc6236f2f359fe3b6f00014c43bf3e9&_id[mac]=593c3ceeca1ee756fac26c33f04051435370192b778e5764125c9b44e18860be&_id[wasString]=true

3). It fails at this line below in model.js const encrypted = await this.encrypted();

lib/model.js

_createClass(Model, [{
key: "save",
value: async function save() {
  return new Promise(async (resolve, reject) => {
    try {
      if (this.beforeSave) {
        await this.beforeSave();
      }
      const now = new Date().getTime();
      this.attrs.createdAt = this.attrs.createdAt || now;
      this.attrs.updatedAt = now;
      await this.sign();
      const encrypted = await this.encrypted();
      const gaiaURL = await this.saveFile(encrypted);
      await (0, _api.sendNewGaiaUrl)(gaiaURL);
      resolve(this);
    } catch (error) {
      reject(error);
    }
  });
 }
}

4). It fails with this error

TypeError: First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.
  at fromObject (index.js:311)
  at from (index.js:137)
  at Function.Buffer.from (index.js:149)
  at encryptECIES (ec.js:88)
  at eval (helpers.js:110)
  at Array.forEach (<anonymous>)
  at encryptObject (helpers.js:93)
  at async eval (model.js:148)

Any ideas?

Nevermind I got it working!

Something with my User Account was corrupted on the Radiks Server. I simply had to go into MongoDB and delete my user account.

@hank,

I am trying to get Invitations to work and noticed the documentation is out of date here https://github.com/blockstack-radiks/radiks#inviting-a-user . I noticed you switched from using makeGroupInvitation to makeGroupMembership but i can’t seem to get it working.

Here is my trace:

1). Create group

     async createPrivateGroup() {
        const group = new UserGroup({ name: 'PrivateGroupMessages' });
        await group.create();
      }

HTTP

[DEBUG] connectToGaiaHub: https://hub.blockstack.org/hub_info
blockstack.js:95694 [DEBUG] uploadToGaiaHub: uploading SigningKey/6e447e321d10-402c-ac42-9ea154c64dd5 to https://hub.blockstack.org
blockstack.js:95694 [DEBUG] connectToGaiaHub: https://hub.blockstack.org/hub_info
blockstack.js:95694 [DEBUG] uploadToGaiaHub: uploading GroupInvitation/cf3054705f3b-421e-b0a1-f9db9b4baca2 to https://hub.blockstack.org
blockstack.js:95694 [DEBUG] connectToGaiaHub: https://hub.blockstack.org/hub_info
blockstack.js:95694 [DEBUG] uploadToGaiaHub: uploading UserGroup/732c74fe248b-4f3b-adbc-94971fd5d50b to https://hub.blockstack.org

MONGO

{
	"_id": "732c74fe248b-4f3b-adbc-94971fd5d50b",
	"members": {
		"iv": "7f219b133690e22783dd1395e87c7544",
		"ephemeralPK": "02c13ff539895fb753c3a835e0045e9bed24ffa43f6011cfdb355824bab88f4dae",
		"cipherText": "bee9d396434d5a1914b552d6eb7712be2bb9c8366962f61c....",
		"mac": "38b076c15be7cdddbf65b81996b1ef88aff2a0a2c4774d7a9c25631b5bdd35ab",
		"wasString": true
	},
	"name": {
		"iv": "3b535fcf6a93411f6931f91f69e4561a",
		"ephemeralPK": "0320545e7a2db55d70e8a46c8580e59c7f07f9724001f8dfbe3036489b9ea6967e",
		"cipherText": "001d09252f604ea6cff961e93ad9e30d72455c273074743483a916a041cab421",
		"mac": "b5037e994ebdad378ff1aeca581a0ef08d11d16b319366a6198be54f2585db52",
		"wasString": true
	},
	"radiksType": "UserGroup",
	"signingKeyId": "6e447e321d10-402c-ac42-9ea154c64dd5",
	"createdAt": 1555526166854,
	"updatedAt": 1555526166854,
	"radiksSignature": "3046022100cde49778e525083b5eea99b05bb05929570b50ab35bd3e1307c59c0c73c..."
}

2). Create Invitation

  async inviteUser() {
    const group = await UserGroup.findById('732c74fe248b-4f3b-adbc-94971fd5d50b');
    const usernameToInvite = 'nicktee.id.blockstack';
    const invitation = await group.makeGroupMembership(usernameToInvite);
    console.log(invitation._id); // the ID used to later activate an invitation
  }

HTTP

https://hub.blockstack.org/store/15P2niPu16fLYTJ6zn3FkC2tiGD6EMvS8w/GroupInvitation/edd9011ee05c-4e25-8baa-f49b0cc784bb

RESPONSE

{"publicURL":"https://gaia.blockstack.org/hub/15P2niPu16fLYTJ6zn3FkC2tiGD6EMvS8w/GroupInvitation/edd9011ee05c-4e25-8baa-f49b0cc784bb"}

CONSOLE ERROR

ERROR Error: Uncaught (in promise): TypeError: First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.
TypeError: First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.
    at fromObject (index.js:311)
    at from (index.js:137)
    at Function.Buffer.from (index.js:149)
    at getPublicKeyFromPrivate (keys.js:39)
    at UserGroup.publicKey (user-group.js:104)
    at UserGroup.encryptionPublicKey (user-group.js:109)
    at encryptObject (helpers.js:86)
    at UserGroup.encrypted (model.js:160)
    at eval (model.js:148)
    at resolvePromise (zone.js:831)
    at eval (zone.js:741)
    at rejected (app.component.ts:14)
    at ZoneDelegate.invoke (zone.js:391)
    at Object.onInvoke (core.js:4760)
    at ZoneDelegate.invoke (zone.js:390)
    at Zone.run (zone.js:150)
    at eval (zone.js:889)
    at ZoneDelegate.invokeTask (zone.js:423)
    at Object.onInvokeTask (core.js:4751)

MONGO

{
	"_id": "edd9011ee05c-4e25-8baa-f49b0cc784bb",
	"updatable": false,
	"userGroupId": {
		"iv": "2e925229183b74edf73cc375ffc66ef3",
		"ephemeralPK": "02aba416abedeec6507ac40126ec1b0f8e75d8f86e9add7b3787297e2484c2106e",
		"cipherText": "27f5927b51dc39b869a65785af0739a6bfd313e652c6317051280c7021a3ed3f26ad7aabf8a3c3b773c9a3f143629b4e",
		"mac": "f9986936f159b0a0b7470f1277fa58e7b22f02622bd9ae9c32a6df185e3e4202",
		"wasString": true
	},
	"signingKeyId": {
		"iv": "f64dc06f709ce70ad03c5cb77c1b8470",
		"ephemeralPK": "02e31ddb691707b05aee98093b7cdb7bc01d1c57ac6e59b69de5f0eff26b78413c",
		"cipherText": "d49b48245a3aa84e5806a38b2eebe3c2c05c7f029dd7232fd145408ca6f575447fe1febd6b26584e160530b50399f954",
		"mac": "6a6c25cb32076fa539679758ab23d71392cf7b6a8d028a87de125cee43947ce8",
		"wasString": true
	},
	"radiksType": "GroupInvitation",
	"createdAt": 1555526709151,
	"updatedAt": 1555526709151
}

3) Accept
When the other user (who already has a account and signed up previously) logs in to accept it fails

  async activateGroup() {
    const invitation = await GroupInvitation.findById('edd9011ee05c-4e25-8baa-f49b0cc784bb');
    await invitation.activate();
  }

RESPONSE
https://blockusign-radiks.azurewebsites.net/radiks/models/find?_id=edd9011ee05c-4e25-8baa-f49b0cc784bb

{
	"total": 1,
	"results": [{
		"_id": "edd9011ee05c-4e25-8baa-f49b0cc784bb",
		"updatable": false,
		"userGroupId": {
			"iv": "2e925229183b74edf73cc375ffc66ef3",
			"ephemeralPK": "02aba416abedeec6507ac40126ec1b0f8e75d8f86e9add7b3787297e2484c2106e",
			"cipherText": "27f5927b51dc39b869a65785af0739a6bfd313e652c6317051280c7021a3ed3f26ad7aabf8a3c3b773c9a3f143629b4e",
			"mac": "f9986936f159b0a0b7470f1277fa58e7b22f02622bd9ae9c32a6df185e3e4202",
			"wasString": true
		},
		"signingKeyId": {
			"iv": "f64dc06f709ce70ad03c5cb77c1b8470",
			"ephemeralPK": "02e31ddb691707b05aee98093b7cdb7bc01d1c57ac6e59b69de5f0eff26b78413c",
			"cipherText": "d49b48245a3aa84e5806a38b2eebe3c2c05c7f029dd7232fd145408ca6f575447fe1febd6b26584e160530b50399f954",
			"mac": "6a6c25cb32076fa539679758ab23d71392cf7b6a8d028a87de125cee43947ce8",
			"wasString": true
		},
		"radiksType": "GroupInvitation",
		"createdAt": 1555526709151,
		"updatedAt": 1555526709151
	}]
}

CONSOLE ERROR

ERROR Error: Uncaught (in promise): TypeError: First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.
TypeError: First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.
    at fromObject (index.js:311)
    at from (index.js:137)
    at Function.Buffer.from (index.js:149)
    at getPublicKeyFromPrivate (keys.js:39)
    at signECDSA (ec.js:162)
    at GroupMembership.sign (model.js:228)
    at eval (model.js:147)
    at resolvePromise (zone.js:831)
    at eval (zone.js:741)
    at rejected (app.component.ts:14)
    at ZoneDelegate.invoke (zone.js:391)
    at Object.onInvoke (core.js:4760)
    at ZoneDelegate.invoke (zone.js:390)
    at Zone.run (zone.js:150)
    at eval (zone.js:889)
    at ZoneDelegate.invokeTask (zone.js:423)
    at Object.onInvokeTask (core.js:4751)

Any ideas? Appears to be something wrong when trying to decrypt the data