Git Product home page Git Product logo

Comments (6)

Spomky avatar Spomky commented on July 23, 2024

Hi @lukos,

You are right: the label is only needed when the provisioning URI is computed.
Depending on the schemen (TOTP/HOTP), you just need the secret, the digest, the digits and additional parameters required by the scheme (counter, interval).

I will not add a static method, from my POV it should be easier to modify the setLabel method by allowing a null label and verify that label in the generateURI one.

WDYT?

from otphp.

Spomky avatar Spomky commented on July 23, 2024

Tagged v8.3.0

from otphp.

lukos avatar lukos commented on July 23, 2024

That is OK but it isn't much better than just passing an empty string to the constructor. The ideal (of course!) is that the constructor should not require the label since it is not conceptually required for a "TOTP" object to be complete but that is obviously not a quick easy fix.

You could also change it so the constructor takes an array of options so you can fill in whatever you want but that is also a breaking change. Thanks anyway.

from otphp.

Spomky avatar Spomky commented on July 23, 2024

I agree with you but if I change the constructor it will creates a BC break.
So for the moment and to fix it quickly I found that solution.

In the next major release, I think the constructor will be private and object will be created through static methods only.

from otphp.

Spomky avatar Spomky commented on July 23, 2024

I have just created a new branch that implements the static methods I mentioned above.

Example:

<?php

use OTPHP\TOTP;

$totp = TOTP::createTOTP(); //Creates a TOTP object with a random secret and digest='sha1', period=30 and digits=6
$totp = TOTP::createTOTP('JDDK4U6G3BJLEZ7Y', 20, 'sha512', 8); // Creates a TOTP object with selected parameters

WDYT?

from otphp.

lukos avatar lukos commented on July 23, 2024

mmmmmmm Factory methods. Nice

from otphp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.