From 8430aac1cd072ac7ac3879b747a7818860e18033 Mon Sep 17 00:00:00 2001 From: Jessie Mongeon Date: Fri, 12 Jul 2024 10:05:57 -0500 Subject: [PATCH] Fix links --- motoko/basic_bitcoin/README.md | 2 +- motoko/basic_dao/README.md | 2 +- motoko/calc/README.md | 4 +- motoko/cert-var/README.md | 2 +- motoko/defi/README.md | 4 +- motoko/dip721-nft-container/README.md | 4 +- motoko/encrypted-notes-dapp/README.md | 2 +- motoko/hello-world/ii.did | 623 ++++++++++++++++++ .../declarations/hello_world/hello_world.did | 3 + .../hello_world/hello_world.did.d.ts | 7 + .../hello_world/hello_world.did.js | 4 + .../src/declarations/hello_world/index.d.ts | 50 ++ .../src/declarations/hello_world/index.js | 42 ++ motoko/hello_cycles/README.md | 2 +- motoko/http_counter/README.md | 2 +- motoko/icp_transfer/README.md | 4 +- motoko/life/README.md | 2 +- motoko/minimal-counter-dapp/README.md | 2 +- motoko/persistent-storage/README.md | 2 +- motoko/pub-sub/README.md | 6 +- motoko/quicksort/README.md | 2 +- motoko/simple-to-do/README.md | 2 +- motoko/superheroes/README.md | 2 +- motoko/token_transfer/README.md | 4 +- motoko/token_transfer_from/README.md | 4 +- motoko/whoami/README.md | 4 +- rust/basic_bitcoin/README.md | 2 +- rust/basic_dao/README.md | 2 +- rust/defi/README.md | 4 +- rust/dip721-nft-container/README.md | 4 +- rust/encrypted-notes-dapp/README.md | 2 +- rust/icp_transfer/README.md | 4 +- rust/pub-sub/README.md | 6 +- rust/token_transfer/README.md | 4 +- rust/token_transfer_from/README.md | 4 +- .../svelte-motoko-starter/internet-identity | 2 +- svelte/svelte-starter/internet-identity | 2 +- 37 files changed, 776 insertions(+), 47 deletions(-) create mode 100644 motoko/hello-world/ii.did create mode 100644 motoko/hello-world/src/declarations/hello_world/hello_world.did create mode 100644 motoko/hello-world/src/declarations/hello_world/hello_world.did.d.ts create mode 100644 motoko/hello-world/src/declarations/hello_world/hello_world.did.js create mode 100644 motoko/hello-world/src/declarations/hello_world/index.d.ts create mode 100644 motoko/hello-world/src/declarations/hello_world/index.js diff --git a/motoko/basic_bitcoin/README.md b/motoko/basic_bitcoin/README.md index 9baa1a5a4..15c882760 100644 --- a/motoko/basic_bitcoin/README.md +++ b/motoko/basic_bitcoin/README.md @@ -166,4 +166,4 @@ If you base your application on this example, we recommend you familiarize yours For example, the following aspects are particularly relevant for this app: * [Certify query responses if they are relevant for security](https://internetcomputer.org/docs/current/references/security/general-security-best-practices#certify-query-responses-if-they-are-relevant-for-security), since the app e.g. offers a method to read balances. -* [Use a decentralized governance system like SNS to make a canister have a decentralized controller](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices#use-a-decentralized-governance-system-like-sns-to-make-a-canister-have-a-decentralized-controller), since decentralized control may be essential for canisters holding Bitcoin on behalf of users. +* [Use a decentralized governance system like SNS to make a canister have a decentralized controller](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview) \ No newline at end of file diff --git a/motoko/basic_dao/README.md b/motoko/basic_dao/README.md index ffda7312b..0941966f2 100644 --- a/motoko/basic_dao/README.md +++ b/motoko/basic_dao/README.md @@ -69,5 +69,5 @@ ic-repl tests/proposal.test.sh If you base your application on this example, we recommend you familiarize yourself with and adhere to the [security best practices](https://internetcomputer.org/docs/current/references/security/) for developing on the Internet Computer. This example may not implement all the best practices. For example, the following aspects are particularly relevant for this app: -* [Use a decentralized governance system like SNS to make a canister have a decentralized controller](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices#use-a-decentralized-governance-system-like-sns-to-make-a-canister-have-a-decentralized-controller), since this is a DAO's use case. +* [Use a decentralized governance system like SNS to make a canister have a decentralized controller](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since this is a DAO's use case. * [Certify query responses if they are relevant for security](https://internetcomputer.org/docs/current/references/security/general-security-best-practices#certify-query-responses-if-they-are-relevant-for-security), since e.g. `account_balance` and `list_accounts` are query calls that a client may want to issue as update call. diff --git a/motoko/calc/README.md b/motoko/calc/README.md index 73262fcc2..a563e4da3 100644 --- a/motoko/calc/README.md +++ b/motoko/calc/README.md @@ -63,5 +63,5 @@ Output: If you base your application on this example, we recommend you familiarize yourself with and adhere to the [security best practices](https://internetcomputer.org/docs/current/references/security/) for developing on the Internet Computer. This example may not implement all the best practices. For example, the following aspects are particularly relevant for this app: -* [Consider using stable memory, version it, test it](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices/#consider-using-stable-memory-version-it-test-it), since this canister uses canister memory and not stable memory. -* [Validate inputs](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices/#validate-inputs), since this canister accepts user input which requires input validation (e.g. div by 0 is not allowed). +* [Consider using stable memory, version it, test it](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since this canister uses canister memory and not stable memory. +* [Validate inputs](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since this canister accepts user input which requires input validation (e.g. div by 0 is not allowed). diff --git a/motoko/cert-var/README.md b/motoko/cert-var/README.md index b2e0554ef..a0db5f6a8 100644 --- a/motoko/cert-var/README.md +++ b/motoko/cert-var/README.md @@ -256,4 +256,4 @@ If you base your application on this example, we recommend you familiarize yours For example, the following aspects are particularly relevant for this app: * [Certify query responses if they are relevant for security](https://internetcomputer.org/docs/current/references/security/general-security-best-practices#certify-query-responses-if-they-are-relevant-for-security), since this app is all about response certification! -* [Validate Inputs](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices/#validate-inputs), since for incrementing the nat32 variable, the argument the inc call may be too big for the addition to be possible. +* [Validate Inputs](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since for incrementing the nat32 variable, the argument the inc call may be too big for the addition to be possible. diff --git a/motoko/defi/README.md b/motoko/defi/README.md index e52424adf..1248f4967 100644 --- a/motoko/defi/README.md +++ b/motoko/defi/README.md @@ -148,7 +148,7 @@ To trade tokens with yourself, you can open a second incognito browser window. If you base your application on this example, we recommend you familiarize yourself with and adhere to the [security best practices](https://internetcomputer.org/docs/current/references/security/) for developing on the Internet Computer. This example may not implement all the best practices. For example, the following aspects are particularly relevant for this app: -* [Inter-canister calls and rollbacks](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices/#inter-canister-calls-and-rollbacks), since issues around inter-canister calls can e.g. lead to time-of-check time-of-use or double spending security bugs. +* [Inter-canister calls and rollbacks](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since issues around inter-canister calls can e.g. lead to time-of-check time-of-use or double spending security bugs. * [Certify query responses if they are relevant for security](https://internetcomputer.org/docs/current/references/security/general-security-best-practices#certify-query-responses-if-they-are-relevant-for-security), since this is essential when e.g. displaying important financial data in the frontend that may be used by users to decide on future transactions. -* [Use a decentralized governance system like SNS to make a canister have a decentralized controller](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices#use-a-decentralized-governance-system-like-sns-to-make-a-canister-have-a-decentralized-controller), since decentralizing control is a fundamental aspect of decentralized finance applications. +* [Use a decentralized governance system like SNS to make a canister have a decentralized controller](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since decentralizing control is a fundamental aspect of decentralized finance applications. diff --git a/motoko/dip721-nft-container/README.md b/motoko/dip721-nft-container/README.md index 9464724b8..a6b866f95 100644 --- a/motoko/dip721-nft-container/README.md +++ b/motoko/dip721-nft-container/README.md @@ -438,9 +438,9 @@ dfx identity get-principal If you base your application on this example, we recommend you familiarize yourself with and adhere to the [security best practices](https://internetcomputer.org/docs/current/references/security/) for developing on the Internet Computer. This example may not implement all the best practices. For example, the following aspects are particularly relevant for this app: -* [Inter-canister calls and rollbacks](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices/#inter-canister-calls-and-rollbacks), since issues around inter-canister calls can e.g. lead to time-of-check time-of-use or double spending security bugs. +* [Inter-canister calls and rollbacks](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since issues around inter-canister calls can e.g. lead to time-of-check time-of-use or double spending security bugs. * [Certify query responses if they are relevant for security](https://internetcomputer.org/docs/current/references/security/general-security-best-practices#certify-query-responses-if-they-are-relevant-for-security), since this is essential when e.g. displaying important NFT data in the frontend that may be used by users to decide on future transactions. -* [Use a decentralized governance system like SNS to make a canister have a decentralized controller](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices#use-a-decentralized-governance-system-like-sns-to-make-a-canister-have-a-decentralized-controller), since decentralizing control is a fundamental aspect when dealing with NFTs. +* [Use a decentralized governance system like SNS to make a canister have a decentralized controller](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since decentralizing control is a fundamental aspect when dealing with NFTs. ## Resources [Rust](https://rustup.rs). diff --git a/motoko/encrypted-notes-dapp/README.md b/motoko/encrypted-notes-dapp/README.md index 81b99c58f..a7cbdb42a 100644 --- a/motoko/encrypted-notes-dapp/README.md +++ b/motoko/encrypted-notes-dapp/README.md @@ -289,7 +289,7 @@ dfx canister --network ic install www --mode=upgrade If you base your application on this example, we recommend you familiarize yourself with and adhere to the [security best practices](https://internetcomputer.org/docs/current/references/security/) for developing on the Internet Computer. This example may not implement all the best practices, see also the [disclaimer](#disclaimer-please-read-carefully) above. For example, the following aspects are particularly relevant for this app: -* [Make sure any action that only a specific user should be able to do requires authentication](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices#make-sure-any-action-that-only-a-specific-user-should-be-able-to-do-requires-authentication), since a user should only be able to manage their own notes. +* [Make sure any action that only a specific user should be able to do requires authentication](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since a user should only be able to manage their own notes. * [Protect key material against XSS using Web Crypto API](https://internetcomputer.org/docs/current/references/security/web-app-development-security-best-practices#crypto-protect-key-material-against-xss-using-web-crypto-api), since this app stores private keys in the browser. * [Use secure cryptographic schemes](https://internetcomputer.org/docs/current/references/security/general-security-best-practices#use-secure-cryptographic-schemes), since notes are being encrypted. diff --git a/motoko/hello-world/ii.did b/motoko/hello-world/ii.did new file mode 100644 index 000000000..f8aa40a10 --- /dev/null +++ b/motoko/hello-world/ii.did @@ -0,0 +1,623 @@ +type UserNumber = nat64; +type PublicKey = blob; +type CredentialId = blob; +type DeviceKey = PublicKey; +type UserKey = PublicKey; +type SessionKey = PublicKey; +type FrontendHostname = text; +type Timestamp = nat64; + +type HeaderField = record { + text; + text; +}; + +type HttpRequest = record { + method: text; + url: text; + headers: vec HeaderField; + body: blob; + certificate_version: opt nat16; +}; + +type HttpResponse = record { + status_code: nat16; + headers: vec HeaderField; + body: blob; + upgrade : opt bool; + streaming_strategy: opt StreamingStrategy; +}; + +type StreamingCallbackHttpResponse = record { + body: blob; + token: opt Token; +}; + +type Token = record {}; + +type StreamingStrategy = variant { + Callback: record { + callback: func (Token) -> (StreamingCallbackHttpResponse) query; + token: Token; + }; +}; + +type Purpose = variant { + recovery; + authentication; +}; + +type KeyType = variant { + unknown; + platform; + cross_platform; + seed_phrase; + browser_storage_key; +}; + +// This describes whether a device is "protected" or not. +// When protected, a device can only be updated or removed if the +// user is authenticated with that very device. +type DeviceProtection = variant { + protected; + unprotected; +}; + +type Challenge = record { + png_base64: text; + challenge_key: ChallengeKey; +}; + +type DeviceData = record { + pubkey : DeviceKey; + alias : text; + credential_id : opt CredentialId; + purpose: Purpose; + key_type: KeyType; + protection: DeviceProtection; + origin: opt text; + // Metadata map for additional device information. + // + // Note: some fields above will be moved to the metadata map in the future. + // All field names of `DeviceData` (such as 'alias', 'origin, etc.) are + // reserved and cannot be written. + // In addition, the keys "usage" and "authenticator_attachment" are reserved as well. + metadata: opt MetadataMap; +}; + +// The same as `DeviceData` but with the `last_usage` field. +// This field cannot be written, hence the separate type. +type DeviceWithUsage = record { + pubkey : DeviceKey; + alias : text; + credential_id : opt CredentialId; + purpose: Purpose; + key_type: KeyType; + protection: DeviceProtection; + origin: opt text; + last_usage: opt Timestamp; + metadata: opt MetadataMap; +}; + +// Map with some variants for the value type. +// Note, due to the Candid mapping this must be a tuple type thus we cannot name the fields `key` and `value`. +type MetadataMap = vec record { + text; + variant { map : MetadataMap; string : text; bytes : vec nat8 }; +}; + +type RegisterResponse = variant { + // A new user was successfully registered. + registered: record { + user_number: UserNumber; + }; + // No more registrations are possible in this instance of the II service canister. + canister_full; + // The challenge was not successful. + bad_challenge; +}; + +type AddTentativeDeviceResponse = variant { + // The device was tentatively added. + added_tentatively: record { + verification_code: text; + // Expiration date, in nanos since the epoch + device_registration_timeout: Timestamp; + }; + // Device registration mode is off, either due to timeout or because it was never enabled. + device_registration_mode_off; + // There is another device already added tentatively + another_device_tentatively_added; +}; + +type VerifyTentativeDeviceResponse = variant { + // The device was successfully verified. + verified; + // Wrong verification code entered. Retry with correct code. + wrong_code: record { + retries_left: nat8 + }; + // Device registration mode is off, either due to timeout or because it was never enabled. + device_registration_mode_off; + // There is no tentative device to be verified. + no_device_to_verify; +}; + +type Delegation = record { + pubkey: PublicKey; + expiration: Timestamp; + targets: opt vec principal; +}; + +type SignedDelegation = record { + delegation: Delegation; + signature: blob; +}; + +type GetDelegationResponse = variant { + // The signed delegation was successfully retrieved. + signed_delegation: SignedDelegation; + + // The signature is not ready. Maybe retry by calling `prepare_delegation` + no_such_delegation +}; + +type InternetIdentityStats = record { + users_registered: nat64; + storage_layout_version: nat8; + assigned_user_number_range: record { + nat64; + nat64; + }; + archive_info: ArchiveInfo; + canister_creation_cycles_cost: nat64; + // Map from event aggregation to a sorted list of top 100 sub-keys to their weights. + // Example: {"prepare_delegation_count 24h ic0.app": [{"https://dapp.com", 100}, {"https://dapp2.com", 50}]} + event_aggregations: vec record {text; vec record {text; nat64}}; +}; + +// Configuration parameters related to the archive. +type ArchiveConfig = record { + // The allowed module hash of the archive canister. + // Changing this parameter does _not_ deploy the archive, but enable archive deployments with the + // corresponding wasm module. + module_hash : blob; + // Buffered archive entries limit. If reached, II will stop accepting new anchor operations + // until the buffered operations are acknowledged by the archive. + entries_buffer_limit: nat64; + // The maximum number of entries to be transferred to the archive per call. + entries_fetch_limit: nat16; + // Polling interval to fetch new entries from II (in nanoseconds). + // Changes to this parameter will only take effect after an archive deployment. + polling_interval_ns: nat64; +}; + +// Information about the archive. +type ArchiveInfo = record { + // Canister id of the archive or empty if no archive has been deployed yet. + archive_canister : opt principal; + // Configuration parameters related to the II archive. + archive_config: opt ArchiveConfig; +}; + +// Rate limit configuration. +// Currently only used for `register`. +type RateLimitConfig = record { + // Time it takes (in ns) for a rate limiting token to be replenished. + time_per_token_ns : nat64; + // How many tokens are at most generated (to accommodate peaks). + max_tokens: nat64; +}; + +// Init arguments of II which can be supplied on install and upgrade. +// Setting a value to null keeps the previous value. +type InternetIdentityInit = record { + // Set lowest and highest anchor + assigned_user_number_range : opt record { + nat64; + nat64; + }; + // Configuration parameters related to the II archive. + // Note: some parameters changes (like the polling interval) will only take effect after an archive deployment. + // See ArchiveConfig for details. + archive_config: opt ArchiveConfig; + // Set the amounts of cycles sent with the create canister message. + // This is configurable because in the staging environment cycles are required. + // The canister creation cost on mainnet is currently 100'000'000'000 cycles. If this value is higher thant the + // canister creation cost, the newly created canister will keep extra cycles. + canister_creation_cycles_cost : opt nat64; + // Rate limit for the `register` call. + register_rate_limit : opt RateLimitConfig; + // Maximum number of inflight captchas. + // Default: 500 + max_inflight_captchas: opt nat64; +}; + +type ChallengeKey = text; + +type ChallengeResult = record { + key : ChallengeKey; + chars : text; +}; +type CaptchaResult = ChallengeResult; + +// Extra information about registration status for new devices +type DeviceRegistrationInfo = record { + // If present, the user has tentatively added a new device. This + // new device needs to be verified (see relevant endpoint) before + // 'expiration'. + tentative_device : opt DeviceData; + // The timestamp at which the anchor will turn off registration mode + // (and the tentative device will be forgotten, if any, and if not verified) + expiration: Timestamp; +}; + +// Information about the anchor +type IdentityAnchorInfo = record { + // All devices that can authenticate to this anchor + devices : vec DeviceWithUsage; + // Device registration status used when adding devices, see DeviceRegistrationInfo + device_registration: opt DeviceRegistrationInfo; +}; + +type AnchorCredentials = record { + credentials : vec WebAuthnCredential; + recovery_credentials : vec WebAuthnCredential; + recovery_phrases: vec PublicKey; +}; + +type WebAuthnCredential = record { + credential_id : CredentialId; + pubkey: PublicKey; +}; + +type DeployArchiveResult = variant { + // The archive was deployed successfully and the supplied wasm module has been installed. The principal of the archive + // canister is returned. + success: principal; + // Initial archive creation is already in progress. + creation_in_progress; + // Archive deployment failed. An error description is returned. + failed: text; +}; + +type BufferedArchiveEntry = record { + anchor_number: UserNumber; + timestamp: Timestamp; + sequence_number: nat64; + entry: blob; +}; + +// API V2 specific types +// WARNING: These type are experimental and may change in the future. + +type IdentityNumber = nat64; + +// Map with some variants for the value type. +// Note, due to the Candid mapping this must be a tuple type thus we cannot name the fields `key` and `value`. +type MetadataMapV2 = vec record { + text; + variant { Map : MetadataMapV2; String : text; Bytes : vec nat8 }; +}; + +// Authentication method using WebAuthn signatures +// See https://www.w3.org/TR/webauthn-2/ +// This is a separate type because WebAuthn requires to also store +// the credential id (in addition to the public key). +type WebAuthn = record { + credential_id: CredentialId; + pubkey: PublicKey; +}; + +// Authentication method using generic signatures +// See https://internetcomputer.org/docs/current/references/ic-interface-spec/#signatures for +// supported signature schemes. +type PublicKeyAuthn = record { + pubkey: PublicKey; +}; + +// The authentication methods currently supported by II. +type AuthnMethod = variant { + WebAuthn: WebAuthn; + PubKey: PublicKeyAuthn; +}; + +// This describes whether an authentication method is "protected" or not. +// When protected, a authentication method can only be updated or removed if the +// user is authenticated with that very authentication method. +type AuthnMethodProtection = variant { + Protected; + Unprotected; +}; + +type AuthnMethodPurpose = variant { + Recovery; + Authentication; +}; + +type AuthnMethodSecuritySettings = record { + protection: AuthnMethodProtection; + purpose: AuthnMethodPurpose; +}; + +type AuthnMethodData = record { + authn_method: AuthnMethod; + security_settings: AuthnMethodSecuritySettings; + // contains the following fields of the DeviceWithUsage type: + // - alias + // - origin + // - authenticator_attachment: data taken from key_type and reduced to "platform", "cross_platform" or absent on migration + // - usage: data taken from key_type and reduced to "recovery_phrase", "browser_storage_key" or absent on migration + // Note: for compatibility reasons with the v1 API, the entries above (if present) + // must be of the `String` variant. This restriction may be lifted in the future. + metadata: MetadataMapV2; + last_authentication: opt Timestamp; +}; + +// Extra information about registration status for new authentication methods +type AuthnMethodRegistrationInfo = record { + // If present, the user has registered a new authentication method. This + // new authentication needs to be verified before 'expiration' in order to + // be added to the identity. + authn_method : opt AuthnMethodData; + // The timestamp at which the identity will turn off registration mode + // (and the authentication method will be forgotten, if any, and if not verified) + expiration: Timestamp; +}; + +type AuthnMethodConfirmationCode = record { + confirmation_code: text; + expiration: Timestamp; +}; + +type AuthnMethodRegisterError = variant { + // Authentication method registration mode is off, either due to timeout or because it was never enabled. + RegistrationModeOff; + // There is another authentication method already registered that needs to be confirmed first. + RegistrationAlreadyInProgress; + // The metadata of the provided authentication method contains invalid entries. + InvalidMetadata: text; +}; + +type AuthnMethodConfirmationError = variant { + // Wrong confirmation code entered. Retry with correct code. + WrongCode: record { + retries_left: nat8 + }; + // Authentication method registration mode is off, either due to timeout or because it was never enabled. + RegistrationModeOff; + // There is no registered authentication method to be confirmed. + NoAuthnMethodToConfirm; +}; + +type IdentityAuthnInfo = record { + authn_methods: vec AuthnMethod; + recovery_authn_methods: vec AuthnMethod; +}; + +type IdentityInfo = record { + authn_methods: vec AuthnMethodData; + authn_method_registration: opt AuthnMethodRegistrationInfo; + // Authentication method independent metadata + metadata: MetadataMapV2; +}; + +type IdentityInfoError = variant { + /// The principal is not authorized to call this method with the given arguments. + Unauthorized: principal; + /// Internal canister error. See the error message for details. + InternalCanisterError: text; +}; + + + +type IdentityRegisterError = variant { + // No more registrations are possible in this instance of the II service canister. + CanisterFull; + // The captcha check was not successful. + BadCaptcha; + // The metadata of the provided authentication method contains invalid entries. + InvalidMetadata: text; +}; + +type AuthnMethodAddError = variant { + InvalidMetadata: text; +}; + +type AuthnMethodReplaceError = variant { + InvalidMetadata: text; + // No authentication method found with the given public key. + AuthnMethodNotFound; +}; + +type AuthnMethodMetadataReplaceError = variant { + InvalidMetadata: text; + /// No authentication method found with the given public key. + AuthnMethodNotFound; +}; + +type AuthnMethodSecuritySettingsReplaceError = variant { + /// No authentication method found with the given public key. + AuthnMethodNotFound; +}; + +type IdentityMetadataReplaceError = variant { + /// The principal is not authorized to call this method with the given arguments. + Unauthorized: principal; + /// The identity including the new metadata exceeds the maximum allowed size. + StorageSpaceExceeded: record {space_available: nat64; space_required: nat64}; + /// Internal canister error. See the error message for details. + InternalCanisterError: text; +}; + +type PrepareIdAliasRequest = record { + /// Origin of the issuer in the attribute sharing flow. + issuer : FrontendHostname; + /// Origin of the relying party in the attribute sharing flow. + relying_party : FrontendHostname; + /// Identity for which the IdAlias should be generated. + identity_number : IdentityNumber; +}; + +type PrepareIdAliasError = variant { + /// The principal is not authorized to call this method with the given arguments. + Unauthorized: principal; + /// Internal canister error. See the error message for details. + InternalCanisterError: text; +}; + +/// The prepared id alias contains two (still unsigned) credentials in JWT format, +/// certifying the id alias for the issuer resp. the relying party. +type PreparedIdAlias = record { + rp_id_alias_jwt : text; + issuer_id_alias_jwt : text; + canister_sig_pk_der : PublicKey; +}; + +/// The request to retrieve the actual signed id alias credentials. +/// The field values should be equal to the values of corresponding +/// fields from the preceding `PrepareIdAliasRequest` and `PrepareIdAliasResponse`. +type GetIdAliasRequest = record { + rp_id_alias_jwt : text; + issuer : FrontendHostname; + issuer_id_alias_jwt : text; + relying_party : FrontendHostname; + identity_number : IdentityNumber; +}; + +type GetIdAliasError = variant { + /// The principal is not authorized to call this method with the given arguments. + Unauthorized: principal; + /// The credential(s) are not available: may be expired or not prepared yet (call prepare_id_alias to prepare). + NoSuchCredentials : text; + /// Internal canister error. See the error message for details. + InternalCanisterError: text; +}; + +/// The signed id alias credentials for each involved party. +type IdAliasCredentials = record { + rp_id_alias_credential : SignedIdAlias; + issuer_id_alias_credential : SignedIdAlias; +}; + +type SignedIdAlias = record { + credential_jws : text; + id_alias : principal; + id_dapp : principal; +}; + +service : (opt InternetIdentityInit) -> { + init_salt: () -> (); + create_challenge : () -> (Challenge); + register : (DeviceData, ChallengeResult, opt principal) -> (RegisterResponse); + add : (UserNumber, DeviceData) -> (); + update : (UserNumber, DeviceKey, DeviceData) -> (); + // Atomically replace device matching the device key with the new device data + replace : (UserNumber, DeviceKey, DeviceData) -> (); + remove : (UserNumber, DeviceKey) -> (); + // Returns all devices of the user (authentication and recovery) but no information about device registrations. + // Note: Clears out the 'alias' fields on the devices. Use 'get_anchor_info' to obtain the full information. + // Deprecated: Use 'get_anchor_credentials' instead. + lookup : (UserNumber) -> (vec DeviceData) query; + get_anchor_credentials : (UserNumber) -> (AnchorCredentials) query; + get_anchor_info : (UserNumber) -> (IdentityAnchorInfo); + get_principal : (UserNumber, FrontendHostname) -> (principal) query; + stats : () -> (InternetIdentityStats) query; + + enter_device_registration_mode : (UserNumber) -> (Timestamp); + exit_device_registration_mode : (UserNumber) -> (); + add_tentative_device : (UserNumber, DeviceData) -> (AddTentativeDeviceResponse); + verify_tentative_device : (UserNumber, verification_code: text) -> (VerifyTentativeDeviceResponse); + + prepare_delegation : (UserNumber, FrontendHostname, SessionKey, maxTimeToLive : opt nat64) -> (UserKey, Timestamp); + get_delegation: (UserNumber, FrontendHostname, SessionKey, Timestamp) -> (GetDelegationResponse) query; + + http_request: (request: HttpRequest) -> (HttpResponse) query; + http_request_update: (request: HttpRequest) -> (HttpResponse); + + deploy_archive: (wasm: blob) -> (DeployArchiveResult); + // Returns a batch of entries _sorted by sequence number_ to be archived. + // This is an update call because the archive information _must_ be certified. + // Only callable by this IIs archive canister. + fetch_entries: () -> (vec BufferedArchiveEntry); + acknowledge_entries: (sequence_number: nat64) -> (); + + // Calls used for event stats housekeeping. + // Only callable by the canister itself. + prune_events_if_necessary: () -> (); + inject_prune_event: (timestamp: Timestamp) -> (); + + // V2 API + // WARNING: The following methods are experimental and may change in the future. + + // Creates a new captcha. The solution needs to be submitted using the + // `identity_register` call. + captcha_create: () -> (variant {Ok: Challenge; Err;}); + + // Registers a new identity with the given authn_method. + // A valid captcha solution to a previously generated captcha (using create_captcha) must be provided. + // The sender needs to match the supplied authn_method. + identity_register: (AuthnMethodData, CaptchaResult, opt principal) -> (variant {Ok: IdentityNumber; Err: IdentityRegisterError;}); + + // Returns information about the authentication methods of the identity with the given number. + // Only returns the minimal information required for authentication without exposing any metadata such as aliases. + identity_authn_info: (IdentityNumber) -> (variant {Ok: IdentityAuthnInfo; Err;}) query; + + // Returns information about the identity with the given number. + // Requires authentication. + identity_info: (IdentityNumber) -> (variant {Ok: IdentityInfo; Err: IdentityInfoError;}); + + // Replaces the authentication method independent metadata map. + // The existing metadata map will be overwritten. + // Requires authentication. + identity_metadata_replace: (IdentityNumber, MetadataMapV2) -> (variant {Ok; Err: IdentityMetadataReplaceError;}); + + // Adds a new authentication method to the identity. + // Requires authentication. + authn_method_add: (IdentityNumber, AuthnMethodData) -> (variant {Ok; Err: AuthnMethodAddError;}); + + // Atomically replaces the authentication method matching the supplied public key with the new authentication method + // provided. + // Requires authentication. + authn_method_replace: (IdentityNumber, PublicKey, AuthnMethodData) -> (variant {Ok; Err: AuthnMethodReplaceError;}); + + // Replaces the authentication method metadata map. + // The existing metadata map will be overwritten. + // Requires authentication. + authn_method_metadata_replace: (IdentityNumber, PublicKey, MetadataMapV2) -> (variant {Ok; Err: AuthnMethodMetadataReplaceError;}); + + // Replaces the authentication method security settings. + // The existing security settings will be overwritten. + // Requires authentication. + authn_method_security_settings_replace: (IdentityNumber, PublicKey, AuthnMethodSecuritySettings) -> (variant {Ok; Err: AuthnMethodSecuritySettingsReplaceError;}); + + // Removes the authentication method associated with the public key from the identity. + // Requires authentication. + authn_method_remove: (IdentityNumber, PublicKey) -> (variant {Ok; Err;}); + + // Enters the authentication method registration mode for the identity. + // In this mode, a new authentication method can be registered, which then needs to be + // confirmed before it can be used for authentication on this identity. + // The registration mode is automatically exited after the returned expiration timestamp. + // Requires authentication. + authn_method_registration_mode_enter : (IdentityNumber) -> (variant {Ok: record { expiration: Timestamp; }; Err;}); + + // Exits the authentication method registration mode for the identity. + // Requires authentication. + authn_method_registration_mode_exit : (IdentityNumber) -> (variant {Ok; Err;}); + + // Registers a new authentication method to the identity. + // This authentication method needs to be confirmed before it can be used for authentication on this identity. + authn_method_register: (IdentityNumber, AuthnMethodData) -> (variant {Ok: AuthnMethodConfirmationCode; Err: AuthnMethodRegisterError;}); + + // Confirms a previously registered authentication method. + // On successful confirmation, the authentication method is permanently added to the identity and can + // subsequently be used for authentication for that identity. + // Requires authentication. + authn_method_confirm: (IdentityNumber, confirmation_code: text) -> (variant {Ok; Err: AuthnMethodConfirmationError;}); + + // Attribute Sharing MVP API + // The methods below are used to generate ID-alias credentials during attribute sharing flow. + prepare_id_alias : (PrepareIdAliasRequest) -> (variant {Ok: PreparedIdAlias; Err: PrepareIdAliasError;}); + get_id_alias : (GetIdAliasRequest) -> (variant {Ok: IdAliasCredentials; Err: GetIdAliasError;}) query; +} diff --git a/motoko/hello-world/src/declarations/hello_world/hello_world.did b/motoko/hello-world/src/declarations/hello_world/hello_world.did new file mode 100644 index 000000000..f10f729ac --- /dev/null +++ b/motoko/hello-world/src/declarations/hello_world/hello_world.did @@ -0,0 +1,3 @@ +service : { + main: () -> () oneway; +} diff --git a/motoko/hello-world/src/declarations/hello_world/hello_world.did.d.ts b/motoko/hello-world/src/declarations/hello_world/hello_world.did.d.ts new file mode 100644 index 000000000..a98764298 --- /dev/null +++ b/motoko/hello-world/src/declarations/hello_world/hello_world.did.d.ts @@ -0,0 +1,7 @@ +import type { Principal } from '@dfinity/principal'; +import type { ActorMethod } from '@dfinity/agent'; +import type { IDL } from '@dfinity/candid'; + +export interface _SERVICE { 'main' : ActorMethod<[], undefined> } +export declare const idlFactory: IDL.InterfaceFactory; +export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[]; diff --git a/motoko/hello-world/src/declarations/hello_world/hello_world.did.js b/motoko/hello-world/src/declarations/hello_world/hello_world.did.js new file mode 100644 index 000000000..8df5488ab --- /dev/null +++ b/motoko/hello-world/src/declarations/hello_world/hello_world.did.js @@ -0,0 +1,4 @@ +export const idlFactory = ({ IDL }) => { + return IDL.Service({ 'main' : IDL.Func([], [], ['oneway']) }); +}; +export const init = ({ IDL }) => { return []; }; diff --git a/motoko/hello-world/src/declarations/hello_world/index.d.ts b/motoko/hello-world/src/declarations/hello_world/index.d.ts new file mode 100644 index 000000000..d22b2d285 --- /dev/null +++ b/motoko/hello-world/src/declarations/hello_world/index.d.ts @@ -0,0 +1,50 @@ +import type { + ActorSubclass, + HttpAgentOptions, + ActorConfig, + Agent, +} from "@dfinity/agent"; +import type { Principal } from "@dfinity/principal"; +import type { IDL } from "@dfinity/candid"; + +import { _SERVICE } from './hello_world.did'; + +export declare const idlFactory: IDL.InterfaceFactory; +export declare const canisterId: string; + +export declare interface CreateActorOptions { + /** + * @see {@link Agent} + */ + agent?: Agent; + /** + * @see {@link HttpAgentOptions} + */ + agentOptions?: HttpAgentOptions; + /** + * @see {@link ActorConfig} + */ + actorOptions?: ActorConfig; +} + +/** + * Intializes an {@link ActorSubclass}, configured with the provided SERVICE interface of a canister. + * @constructs {@link ActorSubClass} + * @param {string | Principal} canisterId - ID of the canister the {@link Actor} will talk to + * @param {CreateActorOptions} options - see {@link CreateActorOptions} + * @param {CreateActorOptions["agent"]} options.agent - a pre-configured agent you'd like to use. Supercedes agentOptions + * @param {CreateActorOptions["agentOptions"]} options.agentOptions - options to set up a new agent + * @see {@link HttpAgentOptions} + * @param {CreateActorOptions["actorOptions"]} options.actorOptions - options for the Actor + * @see {@link ActorConfig} + */ +export declare const createActor: ( + canisterId: string | Principal, + options?: CreateActorOptions +) => ActorSubclass<_SERVICE>; + +/** + * Intialized Actor using default settings, ready to talk to a canister using its candid interface + * @constructs {@link ActorSubClass} + */ +export declare const hello_world: ActorSubclass<_SERVICE>; diff --git a/motoko/hello-world/src/declarations/hello_world/index.js b/motoko/hello-world/src/declarations/hello_world/index.js new file mode 100644 index 000000000..29b7fd9ff --- /dev/null +++ b/motoko/hello-world/src/declarations/hello_world/index.js @@ -0,0 +1,42 @@ +import { Actor, HttpAgent } from "@dfinity/agent"; + +// Imports and re-exports candid interface +import { idlFactory } from "./hello_world.did.js"; +export { idlFactory } from "./hello_world.did.js"; + +/* CANISTER_ID is replaced by webpack based on node environment + * Note: canister environment variable will be standardized as + * process.env.CANISTER_ID_ + * beginning in dfx 0.15.0 + */ +export const canisterId = + process.env.CANISTER_ID_HELLO_WORLD; + +export const createActor = (canisterId, options = {}) => { + const agent = options.agent || new HttpAgent({ ...options.agentOptions }); + + if (options.agent && options.agentOptions) { + console.warn( + "Detected both agent and agentOptions passed to createActor. Ignoring agentOptions and proceeding with the provided agent." + ); + } + + // Fetch root key for certificate validation during development + if (process.env.DFX_NETWORK !== "ic") { + agent.fetchRootKey().catch((err) => { + console.warn( + "Unable to fetch root key. Check to ensure that your local replica is running" + ); + console.error(err); + }); + } + + // Creates an actor with using the candid interface and the HttpAgent + return Actor.createActor(idlFactory, { + agent, + canisterId, + ...options.actorOptions, + }); +}; + +export const hello_world = canisterId ? createActor(canisterId) : undefined; diff --git a/motoko/hello_cycles/README.md b/motoko/hello_cycles/README.md index c0bfe991d..bf3340cfe 100644 --- a/motoko/hello_cycles/README.md +++ b/motoko/hello_cycles/README.md @@ -157,5 +157,5 @@ Without some additional access control checks (omitted here), a malicious client If you base your application on this example, we recommend you familiarize yourself with and adhere to the [security best practices](https://internetcomputer.org/docs/current/references/security/) for developing on the Internet Computer. This example may not implement all the best practices. For example, the following aspect is particularly relevant for this app: -* [Protect against draining the cycles balance](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices#protect-against-draining-the-cycles-balance), since this canister consumes cycles that are being transferred to other canisters. +* [Protect against draining the cycles balance](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since this canister consumes cycles that are being transferred to other canisters. diff --git a/motoko/http_counter/README.md b/motoko/http_counter/README.md index ceba1cb65..1eb3298d4 100644 --- a/motoko/http_counter/README.md +++ b/motoko/http_counter/README.md @@ -81,4 +81,4 @@ curl --compressed -X POST "$CANISTER_ID.localhost:4943/" --resolve "$CANISTER_ID If you base your application on this example, we recommend you familiarize yourself with and adhere to the [security best practices](https://internetcomputer.org/docs/current/references/security/) for developing on the Internet Computer. This example may not implement all the best practices. For example, the following aspect is particularly relevant for this app: -* [Use HTTP asset certification and avoid serving your dApp through raw.ic0.app](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices#use-http-asset-certification-and-avoid-serving-your-dapp-through-rawic0app), in case the HTTP responses should come with authenticity guarantees. +* [Use HTTP asset certification and avoid serving your dApp through raw.ic0.app](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), in case the HTTP responses should come with authenticity guarantees. diff --git a/motoko/icp_transfer/README.md b/motoko/icp_transfer/README.md index 560652599..e50b1a49f 100644 --- a/motoko/icp_transfer/README.md +++ b/motoko/icp_transfer/README.md @@ -270,6 +270,6 @@ If you base your application on this example, we recommend you familiarize yours For example, the following aspects are particularly relevant for this app: -- [Inter-canister calls and rollbacks](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices/#inter-canister-calls-and-rollbacks), since issues around inter-canister calls (here the ledger) can e.g. lead to time-of-check time-of-use or double spending security bugs. +- [Inter-canister calls and rollbacks](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since issues around inter-canister calls (here the ledger) can e.g. lead to time-of-check time-of-use or double spending security bugs. - [Certify query responses if they are relevant for security](https://internetcomputer.org/docs/current/references/security/general-security-best-practices#certify-query-responses-if-they-are-relevant-for-security), since this is essential when e.g. displaying important financial data in the frontend that may be used by users to decide on future transactions. -- [Use a decentralized governance system like SNS to make a canister have a decentralized controller](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices#use-a-decentralized-governance-system-like-sns-to-make-a-canister-have-a-decentralized-controller), since decentralizing control is a fundamental aspect of decentralized finance applications. +- [Use a decentralized governance system like SNS to make a canister have a decentralized controller](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since decentralizing control is a fundamental aspect of decentralized finance applications. diff --git a/motoko/life/README.md b/motoko/life/README.md index 4076833ff..55d2e3f0e 100644 --- a/motoko/life/README.md +++ b/motoko/life/README.md @@ -149,5 +149,5 @@ Click the button **Run**, then click the button **Pause** when bored. Open **Det If you base your application on this example, we recommend you familiarize yourself with and adhere to the [security best practices](https://internetcomputer.org/docs/current/references/security/) for developing on the Internet Computer. This example may not implement all the best practices. For example, the following aspect is particularly relevant for this app: -* [Consider using stable memory, version it, test it](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices#consider-using-stable-memory-version-it-test-it), since this example is about using stable memory. The best practice focuses on Rust, but are partly also applicable to Motoko. +* [Consider using stable memory, version it, test it](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since this example is about using stable memory. The best practice focuses on Rust, but are partly also applicable to Motoko. diff --git a/motoko/minimal-counter-dapp/README.md b/motoko/minimal-counter-dapp/README.md index 675ea10e6..31b00c01a 100644 --- a/motoko/minimal-counter-dapp/README.md +++ b/motoko/minimal-counter-dapp/README.md @@ -200,5 +200,5 @@ This project is licensed under the Apache 2.0 license, see LICENSE.md for detail If you base your application on this example, we recommend you familiarize yourself with and adhere to the [security best practices](https://internetcomputer.org/docs/current/references/security/) for developing on the Internet Computer. This example may not implement all the best practices. For example, the following aspects are particularly relevant for this app: -* [Use HTTP asset certification and avoid serving your dApp through raw.ic0.app](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices#use-http-asset-certification-and-avoid-serving-your-dapp-through-rawic0app), since this app serves a frontend. +* [Use HTTP asset certification and avoid serving your dApp through raw.ic0.app](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since this app serves a frontend. * [Certify query responses if they are relevant for security](https://internetcomputer.org/docs/current/references/security/general-security-best-practices#certify-query-responses-if-they-are-relevant-for-security), since this app uses query calls. diff --git a/motoko/persistent-storage/README.md b/motoko/persistent-storage/README.md index 3ab54df2a..a56e2b4ee 100644 --- a/motoko/persistent-storage/README.md +++ b/motoko/persistent-storage/README.md @@ -158,5 +158,5 @@ This project is licensed under the Apache 2.0 license, see LICENSE.md for detail If you base your application on this example, we recommend you familiarize yourself with and adhere to the [Security Best Practices](https://internetcomputer.org/docs/current/references/security/) for developing on the Internet Computer. This example may not implement all the best practices. For example, the following aspects are particularly relevant for this app: -* [Consider using stable memory, version it, test it](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices#consider-using-stable-memory-version-it-test-it), since this canister uses stable memory. +* [Consider using stable memory, version it, test it](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since this canister uses stable memory. * [Certify query responses if they are relevant for security](https://internetcomputer.org/docs/current/references/security/general-security-best-practices#certify-query-responses-if-they-are-relevant-for-security), since this canister provides query calls. diff --git a/motoko/pub-sub/README.md b/motoko/pub-sub/README.md index 23ab1baba..8ce86d03f 100644 --- a/motoko/pub-sub/README.md +++ b/motoko/pub-sub/README.md @@ -62,6 +62,6 @@ The output should resemble the following: If you base your application on this example, we recommend you familiarize yourself with and adhere to the [security best practices](https://internetcomputer.org/docs/current/references/security/) for developing on the Internet Computer. This example may not implement all the best practices. For example, the following aspects are particularly relevant for this app, since it makes inter-canister calls: -* [Be aware that state may change during inter-canister calls.](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices#be-aware-that-state-may-change-during-inter-canister-calls) -* [Only make inter-canister calls to trustworthy canisters.](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices#only-make-inter-canister-calls-to-trustworthy-canisters) -* [Don’t panic after await and don’t lock shared resources across await boundaries.](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices#dont-panic-after-await-and-dont-lock-shared-resources-across-await-boundaries) +* [Be aware that state may change during inter-canister calls.](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview) +* [Only make inter-canister calls to trustworthy canisters.](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview) +* [Don’t panic after await and don’t lock shared resources across await boundaries.](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview) diff --git a/motoko/quicksort/README.md b/motoko/quicksort/README.md index 767c879ad..4a59c5225 100644 --- a/motoko/quicksort/README.md +++ b/motoko/quicksort/README.md @@ -62,4 +62,4 @@ The output will resemble the following: If you base your application on this example, we recommend you familiarize yourself with and adhere to the [security best practices](https://internetcomputer.org/docs/current/references/security/) for developing on the Internet Computer. This example may not implement all the best practices. For example, the following aspect is particularly relevant for this app: -* [Validate inputs](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices#validate-inputs), since lists of integers are provided as input to the sorting algorithm. +* [Validate inputs](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since lists of integers are provided as input to the sorting algorithm. diff --git a/motoko/simple-to-do/README.md b/motoko/simple-to-do/README.md index b49b3826b..01e6dac2e 100644 --- a/motoko/simple-to-do/README.md +++ b/motoko/simple-to-do/README.md @@ -88,5 +88,5 @@ ___TO-DOs___ If you base your application on this example, we recommend you familiarize yourself with and adhere to the [security best practices](https://internetcomputer.org/docs/current/references/security/) for developing on the Internet Computer. This example may not implement all the best practices. For example, the following aspect is particularly relevant for this app: -* [Validate inputs](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices#validate-inputs), since this canister processes user-provided input. +* [Validate inputs](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since this canister processes user-provided input. diff --git a/motoko/superheroes/README.md b/motoko/superheroes/README.md index 74d33be97..7d81ab047 100644 --- a/motoko/superheroes/README.md +++ b/motoko/superheroes/README.md @@ -52,6 +52,6 @@ echo "http://127.0.0.1:4943/?canisterId=$(dfx canister id www)" If you base your application on this example, we recommend you familiarize yourself with and adhere to the [security best practices](https://internetcomputer.org/docs/current/references/security/) for developing on the Internet Computer. This example may not implement all the best practices. For example, the following aspects are particularly relevant for this app: -* [Use HTTP asset certification and avoid serving your dApp through raw.ic0.app](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices#use-http-asset-certification-and-avoid-serving-your-dapp-through-rawic0app), since this app serves a frontend. +* [Use HTTP asset certification and avoid serving your dApp through raw.ic0.app](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since this app serves a frontend. * [Certify query responses if they are relevant for security](https://internetcomputer.org/docs/current/references/security/general-security-best-practices#certify-query-responses-if-they-are-relevant-for-security), since this app uses query calls. diff --git a/motoko/token_transfer/README.md b/motoko/token_transfer/README.md index 2b13cab94..a839dc0b7 100644 --- a/motoko/token_transfer/README.md +++ b/motoko/token_transfer/README.md @@ -283,6 +283,6 @@ If you base your application on this example, we recommend you familiarize yours For example, the following aspects are particularly relevant for this app: -- [Inter-canister calls and rollbacks](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices/#inter-canister-calls-and-rollbacks), since issues around inter-canister calls (here the ledger) can e.g. lead to time-of-check time-of-use or double spending security bugs. +- [Inter-canister calls and rollbacks](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since issues around inter-canister calls (here the ledger) can e.g. lead to time-of-check time-of-use or double spending security bugs. - [Certify query responses if they are relevant for security](https://internetcomputer.org/docs/current/references/security/general-security-best-practices#certify-query-responses-if-they-are-relevant-for-security), since this is essential when e.g. displaying important financial data in the frontend that may be used by users to decide on future transactions. In this example, this is e.g. relevant for the call to `canisterBalance`. -- [Use a decentralized governance system like SNS to make a canister have a decentralized controller](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices#use-a-decentralized-governance-system-like-sns-to-make-a-canister-have-a-decentralized-controller), since decentralizing control is a fundamental aspect of decentralized finance applications. +- [Use a decentralized governance system like SNS to make a canister have a decentralized controller](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since decentralizing control is a fundamental aspect of decentralized finance applications. diff --git a/motoko/token_transfer_from/README.md b/motoko/token_transfer_from/README.md index 79bbbed2e..a176663fc 100644 --- a/motoko/token_transfer_from/README.md +++ b/motoko/token_transfer_from/README.md @@ -284,6 +284,6 @@ If you base your application on this example, we recommend you familiarize yours For example, the following aspects are particularly relevant for this app: -- [Inter-canister calls and rollbacks](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices/#inter-canister-calls-and-rollbacks), since issues around inter-canister calls (here the ledger) can e.g. lead to time-of-check time-of-use or double spending security bugs. +- [Inter-canister calls and rollbacks](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since issues around inter-canister calls (here the ledger) can e.g. lead to time-of-check time-of-use or double spending security bugs. - [Certify query responses if they are relevant for security](https://internetcomputer.org/docs/current/references/security/general-security-best-practices#certify-query-responses-if-they-are-relevant-for-security), since this is essential when e.g. displaying important financial data in the frontend that may be used by users to decide on future transactions. -- [Use a decentralized governance system like SNS to make a canister have a decentralized controller](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices#use-a-decentralized-governance-system-like-sns-to-make-a-canister-have-a-decentralized-controller), since decentralizing control is a fundamental aspect of decentralized finance applications. +- [Use a decentralized governance system like SNS to make a canister have a decentralized controller](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since decentralizing control is a fundamental aspect of decentralized finance applications. diff --git a/motoko/whoami/README.md b/motoko/whoami/README.md index ce33476c3..23248ea03 100644 --- a/motoko/whoami/README.md +++ b/motoko/whoami/README.md @@ -56,5 +56,5 @@ dfx canister call whoami id If you base your application on this example, we recommend you familiarize yourself with and adhere to the [security best practices](https://internetcomputer.org/docs/current/references/security/) for developing on the Internet Computer. This example may not implement all the best practices. For example, the following aspects are particularly relevant for this app: -* [Make sure any action that only a specific user should be able to do requires authentication](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices#make-sure-any-action-that-only-a-specific-user-should-be-able-to-do-requires-authentication), since this example illustrates how to access the caller system API. -* [Disallow the anonymous principal in authenticated calls](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices#disallow-the-anonymous-principal-in-authenticated-calls), since the caller system API may return the anonymous principal. +* [Make sure any action that only a specific user should be able to do requires authentication](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since this example illustrates how to access the caller system API. +* [Disallow the anonymous principal in authenticated calls](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since the caller system API may return the anonymous principal. diff --git a/rust/basic_bitcoin/README.md b/rust/basic_bitcoin/README.md index 93af88a82..c9bb408f0 100644 --- a/rust/basic_bitcoin/README.md +++ b/rust/basic_bitcoin/README.md @@ -169,4 +169,4 @@ If you base your application on this example, we recommend you familiarize yours For example, the following aspects are particularly relevant for this app: * [Certify query responses if they are relevant for security](https://internetcomputer.org/docs/current/references/security/general-security-best-practices#certify-query-responses-if-they-are-relevant-for-security), since the app e.g. offers a method to read balances. -* [Use a decentralized governance system like SNS to make a canister have a decentralized controller](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices#use-a-decentralized-governance-system-like-sns-to-make-a-canister-have-a-decentralized-controller), since decentralized control may be essential for canisters holding Bitcoin on behalf of users. +* [Use a decentralized governance system like SNS to make a canister have a decentralized controller](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since decentralized control may be essential for canisters holding Bitcoin on behalf of users. diff --git a/rust/basic_dao/README.md b/rust/basic_dao/README.md index e1e621b90..c508230b9 100644 --- a/rust/basic_dao/README.md +++ b/rust/basic_dao/README.md @@ -263,5 +263,5 @@ Output: If you base your application on this example, we recommend you familiarize yourself with and adhere to the [security best practices](https://internetcomputer.org/docs/current/references/security/) for developing on the Internet Computer. This example may not implement all the best practices. For example, the following aspects are particularly relevant for this app: -* [Use a decentralized governance system like SNS to make a canister have a decentralized controller](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices#use-a-decentralized-governance-system-like-sns-to-make-a-canister-have-a-decentralized-controller), since this is a DAO's use case. +* [Use a decentralized governance system like SNS to make a canister have a decentralized controller](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since this is a DAO's use case. * [Certify query responses if they are relevant for security](https://internetcomputer.org/docs/current/references/security/general-security-best-practices#certify-query-responses-if-they-are-relevant-for-security), since e.g. account_balance and list_accounts are query calls that a client may want to issue as update call. diff --git a/rust/defi/README.md b/rust/defi/README.md index cc2b06f02..34b10b990 100644 --- a/rust/defi/README.md +++ b/rust/defi/README.md @@ -151,7 +151,7 @@ To trade tokens with yourself, you can open a second incognito browser window. If you base your application on this example, we recommend you familiarize yourself with and adhere to the [security best practices](https://internetcomputer.org/docs/current/references/security/) for developing on the Internet Computer. This example may not implement all the best practices. For example, the following aspects are particularly relevant for this app: -* [Inter-canister calls and rollbacks](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices/#inter-canister-calls-and-rollbacks), since issues around inter-canister calls can e.g. lead to time-of-check time-of-use or double spending security bugs. +* [Inter-canister calls and rollbacks](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since issues around inter-canister calls can e.g. lead to time-of-check time-of-use or double spending security bugs. * [Certify query responses if they are relevant for security](https://internetcomputer.org/docs/current/references/security/general-security-best-practices#certify-query-responses-if-they-are-relevant-for-security), since this is essential when e.g. displaying important financial data in the frontend that may be used by users to decide on future transactions. -* [Use a decentralized governance system like SNS to make a canister have a decentralized controller](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices#use-a-decentralized-governance-system-like-sns-to-make-a-canister-have-a-decentralized-controller), since decentralizing control is a fundamental aspect of decentralized finance applications. +* [Use a decentralized governance system like SNS to make a canister have a decentralized controller](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since decentralizing control is a fundamental aspect of decentralized finance applications. diff --git a/rust/dip721-nft-container/README.md b/rust/dip721-nft-container/README.md index 6b09db759..bdb0fb856 100644 --- a/rust/dip721-nft-container/README.md +++ b/rust/dip721-nft-container/README.md @@ -176,9 +176,9 @@ This Rust example comes with a demo script, `demo.sh`, which runs through an exa If you base your application on this example, we recommend you familiarize yourself with and adhere to the [security best practices](https://internetcomputer.org/docs/current/references/security/) for developing on the Internet Computer. This example may not implement all the best practices. For example, the following aspects are particularly relevant for this app: -* [Inter-canister calls and rollbacks](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices/#inter-canister-calls-and-rollbacks), since issues around inter-canister calls can e.g. lead to time-of-check time-of-use or double spending security bugs. +* [Inter-canister calls and rollbacks](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since issues around inter-canister calls can e.g. lead to time-of-check time-of-use or double spending security bugs. * [Certify query responses if they are relevant for security](https://internetcomputer.org/docs/current/references/security/general-security-best-practices#certify-query-responses-if-they-are-relevant-for-security), since this is essential when e.g. displaying important NFT data in the frontend that may be used by users to decide on future transactions. -* [Use a decentralized governance system like SNS to make a canister have a decentralized controller](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices#use-a-decentralized-governance-system-like-sns-to-make-a-canister-have-a-decentralized-controller), since decentralizing control is a fundamental aspect when dealing with NFTs. +* [Use a decentralized governance system like SNS to make a canister have a decentralized controller](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since decentralizing control is a fundamental aspect when dealing with NFTs. ## Resources - [Rust](https://rustup.rs). diff --git a/rust/encrypted-notes-dapp/README.md b/rust/encrypted-notes-dapp/README.md index 305761de2..8295bd0bd 100644 --- a/rust/encrypted-notes-dapp/README.md +++ b/rust/encrypted-notes-dapp/README.md @@ -280,7 +280,7 @@ dfx canister --network ic install www --mode=upgrade If you base your application on this example, we recommend you familiarize yourself with and adhere to the [security best practices](https://internetcomputer.org/docs/current/references/security/) for developing on the Internet Computer. This example may not implement all the best practices, see also the [disclaimer](#disclaimer-please-read-carefully) above. For example, the following aspects are particularly relevant for this app: -* [Make sure any action that only a specific user should be able to do requires authentication](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices#make-sure-any-action-that-only-a-specific-user-should-be-able-to-do-requires-authentication), since a user should only be able to manage their own notes. +* [Make sure any action that only a specific user should be able to do requires authentication](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since a user should only be able to manage their own notes. * [Protect key material against XSS using Web Crypto API](https://internetcomputer.org/docs/current/references/security/web-app-development-security-best-practices#crypto-protect-key-material-against-xss-using-web-crypto-api), since this app stores private keys in the browser. * [Use secure cryptographic schemes](https://internetcomputer.org/docs/current/references/security/general-security-best-practices#use-secure-cryptographic-schemes), since notes are being encrypted. diff --git a/rust/icp_transfer/README.md b/rust/icp_transfer/README.md index 000cd08f6..086b4fadf 100644 --- a/rust/icp_transfer/README.md +++ b/rust/icp_transfer/README.md @@ -308,6 +308,6 @@ If you base your application on this example, we recommend you familiarize yours For example, the following aspects are particularly relevant for this app: -- [Inter-canister calls and rollbacks](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices/#inter-canister-calls-and-rollbacks), since issues around inter-canister calls (here the ledger) can e.g. lead to time-of-check time-of-use or double spending security bugs. +- [Inter-canister calls and rollbacks](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since issues around inter-canister calls (here the ledger) can e.g. lead to time-of-check time-of-use or double spending security bugs. - [Certify query responses if they are relevant for security](https://internetcomputer.org/docs/current/references/security/general-security-best-practices#certify-query-responses-if-they-are-relevant-for-security), since this is essential when e.g. displaying important financial data in the frontend that may be used by users to decide on future transactions. In this example, this is e.g. relevant for the call to `canisterBalance`. -- [Use a decentralized governance system like SNS to make a canister have a decentralized controller](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices#use-a-decentralized-governance-system-like-sns-to-make-a-canister-have-a-decentralized-controller), since decentralizing control is a fundamental aspect of decentralized finance applications. +- [Use a decentralized governance system like SNS to make a canister have a decentralized controller](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since decentralizing control is a fundamental aspect of decentralized finance applications. diff --git a/rust/pub-sub/README.md b/rust/pub-sub/README.md index 466b80257..df08528c3 100644 --- a/rust/pub-sub/README.md +++ b/rust/pub-sub/README.md @@ -67,6 +67,6 @@ The output should resemble the following: If you base your application on this example, we recommend you familiarize yourself with and adhere to the [security best practices](https://internetcomputer.org/docs/current/references/security/) for developing on the Internet Computer. This example may not implement all the best practices. For example, the following aspects are particularly relevant for this app, since it makes inter-canister calls: -* [Be aware that state may change during inter-canister calls.](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices#be-aware-that-state-may-change-during-inter-canister-calls) -* [Only make inter-canister calls to trustworthy canisters.](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices#only-make-inter-canister-calls-to-trustworthy-canisters) -* [Don’t panic after await and don’t lock shared resources across await boundaries.](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices#dont-panic-after-await-and-dont-lock-shared-resources-across-await-boundaries) +* [Be aware that state may change during inter-canister calls.](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview) +* [Only make inter-canister calls to trustworthy canisters.](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview) +* [Don’t panic after await and don’t lock shared resources across await boundaries.](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview) diff --git a/rust/token_transfer/README.md b/rust/token_transfer/README.md index 506b6e78b..e50d5d1a7 100644 --- a/rust/token_transfer/README.md +++ b/rust/token_transfer/README.md @@ -319,6 +319,6 @@ If you base your application on this example, we recommend you familiarize yours For example, the following aspects are particularly relevant for this app: -- [Inter-canister calls and rollbacks](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices/#inter-canister-calls-and-rollbacks), since issues around inter-canister calls (here the ledger) can e.g. lead to time-of-check time-of-use or double spending security bugs. +- [Inter-canister calls and rollbacks](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since issues around inter-canister calls (here the ledger) can e.g. lead to time-of-check time-of-use or double spending security bugs. - [Certify query responses if they are relevant for security](https://internetcomputer.org/docs/current/references/security/general-security-best-practices#certify-query-responses-if-they-are-relevant-for-security), since this is essential when e.g. displaying important financial data in the frontend that may be used by users to decide on future transactions. In this example, this is e.g. relevant for the call to `canisterBalance`. -- [Use a decentralized governance system like SNS to make a canister have a decentralized controller](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices#use-a-decentralized-governance-system-like-sns-to-make-a-canister-have-a-decentralized-controller), since decentralizing control is a fundamental aspect of decentralized finance applications. +- [Use a decentralized governance system like SNS to make a canister have a decentralized controller](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since decentralizing control is a fundamental aspect of decentralized finance applications. diff --git a/rust/token_transfer_from/README.md b/rust/token_transfer_from/README.md index 832d7aa1c..a7ad81359 100644 --- a/rust/token_transfer_from/README.md +++ b/rust/token_transfer_from/README.md @@ -318,6 +318,6 @@ If you base your application on this example, we recommend you familiarize yours For example, the following aspects are particularly relevant for this app: -- [Inter-canister calls and rollbacks](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices/#inter-canister-calls-and-rollbacks), since issues around inter-canister calls (here the ledger) can e.g. lead to time-of-check time-of-use or double spending security bugs. +- [Inter-canister calls and rollbacks](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since issues around inter-canister calls (here the ledger) can e.g. lead to time-of-check time-of-use or double spending security bugs. - [Certify query responses if they are relevant for security](https://internetcomputer.org/docs/current/references/security/general-security-best-practices#certify-query-responses-if-they-are-relevant-for-security), since this is essential when e.g. displaying important financial data in the frontend that may be used by users to decide on future transactions. -- [Use a decentralized governance system like SNS to make a canister have a decentralized controller](https://internetcomputer.org/docs/current/references/security/rust-canister-development-security-best-practices#use-a-decentralized-governance-system-like-sns-to-make-a-canister-have-a-decentralized-controller), since decentralizing control is a fundamental aspect of decentralized finance applications. +- [Use a decentralized governance system like SNS to make a canister have a decentralized controller](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview), since decentralizing control is a fundamental aspect of decentralized finance applications. diff --git a/svelte/svelte-motoko-starter/internet-identity b/svelte/svelte-motoko-starter/internet-identity index 58a63363b..5753544a8 160000 --- a/svelte/svelte-motoko-starter/internet-identity +++ b/svelte/svelte-motoko-starter/internet-identity @@ -1 +1 @@ -Subproject commit 58a63363b53b67f7d36c0002a3a0ab57dea4e4fb +Subproject commit 5753544a82105e605cd51772ce1d4e4184fe8106 diff --git a/svelte/svelte-starter/internet-identity b/svelte/svelte-starter/internet-identity index 58a63363b..5753544a8 160000 --- a/svelte/svelte-starter/internet-identity +++ b/svelte/svelte-starter/internet-identity @@ -1 +1 @@ -Subproject commit 58a63363b53b67f7d36c0002a3a0ab57dea4e4fb +Subproject commit 5753544a82105e605cd51772ce1d4e4184fe8106