/
githubmirror
/
tldraw
Обзор
Документация
Войти
/
githubmirror
/
tldraw
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/editor/src/lib/utils/licensing.ts
30 строк
766 B
Mime Čuvalo
sdk: wires up tldraw to have licensing mechanisms (#4021)
11 июл 2024, 14:49
Не верифицирован
11 июл 2024, 14:49
69a1c17
Код
Авторство
О чём код?
/* Convert a string into an ArrayBuffer from https://developers.google.com/web/updates/2012/06/How-to-convert-ArrayBuffer-to-and-from-String */ export function str2ab(str: string) { const buf = new ArrayBuffer(str.length) const bufView = new Uint8Array(buf) for (let i = 0, strLen = str.length; i < strLen; i++) { bufView[i] = str.charCodeAt(i) } return buf } export function importPublicKey(pemContents: string) { // base64 decode the string to get the binary data const binaryDerString = atob(pemContents) // convert from a binary string to an ArrayBuffer const binaryDer = str2ab(binaryDerString) return crypto.subtle.importKey( 'spki', new Uint8Array(binaryDer), { name: 'ECDSA', namedCurve: 'P-256', }, true, ['verify'] ) }