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 30, 2024
1 parent 133e7a5 commit d86083d
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 24 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
38 changes: 19 additions & 19 deletions src/i18n/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ msgstr ""
msgid "Address Added"
msgstr ""

#: src/views/LoginSuccess.vue:129
#: src/views/LoginSuccess.vue:189
msgid "Address detection failed. Retrying..."
msgstr ""

Expand Down 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 @@ -434,8 +434,8 @@ msgid "Contacts are not affected."
msgstr ""

#: src/components/NotEnoughCookieSpace.vue:8
#: src/views/LoginSuccess.vue:186
#: src/views/LoginSuccess.vue:220
#: src/views/LoginSuccess.vue:249
#: src/views/LoginSuccess.vue:283
#: src/views/SignupLedger.vue:143
msgid "Continue"
msgstr ""
Expand Down Expand Up @@ -485,7 +485,7 @@ msgstr ""
msgid "Creating your Cashlink"
msgstr ""

#: src/views/LoginSuccess.vue:66
#: src/views/LoginSuccess.vue:87
msgid "Detecting addresses..."
msgstr ""

Expand Down Expand Up @@ -543,7 +543,7 @@ msgstr ""
msgid "Fee"
msgstr ""

#: src/views/LoginSuccess.vue:139
#: src/views/LoginSuccess.vue:202
#: src/views/SignupLedger.vue:108
msgid "Fetching Addresses Failed"
msgstr ""
Expand Down Expand Up @@ -629,7 +629,7 @@ msgid ""
"crypto was easy"
msgstr ""

#: src/views/LoginSuccess.vue:199
#: src/views/LoginSuccess.vue:262
#: src/views/SignupLedger.vue:124
msgid "Imported {count} address so far... | Imported {count} addresses so far..."
msgstr ""
Expand Down Expand Up @@ -925,7 +925,7 @@ msgstr ""

#: src/views/ActivatePolygonSuccess.vue:139
#: src/views/BitcoinSyncBaseView.vue:72
#: src/views/LoginSuccess.vue:141
#: src/views/LoginSuccess.vue:204
#: src/views/SetupSwapSuccess.vue:669
#: src/views/SignupLedger.vue:145
msgid "Retry"
Expand Down Expand Up @@ -986,7 +986,7 @@ msgstr ""
msgid "Something went wrong with your request. Please try again."
msgstr ""

#: src/views/LoginSuccess.vue:182
#: src/views/LoginSuccess.vue:245
msgid "Space exceeded"
msgstr ""

Expand Down Expand Up @@ -1043,7 +1043,7 @@ msgstr ""
msgid "Syncing Failed"
msgstr ""

#: src/views/LoginSuccess.vue:65
#: src/views/LoginSuccess.vue:85
msgid "Syncing to network..."
msgstr ""

Expand Down Expand Up @@ -1072,7 +1072,7 @@ msgstr ""
msgid "Syncing with Polygon network..."
msgstr ""

#: src/views/LoginSuccess.vue:140
#: src/views/LoginSuccess.vue:203
#: src/views/SignupLedger.vue:134
msgid "Syncing with the network failed: {error}"
msgstr ""
Expand Down Expand Up @@ -1177,7 +1177,7 @@ msgstr ""
msgid "Unfortunately, due to restrictions of Safari you cannot add more accounts and/or addresses. Please log out of unused accounts to free up space."
msgstr ""

#: src/views/LoginSuccess.vue:184
#: src/views/LoginSuccess.vue:247
msgid "Unfortunately, due to space restrictions of Safari and IOS, this account cannot be stored properly. Please free up space by logging out of other accounts."
msgstr ""

Expand All @@ -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 All @@ -1216,7 +1216,7 @@ msgid ""
"or Recovery Words."
msgstr ""

#: src/views/LoginSuccess.vue:219
#: src/views/LoginSuccess.vue:282
#: src/views/SignupLedger.vue:132
msgid "Used addresses without balance might have been missed."
msgstr ""
Expand All @@ -1241,11 +1241,11 @@ msgid ""
"created"
msgstr ""

#: src/views/LoginSuccess.vue:241
#: src/views/LoginSuccess.vue:304
msgid "Welcome back!"
msgstr ""

#: src/views/LoginSuccess.vue:234
#: src/views/LoginSuccess.vue:297
msgid "Welcome back! | Your Accounts are ready."
msgstr ""

Expand Down Expand Up @@ -1294,7 +1294,7 @@ msgstr ""
msgid "Your {app} app is outdated. Please update your Ledger firmware and {app} app using Ledger Live."
msgstr ""

#: src/views/LoginSuccess.vue:217
#: src/views/LoginSuccess.vue:280
#: src/views/SignupLedger.vue:106
msgid ""
"Your Addresses may be\n"
Expand All @@ -1315,7 +1315,7 @@ msgstr ""
msgid "Your message is signed."
msgstr ""

#: src/views/LoginSuccess.vue:228
#: src/views/LoginSuccess.vue:291
#: src/views/SimpleSuccess.vue:31
msgid "Your password was changed."
msgstr ""
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 d86083d

Please sign in to comment.