Skip to content

feat!: set canister env in cookies for html files - #4387

Merged
ilbertt merged 20 commits into
masterfrom
luca/cookie-env-vars
Sep 26, 2025
Merged

feat!: set canister env in cookies for html files#4387
ilbertt merged 20 commits into
masterfrom
luca/cookie-env-vars

Conversation

@ilbertt

@ilbertt ilbertt commented Sep 23, 2025

Copy link
Copy Markdown
Contributor

Description

Returns the ic_env cookie for all the html files. The cookie includes the root key and all the canister environment variables prefixed with PUBLIC_.

How Has This Been Tested?

Tests will be added in a follow-up PR.

Checklist:

  • The title of this PR complies with Conventional Commits.
  • I have edited the CHANGELOG accordingly.
  • I have made corresponding changes to the documentation.

Comment thread src/canisters/frontend/ic-certified-assets/src/lib.rs Outdated
Comment thread src/canisters/frontend/ic-certified-assets/src/canister_env.rs Outdated
Comment thread src/canisters/frontend/ic-certified-assets/src/state_machine/mod.rs Outdated
@ilbertt
ilbertt marked this pull request as ready for review September 25, 2025 12:16
@ilbertt
ilbertt requested a review from a team as a code owner September 25, 2025 12:16
@ilbertt

ilbertt commented Sep 26, 2025

Copy link
Copy Markdown
Contributor Author

After merging #4392, we should be able to fix tests here

@ilbertt ilbertt changed the title feat: set canister env in cookies for html files feat!: set canister env in cookies for html files Sep 26, 2025
@ilbertt
ilbertt requested a review from viviveevee September 26, 2025 13:42

@viviveevee viviveevee left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add a test that shows that PUBLIC_ env vars are added to the cookie?

@ilbertt

ilbertt commented Sep 26, 2025

Copy link
Copy Markdown
Contributor Author

Can you also add a test that shows that PUBLIC_ env vars are added to the cookie?

Adding them in a follow-up PR

@ilbertt
ilbertt merged commit 2d287c5 into master Sep 26, 2025
132 checks passed
@ilbertt
ilbertt deleted the luca/cookie-env-vars branch September 26, 2025 14:34
ilbertt added a commit that referenced this pull request Sep 26, 2025
After #4387, some methods already have two parameters (time and canister env) that can be condensed into a "system context". Using a system context simplifies the tests as well.

This PR introduces the `system_context` module and refactors the state methods to accept is as the last argument.

---------

Co-authored-by: Vivienne Siffert <severin.siffert@dfinity.org>
ilbertt added a commit that referenced this pull request Sep 26, 2025
ilbertt added a commit that referenced this pull request Oct 2, 2025
ilbertt added a commit to dfinity/icp-cli that referenced this pull request Oct 9, 2025
dfinity/sdk#4387 enables asset canisters to serve the canister environment variables prefixed with `PUBLIC_` in the `ic_env` cookie.

Additionally, switches the frontend-environment-variables asset canister to the one hosted on GitHub, which supports the `ic_env` cookie.

Additionally, aligns the doc comments to the latest pushes on dfinity/icp-js-core#1156.
ilbertt added a commit to dfinity/icp-js-core that referenced this pull request Oct 22, 2025
…#1156)

Introduces the `getCanisterEnv` and `safeGetCanisterEnv` functions to load the canister environment from the `ic_env` cookie. This is an _experimental_ feature.

Additionally, adds the `@types/jsdom` package to the dev dependencies to avoid typescript errors.

Related: dfinity/sdk#4387.
ilbertt added a commit that referenced this pull request Dec 23, 2025
…r environment changed (#4446)

# Description

Sets the `ic_env` cookie for all HTML files only if the canister environment changed in the `commit_batch` method.

The feature was first introduced in #4387.

# How Has This Been Tested?

Successfully deployed the [dfinity/portal](https://github.com/dfinity/portal) locally.
adamspofford-dfinity pushed a commit that referenced this pull request Dec 23, 2025
…r environment changed (#4446)

# Description

Sets the `ic_env` cookie for all HTML files only if the canister environment changed in the `commit_batch` method.

The feature was first introduced in #4387.

# How Has This Been Tested?

Successfully deployed the [dfinity/portal](https://github.com/dfinity/portal) locally.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants