final class WebhookSigner (View source)

테스트와 로컬 확인용으로 웹훅에 Standard Webhooks 서명을 만듭니다.

서명 규칙은 WebhookVerifier와 같으므로 이 서명기가 만든 헤더는 WebhookVerifier::verify()를 통과합니다.

Methods

__construct(string $webhookSecret)

WebhookVerifier와 같은 webhookSecret으로 서명기를 초기화합니다.

array
__debugInfo()

인증 정보가 디버그 출력에 노출되지 않도록 빈 정보를 반환합니다.

array
__serialize()

인증 정보가 직렬화되어 노출되지 않도록 직렬화를 거부합니다.

void
__unserialize(array $data)

인증 정보가 포함된 객체의 역직렬화를 거부합니다.

string
sign(string $msgId, int $timestamp, string $body)

webhook-signature 헤더 값을 반환합니다.

array
headers(string $body, string|null $msgId = null, int|null $timestamp = null)

webhook-id, webhook-signature, webhook-timestamp 헤더를 반환합니다.

Details

__construct(string $webhookSecret)

WebhookVerifier와 같은 webhookSecret으로 서명기를 초기화합니다.

Parameters

string $webhookSecret

array __debugInfo()

인증 정보가 디버그 출력에 노출되지 않도록 빈 정보를 반환합니다.

Return Value

array

array __serialize()

인증 정보가 직렬화되어 노출되지 않도록 직렬화를 거부합니다.

Return Value

array

void __unserialize(array $data)

인증 정보가 포함된 객체의 역직렬화를 거부합니다.

Parameters

array $data

Return Value

void

string sign(string $msgId, int $timestamp, string $body)

webhook-signature 헤더 값을 반환합니다.

Parameters

string $msgId

webhook-id 헤더 값입니다.

int $timestamp

webhook-timestamp 헤더 값(Unix 초)입니다.

string $body

서명할 원본 요청 본문입니다.

Return Value

string

v1,<Base64 서명> 형식의 값입니다.

array headers(string $body, string|null $msgId = null, int|null $timestamp = null)

webhook-id, webhook-signature, webhook-timestamp 헤더를 반환합니다.

Parameters

string $body

서명할 원본 요청 본문입니다.

string|null $msgId

webhook-id 값입니다. 없으면 msg- 뒤에 무작위 UUID를 붙여 만듭니다.

int|null $timestamp

webhook-timestamp 값입니다. 없으면 현재 시각을 씁니다.

Return Value

array