@dynamic-labs/webauthn 3.0.0-alpha.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3843 -0
- package/LICENSE +21 -0
- package/README.md +11 -0
- package/_virtual/_tslib.cjs +36 -0
- package/_virtual/_tslib.js +32 -0
- package/package.json +34 -0
- package/src/index.cjs +18 -0
- package/src/index.d.ts +6 -0
- package/src/index.js +6 -0
- package/src/lib/adapters/convertTransportEnumToTurnkeyEnum.cjs +29 -0
- package/src/lib/adapters/convertTransportEnumToTurnkeyEnum.d.ts +2 -0
- package/src/lib/adapters/convertTransportEnumToTurnkeyEnum.js +25 -0
- package/src/lib/adapters/getWebAuthnAttestationTurnkeyAdapter.cjs +41 -0
- package/src/lib/adapters/getWebAuthnAttestationTurnkeyAdapter.d.ts +6 -0
- package/src/lib/adapters/getWebAuthnAttestationTurnkeyAdapter.js +37 -0
- package/src/lib/createWebauthnCredential.cjs +26 -0
- package/src/lib/createWebauthnCredential.d.ts +2 -0
- package/src/lib/createWebauthnCredential.js +22 -0
- package/src/lib/errors/WebauthnNotSupportedError.cjs +12 -0
- package/src/lib/errors/WebauthnNotSupportedError.d.ts +3 -0
- package/src/lib/errors/WebauthnNotSupportedError.js +8 -0
- package/src/lib/logger.cjs +10 -0
- package/src/lib/logger.d.ts +2 -0
- package/src/lib/logger.js +6 -0
- package/src/lib/verifyWebauthnCredential.cjs +26 -0
- package/src/lib/verifyWebauthnCredential.d.ts +2 -0
- package/src/lib/verifyWebauthnCredential.js +22 -0
- package/src/types.d.ts +5 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Dynamic Labs, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
/******************************************************************************
|
|
7
|
+
Copyright (c) Microsoft Corporation.
|
|
8
|
+
|
|
9
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
10
|
+
purpose with or without fee is hereby granted.
|
|
11
|
+
|
|
12
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
13
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
14
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
15
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
16
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
17
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
18
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
19
|
+
***************************************************************************** */
|
|
20
|
+
|
|
21
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
22
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
32
|
+
var e = new Error(message);
|
|
33
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.__awaiter = __awaiter;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
/******************************************************************************
|
|
3
|
+
Copyright (c) Microsoft Corporation.
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted.
|
|
7
|
+
|
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
9
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
10
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
11
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
12
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
13
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
+
***************************************************************************** */
|
|
16
|
+
|
|
17
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
28
|
+
var e = new Error(message);
|
|
29
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { __awaiter };
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dynamic-labs/webauthn",
|
|
3
|
+
"version": "3.0.0-alpha.46",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
|
|
7
|
+
"directory": "packages/webauthn"
|
|
8
|
+
},
|
|
9
|
+
"description": "A React SDK for implementing wallet web3 authentication and authorization to your website.",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/dynamic-labs/DynamicAuth/issues"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/dynamic-labs/DynamicAuth#readme",
|
|
14
|
+
"author": "Dynamic Labs, Inc.",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"main": "./src/index.cjs",
|
|
17
|
+
"module": "./src/index.js",
|
|
18
|
+
"types": "./src/index.d.ts",
|
|
19
|
+
"type": "module",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./src/index.d.ts",
|
|
23
|
+
"import": "./src/index.js",
|
|
24
|
+
"require": "./src/index.cjs"
|
|
25
|
+
},
|
|
26
|
+
"./package.json": "./package.json"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@simplewebauthn/browser": "9.0.1",
|
|
30
|
+
"@simplewebauthn/types": "9.0.1",
|
|
31
|
+
"@dynamic-labs/logger": "3.0.0-alpha.46"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {}
|
|
34
|
+
}
|
package/src/index.cjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var WebauthnNotSupportedError = require('./lib/errors/WebauthnNotSupportedError.cjs');
|
|
7
|
+
var createWebauthnCredential = require('./lib/createWebauthnCredential.cjs');
|
|
8
|
+
var verifyWebauthnCredential = require('./lib/verifyWebauthnCredential.cjs');
|
|
9
|
+
var convertTransportEnumToTurnkeyEnum = require('./lib/adapters/convertTransportEnumToTurnkeyEnum.cjs');
|
|
10
|
+
var getWebAuthnAttestationTurnkeyAdapter = require('./lib/adapters/getWebAuthnAttestationTurnkeyAdapter.cjs');
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
exports.WebauthnNotSupportedError = WebauthnNotSupportedError.WebauthnNotSupportedError;
|
|
15
|
+
exports.createWebauthnCredential = createWebauthnCredential.createWebauthnCredential;
|
|
16
|
+
exports.verifyWebauthnCredential = verifyWebauthnCredential.verifyWebauthnCredential;
|
|
17
|
+
exports.convertTransportEnumToTurnkeyEnum = convertTransportEnumToTurnkeyEnum.convertTransportEnumToTurnkeyEnum;
|
|
18
|
+
exports.getWebAuthnAttestationTurnkeyAdapter = getWebAuthnAttestationTurnkeyAdapter.getWebAuthnAttestationTurnkeyAdapter;
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './lib/errors/WebauthnNotSupportedError';
|
|
2
|
+
export * from './lib/createWebauthnCredential';
|
|
3
|
+
export * from './lib/verifyWebauthnCredential';
|
|
4
|
+
export * from './types';
|
|
5
|
+
export * from './lib/adapters/convertTransportEnumToTurnkeyEnum';
|
|
6
|
+
export * from './lib/adapters/getWebAuthnAttestationTurnkeyAdapter';
|
package/src/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
export { WebauthnNotSupportedError } from './lib/errors/WebauthnNotSupportedError.js';
|
|
3
|
+
export { createWebauthnCredential } from './lib/createWebauthnCredential.js';
|
|
4
|
+
export { verifyWebauthnCredential } from './lib/verifyWebauthnCredential.js';
|
|
5
|
+
export { convertTransportEnumToTurnkeyEnum } from './lib/adapters/convertTransportEnumToTurnkeyEnum.js';
|
|
6
|
+
export { getWebAuthnAttestationTurnkeyAdapter } from './lib/adapters/getWebAuthnAttestationTurnkeyAdapter.js';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
const convertTransportEnumToTurnkeyEnum = (transportEnum) => {
|
|
7
|
+
switch (transportEnum) {
|
|
8
|
+
case 'internal': {
|
|
9
|
+
return 'AUTHENTICATOR_TRANSPORT_INTERNAL';
|
|
10
|
+
}
|
|
11
|
+
case 'usb': {
|
|
12
|
+
return 'AUTHENTICATOR_TRANSPORT_USB';
|
|
13
|
+
}
|
|
14
|
+
case 'nfc': {
|
|
15
|
+
return 'AUTHENTICATOR_TRANSPORT_NFC';
|
|
16
|
+
}
|
|
17
|
+
case 'ble': {
|
|
18
|
+
return 'AUTHENTICATOR_TRANSPORT_BLE';
|
|
19
|
+
}
|
|
20
|
+
case 'hybrid': {
|
|
21
|
+
return 'AUTHENTICATOR_TRANSPORT_HYBRID';
|
|
22
|
+
}
|
|
23
|
+
default: {
|
|
24
|
+
throw new Error('unsupported transport format ' + transportEnum);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
exports.convertTransportEnumToTurnkeyEnum = convertTransportEnumToTurnkeyEnum;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { AuthenticatorTransportFuture } from '@simplewebauthn/types';
|
|
2
|
+
export declare const convertTransportEnumToTurnkeyEnum: (transportEnum: AuthenticatorTransportFuture) => "AUTHENTICATOR_TRANSPORT_INTERNAL" | "AUTHENTICATOR_TRANSPORT_USB" | "AUTHENTICATOR_TRANSPORT_NFC" | "AUTHENTICATOR_TRANSPORT_BLE" | "AUTHENTICATOR_TRANSPORT_HYBRID";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
const convertTransportEnumToTurnkeyEnum = (transportEnum) => {
|
|
3
|
+
switch (transportEnum) {
|
|
4
|
+
case 'internal': {
|
|
5
|
+
return 'AUTHENTICATOR_TRANSPORT_INTERNAL';
|
|
6
|
+
}
|
|
7
|
+
case 'usb': {
|
|
8
|
+
return 'AUTHENTICATOR_TRANSPORT_USB';
|
|
9
|
+
}
|
|
10
|
+
case 'nfc': {
|
|
11
|
+
return 'AUTHENTICATOR_TRANSPORT_NFC';
|
|
12
|
+
}
|
|
13
|
+
case 'ble': {
|
|
14
|
+
return 'AUTHENTICATOR_TRANSPORT_BLE';
|
|
15
|
+
}
|
|
16
|
+
case 'hybrid': {
|
|
17
|
+
return 'AUTHENTICATOR_TRANSPORT_HYBRID';
|
|
18
|
+
}
|
|
19
|
+
default: {
|
|
20
|
+
throw new Error('unsupported transport format ' + transportEnum);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { convertTransportEnumToTurnkeyEnum };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../_virtual/_tslib.cjs');
|
|
7
|
+
var browser = require('@simplewebauthn/browser');
|
|
8
|
+
var createWebauthnCredential = require('../createWebauthnCredential.cjs');
|
|
9
|
+
var convertTransportEnumToTurnkeyEnum = require('./convertTransportEnumToTurnkeyEnum.cjs');
|
|
10
|
+
|
|
11
|
+
// As part of migrating off of turnkey for passkeys, swap out the turnkey implementation of this
|
|
12
|
+
// with our own. Next we should move the PasskeyService out of embedded-wallets in favor of purely in
|
|
13
|
+
// the `passkey` package GVTY-2169
|
|
14
|
+
// for now continue to use the turnkey input and output types here to not make any breaking changes.
|
|
15
|
+
// input: turnkey type => convert to our type => create attestation => output: converted to turnkey type
|
|
16
|
+
const getWebAuthnAttestationTurnkeyAdapter = (options) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
if (!options.publicKey) {
|
|
19
|
+
throw new Error('Invalid options. Public key attribute must be defined');
|
|
20
|
+
}
|
|
21
|
+
const convertedOptions = Object.assign(Object.assign({}, options.publicKey), { challenge: bufferSourceToString(options.publicKey.challenge), excludeCredentials: (_a = options.publicKey.excludeCredentials) === null || _a === void 0 ? void 0 : _a.map((cred) => (Object.assign(Object.assign({}, cred), { id: bufferSourceToString(cred.id) }))), user: Object.assign(Object.assign({}, options.publicKey.user), { id: bufferSourceToString(options.publicKey.user.id) }) });
|
|
22
|
+
const attestation = yield createWebauthnCredential.createWebauthnCredential(convertedOptions);
|
|
23
|
+
return {
|
|
24
|
+
attestationObject: attestation.response.attestationObject,
|
|
25
|
+
clientDataJson: attestation.response.clientDataJSON,
|
|
26
|
+
credentialId: attestation.rawId,
|
|
27
|
+
transports: ((_b = attestation.response.transports) === null || _b === void 0 ? void 0 : _b.map(convertTransportEnumToTurnkeyEnum.convertTransportEnumToTurnkeyEnum)) ||
|
|
28
|
+
[],
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
const bufferSourceToString = (buf) => {
|
|
32
|
+
if (buf instanceof ArrayBuffer) {
|
|
33
|
+
return browser.bufferToBase64URLString(buf);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
const arr = new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
37
|
+
return browser.bufferToBase64URLString(arr);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
exports.getWebAuthnAttestationTurnkeyAdapter = getWebAuthnAttestationTurnkeyAdapter;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const getWebAuthnAttestationTurnkeyAdapter: (options: CredentialCreationOptions) => Promise<{
|
|
2
|
+
attestationObject: string;
|
|
3
|
+
clientDataJson: string;
|
|
4
|
+
credentialId: string;
|
|
5
|
+
transports: ("AUTHENTICATOR_TRANSPORT_INTERNAL" | "AUTHENTICATOR_TRANSPORT_USB" | "AUTHENTICATOR_TRANSPORT_NFC" | "AUTHENTICATOR_TRANSPORT_BLE" | "AUTHENTICATOR_TRANSPORT_HYBRID")[];
|
|
6
|
+
}>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../_virtual/_tslib.js';
|
|
3
|
+
import { bufferToBase64URLString } from '@simplewebauthn/browser';
|
|
4
|
+
import { createWebauthnCredential } from '../createWebauthnCredential.js';
|
|
5
|
+
import { convertTransportEnumToTurnkeyEnum } from './convertTransportEnumToTurnkeyEnum.js';
|
|
6
|
+
|
|
7
|
+
// As part of migrating off of turnkey for passkeys, swap out the turnkey implementation of this
|
|
8
|
+
// with our own. Next we should move the PasskeyService out of embedded-wallets in favor of purely in
|
|
9
|
+
// the `passkey` package GVTY-2169
|
|
10
|
+
// for now continue to use the turnkey input and output types here to not make any breaking changes.
|
|
11
|
+
// input: turnkey type => convert to our type => create attestation => output: converted to turnkey type
|
|
12
|
+
const getWebAuthnAttestationTurnkeyAdapter = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
if (!options.publicKey) {
|
|
15
|
+
throw new Error('Invalid options. Public key attribute must be defined');
|
|
16
|
+
}
|
|
17
|
+
const convertedOptions = Object.assign(Object.assign({}, options.publicKey), { challenge: bufferSourceToString(options.publicKey.challenge), excludeCredentials: (_a = options.publicKey.excludeCredentials) === null || _a === void 0 ? void 0 : _a.map((cred) => (Object.assign(Object.assign({}, cred), { id: bufferSourceToString(cred.id) }))), user: Object.assign(Object.assign({}, options.publicKey.user), { id: bufferSourceToString(options.publicKey.user.id) }) });
|
|
18
|
+
const attestation = yield createWebauthnCredential(convertedOptions);
|
|
19
|
+
return {
|
|
20
|
+
attestationObject: attestation.response.attestationObject,
|
|
21
|
+
clientDataJson: attestation.response.clientDataJSON,
|
|
22
|
+
credentialId: attestation.rawId,
|
|
23
|
+
transports: ((_b = attestation.response.transports) === null || _b === void 0 ? void 0 : _b.map(convertTransportEnumToTurnkeyEnum)) ||
|
|
24
|
+
[],
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
const bufferSourceToString = (buf) => {
|
|
28
|
+
if (buf instanceof ArrayBuffer) {
|
|
29
|
+
return bufferToBase64URLString(buf);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
const arr = new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
33
|
+
return bufferToBase64URLString(arr);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export { getWebAuthnAttestationTurnkeyAdapter };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
7
|
+
var browser = require('@simplewebauthn/browser');
|
|
8
|
+
var WebauthnNotSupportedError = require('./errors/WebauthnNotSupportedError.cjs');
|
|
9
|
+
var logger = require('./logger.cjs');
|
|
10
|
+
|
|
11
|
+
const createWebauthnCredential = (options) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
12
|
+
if (!browser.browserSupportsWebAuthn()) {
|
|
13
|
+
throw new WebauthnNotSupportedError.WebauthnNotSupportedError();
|
|
14
|
+
}
|
|
15
|
+
let attestationResp;
|
|
16
|
+
try {
|
|
17
|
+
attestationResp = yield browser.startRegistration(options);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
logger.logger.debug('Failed to create webauthn credential', error);
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
return attestationResp;
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
exports.createWebauthnCredential = createWebauthnCredential;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
3
|
+
import { browserSupportsWebAuthn, startRegistration } from '@simplewebauthn/browser';
|
|
4
|
+
import { WebauthnNotSupportedError } from './errors/WebauthnNotSupportedError.js';
|
|
5
|
+
import { logger } from './logger.js';
|
|
6
|
+
|
|
7
|
+
const createWebauthnCredential = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
8
|
+
if (!browserSupportsWebAuthn()) {
|
|
9
|
+
throw new WebauthnNotSupportedError();
|
|
10
|
+
}
|
|
11
|
+
let attestationResp;
|
|
12
|
+
try {
|
|
13
|
+
attestationResp = yield startRegistration(options);
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
logger.debug('Failed to create webauthn credential', error);
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
return attestationResp;
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export { createWebauthnCredential };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
class WebauthnNotSupportedError extends Error {
|
|
7
|
+
constructor() {
|
|
8
|
+
super('Webauthn is not supported on this device');
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
exports.WebauthnNotSupportedError = WebauthnNotSupportedError;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
7
|
+
var browser = require('@simplewebauthn/browser');
|
|
8
|
+
var WebauthnNotSupportedError = require('./errors/WebauthnNotSupportedError.cjs');
|
|
9
|
+
var logger = require('./logger.cjs');
|
|
10
|
+
|
|
11
|
+
const verifyWebauthnCredential = (options) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
12
|
+
if (!browser.browserSupportsWebAuthn()) {
|
|
13
|
+
throw new WebauthnNotSupportedError.WebauthnNotSupportedError();
|
|
14
|
+
}
|
|
15
|
+
let assertionResp;
|
|
16
|
+
try {
|
|
17
|
+
assertionResp = yield browser.startAuthentication(options);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
logger.logger.debug('Failed to verify webauthn credential', error);
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
return assertionResp;
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
exports.verifyWebauthnCredential = verifyWebauthnCredential;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
3
|
+
import { browserSupportsWebAuthn, startAuthentication } from '@simplewebauthn/browser';
|
|
4
|
+
import { WebauthnNotSupportedError } from './errors/WebauthnNotSupportedError.js';
|
|
5
|
+
import { logger } from './logger.js';
|
|
6
|
+
|
|
7
|
+
const verifyWebauthnCredential = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
8
|
+
if (!browserSupportsWebAuthn()) {
|
|
9
|
+
throw new WebauthnNotSupportedError();
|
|
10
|
+
}
|
|
11
|
+
let assertionResp;
|
|
12
|
+
try {
|
|
13
|
+
assertionResp = yield startAuthentication(options);
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
logger.debug('Failed to verify webauthn credential', error);
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
return assertionResp;
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export { verifyWebauthnCredential };
|
package/src/types.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { AuthenticationResponseJSON, PublicKeyCredentialCreationOptionsJSON, PublicKeyCredentialRequestOptionsJSON, RegistrationResponseJSON } from '@simplewebauthn/types';
|
|
2
|
+
export type CreateWebauthnCredentialOptions = PublicKeyCredentialCreationOptionsJSON;
|
|
3
|
+
export type CreateWebauthnCredentialsResponse = RegistrationResponseJSON;
|
|
4
|
+
export type VerifyWebauthnCredentialOptions = PublicKeyCredentialRequestOptionsJSON;
|
|
5
|
+
export type VerifyWebauthnCredentialsResponse = AuthenticationResponseJSON;
|