Skip to content

Commit

Permalink
Add hash to albatross-client file for cache-bust
Browse files Browse the repository at this point in the history
  • Loading branch information
mraveux committed Nov 29, 2024
1 parent 1a02d5f commit 2d2d3be
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion demos/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ <h2>Result</h2>
crossorigin="anonymous"></script>

<script type="module">
import init, * as Nimiq from '/albatross-client/web/index.js';
import init, * as Nimiq from '/albatross-client/web/index.js?v=<%= htmlWebpackPlugin.options.albatrossClientHash %>';

/** @type {Promise<Nimiq> | undefined} */
let initPromise;
Expand Down
2 changes: 1 addition & 1 deletion public/cashlink.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<link rel="icon" href="<%= htmlWebpackPlugin.options.domain %>/favicon.ico">

<script type="module">
import init, * as Nimiq from '/albatross-client/web/index.js';
import init, * as Nimiq from '/albatross-client/web/index.js?v=<%= htmlWebpackPlugin.options.albatrossClientHash %>';

/** @type {Promise<Nimiq> | undefined} */
let initPromise;
Expand Down
2 changes: 1 addition & 1 deletion public/export.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</style>

<script type="module">
import init, * as Nimiq from '/albatross-client/web/index.js';
import init, * as Nimiq from '/albatross-client/web/index.js?v=<%= htmlWebpackPlugin.options.albatrossClientHash %>';

/** @type {Promise<Nimiq> | undefined} */
let initPromise;
Expand Down
2 changes: 1 addition & 1 deletion public/iframe.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="robots" content="noindex">
<title>Nimiq Hub IFrame</title>
<script type="module">
import init, * as Nimiq from '/albatross-client/web/index.js';
import init, * as Nimiq from '/albatross-client/web/index.js?v=<%= htmlWebpackPlugin.options.albatrossClientHash %>';

/** @type {Promise<Nimiq> | undefined} */
let initPromise;
Expand Down
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<link rel="icon" href="<%= htmlWebpackPlugin.options.domain %>/favicon.ico">

<script type="module">
import init, * as Nimiq from '/albatross-client/web/index.js';
import init, * as Nimiq from '/albatross-client/web/index.js?v=<%= htmlWebpackPlugin.options.albatrossClientHash %>';

/** @type {Promise<Nimiq> | undefined} */
let initPromise;
Expand Down
6 changes: 3 additions & 3 deletions src/i18n/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ msgid "Connect your Ledger hardware wallet."
msgstr ""

#: src/views/Migrate.vue:143
#: src/views/Migrate.vue:285
#: src/views/Migrate.vue:283
msgid "Connecting to Keyguard..."
msgstr ""

Expand Down Expand Up @@ -1189,7 +1189,7 @@ msgstr ""
msgid "Unsupported Request"
msgstr ""

#: src/components/CheckoutCardNimiq.vue:329
#: src/components/CheckoutCardNimiq.vue:327
msgid "Updating balances"
msgstr ""

Expand All @@ -1198,7 +1198,7 @@ msgid "Updating Keyguard..."
msgstr ""

#: src/views/Migrate.vue:142
#: src/views/Migrate.vue:284
#: src/views/Migrate.vue:282
msgid "Updating your Accounts"
msgstr ""

Expand Down
9 changes: 9 additions & 0 deletions vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ const bitcoinJsIntegrityHash = `sha256-${createHash('sha256')
.update(fs.readFileSync(path.join(__dirname, 'public/bitcoin/BitcoinJS.min.js')))
.digest('base64')}`;

const albatrossClientHash = `sha256-${createHash('sha256')
.update(fs.readFileSync(path.join(__dirname, 'node_modules/@nimiq/albatross-wasm/web/index.js')))
.digest('base64')}`;

// Accessible within client code via process.env.VUE_APP_BITCOIN_JS_INTEGRITY_HASH,
// see https://cli.vuejs.org/guide/mode-and-env.html#using-env-variables-in-client-side-code
process.env.VUE_APP_BITCOIN_JS_INTEGRITY_HASH = bitcoinJsIntegrityHash;
Expand Down Expand Up @@ -129,6 +133,7 @@ const pages = {
// insert browser warning html template
browserWarningTemplate,
browserWarningIntegrityHash,
albatrossClientHash,
domain,
cdnDomain,
// output as dist/index.html
Expand All @@ -142,6 +147,7 @@ const pages = {
entry: 'src/iframe.ts',
// the source template
template: 'public/iframe.html',
albatrossClientHash,
// output as dist/iframe.html
filename: 'iframe.html',
// chunks to include on this page, by default includes
Expand All @@ -156,6 +162,7 @@ const pages = {
// insert browser warning html template
browserWarningTemplate,
browserWarningIntegrityHash,
albatrossClientHash,
domain,
cdnDomain,
// output as dist/cashlink/index.html
Expand All @@ -169,6 +176,7 @@ const pages = {
entry: 'src/export.ts',
// the source template
template: 'public/export.html',
albatrossClientHash,
cdnDomain,
// output as dist/iframe.html
filename: 'export.html',
Expand All @@ -183,6 +191,7 @@ if (buildName === 'local' || buildName === 'testnet') {
template: 'demos/index.html',
cdnDomain,
bitcoinJsIntegrityHash,
albatrossClientHash,
// output as dist/demos.html
filename: 'demos.html',
// chunks to include on this page, by default includes
Expand Down

0 comments on commit 2d2d3be

Please sign in to comment.