Skip to content

Commit 7ad7e6f

Browse files
authored
feat([sc-15759]): target canister docs page (#231)
1 parent 62248e9 commit 7ad7e6f

File tree

6 files changed

+41
-8
lines changed

6 files changed

+41
-8
lines changed

docs/pages/getting-started/installation.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ backend canisters to the `targets` array.
6767

6868
<Callout type="warning" emoji="⚠️">
6969
Add only **your** backend canister IDs to the `targets` array.
70-
<a href="/miscellaneous/delegation-toolkit">
71-
<strong>More about the Delegation Toolkit.</strong>
70+
<a href="/miscellaneous/target-canisters">
71+
<strong>More about the Target Canisters.</strong>
7272
</a>
7373
</Callout>
7474

docs/pages/miscellaneous/_meta.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export default {
22
"delegation-toolkit": "Delegation Toolkit",
3+
"target-canisters": "Target Canisters",
34
"auth-options": "Auth Options",
45
"local-development": "Local Development",
56
}

docs/pages/miscellaneous/delegation-toolkit.mdx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,14 @@ use those wallet addresses outside your app.
3636
Account delegations can be used to make authenticated calls to your own canisters, and will require
3737
approval to call others.
3838

39-
> Note: ICRC-1, ICRC-7, and other asset canister smart contracts are discouraged from implementing
40-
> this method. Wallets may mark application as a scam if they do.
41-
4239
## Recommendation
4340

4441
We believe Web3 is about having a universal digital identity that people can use to bring their data
4542
and assets from app to app. Therefore our bias is to always ask users connect with their wallet
4643
address. Let users connect with a new Account or Relying party delegation if they don't yet trust
4744
your app, but always strive to decrease how much users need to trust your service to use it.
4845

49-
Read more about the
46+
Read more about [target canisters](/miscellaneous/target-canisters) and the
5047
[ICRC-28](https://github.com/dfinity/wg-identity-authentication/blob/main/topics/icrc_28_trusted_origins.md)
5148
standard.
5249

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
title: "Target Canisters"
3+
date: "2024-07-10"
4+
authors:
5+
- name: "Dan Ostrovsky"
6+
---
7+
8+
## Target Canisters
9+
10+
3rd party application MUST set an array of target canisters to which delegation identity will make
11+
authenticated calls without user approvals. These canisters SHOULD be under the 3rd party
12+
application's control, otherwise the developer opens a trust assumption that other canister
13+
controllers won't carry out drain attacks on their shared pool of users.
14+
15+
## Rust Implementation
16+
17+
Each target canister that wallet providers will query (as an update call for secure consensus)
18+
should have method `icrc28_trusted_origins()`:
19+
20+
```rust
21+
#[derive(Clone, Debug, CandidType, Deserialize)]
22+
pub struct Icrc28TrustedOriginsResponse {
23+
pub trusted_origins: Vec<String>
24+
}
25+
26+
#[update]
27+
fn icrc28_trusted_origins() -> Icrc28TrustedOriginsResponse {
28+
let trusted_origins = vec![
29+
String::from("dscvr.one") // to be replaced with application's frontend origin(s)
30+
];
31+
32+
return Icrc28TrustedOriginsResponse { trusted_origins }
33+
}
34+
```
35+
36+
> Note: ICRC-1, ICRC-7, and other asset canister smart contracts are discouraged from implementing
37+
> this method. Wallets may mark application as a scam if they do.

examples/react-demo/src/idl/service.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ export interface Icrc21LineDisplayPage {
4545
}
4646
export type Result = { Ok: Icrc21ConsentInfo } | { Err: Icrc21Error }
4747
export interface _SERVICE {
48-
get_trusted_origins: ActorMethod<[], Array<string>>
4948
greet: ActorMethod<[string], string>
5049
greet_no_consent: ActorMethod<[string], string>
5150
icrc21_canister_call_consent_message: ActorMethod<[Icrc21ConsentMessageRequest], Result>

examples/react-demo/src/idl/service_idl.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export const idlFactory = ({ IDL }: any) => {
3939
})
4040
const Result = IDL.Variant({ Ok: Icrc21ConsentInfo, Err: Icrc21Error })
4141
return IDL.Service({
42-
get_trusted_origins: IDL.Func([], [IDL.Vec(IDL.Text)], []),
4342
greet: IDL.Func([IDL.Text], [IDL.Text], ["query"]),
4443
greet_no_consent: IDL.Func([IDL.Text], [IDL.Text], ["query"]),
4544
icrc21_canister_call_consent_message: IDL.Func([Icrc21ConsentMessageRequest], [Result], []),

0 commit comments

Comments
 (0)