shogun-core 6.3.2 → 6.3.4
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/dist/browser/shogun-core.js +22 -17
- package/dist/browser/shogun-core.js.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/plugins/webauthn/webauthn.js +1 -1
- package/dist/src/plugins/webauthn/webauthnPlugin.js +21 -16
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Import polyfills FIRST before any other imports
|
|
2
2
|
// This ensures Buffer and other Node.js polyfills are available
|
|
3
|
-
import "./polyfills";
|
|
3
|
+
import "./polyfills.js";
|
|
4
4
|
import { ShogunCore } from "./core.js";
|
|
5
5
|
import { RxJS, crypto, derive, GunErrors, DataBase } from "./gundb/db.js";
|
|
6
6
|
// Gun and SEA imports removed - users should import them directly from 'gun' package
|
|
@@ -77,7 +77,7 @@ import { deriveCredentialsFromMnemonic } from "../../utils/seedPhrase.js";
|
|
|
77
77
|
var DEFAULT_CONFIG = {
|
|
78
78
|
rpName: "Shogun Wallet",
|
|
79
79
|
timeout: 60000,
|
|
80
|
-
userVerification: "
|
|
80
|
+
userVerification: "required",
|
|
81
81
|
attestation: "none",
|
|
82
82
|
authenticatorAttachment: "platform",
|
|
83
83
|
requireResidentKey: false,
|
|
@@ -496,11 +496,13 @@ var WebauthnPlugin = /** @class */ (function (_super) {
|
|
|
496
496
|
*/
|
|
497
497
|
WebauthnPlugin.prototype.login = function (username) {
|
|
498
498
|
return __awaiter(this, void 0, void 0, function () {
|
|
499
|
-
var core,
|
|
499
|
+
var core, credentials_1, authenticator, error_8;
|
|
500
|
+
var _this = this;
|
|
501
|
+
var _a;
|
|
500
502
|
return __generator(this, function (_b) {
|
|
501
503
|
switch (_b.label) {
|
|
502
504
|
case 0:
|
|
503
|
-
_b.trys.push([0,
|
|
505
|
+
_b.trys.push([0, 5, , 6]);
|
|
504
506
|
core = this.assertInitialized();
|
|
505
507
|
if (!username) {
|
|
506
508
|
throw new Error("Username required for WebAuthn login");
|
|
@@ -508,22 +510,25 @@ var WebauthnPlugin = /** @class */ (function (_super) {
|
|
|
508
510
|
if (!this.isSupported()) {
|
|
509
511
|
throw new Error("WebAuthn is not supported by this browser");
|
|
510
512
|
}
|
|
511
|
-
return [4 /*yield*/, this.
|
|
513
|
+
return [4 /*yield*/, this.generateCredentials(username, null, true)];
|
|
512
514
|
case 1:
|
|
513
|
-
|
|
514
|
-
if (!
|
|
515
|
-
|
|
516
|
-
case 2: return [2 /*return*/, _b.sent()];
|
|
517
|
-
case 3: return [4 /*yield*/, this.generateCredentials(username, null, true)];
|
|
518
|
-
case 4:
|
|
519
|
-
credentials = _b.sent();
|
|
520
|
-
if (!(credentials === null || credentials === void 0 ? void 0 : credentials.success)) {
|
|
521
|
-
throw new Error((credentials === null || credentials === void 0 ? void 0 : credentials.error) || "WebAuthn verification failed");
|
|
515
|
+
credentials_1 = _b.sent();
|
|
516
|
+
if (!(credentials_1 === null || credentials_1 === void 0 ? void 0 : credentials_1.success) || !credentials_1.key) {
|
|
517
|
+
throw new Error((credentials_1 === null || credentials_1 === void 0 ? void 0 : credentials_1.error) || "WebAuthn verification failed");
|
|
522
518
|
}
|
|
519
|
+
// Ensure we mark the authentication method before attempting login
|
|
523
520
|
core.setAuthMethod("webauthn");
|
|
524
|
-
return [
|
|
525
|
-
|
|
526
|
-
|
|
521
|
+
if (!core.authenticate) return [3 /*break*/, 3];
|
|
522
|
+
authenticator = function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
523
|
+
return [2 /*return*/, credentials_1];
|
|
524
|
+
}); }); };
|
|
525
|
+
return [4 /*yield*/, core.authenticate(username, authenticator, (_a = credentials_1.key) === null || _a === void 0 ? void 0 : _a.pub)];
|
|
526
|
+
case 2: return [2 /*return*/, _b.sent()];
|
|
527
|
+
case 3: return [4 /*yield*/, core.login(username, "", credentials_1.key)];
|
|
528
|
+
case 4:
|
|
529
|
+
// Login using the derived SEA pair, consistent with the signup flow
|
|
530
|
+
return [2 /*return*/, _b.sent()];
|
|
531
|
+
case 5:
|
|
527
532
|
error_8 = _b.sent();
|
|
528
533
|
console.error("Error during WebAuthn login: ".concat(error_8));
|
|
529
534
|
// Log but do not depend on handler return value
|
|
@@ -532,7 +537,7 @@ var WebauthnPlugin = /** @class */ (function (_super) {
|
|
|
532
537
|
success: false,
|
|
533
538
|
error: error_8.message || "Error during WebAuthn login",
|
|
534
539
|
}];
|
|
535
|
-
case
|
|
540
|
+
case 6: return [2 /*return*/];
|
|
536
541
|
}
|
|
537
542
|
});
|
|
538
543
|
});
|