@gjsify/crypto 0.6.0 → 0.6.1
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/lib/esm/nativescript/algos.js +1 -0
- package/lib/esm/nativescript/hash.js +1 -1
- package/lib/esm/nativescript/hmac.js +1 -1
- package/lib/types/nativescript/algos.d.ts +7 -0
- package/lib/types/nativescript/nativescript.spec.d.ts +2 -0
- package/lib/types/nativescript/stubs.d.ts +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../_virtual/_rolldown/runtime.js";import{sha224 as e,sha256 as t,sha384 as n,sha512 as r,sha512_256 as i}from"@noble/hashes/sha2";import{md5 as a,sha1 as o}from"@noble/hashes/legacy";const s=[`md5`,`sha1`,`sha224`,`sha256`,`sha384`,`sha512`,`sha512-256`];function normalizeAlgorithm(e){return e.toLowerCase().replace(/-/g,``)}const c={sha1:o,sha224:e,sha256:t,sha384:n,sha512:r,sha512256:i,md5:a};function getNobleHash(e){let t=c[normalizeAlgorithm(e)];if(!t){let t=Error(`Unknown message digest: ${e}`);throw t.code=`ERR_CRYPTO_HASH_UNKNOWN`,t}return t}export{s as SUPPORTED_HASHES,getNobleHash,normalizeAlgorithm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../_virtual/_rolldown/runtime.js";import{
|
|
1
|
+
import"../_virtual/_rolldown/runtime.js";import{SUPPORTED_HASHES as e,getNobleHash as t,normalizeAlgorithm as n}from"./algos.js";import{Buffer as r}from"node:buffer";var i=class Hash{_algorithm;_hasher;_finalized=!1;constructor(e){let r=t(e);this._algorithm=n(e),this._hasher=r.create()}update(e,t){if(this._finalized)throw Error(`Digest already called`);let n;return n=typeof e==`string`?r.from(e,t??`utf8`):e instanceof Uint8Array?e:r.from(e),this._hasher.update(n),this}digest(e){if(this._finalized)throw Error(`Digest already called`);this._finalized=!0;let t=this._hasher.digest(),n=r.from(t);return e?n.toString(e):n}copy(){if(this._finalized)throw Error(`Digest already called`);let e=new Hash(this._algorithm);return e._hasher=this._hasher.clone(),e}};function createHash(e){return new i(e)}function getHashes(){return[...e]}function hash(e,t,n){return new i(e).update(t).digest(n)}export{i as Hash,createHash,getHashes,hash};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../_virtual/_rolldown/runtime.js";import{
|
|
1
|
+
import"../_virtual/_rolldown/runtime.js";import{getNobleHash as e}from"./algos.js";import{Buffer as t}from"node:buffer";import{hmac as n}from"@noble/hashes/hmac";var Hmac=class{_hasher;_finalized=!1;constructor(r,i){let a=e(r),o;o=typeof i==`string`?t.from(i,`utf8`):i instanceof Uint8Array?i:t.from(i),this._hasher=n.create(a,o)}update(e,n){if(this._finalized)throw Error(`Digest already called`);let r;return r=typeof e==`string`?t.from(e,n??`utf8`):e instanceof Uint8Array?e:t.from(e),this._hasher.update(r),this}digest(e){if(this._finalized)throw Error(`Digest already called`);this._finalized=!0;let n=this._hasher.digest(),r=t.from(n);return e?r.toString(e):r}};function createHmac(e,t){return new Hmac(e,t)}export{Hmac,createHmac};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type CHash } from '@noble/hashes/utils';
|
|
2
|
+
/** The digest algorithms the NativeScript backend supports, in Node naming. */
|
|
3
|
+
export declare const SUPPORTED_HASHES: readonly ["md5", "sha1", "sha224", "sha256", "sha384", "sha512", "sha512-256"];
|
|
4
|
+
/** Normalise an algorithm name to lowercase without hyphens: "SHA-256" → "sha256". */
|
|
5
|
+
export declare function normalizeAlgorithm(algorithm: string): string;
|
|
6
|
+
/** Resolve a Node digest name to a @noble/hashes hasher, or throw like Node. */
|
|
7
|
+
export declare function getNobleHash(algorithm: string): CHash;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Buffer } from 'node:buffer';
|
|
1
|
+
import type { Buffer } from 'node:buffer';
|
|
2
2
|
export declare function createCipher(..._args: unknown[]): never;
|
|
3
3
|
export declare function createCipheriv(..._args: unknown[]): never;
|
|
4
4
|
export declare function createDecipher(..._args: unknown[]): never;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/crypto",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Node.js crypto module for Gjs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -74,17 +74,17 @@
|
|
|
74
74
|
"crypto"
|
|
75
75
|
],
|
|
76
76
|
"devDependencies": {
|
|
77
|
-
"@gjsify/cli": "^0.6.
|
|
78
|
-
"@gjsify/unit": "^0.6.
|
|
77
|
+
"@gjsify/cli": "^0.6.1",
|
|
78
|
+
"@gjsify/unit": "^0.6.1",
|
|
79
79
|
"@types/diffie-hellman": "^5.0.3",
|
|
80
80
|
"@types/node": "^25.9.2",
|
|
81
81
|
"typescript": "^6.0.3"
|
|
82
82
|
},
|
|
83
83
|
"dependencies": {
|
|
84
84
|
"@girs/glib-2.0": "2.88.0-4.0.4",
|
|
85
|
-
"@gjsify/buffer": "^0.6.
|
|
86
|
-
"@gjsify/stream": "^0.6.
|
|
87
|
-
"@gjsify/utils": "^0.6.
|
|
85
|
+
"@gjsify/buffer": "^0.6.1",
|
|
86
|
+
"@gjsify/stream": "^0.6.1",
|
|
87
|
+
"@gjsify/utils": "^0.6.1",
|
|
88
88
|
"@noble/hashes": "^1.5.0"
|
|
89
89
|
},
|
|
90
90
|
"gjsify": {
|