@turnkey/webauthn-stamper
Advanced tools
Comparing version 0.3.0 to 0.4.0
@@ -1,7 +0,7 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.WebauthnStamper = void 0; | ||
'use strict'; | ||
var index = require('./webauthn-json/index.js'); | ||
var universal = require('./universal.js'); | ||
/// <reference lib="dom" /> | ||
const webauthn_json_1 = require("./webauthn-json"); | ||
const universal_1 = require("./universal"); | ||
// Header name for a webauthn stamp | ||
@@ -32,3 +32,3 @@ const stampHeaderName = "X-Stamp-Webauthn"; | ||
}; | ||
const clientGetResult = await (0, webauthn_json_1.get)(signingOptions); | ||
const clientGetResult = await index.get(signingOptions); | ||
const assertion = clientGetResult.toJSON(); | ||
@@ -47,10 +47,11 @@ const stamp = { | ||
} | ||
exports.WebauthnStamper = WebauthnStamper; | ||
async function getChallengeFromPayload(payload) { | ||
const messageBuffer = new TextEncoder().encode(payload); | ||
const hashBuffer = await crypto.subtle.digest("SHA-256", messageBuffer); | ||
const hexString = universal_1.buffer.from(hashBuffer).toString("hex"); | ||
const hexBuffer = universal_1.buffer.from(hexString, "utf8"); | ||
const hexString = universal.buffer.from(hashBuffer).toString("hex"); | ||
const hexBuffer = universal.buffer.from(hexString, "utf8"); | ||
return new Uint8Array(hexBuffer); | ||
} | ||
//# sourceMappingURL=index.js.map | ||
exports.WebauthnStamper = WebauthnStamper; | ||
//# sourceMappingURL=index.js.map |
# @turnkey/webauthn-stamper | ||
## 0.4.0 | ||
### Minor Changes | ||
- Use rollup to build ESM and CommonJS, fix ESM support (#174) | ||
## 0.3.0 | ||
@@ -4,0 +10,0 @@ |
@@ -1,7 +0,7 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.WebauthnStamper = void 0; | ||
'use strict'; | ||
var index = require('./webauthn-json/index.js'); | ||
var universal = require('./universal.js'); | ||
/// <reference lib="dom" /> | ||
const webauthn_json_1 = require("./webauthn-json"); | ||
const universal_1 = require("./universal"); | ||
// Header name for a webauthn stamp | ||
@@ -32,3 +32,3 @@ const stampHeaderName = "X-Stamp-Webauthn"; | ||
}; | ||
const clientGetResult = await (0, webauthn_json_1.get)(signingOptions); | ||
const clientGetResult = await index.get(signingOptions); | ||
const assertion = clientGetResult.toJSON(); | ||
@@ -47,10 +47,11 @@ const stamp = { | ||
} | ||
exports.WebauthnStamper = WebauthnStamper; | ||
async function getChallengeFromPayload(payload) { | ||
const messageBuffer = new TextEncoder().encode(payload); | ||
const hashBuffer = await crypto.subtle.digest("SHA-256", messageBuffer); | ||
const hexString = universal_1.buffer.from(hashBuffer).toString("hex"); | ||
const hexBuffer = universal_1.buffer.from(hexString, "utf8"); | ||
const hexString = universal.buffer.from(hashBuffer).toString("hex"); | ||
const hexBuffer = universal.buffer.from(hexString, "utf8"); | ||
return new Uint8Array(hexBuffer); | ||
} | ||
//# sourceMappingURL=index.js.map | ||
exports.WebauthnStamper = WebauthnStamper; | ||
//# sourceMappingURL=index.js.map |
@@ -1,12 +0,11 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
'use strict'; | ||
/// <reference lib="dom" /> | ||
exports.buffer = void 0; | ||
/// <reference lib="dom" /> | ||
let buffer; | ||
if (typeof globalThis?.Buffer !== "undefined") { | ||
exports.buffer = buffer = globalThis.Buffer; | ||
exports.buffer = globalThis.Buffer; | ||
} | ||
else { | ||
exports.buffer = buffer = require("buffer").Buffer; | ||
exports.buffer = require("buffer").Buffer; | ||
} | ||
//# sourceMappingURL=universal.js.map | ||
//# sourceMappingURL=universal.js.map |
@@ -1,33 +0,12 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.get = exports.getResponseToJSON = exports.getRequestFromJSON = exports.create = exports.createResponseToJSON = exports.createRequestFromJSON = void 0; | ||
const base64url_1 = require("./base64url"); | ||
const convert_1 = require("./convert"); | ||
const schema_1 = require("./schema"); | ||
function createRequestFromJSON(requestJSON) { | ||
return (0, convert_1.convert)(base64url_1.base64urlToBuffer, schema_1.credentialCreationOptions, requestJSON); | ||
} | ||
exports.createRequestFromJSON = createRequestFromJSON; | ||
function createResponseToJSON(credential) { | ||
return (0, convert_1.convert)(base64url_1.bufferToBase64url, schema_1.publicKeyCredentialWithAttestation, credential); | ||
} | ||
exports.createResponseToJSON = createResponseToJSON; | ||
async function create(requestJSON) { | ||
const credential = (await navigator.credentials.create(createRequestFromJSON(requestJSON))); | ||
return createResponseToJSON(credential); | ||
} | ||
exports.create = create; | ||
function getRequestFromJSON(requestJSON) { | ||
return (0, convert_1.convert)(base64url_1.base64urlToBuffer, schema_1.credentialRequestOptions, requestJSON); | ||
} | ||
exports.getRequestFromJSON = getRequestFromJSON; | ||
'use strict'; | ||
var base64url = require('./base64url.js'); | ||
var convert = require('./convert.js'); | ||
var schema = require('./schema.js'); | ||
function getResponseToJSON(credential) { | ||
return (0, convert_1.convert)(base64url_1.bufferToBase64url, schema_1.publicKeyCredentialWithAssertion, credential); | ||
return convert.convert(base64url.bufferToBase64url, schema.publicKeyCredentialWithAssertion, credential); | ||
} | ||
exports.getResponseToJSON = getResponseToJSON; | ||
async function get(requestJSON) { | ||
const credential = (await navigator.credentials.get(getRequestFromJSON(requestJSON))); | ||
return getResponseToJSON(credential); | ||
} | ||
exports.get = get; | ||
//# sourceMappingURL=api.js.map | ||
//# sourceMappingURL=api.js.map |
@@ -1,19 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.bufferToBase64url = exports.base64urlToBuffer = void 0; | ||
function base64urlToBuffer(baseurl64String) { | ||
// Base64url to Base64 | ||
const padding = "==".slice(0, (4 - (baseurl64String.length % 4)) % 4); | ||
const base64String = baseurl64String.replace(/-/g, "+").replace(/_/g, "/") + padding; | ||
// Base64 to binary string | ||
const str = atob(base64String); | ||
// Binary string to buffer | ||
const buffer = new ArrayBuffer(str.length); | ||
const byteView = new Uint8Array(buffer); | ||
for (let i = 0; i < str.length; i++) { | ||
byteView[i] = str.charCodeAt(i); | ||
} | ||
return buffer; | ||
} | ||
exports.base64urlToBuffer = base64urlToBuffer; | ||
'use strict'; | ||
function bufferToBase64url(buffer) { | ||
@@ -36,3 +20,4 @@ // Buffer to binary string | ||
} | ||
exports.bufferToBase64url = bufferToBase64url; | ||
//# sourceMappingURL=base64url.js.map | ||
//# sourceMappingURL=base64url.js.map |
@@ -1,14 +0,13 @@ | ||
"use strict"; | ||
'use strict'; | ||
// We export these values in order so that they can be used to deduplicate | ||
// schema definitions in minified JS code. | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.optional = exports.required = exports.derived = exports.convert = exports.convertValue = exports.copyValue = void 0; | ||
// TODO: Parcel isn't deduplicating these values. | ||
exports.copyValue = "copy"; | ||
exports.convertValue = "convert"; | ||
const copyValue = "copy"; | ||
const convertValue = "convert"; | ||
function convert(conversionFn, schema, input) { | ||
if (schema === exports.copyValue) { | ||
if (schema === copyValue) { | ||
return input; | ||
} | ||
if (schema === exports.convertValue) { | ||
if (schema === convertValue) { | ||
return conversionFn(input); | ||
@@ -46,3 +45,2 @@ } | ||
} | ||
exports.convert = convert; | ||
function derived(schema, derive) { | ||
@@ -55,3 +53,2 @@ return { | ||
} | ||
exports.derived = derived; | ||
function required(schema) { | ||
@@ -63,3 +60,2 @@ return { | ||
} | ||
exports.required = required; | ||
function optional(schema) { | ||
@@ -71,3 +67,9 @@ return { | ||
} | ||
exports.convert = convert; | ||
exports.convertValue = convertValue; | ||
exports.copyValue = copyValue; | ||
exports.derived = derived; | ||
exports.optional = optional; | ||
//# sourceMappingURL=convert.js.map | ||
exports.required = required; | ||
//# sourceMappingURL=convert.js.map |
@@ -1,19 +0,12 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.get = exports.create = exports.parseRequestOptionsFromJSON = exports.parseCreationOptionsFromJSON = void 0; | ||
const api_1 = require("./api"); | ||
Object.defineProperty(exports, "parseCreationOptionsFromJSON", { enumerable: true, get: function () { return api_1.createRequestFromJSON; } }); | ||
Object.defineProperty(exports, "parseRequestOptionsFromJSON", { enumerable: true, get: function () { return api_1.getRequestFromJSON; } }); | ||
async function create(options) { | ||
const response = (await navigator.credentials.create(options)); | ||
response.toJSON = () => (0, api_1.createResponseToJSON)(response); | ||
return response; | ||
} | ||
exports.create = create; | ||
'use strict'; | ||
var api = require('./api.js'); | ||
async function get(options) { | ||
const response = (await navigator.credentials.get(options)); | ||
response.toJSON = () => (0, api_1.getResponseToJSON)(response); | ||
response.toJSON = () => api.getResponseToJSON(response); | ||
return response; | ||
} | ||
exports.get = get; | ||
//# sourceMappingURL=index.js.map | ||
//# sourceMappingURL=index.js.map |
@@ -1,86 +0,26 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.schema = exports.publicKeyCredentialWithAssertion = exports.credentialRequestOptions = exports.publicKeyCredentialWithAttestation = exports.credentialCreationOptions = void 0; | ||
const convert_1 = require("./convert"); | ||
// Shared by `create()` and `get()`. | ||
const publicKeyCredentialDescriptorSchema = { | ||
type: (0, convert_1.required)(convert_1.copyValue), | ||
id: (0, convert_1.required)(convert_1.convertValue), | ||
transports: (0, convert_1.optional)(convert_1.copyValue), | ||
}; | ||
const simplifiedExtensionsSchema = { | ||
appid: (0, convert_1.optional)(convert_1.copyValue), | ||
appidExclude: (0, convert_1.optional)(convert_1.copyValue), | ||
credProps: (0, convert_1.optional)(convert_1.copyValue), | ||
}; | ||
'use strict'; | ||
var convert = require('./convert.js'); | ||
const simplifiedClientExtensionResultsSchema = { | ||
appid: (0, convert_1.optional)(convert_1.copyValue), | ||
appidExclude: (0, convert_1.optional)(convert_1.copyValue), | ||
credProps: (0, convert_1.optional)(convert_1.copyValue), | ||
appid: convert.optional(convert.copyValue), | ||
appidExclude: convert.optional(convert.copyValue), | ||
credProps: convert.optional(convert.copyValue), | ||
}; | ||
// `navigator.create()` request | ||
exports.credentialCreationOptions = { | ||
publicKey: (0, convert_1.required)({ | ||
rp: (0, convert_1.required)(convert_1.copyValue), | ||
user: (0, convert_1.required)({ | ||
id: (0, convert_1.required)(convert_1.convertValue), | ||
name: (0, convert_1.required)(convert_1.copyValue), | ||
displayName: (0, convert_1.required)(convert_1.copyValue), | ||
}), | ||
challenge: (0, convert_1.required)(convert_1.convertValue), | ||
pubKeyCredParams: (0, convert_1.required)(convert_1.copyValue), | ||
timeout: (0, convert_1.optional)(convert_1.copyValue), | ||
excludeCredentials: (0, convert_1.optional)([publicKeyCredentialDescriptorSchema]), | ||
authenticatorSelection: (0, convert_1.optional)(convert_1.copyValue), | ||
attestation: (0, convert_1.optional)(convert_1.copyValue), | ||
extensions: (0, convert_1.optional)(simplifiedExtensionsSchema), | ||
}), | ||
signal: (0, convert_1.optional)(convert_1.copyValue), | ||
}; | ||
// `navigator.create()` response | ||
exports.publicKeyCredentialWithAttestation = { | ||
type: (0, convert_1.required)(convert_1.copyValue), | ||
id: (0, convert_1.required)(convert_1.copyValue), | ||
rawId: (0, convert_1.required)(convert_1.convertValue), | ||
authenticatorAttachment: (0, convert_1.optional)(convert_1.copyValue), | ||
response: (0, convert_1.required)({ | ||
clientDataJSON: (0, convert_1.required)(convert_1.convertValue), | ||
attestationObject: (0, convert_1.required)(convert_1.convertValue), | ||
transports: (0, convert_1.derived)(convert_1.copyValue, (response) => response.getTransports?.() || []), | ||
}), | ||
clientExtensionResults: (0, convert_1.derived)(simplifiedClientExtensionResultsSchema, (pkc) => pkc.getClientExtensionResults()), | ||
}; | ||
// `navigator.get()` request | ||
exports.credentialRequestOptions = { | ||
mediation: (0, convert_1.optional)(convert_1.copyValue), | ||
publicKey: (0, convert_1.required)({ | ||
challenge: (0, convert_1.required)(convert_1.convertValue), | ||
timeout: (0, convert_1.optional)(convert_1.copyValue), | ||
rpId: (0, convert_1.optional)(convert_1.copyValue), | ||
allowCredentials: (0, convert_1.optional)([publicKeyCredentialDescriptorSchema]), | ||
userVerification: (0, convert_1.optional)(convert_1.copyValue), | ||
extensions: (0, convert_1.optional)(simplifiedExtensionsSchema), | ||
}), | ||
signal: (0, convert_1.optional)(convert_1.copyValue), | ||
}; | ||
// `navigator.get()` response | ||
exports.publicKeyCredentialWithAssertion = { | ||
type: (0, convert_1.required)(convert_1.copyValue), | ||
id: (0, convert_1.required)(convert_1.copyValue), | ||
rawId: (0, convert_1.required)(convert_1.convertValue), | ||
authenticatorAttachment: (0, convert_1.optional)(convert_1.copyValue), | ||
response: (0, convert_1.required)({ | ||
clientDataJSON: (0, convert_1.required)(convert_1.convertValue), | ||
authenticatorData: (0, convert_1.required)(convert_1.convertValue), | ||
signature: (0, convert_1.required)(convert_1.convertValue), | ||
userHandle: (0, convert_1.required)(convert_1.convertValue), | ||
const publicKeyCredentialWithAssertion = { | ||
type: convert.required(convert.copyValue), | ||
id: convert.required(convert.copyValue), | ||
rawId: convert.required(convert.convertValue), | ||
authenticatorAttachment: convert.optional(convert.copyValue), | ||
response: convert.required({ | ||
clientDataJSON: convert.required(convert.convertValue), | ||
authenticatorData: convert.required(convert.convertValue), | ||
signature: convert.required(convert.convertValue), | ||
userHandle: convert.required(convert.convertValue), | ||
}), | ||
clientExtensionResults: (0, convert_1.derived)(simplifiedClientExtensionResultsSchema, (pkc) => pkc.getClientExtensionResults()), | ||
clientExtensionResults: convert.derived(simplifiedClientExtensionResultsSchema, (pkc) => pkc.getClientExtensionResults()), | ||
}; | ||
exports.schema = { | ||
credentialCreationOptions: exports.credentialCreationOptions, | ||
publicKeyCredentialWithAttestation: exports.publicKeyCredentialWithAttestation, | ||
credentialRequestOptions: exports.credentialRequestOptions, | ||
publicKeyCredentialWithAssertion: exports.publicKeyCredentialWithAssertion, | ||
}; | ||
//# sourceMappingURL=schema.js.map | ||
exports.publicKeyCredentialWithAssertion = publicKeyCredentialWithAssertion; | ||
//# sourceMappingURL=schema.js.map |
{ | ||
"name": "@turnkey/webauthn-stamper", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"main": "./dist/index.js", | ||
"module": "./dist/esm/index.js", | ||
"module": "./dist/index.mjs", | ||
"exports": { | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"import": "./dist/esm/index.js", | ||
"import": "./dist/index.mjs", | ||
"require": "./dist/index.js", | ||
"default": "./dist/esm/index.js" | ||
"default": "./dist/index.mjs" | ||
} | ||
@@ -49,5 +49,4 @@ }, | ||
"scripts": { | ||
"build": "tsc -b ./tsconfig.esm.json ./tsconfig.json", | ||
"build": "rollup -c", | ||
"clean": "rimraf ./dist ./.cache", | ||
"pack": "npm pack && mv *.tgz /Users/jessecollier/git/test-app-1/", | ||
"test": "jest", | ||
@@ -54,0 +53,0 @@ "typecheck": "tsc -p tsconfig.typecheck.json" |
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
54495
51
596