@dfns/sdk-browser 0.8.28 → 0.8.30

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dfns/sdk-browser",
3
- "version": "0.8.28",
3
+ "version": "0.8.30",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/dfns/dfns-sdk-ts.git",
@@ -11,7 +11,7 @@
11
11
  "cross-fetch": "^3.1.6"
12
12
  },
13
13
  "peerDependencies": {
14
- "@dfns/sdk": "0.8.28"
14
+ "@dfns/sdk": "0.8.30"
15
15
  },
16
16
  "main": "./index.js",
17
17
  "type": "commonjs",
package/signers/key.d.ts CHANGED
@@ -6,5 +6,5 @@ export declare class BrowserKeySigner implements CredentialSigner<KeyAssertion>,
6
6
  keyPair: CryptoKeyPair;
7
7
  });
8
8
  create(challenge: UserRegistrationChallenge): Promise<KeyAttestation>;
9
- sign(challenge: UserActionChallenge): Promise<KeyAssertion>;
9
+ sign(challenge: Pick<UserActionChallenge, 'challenge' | 'allowCredentials'>): Promise<KeyAssertion>;
10
10
  }
package/signers/key.js CHANGED
@@ -52,9 +52,11 @@ class BrowserKeySigner {
52
52
  if (credId === undefined || credId === '') {
53
53
  throw new sdk_1.DfnsError(-1, 'credId is needed to sign');
54
54
  }
55
- const allowedCredId = challenge.allowCredentials.key.map((cred) => cred.id);
56
- if (!allowedCredId.includes(credId)) {
57
- throw new sdk_1.DfnsError(-1, `${credId} does not match allowed credentials: ${allowedCredId}`);
55
+ if (challenge.allowCredentials) {
56
+ const allowedCredId = challenge.allowCredentials.key.map((cred) => cred.id);
57
+ if (!allowedCredId.includes(credId)) {
58
+ throw new sdk_1.DfnsError(-1, `${credId} does not match allowed credentials: ${allowedCredId}`);
59
+ }
58
60
  }
59
61
  const clientData = JSON.stringify({
60
62
  type: 'key.get',
@@ -16,7 +16,7 @@ class WebAuthnSigner {
16
16
  const response = await navigator.credentials.get({
17
17
  publicKey: {
18
18
  challenge: buffer_1.Buffer.from(challenge.challenge),
19
- allowCredentials: challenge.allowCredentials.webauthn.map(({ id, type }) => ({
19
+ allowCredentials: challenge.allowCredentials?.webauthn.map(({ id, type }) => ({
20
20
  id: (0, utils_1.fromBase64Url)(id).buffer,
21
21
  type,
22
22
  })),