| 1 | package Firefox::Marionette::Cookiescip-perl cpan Firefox-Marionette 1.70 Firefox/Marionette/Cookie/; |
| 2 | |
| 3 | use strictscip-perl cpan Firefox-Marionette 1.70 strict/; |
| 4 | use warningsscip-perl cpan Firefox-Marionette 1.70 warnings/; |
| 5 | |
| 6 | our $VERSIONscip-perl cpan Firefox-Marionette 1.70 Firefox/Marionette/Cookie/$VERSION. = '1.70'; |
| 7 | |
| 8 | sub newscip-perl cpan Firefox-Marionette 1.70 Firefox/Marionette/Cookie/new(). { |
| 9 | my ( $class, %parameters ) = @_scip-perl cpan Firefox-Marionette 1.70 Firefox/Marionette/Cookie/`@_`.; |
| 10 | my $cookie = blessscip-perl cpan Firefox-Marionette 1.70 Firefox/Marionette/Cookie/bless(). { |
| 11 | http_only => $parameters{http_only} ? 1 : 0, |
| 12 | secure => $parameters{secure} ? 1 : 0, |
| 13 | domain => $parameters{domain}, |
| 14 | path => definedscip-perl cpan Firefox-Marionette 1.70 Firefox/Marionette/Cookie/defined(). $parameters{path} ? $parameters{path} : q[/], |
| 15 | value => $parameters{value}, |
| 16 | name => $parameters{name}, |
| 17 | }, $class; |
| 18 | if ( definedscip-perl cpan Firefox-Marionette 1.70 Firefox/Marionette/Cookie/defined(). $parameters{expiry} ) { |
| 19 | $cookie->{expiry} = $parameters{expiry}; |
| 20 | } |
| 21 | if ( definedscip-perl cpan Firefox-Marionette 1.70 Firefox/Marionette/Cookie/defined(). $parameters{same_site} ) { |
| 22 | $cookie->{same_site} = $parameters{same_site}; |
| 23 | } |
| 24 | return $cookie; |
| 25 | } |
| 26 | |
| 27 | sub http_onlyscip-perl cpan Firefox-Marionette 1.70 Firefox/Marionette/Cookie/http_only(). { |
| 28 | my ($self) = @_scip-perl cpan Firefox-Marionette 1.70 Firefox/Marionette/Cookie/`@_`.; |
| 29 | return $self->{http_only}; |
| 30 | } |
| 31 | |
| 32 | sub securescip-perl cpan Firefox-Marionette 1.70 Firefox/Marionette/Cookie/secure(). { |
| 33 | my ($self) = @_scip-perl cpan Firefox-Marionette 1.70 Firefox/Marionette/Cookie/`@_`.; |
| 34 | return $self->{secure}; |
| 35 | } |
| 36 | |
| 37 | sub domainscip-perl cpan Firefox-Marionette 1.70 Firefox/Marionette/Cookie/domain(). { |
| 38 | my ($self) = @_scip-perl cpan Firefox-Marionette 1.70 Firefox/Marionette/Cookie/`@_`.; |
| 39 | return $self->{domain}; |
| 40 | } |
| 41 | |
| 42 | sub pathscip-perl cpan Firefox-Marionette 1.70 Firefox/Marionette/Cookie/path(). { |
| 43 | my ($self) = @_scip-perl cpan Firefox-Marionette 1.70 Firefox/Marionette/Cookie/`@_`.; |
| 44 | return $self->{path}; |
| 45 | } |
| 46 | |
| 47 | sub valuescip-perl cpan Firefox-Marionette 1.70 Firefox/Marionette/Cookie/value(). { |
| 48 | my ($self) = @_scip-perl cpan Firefox-Marionette 1.70 Firefox/Marionette/Cookie/`@_`.; |
| 49 | return $self->{value}; |
| 50 | } |
| 51 | |
| 52 | sub expiryscip-perl cpan Firefox-Marionette 1.70 Firefox/Marionette/Cookie/expiry(). { |
| 53 | my ($self) = @_scip-perl cpan Firefox-Marionette 1.70 Firefox/Marionette/Cookie/`@_`.; |
| 54 | return $self->{expiry}; |
| 55 | } |
| 56 | |
| 57 | sub same_sitescip-perl cpan Firefox-Marionette 1.70 Firefox/Marionette/Cookie/same_site(). { |
| 58 | my ($self) = @_scip-perl cpan Firefox-Marionette 1.70 Firefox/Marionette/Cookie/`@_`.; |
| 59 | return $self->{same_site}; |
| 60 | } |
| 61 | |
| 62 | sub namescip-perl cpan Firefox-Marionette 1.70 Firefox/Marionette/Cookie/name(). { |
| 63 | my ($self) = @_scip-perl cpan Firefox-Marionette 1.70 Firefox/Marionette/Cookie/`@_`.; |
| 64 | return $self->{name}; |
| 65 | } |
| 66 | |
| 67 | 1; # Magic true value required at end of module |
| 68 | __END__ |
| 69 | |
| 70 | =head1 NAME |
| 71 | |
| 72 | Firefox::Marionette::Cookie - Represents a Firefox cookie retrieved using the Marionette protocol |
| 73 | |
| 74 | =head1 VERSION |
| 75 | |
| 76 | Version 1.70 |
| 77 | |
| 78 | =head1 SYNOPSIS |
| 79 | |
| 80 | use Firefox::Marionette(); |
| 81 | use v5.10; |
| 82 | |
| 83 | my $firefox = Firefox::Marionette->new()->go('https://metacpan.org/'); |
| 84 | foreach my $cookie ($firefox->cookies()) { |
| 85 | say "Cookie name is " . $cookie->name(); |
| 86 | } |
| 87 | |
| 88 | =head1 DESCRIPTION |
| 89 | |
| 90 | This module handles the implementation of a single Firefox cookie using the Marionette protocol |
| 91 | |
| 92 | =head1 SUBROUTINES/METHODS |
| 93 | |
| 94 | =head2 new |
| 95 | |
| 96 | accepts a hash as a parameter. Allowed keys are below; |
| 97 | |
| 98 | =over 4 |
| 99 | |
| 100 | =item * http_only - the httpOnly flag on the cookie. Allowed values are 1 or 0. Default is 0. |
| 101 | |
| 102 | =item * secure - the secure flag on the cookie. Allowed values are 1 or 0. Default is 0. |
| 103 | |
| 104 | =item * domain - the domain name belonging to the cookie. |
| 105 | |
| 106 | =item * path - the path belonging to the cookie. |
| 107 | |
| 108 | =item * expiry - the expiry time of the cookie in seconds since the UNIX epoch. expiry will return undef for Firefox versions less than 56 |
| 109 | |
| 110 | =item * value - the value of the cookie. |
| 111 | |
| 112 | =item * same_site - should the cookie be restricted to a first party or same-site context. See L<MSDN|https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite>. |
| 113 | |
| 114 | =item * name - the name of the cookie. |
| 115 | |
| 116 | =back |
| 117 | |
| 118 | This method returns a new L<cookie|Firefox::Marionette::Cookie> object. |
| 119 | |
| 120 | =head2 http_only |
| 121 | |
| 122 | returns the value of the httpOnly flag. |
| 123 | |
| 124 | =head2 secure |
| 125 | |
| 126 | returns the value of the secure flag. |
| 127 | |
| 128 | =head2 domain |
| 129 | |
| 130 | returns the value of cookies domain. For example '.metacpan.org' |
| 131 | |
| 132 | =head2 path |
| 133 | |
| 134 | returns the value of cookies path. For example '/search'. |
| 135 | |
| 136 | =head2 expiry |
| 137 | |
| 138 | returns the integer value of the cookies expiry time in seconds since the UNIX epoch. |
| 139 | |
| 140 | =head2 value |
| 141 | |
| 142 | returns the value of the cookie. |
| 143 | |
| 144 | =head2 same_site |
| 145 | |
| 146 | returns the L<Same Site|https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite> value for the cookie (if any). |
| 147 | |
| 148 | =head2 name |
| 149 | |
| 150 | returns the name of the cookie. |
| 151 | |
| 152 | =head1 DIAGNOSTICS |
| 153 | |
| 154 | None. |
| 155 | |
| 156 | =head1 CONFIGURATION AND ENVIRONMENT |
| 157 | |
| 158 | Firefox::Marionette::Cookie requires no configuration files or environment variables. |
| 159 | |
| 160 | =head1 DEPENDENCIES |
| 161 | |
| 162 | None. |
| 163 | |
| 164 | =head1 INCOMPATIBILITIES |
| 165 | |
| 166 | None reported. |
| 167 | |
| 168 | =head1 BUGS AND LIMITATIONS |
| 169 | |
| 170 | To report a bug, or view the current list of bugs, please visit L<https://github.com/david-dick/firefox-marionette/issues> |
| 171 | |
| 172 | =head1 AUTHOR |
| 173 | |
| 174 | David Dick C<< <[email protected]> >> |
| 175 | |
| 176 | =head1 LICENSE AND COPYRIGHT |
| 177 | |
| 178 | Copyright (c) 2024, David Dick C<< <[email protected]> >>. All rights reserved. |
| 179 | |
| 180 | This module is free software; you can redistribute it and/or |
| 181 | modify it under the same terms as Perl itself. See L<perlartistic/perlartistic>. |
| 182 | |
| 183 | =head1 DISCLAIMER OF WARRANTY |
| 184 | |
| 185 | BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY |
| 186 | FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN |
| 187 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES |
| 188 | PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER |
| 189 | EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 190 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE |
| 191 | ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH |
| 192 | YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL |
| 193 | NECESSARY SERVICING, REPAIR, OR CORRECTION. |
| 194 | |
| 195 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING |
| 196 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR |
| 197 | REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE |
| 198 | LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, |
| 199 | OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE |
| 200 | THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING |
| 201 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A |
| 202 | FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF |
| 203 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF |
| 204 | SUCH DAMAGES. |