From e06c076f2e497304501564d13938f1ccc55def38 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 1 Jun 2025 19:57:30 +0000 Subject: [PATCH 01/16] Initial plan for issue From 6c8a680e6e20c01a6abaebc33b167873e77ccdbc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 1 Jun 2025 20:04:41 +0000 Subject: [PATCH 02/16] Implement disk-based context operations for cross-process sharing Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com> --- src/functions/private/Set-ContextVault.ps1 | 6 ++-- src/functions/public/Get-Context.ps1 | 32 ++++++++++++++---- src/functions/public/Get-ContextInfo.ps1 | 28 ++++++++++++---- src/functions/public/Remove-Context.ps1 | 24 +++++++------- src/functions/public/Set-Context.ps1 | 38 +++++++++++----------- 5 files changed, 83 insertions(+), 45 deletions(-) diff --git a/src/functions/private/Set-ContextVault.ps1 b/src/functions/private/Set-ContextVault.ps1 index c1fd6b5c..f70d865e 100644 --- a/src/functions/private/Set-ContextVault.ps1 +++ b/src/functions/private/Set-ContextVault.ps1 @@ -7,7 +7,7 @@ function Set-ContextVault { .DESCRIPTION Sets the context vault. If the vault does not exist, it will be initialized. - Once the context vault is set, it will be imported into memory. + Once the context vault is set, the keys will be prepared for use. The vault consists of multiple security shards, including a machine-specific shard, a user-specific shard, and a seed shard stored within the vault directory. @@ -20,7 +20,7 @@ function Set-ContextVault { None. .NOTES - This function modifies the script-scoped configuration and imports the vault. + This function modifies the script-scoped configuration and prepares the vault for use. .LINK https://psmodule.io/Context/Functions/Set-ContextVault @@ -73,6 +73,6 @@ function Set-ContextVault { end { Write-Debug "[$stackPath] - End" - Import-Context + # Note: No longer importing all contexts into memory for better cross-process sharing } } diff --git a/src/functions/public/Get-Context.ps1 b/src/functions/public/Get-Context.ps1 index fdf6ecaf..a4b593a4 100644 --- a/src/functions/public/Get-Context.ps1 +++ b/src/functions/public/Get-Context.ps1 @@ -1,10 +1,12 @@ -function Get-Context { +#Requires -Modules @{ ModuleName = 'Sodium'; RequiredVersion = '2.1.2' } + +function Get-Context { <# .SYNOPSIS - Retrieves a context from the in-memory context vault. + Retrieves a context from the context vault. .DESCRIPTION - Retrieves a context from the loaded contexts stored in memory. + Retrieves a context by reading and decrypting context files directly from the vault directory. If no ID is specified, all available contexts will be returned. Wildcards are supported to match multiple contexts. @@ -42,7 +44,7 @@ LoginTime : 2/9/2025 10:45:11 AM ``` - Retrieves all contexts from the context vault (in memory). + Retrieves all contexts from the context vault (directly from disk). .EXAMPLE Get-Context -ID 'MySecret' @@ -68,7 +70,7 @@ YourData : {DataKey=DataValue} ``` - Retrieves all contexts that start with 'My' from the context vault (in memory). + Retrieves all contexts that start with 'My' from the context vault (directly from disk). .OUTPUTS [System.Object] @@ -106,7 +108,25 @@ Write-Verbose "Retrieving contexts - ID: [$($ID -join ', ')]" foreach ($item in $ID) { Write-Verbose "Retrieving contexts - ID: [$item]" - $script:Contexts.Values | Where-Object { $_.ID -like $item } | Select-Object -ExpandProperty Context + # Read context files directly from disk instead of using in-memory cache + $contextFiles = Get-ChildItem -Path $script:Config.VaultPath -Filter *.json -File -Recurse + foreach ($file in $contextFiles) { + try { + $contextInfo = Get-Content -Path $file.FullName | ConvertFrom-Json + if ($contextInfo.ID -like $item) { + # Decrypt and return the context + $params = @{ + SealedBox = $contextInfo.Context + PublicKey = $script:Config.PublicKey + PrivateKey = $script:Config.PrivateKey + } + $contextObj = ConvertFrom-SodiumSealedBox @params + ConvertFrom-ContextJson -JsonString $contextObj + } + } catch { + Write-Warning "Failed to read or decrypt context file: $($file.FullName). Error: $_" + } + } } } diff --git a/src/functions/public/Get-ContextInfo.ps1 b/src/functions/public/Get-ContextInfo.ps1 index c89a0e0f..82eb8303 100644 --- a/src/functions/public/Get-ContextInfo.ps1 +++ b/src/functions/public/Get-ContextInfo.ps1 @@ -1,12 +1,13 @@ function Get-ContextInfo { <# .SYNOPSIS - Retrieves info about a context from the in-memory context vault. + Retrieves info about a context from the context vault. .DESCRIPTION - Retrieves info about context from the loaded contexts stored in memory. + Retrieves info about context files directly from the vault directory on disk. If no ID is specified, all available info on contexts will be returned. Wildcards are supported to match multiple contexts. + Only metadata (ID and Path) is returned without decrypting the context contents. .EXAMPLE Get-ContextInfo @@ -29,7 +30,7 @@ Path : ...\feacc853-5bea-48d1-b751-41ce9768d48e.json ``` - Retrieves all contexts from the context vault (in memory). + Retrieves all contexts from the context vault (directly from disk). .EXAMPLE Get-ContextInfo -ID 'MySecret' @@ -40,7 +41,7 @@ Path : ...\3e223259-f242-4e97-91c8-f0fd054cfea7.json ``` - Retrieves the context called 'MySecret' from the context vault (in memory). + Retrieves the context called 'MySecret' from the context vault (directly from disk). .EXAMPLE 'My*' | Get-ContextInfo @@ -57,7 +58,7 @@ Path : .../b7c01dbe-bccd-4c7e-b075-c5aac1c43b1a.json ``` - Retrieves all contexts that start with 'My' from the context vault (in memory). + Retrieves all contexts that start with 'My' from the context vault (directly from disk). .OUTPUTS [System.Object] @@ -94,7 +95,22 @@ process { Write-Verbose "Retrieving context info - ID: [$ID]" foreach ($item in $ID) { - $script:Contexts.Values | Where-Object { $_.ID -like $item } | Select-Object -ExcludeProperty Context + # Read context files directly from disk instead of using in-memory cache + $contextFiles = Get-ChildItem -Path $script:Config.VaultPath -Filter *.json -File -Recurse + foreach ($file in $contextFiles) { + try { + $contextInfo = Get-Content -Path $file.FullName | ConvertFrom-Json + if ($contextInfo.ID -like $item) { + # Return only metadata (ID and Path), don't decrypt the Context property + [PSCustomObject]@{ + ID = $contextInfo.ID + Path = $contextInfo.Path + } + } + } catch { + Write-Warning "Failed to read context file: $($file.FullName). Error: $_" + } + } } } diff --git a/src/functions/public/Remove-Context.ps1 b/src/functions/public/Remove-Context.ps1 index f24ce43f..a8d94a57 100644 --- a/src/functions/public/Remove-Context.ps1 +++ b/src/functions/public/Remove-Context.ps1 @@ -98,18 +98,20 @@ process { foreach ($item in $ID) { Write-Verbose "Processing ID [$item]" - $script:Contexts.Keys | Where-Object { $_ -like $item } | ForEach-Object { - Write-Verbose "Removing context [$_]" - if ($PSCmdlet.ShouldProcess($_, 'Remove secret')) { - $script:Contexts[$_].Path | Remove-Item -Force - - Write-Verbose "Attempting to remove context: $_" - [PSCustomObject]$removedItem = $null - if ($script:Contexts.TryRemove($_, [ref]$removedItem)) { - Write-Verbose "Removed item: $removedItem" - } else { - Write-Verbose 'Key not found' + # Find contexts by scanning disk files instead of using in-memory cache + $contextFiles = Get-ChildItem -Path $script:Config.VaultPath -Filter *.json -File -Recurse + foreach ($file in $contextFiles) { + try { + $contextInfo = Get-Content -Path $file.FullName | ConvertFrom-Json + if ($contextInfo.ID -like $item) { + Write-Verbose "Removing context [$($contextInfo.ID)]" + if ($PSCmdlet.ShouldProcess($contextInfo.ID, 'Remove secret')) { + $file.FullName | Remove-Item -Force + Write-Verbose "Removed context file: $($file.FullName)" + } } + } catch { + Write-Warning "Failed to read context file: $($file.FullName). Error: $_" } } } diff --git a/src/functions/public/Set-Context.ps1 b/src/functions/public/Set-Context.ps1 index 2a1e4f3d..fe20b726 100644 --- a/src/functions/public/Set-Context.ps1 +++ b/src/functions/public/Set-Context.ps1 @@ -7,8 +7,8 @@ function Set-Context { .DESCRIPTION If the context does not exist, it will be created. If it already exists, it will be updated. - The context is cached in memory for faster access. This function ensures that the context - is securely stored using encryption mechanisms. + The context is securely stored on disk using encryption mechanisms. + Each context operation reads the current state from disk to ensure consistency across processes. .EXAMPLE Set-Context -ID 'PSModule.GitHub' -Context @{ Name = 'MySecret' } @@ -86,14 +86,28 @@ function Set-Context { if (-not $ID) { throw "An ID is required, either as a parameter or as a property of the context object." } - $existingContextInfo = $script:Contexts[$ID] - if (-not $existingContextInfo) { + $existingContextFile = $null + # Check if context already exists by scanning disk files + $contextFiles = Get-ChildItem -Path $script:Config.VaultPath -Filter *.json -File -Recurse + foreach ($file in $contextFiles) { + try { + $contextInfo = Get-Content -Path $file.FullName | ConvertFrom-Json + if ($contextInfo.ID -eq $ID) { + $existingContextFile = $file + $Path = $contextInfo.Path + break + } + } catch { + Write-Warning "Failed to read context file: $($file.FullName). Error: $_" + } + } + + if (-not $existingContextFile) { Write-Verbose "Context [$ID] not found in vault" $Guid = [Guid]::NewGuid().ToString() $Path = Join-Path -Path $script:Config.VaultPath -ChildPath "$Guid.json" } else { Write-Verbose "Context [$ID] found in vault" - $Path = $existingContextInfo.Path } $contextJson = ConvertTo-ContextJson -Context $Context -ID $ID @@ -108,20 +122,6 @@ function Set-Context { if ($PSCmdlet.ShouldProcess($ID, 'Set context')) { Write-Verbose "Setting context [$ID] in vault" Set-Content -Path $Path -Value $param - $content = Get-Content -Path $Path - $contextInfoObj = $content | ConvertFrom-Json - $params = @{ - SealedBox = $contextInfoObj.Context - PublicKey = $script:Config.PublicKey - PrivateKey = $script:Config.PrivateKey - } - $contextObj = ConvertFrom-SodiumSealedBox @params - Write-Verbose ($contextObj | Format-List | Out-String) - $script:Contexts[$ID] = [PSCustomObject]@{ - ID = $ID - Path = $Path - Context = ConvertFrom-ContextJson -JsonString $contextObj - } } if ($PassThru) { From 71fc57ea04bf4b1796dee6e52e83e25ed21471ff Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 1 Jun 2025 20:06:28 +0000 Subject: [PATCH 03/16] Update argument completers to use disk-based context enumeration --- src/completers.ps1 | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/completers.ps1 b/src/completers.ps1 index b5926ee7..e463032e 100644 --- a/src/completers.ps1 +++ b/src/completers.ps1 @@ -2,8 +2,21 @@ param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter) $null = $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter - $script:Contexts.Values.ID | Where-Object { $_ -like "$wordToComplete*" } | - ForEach-Object { - [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) + # Read context IDs directly from disk for tab completion + if ($script:Config.Initialized -and (Test-Path $script:Config.VaultPath)) { + $contextFiles = Get-ChildItem -Path $script:Config.VaultPath -Filter *.json -File -Recurse -ErrorAction SilentlyContinue + $contextIds = @() + foreach ($file in $contextFiles) { + try { + $contextInfo = Get-Content -Path $file.FullName | ConvertFrom-Json + $contextIds += $contextInfo.ID + } catch { + # Skip invalid files + } } + $contextIds | Where-Object { $_ -like "$wordToComplete*" } | + ForEach-Object { + [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) + } + } } From 310c6a87c97203b27f1c1887a5edcb41b1cf031b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 1 Jun 2025 20:20:54 +0000 Subject: [PATCH 04/16] Update argument completer to use Get-ContextInfo for better consistency Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com> --- src/completers.ps1 | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/completers.ps1 b/src/completers.ps1 index e463032e..273f9e44 100644 --- a/src/completers.ps1 +++ b/src/completers.ps1 @@ -2,21 +2,14 @@ param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter) $null = $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter - # Read context IDs directly from disk for tab completion - if ($script:Config.Initialized -and (Test-Path $script:Config.VaultPath)) { - $contextFiles = Get-ChildItem -Path $script:Config.VaultPath -Filter *.json -File -Recurse -ErrorAction SilentlyContinue - $contextIds = @() - foreach ($file in $contextFiles) { - try { - $contextInfo = Get-Content -Path $file.FullName | ConvertFrom-Json - $contextIds += $contextInfo.ID - } catch { - # Skip invalid files - } - } - $contextIds | Where-Object { $_ -like "$wordToComplete*" } | + # Use Get-ContextInfo to get available context IDs for tab completion + try { + $contextInfos = Get-ContextInfo -ErrorAction SilentlyContinue + $contextInfos | Where-Object { $_.ID -like "$wordToComplete*" } | ForEach-Object { - [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) + [System.Management.Automation.CompletionResult]::new($_.ID, $_.ID, 'ParameterValue', $_.ID) } + } catch { + # Silently fail if Get-ContextInfo is not available or vault is not accessible } } From f9dc27722b1d31d8f37164065690d8bdf9b45ab6 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Jun 2025 22:33:40 +0200 Subject: [PATCH 05/16] Refactor argument completer to use dynamic command names and improve context retrieval; update Sodium module version to 2.2.0 across relevant scripts. --- src/completers.ps1 | 14 ++-- src/functions/private/Import-Context.ps1 | 76 ---------------------- src/functions/private/Set-ContextVault.ps1 | 5 +- src/functions/public/Get-Context.ps1 | 2 +- src/functions/public/Set-Context.ps1 | 4 +- src/variables/private/Config.ps1 | 2 +- 6 files changed, 10 insertions(+), 93 deletions(-) delete mode 100644 src/functions/private/Import-Context.ps1 diff --git a/src/completers.ps1 b/src/completers.ps1 index 273f9e44..e38b730c 100644 --- a/src/completers.ps1 +++ b/src/completers.ps1 @@ -1,15 +1,9 @@ -Register-ArgumentCompleter -CommandName 'Get-Context', 'Set-Context', 'Remove-Context', 'Rename-Context' -ParameterName 'ID' -ScriptBlock { +Register-ArgumentCompleter -CommandName ($script:PSModuleInfo.FunctionsToExport) -ParameterName 'ID' -ScriptBlock { param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter) $null = $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter - # Use Get-ContextInfo to get available context IDs for tab completion - try { - $contextInfos = Get-ContextInfo -ErrorAction SilentlyContinue - $contextInfos | Where-Object { $_.ID -like "$wordToComplete*" } | - ForEach-Object { - [System.Management.Automation.CompletionResult]::new($_.ID, $_.ID, 'ParameterValue', $_.ID) - } - } catch { - # Silently fail if Get-ContextInfo is not available or vault is not accessible + $contextInfos = Get-ContextInfo -ErrorAction SilentlyContinue -Verbose:$false -Debug:$false + $contextInfos | Where-Object { $_.ID -like "$wordToComplete*" } | ForEach-Object { + [System.Management.Automation.CompletionResult]::new($_.ID, $_.ID, 'ParameterValue', $_.ID) } } diff --git a/src/functions/private/Import-Context.ps1 b/src/functions/private/Import-Context.ps1 deleted file mode 100644 index cbd8f3f3..00000000 --- a/src/functions/private/Import-Context.ps1 +++ /dev/null @@ -1,76 +0,0 @@ -#Requires -Modules @{ ModuleName = 'Sodium'; RequiredVersion = '2.1.2' } - -filter Import-Context { - <# - .SYNOPSIS - Imports the context vault into memory. - - .DESCRIPTION - Imports all context files from the context vault directory into memory. - Each context is decrypted using the configured private key and stored - in the script-wide context collection for further use. - - .EXAMPLE - Import-Context - - Output: - ```powershell - VERBOSE: Importing contexts from vault: [C:\Vault] - VERBOSE: Found [3] contexts - VERBOSE: Importing context: [123456] - ``` - - Imports all contexts from the context vault into memory. - - .OUTPUTS - [pscustomobject]. - - .NOTES - Represents the imported context object containing ID, Path, and Context properties. - - .LINK - https://psmodule.io/Sodium/Functions/Import-Context/ - #> - [OutputType([object])] - [CmdletBinding()] - param() - - begin { - $stackPath = Get-PSCallStackPath - Write-Debug "[$stackPath] - Start" - if (-not $script:Config.Initialized) { - Set-ContextVault - } - } - - process { - try { - Write-Verbose "Importing contexts from vault: [$($script:Config.VaultPath)]" - $contextFiles = Get-ChildItem -Path $script:Config.VaultPath -Filter *.json -File -Recurse - Write-Verbose "Found [$($contextFiles.Count)] contexts" - $contextFiles | ForEach-Object { - $contextInfo = Get-Content -Path $_.FullName | ConvertFrom-Json - Write-Verbose "Importing context: [$($contextInfo.ID)]" - Write-Verbose ($contextInfo | Format-List | Out-String) - $params = @{ - SealedBox = $contextInfo.Context - PublicKey = $script:Config.PublicKey - PrivateKey = $script:Config.PrivateKey - } - $context = ConvertFrom-SodiumSealedBox @params - $script:Contexts[$contextInfo.ID] = [pscustomobject]@{ - ID = $contextInfo.ID - Path = $contextInfo.Path - Context = ConvertFrom-ContextJson -JsonString $context - } - } - } catch { - Write-Error $_ - throw 'Failed to get context' - } - } - - end { - Write-Debug "[$stackPath] - End" - } -} diff --git a/src/functions/private/Set-ContextVault.ps1 b/src/functions/private/Set-ContextVault.ps1 index f70d865e..9e4e0f3a 100644 --- a/src/functions/private/Set-ContextVault.ps1 +++ b/src/functions/private/Set-ContextVault.ps1 @@ -1,4 +1,4 @@ -#Requires -Modules @{ ModuleName = 'Sodium'; RequiredVersion = '2.1.2' } +#Requires -Modules @{ ModuleName = 'Sodium'; RequiredVersion = '2.2.0' } function Set-ContextVault { <# @@ -59,7 +59,7 @@ function Set-ContextVault { $machineShard = [System.Environment]::MachineName $userShard = [System.Environment]::UserName #$userInputShard = Read-Host -Prompt 'Enter a seed shard' # Eventually 4 shards. +1 for user input. - $seed = $machineShard + $userShard + $seedShard + $userInputShard + $seed = $machineShard + $userShard + $seedShard # + $userInputShard $keys = New-SodiumKeyPair -Seed $seed $script:Config.PrivateKey = $keys.PrivateKey $script:Config.PublicKey = $keys.PublicKey @@ -73,6 +73,5 @@ function Set-ContextVault { end { Write-Debug "[$stackPath] - End" - # Note: No longer importing all contexts into memory for better cross-process sharing } } diff --git a/src/functions/public/Get-Context.ps1 b/src/functions/public/Get-Context.ps1 index a4b593a4..f3537e58 100644 --- a/src/functions/public/Get-Context.ps1 +++ b/src/functions/public/Get-Context.ps1 @@ -1,4 +1,4 @@ -#Requires -Modules @{ ModuleName = 'Sodium'; RequiredVersion = '2.1.2' } +#Requires -Modules @{ ModuleName = 'Sodium'; RequiredVersion = '2.2.0' } function Get-Context { <# diff --git a/src/functions/public/Set-Context.ps1 b/src/functions/public/Set-Context.ps1 index fe20b726..36a08cc9 100644 --- a/src/functions/public/Set-Context.ps1 +++ b/src/functions/public/Set-Context.ps1 @@ -1,4 +1,4 @@ -#Requires -Modules @{ ModuleName = 'Sodium'; RequiredVersion = '2.1.2' } +#Requires -Modules @{ ModuleName = 'Sodium'; RequiredVersion = '2.2.0' } function Set-Context { <# @@ -101,7 +101,7 @@ function Set-Context { Write-Warning "Failed to read context file: $($file.FullName). Error: $_" } } - + if (-not $existingContextFile) { Write-Verbose "Context [$ID] not found in vault" $Guid = [Guid]::NewGuid().ToString() diff --git a/src/variables/private/Config.ps1 b/src/variables/private/Config.ps1 index 0d65178f..9ab4afd4 100644 --- a/src/variables/private/Config.ps1 +++ b/src/variables/private/Config.ps1 @@ -1,7 +1,7 @@ $script:Config = [pscustomobject]@{ Initialized = $false # Has the vault been initialized? VaultPath = Join-Path -Path $HOME -ChildPath '.contextvault' # Vault directory path - SeedShardPath = 'vault.shard' # Seed shard path (relative to VaultPath) + SeedShardPath = 'vault.shard' # Seed shard path (relative to VaultPath) PrivateKey = $null # Private key (populated on init) PublicKey = $null # Public key (populated on init) } From 358c62384cd2fe81ee338db6a1fd07e96483cf9f Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Jun 2025 22:35:32 +0200 Subject: [PATCH 06/16] Remove Contexts.ps1 file and its concurrent dictionary implementation for context management --- src/variables/private/Contexts.ps1 | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 src/variables/private/Contexts.ps1 diff --git a/src/variables/private/Contexts.ps1 b/src/variables/private/Contexts.ps1 deleted file mode 100644 index a804bf0d..00000000 --- a/src/variables/private/Contexts.ps1 +++ /dev/null @@ -1,3 +0,0 @@ -# Using a dictionary to get the benefit of reference type storage in PowerShell while multiple functions are running in parallel. -# Using concurrent dictionary to be able to safely access the dictionary from multiple threads /ForEach -Parallel. -$script:Contexts = [System.Collections.Concurrent.ConcurrentDictionary[string, [PSCustomObject]]]::new() From b17494eb4fee7fc453be59af2603bfdd7eb46e1a Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Jun 2025 22:37:57 +0200 Subject: [PATCH 07/16] Downgrade Sodium module version to 2.1.2 in context functions for compatibility --- src/functions/private/Set-ContextVault.ps1 | 2 +- src/functions/public/Get-Context.ps1 | 2 +- src/functions/public/Set-Context.ps1 | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/functions/private/Set-ContextVault.ps1 b/src/functions/private/Set-ContextVault.ps1 index 9e4e0f3a..c067f767 100644 --- a/src/functions/private/Set-ContextVault.ps1 +++ b/src/functions/private/Set-ContextVault.ps1 @@ -1,4 +1,4 @@ -#Requires -Modules @{ ModuleName = 'Sodium'; RequiredVersion = '2.2.0' } +#Requires -Modules @{ ModuleName = 'Sodium'; RequiredVersion = '2.1.2' } function Set-ContextVault { <# diff --git a/src/functions/public/Get-Context.ps1 b/src/functions/public/Get-Context.ps1 index f3537e58..a4b593a4 100644 --- a/src/functions/public/Get-Context.ps1 +++ b/src/functions/public/Get-Context.ps1 @@ -1,4 +1,4 @@ -#Requires -Modules @{ ModuleName = 'Sodium'; RequiredVersion = '2.2.0' } +#Requires -Modules @{ ModuleName = 'Sodium'; RequiredVersion = '2.1.2' } function Get-Context { <# diff --git a/src/functions/public/Set-Context.ps1 b/src/functions/public/Set-Context.ps1 index 36a08cc9..90ced3ea 100644 --- a/src/functions/public/Set-Context.ps1 +++ b/src/functions/public/Set-Context.ps1 @@ -1,4 +1,4 @@ -#Requires -Modules @{ ModuleName = 'Sodium'; RequiredVersion = '2.2.0' } +#Requires -Modules @{ ModuleName = 'Sodium'; RequiredVersion = '2.1.2' } function Set-Context { <# @@ -84,7 +84,7 @@ function Set-Context { $ID = $Context.ID } if (-not $ID) { - throw "An ID is required, either as a parameter or as a property of the context object." + throw 'An ID is required, either as a parameter or as a property of the context object.' } $existingContextFile = $null # Check if context already exists by scanning disk files From 394246108812d6f7abce4a514125a9b3b466f90b Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 2 Jun 2025 01:44:05 +0200 Subject: [PATCH 08/16] Update Sodium module version to 2.2.0 in context functions for compatibility --- src/functions/private/Set-ContextVault.ps1 | 2 +- src/functions/public/Get-Context.ps1 | 2 +- src/functions/public/Set-Context.ps1 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/functions/private/Set-ContextVault.ps1 b/src/functions/private/Set-ContextVault.ps1 index c067f767..9e4e0f3a 100644 --- a/src/functions/private/Set-ContextVault.ps1 +++ b/src/functions/private/Set-ContextVault.ps1 @@ -1,4 +1,4 @@ -#Requires -Modules @{ ModuleName = 'Sodium'; RequiredVersion = '2.1.2' } +#Requires -Modules @{ ModuleName = 'Sodium'; RequiredVersion = '2.2.0' } function Set-ContextVault { <# diff --git a/src/functions/public/Get-Context.ps1 b/src/functions/public/Get-Context.ps1 index a4b593a4..f3537e58 100644 --- a/src/functions/public/Get-Context.ps1 +++ b/src/functions/public/Get-Context.ps1 @@ -1,4 +1,4 @@ -#Requires -Modules @{ ModuleName = 'Sodium'; RequiredVersion = '2.1.2' } +#Requires -Modules @{ ModuleName = 'Sodium'; RequiredVersion = '2.2.0' } function Get-Context { <# diff --git a/src/functions/public/Set-Context.ps1 b/src/functions/public/Set-Context.ps1 index 90ced3ea..143edf45 100644 --- a/src/functions/public/Set-Context.ps1 +++ b/src/functions/public/Set-Context.ps1 @@ -1,4 +1,4 @@ -#Requires -Modules @{ ModuleName = 'Sodium'; RequiredVersion = '2.1.2' } +#Requires -Modules @{ ModuleName = 'Sodium'; RequiredVersion = '2.2.0' } function Set-Context { <# From a033a2f81799848392c02fa63bdd66aa06927dcf Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 2 Jun 2025 02:09:47 +0200 Subject: [PATCH 09/16] Add blank line at the beginning of README.md for improved readability --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e80161b4..9e81e70a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # Context + Modules typically handle two types of data that benefit from persistent secure storage and management: module settings and user settings and secrets. This module introduces the concept of `Contexts`, which store data locally on the machine where the module runs. It allows module developers to separate user and module data from the module code, enabling users to resume their work without needing to reconfigure the module or log in again, From a9e03a2d84039d089e3afdb9ea3c246b3081f178 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 2 Jun 2025 02:35:13 +0200 Subject: [PATCH 10/16] Remove unnecessary blank line at the beginning of README.md for improved formatting --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 9e81e70a..e80161b4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # Context - Modules typically handle two types of data that benefit from persistent secure storage and management: module settings and user settings and secrets. This module introduces the concept of `Contexts`, which store data locally on the machine where the module runs. It allows module developers to separate user and module data from the module code, enabling users to resume their work without needing to reconfigure the module or log in again, From e8d2a6a2d10e159483b4e5768f551a135ccf982b Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 2 Jun 2025 03:00:55 +0200 Subject: [PATCH 11/16] Add blank line at the beginning of README.md for improved readability --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e80161b4..9e81e70a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # Context + Modules typically handle two types of data that benefit from persistent secure storage and management: module settings and user settings and secrets. This module introduces the concept of `Contexts`, which store data locally on the machine where the module runs. It allows module developers to separate user and module data from the module code, enabling users to resume their work without needing to reconfigure the module or log in again, From d94239e873f5f5bf6be88e25600fb92f76bdbc28 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 2 Jun 2025 03:01:01 +0200 Subject: [PATCH 12/16] Remove unnecessary blank line at the beginning of README.md for improved formatting --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 9e81e70a..e80161b4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # Context - Modules typically handle two types of data that benefit from persistent secure storage and management: module settings and user settings and secrets. This module introduces the concept of `Contexts`, which store data locally on the machine where the module runs. It allows module developers to separate user and module data from the module code, enabling users to resume their work without needing to reconfigure the module or log in again, From 4237d121f0b91bc08743f310ff4b5a55b2b6ad6c Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 2 Jun 2025 03:41:00 +0200 Subject: [PATCH 13/16] Add blank line at the beginning of README.md for improved readability --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e80161b4..9e81e70a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # Context + Modules typically handle two types of data that benefit from persistent secure storage and management: module settings and user settings and secrets. This module introduces the concept of `Contexts`, which store data locally on the machine where the module runs. It allows module developers to separate user and module data from the module code, enabling users to resume their work without needing to reconfigure the module or log in again, From 040e70971de0110e116ce5472bfb59815554456f Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 2 Jun 2025 03:41:08 +0200 Subject: [PATCH 14/16] Remove unnecessary blank line at the beginning of README.md for improved formatting --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 9e81e70a..e80161b4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # Context - Modules typically handle two types of data that benefit from persistent secure storage and management: module settings and user settings and secrets. This module introduces the concept of `Contexts`, which store data locally on the machine where the module runs. It allows module developers to separate user and module data from the module code, enabling users to resume their work without needing to reconfigure the module or log in again, From a9a8b6fb76703a230170cf38d653ea142d9efd5a Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 2 Jun 2025 04:02:54 +0200 Subject: [PATCH 15/16] Add blank line at the beginning of README.md for improved readability --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e80161b4..9e81e70a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # Context + Modules typically handle two types of data that benefit from persistent secure storage and management: module settings and user settings and secrets. This module introduces the concept of `Contexts`, which store data locally on the machine where the module runs. It allows module developers to separate user and module data from the module code, enabling users to resume their work without needing to reconfigure the module or log in again, From 0515f23787e9592df6f4325a6cb443a7ade84757 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 2 Jun 2025 04:03:02 +0200 Subject: [PATCH 16/16] Remove unnecessary blank line at the beginning of README.md for improved formatting --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 9e81e70a..e80161b4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # Context - Modules typically handle two types of data that benefit from persistent secure storage and management: module settings and user settings and secrets. This module introduces the concept of `Contexts`, which store data locally on the machine where the module runs. It allows module developers to separate user and module data from the module code, enabling users to resume their work without needing to reconfigure the module or log in again,