@sphereon/ssi-sdk-ext.key-utils 0.14.1-next.7 → 0.14.1-unstable.34

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.
@@ -1,7 +1,7 @@
1
- export type HashAlgorithm = 'SHA-256' | 'SHA-512';
2
- export type TDigestMethod = (input: string) => string;
3
- export declare const digestMethodParams: (hashAlgorithm: HashAlgorithm) => {
4
- hashAlgorithm: HashAlgorithm;
5
- digestMethod: TDigestMethod;
6
- };
1
+ export type HashAlgorithm = 'SHA-256' | 'SHA-512';
2
+ export type TDigestMethod = (input: string) => string;
3
+ export declare const digestMethodParams: (hashAlgorithm: HashAlgorithm) => {
4
+ hashAlgorithm: HashAlgorithm;
5
+ digestMethod: TDigestMethod;
6
+ };
7
7
  //# sourceMappingURL=digest-methods.d.ts.map
@@ -1,95 +1,95 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.digestMethodParams = void 0;
27
- const sha256_1 = require("@stablelib/sha256");
28
- const sha512_1 = require("@stablelib/sha512");
29
- const u8a = __importStar(require("uint8arrays"));
30
- const digestMethodParams = (hashAlgorithm) => {
31
- if (hashAlgorithm === 'SHA-256') {
32
- return { hashAlgorithm: 'SHA-256', digestMethod: sha256DigestMethod };
33
- }
34
- else {
35
- return { hashAlgorithm: 'SHA-512', digestMethod: sha512DigestMethod };
36
- }
37
- };
38
- exports.digestMethodParams = digestMethodParams;
39
- const sha256DigestMethod = (input) => {
40
- return u8a.toString((0, sha256_1.hash)(u8a.fromString(input, 'utf-8')), 'base16');
41
- };
42
- const sha512DigestMethod = (input) => {
43
- return u8a.toString((0, sha512_1.hash)(u8a.fromString(input, 'utf-8')), 'base16');
44
- };
45
- /*
46
- // PKCS#1 (PSS) mask generation function
47
- function pss_mgf1_str(seed, len, hash) {
48
- var mask = '', i = 0;
49
-
50
- while (mask.length < len) {
51
- mask += hextorstr(hash(rstrtohex(seed + String.fromCharCode.apply(String, [
52
- (i & 0xff000000) >> 24,
53
- (i & 0x00ff0000) >> 16,
54
- (i & 0x0000ff00) >> 8,
55
- i & 0x000000ff]))));
56
- i += 1;
57
- }
58
-
59
- return mask;
60
- }
61
-
62
- */
63
- /*
64
-
65
- /!**
66
- * Generate mask of specified length.
67
- *
68
- * @param {String} seed The seed for mask generation.
69
- * @param maskLen Number of bytes to generate.
70
- * @return {String} The generated mask.
71
- *!/
72
- export const mgf1 = (dm: TDigestMethod, seed: string, maskLen: number) => {
73
- /!* 2. Let T be the empty octet string. *!/
74
- var t = new forge.util.ByteBuffer();
75
-
76
- /!* 3. For counter from 0 to ceil(maskLen / hLen), do the following: *!/
77
- var len = Math.ceil(maskLen / md.digestLength);
78
- for(var i = 0; i < len; i++) {
79
- /!* a. Convert counter to an octet string C of length 4 octets *!/
80
- var c = new forge.util.ByteBuffer();
81
- c.putInt32(i);
82
-
83
- /!* b. Concatenate the hash of the seed mgfSeed and C to the octet
84
- * string T: *!/
85
- md.start();
86
- md.update(seed + c.getBytes());
87
- t.putBuffer(md.digest());
88
- }
89
-
90
- /!* Output the leading maskLen octets of T as the octet string mask. *!/
91
- t.truncate(t.length() - maskLen);
92
- return t.getBytes();
93
- }
94
- */
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.digestMethodParams = void 0;
27
+ const sha256_1 = require("@stablelib/sha256");
28
+ const sha512_1 = require("@stablelib/sha512");
29
+ const u8a = __importStar(require("uint8arrays"));
30
+ const digestMethodParams = (hashAlgorithm) => {
31
+ if (hashAlgorithm === 'SHA-256') {
32
+ return { hashAlgorithm: 'SHA-256', digestMethod: sha256DigestMethod };
33
+ }
34
+ else {
35
+ return { hashAlgorithm: 'SHA-512', digestMethod: sha512DigestMethod };
36
+ }
37
+ };
38
+ exports.digestMethodParams = digestMethodParams;
39
+ const sha256DigestMethod = (input) => {
40
+ return u8a.toString((0, sha256_1.hash)(u8a.fromString(input, 'utf-8')), 'base16');
41
+ };
42
+ const sha512DigestMethod = (input) => {
43
+ return u8a.toString((0, sha512_1.hash)(u8a.fromString(input, 'utf-8')), 'base16');
44
+ };
45
+ /*
46
+ // PKCS#1 (PSS) mask generation function
47
+ function pss_mgf1_str(seed, len, hash) {
48
+ var mask = '', i = 0;
49
+
50
+ while (mask.length < len) {
51
+ mask += hextorstr(hash(rstrtohex(seed + String.fromCharCode.apply(String, [
52
+ (i & 0xff000000) >> 24,
53
+ (i & 0x00ff0000) >> 16,
54
+ (i & 0x0000ff00) >> 8,
55
+ i & 0x000000ff]))));
56
+ i += 1;
57
+ }
58
+
59
+ return mask;
60
+ }
61
+
62
+ */
63
+ /*
64
+
65
+ /!**
66
+ * Generate mask of specified length.
67
+ *
68
+ * @param {String} seed The seed for mask generation.
69
+ * @param maskLen Number of bytes to generate.
70
+ * @return {String} The generated mask.
71
+ *!/
72
+ export const mgf1 = (dm: TDigestMethod, seed: string, maskLen: number) => {
73
+ /!* 2. Let T be the empty octet string. *!/
74
+ var t = new forge.util.ByteBuffer();
75
+
76
+ /!* 3. For counter from 0 to ceil(maskLen / hLen), do the following: *!/
77
+ var len = Math.ceil(maskLen / md.digestLength);
78
+ for(var i = 0; i < len; i++) {
79
+ /!* a. Convert counter to an octet string C of length 4 octets *!/
80
+ var c = new forge.util.ByteBuffer();
81
+ c.putInt32(i);
82
+
83
+ /!* b. Concatenate the hash of the seed mgfSeed and C to the octet
84
+ * string T: *!/
85
+ md.start();
86
+ md.update(seed + c.getBytes());
87
+ t.putBuffer(md.digest());
88
+ }
89
+
90
+ /!* Output the leading maskLen octets of T as the octet string mask. *!/
91
+ t.truncate(t.length() - maskLen);
92
+ return t.getBytes();
93
+ }
94
+ */
95
95
  //# sourceMappingURL=digest-methods.js.map
@@ -1,44 +1,45 @@
1
- import { IAgentContext, IKey, IKeyManager } from '@veramo/core';
2
- import { JsonWebKey } from 'did-resolver';
3
- import { IImportProvidedOrGeneratedKeyArgs, JwkKeyUse, TKeyType } from './types';
4
- /**
5
- * Generates a random Private Hex Key for the specified key type
6
- * @param type The key type
7
- * @return The private key in Hex form
8
- */
9
- export declare const generatePrivateKeyHex: (type: TKeyType) => Promise<string>;
10
- /**
11
- * We optionally generate and then import our own keys.
12
- *
13
- * @param args The key arguments
14
- * @param context The Veramo agent context
15
- * @private
16
- */
17
- export declare function importProvidedOrGeneratedKey(args: IImportProvidedOrGeneratedKeyArgs & {
18
- kms: string;
19
- }, context: IAgentContext<IKeyManager>): Promise<IKey>;
20
- /**
21
- * Converts hex value to base64url
22
- * @param value hex value
23
- * @return Base64Url encoded value
24
- */
25
- export declare const hex2base64url: (value: string) => string;
26
- /**
27
- * Converts a public key in hex format to a JWK
28
- * @param publicKeyHex public key in hex
29
- * @param type The type of the key (Ed25519, Secp256k1/r1)
30
- * @param opts. Options, like the optional use for the key (sig/enc)
31
- * @return The JWK
32
- */
33
- export declare const toJwk: (publicKeyHex: string, type: TKeyType, opts?: {
34
- use?: JwkKeyUse;
35
- key?: IKey;
36
- }) => JsonWebKey;
37
- /**
38
- * Determines the use param based upon the key/signature type or supplied use value.
39
- *
40
- * @param type The key type
41
- * @param suppliedUse A supplied use. Will be used in case it is present
42
- */
43
- export declare const jwkDetermineUse: (type: TKeyType, suppliedUse?: JwkKeyUse) => JwkKeyUse | undefined;
1
+ import { IAgentContext, IKey, IKeyManager } from '@veramo/core';
2
+ import { JsonWebKey } from 'did-resolver';
3
+ import { IImportProvidedOrGeneratedKeyArgs, JwkKeyUse, TKeyType } from './types';
4
+ /**
5
+ * Generates a random Private Hex Key for the specified key type
6
+ * @param type The key type
7
+ * @return The private key in Hex form
8
+ */
9
+ export declare const generatePrivateKeyHex: (type: TKeyType) => Promise<string>;
10
+ /**
11
+ * We optionally generate and then import our own keys.
12
+ *
13
+ * @param args The key arguments
14
+ * @param context The Veramo agent context
15
+ * @private
16
+ */
17
+ export declare function importProvidedOrGeneratedKey(args: IImportProvidedOrGeneratedKeyArgs & {
18
+ kms: string;
19
+ }, context: IAgentContext<IKeyManager>): Promise<IKey>;
20
+ /**
21
+ * Converts hex value to base64url
22
+ * @param value hex value
23
+ * @return Base64Url encoded value
24
+ */
25
+ export declare const hex2base64url: (value: string) => string;
26
+ /**
27
+ * Converts a public key in hex format to a JWK
28
+ * @param publicKeyHex public key in hex
29
+ * @param type The type of the key (Ed25519, Secp256k1/r1)
30
+ * @param opts. Options, like the optional use for the key (sig/enc)
31
+ * @return The JWK
32
+ */
33
+ export declare const toJwk: (publicKeyHex: string, type: TKeyType, opts?: {
34
+ use?: JwkKeyUse;
35
+ key?: IKey;
36
+ isPrivateKey?: boolean;
37
+ }) => JsonWebKey;
38
+ /**
39
+ * Determines the use param based upon the key/signature type or supplied use value.
40
+ *
41
+ * @param type The key type
42
+ * @param suppliedUse A supplied use. Will be used in case it is present
43
+ */
44
+ export declare const jwkDetermineUse: (type: TKeyType, suppliedUse?: JwkKeyUse) => JwkKeyUse | undefined;
44
45
  //# sourceMappingURL=functions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../src/functions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE/D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAGzC,OAAO,EAAgB,iCAAiC,EAAE,SAAS,EAAmC,QAAQ,EAAE,MAAM,SAAS,CAAA;AAG/H;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,SAAgB,QAAQ,KAAG,QAAQ,MAAM,CAmB1E,CAAA;AAED;;;;;;GAMG;AACH,wBAAsB,4BAA4B,CAChD,IAAI,EAAE,iCAAiC,GAAG;IACxC,GAAG,EAAE,MAAM,CAAA;CACZ,EACD,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,GAClC,OAAO,CAAC,IAAI,CAAC,CAuCf;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa,UAAW,MAAM,WAO1C,CAAA;AAED;;;;;;GAMG;A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