@dfns/sdk-keysigner 0.8.29 → 0.8.31
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/index.d.ts +3 -1
- package/index.js +6 -3
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { CredentialSigner, KeyAssertion, UserActionChallenge } from '@dfns/sdk';
|
|
2
2
|
export declare class AsymmetricKeySigner implements CredentialSigner<KeyAssertion> {
|
|
3
3
|
private options;
|
|
4
|
+
readonly useClientChallenge?: boolean;
|
|
4
5
|
constructor(options: {
|
|
5
6
|
credId: string;
|
|
6
7
|
privateKey: string;
|
|
7
8
|
algorithm?: string;
|
|
9
|
+
useClientChallenge?: boolean;
|
|
8
10
|
});
|
|
9
|
-
sign(challenge: UserActionChallenge): Promise<KeyAssertion>;
|
|
11
|
+
sign(challenge: Pick<UserActionChallenge, 'challenge' | 'allowCredentials'>): Promise<KeyAssertion>;
|
|
10
12
|
}
|
package/index.js
CHANGED
|
@@ -40,12 +40,15 @@ const utils_1 = require("@dfns/sdk/utils");
|
|
|
40
40
|
class AsymmetricKeySigner {
|
|
41
41
|
constructor(options) {
|
|
42
42
|
this.options = options;
|
|
43
|
+
this.useClientChallenge = options.useClientChallenge;
|
|
43
44
|
}
|
|
44
45
|
async sign(challenge) {
|
|
45
46
|
const { credId, privateKey, algorithm } = this.options;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
if (challenge.allowCredentials) {
|
|
48
|
+
const allowedCredId = challenge.allowCredentials.key.map((cred) => cred.id);
|
|
49
|
+
if (!allowedCredId.includes(credId)) {
|
|
50
|
+
throw new sdk_1.DfnsError(-1, `${credId} does not match allowed credentials: ${allowedCredId}`);
|
|
51
|
+
}
|
|
49
52
|
}
|
|
50
53
|
const clientData = Buffer.from(JSON.stringify({
|
|
51
54
|
type: 'key.get',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dfns/sdk-keysigner",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.31",
|
|
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.
|
|
14
|
+
"@dfns/sdk": "0.8.31"
|
|
15
15
|
},
|
|
16
16
|
"main": "./index.js",
|
|
17
17
|
"type": "commonjs",
|