@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.
@@ -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 = this.userCredentials[userId]) !== null && _a !== void 0 ? _a : {};
46
+ var map = (_a = InMemoryCredentialsHandler.userCredentials[userId]) !== null && _a !== void 0 ? _a : {};
47
47
  f(map);
48
- this.userCredentials[userId] = map;
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 = this.userCredentials[userId]) !== null && _a !== void 0 ? _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;
@@ -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
- var types_ts_1 = require("./types.cjs");
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
  /**
@@ -1,4 +1,4 @@
1
- import { CredentialsHandler } from "./types.ts";
1
+ import type { CredentialsHandler } from "./types.ts";
2
2
  export declare class InMemoryCredentialsHandler implements CredentialsHandler {
3
3
  private static userCredentials;
4
4
  private static tryMutate;
@@ -2,16 +2,16 @@ export class InMemoryCredentialsHandler {
2
2
  static userCredentials = {};
3
3
  static tryMutate(userId, f) {
4
4
  try {
5
- let map = this.userCredentials[userId] ?? {};
5
+ const map = InMemoryCredentialsHandler.userCredentials[userId] ?? {};
6
6
  f(map);
7
- this.userCredentials[userId] = map;
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 = this.userCredentials[userId] ?? {};
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) {
@@ -1,4 +1,5 @@
1
- import { AddressGenerator } from "@virtonetwork/signer";
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
- export { InMemoryCredentialsHandler, CredentialsHandler };
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
- import { Assertion } from "./types.js";
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"));
@@ -1,6 +1,6 @@
1
- import { AuthorityId, DeviceId, HashedUserId } from "@virtonetwork/signer";
2
- import { Binary, HexString } from "@polkadot-api/substrate-bindings";
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
@@ -1,4 +1,4 @@
1
- import { Bin } from "@polkadot-api/substrate-bindings";
1
+ import { Bin, } from "@polkadot-api/substrate-bindings";
2
2
  import { Struct, u32 } from "scale-ts";
3
3
  const AttestationMeta = Struct({
4
4
  authority_id: Bin(32),
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.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": "node --loader ts-node/esm test/test.ts",
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.0",
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
  }
@@ -1 +0,0 @@
1
- {"type": "commonjs"}