Skip to content

Commit 226e49d

Browse files
committed
add keyring selector
1 parent 6b27cf7 commit 226e49d

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

packages/auth/src/team/selectors/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export * from './hasRole.js'
55
export * from './hasServer.js'
66
export * from './invitation.js'
77
export * from './keyMap.js'
8+
export * from './keyring.js'
89
export * from './keys.js'
910
export * from './lockboxesInScope.js'
1011
export * from './member.js'
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { type KeysetWithSecrets, createKeyring, type KeyScope } from '@localfirst/crdx'
2+
import { type TeamState } from 'team/types.js'
3+
import { keyMap } from './keyMap.js'
4+
5+
/**
6+
* Returns a keyring containing all generations of keys for the given scope.
7+
*/
8+
9+
export const keyring = (state: TeamState, scope: KeyScope, keys: KeysetWithSecrets) => {
10+
const foo = keyMap(state, keys)
11+
const allKeys = foo[scope.type]?.[scope.name]
12+
return createKeyring(allKeys)
13+
}

0 commit comments

Comments
 (0)