Skip to content

Commit 2635d2a

Browse files
authored
Signature: Improved naming consistency (#1863)
1 parent 8c86695 commit 2635d2a

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

includes/class-signature.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace Activitypub;
99

1010
use Activitypub\Collection\Actors;
11-
use Activitypub\Signature\Draft_Cavage_Signature;
11+
use Activitypub\Signature\Http_Signature_Draft;
1212
use Activitypub\Signature\Http_Message_Signature;
1313

1414
/**
@@ -47,7 +47,7 @@ public static function sign_request( $args, $url ) {
4747
$signature = new Http_Message_Signature();
4848
\add_filter( 'http_response', array( self::class, 'maybe_double_knock' ), 10, 3 );
4949
} else {
50-
$signature = new Draft_Cavage_Signature();
50+
$signature = new Http_Signature_Draft();
5151
}
5252

5353
return $signature->sign( $args, $url );
@@ -70,7 +70,7 @@ public static function verify_http_signature( $request ) {
7070
$headers['(request-target)'][0] = strtolower( $headers['request_method'][0] ) . ' ' . $headers['request_uri'][0];
7171
}
7272

73-
$signature = isset( $headers['signature_input'] ) ? new Http_Message_Signature() : new Draft_Cavage_Signature();
73+
$signature = isset( $headers['signature_input'] ) ? new Http_Message_Signature() : new Http_Signature_Draft();
7474

7575
return $signature->verify( $headers, $body ?? null );
7676
}
@@ -95,7 +95,7 @@ public static function maybe_double_knock( $response, $parsed_args, $url ) {
9595
unset( $parsed_args['headers']['Signature'], $parsed_args['headers']['Signature-Input'], $parsed_args['headers']['Content-Digest'] );
9696
self::rfc9421_add_unsupported_host( $url );
9797

98-
$parsed_args = ( new Draft_Cavage_Signature() )->sign( $parsed_args, $url );
98+
$parsed_args = ( new Http_Signature_Draft() )->sign( $parsed_args, $url );
9999
$response = \wp_remote_request( $url, $parsed_args );
100100
}
101101

includes/signature/class-http-message-signature.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
* @see https://www.rfc-editor.org/rfc/rfc9421.html
2222
*/
23-
class Http_Message_Signature implements Signature_Standard {
23+
class Http_Message_Signature implements Http_Signature {
2424

2525
/**
2626
* Signature algorithms.

includes/signature/class-draft-cavage-signature.php renamed to includes/signature/class-http-signature-draft.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
use Activitypub\Collection\Actors;
1515

1616
/**
17-
* Class Draft_Cavage.
17+
* Class Http_Signature_Draft.
1818
*
1919
* Implements the Draft Cavage signature standard for verifying HTTP signatures.
2020
*
2121
* @see https://tools.ietf.org/html/draft-cavage-http-signatures-12
2222
*/
23-
class Draft_Cavage_Signature implements Signature_Standard {
23+
class Http_Signature_Draft implements Http_Signature {
2424

2525
/**
2626
* Generate Signature headers for an outgoing HTTP request.

includes/signature/interface-signature-standard.php renamed to includes/signature/interface-http-signature.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Interface for HTTP Signature Standards.
3+
* Interface for HTTP Signature.
44
*
55
* This interface defines the methods required for verifying HTTP signatures
66
* according to various standards, such as Draft Cavage and HTTP Message Signature.
@@ -11,9 +11,9 @@
1111
namespace Activitypub\Signature;
1212

1313
/**
14-
* Interface Signature_Standard.
14+
* Interface Http_Signature.
1515
*/
16-
interface Signature_Standard {
16+
interface Http_Signature {
1717

1818
/**
1919
* Generate Signature headers for an outgoing HTTP request.

tests/includes/class-test-signature.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ function () use ( $keys ) {
317317
}
318318
);
319319

320-
$signature = new Signature\Draft_Cavage_Signature();
320+
$signature = new Signature\Http_Signature_Draft();
321321
$args = $signature->sign(
322322
array(
323323
'method' => 'POST',

tests/includes/rest/class-test-actors-inbox-controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ function ( $json, $actor ) {
299299
// Mock remote actor URL.
300300
$activity->add_cc( $actor->get_id() );
301301

302-
$signature = new \Activitypub\Signature\Draft_Cavage_Signature();
302+
$signature = new \Activitypub\Signature\Http_Signature_Draft();
303303
$args = $signature->sign(
304304
array(
305305
'method' => 'POST',

0 commit comments

Comments
 (0)