@nuggetslife/vc-multiplatform 1.3.2 → 1.5.0

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 (3) hide show
  1. package/index.d.ts +29 -0
  2. package/index.js +137 -48
  3. package/package.json +11 -6
package/index.d.ts CHANGED
@@ -22,6 +22,23 @@ export {
22
22
  verifyCommitment,
23
23
  unblindSignature,
24
24
  deriveProofHolderBound,
25
+ // JOSE enums (prefixed names)
26
+ JoseNamedCurve,
27
+ JoseContentEncryption,
28
+ JoseKeyEncryption,
29
+ JoseSigningAlgorithm,
30
+ // JOSE functions
31
+ generateJwk,
32
+ generateKeyPair,
33
+ joseEncrypt,
34
+ joseDecrypt,
35
+ generalEncryptJson,
36
+ decryptJson,
37
+ compactSignJson,
38
+ compactJsonVerify,
39
+ flattenedSignJson,
40
+ jsonVerify,
41
+ generalSignJson,
25
42
  // Types
26
43
  type BoundSignatureSuiteOptions,
27
44
  type BoundCreateProofOptions,
@@ -44,4 +61,16 @@ export {
44
61
  type KeyPairSignerOptions,
45
62
  type KeyPairVerifierOptions,
46
63
  type BoundKeyPairOptions,
64
+ type JoseEncryptResult,
47
65
  } from '@nuggetslife/vc'
66
+
67
+ // JOSE enum aliases matching ffi-jose names
68
+ export { JoseNamedCurve as NamedCurve } from '@nuggetslife/vc'
69
+ export { JoseContentEncryption as ContentEncryption } from '@nuggetslife/vc'
70
+ export { JoseKeyEncryption as KeyEncryption } from '@nuggetslife/vc'
71
+ export { JoseSigningAlgorithm as SigningAlgorithm } from '@nuggetslife/vc'
72
+ // generateJWK alias (ffi-jose uses capital JWK)
73
+ export { generateJwk as generateJWK } from '@nuggetslife/vc'
74
+
75
+ // JWK type for ffi-jose compatibility
76
+ export type JWK = Record<string, any>
package/index.js CHANGED
@@ -1,5 +1,7 @@
1
- // NodeJS Support
2
- //
1
+ // Platform detection: try NAPI (NodeJS) first, fall back to RN (React Native)
2
+ let loaded = false
3
+
4
+ // NodeJS Support (NAPI)
3
5
  try {
4
6
  const nativeBinding = require('@nuggetslife/vc')
5
7
  const {
@@ -26,6 +28,23 @@ try {
26
28
  verifyCommitment,
27
29
  unblindSignature,
28
30
  deriveProofHolderBound,
31
+ // JOSE enums
32
+ JoseNamedCurve,
33
+ JoseContentEncryption,
34
+ JoseKeyEncryption,
35
+ JoseSigningAlgorithm,
36
+ // JOSE functions
37
+ generateJwk,
38
+ generateKeyPair,
39
+ joseEncrypt,
40
+ joseDecrypt,
41
+ generalEncryptJson,
42
+ decryptJson,
43
+ compactSignJson,
44
+ compactJsonVerify,
45
+ flattenedSignJson,
46
+ jsonVerify,
47
+ generalSignJson,
29
48
  } = nativeBinding
30
49
  module.exports.Bls12381G2KeyPair = Bls12381G2KeyPair
31
50
  module.exports.KeyPairSigner = KeyPairSigner
@@ -44,52 +63,122 @@ try {
44
63
  module.exports.verifyCommitment = verifyCommitment
45
64
  module.exports.unblindSignature = unblindSignature
46
65
  module.exports.deriveProofHolderBound = deriveProofHolderBound
66
+ module.exports.JoseNamedCurve = JoseNamedCurve
67
+ module.exports.JoseContentEncryption = JoseContentEncryption
68
+ module.exports.JoseKeyEncryption = JoseKeyEncryption
69
+ module.exports.JoseSigningAlgorithm = JoseSigningAlgorithm
70
+ module.exports.generateJwk = generateJwk
71
+ module.exports.generateKeyPair = generateKeyPair
72
+ module.exports.joseEncrypt = joseEncrypt
73
+ module.exports.joseDecrypt = joseDecrypt
74
+ module.exports.generalEncryptJson = generalEncryptJson
75
+ module.exports.decryptJson = decryptJson
76
+ module.exports.compactSignJson = compactSignJson
77
+ module.exports.compactJsonVerify = compactJsonVerify
78
+ module.exports.flattenedSignJson = flattenedSignJson
79
+ module.exports.jsonVerify = jsonVerify
80
+ module.exports.generalSignJson = generalSignJson
81
+ // Aliases matching ffi-jose enum names
82
+ module.exports.NamedCurve = JoseNamedCurve
83
+ module.exports.ContentEncryption = JoseContentEncryption
84
+ module.exports.KeyEncryption = JoseKeyEncryption
85
+ module.exports.SigningAlgorithm = JoseSigningAlgorithm
86
+ // Alias for generateJWK (ffi-jose uses capital JWK)
87
+ module.exports.generateJWK = generateJwk
88
+ loaded = true
47
89
  } catch (e) {
48
- throw new Error(`failed to load native binding: ${e}`)
90
+ // NAPI not available will try RN below
91
+ }
92
+
93
+ // React Native Support (UniFFI)
94
+ if (!loaded) {
95
+ try {
96
+ const nativeBinding = require('@nuggetslife/vc-rn')
97
+ const {
98
+ // Key pairs (KeyPairSigner/KeyPairVerifier are type-only in RN)
99
+ Bls12381G2KeyPair,
100
+ BoundBls12381G2KeyPair,
101
+ // BBS+ signature suites
102
+ BbsBlsSignature2020,
103
+ BbsBlsSignatureProof2020,
104
+ // Holder-bound signature suites
105
+ BbsBlsHolderBoundSignature2022,
106
+ BbsBlsHolderBoundSignatureProof2022,
107
+ // JSON-LD processor
108
+ JsonLd,
109
+ // Linked data signature functions
110
+ ldSign,
111
+ ldVerify,
112
+ ldDeriveProof,
113
+ deriveProof,
114
+ // Blind signing functions
115
+ createCommitment,
116
+ verifyCommitment,
117
+ unblindSignature,
118
+ deriveProofHolderBound,
119
+ // JOSE enums
120
+ JoseNamedCurve,
121
+ JoseContentEncryption,
122
+ JoseKeyEncryption,
123
+ JoseSigningAlgorithm,
124
+ // JOSE functions
125
+ generateJwk,
126
+ generateKeyPair,
127
+ joseEncrypt,
128
+ joseDecrypt,
129
+ generalEncryptJson,
130
+ decryptJson,
131
+ compactSignJson,
132
+ compactJsonVerify,
133
+ flattenedSignJson,
134
+ jsonVerify,
135
+ generalSignJson,
136
+ } = nativeBinding
137
+ module.exports.Bls12381G2KeyPair = Bls12381G2KeyPair
138
+ module.exports.BoundBls12381G2KeyPair = BoundBls12381G2KeyPair
139
+ module.exports.BbsBlsSignature2020 = BbsBlsSignature2020
140
+ module.exports.BbsBlsSignatureProof2020 = BbsBlsSignatureProof2020
141
+ module.exports.BbsBlsHolderBoundSignature2022 = BbsBlsHolderBoundSignature2022
142
+ module.exports.BbsBlsHolderBoundSignatureProof2022 = BbsBlsHolderBoundSignatureProof2022
143
+ module.exports.JsonLd = JsonLd
144
+ module.exports.ldSign = ldSign
145
+ module.exports.ldVerify = ldVerify
146
+ module.exports.ldDeriveProof = ldDeriveProof
147
+ module.exports.deriveProof = deriveProof
148
+ module.exports.createCommitment = createCommitment
149
+ module.exports.verifyCommitment = verifyCommitment
150
+ module.exports.unblindSignature = unblindSignature
151
+ module.exports.deriveProofHolderBound = deriveProofHolderBound
152
+ module.exports.JoseNamedCurve = JoseNamedCurve
153
+ module.exports.JoseContentEncryption = JoseContentEncryption
154
+ module.exports.JoseKeyEncryption = JoseKeyEncryption
155
+ module.exports.JoseSigningAlgorithm = JoseSigningAlgorithm
156
+ module.exports.generateJwk = generateJwk
157
+ module.exports.generateKeyPair = generateKeyPair
158
+ module.exports.joseEncrypt = joseEncrypt
159
+ module.exports.joseDecrypt = joseDecrypt
160
+ module.exports.generalEncryptJson = generalEncryptJson
161
+ module.exports.decryptJson = decryptJson
162
+ module.exports.compactSignJson = compactSignJson
163
+ module.exports.compactJsonVerify = compactJsonVerify
164
+ module.exports.flattenedSignJson = flattenedSignJson
165
+ module.exports.jsonVerify = jsonVerify
166
+ module.exports.generalSignJson = generalSignJson
167
+ // Aliases matching ffi-jose enum names
168
+ module.exports.NamedCurve = JoseNamedCurve
169
+ module.exports.ContentEncryption = JoseContentEncryption
170
+ module.exports.KeyEncryption = JoseKeyEncryption
171
+ module.exports.SigningAlgorithm = JoseSigningAlgorithm
172
+ // Alias for generateJWK (ffi-jose uses capital JWK)
173
+ module.exports.generateJWK = generateJwk
174
+ loaded = true
175
+ } catch (e) {
176
+ // RN not available either
177
+ }
49
178
  }
50
179
 
51
- // React Native Support
52
- //
53
- // try {
54
- // const nativeBinding = require('@nuggetslife/vc-rn')
55
- // const {
56
- // // Key pairs
57
- // Bls12381G2KeyPair,
58
- // BoundBls12381G2KeyPair,
59
- // // BBS+ signature suites
60
- // BbsBlsSignature2020,
61
- // BbsBlsSignatureProof2020,
62
- // // Holder-bound signature suites
63
- // BbsBlsHolderBoundSignature2022,
64
- // BbsBlsHolderBoundSignatureProof2022,
65
- // // JSON-LD processor
66
- // JsonLd,
67
- // // Linked data signature functions
68
- // ldSign,
69
- // ldVerify,
70
- // ldDeriveProof,
71
- // deriveProof,
72
- // // Blind signing functions
73
- // createCommitment,
74
- // verifyCommitment,
75
- // unblindSignature,
76
- // deriveProofHolderBound,
77
- // } = nativeBinding
78
- // module.exports.Bls12381G2KeyPair = Bls12381G2KeyPair
79
- // module.exports.BoundBls12381G2KeyPair = BoundBls12381G2KeyPair
80
- // module.exports.BbsBlsSignature2020 = BbsBlsSignature2020
81
- // module.exports.BbsBlsSignatureProof2020 = BbsBlsSignatureProof2020
82
- // module.exports.BbsBlsHolderBoundSignature2022 = BbsBlsHolderBoundSignature2022
83
- // module.exports.BbsBlsHolderBoundSignatureProof2022 = BbsBlsHolderBoundSignatureProof2022
84
- // module.exports.JsonLd = JsonLd
85
- // module.exports.ldSign = ldSign
86
- // module.exports.ldVerify = ldVerify
87
- // module.exports.ldDeriveProof = ldDeriveProof
88
- // module.exports.deriveProof = deriveProof
89
- // module.exports.createCommitment = createCommitment
90
- // module.exports.verifyCommitment = verifyCommitment
91
- // module.exports.unblindSignature = unblindSignature
92
- // module.exports.deriveProofHolderBound = deriveProofHolderBound
93
- // } catch (e) {
94
- // throw new Error(`failed to load: ${e}`)
95
- // }
180
+ if (!loaded) {
181
+ throw new Error(
182
+ 'Failed to load native binding: neither @nuggetslife/vc (NAPI) nor @nuggetslife/vc-rn (React Native) is available'
183
+ )
184
+ }
package/package.json CHANGED
@@ -1,16 +1,21 @@
1
1
  {
2
2
  "name": "@nuggetslife/vc-multiplatform",
3
- "version": "1.3.2",
4
- "description": "Multiplatform support for VC library",
3
+ "version": "1.5.0",
4
+ "description": "Multiplatform Verifiable Credentials library — NAPI (Node.js) with React Native fallback",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "scripts": {
8
8
  "test": "echo \"Error: no test specified\" && exit 1"
9
9
  },
10
- "author": "",
11
- "license": "ISC",
10
+ "author": "Harry Anderson <harry@nuggets.life> (https://github.com/harry-anderson)",
11
+ "license": "MIT",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/NuggetsLtd/clientffi.git"
15
+ },
16
+ "homepage": "https://github.com/NuggetsLtd/clientffi#readme",
12
17
  "optionalDependencies": {
13
- "@nuggetslife/vc": "0.0.21",
14
- "@nuggetslife/vc-rn": "0.1.9"
18
+ "@nuggetslife/vc": "0.0.23",
19
+ "@nuggetslife/vc-rn": "0.2.0"
15
20
  }
16
21
  }