@virtonetwork/authenticators-webauthn 1.2.2 β 1.2.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/README.md +3 -1
- package/dist/cjs/in-memory-credentials-handler.cjs +3 -3
- package/dist/cjs/index.cjs +18 -2
- package/dist/esm/in-memory-credentials-handler.d.ts +1 -1
- package/dist/esm/in-memory-credentials-handler.js +3 -3
- package/dist/esm/index.d.ts +5 -6
- package/dist/esm/index.js +18 -2
- package/dist/esm/types.d.ts +3 -3
- package/dist/esm/types.js +1 -1
- package/package.json +9 -7
- package/dist/cjs/package.json +0 -1
package/README.md
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
# WebAuthn Authenticator
|
|
1
|
+
# WebAuthn Authenticator
|
|
2
|
+
|
|
3
|
+
[**π Documentation**](https://virtonetwork.github.io/papi-signers/guide/webauthn)
|
|
2
4
|
|
|
3
5
|
A TypeScript helper that wires **passkeys** (WebAuthn resident credentials) to the [@virtonetwork/signer](https://github.com/virto-network/papi-signers) stack. It exposes a single class, `WebAuthn`, that fulfils the `Authenticator<number>` interface used by `PassSigner`.
|
|
4
6
|
The implementation is **browserβonly** and keeps all credential mapping in the callerβs hands β perfect for SPAs or wallet extensions that already manage users.
|
|
@@ -43,9 +43,9 @@ var InMemoryCredentialsHandler = /** @class */ (function () {
|
|
|
43
43
|
InMemoryCredentialsHandler.tryMutate = function (userId, f) {
|
|
44
44
|
var _a;
|
|
45
45
|
try {
|
|
46
|
-
var map = (_a =
|
|
46
|
+
var map = (_a = InMemoryCredentialsHandler.userCredentials[userId]) !== null && _a !== void 0 ? _a : {};
|
|
47
47
|
f(map);
|
|
48
|
-
|
|
48
|
+
InMemoryCredentialsHandler.userCredentials[userId] = map;
|
|
49
49
|
}
|
|
50
50
|
catch (_b) {
|
|
51
51
|
/* on error, no-op */
|
|
@@ -53,7 +53,7 @@ var InMemoryCredentialsHandler = /** @class */ (function () {
|
|
|
53
53
|
};
|
|
54
54
|
InMemoryCredentialsHandler.credentialIds = function (userId) {
|
|
55
55
|
var _a;
|
|
56
|
-
var credentials = (_a =
|
|
56
|
+
var credentials = (_a = InMemoryCredentialsHandler.userCredentials[userId]) !== null && _a !== void 0 ? _a : {};
|
|
57
57
|
return Object.entries(credentials).map(function (_a) {
|
|
58
58
|
var credential = _a[1];
|
|
59
59
|
return new Uint8Array(credential.rawId).buffer;
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -37,11 +37,27 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.WebAuthn = exports.KREIVO_AUTHORITY_ID = exports.InMemoryCredentialsHandler = void 0;
|
|
40
|
-
var signer_1 = require("@virtonetwork/signer");
|
|
41
40
|
var substrate_bindings_1 = require("@polkadot-api/substrate-bindings");
|
|
42
|
-
|
|
41
|
+
/**
|
|
42
|
+
* WebAuthn passβkey authenticator for Virto Network.
|
|
43
|
+
*
|
|
44
|
+
* Exposes a browserβside implementation of {@link Authenticator} that creates,
|
|
45
|
+
* stores, and uses WebAuthn resident credentials ("passkeys") while producing
|
|
46
|
+
* SCALEβencoded data structures understood by the Kreivo signer pallet.
|
|
47
|
+
*
|
|
48
|
+
* Responsibilities
|
|
49
|
+
* βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
50
|
+
* β’ Derive a deterministic `deviceId` from the raw credential id
|
|
51
|
+
* β’ Emit `TAttestation<number>` during registration
|
|
52
|
+
* β’ Emit `TPassAuthenticate` during authentication
|
|
53
|
+
* β’ Never persist the credential mapping; that is delegated to the caller
|
|
54
|
+
*
|
|
55
|
+
* @module WebAuthn
|
|
56
|
+
*/
|
|
57
|
+
var signer_1 = require("@virtonetwork/signer");
|
|
43
58
|
var in_memory_credentials_handler_ts_1 = require("./in-memory-credentials-handler.cjs");
|
|
44
59
|
Object.defineProperty(exports, "InMemoryCredentialsHandler", { enumerable: true, get: function () { return in_memory_credentials_handler_ts_1.InMemoryCredentialsHandler; } });
|
|
60
|
+
var types_ts_1 = require("./types.cjs");
|
|
45
61
|
/** Fixed authority id for Kreivo passβkey attestors. */
|
|
46
62
|
exports.KREIVO_AUTHORITY_ID = substrate_bindings_1.Binary.fromText("kreivo_p".padEnd(32, "\0"));
|
|
47
63
|
/**
|
|
@@ -2,16 +2,16 @@ export class InMemoryCredentialsHandler {
|
|
|
2
2
|
static userCredentials = {};
|
|
3
3
|
static tryMutate(userId, f) {
|
|
4
4
|
try {
|
|
5
|
-
|
|
5
|
+
const map = InMemoryCredentialsHandler.userCredentials[userId] ?? {};
|
|
6
6
|
f(map);
|
|
7
|
-
|
|
7
|
+
InMemoryCredentialsHandler.userCredentials[userId] = map;
|
|
8
8
|
}
|
|
9
9
|
catch {
|
|
10
10
|
/* on error, no-op */
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
static credentialIds(userId) {
|
|
14
|
-
const credentials =
|
|
14
|
+
const credentials = InMemoryCredentialsHandler.userCredentials[userId] ?? {};
|
|
15
15
|
return Object.entries(credentials).map(([, credential]) => new Uint8Array(credential.rawId).buffer);
|
|
16
16
|
}
|
|
17
17
|
async onCreatedCredentials(userId, credential) {
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Binary } from "@polkadot-api/substrate-bindings";
|
|
2
|
+
import type { Challenger, TPassAuthenticate } from "@virtonetwork/signer";
|
|
2
3
|
/**
|
|
3
4
|
* WebAuthn passβkey authenticator for Virto Network.
|
|
4
5
|
*
|
|
@@ -15,12 +16,10 @@ import { AddressGenerator } from "@virtonetwork/signer";
|
|
|
15
16
|
*
|
|
16
17
|
* @module WebAuthn
|
|
17
18
|
*/
|
|
18
|
-
import { Authenticator } from "@virtonetwork/signer";
|
|
19
|
-
import { Binary } from "@polkadot-api/substrate-bindings";
|
|
20
|
-
import type { Challenger, TPassAuthenticate } from "@virtonetwork/signer";
|
|
21
|
-
import type { CredentialsHandler, TAttestation } from "./types.ts";
|
|
19
|
+
import { type AddressGenerator, type Authenticator } from "@virtonetwork/signer";
|
|
22
20
|
import { InMemoryCredentialsHandler } from "./in-memory-credentials-handler.ts";
|
|
23
|
-
|
|
21
|
+
import type { CredentialsHandler, TAttestation } from "./types.ts";
|
|
22
|
+
export { InMemoryCredentialsHandler, type CredentialsHandler };
|
|
24
23
|
/** Fixed authority id for Kreivo passβkey attestors. */
|
|
25
24
|
export declare const KREIVO_AUTHORITY_ID: Binary;
|
|
26
25
|
/**
|
package/dist/esm/index.js
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
1
|
-
import { kreivoPassDefaultAddressGenerator, } from "@virtonetwork/signer";
|
|
2
1
|
import { Binary, Blake2256 } from "@polkadot-api/substrate-bindings";
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* WebAuthn passβkey authenticator for Virto Network.
|
|
4
|
+
*
|
|
5
|
+
* Exposes a browserβside implementation of {@link Authenticator} that creates,
|
|
6
|
+
* stores, and uses WebAuthn resident credentials ("passkeys") while producing
|
|
7
|
+
* SCALEβencoded data structures understood by the Kreivo signer pallet.
|
|
8
|
+
*
|
|
9
|
+
* Responsibilities
|
|
10
|
+
* βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
11
|
+
* β’ Derive a deterministic `deviceId` from the raw credential id
|
|
12
|
+
* β’ Emit `TAttestation<number>` during registration
|
|
13
|
+
* β’ Emit `TPassAuthenticate` during authentication
|
|
14
|
+
* β’ Never persist the credential mapping; that is delegated to the caller
|
|
15
|
+
*
|
|
16
|
+
* @module WebAuthn
|
|
17
|
+
*/
|
|
18
|
+
import { kreivoPassDefaultAddressGenerator, } from "@virtonetwork/signer";
|
|
4
19
|
import { InMemoryCredentialsHandler } from "./in-memory-credentials-handler.js";
|
|
20
|
+
import { Assertion } from "./types.js";
|
|
5
21
|
export { InMemoryCredentialsHandler };
|
|
6
22
|
/** Fixed authority id for Kreivo passβkey attestors. */
|
|
7
23
|
export const KREIVO_AUTHORITY_ID = Binary.fromText("kreivo_p".padEnd(32, "\0"));
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { Codec } from "scale-ts";
|
|
1
|
+
import { type Binary, type HexString } from "@polkadot-api/substrate-bindings";
|
|
2
|
+
import type { AuthorityId, DeviceId, HashedUserId } from "@virtonetwork/signer";
|
|
3
|
+
import { type Codec } from "scale-ts";
|
|
4
4
|
export type BlockHash = HexString;
|
|
5
5
|
export type hashedUserId = (userId: string) => Promise<Uint8Array>;
|
|
6
6
|
export interface CredentialsHandler {
|
package/dist/esm/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@virtonetwork/authenticators-webauthn",
|
|
3
3
|
"description": "An Authenticator compatible with KreivoPassSigner that uses the WebAuthn standard",
|
|
4
|
-
"
|
|
4
|
+
"homepage": "https://virtonetwork.github.io/papi-signers/guide/webauthn",
|
|
5
|
+
"version": "1.2.4",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"files": [
|
|
7
8
|
"dist"
|
|
@@ -20,7 +21,7 @@
|
|
|
20
21
|
"browser": "./dist/esm/index.js",
|
|
21
22
|
"types": "./dist/esm/index.d.ts",
|
|
22
23
|
"scripts": {
|
|
23
|
-
"test": "
|
|
24
|
+
"test": "tsx test/test.ts",
|
|
24
25
|
"build": "tsc && tsc -p tsconfig.cjs.json && node ../../scripts/fix-cjs.js dist/cjs",
|
|
25
26
|
"prepack": "npm run build"
|
|
26
27
|
},
|
|
@@ -36,13 +37,13 @@
|
|
|
36
37
|
],
|
|
37
38
|
"dependencies": {
|
|
38
39
|
"@simplewebauthn/server": "^13.1.1",
|
|
39
|
-
"@virtonetwork/signer": "^1.
|
|
40
|
+
"@virtonetwork/signer": "^1.3.0",
|
|
40
41
|
"nid-webauthn-emulator": "^0.2.4"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
44
|
+
"@levischuck/tiny-cbor": "^0.2.11",
|
|
43
45
|
"esmock": "^2.7.0",
|
|
44
|
-
"sinon": "^20.0.0"
|
|
45
|
-
"ts-node": "^10.9.2"
|
|
46
|
+
"sinon": "^20.0.0"
|
|
46
47
|
},
|
|
47
48
|
"repository": {
|
|
48
49
|
"url": "https://github.com/virto-network/papi-signers",
|
|
@@ -50,6 +51,7 @@
|
|
|
50
51
|
},
|
|
51
52
|
"publishConfig": {
|
|
52
53
|
"registry": "https://registry.npmjs.org/",
|
|
53
|
-
"access": "public"
|
|
54
|
+
"access": "public",
|
|
55
|
+
"provenance": true
|
|
54
56
|
}
|
|
55
|
-
}
|
|
57
|
+
}
|
package/dist/cjs/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type": "commonjs"}
|