More tidying up, added category to invoices, invoice delete now deletes invoice, pyaments, history and items associated with invoice. Exclude Cancelled invoice under dashboard income recieveables

This commit is contained in:
root 2019-05-17 15:33:01 -04:00
parent 9683d9f9f0
commit 9634d7a1e4
29 changed files with 1195 additions and 45 deletions

View File

@ -75,7 +75,7 @@
<option value="">- Vendor -</option>
<?php
$sql = mysqli_query($mysqli,"SELECT * FROM vendors");
$sql = mysqli_query($mysqli,"SELECT * FROM vendors WHERE client_id = 0 order by vendor_name ASC");
while($row = mysqli_fetch_array($sql)){
$vendor_id = $row['vendor_id'];
$vendor_name = $row['vendor_name'];

View File

@ -36,8 +36,6 @@
$location_id = $row['location_id'];
$contact_id = $row['contact_id'];
if($asset_type == 'Laptop'){
$device_icon = "laptop";
}elseif($asset_type == 'Desktop'){
@ -48,8 +46,8 @@
$device_icon = "print";
}elseif($asset_type == 'Camera'){
$device_icon = "video";
}elseif($file_ext == 'Switch' or $file_ext == 'Firewall/Router'){
$device_icon = "network";
}elseif($asset_type == 'Switch' or $asset_type == 'Firewall/Router'){
$device_icon = "network-wired";
}elseif($asset_type == 'Access Point'){
$device_icon = "wifi";
}elseif($asset_type == 'Phone'){
@ -90,7 +88,7 @@
<div class="modal-dialog modal-sm">
<div class="modal-content bg-dark">
<div class="modal-header text-white">
<h5 class="modal-title"><i class="fa fa-fw fa-key mr-2"></i><?php echo $asset_name; ?> Login</h5>
<h5 class="modal-title"><i class="fa fa-fw fa-key mr-2"></i><?php echo $asset_name; ?></h5>
<button type="button" class="close text-white" data-dismiss="modal">
<span aria-hidden="true">&times;</span>
</button>

View File

@ -32,10 +32,14 @@
?>
<tr>
<?php if(!empty($contact_photo)){ ?>
<td class="text-center">
<img height="48" width="48" class="img-fluid rounded-circle" src="<?php echo $contact_photo; ?>">
<div class="text-secondary"><?php echo $contact_name; ?></div>
</td>
<?php }else{ ?>
<td class="text-center"><?php echo $contact_name; ?></td>
<?php } ?>
<td><?php echo $contact_title; ?></td>
<td><a href="mailto:<?php echo $contact_email; ?>"><?php echo $contact_email; ?></a></td>
<td><?php echo $contact_phone; ?></td>

View File

@ -1,6 +1,6 @@
<?php
$sql = mysqli_query($mysqli,"SELECT * FROM invoices WHERE client_id = $client_id ORDER BY invoice_number DESC");
$sql = mysqli_query($mysqli,"SELECT * FROM invoices, categories WHERE invoices.client_id = $client_id AND invoices.category_id = categories.category_id ORDER BY invoice_number DESC");
?>
@ -19,6 +19,7 @@
<th class="text-right">Amount</th>
<th>Date</th>
<th>Due</th>
<th>Category</th>
<th>Status</th>
<th class="text-center">Actions</th>
</tr>
@ -34,6 +35,7 @@
$invoice_due = $row['invoice_due'];
$invoice_amount = $row['invoice_amount'];
$invoice_category_id = $row['category_id'];
$category_name = $row['category_name'];
$now = time();
if(($invoice_status == "Sent" or $invoice_status == "Partial") and strtotime($invoice_due) < $now ){
@ -62,6 +64,7 @@
<td class="text-right text-monospace">$<?php echo number_format($invoice_amount,2); ?></td>
<td><?php echo $invoice_date; ?></td>
<td><div class="<?php echo $overdue_color; ?>"><?php echo $invoice_due; ?></div></td>
<td><?php echo $category_name; ?></td>
<td>
<span class="p-2 badge badge-<?php echo $invoice_badge_color; ?>">
<?php echo $invoice_status; ?>

View File

@ -28,8 +28,8 @@ $sql_total_expenses = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS total_
$row = mysqli_fetch_array($sql_total_expenses);
$total_expenses = $row['total_expenses'];
//Total up all the
$sql_invoice_totals = mysqli_query($mysqli,"SELECT SUM(invoice_amount) AS invoice_totals FROM invoices WHERE invoice_status NOT LIKE 'Draft' AND AND YEAR(invoice_date) = $year");
//Total up all the Invoices that are not draft or cancelled
$sql_invoice_totals = mysqli_query($mysqli,"SELECT SUM(invoice_amount) AS invoice_totals FROM invoices WHERE invoice_status NOT LIKE 'Draft' AND invoice_status NOT LIKE 'Cancelled' AND YEAR(invoice_date) = $year");
$row = mysqli_fetch_array($sql_invoice_totals);
$invoice_totals = $row['invoice_totals'];
@ -409,7 +409,7 @@ var myPieChart = new Chart(ctx, {
datasets: [{
data: [
<?php
$sql_categories = mysqli_query($mysqli,"SELECT * FROM categories WHERE category_type = 'expense'");
$sql_categories = mysqli_query($mysqli,"SELECT * FROM categories WHERE category_type = 'Expense'");
while($row = mysqli_fetch_array($sql_categories)){
$category_id = $row['category_id'];

View File

@ -8,6 +8,7 @@
</button>
</div>
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="category_id" value="<?php echo $category_id; ?>">
<div class="modal-body bg-white">
<div class="form-group">
<label>Name</label>
@ -28,7 +29,7 @@
</div>
<div class="modal-footer bg-white">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="submit" name="add_category" class="btn btn-primary">Save</button>
<button type="submit" name="edit_category" class="btn btn-primary">Save</button>
</div>
</form>
</div>

View File

@ -73,7 +73,7 @@
<select class="form-control" name="vendor" required>
<?php
$sql2 = mysqli_query($mysqli,"SELECT * FROM vendors");
$sql2 = mysqli_query($mysqli,"SELECT * FROM vendors WHERE client_id = 0 ORDER BY vendor_name ASC");
while($row = mysqli_fetch_array($sql2)){
$vendor_id2 = $row['vendor_id'];
$vendor_name = $row['vendor_name'];

View File

@ -24,7 +24,6 @@
<th>Vendor</th>
<th>Category</th>
<th>Account</th>
<th></th>
<th class="text-center">Actions</th>
</tr>
</thead>
@ -48,24 +47,30 @@
if(empty($expense_receipt)){
$receipt_attached = "";
}else{
$receipt_attached = "<a class='btn btn-dark btn-sm' target='_blank' href='$expense_receipt'><i class='fa fa-file-pdf'></i></a>";
$receipt_attached = "<a class='text-secondary mr-2' target='_blank' href='$expense_receipt'><i class='fa fa-file-pdf'></i></a>";
}
?>
<tr>
<td><?php echo $expense_date; ?></td>
<td><?php echo $receipt_attached; ?> <?php echo $expense_date; ?></td>
<td class="text-right text-monospace">$<?php echo number_format($expense_amount,2); ?></td>
<td><?php echo $vendor_name; ?></td>
<td><?php echo $category_name; ?></td>
<td><?php echo $account_name; ?></td>
<td><?php echo $receipt_attached; ?></td>
<td>
<div class="dropdown dropleft text-center">
<button class="btn btn-secondary btn-sm" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fas fa-ellipsis-h"></i>
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<?php
if(!empty($expense_receipt)){
?>
<a class="dropdown-item" href="<?php echo $expense_receipt; ?>" target="_blank">Reciept</a>
<?php
}
?>
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#editExpenseModal<?php echo $expense_id; ?>">Edit</a>
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addExpenseCopyModal<?php echo $expense_id; ?>">Copy</a>
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addExpenseRefundModal<?php echo $expense_id; ?>">Refund</a>

View File

@ -54,7 +54,7 @@ if(isset($_GET['invoice_id'])){
//Set Badge color based off of invoice status
if($invoice_status == "Sent"){
$invoice_badge_color = "warning";
$invoice_badge_color = "warning text-white";
}elseif($invoice_status == "Partial"){
$invoice_badge_color = "primary";
}elseif($invoice_status == "Paid"){

View File

@ -45,8 +45,9 @@
$real_overdue_amount = $total_overdue - $total_overdue_partial;
$sql = mysqli_query($mysqli,"SELECT * FROM invoices, clients
$sql = mysqli_query($mysqli,"SELECT * FROM invoices, clients, categories
WHERE invoices.client_id = clients.client_id
AND invoices.category_id = categories.category_id
ORDER BY invoices.invoice_number DESC");
?>
@ -108,6 +109,7 @@
<th class="text-right">Amount</th>
<th>Invoice Date</th>
<th>Due Date</th>
<th>Category</th>
<th>Status</th>
<th class="text-center">Actions</th>
</tr>
@ -125,6 +127,7 @@
$client_id = $row['client_id'];
$client_name = $row['client_name'];
$category_id = $row['category_id'];
$category_name = $row['category_name'];
$now = time();
@ -134,15 +137,8 @@
$overdue_color = "";
}
//$unixtime_invoice_due = strtotime($invoice_due);
//if($unixtime_invoice_due < time()){
// $overdue_color = "text-danger";
//}else{
// $overdue_color = "";
//}
if($invoice_status == "Sent"){
$invoice_badge_color = "warning";
$invoice_badge_color = "warning text-white";
}elseif($invoice_status == "Partial"){
$invoice_badge_color = "primary";
}elseif($invoice_status == "Paid"){
@ -161,6 +157,7 @@
<td class="text-right text-monospace">$<?php echo number_format($invoice_amount,2); ?></td>
<td><?php echo $invoice_date; ?></td>
<td class="<?php echo $overdue_color; ?>"><?php echo $invoice_due; ?></td>
<td><?php echo $category_name; ?></td>
<td>
<span class="p-2 badge badge-<?php echo $invoice_badge_color; ?>">
<?php echo $invoice_status; ?>

View File

@ -503,7 +503,7 @@ if(isset($_POST['add_account'])){
$name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']));
$opening_balance = $_POST['opening_balance'];
mysqli_query($mysqli,"INSERT INTO accounts SET account_name = '$name', opening_balance = '$opening_balance', account_created_at NOW()");
mysqli_query($mysqli,"INSERT INTO accounts SET account_name = '$name', opening_balance = '$opening_balance', account_created_at = NOW()");
$_SESSION['alert_message'] = "Account added";
@ -516,7 +516,7 @@ if(isset($_POST['edit_account'])){
$account_id = intval($_POST['account_id']);
$name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']));
mysqli_query($mysqli,"UPDATE accounts SET account_name = '$name' account_updated_at = NOW() WHERE account_id = $account_id");
mysqli_query($mysqli,"UPDATE accounts SET account_name = '$name', account_updated_at = NOW() WHERE account_id = $account_id");
$_SESSION['alert_message'] = "Account modified";
@ -740,7 +740,7 @@ if(isset($_POST['add_invoice'])){
mysqli_query($mysqli,"INSERT INTO invoice_history SET invoice_history_date = CURDATE(), invoice_history_status = 'Draft', invoice_history_description = 'INVOICE added!', invoice_id = $invoice_id");
$_SESSION['alert_message'] = "Invoice added";
header("Location: invoice.php?invoicvoice_id");
header("Location: invoice.php?invoice_id=$invoice_id");
}
if(isset($_POST['edit_invoice'])){
@ -958,6 +958,27 @@ if(isset($_GET['delete_invoice'])){
mysqli_query($mysqli,"DELETE FROM invoices WHERE invoice_id = $invoice_id");
//Delete Items Associated with the Invoice
$sql = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE invoice_id = $invoice_id");
while($row = mysqli_fetch_array($sql)){;
$item_id = $row['item_id'];
mysqli_query($mysqli,"DELETE FROM invoice_items WHERE item_id = $item_id");
}
//Delete History Associated with the Invoice
$sql = mysqli_query($mysqli,"SELECT * FROM invoice_history WHERE invoice_id = $invoice_id");
while($row = mysqli_fetch_array($sql)){;
$invoice_history_id = $row['invoice_history_id'];
mysqli_query($mysqli,"DELETE FROM invoice_history WHERE invoice_history_id = $invoice_history_id");
}
//Delete Payments Associated with the Invoice
$sql = mysqli_query($mysqli,"SELECT * FROM payments WHERE invoice_id = $invoice_id");
while($row = mysqli_fetch_array($sql)){;
$payment_id = $row['payment_id'];
mysqli_query($mysqli,"DELETE FROM payments WHERE payment_id = $payment_id");
}
$_SESSION['alert_message'] = "Invoice deleted";
header("Location: " . $_SERVER["HTTP_REFERER"]);
@ -1053,7 +1074,10 @@ if(isset($_POST['add_payment'])){
//Calculate the Invoice balance
$invoice_balance = $invoice_amount - $total_payments_amount;
//Format Amount
$formatted_amount = number_format($amount,2);
$formatted_invoice_balance = number_format($invoice_balance,2);
//Determine if invoice has been paid then set the status accordingly
if($invoice_balance == 0){
$invoice_status = "Paid";
@ -1079,8 +1103,8 @@ if(isset($_POST['add_payment'])){
// Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = "Thank You! - Payment Recieved for Invoice INV-$invoice_number";
$mail->Body = "Hello $client_name,<br><br>We have recieved your payment of $amount on $date for invoice INV-$invoice_number by $payment_method<br><br>If you have any questions please contact us at the number below.<br><br>~<br>$config_company_name<br>Automated Billing Department<br>$config_company_phone";
$mail->Subject = "Payment Recieved - Invoice INV-$invoice_number";
$mail->Body = "Hello $client_name,<br><br>You are paid in full, we have recieved your payment of $$formatted_amount on $date for invoice INV-$invoice_number by $payment_method.<br><br>If you have any questions please contact us at the number below.<br><br>~<br>$config_company_name<br>Automated Billing Department<br>$config_company_phone";
//$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->send();
@ -1119,8 +1143,8 @@ if(isset($_POST['add_payment'])){
// Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = "Thank You! - Partial Payment Recieved for Invoice INV-$invoice_number";
$mail->Body = "Hello $client_name,<br><br>We have recieved your payment of $amount on $date for invoice INV-$invoice_number by $payment_method, although you still have a balance of $invoice_balance<br><br>If you have any questions please contact us at the number below.<br><br>~<br>$config_company_name<br>Automated Billing Department<br>$config_company_phone";
$mail->Subject = "Partial Payment Recieved for Invoice INV-$invoice_number";
$mail->Body = "Hello $client_name,<br><br>We have recieved your payment of $$formatted_amount on $date for invoice INV-$invoice_number by $payment_method with a balance of $$formatted_invoice_balance.<br><br>If you have any questions please contact us at the number below.<br><br>~<br>$config_company_name<br>Automated Billing Department<br>$config_company_phone";
//$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->send();
@ -1178,6 +1202,9 @@ if(isset($_GET['delete_payment'])){
//Update Invoice Status
mysqli_query($mysqli,"UPDATE invoices SET invoice_status = '$invoice_status' WHERE invoice_id = $invoice_id");
//Add Payment to History
mysqli_query($mysqli,"INSERT INTO invoice_history SET invoice_history_date = CURDATE(), invoice_history_status = '$invoice_status', invoice_history_description = 'INVOICE payment deleted', invoice_id = $invoice_id");
mysqli_query($mysqli,"DELETE FROM payments WHERE payment_id = $payment_id");
$_SESSION['alert_message'] = "Payment deleted";
@ -1402,10 +1429,19 @@ if(isset($_GET['email_invoice'])){
// Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = "Invoice $invoice_number - $invoice_date - Due $invoice_due";
$mail->Body = "Hello $client_name,<br><br>Thank you for choosing $config_company_name! -- attached to this email is your invoice in PDF form due on <b>$invoice_due</b> Please make all checks payable to $config_company_name and mail to $config_company_address $config_company_city $config_company_state $config_company_zip before <b>$invoice_due</b>.<br><br>If you have any questions please contact us at the number below.<br><br>~<br>$config_company_name<br>Automated Billing Department<br>$config_company_phone";
//$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if($invoice_status == 'Paid'){
$mail->Subject = "Copy of Invoice $invoice_number";
$mail->Body = "Hello $client_name,<br><br>Attached to this email is a copy of your invoice marked <b>paid</b>.<br><br>If you have any questions please contact us at the number below.<br><br>~<br>$config_company_name<br>Automated Billing Department<br>$config_company_phone";
}else{
$mail->Subject = "Invoice $invoice_number - $invoice_date - Due on $invoice_due";
$mail->Body = "Hello $client_name,<br><br>Attached to this email is your invoice. Please make all checks payable to $config_company_name and mail to <br><br>$config_company_address<br>$config_company_city $config_company_state $config_company_zip<br><br>before <b>$invoice_due</b>.<br><br>If you have any questions please contact us at the number below.<br><br>~<br>$config_company_name<br>Automated Billing Department<br>$config_company_phone";
//$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
}
$mail->send();
echo 'Message has been sent';

View File

@ -30,22 +30,37 @@
<div class="form-group">
<label>City</label>
<input type="text" class="form-control" name="config_company_city" placeholder="City" value="<?php echo $config_company_city; ?>" >
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-city"></i></span>
</div>
<input type="text" class="form-control" name="config_company_city" placeholder="City" value="<?php echo $config_company_city; ?>" >
</div>
</div>
<div class="form-group">
<label>State</label>
<select class="form-control" name="config_company_state">
<option value="">Select a state...</option>
<?php foreach($states_array as $state_abbr => $state_name) { ?>
<option <?php if($config_company_state == $state_abbr) { echo "selected"; } ?> value="<?php echo $state_abbr; ?>"><?php echo $state_name; ?></option>
<?php } ?>
</select>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-flag"></i></span>
</div>
<select class="form-control" name="config_company_state">
<option value="">Select a state...</option>
<?php foreach($states_array as $state_abbr => $state_name) { ?>
<option <?php if($config_company_state == $state_abbr) { echo "selected"; } ?> value="<?php echo $state_abbr; ?>"><?php echo $state_name; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group">
<label>Zip</label>
<input type="text" class="form-control" name="config_company_zip" placeholder="Zip Code" value="<?php echo $config_company_zip; ?>" >
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fab fa-fw fa-usps"></i></span>
</div>
<input type="text" class="form-control" name="config_company_zip" placeholder="Zip Code" value="<?php echo $config_company_zip; ?>" >
</div>
</div>
<div class="form-group">

View File

@ -0,0 +1,25 @@
# Contributing
First of all, **thank you** for contributing.
Bugs or feature requests can be posted online on the GitHub issues section of the project.
Few rules to ease code reviews and merges:
- You MUST follow the [PSR-1](http://www.php-fig.org/psr/psr-1/), [PSR-2](http://www.php-fig.org/psr/psr-2/) and [PSR-4](http://www.php-fig.org/psr/psr-4/) coding standards.
- You MUST run the test suite.
- You MUST write (or update) unit tests when bugs are fixed or features are added.
- You SHOULD write documentation.
We use [Git-Flow](http://jeffkreeftmeijer.com/2010/why-arent-you-using-git-flow/) to automate our git branching workflow.
To contribute use [Pull Requests](https://help.github.com/articles/using-pull-requests), please, write commit messages that make sense, and rebase your branch before submitting your PR.
May be asked to squash your commits too. This is used to "clean" your Pull Request before merging it, avoiding commits such as fix tests, fix 2, fix 3, etc.
Run test suite
------------
* install composer: `curl -s http://getcomposer.org/installer | php`
* install dependencies: `php composer.phar install`
* run tests: `vendor/bin/phpunit`

View File

@ -0,0 +1,16 @@
| Q | A
| -------------------- | -----
| Bug report? | yes/no
| Feature request? | yes/no
| BC Break report? | yes/no
| RFC? / Specification | yes/no
| Library version | x.y(.z)
<!--
Fill in this template according to your issue.
Otherwise, replace this comment by the description of your issue.
Please consider the following requirements
* You MUST never send security issues here. If you think that your issue is a security one then contact Spomky in private at https://gitter.im/Spomky/
* You should not post many lines of source code or console logs. Small inputs (approx 5 lines) are acceptable otherwize you should use a third party service (e.g. Pastebin, Chop...).
-->

View File

@ -0,0 +1,21 @@
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | yes/no
| New feature? | yes/no
| BC breaks? | yes/no
| Deprecations? | yes/no
| Tests pass? | yes/no
| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->
| License | MIT
| Tests added | <!--highly recommended for new features-->
| Doc PR | <!--highly recommended for new features-->
<!--
Fill in this template according to the PR you're about to submit.
Replace this comment by a description of what your PR is solving.
Please consider the following requirement:
* Modification of existing tests should be avoided unless deemed necessary.
* You MUST never open a PR related to a security issue. Contact Spomky in private at https://gitter.im/Spomky/
-->

61
vendor/otphp-10.0/.php_cs.dist vendored Normal file
View File

@ -0,0 +1,61 @@
<?php
$header = 'The MIT License (MIT)
Copyright (c) 2014-2019 Spomky-Labs
This software may be modified and distributed under the terms
of the MIT license. See the LICENSE file for details.';
$finder = PhpCsFixer\Finder::create()
->in(__DIR__.'/src')
->in(__DIR__.'/tests')
;
return PhpCsFixer\Config::create()
->setRules([
'@PSR1' => true,
'@PSR2' => true,
'@Symfony' => true,
'@DoctrineAnnotation' => true,
'@PHP70Migration' => true,
'@PHP71Migration' => true,
'strict_param' => true,
'strict_comparison' => true,
'array_syntax' => ['syntax' => 'short'],
'array_indentation' => true,
'ordered_imports' => true,
'protected_to_private' => true,
'declare_strict_types' => true,
'native_function_invocation' => [
'include' => ['@compiler_optimized'],
'scope' => 'namespaced',
],
'mb_str_functions' => true,
'method_chaining_indentation' => true,
'linebreak_after_opening_tag' => true,
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
'compact_nullable_typehint' => true,
'no_superfluous_phpdoc_tags' => true,
'no_superfluous_elseif' => true,
'phpdoc_trim_consecutive_blank_line_separation' => true,
'phpdoc_order' => true,
'pow_to_exponentiation' => true,
'simplified_null_return' => true,
'header_comment' => [
'header' => $header,
],
'align_multiline_comment' => [
'comment_type' => 'all_multiline',
],
'php_unit_test_annotation' => [
'case' => 'snake',
'style' => 'annotation',
],
'php_unit_test_case_static_method_calls' => true,
])
->setRiskyAllowed(true)
->setUsingCache(true)
->setFinder($finder)
;

46
vendor/otphp-10.0/CODE_OF_CONDUCT.md vendored Normal file
View File

@ -0,0 +1,46 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at contact@spomky-labs.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/

20
vendor/otphp-10.0/LICENSE vendored Normal file
View File

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2014-2016 Florent Morselli
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

50
vendor/otphp-10.0/composer.json vendored Normal file
View File

@ -0,0 +1,50 @@
{
"name": "spomky-labs/otphp",
"type": "library",
"description": "A PHP library for generating one time passwords according to RFC 4226 (HOTP Algorithm) and the RFC 6238 (TOTP Algorithm) and compatible with Google Authenticator",
"license": "MIT",
"keywords": ["otp", "hotp", "totp", "RFC 4226", "RFC 6238", "Google Authenticator", "FreeOTP"],
"homepage": "https://github.com/Spomky-Labs/otphp",
"authors": [
{
"name": "Florent Morselli",
"homepage": "https://github.com/Spomky"
},
{
"name": "All contributors",
"homepage": "https://github.com/Spomky-Labs/otphp/contributors"
}
],
"require": {
"php": "^7.2|^8.0",
"ext-mbstring": "*",
"paragonie/constant_time_encoding": "^2.0",
"beberlei/assert": "^3.0",
"thecodingmachine/safe": "^0.1.14"
},
"require-dev": {
"phpunit/phpunit": "^8.0",
"php-coveralls/php-coveralls": "^2.0",
"phpstan/phpstan": "^0.11",
"phpstan/phpstan-beberlei-assert": "^0.11.0",
"phpstan/phpstan-deprecation-rules": "^0.11",
"phpstan/phpstan-phpunit": "^0.11",
"phpstan/phpstan-strict-rules": "^0.11",
"thecodingmachine/phpstan-safe-rule": "^0.1.0"
},
"suggest": {
},
"autoload": {
"psr-4": { "OTPHP\\": "src/" }
},
"autoload-dev": {
"psr-4": { "OTPHP\\Test\\": "tests/" }
},
"extra": {
"branch-alias": {
"v10.0": "10.0.x-dev",
"v9.0": "9.0.x-dev",
"v8.3": "8.3.x-dev"
}
}
}

13
vendor/otphp-10.0/phpstan.neon vendored Normal file
View File

@ -0,0 +1,13 @@
parameters:
level: 7
paths:
- src
- tests
ignoreErrors:
- '#Variable property access on \$this\(OTPHP\\OTP\)\.#'
includes:
- vendor/phpstan/phpstan-strict-rules/rules.neon
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
- vendor/thecodingmachine/phpstan-safe-rule/phpstan-safe-rule.neon
- vendor/phpstan/phpstan-beberlei-assert/extension.neon

103
vendor/otphp-10.0/src/Factory.php vendored Normal file
View File

@ -0,0 +1,103 @@
<?php
declare(strict_types=1);
/*
* The MIT License (MIT)
*
* Copyright (c) 2014-2019 Spomky-Labs
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
namespace OTPHP;
use Assert\Assertion;
use InvalidArgumentException;
use function Safe\parse_url;
use function Safe\sprintf;
use Throwable;
/**
* This class is used to load OTP object from a provisioning Uri.
*/
final class Factory implements FactoryInterface
{
public static function loadFromProvisioningUri(string $uri): OTPInterface
{
try {
$parsed_url = parse_url($uri);
} catch (Throwable $throwable) {
throw new InvalidArgumentException('Not a valid OTP provisioning URI', $throwable->getCode(), $throwable);
}
Assertion::isArray($parsed_url, 'Not a valid OTP provisioning URI');
self::checkData($parsed_url);
$otp = self::createOTP($parsed_url);
self::populateOTP($otp, $parsed_url);
return $otp;
}
private static function populateParameters(OTPInterface &$otp, array $data): void
{
foreach ($data['query'] as $key => $value) {
$otp->setParameter($key, $value);
}
}
private static function populateOTP(OTPInterface &$otp, array $data): void
{
self::populateParameters($otp, $data);
$result = explode(':', rawurldecode(mb_substr($data['path'], 1)));
if (2 > \count($result)) {
$otp->setIssuerIncludedAsParameter(false);
return;
}
if (null !== $otp->getIssuer()) {
Assertion::eq($result[0], $otp->getIssuer(), 'Invalid OTP: invalid issuer in parameter');
$otp->setIssuerIncludedAsParameter(true);
}
$otp->setIssuer($result[0]);
}
private static function checkData(array &$data): void
{
foreach (['scheme', 'host', 'path', 'query'] as $key) {
Assertion::keyExists($data, $key, 'Not a valid OTP provisioning URI');
}
Assertion::eq('otpauth', $data['scheme'], 'Not a valid OTP provisioning URI');
parse_str($data['query'], $data['query']);
Assertion::keyExists($data['query'], 'secret', 'Not a valid OTP provisioning URI');
}
private static function createOTP(array $parsed_url): OTPInterface
{
switch ($parsed_url['host']) {
case 'totp':
$totp = TOTP::create($parsed_url['query']['secret']);
$totp->setLabel(self::getLabel($parsed_url['path']));
return $totp;
case 'hotp':
$hotp = HOTP::create($parsed_url['query']['secret']);
$hotp->setLabel(self::getLabel($parsed_url['path']));
return $hotp;
default:
throw new InvalidArgumentException(sprintf('Unsupported "%s" OTP type', $parsed_url['host']));
}
}
private static function getLabel(string $data): string
{
$result = explode(':', rawurldecode(mb_substr($data, 1)));
return 2 === \count($result) ? $result[1] : $result[0];
}
}

View File

@ -0,0 +1,23 @@
<?php
declare(strict_types=1);
/*
* The MIT License (MIT)
*
* Copyright (c) 2014-2019 Spomky-Labs
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
namespace OTPHP;
interface FactoryInterface
{
/**
* This method is the unique public method of the class.
* It can load a provisioning Uri and convert it into an OTP object.
*/
public static function loadFromProvisioningUri(string $uri): OTPInterface;
}

100
vendor/otphp-10.0/src/HOTP.php vendored Normal file
View File

@ -0,0 +1,100 @@
<?php
declare(strict_types=1);
/*
* The MIT License (MIT)
*
* Copyright (c) 2014-2019 Spomky-Labs
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
namespace OTPHP;
use Assert\Assertion;
final class HOTP extends OTP implements HOTPInterface
{
protected function __construct(?string $secret, int $counter, string $digest, int $digits)
{
parent::__construct($secret, $digest, $digits);
$this->setCounter($counter);
}
public static function create(?string $secret = null, int $counter = 0, string $digest = 'sha1', int $digits = 6): HOTPInterface
{
return new self($secret, $counter, $digest, $digits);
}
protected function setCounter(int $counter): void
{
$this->setParameter('counter', $counter);
}
public function getCounter(): int
{
return $this->getParameter('counter');
}
private function updateCounter(int $counter): void
{
$this->setCounter($counter);
}
public function getProvisioningUri(): string
{
return $this->generateURI('hotp', ['counter' => $this->getCounter()]);
}
/**
* If the counter is not provided, the OTP is verified at the actual counter.
*/
public function verify(string $otp, ?int $counter = null, ?int $window = null): bool
{
Assertion::greaterOrEqualThan($counter, 0, 'The counter must be at least 0.');
if (null === $counter) {
$counter = $this->getCounter();
} elseif ($counter < $this->getCounter()) {
return false;
}
return $this->verifyOtpWithWindow($otp, $counter, $window);
}
private function getWindow(?int $window): int
{
return abs($window ?? 0);
}
private function verifyOtpWithWindow(string $otp, int $counter, ?int $window): bool
{
$window = $this->getWindow($window);
for ($i = $counter; $i <= $counter + $window; ++$i) {
if ($this->compareOTP($this->at($i), $otp)) {
$this->updateCounter($i + 1);
return true;
}
}
return false;
}
protected function getParameterMap(): array
{
$v = array_merge(
parent::getParameterMap(),
['counter' => function ($value) {
Assertion::greaterOrEqualThan((int) $value, 0, 'Counter must be at least 0.');
return (int) $value;
}]
);
return $v;
}
}

29
vendor/otphp-10.0/src/HOTPInterface.php vendored Normal file
View File

@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
/*
* The MIT License (MIT)
*
* Copyright (c) 2014-2019 Spomky-Labs
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
namespace OTPHP;
interface HOTPInterface extends OTPInterface
{
/**
* The initial counter (a positive integer).
*/
public function getCounter(): int;
/**
* Create a new TOTP object.
*
* If the secret is null, a random 64 bytes secret will be generated.
*/
public static function create(?string $secret = null, int $counter = 0, string $digest = 'sha1', int $digits = 6): self;
}

111
vendor/otphp-10.0/src/OTP.php vendored Normal file
View File

@ -0,0 +1,111 @@
<?php
declare(strict_types=1);
/*
* The MIT License (MIT)
*
* Copyright (c) 2014-2019 Spomky-Labs
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
namespace OTPHP;
use Assert\Assertion;
use ParagonIE\ConstantTime\Base32;
use RuntimeException;
use function Safe\ksort;
use function Safe\sprintf;
abstract class OTP implements OTPInterface
{
use ParameterTrait;
protected function __construct(?string $secret, string $digest, int $digits)
{
$this->setSecret($secret);
$this->setDigest($digest);
$this->setDigits($digits);
}
public function getQrCodeUri(string $uri, string $placeholder): string
{
$provisioning_uri = urlencode($this->getProvisioningUri());
return str_replace($placeholder, $provisioning_uri, $uri);
}
/**
* The OTP at the specified input.
*/
protected function generateOTP(int $input): string
{
$hash = hash_hmac($this->getDigest(), $this->intToByteString($input), $this->getDecodedSecret());
$hmac = [];
foreach (str_split($hash, 2) as $hex) {
$hmac[] = hexdec($hex);
}
$offset = $hmac[\count($hmac) - 1] & 0xF;
$code = ($hmac[$offset + 0] & 0x7F) << 24 | ($hmac[$offset + 1] & 0xFF) << 16 | ($hmac[$offset + 2] & 0xFF) << 8 | ($hmac[$offset + 3] & 0xFF);
$otp = $code % 10 ** $this->getDigits();
return str_pad((string) $otp, $this->getDigits(), '0', STR_PAD_LEFT);
}
public function at(int $timestamp): string
{
return $this->generateOTP($timestamp);
}
protected function filterOptions(array &$options): void
{
foreach (['algorithm' => 'sha1', 'period' => 30, 'digits' => 6] as $key => $default) {
if (isset($options[$key]) && $default === $options[$key]) {
unset($options[$key]);
}
}
ksort($options);
}
protected function generateURI(string $type, array $options): string
{
$label = $this->getLabel();
Assertion::string($label, 'The label is not set.');
Assertion::false($this->hasColon($label), 'Label must not contain a colon.');
$options = array_merge($options, $this->getParameters());
$this->filterOptions($options);
$params = str_replace(['+', '%7E'], ['%20', '~'], http_build_query($options));
return sprintf('otpauth://%s/%s?%s', $type, rawurlencode((null !== $this->getIssuer() ? $this->getIssuer().':' : '').$label), $params);
}
private function getDecodedSecret(): string
{
try {
$secret = Base32::decodeUpper($this->getSecret());
} catch (\Exception $e) {
throw new RuntimeException('Unable to decode the secret. Is it correctly base32 encoded?');
}
return $secret;
}
private function intToByteString(int $int): string
{
$result = [];
while (0 !== $int) {
$result[] = \chr($int & 0xFF);
$int >>= 8;
}
return str_pad(implode(array_reverse($result)), 8, "\000", STR_PAD_LEFT);
}
protected function compareOTP(string $safe, string $user): bool
{
return hash_equals($safe, $user);
}
}

94
vendor/otphp-10.0/src/OTPInterface.php vendored Normal file
View File

@ -0,0 +1,94 @@
<?php
declare(strict_types=1);
/*
* The MIT License (MIT)
*
* Copyright (c) 2014-2019 Spomky-Labs
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
namespace OTPHP;
interface OTPInterface
{
/**
* @return string Return the OTP at the specified timestamp
*/
public function at(int $timestamp): string;
/**
* Verify that the OTP is valid with the specified input.
* If no input is provided, the input is set to a default value or false is returned.
*/
public function verify(string $otp, ?int $input = null, ?int $window = null): bool;
/**
* @return string The secret of the OTP
*/
public function getSecret(): string;
/**
* @param string $label The label of the OTP
*/
public function setLabel(string $label): void;
/**
* @return string|null The label of the OTP
*/
public function getLabel(): ?string;
/**
* @return string|null The issuer
*/
public function getIssuer(): ?string;
public function setIssuer(string $issuer): void;
/**
* @return bool If true, the issuer will be added as a parameter in the provisioning URI
*/
public function isIssuerIncludedAsParameter(): bool;
public function setIssuerIncludedAsParameter(bool $issuer_included_as_parameter): void;
/**
* @return int Number of digits in the OTP
*/
public function getDigits(): int;
/**
* @return string Digest algorithm used to calculate the OTP. Possible values are 'md5', 'sha1', 'sha256' and 'sha512'
*/
public function getDigest(): string;
/**
* @return mixed|null
*/
public function getParameter(string $parameter);
public function hasParameter(string $parameter): bool;
public function getParameters(): array;
/**
* @param mixed|null $value
*/
public function setParameter(string $parameter, $value): void;
/**
* Get the provisioning URI.
*/
public function getProvisioningUri(): string;
/**
* Get the provisioning URI.
*
* @param string $uri The Uri of the QRCode generator with all parameters. This Uri MUST contain a placeholder that will be replaced by the method.
* @param string $placeholder the placeholder to be replaced in the QR Code generator URI
*/
public function getQrCodeUri(string $uri, string $placeholder): string;
}

190
vendor/otphp-10.0/src/ParameterTrait.php vendored Normal file
View File

@ -0,0 +1,190 @@
<?php
declare(strict_types=1);
/*
* The MIT License (MIT)
*
* Copyright (c) 2014-2019 Spomky-Labs
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
namespace OTPHP;
use Assert\Assertion;
use InvalidArgumentException;
use ParagonIE\ConstantTime\Base32;
use function Safe\sprintf;
trait ParameterTrait
{
/**
* @var array
*/
private $parameters = [];
/**
* @var string|null
*/
private $issuer;
/**
* @var string|null
*/
private $label;
/**
* @var bool
*/
private $issuer_included_as_parameter = true;
public function getParameters(): array
{
$parameters = $this->parameters;
if (null !== $this->getIssuer() && true === $this->isIssuerIncludedAsParameter()) {
$parameters['issuer'] = $this->getIssuer();
}
return $parameters;
}
public function getSecret(): string
{
return $this->getParameter('secret');
}
private function setSecret(?string $secret): void
{
$this->setParameter('secret', $secret);
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(string $label): void
{
$this->setParameter('label', $label);
}
public function getIssuer(): ?string
{
return $this->issuer;
}
public function setIssuer(string $issuer): void
{
$this->setParameter('issuer', $issuer);
}
public function isIssuerIncludedAsParameter(): bool
{
return $this->issuer_included_as_parameter;
}
public function setIssuerIncludedAsParameter(bool $issuer_included_as_parameter): void
{
$this->issuer_included_as_parameter = $issuer_included_as_parameter;
}
public function getDigits(): int
{
return $this->getParameter('digits');
}
private function setDigits(int $digits): void
{
$this->setParameter('digits', $digits);
}
public function getDigest(): string
{
return $this->getParameter('algorithm');
}
private function setDigest(string $digest): void
{
$this->setParameter('algorithm', $digest);
}
public function hasParameter(string $parameter): bool
{
return \array_key_exists($parameter, $this->parameters);
}
public function getParameter(string $parameter)
{
if ($this->hasParameter($parameter)) {
return $this->getParameters()[$parameter];
}
throw new InvalidArgumentException(sprintf('Parameter "%s" does not exist', $parameter));
}
public function setParameter(string $parameter, $value): void
{
$map = $this->getParameterMap();
if (true === \array_key_exists($parameter, $map)) {
$callback = $map[$parameter];
$value = $callback($value);
}
if (property_exists($this, $parameter)) {
$this->$parameter = $value;
} else {
$this->parameters[$parameter] = $value;
}
}
protected function getParameterMap(): array
{
return [
'label' => function ($value) {
Assertion::false($this->hasColon($value), 'Label must not contain a colon.');
return $value;
},
'secret' => function ($value) {
if (null === $value) {
$value = Base32::encodeUpper(random_bytes(64));
}
$value = trim(mb_strtoupper($value), '=');
return $value;
},
'algorithm' => function ($value) {
$value = mb_strtolower($value);
Assertion::inArray($value, hash_algos(), sprintf('The "%s" digest is not supported.', $value));
return $value;
},
'digits' => function ($value) {
Assertion::greaterThan($value, 0, 'Digits must be at least 1.');
return (int) $value;
},
'issuer' => function ($value) {
Assertion::false($this->hasColon($value), 'Issuer must not contain a colon.');
return $value;
},
];
}
private function hasColon(string $value): bool
{
$colons = [':', '%3A', '%3a'];
foreach ($colons as $colon) {
if (false !== mb_strpos($value, $colon)) {
return true;
}
}
return false;
}
}

153
vendor/otphp-10.0/src/TOTP.php vendored Normal file
View File

@ -0,0 +1,153 @@
<?php
declare(strict_types=1);
/*
* The MIT License (MIT)
*
* Copyright (c) 2014-2019 Spomky-Labs
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
namespace OTPHP;
use Assert\Assertion;
use function Safe\ksort;
final class TOTP extends OTP implements TOTPInterface
{
protected function __construct(?string $secret, int $period, string $digest, int $digits, int $epoch = 0)
{
parent::__construct($secret, $digest, $digits);
$this->setPeriod($period);
$this->setEpoch($epoch);
}
public static function create(?string $secret = null, int $period = 30, string $digest = 'sha1', int $digits = 6, int $epoch = 0): TOTPInterface
{
return new self($secret, $period, $digest, $digits, $epoch);
}
protected function setPeriod(int $period): void
{
$this->setParameter('period', $period);
}
public function getPeriod(): int
{
return $this->getParameter('period');
}
private function setEpoch(int $epoch): void
{
$this->setParameter('epoch', $epoch);
}
public function getEpoch(): int
{
return $this->getParameter('epoch');
}
public function at(int $timestamp): string
{
return $this->generateOTP($this->timecode($timestamp));
}
public function now(): string
{
return $this->at(time());
}
/**
* If no timestamp is provided, the OTP is verified at the actual timestamp.
*/
public function verify(string $otp, ?int $timestamp = null, ?int $window = null): bool
{
$timestamp = $this->getTimestamp($timestamp);
if (null === $window) {
return $this->compareOTP($this->at($timestamp), $otp);
}
return $this->verifyOtpWithWindow($otp, $timestamp, $window);
}
private function verifyOtpWithWindow(string $otp, int $timestamp, int $window): bool
{
$window = abs($window);
for ($i = 0; $i <= $window; ++$i) {
$next = $i * $this->getPeriod() + $timestamp;
$previous = -$i * $this->getPeriod() + $timestamp;
$valid = $this->compareOTP($this->at($next), $otp) ||
$this->compareOTP($this->at($previous), $otp);
if ($valid) {
return true;
}
}
return false;
}
private function getTimestamp(?int $timestamp): int
{
$timestamp = $timestamp ?? time();
Assertion::greaterOrEqualThan($timestamp, 0, 'Timestamp must be at least 0.');
return $timestamp;
}
public function getProvisioningUri(): string
{
$params = [];
if (30 !== $this->getPeriod()) {
$params['period'] = $this->getPeriod();
}
if (0 !== $this->getEpoch()) {
$params['epoch'] = $this->getEpoch();
}
return $this->generateURI('totp', $params);
}
private function timecode(int $timestamp): int
{
return (int) floor(($timestamp - $this->getEpoch()) / $this->getPeriod());
}
protected function getParameterMap(): array
{
$v = array_merge(
parent::getParameterMap(),
[
'period' => function ($value) {
Assertion::greaterThan((int) $value, 0, 'Period must be at least 1.');
return (int) $value;
},
'epoch' => function ($value) {
Assertion::greaterOrEqualThan((int) $value, 0, 'Epoch must be greater than or equal to 0.');
return (int) $value;
},
]
);
return $v;
}
protected function filterOptions(array &$options): void
{
parent::filterOptions($options);
if (isset($options['epoch']) && 0 === $options['epoch']) {
unset($options['epoch']);
}
ksort($options);
}
}

36
vendor/otphp-10.0/src/TOTPInterface.php vendored Normal file
View File

@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
/*
* The MIT License (MIT)
*
* Copyright (c) 2014-2019 Spomky-Labs
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
namespace OTPHP;
interface TOTPInterface extends OTPInterface
{
/**
* Create a new TOTP object.
*
* If the secret is null, a random 64 bytes secret will be generated.
*/
public static function create(?string $secret = null, int $period = 30, string $digest = 'sha1', int $digits = 6): self;
/**
* Return the TOTP at the current time.
*/
public function now(): string;
/**
* Get the period of time for OTP generation (a non-null positive integer, in second).
*/
public function getPeriod(): int;
public function getEpoch(): int;
}