@virtonetwork/authenticators-webauthn 1.2.2 → 1.2.3
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/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 +7 -6
- package/dist/cjs/package.json +0 -1
|
@@ -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,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@virtonetwork/authenticators-webauthn",
|
|
3
3
|
"description": "An Authenticator compatible with KreivoPassSigner that uses the WebAuthn standard",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"browser": "./dist/esm/index.js",
|
|
21
21
|
"types": "./dist/esm/index.d.ts",
|
|
22
22
|
"scripts": {
|
|
23
|
-
"test": "
|
|
23
|
+
"test": "tsx test/test.ts",
|
|
24
24
|
"build": "tsc && tsc -p tsconfig.cjs.json && node ../../scripts/fix-cjs.js dist/cjs",
|
|
25
25
|
"prepack": "npm run build"
|
|
26
26
|
},
|
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@simplewebauthn/server": "^13.1.1",
|
|
39
|
-
"@virtonetwork/signer": "^1.2.
|
|
39
|
+
"@virtonetwork/signer": "^1.2.4",
|
|
40
40
|
"nid-webauthn-emulator": "^0.2.4"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
+
"@levischuck/tiny-cbor": "^0.2.11",
|
|
43
44
|
"esmock": "^2.7.0",
|
|
44
|
-
"sinon": "^20.0.0"
|
|
45
|
-
"ts-node": "^10.9.2"
|
|
45
|
+
"sinon": "^20.0.0"
|
|
46
46
|
},
|
|
47
47
|
"repository": {
|
|
48
48
|
"url": "https://github.com/virto-network/papi-signers",
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
},
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"registry": "https://registry.npmjs.org/",
|
|
53
|
-
"access": "public"
|
|
53
|
+
"access": "public",
|
|
54
|
+
"provenance": true
|
|
54
55
|
}
|
|
55
56
|
}
|
package/dist/cjs/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type": "commonjs"}
|