Lesspass.psm1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
function Get-LessPass {
    [CmdletBinding()]
    [alias("lesspass")]
    param(
        [string]$Site,
        [string]$Login,
        [string][Parameter(Mandatory=$true)]$MasterPassword,
        [Alias('l')][Switch]$Lowercase,
        [Alias('u')][Switch]$Uppercase,
        [Alias('d')][Switch]$Digits,
        [Alias('s')][Switch]$Symbols,
        [Alias('nl')][Switch]$noLowercase,
        [Alias('nu')][Switch]$noUppercase,
        [Alias('nd')][Switch]$noDigits,
        [Alias('ns')][Switch]$noSymbols,
        [ValidateRange(5, 35)]$Length=16,
        $Counter=1,
        # $Prompt,
        # $Clipboard,
        [Switch]$version
    )
    process {
        if ($version) {
            (Get-Module Lesspass).Version | Write-Host
            return 
        }
        $Error, $HelpMessage = Confirm-Arguments @PSBoundParameters
        if ($Error) {
            Write-Host $HelpMessage
        }

        
        $PasswordProfile = New-Profile @PSBoundParameters
        
        return GeneratePassword $PasswordProfile $MasterPassword
        # todo: if -Prompt flag is present copy to clipboard
        # todo: request MasterPassword if not provided
        # todo: if -Clipboard flag is present copy to clipboard
    }
    end {
    }

<#
.SYNOPSIS
LessPass - stateless password generator

.LINK
Website: http://lesspass.com/
Github: https://github.com/lesspass/lesspass/

.DESCRIPTION
LessPass computes a unique password using a Site, Login and a master password.
You don't need to sync a password vault across every device because LessPass works offline!

LINUX REQUIREMENT:
The `xclip` utility must be installed to support the copy to clipboard feature;
Debian-based platforms such as Ubuntu/Linux Mint, install it with:

    sudo apt install xclip

.PARAMETER Site
Site used in the password generation (required)

.PARAMETER Login
Login used in the password generation
default to '' if not provided.

.PARAMETER MasterPassword
Master password used in password generation
default to LESSPASS_MASTER_PASSWORD env variable or prompt

.PARAMETER Lowercase
Add lowercase in password

.PARAMETER Uppercase
Add uppercase in password

.PARAMETER Digits
Add digits in password

.PARAMETER Symbols
Add symbols in password

.PARAMETER NoLowercase
Remove lowercase from password

.PARAMETER NoUppercase
Remove uppercase from password

.PARAMETER NoDigits
Remove digits from password

.PARAMETER NoSymbols
Remove symbols from password

.PARAMETER Length
Password length (default: 16)

.PARAMETER Counter
Get a new version for an existing password (default: 1)

# .PARAMETER Prompt
# Interactively prompt SITE and LOGIN (prevent leak to shell history)

# .PARAMETER Clipboard
# Copy generated password to clipboard rather than displaying it.
# Need pbcopy (OSX), xsel or xclip (Linux) or clip (Windows).

# .PARAMETER Version
# lesspass version number

.EXAMPLE
lesspass Site Login masterpassword -noSymbols

No Symbols

.EXAMPLE
lesspass Site Login masterpassword -L -U -D

No Symbols shortcut

.EXAMPLE
lesspass Site Login masterpassword -D -L 8

Only Digits and Length of 8

# .EXAMPLE # is it applicable to Powershell?
# LESSPASS_MASTER_PASSWORD="masterpassword" lesspass Site Login

# Master password in env variable
#>

}

Export-ModuleMember -Function Get-LessPass -Alias lesspass