-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: unify connection record state and role (#732)
Signed-off-by: Timo Glastra <[email protected]>
- Loading branch information
1 parent
73d296f
commit 3068f32
Showing
15 changed files
with
187 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 0 additions & 10 deletions
10
packages/core/src/modules/connections/__tests__/ConnectionState.test.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 19 additions & 2 deletions
21
packages/core/src/modules/connections/models/ConnectionState.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,30 @@ | ||
import { DidExchangeState } from './DidExchangeState' | ||
|
||
/** | ||
* Connection states as defined in RFC 0160. | ||
* | ||
* State 'null' from RFC is changed to 'init' | ||
* | ||
* @see https://github.com/hyperledger/aries-rfcs/blob/master/features/0160-connection-protocol/README.md#states | ||
*/ | ||
export enum ConnectionState { | ||
Null = 'null', | ||
Invited = 'invited', | ||
Requested = 'requested', | ||
Responded = 'responded', | ||
Complete = 'complete', | ||
} | ||
|
||
export function rfc0160StateFromDidExchangeState(didExchangeState: DidExchangeState) { | ||
const stateMapping = { | ||
[DidExchangeState.Start]: ConnectionState.Null, | ||
[DidExchangeState.Abandoned]: ConnectionState.Null, | ||
[DidExchangeState.InvitationReceived]: ConnectionState.Invited, | ||
[DidExchangeState.InvitationSent]: ConnectionState.Invited, | ||
[DidExchangeState.RequestReceived]: ConnectionState.Requested, | ||
[DidExchangeState.RequestSent]: ConnectionState.Requested, | ||
[DidExchangeState.ResponseReceived]: ConnectionState.Responded, | ||
[DidExchangeState.ResponseSent]: ConnectionState.Responded, | ||
[DidExchangeState.Completed]: DidExchangeState.Completed, | ||
} | ||
|
||
return stateMapping[didExchangeState] | ||
} |
Oops, something went wrong.