protected function generateToken(string $lockTo): array
    {
        $index = Base64UrlSafe::encode(\random_bytes(18));
        $token = Base64UrlSafe::encode(\random_bytes(33));

        $new = $this->buildBasicToken([
            'created' => \intval(
                \date('YmdHis')
            ),
            'uri' => isset($this->server['REQUEST_URI'])
                ? $this->server['REQUEST_URI']
                : $this->server['SCRIPT_NAME'],
            'token' => $token
        ]);

        if (\preg_match('#/$#', $lockTo)) {
            $lockTo = Binary::safeSubstr(
                $lockTo,
                0,
                Binary::safeStrlen($lockTo) - 1
            );
        }

        if ($this->useNativeSession) {
            /** @var array<string, array<string, string|int>> $sess */
            $sess =& $_SESSION[$this->sessionIndex];
        } else {
            /** @var array<string, array<string, string|int>> $sess */
            $sess =& $this->session[$this->sessionIndex];
        }
        $sess[$index] = $new;
        $sess[$index]['lockTo'] = $lockTo;

        $this->recycleTokens();
        return [$index, $token];
    }
protected function generateToken(string $lockTo): array
    {
        $index = Base64UrlSafe::encode(\random_bytes(18));
        $token = Base64UrlSafe::encode(\random_bytes(33));

        $new = $this->buildBasicToken([
            'created' => \intval(
                \date('YmdHis')
            ),
            'uri' => isset($this->server['REQUEST_URI'])
                ? $this->server['REQUEST_URI']
                : $this->server['SCRIPT_NAME'],
            'token' => $token
        ]);

        if (\preg_match('#/$#', $lockTo)) {
            $lockTo = Binary::safeSubstr(
                $lockTo,
                0,
                Binary::safeStrlen($lockTo) - 1
            );
        }

        if ($this->useNativeSession) {
            /** @var array<string, array<string, string|int>> $sess */
            $sess =& $_SESSION[$this->sessionIndex];
        } else {
            /** @var array<string, array<string, string|int>> $sess */
            $sess =& $this->session[$this->sessionIndex];
        }
        $sess[$index] = $new;
        $sess[$index]['lockTo'] = $lockTo;

        $this->recycleTokens();
        return [$index, $token];
    }
protected function generateToken ( string $ lockTo ) : array { $ index = Base64UrlSafe :: encode ( \ random_bytes ( 18 ) ) ; $ token = Base64UrlSafe :: encode ( \ random_bytes ( 33 ) ) ; $ new = $ this -> buildBasicToken ( [ 'created' => \ intval ( \ date ( 'YmdHis' ) ) , 'uri' => isset ( $ this -> server [ 'REQUEST_URI' ] ) ? $ this -> server [ 'REQUEST_URI' ] : $ this -> server [ 'SCRIPT_NAME' ] , 'token' => $ token ] ) ; if ( \ preg_match ( '#/$#' , $ lockTo ) ) { $ lockTo = Binary :: safeSubstr ( $ lockTo , 0 , Binary :: safeStrlen ( $ lockTo ) - 1 ) ; } if ( $ this -> useNativeSession ) { /** @var array<string, array<string, string|int>> $sess */ $ sess = & $ _SESSION [ $ this -> sessionIndex ] ; } else { /** @var array<string, array<string, string|int>> $sess */ $ sess = & $ this -> session [ $ this -> sessionIndex ] ; } $ sess [ $ index ] = $ new ; $ sess [ $ index ] [ 'lockTo' ] = $ lockTo ; $ this -> recycleTokens ( ) ; return [ $ index , $ token ] ; }
Generate, store, and return the index and token

@param string $lockTo What URI endpoint this is valid for
@return string[]
@throws \TypeError
@throws \Exception
Generate store and return the index and token