From a2f2a952136bf708156e72340e56ef595633aeea Mon Sep 17 00:00:00 2001 From: Florent Vilmart Date: Sun, 3 Nov 2024 11:12:57 -0500 Subject: [PATCH] fix compat with latest version of nu --- nushell/config.nu | 3 +-- nushell/env.nu | 9 ++++++--- nushell/scripts/jwt_utils.nu | 8 ++++---- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/nushell/config.nu b/nushell/config.nu index 3df6fa4..1a85d32 100644 --- a/nushell/config.nu +++ b/nushell/config.nu @@ -81,7 +81,6 @@ $env.config = { keycode: backspace, mode: [emacs, vi_insert], event: { edit: backspaceword } - - } + } ] } diff --git a/nushell/env.nu b/nushell/env.nu index a45c290..c9338ad 100644 --- a/nushell/env.nu +++ b/nushell/env.nu @@ -1,6 +1,8 @@ # Nushell Environment Config File -open ~/.config/nu.env.toml | get env | load-env +try { + open ~/.config/nu.env.toml | get env | load-env +} catch {} def starship_prompt [short_prompt = false] { let dur = $env.CMD_DURATION_MS; @@ -43,8 +45,9 @@ $env.PATH = ($env.PATH | prepend $"($env.HOME)/.rd/bin") $env.PATH = ($env.PATH | prepend $"($env.HOME)/.volta/bin") $env.PATH = ($env.PATH | prepend $"/usr/local/opt/kubernetes-cli@1.22/bin") - -$env.HOMEBREW_GITHUB_API_TOKEN = $env.GITHUB_TOKEN +if ('GITHUB_TOKEN' in $env) { + $env.HOMEBREW_GITHUB_API_TOKEN = $env.GITHUB_TOKEN +} # Specifies how environment variables are: # - converted from a string to a value on Nushell startup (from_string) diff --git a/nushell/scripts/jwt_utils.nu b/nushell/scripts/jwt_utils.nu index 83f4e23..b11b054 100644 --- a/nushell/scripts/jwt_utils.nu +++ b/nushell/scripts/jwt_utils.nu @@ -2,7 +2,7 @@ use std assert use ./utils.nu default_value export def jwt [token?: string] { - def b64_to_record [] { $in | decode new-base64 --nopad | decode | from json; } + def b64_to_record [] { $in | decode base64 --nopad | decode | from json; } let token = default_value $token $in let parts = $token | split row "." @@ -47,11 +47,11 @@ export def verify_signature [token: string, jwks?: string] { let signer = $key | select e kty n print $signer.n - let n = $signer.n | decode new-base64 --nopad --url | encode hex - let e = $signer.e | decode new-base64 --nopad --url | encode hex + let n = $signer.n | decode base64 --nopad --url | encode hex + let e = $signer.e | decode base64 --nopad --url | encode hex let len = ($n | str length) - print { len: $len, signer_n: $signer.n, enc_n: ($signer.n | encode new-base64), signer_e: $signer.e, n: $n, e: $e, hash: $hash, sig: $parts.2 } | to json + print { len: $len, signer_n: $signer.n, enc_n: ($signer.n | encode base64), signer_e: $signer.e, n: $n, e: $e, hash: $hash, sig: $parts.2 } | to json }