@@ -255,7 +255,7 @@ export class AuthProvider extends EventEmitter<AuthProviderEvents> {
255
255
/**
256
256
* Creates a private share for a team we're already a member of.
257
257
*/
258
- public async addTeam ( team : Auth . Team ) {
258
+ public async addTeam ( team : Auth . Team , teamKeyring = team . teamKeyring ( ) ) {
259
259
const shareId = getShareId ( team )
260
260
261
261
if ( this . hasTeam ( shareId ) ) {
@@ -269,6 +269,7 @@ export class AuthProvider extends EventEmitter<AuthProviderEvents> {
269
269
shareId,
270
270
team,
271
271
documentIds : new Set ( ) ,
272
+ teamKeyring,
272
273
} )
273
274
274
275
// persist our state now and whenever the team changes
@@ -469,16 +470,16 @@ export class AuthProvider extends EventEmitter<AuthProviderEvents> {
469
470
this . #connections. set ( [ shareId , peerId ] , connection )
470
471
471
472
connection
472
- . on ( 'joined' , async ( { team, user } ) => {
473
+ . on ( 'joined' , async ( { team, user, teamKeyring } ) => {
473
474
// When we successfully join a team, the connection gives us the team graph and the user's
474
475
// info (including keys).
475
476
476
477
// When we're joining as a new device for an existing user, this is how we get the user's id and keys.
477
478
this . #user = user
478
479
this . #log = log . extend ( user . userName )
479
480
480
- // Create a share with this team
481
- await this . addTeam ( team )
481
+ // Create a share with this team and the full team keys
482
+ await this . addTeam ( team , teamKeyring )
482
483
483
484
// remove the used invitation as we no longer need it & don't want to present it to others
484
485
this . #invitations. delete ( shareId )
@@ -640,7 +641,10 @@ export class AuthProvider extends EventEmitter<AuthProviderEvents> {
640
641
? ( {
641
642
shareId,
642
643
encryptedTeam : share . team . save ( ) ,
643
- encryptedTeamKeys : encryptBytes ( share . team . teamKeyring ( ) , this . #device. keys . secretKey ) ,
644
+ encryptedTeamKeys : encryptBytes (
645
+ { ...share . teamKeyring , ...share . team . teamKeyring ( ) } ,
646
+ this . #device. keys . secretKey
647
+ ) ,
644
648
documentIds,
645
649
} as SerializedShare )
646
650
: { shareId, documentIds }
0 commit comments