@sphereon/ssi-sdk-ext.did-resolver-key 0.28.1-feature.esm.cjs.9 → 0.28.1-feature.oyd.cmsm.improv.16
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/drivers/bls12381g2.d.ts +8 -0
- package/dist/drivers/bls12381g2.d.ts.map +1 -0
- package/dist/drivers/bls12381g2.js +49 -0
- package/dist/drivers/bls12381g2.js.map +1 -0
- package/dist/drivers/ed25519.d.ts +8 -0
- package/dist/drivers/ed25519.d.ts.map +1 -0
- package/dist/drivers/ed25519.js +118 -0
- package/dist/drivers/ed25519.js.map +1 -0
- package/dist/drivers/jwk.jcs.d.ts +8 -0
- package/dist/drivers/jwk.jcs.d.ts.map +1 -0
- package/dist/drivers/jwk.jcs.js +23 -0
- package/dist/drivers/jwk.jcs.js.map +1 -0
- package/dist/drivers/secp256k1.d.ts +8 -0
- package/dist/drivers/secp256k1.d.ts.map +1 -0
- package/dist/drivers/secp256k1.js +49 -0
- package/dist/drivers/secp256k1.js.map +1 -0
- package/dist/drivers/secp256r1.d.ts +24 -0
- package/dist/drivers/secp256r1.d.ts.map +1 -0
- package/dist/drivers/secp256r1.js +99 -0
- package/dist/drivers/secp256r1.js.map +1 -0
- package/dist/drivers/secp384r1.d.ts +24 -0
- package/dist/drivers/secp384r1.d.ts.map +1 -0
- package/dist/drivers/secp384r1.js +99 -0
- package/dist/drivers/secp384r1.js.map +1 -0
- package/dist/drivers/secp521r1.d.ts +23 -0
- package/dist/drivers/secp521r1.d.ts.map +1 -0
- package/dist/drivers/secp521r1.js +87 -0
- package/dist/drivers/secp521r1.js.map +1 -0
- package/dist/index.d.ts +5 -18
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +87 -485
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +14 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/package.json +10 -22
- package/src/__tests__/__snapshots__/secp256r1.test.ts.snap +1 -249
- package/src/__tests__/__snapshots__/secp384r1.test.ts.snap +1 -249
- package/src/__tests__/__snapshots__/secp521r1.test.ts.snap +1 -280
- package/src/__tests__/key_resolver.test.ts +1 -2
- package/src/__tests__/secp256r1.test.ts +4 -4
- package/src/__tests__/secp384r1.test.ts +3 -3
- package/src/__tests__/secp521r1.test.ts +2 -3
- package/src/drivers/bls12381g2.ts +2 -3
- package/src/drivers/ed25519.ts +5 -7
- package/src/drivers/secp256k1.ts +2 -3
- package/src/drivers/secp256r1.ts +5 -5
- package/src/drivers/secp384r1.ts +2 -3
- package/src/drivers/secp521r1.ts +2 -3
- package/src/index.ts +1 -3
- package/dist/index.cjs +0 -492
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -21
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Brent Shambaugh <brent.shambaugh@gmail.com>. 2021.
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.keyToDidDoc = keyToDidDoc;
|
|
28
|
+
exports.pubKeyBytesToXY = pubKeyBytesToXY;
|
|
29
|
+
const u8a = __importStar(require("uint8arrays"));
|
|
30
|
+
const nist_weierstrauss = __importStar(require("nist-weierstrauss"));
|
|
31
|
+
/**
|
|
32
|
+
* Constructs the document based on the method key
|
|
33
|
+
*/
|
|
34
|
+
function keyToDidDoc({ pubKeyBytes, fingerprint }) {
|
|
35
|
+
const did = `did:key:${fingerprint}`;
|
|
36
|
+
const keyId = `${did}#${fingerprint}`;
|
|
37
|
+
const key = pubKeyBytesToXY(pubKeyBytes);
|
|
38
|
+
return {
|
|
39
|
+
id: did,
|
|
40
|
+
verificationMethod: [
|
|
41
|
+
{
|
|
42
|
+
id: keyId,
|
|
43
|
+
type: 'JsonWebKey2020',
|
|
44
|
+
controller: did,
|
|
45
|
+
publicKeyJwk: {
|
|
46
|
+
kty: 'EC',
|
|
47
|
+
crv: 'P-521',
|
|
48
|
+
x: key.xm,
|
|
49
|
+
y: key.ym,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
authentication: [keyId],
|
|
54
|
+
assertionMethod: [keyId],
|
|
55
|
+
capabilityDelegation: [keyId],
|
|
56
|
+
capabilityInvocation: [keyId],
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
*
|
|
61
|
+
* @param pubKeyBytes - public key as compressed with 0x02 prefix if even and 0x03 prefix if odd.
|
|
62
|
+
* @returns point x,y with coordinates as multibase encoded base64urls
|
|
63
|
+
*
|
|
64
|
+
* See the the did:key specification: https://w3c-ccg.github.io/did-method-key/#p-521.
|
|
65
|
+
* For compression see: https://tools.ietf.org/id/draft-jivsov-ecc-compact-05.html#rfc.section.3
|
|
66
|
+
* @throws TypeError: input cannot be null or undefined.
|
|
67
|
+
* @throws Error: Unexpected pubKeyBytes
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
70
|
+
function pubKeyBytesToXY(pubKeyBytes) {
|
|
71
|
+
if (!nist_weierstrauss.nist_weierstrauss_common.testUint8Array(pubKeyBytes)) {
|
|
72
|
+
throw new TypeError('input must be a Uint8Array');
|
|
73
|
+
}
|
|
74
|
+
const publicKeyHex = nist_weierstrauss.nist_weierstrauss_common.pubKeyBytesToHex(pubKeyBytes);
|
|
75
|
+
// compressed p-521 key, SEC format
|
|
76
|
+
// publicKeyHex.length / 2.0 = 67.0 bytes
|
|
77
|
+
if (132 <= publicKeyHex.length && publicKeyHex.length <= 134) {
|
|
78
|
+
if (publicKeyHex.slice(0, 2) == '03' || publicKeyHex.slice(0, 2) == '02') {
|
|
79
|
+
const publicKey = u8a.fromString(publicKeyHex, 'base16');
|
|
80
|
+
const point = nist_weierstrauss.secp521r1.ECPointDecompress(publicKey);
|
|
81
|
+
return nist_weierstrauss.nist_weierstrauss_common.publicKeyIntToXY(point);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
throw new Error('Unexpected pubKeyBytes');
|
|
85
|
+
}
|
|
86
|
+
exports.default = { keyToDidDoc };
|
|
87
|
+
//# sourceMappingURL=secp521r1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secp521r1.js","sourceRoot":"","sources":["../../src/drivers/secp521r1.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;;;;;;;;;;;;;;;;;;;;;;;AAWrD,kCAwBC;AAaD,0CAiBC;AA/DD,iDAAkC;AAElC,qEAAsD;AAItD;;GAEG;AACH,SAAgB,WAAW,CAAC,EAAE,WAAW,EAAE,WAAW,EAAmB;IACvE,MAAM,GAAG,GAAG,WAAW,WAAW,EAAE,CAAA;IACpC,M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iBAAiB,CAAC,SAAS,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAA;YACtE,OAAO,iBAAiB,CAAC,wBAAwB,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAA;QAC3E,CAAC;IACH,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAA;AAC3C,CAAC;AAED,kBAAe,EAAE,WAAW,EAAE,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,21 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
declare const
|
|
4
|
-
declare const DID_JSON = "application/did+json";
|
|
5
|
-
type PublicKeyFormat = 'JsonWebKey2020' | 'Ed25519VerificationKey2018' | 'X25519KeyAgreementKey2019' | 'Ed25519VerificationKey2020' | 'X25519KeyAgreementKey2020' | 'Multikey';
|
|
6
|
-
interface KeyToDidDocArgs {
|
|
7
|
-
pubKeyBytes: Uint8Array;
|
|
8
|
-
fingerprint: string;
|
|
9
|
-
contentType?: string;
|
|
10
|
-
options?: DIDKeyResolutionOptions;
|
|
11
|
-
}
|
|
12
|
-
interface DIDKeyResolutionOptions extends DIDResolutionOptions {
|
|
13
|
-
publicKeyFormat?: PublicKeyFormat;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
declare const getResolver: () => ResolverRegistry;
|
|
1
|
+
import { ResolverRegistry } from 'did-resolver';
|
|
2
|
+
export * from './types';
|
|
3
|
+
export declare const getResolver: () => ResolverRegistry;
|
|
17
4
|
declare const _default: {
|
|
18
5
|
getResolver: () => ResolverRegistry;
|
|
19
6
|
};
|
|
20
|
-
|
|
21
|
-
|
|
7
|
+
export default _default;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAA8C,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAI3F,cAAc,SAAS,CAAA;AAYvB,eAAO,MAAM,WAAW,QAAO,gBAuC9B,CAAA;;uBAvC8B,gBAAgB;;AAwC/C,wBAA8B"}
|