Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ on:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
DFX_VERSION: 0.29.1
jobs:
examples-password-manager-with-metadata-rust-darwin:
runs-on: macos-15
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/examples-password-manager.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ on:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
DFX_VERSION: 0.29.1
jobs:
examples-password-manager-rust-darwin:
runs-on: macos-15
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import IcVetkeys "mo:ic-vetkeys";
import IcVetkeys "../../../../../backend/mo/ic_vetkeys/src";
import Types "mo:ic-vetkeys/Types";
import Principal "mo:base/Principal";
import Text "mo:base/Text";
import Blob "mo:base/Blob";
import Result "mo:base/Result";
import Array "mo:base/Array";

actor class (keyName : Text) {
var encryptedMaps = IcVetkeys.EncryptedMaps.EncryptedMaps<Types.AccessRights>({ curve = #bls12_381_g2; name = keyName }, "encrypted maps dapp", Types.accessRightsOperations());
persistent actor class (keyName : Text) {
let encryptedMapsState = IcVetkeys.EncryptedMaps.newEncryptedMapsState<Types.AccessRights>({ curve = #bls12_381_g2; name = keyName }, "password_manager_example_dapp");
transient let encryptedMaps = IcVetkeys.EncryptedMaps.EncryptedMaps<Types.AccessRights>(encryptedMapsState, Types.accessRightsOperations());

/// In this canister, we use the `ByteBuf` type to represent blobs. The reason is that we want to be consistent with the Rust canister implementation.
/// Unfortunately, the `Blob` type cannot be serialized/deserialized in the current Rust implementation efficiently without nesting it in another type.
public type ByteBuf = { inner : Blob };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,13 @@ import Time "mo:base/Time";
import Nat64 "mo:base/Nat64";
import Int "mo:base/Int";
import Debug "mo:base/Debug";
import VetKeys "mo:ic-vetkeys";
import VetKeys "../../../../../backend/mo/ic_vetkeys/src";

actor class (keyName : Text) {
persistent actor class (keyName : Text) {

// Global state
let accessRightsOperations = VetKeys.accessRightsOperations();
let keyId = { curve = #bls12_381_g2; name = keyName };
let encryptedMaps = VetKeys.EncryptedMaps.EncryptedMaps<VetKeys.AccessRights>(
keyId,
"password_manager_dapp",
accessRightsOperations,
);
let encryptedMapsState = VetKeys.EncryptedMaps.newEncryptedMapsState<VetKeys.AccessRights>({ curve = #bls12_381_g2; name = keyName }, "password_manager_example_dapp");
transient let encryptedMaps = VetKeys.EncryptedMaps.EncryptedMaps<VetKeys.AccessRights>(encryptedMapsState, VetKeys.accessRightsOperations());

func compareMetadataKeys(a : MetadataKey, b : MetadataKey) : {
#less;
Expand All @@ -39,7 +34,7 @@ actor class (keyName : Text) {
ownerCompare;
};
};
let metadataMapOps = OrderedMap.Make<MetadataKey>(compareMetadataKeys);
transient let metadataMapOps = OrderedMap.Make<MetadataKey>(compareMetadataKeys);
var metadata : OrderedMap.Map<MetadataKey, PasswordMetadata> = metadataMapOps.empty<PasswordMetadata>();

// Types
Expand Down Expand Up @@ -249,7 +244,7 @@ actor class (keyName : Text) {
access_rights : VetKeys.AccessRights,
) : async Result<?VetKeys.AccessRights, Text> {
let mapId = (map_owner, map_name.inner);
convertResult(encryptedMaps.keyManager.setUserRights(caller, mapId, user, access_rights));
convertResult(encryptedMaps.setUserRights(caller, mapId, user, access_rights));
};

public shared ({ caller }) func remove_user(
Expand All @@ -258,6 +253,6 @@ actor class (keyName : Text) {
user : Principal,
) : async Result<?VetKeys.AccessRights, Text> {
let mapId = (map_owner, map_name.inner);
convertResult(encryptedMaps.keyManager.removeUserRights(caller, mapId, user));
convertResult(encryptedMaps.removeUser(caller, mapId, user));
};
};
2 changes: 1 addition & 1 deletion examples/password_manager_with_metadata/motoko/dfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
},
"networks": {
"local": {
"bind": "localhost:8000",
"bind": "127.0.0.1:8000",
"type": "ephemeral"
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/password_manager_with_metadata/rust/dfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
},
"networks": {
"local": {
"bind": "localhost:8000",
"bind": "127.0.0.1:8000",
"type": "ephemeral"
}
}
Expand Down