@sd-jwt/crypto-nodejs 0.3.2-next.98 → 0.3.2-next.99

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/index.d.mts CHANGED
@@ -1,10 +1,12 @@
1
+ import * as crypto from 'crypto';
2
+
1
3
  declare const generateSalt: (length: number) => string;
2
4
  declare const digest: (data: string, algorithm?: string) => Uint8Array;
3
5
  declare const ES256: {
4
6
  alg: string;
5
7
  generateKeyPair(): Promise<{
6
- publicKey: JsonWebKey;
7
- privateKey: JsonWebKey;
8
+ publicKey: crypto.webcrypto.JsonWebKey;
9
+ privateKey: crypto.webcrypto.JsonWebKey;
8
10
  }>;
9
11
  getSigner(privateKeyJWK: object): Promise<(data: string) => Promise<string>>;
10
12
  getVerifier(publicKeyJWK: object): Promise<(data: string, signatureBase64url: string) => Promise<boolean>>;
package/dist/index.d.ts CHANGED
@@ -1,10 +1,12 @@
1
+ import * as crypto from 'crypto';
2
+
1
3
  declare const generateSalt: (length: number) => string;
2
4
  declare const digest: (data: string, algorithm?: string) => Uint8Array;
3
5
  declare const ES256: {
4
6
  alg: string;
5
7
  generateKeyPair(): Promise<{
6
- publicKey: JsonWebKey;
7
- privateKey: JsonWebKey;
8
+ publicKey: crypto.webcrypto.JsonWebKey;
9
+ privateKey: crypto.webcrypto.JsonWebKey;
8
10
  }>;
9
11
  getSigner(privateKeyJWK: object): Promise<(data: string) => Promise<string>>;
10
12
  getVerifier(publicKeyJWK: object): Promise<(data: string, signatureBase64url: string) => Promise<boolean>>;
package/dist/index.js CHANGED
@@ -68,8 +68,7 @@ var ES256 = {
68
68
  alg: "ES256",
69
69
  generateKeyPair() {
70
70
  return __async(this, null, function* () {
71
- const { subtle } = globalThis.crypto;
72
- const keyPair = yield subtle.generateKey(
71
+ const keyPair = yield import_crypto.subtle.generateKey(
73
72
  {
74
73
  name: "ECDSA",
75
74
  namedCurve: "P-256"
@@ -80,15 +79,14 @@ var ES256 = {
80
79
  ["sign", "verify"]
81
80
  // can be used to sign and verify signatures
82
81
  );
83
- const publicKeyJWK = yield subtle.exportKey("jwk", keyPair.publicKey);
84
- const privateKeyJWK = yield subtle.exportKey("jwk", keyPair.privateKey);
82
+ const publicKeyJWK = yield import_crypto.subtle.exportKey("jwk", keyPair.publicKey);
83
+ const privateKeyJWK = yield import_crypto.subtle.exportKey("jwk", keyPair.privateKey);
85
84
  return { publicKey: publicKeyJWK, privateKey: privateKeyJWK };
86
85
  });
87
86
  },
88
87
  getSigner(privateKeyJWK) {
89
88
  return __async(this, null, function* () {
90
- const { subtle } = globalThis.crypto;
91
- const privateKey = yield subtle.importKey(
89
+ const privateKey = yield import_crypto.subtle.importKey(
92
90
  "jwk",
93
91
  privateKeyJWK,
94
92
  {
@@ -102,7 +100,7 @@ var ES256 = {
102
100
  );
103
101
  return (data) => __async(this, null, function* () {
104
102
  const encoder = new TextEncoder();
105
- const signature = yield subtle.sign(
103
+ const signature = yield import_crypto.subtle.sign(
106
104
  {
107
105
  name: "ECDSA",
108
106
  hash: { name: "SHA-256" }
@@ -117,8 +115,7 @@ var ES256 = {
117
115
  },
118
116
  getVerifier(publicKeyJWK) {
119
117
  return __async(this, null, function* () {
120
- const { subtle } = globalThis.crypto;
121
- const publicKey = yield subtle.importKey(
118
+ const publicKey = yield import_crypto.subtle.importKey(
122
119
  "jwk",
123
120
  publicKeyJWK,
124
121
  {
@@ -136,7 +133,7 @@ var ES256 = {
136
133
  atob(signatureBase64url.replace(/-/g, "+").replace(/_/g, "/")),
137
134
  (c) => c.charCodeAt(0)
138
135
  );
139
- const isValid = yield subtle.verify(
136
+ const isValid = yield import_crypto.subtle.verify(
140
137
  {
141
138
  name: "ECDSA",
142
139
  hash: { name: "SHA-256" }
package/dist/index.mjs CHANGED
@@ -20,7 +20,7 @@ var __async = (__this, __arguments, generator) => {
20
20
  };
21
21
 
22
22
  // src/crypto.ts
23
- import { createHash, randomBytes } from "crypto";
23
+ import { createHash, randomBytes, subtle } from "crypto";
24
24
  var generateSalt = (length) => {
25
25
  if (length <= 0) {
26
26
  return "";
@@ -41,7 +41,6 @@ var ES256 = {
41
41
  alg: "ES256",
42
42
  generateKeyPair() {
43
43
  return __async(this, null, function* () {
44
- const { subtle } = globalThis.crypto;
45
44
  const keyPair = yield subtle.generateKey(
46
45
  {
47
46
  name: "ECDSA",
@@ -60,7 +59,6 @@ var ES256 = {
60
59
  },
61
60
  getSigner(privateKeyJWK) {
62
61
  return __async(this, null, function* () {
63
- const { subtle } = globalThis.crypto;
64
62
  const privateKey = yield subtle.importKey(
65
63
  "jwk",
66
64
  privateKeyJWK,
@@ -90,7 +88,6 @@ var ES256 = {
90
88
  },
91
89
  getVerifier(publicKeyJWK) {
92
90
  return __async(this, null, function* () {
93
- const { subtle } = globalThis.crypto;
94
91
  const publicKey = yield subtle.importKey(
95
92
  "jwk",
96
93
  publicKeyJWK,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sd-jwt/crypto-nodejs",
3
- "version": "0.3.2-next.98+03e028f",
3
+ "version": "0.3.2-next.99+94f33f1",
4
4
  "description": "sd-jwt draft 7 implementation in typescript",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -52,5 +52,5 @@
52
52
  "esm"
53
53
  ]
54
54
  },
55
- "gitHead": "03e028fb452bacb445b35dcc2fb0cc9ef6d53874"
55
+ "gitHead": "94f33f1931393345ad1d0977adad67d407615607"
56
56
  }
package/src/crypto.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { createHash, randomBytes } from 'crypto';
1
+ import { createHash, randomBytes, subtle } from 'crypto';
2
2
 
3
3
  export const generateSalt = (length: number): string => {
4
4
  if (length <= 0) {
@@ -24,7 +24,6 @@ export const ES256 = {
24
24
  alg: 'ES256',
25
25
 
26
26
  async generateKeyPair() {
27
- const { subtle } = globalThis.crypto;
28
27
  const keyPair = await subtle.generateKey(
29
28
  {
30
29
  name: 'ECDSA',
@@ -42,7 +41,6 @@ export const ES256 = {
42
41
  },
43
42
 
44
43
  async getSigner(privateKeyJWK: object) {
45
- const { subtle } = globalThis.crypto;
46
44
  const privateKey = await subtle.importKey(
47
45
  'jwk',
48
46
  privateKeyJWK,
@@ -73,7 +71,6 @@ export const ES256 = {
73
71
  },
74
72
 
75
73
  async getVerifier(publicKeyJWK: object) {
76
- const { subtle } = globalThis.crypto;
77
74
  const publicKey = await subtle.importKey(
78
75
  'jwk',
79
76
  publicKeyJWK,