@sd-jwt/utils 0.2.1 → 2.0.2-next.26

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.
Files changed (42) hide show
  1. package/LICENSE +201 -0
  2. package/dist/index.d.mts +35 -0
  3. package/dist/index.d.ts +35 -0
  4. package/dist/index.js +145 -0
  5. package/dist/index.mjs +115 -0
  6. package/package.json +58 -46
  7. package/src/base64url.ts +8 -0
  8. package/src/disclosure.ts +98 -0
  9. package/src/error.ts +16 -0
  10. package/src/index.ts +3 -0
  11. package/src/test/base64url.spec.ts +26 -0
  12. package/src/test/disclosure.spec.ts +141 -0
  13. package/src/test/error.spec.ts +15 -0
  14. package/tsconfig.json +7 -0
  15. package/vitest.config.mts +4 -0
  16. package/build/assert.d.ts +0 -1
  17. package/build/assert.js +0 -16
  18. package/build/assert.js.map +0 -1
  19. package/build/base64url.d.ts +0 -29
  20. package/build/base64url.js +0 -44
  21. package/build/base64url.js.map +0 -1
  22. package/build/getValueByKeyAnyLevel.d.ts +0 -1
  23. package/build/getValueByKeyAnyLevel.js +0 -20
  24. package/build/getValueByKeyAnyLevel.js.map +0 -1
  25. package/build/hasherAlgorithm.d.ts +0 -70
  26. package/build/hasherAlgorithm.js +0 -75
  27. package/build/hasherAlgorithm.js.map +0 -1
  28. package/build/index.d.ts +0 -6
  29. package/build/index.js +0 -23
  30. package/build/index.js.map +0 -1
  31. package/build/isPromise.d.ts +0 -1
  32. package/build/isPromise.js +0 -11
  33. package/build/isPromise.js.map +0 -1
  34. package/build/object.d.ts +0 -5
  35. package/build/object.js +0 -76
  36. package/build/object.js.map +0 -1
  37. package/build/simpleDeepEqual.d.ts +0 -1
  38. package/build/simpleDeepEqual.js +0 -20
  39. package/build/simpleDeepEqual.js.map +0 -1
  40. package/build/swapClaims.d.ts +0 -2
  41. package/build/swapClaims.js +0 -73
  42. package/build/swapClaims.js.map +0 -1
@@ -0,0 +1,98 @@
1
+ import {
2
+ Uint8ArrayToBase64Url,
3
+ Base64urlDecode,
4
+ Base64urlEncode,
5
+ } from './base64url';
6
+ import { SDJWTException } from './error';
7
+ import { HasherAndAlg, DisclosureData, HasherAndAlgSync } from '@sd-jwt/types';
8
+
9
+ export class Disclosure<T = unknown> {
10
+ public salt: string;
11
+ public key?: string;
12
+ public value: T;
13
+ private _digest: string | undefined;
14
+ private _encoded: string | undefined;
15
+
16
+ public constructor(
17
+ data: DisclosureData<T>,
18
+ _meta?: { digest: string; encoded: string },
19
+ ) {
20
+ // If the meta is provided, then we assume that the data is already encoded and digested
21
+ this._digest = _meta?.digest;
22
+ this._encoded = _meta?.encoded;
23
+
24
+ if (data.length === 2) {
25
+ this.salt = data[0];
26
+ this.value = data[1];
27
+ return;
28
+ }
29
+ if (data.length === 3) {
30
+ this.salt = data[0];
31
+ this.key = data[1] as string;
32
+ this.value = data[2];
33
+ return;
34
+ }
35
+ throw new SDJWTException('Invalid disclosure data');
36
+ }
37
+
38
+ // We need to digest of the original encoded data.
39
+ // After decode process, we use JSON.stringify to encode the data.
40
+ // This can be different from the original encoded data.
41
+ public static async fromEncode<T>(s: string, hash: HasherAndAlg) {
42
+ const { hasher, alg } = hash;
43
+ const digest = await hasher(s, alg);
44
+ const digestStr = Uint8ArrayToBase64Url(digest);
45
+ const item = JSON.parse(Base64urlDecode(s)) as DisclosureData<T>;
46
+ return Disclosure.fromArray<T>(item, { digest: digestStr, encoded: s });
47
+ }
48
+
49
+ public static fromEncodeSync<T>(s: string, hash: HasherAndAlgSync) {
50
+ const { hasher, alg } = hash;
51
+ const digest = hasher(s, alg);
52
+ const digestStr = Uint8ArrayToBase64Url(digest);
53
+ const item = JSON.parse(Base64urlDecode(s)) as DisclosureData<T>;
54
+ return Disclosure.fromArray<T>(item, { digest: digestStr, encoded: s });
55
+ }
56
+
57
+ public static fromArray<T>(
58
+ item: DisclosureData<T>,
59
+ _meta?: { digest: string; encoded: string },
60
+ ) {
61
+ return new Disclosure(item, _meta);
62
+ }
63
+
64
+ public encode() {
65
+ if (!this._encoded) {
66
+ // we use JSON.stringify to encode the data
67
+ // It's the most reliable and universal way to encode JSON object
68
+ this._encoded = Base64urlEncode(JSON.stringify(this.decode()));
69
+ }
70
+ return this._encoded;
71
+ }
72
+
73
+ public decode(): DisclosureData<T> {
74
+ return this.key
75
+ ? [this.salt, this.key, this.value]
76
+ : [this.salt, this.value];
77
+ }
78
+
79
+ public async digest(hash: HasherAndAlg): Promise<string> {
80
+ const { hasher, alg } = hash;
81
+ if (!this._digest) {
82
+ const hash = await hasher(this.encode(), alg);
83
+ this._digest = Uint8ArrayToBase64Url(hash);
84
+ }
85
+
86
+ return this._digest;
87
+ }
88
+
89
+ public digestSync(hash: HasherAndAlgSync): string {
90
+ const { hasher, alg } = hash;
91
+ if (!this._digest) {
92
+ const hash = hasher(this.encode(), alg);
93
+ this._digest = Uint8ArrayToBase64Url(hash);
94
+ }
95
+
96
+ return this._digest;
97
+ }
98
+ }
package/src/error.ts ADDED
@@ -0,0 +1,16 @@
1
+ export class SDJWTException extends Error {
2
+ public details?: unknown;
3
+
4
+ constructor(message: string, details?: unknown) {
5
+ super(message);
6
+ Object.setPrototypeOf(this, SDJWTException.prototype);
7
+ this.name = 'SDJWTException';
8
+ this.details = details;
9
+ }
10
+
11
+ getFullMessage(): string {
12
+ return `${this.name}: ${this.message} ${
13
+ this.details ? `- ${JSON.stringify(this.details)}` : ''
14
+ }`;
15
+ }
16
+ }
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './base64url';
2
+ export * from './error';
3
+ export * from './disclosure';
@@ -0,0 +1,26 @@
1
+ import { describe, expect, test } from 'vitest';
2
+ import {
3
+ Base64urlDecode,
4
+ Base64urlEncode,
5
+ Uint8ArrayToBase64Url,
6
+ } from '../base64url';
7
+
8
+ describe('Base64url', () => {
9
+ const raw = 'abcdefghijklmnopqrstuvwxyz';
10
+ const encoded = 'YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo';
11
+ test('Encode', () => {
12
+ expect(Base64urlEncode(raw)).toStrictEqual(encoded);
13
+ });
14
+ test('Decode', () => {
15
+ expect(Base64urlDecode(encoded)).toStrictEqual(raw);
16
+ });
17
+ test('Encode and decode', () => {
18
+ const str = 'hello world';
19
+ expect(Base64urlDecode(Base64urlEncode(str))).toStrictEqual(str);
20
+ });
21
+ test('Uint8Array', () => {
22
+ const str = 'hello world';
23
+ const uint8 = new TextEncoder().encode(str);
24
+ expect(Uint8ArrayToBase64Url(uint8)).toStrictEqual(Base64urlEncode(str));
25
+ });
26
+ });
@@ -0,0 +1,141 @@
1
+ import { generateSalt, digest as hasher } from '@sd-jwt/crypto-nodejs';
2
+ import { Disclosure } from '../disclosure';
3
+ import { describe, expect, test } from 'vitest';
4
+ import { Base64urlEncode, SDJWTException } from '../index';
5
+
6
+ const hash = { alg: 'SHA256', hasher };
7
+
8
+ /*
9
+ ref draft-ietf-oauth-selective-disclosure-jwt-07
10
+ Claim given_name:
11
+ SHA-256 Hash: jsu9yVulwQQlhFlM_3JlzMaSFzglhQG0DpfayQwLUK4
12
+ Disclosure: WyIyR0xDNDJzS1F2ZUNmR2ZyeU5STjl3IiwgImdpdmVuX25hbWUiLCAiSm9obiJd
13
+ Contents: ["2GLC42sKQveCfGfryNRN9w", "given_name", "John"]
14
+ For example, the SHA-256 digest of the Disclosure
15
+ WyI2cU1RdlJMNWhhaiIsICJmYW1pbHlfbmFtZSIsICJNw7ZiaXVzIl0 would be uutlBuYeMDyjLLTpf6Jxi7yNkEF35jdyWMn9U7b_RYY.
16
+ The SHA-256 digest of the Disclosure
17
+ WyJsa2x4RjVqTVlsR1RQVW92TU5JdkNBIiwgIkZSIl0 would be w0I8EKcdCtUPkGCNUrfwVp2xEgNjtoIDlOxc9-PlOhs.
18
+ */
19
+ const TestDataDraft7 = {
20
+ claimTests: [
21
+ {
22
+ contents: '["2GLC42sKQveCfGfryNRN9w", "given_name", "John"]',
23
+ digest: 'jsu9yVulwQQlhFlM_3JlzMaSFzglhQG0DpfayQwLUK4',
24
+ disclosure:
25
+ 'WyIyR0xDNDJzS1F2ZUNmR2ZyeU5STjl3IiwgImdpdmVuX25hbWUiLCAiSm9obiJd',
26
+ },
27
+ ],
28
+ sha256Tests: [
29
+ {
30
+ digest: 'uutlBuYeMDyjLLTpf6Jxi7yNkEF35jdyWMn9U7b_RYY',
31
+ disclosure: 'WyI2cU1RdlJMNWhhaiIsICJmYW1pbHlfbmFtZSIsICJNw7ZiaXVzIl0',
32
+ },
33
+ {
34
+ digest: 'w0I8EKcdCtUPkGCNUrfwVp2xEgNjtoIDlOxc9-PlOhs',
35
+ disclosure: 'WyJsa2x4RjVqTVlsR1RQVW92TU5JdkNBIiwgIkZSIl0',
36
+ },
37
+ ],
38
+ };
39
+
40
+ describe('Disclosure', () => {
41
+ test('create object disclosure', async () => {
42
+ const salt = generateSalt(16);
43
+ const disclosure = new Disclosure([salt, 'name', 'James']);
44
+ expect(disclosure).toBeDefined();
45
+ expect(disclosure.key).toBe('name');
46
+ expect(disclosure.value).toBe('James');
47
+ expect(disclosure.salt).toBe(salt);
48
+ });
49
+
50
+ test('create array disclosure', async () => {
51
+ const salt = generateSalt(16);
52
+ const disclosure = new Disclosure([salt, 'US']);
53
+ expect(disclosure).toBeDefined();
54
+ expect(disclosure.key).toBe(undefined);
55
+ expect(disclosure.value).toBe('US');
56
+ expect(disclosure.salt).toBe(salt);
57
+ });
58
+
59
+ test('create disclosure error', async () => {
60
+ const salt = generateSalt(16);
61
+ const data: [string, string, string] = [salt, 'name', 'James'];
62
+ data.push('any');
63
+ expect(() => new Disclosure(data)).toThrow();
64
+ try {
65
+ new Disclosure(data);
66
+ } catch (e: unknown) {
67
+ const error = e as SDJWTException;
68
+ expect(typeof error.getFullMessage()).toBe('string');
69
+ }
70
+ });
71
+
72
+ test('encode disclosure', async () => {
73
+ const salt = generateSalt(16);
74
+ const disclosure = new Disclosure([salt, 'name', 'James']);
75
+ const encodedDisclosure = disclosure.encode();
76
+ expect(encodedDisclosure).toBeDefined();
77
+ expect(typeof encodedDisclosure).toBe('string');
78
+ });
79
+
80
+ test('decode disclosure', async () => {
81
+ const salt = generateSalt(16);
82
+ const disclosure = new Disclosure([salt, 'name', 'James']);
83
+ const encodedDisclosure = disclosure.encode();
84
+ const newDisclosure = await Disclosure.fromEncode(encodedDisclosure, {
85
+ alg: 'SHA256',
86
+ hasher,
87
+ });
88
+
89
+ expect(newDisclosure).toBeDefined();
90
+ expect(newDisclosure.key).toBe('name');
91
+ expect(newDisclosure.value).toBe('James');
92
+ expect(newDisclosure.salt).toBe(salt);
93
+ });
94
+
95
+ test('digest disclosure #1', async () => {
96
+ const salt = generateSalt(16);
97
+ const disclosure = new Disclosure([salt, 'name', 'James']);
98
+ const digest = await disclosure.digest({ alg: 'SHA256', hasher });
99
+ expect(digest).toBeDefined();
100
+ expect(typeof digest).toBe('string');
101
+ });
102
+
103
+ test('digest disclosure #2', async () => {
104
+ const disclosure = new Disclosure([
105
+ '2GLC42sKQveCfGfryNRN9w',
106
+ 'given_name',
107
+ 'John',
108
+ ]);
109
+ const encode = disclosure.encode();
110
+ expect(encode).toBe(
111
+ 'WyIyR0xDNDJzS1F2ZUNmR2ZyeU5STjl3IiwiZ2l2ZW5fbmFtZSIsIkpvaG4iXQ',
112
+ );
113
+ const digest = await disclosure.digest(hash);
114
+ expect(digest).toBe('8VHiz7qTXavxvpiTYDCSr_shkUO6qRcVXjkhEnt1os4');
115
+ });
116
+
117
+ test('digest disclosure #2', async () => {
118
+ const encoded = Base64urlEncode(TestDataDraft7.claimTests[0].contents);
119
+ expect(encoded).toStrictEqual(TestDataDraft7.claimTests[0].disclosure);
120
+
121
+ const disclosure = await Disclosure.fromEncode(
122
+ TestDataDraft7.claimTests[0].disclosure,
123
+ hash,
124
+ );
125
+
126
+ const digest = await disclosure.digest(hash);
127
+ expect(digest).toBe(TestDataDraft7.claimTests[0].digest);
128
+ });
129
+
130
+ test('digest disclosure #3', async () => {
131
+ for (const sha256Test of TestDataDraft7.sha256Tests) {
132
+ const disclosure = await Disclosure.fromEncode(
133
+ sha256Test.disclosure,
134
+ hash,
135
+ );
136
+
137
+ const digest = await disclosure.digest(hash);
138
+ expect(digest).toBe(sha256Test.digest);
139
+ }
140
+ });
141
+ });
@@ -0,0 +1,15 @@
1
+ import { SDJWTException } from '../error';
2
+ import { describe, expect, test } from 'vitest';
3
+
4
+ describe('Error tests', () => {
5
+ test('Detail', () => {
6
+ try {
7
+ throw new SDJWTException('msg', { info: 'details' });
8
+ } catch (e: unknown) {
9
+ const exception = e as SDJWTException;
10
+ expect(exception.getFullMessage()).toEqual(
11
+ 'SDJWTException: msg - {"info":"details"}',
12
+ );
13
+ }
14
+ });
15
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "rootDir": "src",
5
+ "outDir": "dist"
6
+ }
7
+ }
@@ -0,0 +1,4 @@
1
+ // vite.config.ts
2
+ import { allEnvs } from '../../vitest.shared';
3
+
4
+ export default allEnvs;
package/build/assert.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare const assertClaimInObject: (object: Record<string, unknown>, claimKey: string, claimValue?: unknown) => void;
package/build/assert.js DELETED
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.assertClaimInObject = void 0;
4
- const getValueByKeyAnyLevel_1 = require("./getValueByKeyAnyLevel");
5
- const simpleDeepEqual_1 = require("./simpleDeepEqual");
6
- const assertClaimInObject = (object, claimKey, claimValue) => {
7
- const value = (0, getValueByKeyAnyLevel_1.getValueByKeyAnyLevel)(object, claimKey);
8
- if (!value) {
9
- throw new Error(`Claim key '${claimKey}' not found in any level`);
10
- }
11
- if (claimValue && !(0, simpleDeepEqual_1.simpleDeepEqual)(value, claimValue)) {
12
- throw new Error(`Claim key '${claimKey}' was found, but values did not match`);
13
- }
14
- };
15
- exports.assertClaimInObject = assertClaimInObject;
16
- //# sourceMappingURL=assert.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"assert.js","sourceRoot":"","sources":["../src/assert.ts"],"names":[],"mappings":";;;AAAA,mEAA+D;AAC/D,uDAAmD;AAE5C,MAAM,mBAAmB,GAAG,CAC/B,MAA+B,EAC/B,QAAgB,EAChB,UAAoB,EACtB,EAAE;IACA,MAAM,KAAK,GAAG,IAAA,6CAAqB,EAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IAErD,IAAI,CAAC,KAAK,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CAAC,cAAc,QAAQ,0BAA0B,CAAC,CAAA;IACrE,CAAC;IAED,IAAI,UAAU,IAAI,CAAC,IAAA,iCAAe,EAAC,KAAK,EAAE,UAAU,CAAC,EAAE,CAAC;QACpD,MAAM,IAAI,KAAK,CACX,cAAc,QAAQ,uCAAuC,CAChE,CAAA;IACL,CAAC;AACL,CAAC,CAAA;AAhBY,QAAA,mBAAmB,uBAgB/B"}
@@ -1,29 +0,0 @@
1
- /// <reference types="node" />
2
- import { Buffer } from 'buffer';
3
- export declare class Base64url {
4
- /**
5
- *
6
- * Encode into base64url string
7
- *
8
- */
9
- static encode(input: string | Uint8Array | Buffer): string;
10
- /**
11
- *
12
- * Encode from JSON into a base64url string
13
- *
14
- */
15
- static encodeFromJson(input: Record<string, unknown> | Array<unknown>): string;
16
- /**
17
- *
18
- * Decode from base64url into JSON
19
- *
20
- */
21
- static decodeToJson<T extends Record<string, unknown> | Array<unknown> = Record<string, unknown>>(input: string): T;
22
- /**
23
- *
24
- * Decode from base64url into a byte array
25
- *
26
- */
27
- static decode(input: string): Uint8Array;
28
- }
29
- export declare function base64ToBase64URL(base64: string): string;
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.base64ToBase64URL = exports.Base64url = void 0;
4
- const buffer_1 = require("buffer");
5
- class Base64url {
6
- /**
7
- *
8
- * Encode into base64url string
9
- *
10
- */
11
- static encode(input) {
12
- return base64ToBase64URL(buffer_1.Buffer.from(input).toString('base64'));
13
- }
14
- /**
15
- *
16
- * Encode from JSON into a base64url string
17
- *
18
- */
19
- static encodeFromJson(input) {
20
- return base64ToBase64URL(buffer_1.Buffer.from(JSON.stringify(input)).toString('base64'));
21
- }
22
- /**
23
- *
24
- * Decode from base64url into JSON
25
- *
26
- */
27
- static decodeToJson(input) {
28
- return JSON.parse(buffer_1.Buffer.from(input, 'base64').toString());
29
- }
30
- /**
31
- *
32
- * Decode from base64url into a byte array
33
- *
34
- */
35
- static decode(input) {
36
- return Uint8Array.from(buffer_1.Buffer.from(input, 'base64'));
37
- }
38
- }
39
- exports.Base64url = Base64url;
40
- function base64ToBase64URL(base64) {
41
- return base64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
42
- }
43
- exports.base64ToBase64URL = base64ToBase64URL;
44
- //# sourceMappingURL=base64url.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base64url.js","sourceRoot":"","sources":["../src/base64url.ts"],"names":[],"mappings":";;;AAAA,mCAA+B;AAE/B,MAAa,SAAS;IAClB;;;;OAIG;IACI,MAAM,CAAC,MAAM,CAAC,KAAmC;QACpD,OAAO,iBAAiB,CAAC,eAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAA;IACnE,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,cAAc,CACxB,KAA+C;QAE/C,OAAO,iBAAiB,CACpB,eAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CACxD,CAAA;IACL,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,YAAY,CAKxB,KAAa;QACX,OAAO,IAAI,CAAC,KAAK,CAAC,eAAM,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAM,CAAA;IACnE,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,MAAM,CAAC,KAAa;QAC9B,OAAO,UAAU,CAAC,IAAI,CAAC,eAAM,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAA;IACxD,CAAC;CACJ;AA7CD,8BA6CC;AAED,SAAgB,iBAAiB,CAAC,MAAc;IAC5C,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;AAC3E,CAAC;AAFD,8CAEC"}
@@ -1 +0,0 @@
1
- export declare const getValueByKeyAnyLevel: <T = unknown>(obj: Record<string, unknown>, key: string) => T | undefined;
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getValueByKeyAnyLevel = void 0;
4
- const getValueByKeyAnyLevel = (obj, key) => {
5
- // Check if the current object has the key
6
- if (obj && obj.hasOwnProperty(key)) {
7
- return obj[key];
8
- }
9
- // If not found in the current object, iterate over its properties
10
- for (const prop in obj) {
11
- if (obj.hasOwnProperty(prop) && typeof obj[prop] === 'object') {
12
- const result = (0, exports.getValueByKeyAnyLevel)(obj[prop], key);
13
- if (result !== undefined) {
14
- return result;
15
- }
16
- }
17
- }
18
- };
19
- exports.getValueByKeyAnyLevel = getValueByKeyAnyLevel;
20
- //# sourceMappingURL=getValueByKeyAnyLevel.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getValueByKeyAnyLevel.js","sourceRoot":"","sources":["../src/getValueByKeyAnyLevel.ts"],"names":[],"mappings":";;;AAAO,MAAM,qBAAqB,GAAG,CACjC,GAA4B,EAC5B,GAAW,EACE,EAAE;IACf,0CAA0C;IAC1C,IAAI,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;QACjC,OAAO,GAAG,CAAC,GAAG,CAAM,CAAA;IACxB,CAAC;IAED,kEAAkE;IAClE,KAAK,MAAM,IAAI,IAAI,GAAG,EAAE,CAAC;QACrB,IAAI,GAAG,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,OAAO,GAAG,CAAC,IAAI,CAAC,KAAK,QAAQ,EAAE,CAAC;YAC5D,MAAM,MAAM,GAAG,IAAA,6BAAqB,EAChC,GAAG,CAAC,IAAI,CAA4B,EACpC,GAAG,CACN,CAAA;YACD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBACvB,OAAO,MAAW,CAAA;YACtB,CAAC;QACL,CAAC;IACL,CAAC;AACL,CAAC,CAAA;AArBY,QAAA,qBAAqB,yBAqBjC"}
@@ -1,70 +0,0 @@
1
- export declare enum HasherAlgorithm {
2
- /**
3
- * Sha-256: 256 bits. [RFC6920] (current)
4
- */
5
- Sha256 = "sha-256",
6
- /**
7
- * Sha-256-128: 128 bits. [RFC6920] (current)
8
- */
9
- Sha256_128 = "sha-256-128",
10
- /**
11
- * Sha-256-120: 120 bits. [RFC6920] (current)
12
- */
13
- Sha256_120 = "sha-256-120",
14
- /**
15
- * Sha-256-96: 96 bits. [RFC6920] (current)
16
- */
17
- Sha256_96 = "sha-256-96",
18
- /**
19
- * Sha-256-64: 64 bits. [RFC6920] (current)
20
- */
21
- Sha256_64 = "sha-256-64",
22
- /**
23
- * Sha-256-32: 32 bits. [RFC6920] (current)
24
- */
25
- Sha256_32 = "sha-256-32",
26
- /**
27
- * Sha-384: 384 bits. [FIPS 180-4] (current)
28
- */
29
- Sha384 = "sha-384",
30
- /**
31
- * Sha-512: 512 bits. [FIPS 180-4] (current)
32
- */
33
- Sha512 = "sha-512",
34
- /**
35
- * Sha3-224: 224 bits. [FIPS 202] (current)
36
- */
37
- Sha3_224 = "sha3-224",
38
- /**
39
- * Sha3-256: 256 bits. [FIPS 202] (current)
40
- */
41
- Sha3_256 = "sha3-256",
42
- /**
43
- * Sha3-384: 384 bits. [FIPS 202] (current)
44
- */
45
- Sha3_384 = "sha3-384",
46
- /**
47
- * Sha3-512: 512 bits. [FIPS 202] (current)
48
- */
49
- Sha3_512 = "sha3-512",
50
- /**
51
- * Blake2s-256: 256 bits. [RFC7693] (current)
52
- */
53
- Blake2s_256 = "blake2s-256",
54
- /**
55
- * Blake2b-256: 256 bits. [RFC7693] (current)
56
- */
57
- Blake2b_256 = "blake2b-256",
58
- /**
59
- * Blake2b-512: 512 bits. [RFC7693] (current)
60
- */
61
- Blake2b_512 = "blake2b-512",
62
- /**
63
- * K12-256: 256 bits. [draft-irtf-cfrg-kangarootwelve-06] (current)
64
- */
65
- K12_256 = "k12-256",
66
- /**
67
- * K12-512: 512 bits. [draft-irtf-cfrg-kangarootwelve-06] (current)
68
- */
69
- K12_512 = "k12-512"
70
- }
@@ -1,75 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HasherAlgorithm = void 0;
4
- var HasherAlgorithm;
5
- (function (HasherAlgorithm) {
6
- /**
7
- * Sha-256: 256 bits. [RFC6920] (current)
8
- */
9
- HasherAlgorithm["Sha256"] = "sha-256";
10
- /**
11
- * Sha-256-128: 128 bits. [RFC6920] (current)
12
- */
13
- HasherAlgorithm["Sha256_128"] = "sha-256-128";
14
- /**
15
- * Sha-256-120: 120 bits. [RFC6920] (current)
16
- */
17
- HasherAlgorithm["Sha256_120"] = "sha-256-120";
18
- /**
19
- * Sha-256-96: 96 bits. [RFC6920] (current)
20
- */
21
- HasherAlgorithm["Sha256_96"] = "sha-256-96";
22
- /**
23
- * Sha-256-64: 64 bits. [RFC6920] (current)
24
- */
25
- HasherAlgorithm["Sha256_64"] = "sha-256-64";
26
- /**
27
- * Sha-256-32: 32 bits. [RFC6920] (current)
28
- */
29
- HasherAlgorithm["Sha256_32"] = "sha-256-32";
30
- /**
31
- * Sha-384: 384 bits. [FIPS 180-4] (current)
32
- */
33
- HasherAlgorithm["Sha384"] = "sha-384";
34
- /**
35
- * Sha-512: 512 bits. [FIPS 180-4] (current)
36
- */
37
- HasherAlgorithm["Sha512"] = "sha-512";
38
- /**
39
- * Sha3-224: 224 bits. [FIPS 202] (current)
40
- */
41
- HasherAlgorithm["Sha3_224"] = "sha3-224";
42
- /**
43
- * Sha3-256: 256 bits. [FIPS 202] (current)
44
- */
45
- HasherAlgorithm["Sha3_256"] = "sha3-256";
46
- /**
47
- * Sha3-384: 384 bits. [FIPS 202] (current)
48
- */
49
- HasherAlgorithm["Sha3_384"] = "sha3-384";
50
- /**
51
- * Sha3-512: 512 bits. [FIPS 202] (current)
52
- */
53
- HasherAlgorithm["Sha3_512"] = "sha3-512";
54
- /**
55
- * Blake2s-256: 256 bits. [RFC7693] (current)
56
- */
57
- HasherAlgorithm["Blake2s_256"] = "blake2s-256";
58
- /**
59
- * Blake2b-256: 256 bits. [RFC7693] (current)
60
- */
61
- HasherAlgorithm["Blake2b_256"] = "blake2b-256";
62
- /**
63
- * Blake2b-512: 512 bits. [RFC7693] (current)
64
- */
65
- HasherAlgorithm["Blake2b_512"] = "blake2b-512";
66
- /**
67
- * K12-256: 256 bits. [draft-irtf-cfrg-kangarootwelve-06] (current)
68
- */
69
- HasherAlgorithm["K12_256"] = "k12-256";
70
- /**
71
- * K12-512: 512 bits. [draft-irtf-cfrg-kangarootwelve-06] (current)
72
- */
73
- HasherAlgorithm["K12_512"] = "k12-512";
74
- })(HasherAlgorithm || (exports.HasherAlgorithm = HasherAlgorithm = {}));
75
- //# sourceMappingURL=hasherAlgorithm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hasherAlgorithm.js","sourceRoot":"","sources":["../src/hasherAlgorithm.ts"],"names":[],"mappings":";;;AAAA,IAAY,eAqEX;AArED,WAAY,eAAe;IACvB;;OAEG;IACH,qCAAkB,CAAA;IAClB;;OAEG;IACH,6CAA0B,CAAA;IAC1B;;OAEG;IACH,6CAA0B,CAAA;IAC1B;;OAEG;IACH,2CAAwB,CAAA;IACxB;;OAEG;IACH,2CAAwB,CAAA;IACxB;;OAEG;IACH,2CAAwB,CAAA;IACxB;;OAEG;IACH,qCAAkB,CAAA;IAClB;;OAEG;IACH,qCAAkB,CAAA;IAClB;;OAEG;IACH,wCAAqB,CAAA;IACrB;;OAEG;IACH,wCAAqB,CAAA;IACrB;;OAEG;IACH,wCAAqB,CAAA;IACrB;;OAEG;IACH,wCAAqB,CAAA;IACrB;;OAEG;IACH,8CAA2B,CAAA;IAC3B;;OAEG;IACH,8CAA2B,CAAA;IAC3B;;OAEG;IACH,8CAA2B,CAAA;IAC3B;;OAEG;IACH,sCAAmB,CAAA;IACnB;;OAEG;IACH,sCAAmB,CAAA;AACvB,CAAC,EArEW,eAAe,+BAAf,eAAe,QAqE1B"}
package/build/index.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export * from './base64url';
2
- export * from './assert';
3
- export * from './getValueByKeyAnyLevel';
4
- export * from './isPromise';
5
- export * from './object';
6
- export * from './simpleDeepEqual';
package/build/index.js DELETED
@@ -1,23 +0,0 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./base64url"), exports);
18
- __exportStar(require("./assert"), exports);
19
- __exportStar(require("./getValueByKeyAnyLevel"), exports);
20
- __exportStar(require("./isPromise"), exports);
21
- __exportStar(require("./object"), exports);
22
- __exportStar(require("./simpleDeepEqual"), exports);
23
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA2B;AAC3B,2CAAwB;AACxB,0DAAuC;AACvC,8CAA2B;AAC3B,2CAAwB;AACxB,oDAAiC"}
@@ -1 +0,0 @@
1
- export declare const isPromise: <T>(value: T | Promise<T>) => value is Promise<T>;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isPromise = void 0;
4
- const isPromise = (value) => value instanceof Promise ||
5
- (value &&
6
- typeof value === 'object' &&
7
- value !== null &&
8
- 'then' in value &&
9
- value.then === 'function');
10
- exports.isPromise = isPromise;
11
- //# sourceMappingURL=isPromise.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isPromise.js","sourceRoot":"","sources":["../src/isPromise.ts"],"names":[],"mappings":";;;AAAO,MAAM,SAAS,GAAG,CAAI,KAAqB,EAAuB,EAAE,CACvE,KAAK,YAAY,OAAO;IACxB,CAAC,KAAK;QACF,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,MAAM,IAAI,KAAK;QACf,KAAK,CAAC,IAAI,KAAK,UAAU,CAAC,CAAA;AANrB,QAAA,SAAS,aAMY"}
package/build/object.d.ts DELETED
@@ -1,5 +0,0 @@
1
- export declare function isObject(input: any): boolean;
2
- export declare function getAllKeys(object: unknown, keys?: Array<string>): Array<string>;
3
- export declare function deleteByPath(object: Record<string, unknown>, path: string[]): void;
4
- export declare function getByPath(item: any[] | Record<string, unknown>, path: Array<string | number>): unknown;
5
- export declare function hasByPath(item: any[] | Record<string, unknown>, path: Array<string | number>): boolean;