webauthn-p256
Advanced tools
Comparing version 0.0.9-main.20240805T213617 to 0.0.9-main.20240813T212422
@@ -28,2 +28,3 @@ "use strict"; | ||
}, | ||
raw: credential, | ||
}; | ||
@@ -30,0 +31,0 @@ } |
@@ -28,4 +28,7 @@ "use strict"; | ||
exports.base64UrlToBase64 = base64UrlToBase64; | ||
function base64ToBase64Url(base64) { | ||
return base64.replaceAll('+', '-').replaceAll('/', '_'); | ||
function base64ToBase64Url(base64, { pad = true } = {}) { | ||
const base64Url = base64.replaceAll('+', '-').replaceAll('/', '_'); | ||
if (!pad) | ||
return base64Url.replace(/=+$/, ''); | ||
return base64Url; | ||
} | ||
@@ -32,0 +35,0 @@ exports.base64ToBase64Url = base64ToBase64Url; |
@@ -40,2 +40,3 @@ import { numberToBytesBE } from '@noble/curves/abstract/utils'; | ||
}, | ||
raw: credential, | ||
}; | ||
@@ -42,0 +43,0 @@ } |
@@ -20,4 +20,7 @@ import { bytesToHex as bytesToHex_noble, hexToBytes as hexToBytes_noble, } from '@noble/hashes/utils'; | ||
} | ||
export function base64ToBase64Url(base64) { | ||
return base64.replaceAll('+', '-').replaceAll('/', '_'); | ||
export function base64ToBase64Url(base64, { pad = true } = {}) { | ||
const base64Url = base64.replaceAll('+', '-').replaceAll('/', '_'); | ||
if (!pad) | ||
return base64Url.replace(/=+$/, ''); | ||
return base64Url; | ||
} | ||
@@ -24,0 +27,0 @@ export function base64ToUtf8(base64) { |
@@ -14,2 +14,3 @@ import type { Credential, Hex, Signature, WebAuthnData } from './types.js'; | ||
webauthn: WebAuthnData; | ||
raw: PublicKeyCredential; | ||
}; | ||
@@ -16,0 +17,0 @@ /** |
@@ -7,3 +7,5 @@ import type { Hex } from './types.js'; | ||
export declare function base64UrlToBase64(base64Url: string): string; | ||
export declare function base64ToBase64Url(base64: string): string; | ||
export declare function base64ToBase64Url(base64: string, { pad }?: { | ||
pad?: boolean; | ||
}): string; | ||
export declare function base64ToUtf8(base64: string): string; | ||
@@ -10,0 +12,0 @@ export declare function utf8ToBase64(base64: string): string; |
{ | ||
"name": "webauthn-p256", | ||
"description": "P256 signature utilities for WebAuthn", | ||
"version": "0.0.9-main.20240805T213617", | ||
"version": "0.0.9-main.20240813T212422", | ||
"type": "module", | ||
@@ -6,0 +6,0 @@ "main": "./_cjs/index.js", |
255
sign.test.ts
@@ -18,2 +18,3 @@ import { describe, expect, test } from 'vitest' | ||
return Promise.resolve({ | ||
id: 'm1-bMPuAqpWhCxHZQZTT6e-lSPntQbh3opIoGe7g4Qs', | ||
response: { | ||
@@ -52,2 +53,256 @@ authenticatorData: [ | ||
{ | ||
"raw": { | ||
"id": "m1-bMPuAqpWhCxHZQZTT6e-lSPntQbh3opIoGe7g4Qs", | ||
"response": { | ||
"authenticatorData": [ | ||
73, | ||
150, | ||
13, | ||
229, | ||
136, | ||
14, | ||
140, | ||
104, | ||
116, | ||
52, | ||
23, | ||
15, | ||
100, | ||
118, | ||
96, | ||
91, | ||
143, | ||
228, | ||
174, | ||
185, | ||
162, | ||
134, | ||
50, | ||
199, | ||
153, | ||
92, | ||
243, | ||
186, | ||
131, | ||
29, | ||
151, | ||
99, | ||
5, | ||
0, | ||
0, | ||
0, | ||
0, | ||
], | ||
"clientDataJSON": [ | ||
123, | ||
34, | ||
116, | ||
121, | ||
112, | ||
101, | ||
34, | ||
58, | ||
34, | ||
119, | ||
101, | ||
98, | ||
97, | ||
117, | ||
116, | ||
104, | ||
110, | ||
46, | ||
103, | ||
101, | ||
116, | ||
34, | ||
44, | ||
34, | ||
99, | ||
104, | ||
97, | ||
108, | ||
108, | ||
101, | ||
110, | ||
103, | ||
101, | ||
34, | ||
58, | ||
34, | ||
57, | ||
106, | ||
69, | ||
70, | ||
105, | ||
106, | ||
117, | ||
104, | ||
69, | ||
87, | ||
114, | ||
77, | ||
52, | ||
83, | ||
79, | ||
87, | ||
45, | ||
116, | ||
67, | ||
104, | ||
74, | ||
98, | ||
85, | ||
69, | ||
72, | ||
69, | ||
80, | ||
52, | ||
52, | ||
86, | ||
99, | ||
106, | ||
99, | ||
74, | ||
45, | ||
66, | ||
113, | ||
111, | ||
49, | ||
102, | ||
84, | ||
77, | ||
56, | ||
34, | ||
44, | ||
34, | ||
111, | ||
114, | ||
105, | ||
103, | ||
105, | ||
110, | ||
34, | ||
58, | ||
34, | ||
104, | ||
116, | ||
116, | ||
112, | ||
58, | ||
47, | ||
47, | ||
108, | ||
111, | ||
99, | ||
97, | ||
108, | ||
104, | ||
111, | ||
115, | ||
116, | ||
58, | ||
53, | ||
49, | ||
55, | ||
51, | ||
34, | ||
44, | ||
34, | ||
99, | ||
114, | ||
111, | ||
115, | ||
115, | ||
79, | ||
114, | ||
105, | ||
103, | ||
105, | ||
110, | ||
34, | ||
58, | ||
102, | ||
97, | ||
108, | ||
115, | ||
101, | ||
125, | ||
], | ||
"signature": [ | ||
48, | ||
70, | ||
2, | ||
33, | ||
0, | ||
146, | ||
61, | ||
150, | ||
57, | ||
188, | ||
182, | ||
119, | ||
250, | ||
23, | ||
162, | ||
103, | ||
56, | ||
232, | ||
200, | ||
162, | ||
77, | ||
88, | ||
37, | ||
145, | ||
151, | ||
40, | ||
59, | ||
42, | ||
63, | ||
46, | ||
225, | ||
53, | ||
221, | ||
74, | ||
128, | ||
13, | ||
165, | ||
2, | ||
33, | ||
0, | ||
128, | ||
39, | ||
38, | ||
71, | ||
180, | ||
153, | ||
30, | ||
232, | ||
243, | ||
94, | ||
159, | ||
66, | ||
42, | ||
246, | ||
56, | ||
195, | ||
195, | ||
139, | ||
40, | ||
163, | ||
26, | ||
34, | ||
125, | ||
244, | ||
171, | ||
166, | ||
7, | ||
178, | ||
169, | ||
246, | ||
142, | ||
198, | ||
], | ||
}, | ||
}, | ||
"signature": "0x923d9639bcb677fa17a26738e8c8a24d58259197283b2a3f2ee135dd4a800da57fd8d9b74b66e1180ca160bdd509c73bf95bd20a8cf520904813c310526c968b", | ||
@@ -54,0 +309,0 @@ "webauthn": { |
@@ -28,2 +28,3 @@ import { numberToBytesBE } from '@noble/curves/abstract/utils' | ||
webauthn: WebAuthnData | ||
raw: PublicKeyCredential | ||
} | ||
@@ -81,2 +82,3 @@ | ||
}, | ||
raw: credential, | ||
} | ||
@@ -83,0 +85,0 @@ } catch (error) { |
@@ -30,4 +30,6 @@ import { | ||
export function base64ToBase64Url(base64: string): string { | ||
return base64.replaceAll('+', '-').replaceAll('/', '_') | ||
export function base64ToBase64Url(base64: string, { pad = true }: { pad?: boolean } = {}): string { | ||
const base64Url = base64.replaceAll('+', '-').replaceAll('/', '_') | ||
if (!pad) return base64Url.replace(/=+$/, '') | ||
return base64Url | ||
} | ||
@@ -34,0 +36,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
195664
3385