-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: register as external ID attester (#120)
* feat: register as external ID attestor * chore: rename tag -> provider_name
- Loading branch information
Showing
9 changed files
with
118 additions
and
9 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
35 changes: 35 additions & 0 deletions
35
crates/username_registry_validation/src/external_id_attestor.rs
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use core::str; | ||
|
||
use hdi::prelude::*; | ||
|
||
pub fn validate_create_link_external_id_attestor( | ||
action: CreateLink, | ||
_base_address: AnyLinkableHash, | ||
target_address: AnyLinkableHash, | ||
tag: LinkTag, | ||
) -> ExternResult<ValidateCallbackResult> { | ||
if AnyLinkableHash::from(action.author) != target_address { | ||
return Ok(ValidateCallbackResult::Invalid( | ||
"Target of attestor link must author".to_string(), | ||
)); | ||
} | ||
|
||
if str::from_utf8(&tag.into_inner()).is_err() { | ||
return Ok(ValidateCallbackResult::Invalid( | ||
"Tag must be a valid utf-8 string".to_string(), | ||
)); | ||
} | ||
|
||
Ok(ValidateCallbackResult::Valid) | ||
} | ||
pub fn validate_delete_link_external_id_attestor( | ||
_action: DeleteLink, | ||
_original_action: CreateLink, | ||
_base: AnyLinkableHash, | ||
_target: AnyLinkableHash, | ||
_tag: LinkTag, | ||
) -> ExternResult<ValidateCallbackResult> { | ||
Ok(ValidateCallbackResult::Invalid(String::from( | ||
"Attestor links cannot be deleted", | ||
))) | ||
} |
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
24 changes: 24 additions & 0 deletions
24
packages/tryorama/src/external_attestation/agents_can_list_as_external_id_attestors.test.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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { expect, test } from "vitest"; | ||
import { dhtSync, runScenario } from "@holochain/tryorama"; | ||
|
||
import { setupPlayer } from "../utils/setup-happ.js"; | ||
|
||
test("Agents can list as external id attestors", async () => { | ||
await runScenario(async (scenario) => { | ||
const [alice, aliceCoordinators] = await setupPlayer(scenario); | ||
const [bob, bobCoordinators] = await setupPlayer(scenario); | ||
await scenario.shareAllAgents(); | ||
|
||
await expect( | ||
aliceCoordinators.usernameRegistry.registerAsExternalIdAttestor( | ||
"some-identity-provider" | ||
) | ||
).resolves.not.toThrow(); | ||
|
||
await dhtSync([alice, bob], alice.cells[0].cell_id[0]); | ||
|
||
await expect( | ||
bobCoordinators.usernameRegistry.getAllExternalIdAttestors() | ||
).resolves.toEqual([[alice.agentPubKey, "some-identity-provider"]]); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from "./types"; | ||
export * from "./zome-functions"; | ||
export * from "./utils"; | ||
export * from "./integrity-enums"; |
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