Bind domain access to registered node type
This commit is contained in:
parent
f3a1ee82a2
commit
8807b99d98
15 changed files with 168 additions and 63 deletions
|
|
@ -55,6 +55,7 @@ export interface DomainSessionCapability {
|
|||
domainId: string
|
||||
expiresAt: number
|
||||
nodeId: string
|
||||
nodeType: DomainNodeType
|
||||
scopes: string[]
|
||||
}
|
||||
|
||||
|
|
@ -63,6 +64,7 @@ export interface DomainConnectionReceipt {
|
|||
domainId: string
|
||||
manifestDigest: string
|
||||
nodeId: string
|
||||
nodeType: DomainNodeType
|
||||
receiptId: string
|
||||
state: 'online'
|
||||
}
|
||||
|
|
@ -217,6 +219,9 @@ export function acceptDomainSession(
|
|||
if (session.expiresAt <= now) {
|
||||
throw new DomainContractError('domain_session_expired')
|
||||
}
|
||||
if (session.nodeType !== state.nodeType) {
|
||||
throw new DomainContractError('domain_session_node_type_mismatch')
|
||||
}
|
||||
if (!session.scopes.includes(REQUIRED_ENTER_SCOPE)) {
|
||||
throw new DomainContractError('domain_session_enter_scope_missing')
|
||||
}
|
||||
|
|
@ -238,6 +243,9 @@ export function acceptDomainConnectionReceipt(
|
|||
if (receipt.nodeId !== state.session.nodeId) {
|
||||
throw new DomainContractError('domain_connection_node_mismatch')
|
||||
}
|
||||
if (receipt.nodeType !== state.nodeType || receipt.nodeType !== state.session.nodeType) {
|
||||
throw new DomainContractError('domain_connection_node_type_mismatch')
|
||||
}
|
||||
if (receipt.manifestDigest !== state.manifest.provenance.digest) {
|
||||
throw new DomainContractError('domain_connection_manifest_mismatch')
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue