@agnostack/verifyd 2.5.0-alpha.4 → 2.5.0-beta.2
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/esm/lib/index.js +3 -3
- package/dist/esm/lib/utils/index.js +1 -1
- package/dist/esm/lib/utils/rawbody.js +1 -1
- package/dist/esm/lib/verification.js +6 -6
- package/dist/esm/react/hooks/index.js +1 -1
- package/dist/esm/react/hooks/useVerification.js +1 -1
- package/dist/esm/react/index.js +2 -2
- package/dist/esm/shared/WebCrypto.js +26 -8
- package/dist/esm/shared/authorization.js +2 -2
- package/dist/esm/shared/index.js +5 -5
- package/dist/esm/shared/request.js +1 -1
- package/dist/esm/shared/verification.js +4 -4
- package/dist/lib/index.d.ts +3 -3
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +3 -3
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/types.d.ts +2 -2
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/utils/index.d.ts +1 -1
- package/dist/lib/utils/index.js +1 -1
- package/dist/lib/utils/index.js.map +1 -1
- package/dist/lib/utils/rawbody.js +2 -2
- package/dist/lib/utils/rawbody.js.map +1 -1
- package/dist/lib/verification.d.ts +2 -2
- package/dist/lib/verification.d.ts.map +1 -1
- package/dist/lib/verification.js +20 -20
- package/dist/lib/verification.js.map +1 -1
- package/dist/react/hooks/index.d.ts +1 -1
- package/dist/react/hooks/index.js +1 -1
- package/dist/react/hooks/index.js.map +1 -1
- package/dist/react/hooks/useVerification.js +4 -4
- package/dist/react/hooks/useVerification.js.map +1 -1
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +2 -2
- package/dist/react/index.js.map +1 -1
- package/dist/shared/WebCrypto.d.ts +55 -59
- package/dist/shared/WebCrypto.d.ts.map +1 -1
- package/dist/shared/WebCrypto.js +32 -14
- package/dist/shared/WebCrypto.js.map +1 -1
- package/dist/shared/authorization.d.ts +2 -2
- package/dist/shared/authorization.js +4 -4
- package/dist/shared/authorization.js.map +1 -1
- package/dist/shared/index.d.ts +5 -5
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index.js +5 -5
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/request.js +5 -5
- package/dist/shared/request.js.map +1 -1
- package/dist/shared/verification.d.ts +3 -6
- package/dist/shared/verification.d.ts.map +1 -1
- package/dist/shared/verification.js +19 -19
- package/dist/shared/verification.js.map +1 -1
- package/dist/umd/index.js +406 -471
- package/dist/umd/index.js.map +1 -1
- package/dist/umd/lib/index.d.ts +3 -3
- package/dist/umd/lib/index.d.ts.map +1 -1
- package/dist/umd/lib/types.d.ts +2 -2
- package/dist/umd/lib/types.d.ts.map +1 -1
- package/dist/umd/lib/utils/index.d.ts +1 -1
- package/dist/umd/lib/verification.d.ts +2 -2
- package/dist/umd/lib/verification.d.ts.map +1 -1
- package/dist/umd/react/hooks/index.d.ts +1 -1
- package/dist/umd/react/index.d.ts +2 -2
- package/dist/umd/react/index.d.ts.map +1 -1
- package/dist/umd/shared/WebCrypto.d.ts +55 -59
- package/dist/umd/shared/WebCrypto.d.ts.map +1 -1
- package/dist/umd/shared/authorization.d.ts +2 -2
- package/dist/umd/shared/index.d.ts +5 -5
- package/dist/umd/shared/index.d.ts.map +1 -1
- package/dist/umd/shared/verification.d.ts +3 -6
- package/dist/umd/shared/verification.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/esm/lib/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from '../shared';
|
|
2
|
-
export * from './utils';
|
|
3
|
-
export * from './verification';
|
|
1
|
+
export * from '../shared/index.js';
|
|
2
|
+
export * from './utils/index.js';
|
|
3
|
+
export * from './verification.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './rawbody';
|
|
1
|
+
export * from './rawbody.js';
|
|
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { lowercase } from '../../shared/display';
|
|
10
|
+
import { lowercase } from '../../shared/display.js';
|
|
11
11
|
const getChunkedRawBody = (req) => __awaiter(void 0, void 0, void 0, function* () {
|
|
12
12
|
if (req === null || req === void 0 ? void 0 : req.rawBody) {
|
|
13
13
|
return req.rawBody;
|
|
@@ -7,11 +7,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { objectToSortedString, ensureString, safeParse, isTrue, } from '../shared/display';
|
|
11
|
-
import { normalizeURIParts, getRequestMethod, VERIFYD_HEADERS, } from '../shared/request';
|
|
12
|
-
import { VerificationError } from '../shared/errors';
|
|
13
|
-
import { WebCrypto } from '../shared/WebCrypto';
|
|
14
|
-
import { ensureRawBody } from './utils';
|
|
10
|
+
import { objectToSortedString, ensureString, safeParse, isTrue, } from '../shared/display.js';
|
|
11
|
+
import { normalizeURIParts, getRequestMethod, VERIFYD_HEADERS, } from '../shared/request.js';
|
|
12
|
+
import { VerificationError } from '../shared/errors.js';
|
|
13
|
+
import { WebCrypto } from '../shared/WebCrypto.js';
|
|
14
|
+
import { ensureRawBody } from './utils/index.js';
|
|
15
15
|
export const generateStorableKeyPairs = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* ({ crypto: _crypto, util: _util } = {}) {
|
|
16
16
|
const webCrypto = new WebCrypto({ crypto: _crypto, util: _util });
|
|
17
17
|
const sharedKeyPair = yield webCrypto.generateKeyPair();
|
|
@@ -56,7 +56,7 @@ export const getVerificationHelpers = ({ keyPairs, util: _util, crypto: _crypto,
|
|
|
56
56
|
publicKey: ephemeralPublicKey,
|
|
57
57
|
privateKey: keyPairs.shared.privateKey,
|
|
58
58
|
});
|
|
59
|
-
if (!verificationKeys) {
|
|
59
|
+
if (!(verificationKeys === null || verificationKeys === void 0 ? void 0 : verificationKeys.derivedHMACKey) || !verificationKeys.derivedSecretKey) {
|
|
60
60
|
throw new VerificationError('Invalid or missing verification', { code: 412 });
|
|
61
61
|
}
|
|
62
62
|
const verificationPayload = objectToSortedString(Object.assign({ method: getRequestMethod(rawBody, req.method), timestamp: customAuthTimestamp, body: requestBody }, normalizeURIParts(uri)));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './useVerification';
|
|
1
|
+
export * from './useVerification.js';
|
|
@@ -19,7 +19,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
19
19
|
return t;
|
|
20
20
|
};
|
|
21
21
|
import { useState } from 'react';
|
|
22
|
-
import { getVerificationKeysData, prepareVerificationRequest, processVerificationResponse, } from '../../shared/verification';
|
|
22
|
+
import { getVerificationKeysData, prepareVerificationRequest, processVerificationResponse, } from '../../shared/verification.js';
|
|
23
23
|
export const useVerification = (_a = {}) => {
|
|
24
24
|
var { publicKey, disableRecryption } = _a, params = __rest(_a, ["publicKey", "disableRecryption"]);
|
|
25
25
|
const [keysData, setKeysData] = useState();
|
package/dist/esm/react/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '../shared/request'; // HMMMM: why cant we export WebCrypto class??
|
|
2
|
-
export * from './hooks';
|
|
1
|
+
export * from '../shared/request.js'; // HMMMM: why cant we export WebCrypto class??
|
|
2
|
+
export * from './hooks/index.js';
|
|
@@ -7,17 +7,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { isString, objectEmpty, ensureString, ensureArray, } from './display';
|
|
11
|
-
import { CryptoError } from './errors';
|
|
10
|
+
import { isString, objectEmpty, ensureString, ensureArray, } from './display.js';
|
|
11
|
+
import { CryptoError } from './errors.js';
|
|
12
12
|
export class WebCrypto {
|
|
13
|
-
constructor({ crypto: _crypto, util: _util } = {}) {
|
|
13
|
+
constructor({ crypto: _crypto, util: _util, encoding } = {}) {
|
|
14
14
|
this._crypto = _crypto !== null && _crypto !== void 0 ? _crypto : {};
|
|
15
15
|
this._util = _util !== null && _util !== void 0 ? _util : {};
|
|
16
|
+
this._encoding = encoding;
|
|
16
17
|
}
|
|
17
18
|
get subtle() {
|
|
18
19
|
var _a;
|
|
19
20
|
return (_a = this._crypto) === null || _a === void 0 ? void 0 : _a.subtle;
|
|
20
21
|
}
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
23
|
getWebCrypto() {
|
|
22
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
25
|
var _a, _b, _c, _d;
|
|
@@ -124,13 +126,14 @@ export class WebCrypto {
|
|
|
124
126
|
return (Array.from(ensureString(stringValue), (char) => (char.charCodeAt(0).toString(16).padStart(2, '0'))).join(''));
|
|
125
127
|
}
|
|
126
128
|
hexToString(hexValue) {
|
|
129
|
+
var _a;
|
|
127
130
|
if (!isString(hexValue)) {
|
|
128
131
|
throw new CryptoError('hexValue must be a string');
|
|
129
132
|
}
|
|
130
133
|
if (!/^(?:[0-9a-f]{2})+$/.test(hexValue)) {
|
|
131
134
|
throw new CryptoError('hexValue must be a valid hex string');
|
|
132
135
|
}
|
|
133
|
-
return ensureArray(hexValue.match(/.{1,2}/g))
|
|
136
|
+
return ensureArray((_a = hexValue.match(/.{1,2}/g)) !== null && _a !== void 0 ? _a : [])
|
|
134
137
|
.map((byte) => String.fromCharCode(parseInt(byte, 16)))
|
|
135
138
|
.join('');
|
|
136
139
|
}
|
|
@@ -142,7 +145,12 @@ export class WebCrypto {
|
|
|
142
145
|
});
|
|
143
146
|
}
|
|
144
147
|
arrayToArrayBuffer(array) {
|
|
145
|
-
|
|
148
|
+
// Defensive `ArrayBuffer.from` check is vestigial (no such standard method),
|
|
149
|
+
// but preserved to keep this conversion behavior-identical to the .js source.
|
|
150
|
+
return (
|
|
151
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
152
|
+
(ArrayBuffer.from != undefined)
|
|
153
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
146
154
|
? ArrayBuffer.from(array)
|
|
147
155
|
: new Uint8Array(array).buffer);
|
|
148
156
|
}
|
|
@@ -224,7 +232,7 @@ export class WebCrypto {
|
|
|
224
232
|
const crypto = yield this.getWebCrypto();
|
|
225
233
|
const Encoder = yield this.getTextEncoder();
|
|
226
234
|
const signature = yield crypto.subtle.sign('HMAC', derivedKey, new Encoder().encode(message));
|
|
227
|
-
return this.stringToHex(this.arrayBufferToString(signature));
|
|
235
|
+
return this.stringToHex(yield this.arrayBufferToString(signature));
|
|
228
236
|
});
|
|
229
237
|
}
|
|
230
238
|
verifyHMAC(message, derivedKey, verifiableHMAC) {
|
|
@@ -375,6 +383,12 @@ export class WebCrypto {
|
|
|
375
383
|
...iv,
|
|
376
384
|
...new Uint8Array(ciphertext)
|
|
377
385
|
]);
|
|
386
|
+
if (this._encoding === 'base64') {
|
|
387
|
+
// btoa is universal in browsers + Node 16+; no polyfill needed.
|
|
388
|
+
// String.fromCharCode + spread is safe for the small payloads we produce
|
|
389
|
+
// (IV + ciphertext + tag — typically < 100KB even for large messages).
|
|
390
|
+
return btoa(String.fromCharCode(...encryptedMessage));
|
|
391
|
+
}
|
|
378
392
|
return Array.from(encryptedMessage);
|
|
379
393
|
});
|
|
380
394
|
}
|
|
@@ -384,8 +398,12 @@ export class WebCrypto {
|
|
|
384
398
|
return undefined;
|
|
385
399
|
}
|
|
386
400
|
const crypto = yield this.getWebCrypto();
|
|
387
|
-
//
|
|
388
|
-
|
|
401
|
+
// When encoding === 'base64', the input is a base64 string from a matching
|
|
402
|
+
// encryptMessage call on a peer instance with the same option. Otherwise,
|
|
403
|
+
// accept number[] / ArrayBuffer (existing behavior).
|
|
404
|
+
const encryptedArrayBuffer = (this._encoding === 'base64')
|
|
405
|
+
? Uint8Array.from(atob(encryptedMessage), (c) => c.charCodeAt(0)).buffer
|
|
406
|
+
: this.ensureArrayBuffer(encryptedMessage);
|
|
389
407
|
const iv = encryptedArrayBuffer.slice(0, 12);
|
|
390
408
|
const ciphertext = encryptedArrayBuffer.slice(12);
|
|
391
409
|
const decryptedArrayBuffer = yield crypto.subtle.decrypt({
|
|
@@ -7,8 +7,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { stringEmpty } from './display';
|
|
11
|
-
import { WebCrypto } from './WebCrypto';
|
|
10
|
+
import { stringEmpty } from './display.js';
|
|
11
|
+
import { WebCrypto } from './WebCrypto.js';
|
|
12
12
|
export const getAuthorizationHelpers = (sharedSecret_1, ...args_1) => __awaiter(void 0, [sharedSecret_1, ...args_1], void 0, function* (sharedSecret, { crypto: _crypto, util: _util } = {}) {
|
|
13
13
|
if (stringEmpty(sharedSecret)) {
|
|
14
14
|
return undefined;
|
package/dist/esm/shared/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// export * from './constants' // HMMMM???
|
|
2
|
-
export * from './errors';
|
|
3
|
-
export * from './authorization';
|
|
4
|
-
export * from './request';
|
|
5
|
-
export * from './verification';
|
|
6
|
-
export * from './WebCrypto';
|
|
2
|
+
export * from './errors.js';
|
|
3
|
+
export * from './authorization.js';
|
|
4
|
+
export * from './request.js';
|
|
5
|
+
export * from './verification.js';
|
|
6
|
+
export * from './WebCrypto.js';
|
|
@@ -9,7 +9,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import { ensureLeadingSlash, stringEmpty, uppercase, safeParse, } from './display';
|
|
12
|
+
import { ensureLeadingSlash, stringEmpty, uppercase, safeParse, } from './display.js';
|
|
13
13
|
const TEMP_HOSTNAME = 'xyz.com';
|
|
14
14
|
const REMOVABLE_KEYS = ['shop', 'host'];
|
|
15
15
|
export const VERIFYD_HEADERS = {
|
|
@@ -18,10 +18,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
18
18
|
}
|
|
19
19
|
return t;
|
|
20
20
|
};
|
|
21
|
-
import { VerificationError } from './errors';
|
|
22
|
-
import { normalizeURIParts, prepareRequestOptions, getRequestMethod, } from './request';
|
|
23
|
-
import { isTrue, safeParse, stringEmpty, objectToSortedString, } from './display';
|
|
24
|
-
import { WebCrypto } from './WebCrypto';
|
|
21
|
+
import { VerificationError } from './errors.js';
|
|
22
|
+
import { normalizeURIParts, prepareRequestOptions, getRequestMethod, } from './request.js';
|
|
23
|
+
import { isTrue, safeParse, stringEmpty, objectToSortedString, } from './display.js';
|
|
24
|
+
import { WebCrypto } from './WebCrypto.js';
|
|
25
25
|
const getUnixString = () => {
|
|
26
26
|
const currentDate = new Date();
|
|
27
27
|
const unixTimestamp = currentDate.getTime();
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from '../shared';
|
|
2
|
-
export * from './utils';
|
|
3
|
-
export * from './verification';
|
|
1
|
+
export * from '../shared/index.js';
|
|
2
|
+
export * from './utils/index.js';
|
|
3
|
+
export * from './verification.js';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA;AAChC,cAAc,mBAAmB,CAAA"}
|
package/dist/lib/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("../shared"), exports);
|
|
18
|
-
__exportStar(require("./utils"), exports);
|
|
19
|
-
__exportStar(require("./verification"), exports);
|
|
17
|
+
__exportStar(require("../shared/index.js"), exports);
|
|
18
|
+
__exportStar(require("./utils/index.js"), exports);
|
|
19
|
+
__exportStar(require("./verification.js"), exports);
|
|
20
20
|
//# sourceMappingURL=index.js.map
|
package/dist/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAkC;AAClC,mDAAgC;AAChC,oDAAiC"}
|
package/dist/lib/types.d.ts
CHANGED
package/dist/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE;QACN,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED,MAAM,WAAW,gBAAgB;IAC/B,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE;QACN,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED,MAAM,WAAW,gBAAgB;IAC/B,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B,gBAAgB,CAAC,EAAE,SAAS,CAAC;CAC9B;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./rawbody";
|
|
1
|
+
export * from "./rawbody.js";
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/lib/utils/index.js
CHANGED
|
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./rawbody"), exports);
|
|
17
|
+
__exportStar(require("./rawbody.js"), exports);
|
|
18
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/utils/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/utils/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA4B"}
|
|
@@ -33,7 +33,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
33
33
|
};
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
35
|
exports.ensureRawBody = void 0;
|
|
36
|
-
const
|
|
36
|
+
const display_js_1 = require("../../shared/display.js");
|
|
37
37
|
const getChunkedRawBody = (req) => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
38
|
if (req === null || req === void 0 ? void 0 : req.rawBody) {
|
|
39
39
|
return req.rawBody;
|
|
@@ -44,7 +44,7 @@ const getChunkedRawBody = (req) => __awaiter(void 0, void 0, void 0, function* (
|
|
|
44
44
|
const rawBodyModule = 'raw-body';
|
|
45
45
|
try {
|
|
46
46
|
const _getRawBody = (yield Promise.resolve(`${rawBodyModule}`).then(s => __importStar(require(s)))).default;
|
|
47
|
-
if (!req.method || ((0,
|
|
47
|
+
if (!req.method || ((0, display_js_1.lowercase)(req.method) === 'get')) {
|
|
48
48
|
return undefined;
|
|
49
49
|
}
|
|
50
50
|
return _getRawBody(req).then((_rawBody) => _rawBody === null || _rawBody === void 0 ? void 0 : _rawBody.toString());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rawbody.js","sourceRoot":"","sources":["../../../src/lib/utils/rawbody.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"rawbody.js","sourceRoot":"","sources":["../../../src/lib/utils/rawbody.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wDAAmD;AAEnD,MAAM,iBAAiB,GAAG,CAAO,GAAG,EAAE,EAAE;IACtC,IAAI,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,OAAO,EAAE,CAAC;QACjB,OAAO,GAAG,CAAC,OAAO,CAAA;IACpB,CAAC;IAED,gGAAgG;IAChG,sFAAsF;IACtF,yEAAyE;IACzE,MAAM,aAAa,GAAG,UAAU,CAAA;IAChC,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,CAAC,yBAAa,aAAa,uCAAC,CAAC,CAAC,OAAO,CAAA;QAEzD,IAAI,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,IAAA,sBAAS,EAAC,GAAG,CAAC,MAAM,CAAC,KAAK,KAAK,CAAC,EAAE,CAAC;YACrD,OAAO,SAAS,CAAA;QAClB,CAAC;QAED,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,QAAQ,EAAE,CAAC,CAAA;IAClE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,wEAAwE,CAAC,CAAA;QACvF,MAAM,KAAK,CAAA;IACb,CAAC;AACH,CAAC,CAAA,CAAA;AAED,yEAAyE;AAClE,MAAM,aAAa,GAAG,CAAO,GAAG,EAAE,EAAE;IAAC,OAAA,CAC1C,iBAAiB,CAAC,GAAG,CAAC;SACnB,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QACf,OAAO,CAAC,KAAK,CAAC,+BAA+B,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,GAAG,GAAG,EAAE,KAAK,CAAC,CAAA;QAChE,MAAM,KAAK,CAAA;IACf,CAAC,CAAC,CACH,CAAA;EAAA,CAAA;AANY,QAAA,aAAa,iBAMzB"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { KeyPairs, RequestParams } from './types';
|
|
1
|
+
import { KeyPairs, RequestParams } from './types.js';
|
|
2
2
|
export declare const generateStorableKeyPairs: ({ crypto: _crypto, util: _util }?: {
|
|
3
3
|
crypto?: unknown;
|
|
4
4
|
util?: unknown;
|
|
5
|
-
}) => Promise<
|
|
5
|
+
}) => Promise<Record<string, string>>;
|
|
6
6
|
export declare const getVerificationHelpers: ({ keyPairs, util: _util, crypto: _crypto, DISABLE_RECRYPTION, }?: {
|
|
7
7
|
keyPairs: KeyPairs;
|
|
8
8
|
crypto?: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verification.d.ts","sourceRoot":"","sources":["../../src/lib/verification.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAoB,MAAM,
|
|
1
|
+
{"version":3,"file":"verification.d.ts","sourceRoot":"","sources":["../../src/lib/verification.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAoB,MAAM,YAAY,CAAA;AAEtE,eAAO,MAAM,wBAAwB,sCAA4C;IAAE,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,oCAQpH,CAAA;AAED,eAAO,MAAM,sBAAsB;cAMvB,QAAQ;aACT,OAAO;WACT,OAAO;;YAKK;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,WAAW,aAAa;;;iCAuFlF,OAAO;EAkBtD,CAAA"}
|
package/dist/lib/verification.js
CHANGED
|
@@ -10,13 +10,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.getVerificationHelpers = exports.generateStorableKeyPairs = void 0;
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
13
|
+
const display_js_1 = require("../shared/display.js");
|
|
14
|
+
const request_js_1 = require("../shared/request.js");
|
|
15
|
+
const errors_js_1 = require("../shared/errors.js");
|
|
16
|
+
const WebCrypto_js_1 = require("../shared/WebCrypto.js");
|
|
17
|
+
const index_js_1 = require("./utils/index.js");
|
|
18
18
|
const generateStorableKeyPairs = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* ({ crypto: _crypto, util: _util } = {}) {
|
|
19
|
-
const webCrypto = new
|
|
19
|
+
const webCrypto = new WebCrypto_js_1.WebCrypto({ crypto: _crypto, util: _util });
|
|
20
20
|
const sharedKeyPair = yield webCrypto.generateKeyPair();
|
|
21
21
|
return webCrypto.getStorableKeyPair({
|
|
22
22
|
publicKey: sharedKeyPair.publicKey,
|
|
@@ -25,26 +25,26 @@ const generateStorableKeyPairs = (...args_1) => __awaiter(void 0, [...args_1], v
|
|
|
25
25
|
});
|
|
26
26
|
exports.generateStorableKeyPairs = generateStorableKeyPairs;
|
|
27
27
|
const getVerificationHelpers = ({ keyPairs, util: _util, crypto: _crypto, DISABLE_RECRYPTION, } = { keyPairs: {} }) => {
|
|
28
|
-
const webCrypto = new
|
|
28
|
+
const webCrypto = new WebCrypto_js_1.WebCrypto({ crypto: _crypto, util: _util });
|
|
29
29
|
return (req, params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
30
|
var _a;
|
|
31
|
-
const { [
|
|
31
|
+
const { [request_js_1.VERIFYD_HEADERS.PUBLIC_KEY]: _apiKey, [request_js_1.VERIFYD_HEADERS.PUBLIC_KEY.toLowerCase()]: apiKey = _apiKey, [request_js_1.VERIFYD_HEADERS.EPHEMERAL_KEY]: _ephemeralPublicKey, [request_js_1.VERIFYD_HEADERS.EPHEMERAL_KEY.toLowerCase()]: ephemeralPublicKey = _ephemeralPublicKey, [request_js_1.VERIFYD_HEADERS.AUTHORIZATION_TIMESTAMP]: _customAuthTimestamp, [request_js_1.VERIFYD_HEADERS.AUTHORIZATION_TIMESTAMP.toLowerCase()]: customAuthTimestamp = _customAuthTimestamp, [request_js_1.VERIFYD_HEADERS.AUTHORIZATION]: _customAuth, [request_js_1.VERIFYD_HEADERS.AUTHORIZATION.toLowerCase()]: customAuth = _customAuth, } = (_a = req.headers) !== null && _a !== void 0 ? _a : {};
|
|
32
32
|
const { uri: _uri, disableRecryption: _disableRecryption } = params !== null && params !== void 0 ? params : {};
|
|
33
33
|
const uri = _uri !== null && _uri !== void 0 ? _uri : req.url;
|
|
34
|
-
const disableRecryption = (0,
|
|
34
|
+
const disableRecryption = (0, display_js_1.isTrue)(DISABLE_RECRYPTION) || (0, display_js_1.isTrue)(_disableRecryption);
|
|
35
35
|
let isVerifiable = false;
|
|
36
36
|
try {
|
|
37
|
-
const [authProtocol, authSignature] = (0,
|
|
38
|
-
isVerifiable = (0,
|
|
37
|
+
const [authProtocol, authSignature] = (0, display_js_1.ensureString)(customAuth).split(' ');
|
|
38
|
+
isVerifiable = (0, display_js_1.isTrue)(apiKey &&
|
|
39
39
|
ephemeralPublicKey &&
|
|
40
40
|
customAuthTimestamp &&
|
|
41
41
|
authSignature &&
|
|
42
42
|
(authProtocol === 'HMAC-SHA256') &&
|
|
43
43
|
(keyPairs === null || keyPairs === void 0 ? void 0 : keyPairs.shared));
|
|
44
44
|
let verificationKeys;
|
|
45
|
-
const rawBody = yield (0,
|
|
45
|
+
const rawBody = yield (0, index_js_1.ensureRawBody)(req);
|
|
46
46
|
// NOTE: requestBody should be wind up decrypted when isVerifiable (unless disableRecryption, then will pass through)
|
|
47
|
-
let requestBody = (0,
|
|
47
|
+
let requestBody = (0, display_js_1.safeParse)(rawBody);
|
|
48
48
|
// TEMP!!! remove isVerifiable check once web widget moved to react
|
|
49
49
|
if (isVerifiable) {
|
|
50
50
|
if (!apiKey ||
|
|
@@ -54,27 +54,27 @@ const getVerificationHelpers = ({ keyPairs, util: _util, crypto: _crypto, DISABL
|
|
|
54
54
|
(authProtocol !== 'HMAC-SHA256') ||
|
|
55
55
|
!(keyPairs === null || keyPairs === void 0 ? void 0 : keyPairs.shared) ||
|
|
56
56
|
(apiKey !== keyPairs.shared.publicKey)) {
|
|
57
|
-
throw new
|
|
57
|
+
throw new errors_js_1.VerificationError('Invalid or missing authorization', { code: 401 });
|
|
58
58
|
}
|
|
59
59
|
verificationKeys = yield webCrypto.getVerificationKeys({
|
|
60
60
|
publicKey: ephemeralPublicKey,
|
|
61
61
|
privateKey: keyPairs.shared.privateKey,
|
|
62
62
|
});
|
|
63
|
-
if (!verificationKeys) {
|
|
64
|
-
throw new
|
|
63
|
+
if (!(verificationKeys === null || verificationKeys === void 0 ? void 0 : verificationKeys.derivedHMACKey) || !verificationKeys.derivedSecretKey) {
|
|
64
|
+
throw new errors_js_1.VerificationError('Invalid or missing verification', { code: 412 });
|
|
65
65
|
}
|
|
66
|
-
const verificationPayload = (0,
|
|
66
|
+
const verificationPayload = (0, display_js_1.objectToSortedString)(Object.assign({ method: (0, request_js_1.getRequestMethod)(rawBody, req.method), timestamp: customAuthTimestamp, body: requestBody }, (0, request_js_1.normalizeURIParts)(uri)));
|
|
67
67
|
const isValid = yield webCrypto.verifyHMAC(verificationPayload, verificationKeys.derivedHMACKey, authSignature);
|
|
68
68
|
if (!isValid) {
|
|
69
|
-
throw new
|
|
69
|
+
throw new errors_js_1.VerificationError('Invalid or missing verification', { code: 403 });
|
|
70
70
|
}
|
|
71
71
|
if (!disableRecryption && requestBody) {
|
|
72
72
|
try {
|
|
73
73
|
const decryptedMessage = yield webCrypto.decryptMessage(requestBody, verificationKeys.derivedSecretKey);
|
|
74
|
-
requestBody = (0,
|
|
74
|
+
requestBody = (0, display_js_1.safeParse)(decryptedMessage);
|
|
75
75
|
}
|
|
76
76
|
catch (_b) {
|
|
77
|
-
throw new
|
|
77
|
+
throw new errors_js_1.VerificationError('Error decrypting request', { code: 400 });
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verification.js","sourceRoot":"","sources":["../../src/lib/verification.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"file":"verification.js","sourceRoot":"","sources":["../../src/lib/verification.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAK6B;AAC7B,qDAI6B;AAC7B,mDAAuD;AACvD,yDAAkD;AAClD,+CAAgD;AAGzC,MAAM,wBAAwB,GAAG,YAAoF,EAAE,mDAA/E,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,KAA2C,EAAE;IACxH,MAAM,SAAS,GAAG,IAAI,wBAAS,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;IACjE,MAAM,aAAa,GAAG,MAAM,SAAS,CAAC,eAAe,EAAE,CAAA;IAEvD,OAAO,SAAS,CAAC,kBAAkB,CAAC;QAClC,SAAS,EAAE,aAAa,C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AAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,gBAAgB,CAAA,EAAE,CAAC;oBAC3F,OAAO,QAAQ,CAAA;gBACjB,CAAC;gBAED,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAA;YAC9F,CAAC,CAAA,CAAA;YAED,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,CAAA;QAClD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,4CAA4C,GAAG,GAAG,EAAE;gBAChE,KAAK;gBACL,YAAY;gBACZ,iBAAiB;aAClB,CAAC,CAAA;YACF,MAAM,KAAK,CAAA;QACb,CAAC;IACH,CAAC,CAAA,CAAA;AACH,CAAC,CAAA;AAtHY,QAAA,sBAAsB,0BAsHlC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./useVerification";
|
|
1
|
+
export * from "./useVerification.js";
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./useVerification"), exports);
|
|
17
|
+
__exportStar(require("./useVerification.js"), exports);
|
|
18
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react/hooks/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react/hooks/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAoC"}
|
|
@@ -22,12 +22,12 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
23
|
exports.useVerification = void 0;
|
|
24
24
|
const react_1 = require("react");
|
|
25
|
-
const
|
|
25
|
+
const verification_js_1 = require("../../shared/verification.js");
|
|
26
26
|
const useVerification = (_a = {}) => {
|
|
27
27
|
var { publicKey, disableRecryption } = _a, params = __rest(_a, ["publicKey", "disableRecryption"]);
|
|
28
28
|
const [keysData, setKeysData] = (0, react_1.useState)();
|
|
29
29
|
const ensureKeysData = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
-
const _keysData = keysData !== null && keysData !== void 0 ? keysData : (yield (0,
|
|
30
|
+
const _keysData = keysData !== null && keysData !== void 0 ? keysData : (yield (0, verification_js_1.getVerificationKeysData)(publicKey, params));
|
|
31
31
|
if (_keysData && !keysData) {
|
|
32
32
|
setKeysData(_keysData);
|
|
33
33
|
}
|
|
@@ -35,12 +35,12 @@ const useVerification = (_a = {}) => {
|
|
|
35
35
|
});
|
|
36
36
|
const prepareVerification = (requestPath, requestOptions) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
37
|
const _keysData = yield ensureKeysData();
|
|
38
|
-
const _prepareVerification = (0,
|
|
38
|
+
const _prepareVerification = (0, verification_js_1.prepareVerificationRequest)({ disableRecryption, keysData: _keysData });
|
|
39
39
|
return _prepareVerification(requestPath, requestOptions);
|
|
40
40
|
});
|
|
41
41
|
const processResponse = (encryptedResponse, derivedSecretKey) => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
42
|
const _keysData = yield ensureKeysData();
|
|
43
|
-
const _processResponse = (0,
|
|
43
|
+
const _processResponse = (0, verification_js_1.processVerificationResponse)({ disableRecryption, keysData: _keysData });
|
|
44
44
|
return _processResponse(encryptedResponse, derivedSecretKey);
|
|
45
45
|
});
|
|
46
46
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useVerification.js","sourceRoot":"","sources":["../../../src/react/hooks/useVerification.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAgC;AAEhC,
|
|
1
|
+
{"version":3,"file":"useVerification.js","sourceRoot":"","sources":["../../../src/react/hooks/useVerification.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAgC;AAEhC,kEAIqC;AAE9B,MAAM,eAAe,GAAG,CAAC,KAA8C,EAAE,EAAE,EAAE;QAApD,EAAE,SAAS,EAAE,iBAAiB,OAAkB,EAAb,MAAM,cAAzC,kCAA2C,CAAF;IACvE,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,GAAE,CAAA;IAE1C,MAAM,cAAc,GAAG,GAAS,EAAE;QAChC,MAAM,SAAS,GAAG,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,CAAC,MAAM,IAAA,yCAAuB,EAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAA;QAChF,IAAI,SAAS,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC3B,WAAW,CAAC,SAAS,CAAC,CAAA;QACxB,CAAC;QAED,OAAO,SAAS,CAAA;IAClB,CAAC,CAAA,CAAA;IAED,MAAM,mBAAmB,GAAG,CAAO,WAAW,EAAE,cAAc,EAAE,EAAE;QAChE,MAAM,SAAS,GAAG,MAAM,cAAc,EAAE,CAAA;QACxC,MAAM,oBAAoB,GAAG,IAAA,4CAA0B,EAAC,EAAE,iBAAiB,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAA;QAEnG,OAAO,oBAAoB,CAAC,WAAW,EAAE,cAAc,CAAC,CAAA;IAC1D,CAAC,CAAA,CAAA;IAED,MAAM,eAAe,GAAG,CAAO,iBAAiB,EAAE,gBAAgB,EAAE,EAAE;QACpE,MAAM,SAAS,GAAG,MAAM,cAAc,EAAE,CAAA;QACxC,MAAM,gBAAgB,GAAG,IAAA,6CAA2B,EAAC,EAAE,iBAAiB,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAA;QAEhG,OAAO,gBAAgB,CAAC,iBAAiB,EAAE,gBAAgB,CAAC,CAAA;IAC9D,CAAC,CAAA,CAAA;IAED,OAAO;QACL,mBAAmB;QACnB,eAAe;KAChB,CAAA;AACH,CAAC,CAAA;AA9BY,QAAA,eAAe,mBA8B3B"}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from '../shared/request';
|
|
2
|
-
export * from './hooks';
|
|
1
|
+
export * from '../shared/request.js';
|
|
2
|
+
export * from './hooks/index.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,kBAAkB,CAAA"}
|
package/dist/react/index.js
CHANGED
|
@@ -14,6 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("../shared/request"), exports); // HMMMM: why cant we export WebCrypto class??
|
|
18
|
-
__exportStar(require("./hooks"), exports);
|
|
17
|
+
__exportStar(require("../shared/request.js"), exports); // HMMMM: why cant we export WebCrypto class??
|
|
18
|
+
__exportStar(require("./hooks/index.js"), exports);
|
|
19
19
|
//# sourceMappingURL=index.js.map
|
package/dist/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAoC,CAAC,8CAA8C;AACnF,mDAAgC"}
|