Skip to content

Commit b1e09e9

Browse files
vockalimoMinishlink
authored andcommitted
Encode VAPID key in URL-safe base64 (#220)
* fix base64encode issue * typo ~ fix Base64Url::encode * fix phpunit testing * fix The condition becomes ">=86" and ">=42"
1 parent 0f611f8 commit b1e09e9

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/VAPID.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ public static function createVapidKeys(): array
190190
}
191191

192192
return [
193-
'publicKey' => base64_encode($binaryPublicKey),
194-
'privateKey' => base64_encode($binaryPrivateKey)
193+
'publicKey' => Base64Url::encode($binaryPublicKey),
194+
'privateKey' => Base64Url::encode($binaryPrivateKey)
195195
];
196196
}
197197
}

tests/VAPIDTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function testCreateVapidKeys()
9898
$keys = VAPID::createVapidKeys();
9999
$this->assertArrayHasKey('publicKey', $keys);
100100
$this->assertArrayHasKey('privateKey', $keys);
101-
$this->assertEquals(strlen($keys['publicKey']), 88);
102-
$this->assertEquals(strlen($keys['privateKey']), 44);
101+
$this->assertGreaterThanOrEqual(86, strlen($keys['publicKey']));
102+
$this->assertGreaterThanOrEqual(42, strlen($keys['privateKey']));
103103
}
104104
}

0 commit comments

Comments
 (0)