From 24b626fb4f95917631c6a4ed155bda97890ecec6 Mon Sep 17 00:00:00 2001 From: Bubka <858858+Bubka@users.noreply.github.com> Date: Sun, 9 Mar 2025 18:22:12 +0100 Subject: [PATCH] Update .proto message description & regenerate classes --- App/Protobuf/GPBMetadata/GoogleAuth.php | Bin 0 -> 1507 bytes App/Protobuf/GoogleAuth/Payload.php | 186 ++++++++++++ .../GoogleAuth/Payload/OtpParameters.php | 270 ++++++++++++++++++ .../Payload/OtpParameters}/Algorithm.php | 6 +- .../Payload/OtpParameters}/DigitCount.php | 6 +- .../Payload/OtpParameters}/OtpType.php | 6 +- .../GoogleAuth/Payload_OtpParameters.php | 16 ++ .../Payload_OtpParameters_Algorithm.php | 16 ++ .../Payload_OtpParameters_DigitCount.php | 16 ++ .../Payload_OtpParameters_OtpType.php | 16 ++ app/Protobuf/GPBMetadata/GoogleAuth.php | Bin 2071 -> 1507 bytes app/Protobuf/GoogleAuth.proto | 47 +-- app/Protobuf/GoogleAuth/Payload.php | 44 ++- .../GoogleAuth/Payload/OtpParameters.php | 77 +++-- .../Payload/OtpParameters/Algorithm.php | 66 +++++ .../Payload/OtpParameters/DigitCount.php | 56 ++++ .../Payload/OtpParameters/OtpType.php | 56 ++++ app/Protobuf/GoogleAuth/Payload_Algorithm.php | 16 -- .../GoogleAuth/Payload_DigitCount.php | 16 -- .../Payload_OtpParameters_Algorithm.php | 16 ++ .../Payload_OtpParameters_DigitCount.php | 16 ++ .../Payload_OtpParameters_OtpType.php | 16 ++ app/Protobuf/GoogleAuth/Payload_OtpType.php | 16 -- app/Protobuf/README.md | 6 + app/Services/Migrators/GoogleAuthMigrator.php | 21 +- composer.json | 2 +- composer.lock | 14 +- 27 files changed, 893 insertions(+), 130 deletions(-) create mode 100644 App/Protobuf/GPBMetadata/GoogleAuth.php create mode 100644 App/Protobuf/GoogleAuth/Payload.php create mode 100644 App/Protobuf/GoogleAuth/Payload/OtpParameters.php rename {app/Protobuf/GoogleAuth/Payload => App/Protobuf/GoogleAuth/Payload/OtpParameters}/Algorithm.php (88%) rename {app/Protobuf/GoogleAuth/Payload => App/Protobuf/GoogleAuth/Payload/OtpParameters}/DigitCount.php (89%) rename {app/Protobuf/GoogleAuth/Payload => App/Protobuf/GoogleAuth/Payload/OtpParameters}/OtpType.php (89%) create mode 100644 App/Protobuf/GoogleAuth/Payload_OtpParameters.php create mode 100644 App/Protobuf/GoogleAuth/Payload_OtpParameters_Algorithm.php create mode 100644 App/Protobuf/GoogleAuth/Payload_OtpParameters_DigitCount.php create mode 100644 App/Protobuf/GoogleAuth/Payload_OtpParameters_OtpType.php create mode 100644 app/Protobuf/GoogleAuth/Payload/OtpParameters/Algorithm.php create mode 100644 app/Protobuf/GoogleAuth/Payload/OtpParameters/DigitCount.php create mode 100644 app/Protobuf/GoogleAuth/Payload/OtpParameters/OtpType.php delete mode 100644 app/Protobuf/GoogleAuth/Payload_Algorithm.php delete mode 100644 app/Protobuf/GoogleAuth/Payload_DigitCount.php create mode 100644 app/Protobuf/GoogleAuth/Payload_OtpParameters_Algorithm.php create mode 100644 app/Protobuf/GoogleAuth/Payload_OtpParameters_DigitCount.php create mode 100644 app/Protobuf/GoogleAuth/Payload_OtpParameters_OtpType.php delete mode 100644 app/Protobuf/GoogleAuth/Payload_OtpType.php diff --git a/App/Protobuf/GPBMetadata/GoogleAuth.php b/App/Protobuf/GPBMetadata/GoogleAuth.php new file mode 100644 index 0000000000000000000000000000000000000000..48120d6ddc306f55101ac204fb71dd66d516ef81 GIT binary patch literal 1507 zcmb7EO;6iE5G5fbWC9_$Al!14|8In{uuEQLCkZxYq~b- z2ZI6ekm=qqY7WuZY zFr&!UYio@Q!m))pJ^?Uo?E48a`~)O^Ea=NCEiLe`=~%Kb=TvHJFrnVKQ_%nckaH6g>tjL2Eh zL$P}N$V9>sU9hDs$eCd}(QYob@&K}oc+|DzRRI>NTgouH!jtPOZmJ@_x=v_sc?|iu zy{E8U|J3e&R`t$>aeaBEwa(OYwbd*wiCGro&{d~?SW1cFr8`*l=(v<#K#vZqrDbUo z*5k7m&7)GLd<~HBV;6RsYFpKfv+nh!ey{oy*hmJi)Gwm^Hf$!rmfG&=6P`IL?app.Protobuf.GoogleAuth.Payload + */ +class Payload extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field repeated .app.Protobuf.GoogleAuth.Payload.OtpParameters otp_parameters = 1; + */ + private $otp_parameters; + /** + * Generated from protobuf field int32 version = 2; + */ + protected $version = 0; + /** + * Generated from protobuf field int32 batch_size = 3; + */ + protected $batch_size = 0; + /** + * Generated from protobuf field optional int32 batch_index = 4; + */ + protected $batch_index = null; + /** + * Generated from protobuf field optional int32 batch_id = 5; + */ + protected $batch_id = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\App\Protobuf\GoogleAuth\Payload\OtpParameters>|\Google\Protobuf\Internal\RepeatedField $otp_parameters + * @type int $version + * @type int $batch_size + * @type int $batch_index + * @type int $batch_id + * } + */ + public function __construct($data = NULL) { + \App\Protobuf\GPBMetadata\GoogleAuth::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field repeated .app.Protobuf.GoogleAuth.Payload.OtpParameters otp_parameters = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getOtpParameters() + { + return $this->otp_parameters; + } + + /** + * Generated from protobuf field repeated .app.Protobuf.GoogleAuth.Payload.OtpParameters otp_parameters = 1; + * @param array<\App\Protobuf\GoogleAuth\Payload\OtpParameters>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setOtpParameters($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \App\Protobuf\GoogleAuth\Payload\OtpParameters::class); + $this->otp_parameters = $arr; + + return $this; + } + + /** + * Generated from protobuf field int32 version = 2; + * @return int + */ + public function getVersion() + { + return $this->version; + } + + /** + * Generated from protobuf field int32 version = 2; + * @param int $var + * @return $this + */ + public function setVersion($var) + { + GPBUtil::checkInt32($var); + $this->version = $var; + + return $this; + } + + /** + * Generated from protobuf field int32 batch_size = 3; + * @return int + */ + public function getBatchSize() + { + return $this->batch_size; + } + + /** + * Generated from protobuf field int32 batch_size = 3; + * @param int $var + * @return $this + */ + public function setBatchSize($var) + { + GPBUtil::checkInt32($var); + $this->batch_size = $var; + + return $this; + } + + /** + * Generated from protobuf field optional int32 batch_index = 4; + * @return int + */ + public function getBatchIndex() + { + return isset($this->batch_index) ? $this->batch_index : 0; + } + + public function hasBatchIndex() + { + return isset($this->batch_index); + } + + public function clearBatchIndex() + { + unset($this->batch_index); + } + + /** + * Generated from protobuf field optional int32 batch_index = 4; + * @param int $var + * @return $this + */ + public function setBatchIndex($var) + { + GPBUtil::checkInt32($var); + $this->batch_index = $var; + + return $this; + } + + /** + * Generated from protobuf field optional int32 batch_id = 5; + * @return int + */ + public function getBatchId() + { + return isset($this->batch_id) ? $this->batch_id : 0; + } + + public function hasBatchId() + { + return isset($this->batch_id); + } + + public function clearBatchId() + { + unset($this->batch_id); + } + + /** + * Generated from protobuf field optional int32 batch_id = 5; + * @param int $var + * @return $this + */ + public function setBatchId($var) + { + GPBUtil::checkInt32($var); + $this->batch_id = $var; + + return $this; + } + +} + diff --git a/App/Protobuf/GoogleAuth/Payload/OtpParameters.php b/App/Protobuf/GoogleAuth/Payload/OtpParameters.php new file mode 100644 index 00000000..c111c123 --- /dev/null +++ b/App/Protobuf/GoogleAuth/Payload/OtpParameters.php @@ -0,0 +1,270 @@ +app.Protobuf.GoogleAuth.Payload.OtpParameters + */ +class OtpParameters extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field bytes secret = 1; + */ + protected $secret = ''; + /** + * Generated from protobuf field string name = 2; + */ + protected $name = ''; + /** + * Generated from protobuf field string issuer = 3; + */ + protected $issuer = ''; + /** + * Generated from protobuf field .app.Protobuf.GoogleAuth.Payload.OtpParameters.Algorithm algorithm = 4; + */ + protected $algorithm = 0; + /** + * Generated from protobuf field .app.Protobuf.GoogleAuth.Payload.OtpParameters.DigitCount digits = 5; + */ + protected $digits = 0; + /** + * Generated from protobuf field .app.Protobuf.GoogleAuth.Payload.OtpParameters.OtpType type = 6; + */ + protected $type = 0; + /** + * Generated from protobuf field optional int32 counter = 7; + */ + protected $counter = null; + /** + * Generated from protobuf field optional .google.protobuf.Any period = 8; + */ + protected $period = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $secret + * @type string $name + * @type string $issuer + * @type int $algorithm + * @type int $digits + * @type int $type + * @type int $counter + * @type \Google\Protobuf\Any $period + * } + */ + public function __construct($data = NULL) { + \App\Protobuf\GPBMetadata\GoogleAuth::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field bytes secret = 1; + * @return string + */ + public function getSecret() + { + return $this->secret; + } + + /** + * Generated from protobuf field bytes secret = 1; + * @param string $var + * @return $this + */ + public function setSecret($var) + { + GPBUtil::checkString($var, False); + $this->secret = $var; + + return $this; + } + + /** + * Generated from protobuf field string name = 2; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Generated from protobuf field string name = 2; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Generated from protobuf field string issuer = 3; + * @return string + */ + public function getIssuer() + { + return $this->issuer; + } + + /** + * Generated from protobuf field string issuer = 3; + * @param string $var + * @return $this + */ + public function setIssuer($var) + { + GPBUtil::checkString($var, True); + $this->issuer = $var; + + return $this; + } + + /** + * Generated from protobuf field .app.Protobuf.GoogleAuth.Payload.OtpParameters.Algorithm algorithm = 4; + * @return int + */ + public function getAlgorithm() + { + return $this->algorithm; + } + + /** + * Generated from protobuf field .app.Protobuf.GoogleAuth.Payload.OtpParameters.Algorithm algorithm = 4; + * @param int $var + * @return $this + */ + public function setAlgorithm($var) + { + GPBUtil::checkEnum($var, \App\Protobuf\GoogleAuth\Payload\OtpParameters\Algorithm::class); + $this->algorithm = $var; + + return $this; + } + + /** + * Generated from protobuf field .app.Protobuf.GoogleAuth.Payload.OtpParameters.DigitCount digits = 5; + * @return int + */ + public function getDigits() + { + return $this->digits; + } + + /** + * Generated from protobuf field .app.Protobuf.GoogleAuth.Payload.OtpParameters.DigitCount digits = 5; + * @param int $var + * @return $this + */ + public function setDigits($var) + { + GPBUtil::checkEnum($var, \App\Protobuf\GoogleAuth\Payload\OtpParameters\DigitCount::class); + $this->digits = $var; + + return $this; + } + + /** + * Generated from protobuf field .app.Protobuf.GoogleAuth.Payload.OtpParameters.OtpType type = 6; + * @return int + */ + public function getType() + { + return $this->type; + } + + /** + * Generated from protobuf field .app.Protobuf.GoogleAuth.Payload.OtpParameters.OtpType type = 6; + * @param int $var + * @return $this + */ + public function setType($var) + { + GPBUtil::checkEnum($var, \App\Protobuf\GoogleAuth\Payload\OtpParameters\OtpType::class); + $this->type = $var; + + return $this; + } + + /** + * Generated from protobuf field optional int32 counter = 7; + * @return int + */ + public function getCounter() + { + return isset($this->counter) ? $this->counter : 0; + } + + public function hasCounter() + { + return isset($this->counter); + } + + public function clearCounter() + { + unset($this->counter); + } + + /** + * Generated from protobuf field optional int32 counter = 7; + * @param int $var + * @return $this + */ + public function setCounter($var) + { + GPBUtil::checkInt32($var); + $this->counter = $var; + + return $this; + } + + /** + * Generated from protobuf field optional .google.protobuf.Any period = 8; + * @return \Google\Protobuf\Any|null + */ + public function getPeriod() + { + return $this->period; + } + + public function hasPeriod() + { + return isset($this->period); + } + + public function clearPeriod() + { + unset($this->period); + } + + /** + * Generated from protobuf field optional .google.protobuf.Any period = 8; + * @param \Google\Protobuf\Any $var + * @return $this + */ + public function setPeriod($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Any::class); + $this->period = $var; + + return $this; + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(OtpParameters::class, \App\Protobuf\GoogleAuth\Payload_OtpParameters::class); + diff --git a/app/Protobuf/GoogleAuth/Payload/Algorithm.php b/App/Protobuf/GoogleAuth/Payload/OtpParameters/Algorithm.php similarity index 88% rename from app/Protobuf/GoogleAuth/Payload/Algorithm.php rename to App/Protobuf/GoogleAuth/Payload/OtpParameters/Algorithm.php index 29f42e02..57ae9e93 100644 --- a/app/Protobuf/GoogleAuth/Payload/Algorithm.php +++ b/App/Protobuf/GoogleAuth/Payload/OtpParameters/Algorithm.php @@ -2,12 +2,12 @@ # Generated by the protocol buffer compiler. DO NOT EDIT! # source: GoogleAuth.proto -namespace App\Protobuf\GoogleAuth\Payload; +namespace App\Protobuf\GoogleAuth\Payload\OtpParameters; use UnexpectedValueException; /** - * Protobuf type app.Protobuf.GoogleAuth.Payload.Algorithm + * Protobuf type app.Protobuf.GoogleAuth.Payload.OtpParameters.Algorithm */ class Algorithm { @@ -62,5 +62,5 @@ public static function value($name) } // Adding a class alias for backwards compatibility with the previous class name. -class_alias(Algorithm::class, \App\Protobuf\GoogleAuth\Payload_Algorithm::class); +class_alias(Algorithm::class, \App\Protobuf\GoogleAuth\Payload_OtpParameters_Algorithm::class); diff --git a/app/Protobuf/GoogleAuth/Payload/DigitCount.php b/App/Protobuf/GoogleAuth/Payload/OtpParameters/DigitCount.php similarity index 89% rename from app/Protobuf/GoogleAuth/Payload/DigitCount.php rename to App/Protobuf/GoogleAuth/Payload/OtpParameters/DigitCount.php index 7545fa66..8b8719a8 100644 --- a/app/Protobuf/GoogleAuth/Payload/DigitCount.php +++ b/App/Protobuf/GoogleAuth/Payload/OtpParameters/DigitCount.php @@ -2,12 +2,12 @@ # Generated by the protocol buffer compiler. DO NOT EDIT! # source: GoogleAuth.proto -namespace App\Protobuf\GoogleAuth\Payload; +namespace App\Protobuf\GoogleAuth\Payload\OtpParameters; use UnexpectedValueException; /** - * Protobuf type app.Protobuf.GoogleAuth.Payload.DigitCount + * Protobuf type app.Protobuf.GoogleAuth.Payload.OtpParameters.DigitCount */ class DigitCount { @@ -52,5 +52,5 @@ public static function value($name) } // Adding a class alias for backwards compatibility with the previous class name. -class_alias(DigitCount::class, \App\Protobuf\GoogleAuth\Payload_DigitCount::class); +class_alias(DigitCount::class, \App\Protobuf\GoogleAuth\Payload_OtpParameters_DigitCount::class); diff --git a/app/Protobuf/GoogleAuth/Payload/OtpType.php b/App/Protobuf/GoogleAuth/Payload/OtpParameters/OtpType.php similarity index 89% rename from app/Protobuf/GoogleAuth/Payload/OtpType.php rename to App/Protobuf/GoogleAuth/Payload/OtpParameters/OtpType.php index e434df9b..04a75199 100644 --- a/app/Protobuf/GoogleAuth/Payload/OtpType.php +++ b/App/Protobuf/GoogleAuth/Payload/OtpParameters/OtpType.php @@ -2,12 +2,12 @@ # Generated by the protocol buffer compiler. DO NOT EDIT! # source: GoogleAuth.proto -namespace App\Protobuf\GoogleAuth\Payload; +namespace App\Protobuf\GoogleAuth\Payload\OtpParameters; use UnexpectedValueException; /** - * Protobuf type app.Protobuf.GoogleAuth.Payload.OtpType + * Protobuf type app.Protobuf.GoogleAuth.Payload.OtpParameters.OtpType */ class OtpType { @@ -52,5 +52,5 @@ public static function value($name) } // Adding a class alias for backwards compatibility with the previous class name. -class_alias(OtpType::class, \App\Protobuf\GoogleAuth\Payload_OtpType::class); +class_alias(OtpType::class, \App\Protobuf\GoogleAuth\Payload_OtpParameters_OtpType::class); diff --git a/App/Protobuf/GoogleAuth/Payload_OtpParameters.php b/App/Protobuf/GoogleAuth/Payload_OtpParameters.php new file mode 100644 index 00000000..f5fa1720 --- /dev/null +++ b/App/Protobuf/GoogleAuth/Payload_OtpParameters.php @@ -0,0 +1,16 @@ +4|8In{uuEQLCkZxYq~b- z2ZI6ekm=qqY7WuZY zFr&!UYio@Q!m))pJ^?Uo?E48a`~)O^Ea=NCEiLe`=~%Kb=TvHJFrnVKQ_%nckaH6g>tjL2Eh zL$P}N$V9>sU9hDs$eCd}(QYob@&K}oc+|DzRRI>NTgouH!jtPOZmJ@_x=v_sc?|iu zy{E8U|J3e&R`t$>aeaBEwa(OYwbd*wiCGro&{d~?SW1cFr8`*l=(v<#K#vZqrDbUo z*5k7m&7)GLd<~HBV;6RsYFpKfv+nh!ey{oy*hmJi)Gwm^Hf$!rmfG&=6P`IL?L=DjyFyZhl&bK4|u*;%MU>$^~}#V^*~2G+E7SLgMTE!HuHmgV(bQ!Yb$$k^!x z`+jl7zMP(4y+P=zUblIev$MLsS%#B!cYD|eCrRb+!m9CkU?)v;eMuRS?fUHU^S99X z!gu~CN%Ey%t+s-bKMBK6vtBIAoUJ}#`cYP8SNdi78zPTc^vhL1_+xBbS9w>~ z6{CQQDi5;*HsmDiepAELF}oh*KBzjcy3kgBd3_pId0RGJ-ChDZpWlRTst&!G9gMV; zu8eFpXq?XjB@-FeI*)qftp1>PyUR&Z!+K>ehm z`P5*{Fq_n2JJyp}u`6C_7B~6F`NLd|3dT;jkyULvMQW%Em{00*x>=XfWz;FXqlyA6 z0y|pgFcgi{nbA7cg^9-KV3gt7Xr(i4@rxzFX>`Dd9lA40AzCN_oB&SuXUDGW15PTV zEU?JA_~zaOKFeiEuf1#`Ck@X%ELI zBT*}pj_$!P#8XIAlekk9AO0mOkG$wXf9g%WM;|>>L@2~ri0_O#@`A#lI*($|nf~3V o?gint32 batch_index = 4; + * Generated from protobuf field optional int32 batch_index = 4; */ - protected $batch_index = 0; + protected $batch_index = null; /** - * Generated from protobuf field int32 batch_id = 5; + * Generated from protobuf field optional int32 batch_id = 5; */ - protected $batch_id = 0; + protected $batch_id = null; /** * Constructor. @@ -40,7 +40,7 @@ class Payload extends \Google\Protobuf\Internal\Message * @param array $data { * Optional. Data for populating the Message object. * - * @type \App\Protobuf\GoogleAuth\Payload\OtpParameters[]|\Google\Protobuf\Internal\RepeatedField $otp_parameters + * @type array<\App\Protobuf\GoogleAuth\Payload\OtpParameters>|\Google\Protobuf\Internal\RepeatedField $otp_parameters * @type int $version * @type int $batch_size * @type int $batch_index @@ -63,7 +63,7 @@ public function getOtpParameters() /** * Generated from protobuf field repeated .app.Protobuf.GoogleAuth.Payload.OtpParameters otp_parameters = 1; - * @param \App\Protobuf\GoogleAuth\Payload\OtpParameters[]|\Google\Protobuf\Internal\RepeatedField $var + * @param array<\App\Protobuf\GoogleAuth\Payload\OtpParameters>|\Google\Protobuf\Internal\RepeatedField $var * @return $this */ public function setOtpParameters($var) @@ -119,16 +119,26 @@ public function setBatchSize($var) } /** - * Generated from protobuf field int32 batch_index = 4; + * Generated from protobuf field optional int32 batch_index = 4; * @return int */ public function getBatchIndex() { - return $this->batch_index; + return isset($this->batch_index) ? $this->batch_index : 0; + } + + public function hasBatchIndex() + { + return isset($this->batch_index); + } + + public function clearBatchIndex() + { + unset($this->batch_index); } /** - * Generated from protobuf field int32 batch_index = 4; + * Generated from protobuf field optional int32 batch_index = 4; * @param int $var * @return $this */ @@ -141,16 +151,26 @@ public function setBatchIndex($var) } /** - * Generated from protobuf field int32 batch_id = 5; + * Generated from protobuf field optional int32 batch_id = 5; * @return int */ public function getBatchId() { - return $this->batch_id; + return isset($this->batch_id) ? $this->batch_id : 0; + } + + public function hasBatchId() + { + return isset($this->batch_id); + } + + public function clearBatchId() + { + unset($this->batch_id); } /** - * Generated from protobuf field int32 batch_id = 5; + * Generated from protobuf field optional int32 batch_id = 5; * @param int $var * @return $this */ diff --git a/app/Protobuf/GoogleAuth/Payload/OtpParameters.php b/app/Protobuf/GoogleAuth/Payload/OtpParameters.php index a63c075d..c111c123 100644 --- a/app/Protobuf/GoogleAuth/Payload/OtpParameters.php +++ b/app/Protobuf/GoogleAuth/Payload/OtpParameters.php @@ -26,25 +26,25 @@ class OtpParameters extends \Google\Protobuf\Internal\Message */ protected $issuer = ''; /** - * Generated from protobuf field .app.Protobuf.GoogleAuth.Payload.Algorithm algorithm = 4; + * Generated from protobuf field .app.Protobuf.GoogleAuth.Payload.OtpParameters.Algorithm algorithm = 4; */ protected $algorithm = 0; /** - * Generated from protobuf field .app.Protobuf.GoogleAuth.Payload.DigitCount digits = 5; + * Generated from protobuf field .app.Protobuf.GoogleAuth.Payload.OtpParameters.DigitCount digits = 5; */ protected $digits = 0; /** - * Generated from protobuf field .app.Protobuf.GoogleAuth.Payload.OtpType type = 6; + * Generated from protobuf field .app.Protobuf.GoogleAuth.Payload.OtpParameters.OtpType type = 6; */ protected $type = 0; /** - * Generated from protobuf field int64 counter = 7; + * Generated from protobuf field optional int32 counter = 7; */ - protected $counter = 0; + protected $counter = null; /** - * Generated from protobuf field int64 period = 8; + * Generated from protobuf field optional .google.protobuf.Any period = 8; */ - protected $period = 0; + protected $period = null; /** * Constructor. @@ -58,7 +58,8 @@ class OtpParameters extends \Google\Protobuf\Internal\Message * @type int $algorithm * @type int $digits * @type int $type - * @type int|string $counter + * @type int $counter + * @type \Google\Protobuf\Any $period * } */ public function __construct($data = NULL) { @@ -133,7 +134,7 @@ public function setIssuer($var) } /** - * Generated from protobuf field .app.Protobuf.GoogleAuth.Payload.Algorithm algorithm = 4; + * Generated from protobuf field .app.Protobuf.GoogleAuth.Payload.OtpParameters.Algorithm algorithm = 4; * @return int */ public function getAlgorithm() @@ -142,20 +143,20 @@ public function getAlgorithm() } /** - * Generated from protobuf field .app.Protobuf.GoogleAuth.Payload.Algorithm algorithm = 4; + * Generated from protobuf field .app.Protobuf.GoogleAuth.Payload.OtpParameters.Algorithm algorithm = 4; * @param int $var * @return $this */ public function setAlgorithm($var) { - GPBUtil::checkEnum($var, \App\Protobuf\GoogleAuth\Payload_Algorithm::class); + GPBUtil::checkEnum($var, \App\Protobuf\GoogleAuth\Payload\OtpParameters\Algorithm::class); $this->algorithm = $var; return $this; } /** - * Generated from protobuf field .app.Protobuf.GoogleAuth.Payload.DigitCount digits = 5; + * Generated from protobuf field .app.Protobuf.GoogleAuth.Payload.OtpParameters.DigitCount digits = 5; * @return int */ public function getDigits() @@ -164,20 +165,20 @@ public function getDigits() } /** - * Generated from protobuf field .app.Protobuf.GoogleAuth.Payload.DigitCount digits = 5; + * Generated from protobuf field .app.Protobuf.GoogleAuth.Payload.OtpParameters.DigitCount digits = 5; * @param int $var * @return $this */ public function setDigits($var) { - GPBUtil::checkEnum($var, \App\Protobuf\GoogleAuth\Payload_DigitCount::class); + GPBUtil::checkEnum($var, \App\Protobuf\GoogleAuth\Payload\OtpParameters\DigitCount::class); $this->digits = $var; return $this; } /** - * Generated from protobuf field .app.Protobuf.GoogleAuth.Payload.OtpType type = 6; + * Generated from protobuf field .app.Protobuf.GoogleAuth.Payload.OtpParameters.OtpType type = 6; * @return int */ public function getType() @@ -186,57 +187,77 @@ public function getType() } /** - * Generated from protobuf field .app.Protobuf.GoogleAuth.Payload.OtpType type = 6; + * Generated from protobuf field .app.Protobuf.GoogleAuth.Payload.OtpParameters.OtpType type = 6; * @param int $var * @return $this */ public function setType($var) { - GPBUtil::checkEnum($var, \App\Protobuf\GoogleAuth\Payload_OtpType::class); + GPBUtil::checkEnum($var, \App\Protobuf\GoogleAuth\Payload\OtpParameters\OtpType::class); $this->type = $var; return $this; } /** - * Generated from protobuf field int64 counter = 7; - * @return int|string + * Generated from protobuf field optional int32 counter = 7; + * @return int */ public function getCounter() { - return $this->counter; + return isset($this->counter) ? $this->counter : 0; + } + + public function hasCounter() + { + return isset($this->counter); + } + + public function clearCounter() + { + unset($this->counter); } /** - * Generated from protobuf field int64 counter = 7; - * @param int|string $var + * Generated from protobuf field optional int32 counter = 7; + * @param int $var * @return $this */ public function setCounter($var) { - GPBUtil::checkInt64($var); + GPBUtil::checkInt32($var); $this->counter = $var; return $this; } /** - * Generated from protobuf field int64 period = 8; - * @return int|string + * Generated from protobuf field optional .google.protobuf.Any period = 8; + * @return \Google\Protobuf\Any|null */ public function getPeriod() { return $this->period; } + public function hasPeriod() + { + return isset($this->period); + } + + public function clearPeriod() + { + unset($this->period); + } + /** - * Generated from protobuf field int64 period = 8; - * @param int|string $var + * Generated from protobuf field optional .google.protobuf.Any period = 8; + * @param \Google\Protobuf\Any $var * @return $this */ public function setPeriod($var) { - GPBUtil::checkInt64($var); + GPBUtil::checkMessage($var, \Google\Protobuf\Any::class); $this->period = $var; return $this; diff --git a/app/Protobuf/GoogleAuth/Payload/OtpParameters/Algorithm.php b/app/Protobuf/GoogleAuth/Payload/OtpParameters/Algorithm.php new file mode 100644 index 00000000..57ae9e93 --- /dev/null +++ b/app/Protobuf/GoogleAuth/Payload/OtpParameters/Algorithm.php @@ -0,0 +1,66 @@ +app.Protobuf.GoogleAuth.Payload.OtpParameters.Algorithm + */ +class Algorithm +{ + /** + * Generated from protobuf enum ALGORITHM_UNSPECIFIED = 0; + */ + const ALGORITHM_UNSPECIFIED = 0; + /** + * Generated from protobuf enum ALGORITHM_SHA1 = 1; + */ + const ALGORITHM_SHA1 = 1; + /** + * Generated from protobuf enum ALGORITHM_SHA256 = 2; + */ + const ALGORITHM_SHA256 = 2; + /** + * Generated from protobuf enum ALGORITHM_SHA512 = 3; + */ + const ALGORITHM_SHA512 = 3; + /** + * Generated from protobuf enum ALGORITHM_MD5 = 4; + */ + const ALGORITHM_MD5 = 4; + + private static $valueToName = [ + self::ALGORITHM_UNSPECIFIED => 'ALGORITHM_UNSPECIFIED', + self::ALGORITHM_SHA1 => 'ALGORITHM_SHA1', + self::ALGORITHM_SHA256 => 'ALGORITHM_SHA256', + self::ALGORITHM_SHA512 => 'ALGORITHM_SHA512', + self::ALGORITHM_MD5 => 'ALGORITHM_MD5', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(Algorithm::class, \App\Protobuf\GoogleAuth\Payload_OtpParameters_Algorithm::class); + diff --git a/app/Protobuf/GoogleAuth/Payload/OtpParameters/DigitCount.php b/app/Protobuf/GoogleAuth/Payload/OtpParameters/DigitCount.php new file mode 100644 index 00000000..8b8719a8 --- /dev/null +++ b/app/Protobuf/GoogleAuth/Payload/OtpParameters/DigitCount.php @@ -0,0 +1,56 @@ +app.Protobuf.GoogleAuth.Payload.OtpParameters.DigitCount + */ +class DigitCount +{ + /** + * Generated from protobuf enum DIGIT_COUNT_UNSPECIFIED = 0; + */ + const DIGIT_COUNT_UNSPECIFIED = 0; + /** + * Generated from protobuf enum DIGIT_COUNT_SIX = 1; + */ + const DIGIT_COUNT_SIX = 1; + /** + * Generated from protobuf enum DIGIT_COUNT_EIGHT = 2; + */ + const DIGIT_COUNT_EIGHT = 2; + + private static $valueToName = [ + self::DIGIT_COUNT_UNSPECIFIED => 'DIGIT_COUNT_UNSPECIFIED', + self::DIGIT_COUNT_SIX => 'DIGIT_COUNT_SIX', + self::DIGIT_COUNT_EIGHT => 'DIGIT_COUNT_EIGHT', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(DigitCount::class, \App\Protobuf\GoogleAuth\Payload_OtpParameters_DigitCount::class); + diff --git a/app/Protobuf/GoogleAuth/Payload/OtpParameters/OtpType.php b/app/Protobuf/GoogleAuth/Payload/OtpParameters/OtpType.php new file mode 100644 index 00000000..04a75199 --- /dev/null +++ b/app/Protobuf/GoogleAuth/Payload/OtpParameters/OtpType.php @@ -0,0 +1,56 @@ +app.Protobuf.GoogleAuth.Payload.OtpParameters.OtpType + */ +class OtpType +{ + /** + * Generated from protobuf enum OTP_TYPE_UNSPECIFIED = 0; + */ + const OTP_TYPE_UNSPECIFIED = 0; + /** + * Generated from protobuf enum OTP_TYPE_HOTP = 1; + */ + const OTP_TYPE_HOTP = 1; + /** + * Generated from protobuf enum OTP_TYPE_TOTP = 2; + */ + const OTP_TYPE_TOTP = 2; + + private static $valueToName = [ + self::OTP_TYPE_UNSPECIFIED => 'OTP_TYPE_UNSPECIFIED', + self::OTP_TYPE_HOTP => 'OTP_TYPE_HOTP', + self::OTP_TYPE_TOTP => 'OTP_TYPE_TOTP', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(OtpType::class, \App\Protobuf\GoogleAuth\Payload_OtpParameters_OtpType::class); + diff --git a/app/Protobuf/GoogleAuth/Payload_Algorithm.php b/app/Protobuf/GoogleAuth/Payload_Algorithm.php deleted file mode 100644 index b8c18bce..00000000 --- a/app/Protobuf/GoogleAuth/Payload_Algorithm.php +++ /dev/null @@ -1,16 +0,0 @@ -Reference: [protocol-buffers/docs/php-generated](https://developers.google.com/protocol-buffers/docs/reference/php-generated#invocation) + +command to decode an otpauth uri using protoc cli + +```bash +echo "otpauth-migration://offline?data=[BASE32_ENCODED_DATA]" | sed 's/QR-Code://' | sed 's/otpauth-migration:\/\/offline?data=//' | sed -e 's/%2B/+/ig' -e 's/%2F/\//ig' -e 's/%3D/=/ig' | base64 -d | protoc --decode_raw +``` diff --git a/app/Services/Migrators/GoogleAuthMigrator.php b/app/Services/Migrators/GoogleAuthMigrator.php index d97e24e4..c7cba64f 100644 --- a/app/Services/Migrators/GoogleAuthMigrator.php +++ b/app/Services/Migrators/GoogleAuthMigrator.php @@ -6,9 +6,9 @@ use App\Models\TwoFAccount; use App\Protobuf\GAuthValueMapping; use App\Protobuf\GoogleAuth\Payload; -use App\Protobuf\GoogleAuth\Payload\Algorithm; -use App\Protobuf\GoogleAuth\Payload\DigitCount; -use App\Protobuf\GoogleAuth\Payload\OtpType; +use App\Protobuf\GoogleAuth\Payload\OtpParameters\Algorithm; +use App\Protobuf\GoogleAuth\Payload\OtpParameters\DigitCount; +use App\Protobuf\GoogleAuth\Payload\OtpParameters\OtpType; use Exception; use Illuminate\Support\Collection; use Illuminate\Support\Facades\Log; @@ -29,6 +29,21 @@ public function migrate(mixed $migrationPayload) : Collection try { $migrationData = base64_decode(urldecode(Str::replace('otpauth-migration://offline?data=', '', strval($migrationPayload)))); $protobuf = new Payload; + + // $input = new CodedInputStream($migrationData); + // while (true) { + // $tag = $input->readTag(); + // // End of input. This is a valid place to end, so return true. + // if ($tag === 0) { + // return true; + // } + + // $number = GPBWire::getTagFieldNumber($tag); + // $field = $protobuf->desc->getFieldByNumber($number); + + // $protobuf->parseFieldFromStream($tag, $input, $field); + // } + $protobuf->mergeFromString($migrationData); $otpParameters = $protobuf->getOtpParameters(); } catch (Exception $ex) { diff --git a/composer.json b/composer.json index 7d238369..2253532d 100644 --- a/composer.json +++ b/composer.json @@ -125,4 +125,4 @@ "php artisan ide-helper:models" ] } -} +} \ No newline at end of file diff --git a/composer.lock b/composer.lock index 85ae629b..8771968b 100644 --- a/composer.lock +++ b/composer.lock @@ -955,16 +955,16 @@ }, { "name": "google/protobuf", - "version": "v4.28.3", + "version": "v4.30.0", "source": { "type": "git", "url": "https://github.com/protocolbuffers/protobuf-php.git", - "reference": "c5c311e0f3d89928251ac5a2f0e3db283612c100" + "reference": "e1d66682f6836aa87820400f0aa07d9eb566feb6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/protocolbuffers/protobuf-php/zipball/c5c311e0f3d89928251ac5a2f0e3db283612c100", - "reference": "c5c311e0f3d89928251ac5a2f0e3db283612c100", + "url": "https://api.github.com/repos/protocolbuffers/protobuf-php/zipball/e1d66682f6836aa87820400f0aa07d9eb566feb6", + "reference": "e1d66682f6836aa87820400f0aa07d9eb566feb6", "shasum": "" }, "require": { @@ -993,9 +993,9 @@ "proto" ], "support": { - "source": "https://github.com/protocolbuffers/protobuf-php/tree/v4.28.3" + "source": "https://github.com/protocolbuffers/protobuf-php/tree/v4.30.0" }, - "time": "2024-10-22T22:27:17+00:00" + "time": "2025-03-04T22:54:49+00:00" }, { "name": "graham-campbell/result-type", @@ -10962,5 +10962,5 @@ "ext-xml": "*" }, "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" }