@xylabs/crypto 2.11.6
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/LICENSE +165 -0
- package/README.md +71 -0
- package/babel.config.json +5 -0
- package/dist/browser/Crypto.d.mts +3 -0
- package/dist/browser/Crypto.d.mts.map +1 -0
- package/dist/browser/Crypto.d.ts +3 -0
- package/dist/browser/Crypto.d.ts.map +1 -0
- package/dist/browser/Crypto.js +41 -0
- package/dist/browser/Crypto.js.map +1 -0
- package/dist/browser/Crypto.mjs +6 -0
- package/dist/browser/Crypto.mjs.map +1 -0
- package/dist/browser/cryptoPolyfill.d.mts +2 -0
- package/dist/browser/cryptoPolyfill.d.mts.map +1 -0
- package/dist/browser/cryptoPolyfill.d.ts +2 -0
- package/dist/browser/cryptoPolyfill.d.ts.map +1 -0
- package/dist/browser/cryptoPolyfill.js +61 -0
- package/dist/browser/cryptoPolyfill.js.map +1 -0
- package/dist/browser/cryptoPolyfill.mjs +24 -0
- package/dist/browser/cryptoPolyfill.mjs.map +1 -0
- package/dist/browser/index.d.mts +3 -0
- package/dist/browser/index.d.mts.map +1 -0
- package/dist/browser/index.d.ts +3 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +63 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/index.mjs +25 -0
- package/dist/browser/index.mjs.map +1 -0
- package/dist/browserIndex.d.mts +3 -0
- package/dist/browserIndex.d.mts.map +1 -0
- package/dist/browserIndex.d.ts +3 -0
- package/dist/browserIndex.d.ts.map +1 -0
- package/dist/browserIndex.js +67 -0
- package/dist/browserIndex.js.map +1 -0
- package/dist/browserIndex.mjs +27 -0
- package/dist/browserIndex.mjs.map +1 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +67 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +27 -0
- package/dist/index.mjs.map +1 -0
- package/dist/node/Crypto.d.mts +3 -0
- package/dist/node/Crypto.d.mts.map +1 -0
- package/dist/node/Crypto.d.ts +3 -0
- package/dist/node/Crypto.d.ts.map +1 -0
- package/dist/node/Crypto.js +41 -0
- package/dist/node/Crypto.js.map +1 -0
- package/dist/node/Crypto.mjs +6 -0
- package/dist/node/Crypto.mjs.map +1 -0
- package/dist/node/cryptoPolyfill.d.mts +2 -0
- package/dist/node/cryptoPolyfill.d.mts.map +1 -0
- package/dist/node/cryptoPolyfill.d.ts +2 -0
- package/dist/node/cryptoPolyfill.d.ts.map +1 -0
- package/dist/node/cryptoPolyfill.js +33 -0
- package/dist/node/cryptoPolyfill.js.map +1 -0
- package/dist/node/cryptoPolyfill.mjs +8 -0
- package/dist/node/cryptoPolyfill.mjs.map +1 -0
- package/dist/node/index.d.mts +3 -0
- package/dist/node/index.d.mts.map +1 -0
- package/dist/node/index.d.ts +3 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +50 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/index.mjs +12 -0
- package/dist/node/index.mjs.map +1 -0
- package/dist/nodeIndex.d.mts +3 -0
- package/dist/nodeIndex.d.mts.map +1 -0
- package/dist/nodeIndex.d.ts +3 -0
- package/dist/nodeIndex.d.ts.map +1 -0
- package/dist/nodeIndex.js +54 -0
- package/dist/nodeIndex.js.map +1 -0
- package/dist/nodeIndex.mjs +14 -0
- package/dist/nodeIndex.mjs.map +1 -0
- package/jest.config.cjs +22 -0
- package/package.json +74 -0
- package/src/browser/Crypto.ts +3 -0
- package/src/browser/cryptoPolyfill.ts +22 -0
- package/src/browser/index.ts +2 -0
- package/src/browserIndex.ts +2 -0
- package/src/index.ts +1 -0
- package/src/node/Crypto.ts +3 -0
- package/src/node/cryptoPolyfill.ts +3 -0
- package/src/node/index.ts +2 -0
- package/src/nodeIndex.ts +2 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// src/browser/Crypto.ts
|
|
2
|
+
import BrowserCrypto from "crypto-js";
|
|
3
|
+
|
|
4
|
+
// src/browser/cryptoPolyfill.ts
|
|
5
|
+
var isBrowser = () => {
|
|
6
|
+
return typeof window !== "undefined" && typeof window?.document !== "undefined";
|
|
7
|
+
};
|
|
8
|
+
var isWebworker = () => {
|
|
9
|
+
return typeof self === "object" && self.constructor?.name === "DedicatedWorkerGlobalScope";
|
|
10
|
+
};
|
|
11
|
+
var cryptoPolyfillBrowser = () => {
|
|
12
|
+
const global = isBrowser() ? window : isWebworker() ? self : void 0;
|
|
13
|
+
if (global) {
|
|
14
|
+
if (global.Crypto === void 0) {
|
|
15
|
+
global.Crypto = BrowserCrypto;
|
|
16
|
+
} else {
|
|
17
|
+
global.Crypto = { ...BrowserCrypto, ...global.Crypto };
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
BrowserCrypto,
|
|
23
|
+
BrowserCrypto as Crypto,
|
|
24
|
+
cryptoPolyfillBrowser as bufferPolyfill,
|
|
25
|
+
cryptoPolyfillBrowser
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=browserIndex.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/browser/Crypto.ts","../src/browser/cryptoPolyfill.ts"],"sourcesContent":["import BrowserCrypto from 'crypto-js'\n\nexport { BrowserCrypto }\n","import { BrowserCrypto } from './Crypto'\n\ntype WithOptionalCrypto = { Crypto?: typeof BrowserCrypto }\n\nconst isBrowser = () => {\n return typeof window !== 'undefined' && typeof window?.document !== 'undefined'\n}\n\nconst isWebworker = () => {\n return typeof self === 'object' && self.constructor?.name === 'DedicatedWorkerGlobalScope'\n}\n\nexport const cryptoPolyfillBrowser = () => {\n const global = isBrowser() ? (window as unknown as WithOptionalCrypto) : isWebworker() ? (self as unknown as WithOptionalCrypto) : undefined\n if (global) {\n if (global.Crypto === undefined) {\n global.Crypto = BrowserCrypto\n } else {\n global.Crypto = { ...BrowserCrypto, ...global.Crypto }\n }\n }\n}\n"],"mappings":";AAAA,OAAO,mBAAmB;;;ACI1B,IAAM,YAAY,MAAM;AACtB,SAAO,OAAO,WAAW,eAAe,OAAO,QAAQ,aAAa;AACtE;AAEA,IAAM,cAAc,MAAM;AACxB,SAAO,OAAO,SAAS,YAAY,KAAK,aAAa,SAAS;AAChE;AAEO,IAAM,wBAAwB,MAAM;AACzC,QAAM,SAAS,UAAU,IAAK,SAA2C,YAAY,IAAK,OAAyC;AACnI,MAAI,QAAQ;AACV,QAAI,OAAO,WAAW,QAAW;AAC/B,aAAO,SAAS;AAAA,IAClB,OAAO;AACL,aAAO,SAAS,EAAE,GAAG,eAAe,GAAG,OAAO,OAAO;AAAA,IACvD;AAAA,EACF;AACF;","names":[]}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
|
+
BrowserCrypto: () => import_crypto_js.default,
|
|
34
|
+
Crypto: () => import_crypto_js.default,
|
|
35
|
+
bufferPolyfill: () => cryptoPolyfillBrowser,
|
|
36
|
+
cryptoPolyfillBrowser: () => cryptoPolyfillBrowser
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(src_exports);
|
|
39
|
+
|
|
40
|
+
// src/browser/Crypto.ts
|
|
41
|
+
var import_crypto_js = __toESM(require("crypto-js"));
|
|
42
|
+
|
|
43
|
+
// src/browser/cryptoPolyfill.ts
|
|
44
|
+
var isBrowser = () => {
|
|
45
|
+
return typeof window !== "undefined" && typeof window?.document !== "undefined";
|
|
46
|
+
};
|
|
47
|
+
var isWebworker = () => {
|
|
48
|
+
return typeof self === "object" && self.constructor?.name === "DedicatedWorkerGlobalScope";
|
|
49
|
+
};
|
|
50
|
+
var cryptoPolyfillBrowser = () => {
|
|
51
|
+
const global = isBrowser() ? window : isWebworker() ? self : void 0;
|
|
52
|
+
if (global) {
|
|
53
|
+
if (global.Crypto === void 0) {
|
|
54
|
+
global.Crypto = import_crypto_js.default;
|
|
55
|
+
} else {
|
|
56
|
+
global.Crypto = { ...import_crypto_js.default, ...global.Crypto };
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
+
0 && (module.exports = {
|
|
62
|
+
BrowserCrypto,
|
|
63
|
+
Crypto,
|
|
64
|
+
bufferPolyfill,
|
|
65
|
+
cryptoPolyfillBrowser
|
|
66
|
+
});
|
|
67
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/browser/Crypto.ts","../src/browser/cryptoPolyfill.ts"],"sourcesContent":["export * from './browserIndex'\n","import BrowserCrypto from 'crypto-js'\n\nexport { BrowserCrypto }\n","import { BrowserCrypto } from './Crypto'\n\ntype WithOptionalCrypto = { Crypto?: typeof BrowserCrypto }\n\nconst isBrowser = () => {\n return typeof window !== 'undefined' && typeof window?.document !== 'undefined'\n}\n\nconst isWebworker = () => {\n return typeof self === 'object' && self.constructor?.name === 'DedicatedWorkerGlobalScope'\n}\n\nexport const cryptoPolyfillBrowser = () => {\n const global = isBrowser() ? (window as unknown as WithOptionalCrypto) : isWebworker() ? (self as unknown as WithOptionalCrypto) : undefined\n if (global) {\n if (global.Crypto === undefined) {\n global.Crypto = BrowserCrypto\n } else {\n global.Crypto = { ...BrowserCrypto, ...global.Crypto }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wCAAAA;AAAA,EAAA,+BAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;;;ACAA,uBAA0B;;;ACI1B,IAAM,YAAY,MAAM;AACtB,SAAO,OAAO,WAAW,eAAe,OAAO,QAAQ,aAAa;AACtE;AAEA,IAAM,cAAc,MAAM;AACxB,SAAO,OAAO,SAAS,YAAY,KAAK,aAAa,SAAS;AAChE;AAEO,IAAM,wBAAwB,MAAM;AACzC,QAAM,SAAS,UAAU,IAAK,SAA2C,YAAY,IAAK,OAAyC;AACnI,MAAI,QAAQ;AACV,QAAI,OAAO,WAAW,QAAW;AAC/B,aAAO,SAAS,iBAAAC;AAAA,IAClB,OAAO;AACL,aAAO,SAAS,EAAE,GAAG,iBAAAA,SAAe,GAAG,OAAO,OAAO;AAAA,IACvD;AAAA,EACF;AACF;","names":["BrowserCrypto","BrowserCrypto"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// src/browser/Crypto.ts
|
|
2
|
+
import BrowserCrypto from "crypto-js";
|
|
3
|
+
|
|
4
|
+
// src/browser/cryptoPolyfill.ts
|
|
5
|
+
var isBrowser = () => {
|
|
6
|
+
return typeof window !== "undefined" && typeof window?.document !== "undefined";
|
|
7
|
+
};
|
|
8
|
+
var isWebworker = () => {
|
|
9
|
+
return typeof self === "object" && self.constructor?.name === "DedicatedWorkerGlobalScope";
|
|
10
|
+
};
|
|
11
|
+
var cryptoPolyfillBrowser = () => {
|
|
12
|
+
const global = isBrowser() ? window : isWebworker() ? self : void 0;
|
|
13
|
+
if (global) {
|
|
14
|
+
if (global.Crypto === void 0) {
|
|
15
|
+
global.Crypto = BrowserCrypto;
|
|
16
|
+
} else {
|
|
17
|
+
global.Crypto = { ...BrowserCrypto, ...global.Crypto };
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
BrowserCrypto,
|
|
23
|
+
BrowserCrypto as Crypto,
|
|
24
|
+
cryptoPolyfillBrowser as bufferPolyfill,
|
|
25
|
+
cryptoPolyfillBrowser
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/browser/Crypto.ts","../src/browser/cryptoPolyfill.ts"],"sourcesContent":["import BrowserCrypto from 'crypto-js'\n\nexport { BrowserCrypto }\n","import { BrowserCrypto } from './Crypto'\n\ntype WithOptionalCrypto = { Crypto?: typeof BrowserCrypto }\n\nconst isBrowser = () => {\n return typeof window !== 'undefined' && typeof window?.document !== 'undefined'\n}\n\nconst isWebworker = () => {\n return typeof self === 'object' && self.constructor?.name === 'DedicatedWorkerGlobalScope'\n}\n\nexport const cryptoPolyfillBrowser = () => {\n const global = isBrowser() ? (window as unknown as WithOptionalCrypto) : isWebworker() ? (self as unknown as WithOptionalCrypto) : undefined\n if (global) {\n if (global.Crypto === undefined) {\n global.Crypto = BrowserCrypto\n } else {\n global.Crypto = { ...BrowserCrypto, ...global.Crypto }\n }\n }\n}\n"],"mappings":";AAAA,OAAO,mBAAmB;;;ACI1B,IAAM,YAAY,MAAM;AACtB,SAAO,OAAO,WAAW,eAAe,OAAO,QAAQ,aAAa;AACtE;AAEA,IAAM,cAAc,MAAM;AACxB,SAAO,OAAO,SAAS,YAAY,KAAK,aAAa,SAAS;AAChE;AAEO,IAAM,wBAAwB,MAAM;AACzC,QAAM,SAAS,UAAU,IAAK,SAA2C,YAAY,IAAK,OAAyC;AACnI,MAAI,QAAQ;AACV,QAAI,OAAO,WAAW,QAAW;AAC/B,aAAO,SAAS;AAAA,IAClB,OAAO;AACL,aAAO,SAAS,EAAE,GAAG,eAAe,GAAG,OAAO,OAAO;AAAA,IACvD;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Crypto.d.ts","sourceRoot":"","sources":["../../src/node/Crypto.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,QAAQ,CAAA;AAE/B,OAAO,EAAE,UAAU,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Crypto.d.ts","sourceRoot":"","sources":["../../src/node/Crypto.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,QAAQ,CAAA;AAE/B,OAAO,EAAE,UAAU,EAAE,CAAA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/node/Crypto.ts
|
|
31
|
+
var Crypto_exports = {};
|
|
32
|
+
__export(Crypto_exports, {
|
|
33
|
+
NodeCrypto: () => import_crypto.default
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(Crypto_exports);
|
|
36
|
+
var import_crypto = __toESM(require("crypto"));
|
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
+
0 && (module.exports = {
|
|
39
|
+
NodeCrypto
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=Crypto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/node/Crypto.ts"],"sourcesContent":["import NodeCrypto from 'crypto'\n// eslint-disable-next-line import/no-default-export\nexport { NodeCrypto }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,kCAAAA;AAAA;AAAA;AAAA,oBAAuB;","names":["NodeCrypto"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/node/Crypto.ts"],"sourcesContent":["import NodeCrypto from 'crypto'\n// eslint-disable-next-line import/no-default-export\nexport { NodeCrypto }\n"],"mappings":";AAAA,OAAO,gBAAgB;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cryptoPolyfill.d.ts","sourceRoot":"","sources":["../../src/node/cryptoPolyfill.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,YAE9B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cryptoPolyfill.d.ts","sourceRoot":"","sources":["../../src/node/cryptoPolyfill.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,YAE9B,CAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/node/cryptoPolyfill.ts
|
|
21
|
+
var cryptoPolyfill_exports = {};
|
|
22
|
+
__export(cryptoPolyfill_exports, {
|
|
23
|
+
cryptoPolyfillNode: () => cryptoPolyfillNode
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(cryptoPolyfill_exports);
|
|
26
|
+
var cryptoPolyfillNode = () => {
|
|
27
|
+
return;
|
|
28
|
+
};
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
cryptoPolyfillNode
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=cryptoPolyfill.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/node/cryptoPolyfill.ts"],"sourcesContent":["export const cryptoPolyfillNode = () => {\n return\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,IAAM,qBAAqB,MAAM;AACtC;AACF;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/node/cryptoPolyfill.ts"],"sourcesContent":["export const cryptoPolyfillNode = () => {\n return\n}\n"],"mappings":";AAAO,IAAM,qBAAqB,MAAM;AACtC;AACF;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,kBAAkB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/node/index.ts
|
|
31
|
+
var node_exports = {};
|
|
32
|
+
__export(node_exports, {
|
|
33
|
+
NodeCrypto: () => import_crypto.default,
|
|
34
|
+
cryptoPolyfillNode: () => cryptoPolyfillNode
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(node_exports);
|
|
37
|
+
|
|
38
|
+
// src/node/Crypto.ts
|
|
39
|
+
var import_crypto = __toESM(require("crypto"));
|
|
40
|
+
|
|
41
|
+
// src/node/cryptoPolyfill.ts
|
|
42
|
+
var cryptoPolyfillNode = () => {
|
|
43
|
+
return;
|
|
44
|
+
};
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
NodeCrypto,
|
|
48
|
+
cryptoPolyfillNode
|
|
49
|
+
});
|
|
50
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/node/index.ts","../../src/node/Crypto.ts","../../src/node/cryptoPolyfill.ts"],"sourcesContent":["export * from './Crypto'\nexport * from './cryptoPolyfill'\n","import NodeCrypto from 'crypto'\n// eslint-disable-next-line import/no-default-export\nexport { NodeCrypto }\n","export const cryptoPolyfillNode = () => {\n return\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,kCAAAA;AAAA,EAAA;AAAA;AAAA;;;ACAA,oBAAuB;;;ACAhB,IAAM,qBAAqB,MAAM;AACtC;AACF;","names":["NodeCrypto"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/node/Crypto.ts","../../src/node/cryptoPolyfill.ts"],"sourcesContent":["import NodeCrypto from 'crypto'\n// eslint-disable-next-line import/no-default-export\nexport { NodeCrypto }\n","export const cryptoPolyfillNode = () => {\n return\n}\n"],"mappings":";AAAA,OAAO,gBAAgB;;;ACAhB,IAAM,qBAAqB,MAAM;AACtC;AACF;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodeIndex.d.ts","sourceRoot":"","sources":["../src/nodeIndex.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,OAAO,EAAE,UAAU,IAAI,MAAM,EAAE,kBAAkB,IAAI,cAAc,EAAE,MAAM,QAAQ,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodeIndex.d.ts","sourceRoot":"","sources":["../src/nodeIndex.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,OAAO,EAAE,UAAU,IAAI,MAAM,EAAE,kBAAkB,IAAI,cAAc,EAAE,MAAM,QAAQ,CAAA"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/nodeIndex.ts
|
|
31
|
+
var nodeIndex_exports = {};
|
|
32
|
+
__export(nodeIndex_exports, {
|
|
33
|
+
Crypto: () => import_crypto.default,
|
|
34
|
+
NodeCrypto: () => import_crypto.default,
|
|
35
|
+
cryptoPolyfill: () => cryptoPolyfillNode,
|
|
36
|
+
cryptoPolyfillNode: () => cryptoPolyfillNode
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(nodeIndex_exports);
|
|
39
|
+
|
|
40
|
+
// src/node/Crypto.ts
|
|
41
|
+
var import_crypto = __toESM(require("crypto"));
|
|
42
|
+
|
|
43
|
+
// src/node/cryptoPolyfill.ts
|
|
44
|
+
var cryptoPolyfillNode = () => {
|
|
45
|
+
return;
|
|
46
|
+
};
|
|
47
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
48
|
+
0 && (module.exports = {
|
|
49
|
+
Crypto,
|
|
50
|
+
NodeCrypto,
|
|
51
|
+
cryptoPolyfill,
|
|
52
|
+
cryptoPolyfillNode
|
|
53
|
+
});
|
|
54
|
+
//# sourceMappingURL=nodeIndex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/nodeIndex.ts","../src/node/Crypto.ts","../src/node/cryptoPolyfill.ts"],"sourcesContent":["export * from './node'\nexport { NodeCrypto as Crypto, cryptoPolyfillNode as cryptoPolyfill } from './node'\n","import NodeCrypto from 'crypto'\n// eslint-disable-next-line import/no-default-export\nexport { NodeCrypto }\n","export const cryptoPolyfillNode = () => {\n return\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,8BAAAA;AAAA,EAAA,gCAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;;;ACAA,oBAAuB;;;ACAhB,IAAM,qBAAqB,MAAM;AACtC;AACF;","names":["NodeCrypto"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// src/node/Crypto.ts
|
|
2
|
+
import NodeCrypto from "crypto";
|
|
3
|
+
|
|
4
|
+
// src/node/cryptoPolyfill.ts
|
|
5
|
+
var cryptoPolyfillNode = () => {
|
|
6
|
+
return;
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
NodeCrypto as Crypto,
|
|
10
|
+
NodeCrypto,
|
|
11
|
+
cryptoPolyfillNode as cryptoPolyfill,
|
|
12
|
+
cryptoPolyfillNode
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=nodeIndex.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/node/Crypto.ts","../src/node/cryptoPolyfill.ts"],"sourcesContent":["import NodeCrypto from 'crypto'\n// eslint-disable-next-line import/no-default-export\nexport { NodeCrypto }\n","export const cryptoPolyfillNode = () => {\n return\n}\n"],"mappings":";AAAA,OAAO,gBAAgB;;;ACAhB,IAAM,qBAAqB,MAAM;AACtC;AACF;","names":[]}
|
package/jest.config.cjs
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const generateJestConfig = ({ esModules }) => {
|
|
2
|
+
const esModuleslist = Array.isArray(esModules) ? esModules.join('|') : esModules
|
|
3
|
+
return {
|
|
4
|
+
globals: {
|
|
5
|
+
'ts-jest': {
|
|
6
|
+
tsconfig: 'tsconfig.test.json',
|
|
7
|
+
},
|
|
8
|
+
},
|
|
9
|
+
moduleNameMapper: {
|
|
10
|
+
'^(\\.{1,2}/.*)\\.js$': '$1',
|
|
11
|
+
},
|
|
12
|
+
preset: 'ts-jest/presets/default-esm',
|
|
13
|
+
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$',
|
|
14
|
+
transform: {
|
|
15
|
+
[`(${esModuleslist}).+\\.js$`]: 'babel-jest',
|
|
16
|
+
'^.+\\.tsx?$': 'ts-jest',
|
|
17
|
+
},
|
|
18
|
+
transformIgnorePatterns: [`./node_modules/(?!${esModuleslist})`],
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = generateJestConfig({ esModules: ['is-ip', 'ip-regex'] })
|
package/package.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"license": "LGPL-3.0",
|
|
3
|
+
"name": "@xylabs/crypto",
|
|
4
|
+
"author": {
|
|
5
|
+
"email": "support@xylabs.com",
|
|
6
|
+
"name": "XY Labs Development Team",
|
|
7
|
+
"url": "https://xylabs.com"
|
|
8
|
+
},
|
|
9
|
+
"bugs": {
|
|
10
|
+
"email": "support@xylabs.com",
|
|
11
|
+
"url": "https://github.com/xylabs/sdk-js/issues"
|
|
12
|
+
},
|
|
13
|
+
"description": "Base functionality used throughout XY Labs TypeScript/JavaScript libraries",
|
|
14
|
+
"docs": "dist/docs.json",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"require": {
|
|
18
|
+
"node": {
|
|
19
|
+
"types": "./dist/nodeIndex.d.ts",
|
|
20
|
+
"default": "./dist/nodeIndex.js"
|
|
21
|
+
},
|
|
22
|
+
"types": "./dist/browserIndex.d.ts",
|
|
23
|
+
"default": "./dist/browserIndex.js"
|
|
24
|
+
},
|
|
25
|
+
"import": {
|
|
26
|
+
"node": {
|
|
27
|
+
"types": "./dist/nodeIndex.d.ts",
|
|
28
|
+
"default": "./dist/nodeIndex.mjs"
|
|
29
|
+
},
|
|
30
|
+
"types": "./dist/browserIndex.d.mts",
|
|
31
|
+
"default": "./dist/browserIndex.mjs"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"./docs": {
|
|
35
|
+
"default": "./dist/docs.json"
|
|
36
|
+
},
|
|
37
|
+
"./package.json": "./package.json"
|
|
38
|
+
},
|
|
39
|
+
"main": "dist/index.js",
|
|
40
|
+
"module": "dist/index.mjs",
|
|
41
|
+
"homepage": "https://xylabs.com",
|
|
42
|
+
"keywords": [
|
|
43
|
+
"xylabs",
|
|
44
|
+
"utility",
|
|
45
|
+
"typescript",
|
|
46
|
+
"esm",
|
|
47
|
+
"crypto"
|
|
48
|
+
],
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"crypto-js": "^4.1.1"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@types/crypto-js": "^4.1.2",
|
|
54
|
+
"@types/node": "^20.6.2",
|
|
55
|
+
"@xylabs/ts-scripts-yarn3": "^3.0.28",
|
|
56
|
+
"@xylabs/tsconfig": "^3.0.28",
|
|
57
|
+
"@xylabs/tsconfig-dom": "^3.0.28",
|
|
58
|
+
"typescript": "^5.2.2"
|
|
59
|
+
},
|
|
60
|
+
"publishConfig": {
|
|
61
|
+
"access": "public"
|
|
62
|
+
},
|
|
63
|
+
"repository": {
|
|
64
|
+
"type": "git",
|
|
65
|
+
"url": "https://github.com/xylabs/sdk-js.git"
|
|
66
|
+
},
|
|
67
|
+
"sideEffects": false,
|
|
68
|
+
"version": "2.11.6",
|
|
69
|
+
"xy": {
|
|
70
|
+
"compile": {
|
|
71
|
+
"depth": 1
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BrowserCrypto } from './Crypto'
|
|
2
|
+
|
|
3
|
+
type WithOptionalCrypto = { Crypto?: typeof BrowserCrypto }
|
|
4
|
+
|
|
5
|
+
const isBrowser = () => {
|
|
6
|
+
return typeof window !== 'undefined' && typeof window?.document !== 'undefined'
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const isWebworker = () => {
|
|
10
|
+
return typeof self === 'object' && self.constructor?.name === 'DedicatedWorkerGlobalScope'
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const cryptoPolyfillBrowser = () => {
|
|
14
|
+
const global = isBrowser() ? (window as unknown as WithOptionalCrypto) : isWebworker() ? (self as unknown as WithOptionalCrypto) : undefined
|
|
15
|
+
if (global) {
|
|
16
|
+
if (global.Crypto === undefined) {
|
|
17
|
+
global.Crypto = BrowserCrypto
|
|
18
|
+
} else {
|
|
19
|
+
global.Crypto = { ...BrowserCrypto, ...global.Crypto }
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './browserIndex'
|