@bsv/sdk 1.2.20 → 1.2.21

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 (154) hide show
  1. package/dist/cjs/package.json +3 -3
  2. package/dist/cjs/src/auth/Peer.js +536 -0
  3. package/dist/cjs/src/auth/Peer.js.map +1 -0
  4. package/dist/cjs/src/auth/SessionManager.js +66 -0
  5. package/dist/cjs/src/auth/SessionManager.js.map +1 -0
  6. package/dist/cjs/src/auth/{Certificate.js → certificates/Certificate.js} +22 -26
  7. package/dist/cjs/src/auth/certificates/Certificate.js.map +1 -0
  8. package/dist/cjs/src/auth/certificates/MasterCertificate.js +79 -0
  9. package/dist/cjs/src/auth/certificates/MasterCertificate.js.map +1 -0
  10. package/dist/cjs/src/auth/certificates/VerifiableCertificate.js +49 -0
  11. package/dist/cjs/src/auth/certificates/VerifiableCertificate.js.map +1 -0
  12. package/dist/cjs/src/auth/certificates/index.js +25 -0
  13. package/dist/cjs/src/auth/certificates/index.js.map +1 -0
  14. package/dist/cjs/src/auth/clients/AuthFetch.js +411 -0
  15. package/dist/cjs/src/auth/clients/AuthFetch.js.map +1 -0
  16. package/dist/cjs/src/auth/clients/index.js +18 -0
  17. package/dist/cjs/src/auth/clients/index.js.map +1 -0
  18. package/dist/cjs/src/auth/index.js +20 -5
  19. package/dist/cjs/src/auth/index.js.map +1 -1
  20. package/dist/cjs/src/auth/transports/SimplifiedFetchTransport.js +259 -0
  21. package/dist/cjs/src/auth/transports/SimplifiedFetchTransport.js.map +1 -0
  22. package/dist/cjs/src/auth/transports/index.js +18 -0
  23. package/dist/cjs/src/auth/transports/index.js.map +1 -0
  24. package/dist/cjs/src/auth/types.js +3 -0
  25. package/dist/cjs/src/auth/types.js.map +1 -0
  26. package/dist/cjs/src/auth/utils/certificateHelpers.js +51 -0
  27. package/dist/cjs/src/auth/utils/certificateHelpers.js.map +1 -0
  28. package/dist/cjs/src/auth/utils/createNonce.js +19 -0
  29. package/dist/cjs/src/auth/utils/createNonce.js.map +1 -0
  30. package/dist/cjs/src/auth/utils/getVerifiableCertificates.js +31 -0
  31. package/dist/cjs/src/auth/utils/getVerifiableCertificates.js.map +1 -0
  32. package/dist/cjs/src/auth/utils/index.js +21 -0
  33. package/dist/cjs/src/auth/utils/index.js.map +1 -0
  34. package/dist/cjs/src/auth/utils/validateCertificates.js +42 -0
  35. package/dist/cjs/src/auth/utils/validateCertificates.js.map +1 -0
  36. package/dist/cjs/src/auth/utils/verifyNonce.js +27 -0
  37. package/dist/cjs/src/auth/utils/verifyNonce.js.map +1 -0
  38. package/dist/cjs/src/wallet/substrates/WalletWireProcessor.js +1 -1
  39. package/dist/cjs/src/wallet/substrates/WalletWireProcessor.js.map +1 -1
  40. package/dist/cjs/src/wallet/substrates/WalletWireTransceiver.js +148 -148
  41. package/dist/cjs/src/wallet/substrates/WalletWireTransceiver.js.map +1 -1
  42. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  43. package/dist/esm/src/auth/Peer.js +533 -0
  44. package/dist/esm/src/auth/Peer.js.map +1 -0
  45. package/dist/esm/src/auth/SessionManager.js +63 -0
  46. package/dist/esm/src/auth/SessionManager.js.map +1 -0
  47. package/dist/esm/src/auth/{Certificate.js → certificates/Certificate.js} +1 -2
  48. package/dist/esm/src/auth/certificates/Certificate.js.map +1 -0
  49. package/dist/esm/src/auth/certificates/MasterCertificate.js +73 -0
  50. package/dist/esm/src/auth/certificates/MasterCertificate.js.map +1 -0
  51. package/dist/esm/src/auth/certificates/VerifiableCertificate.js +44 -0
  52. package/dist/esm/src/auth/certificates/VerifiableCertificate.js.map +1 -0
  53. package/dist/esm/src/auth/certificates/index.js +4 -0
  54. package/dist/esm/src/auth/certificates/index.js.map +1 -0
  55. package/dist/esm/src/auth/clients/AuthFetch.js +409 -0
  56. package/dist/esm/src/auth/clients/AuthFetch.js.map +1 -0
  57. package/dist/esm/src/auth/clients/index.js +2 -0
  58. package/dist/esm/src/auth/clients/index.js.map +1 -0
  59. package/dist/esm/src/auth/index.js +7 -1
  60. package/dist/esm/src/auth/index.js.map +1 -1
  61. package/dist/esm/src/auth/transports/SimplifiedFetchTransport.js +258 -0
  62. package/dist/esm/src/auth/transports/SimplifiedFetchTransport.js.map +1 -0
  63. package/dist/esm/src/auth/transports/index.js +2 -0
  64. package/dist/esm/src/auth/transports/index.js.map +1 -0
  65. package/dist/esm/src/auth/types.js +2 -0
  66. package/dist/esm/src/auth/types.js.map +1 -0
  67. package/dist/esm/src/auth/utils/certificateHelpers.js +47 -0
  68. package/dist/esm/src/auth/utils/certificateHelpers.js.map +1 -0
  69. package/dist/esm/src/auth/utils/createNonce.js +16 -0
  70. package/dist/esm/src/auth/utils/createNonce.js.map +1 -0
  71. package/dist/esm/src/auth/utils/getVerifiableCertificates.js +27 -0
  72. package/dist/esm/src/auth/utils/getVerifiableCertificates.js.map +1 -0
  73. package/dist/esm/src/auth/utils/index.js +5 -0
  74. package/dist/esm/src/auth/utils/index.js.map +1 -0
  75. package/dist/esm/src/auth/utils/validateCertificates.js +38 -0
  76. package/dist/esm/src/auth/utils/validateCertificates.js.map +1 -0
  77. package/dist/esm/src/auth/utils/verifyNonce.js +24 -0
  78. package/dist/esm/src/auth/utils/verifyNonce.js.map +1 -0
  79. package/dist/esm/src/wallet/substrates/WalletWireProcessor.js +1 -1
  80. package/dist/esm/src/wallet/substrates/WalletWireProcessor.js.map +1 -1
  81. package/dist/esm/src/wallet/substrates/WalletWireTransceiver.js +1 -1
  82. package/dist/esm/src/wallet/substrates/WalletWireTransceiver.js.map +1 -1
  83. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  84. package/dist/types/src/auth/Peer.d.ts +193 -0
  85. package/dist/types/src/auth/Peer.d.ts.map +1 -0
  86. package/dist/types/src/auth/SessionManager.d.ts +42 -0
  87. package/dist/types/src/auth/SessionManager.d.ts.map +1 -0
  88. package/dist/types/src/auth/{Certificate.d.ts → certificates/Certificate.d.ts} +1 -1
  89. package/dist/types/src/auth/certificates/Certificate.d.ts.map +1 -0
  90. package/dist/types/src/auth/certificates/MasterCertificate.d.ts +38 -0
  91. package/dist/types/src/auth/certificates/MasterCertificate.d.ts.map +1 -0
  92. package/dist/types/src/auth/certificates/VerifiableCertificate.d.ts +26 -0
  93. package/dist/types/src/auth/certificates/VerifiableCertificate.d.ts.map +1 -0
  94. package/dist/types/src/auth/certificates/index.d.ts +4 -0
  95. package/dist/types/src/auth/certificates/index.d.ts.map +1 -0
  96. package/dist/types/src/auth/clients/AuthFetch.d.ts +87 -0
  97. package/dist/types/src/auth/clients/AuthFetch.d.ts.map +1 -0
  98. package/dist/types/src/auth/clients/index.d.ts +2 -0
  99. package/dist/types/src/auth/clients/index.d.ts.map +1 -0
  100. package/dist/types/src/auth/index.d.ts +7 -1
  101. package/dist/types/src/auth/index.d.ts.map +1 -1
  102. package/dist/types/src/auth/transports/SimplifiedFetchTransport.d.ts +51 -0
  103. package/dist/types/src/auth/transports/SimplifiedFetchTransport.d.ts.map +1 -0
  104. package/dist/types/src/auth/transports/index.d.ts +2 -0
  105. package/dist/types/src/auth/transports/index.d.ts.map +1 -0
  106. package/dist/types/src/auth/types.d.ts +31 -0
  107. package/dist/types/src/auth/types.d.ts.map +1 -0
  108. package/dist/types/src/auth/utils/certificateHelpers.d.ts +26 -0
  109. package/dist/types/src/auth/utils/certificateHelpers.d.ts.map +1 -0
  110. package/dist/types/src/auth/utils/createNonce.d.ts +8 -0
  111. package/dist/types/src/auth/utils/createNonce.d.ts.map +1 -0
  112. package/dist/types/src/auth/utils/getVerifiableCertificates.d.ts +13 -0
  113. package/dist/types/src/auth/utils/getVerifiableCertificates.d.ts.map +1 -0
  114. package/dist/types/src/auth/utils/index.d.ts +5 -0
  115. package/dist/types/src/auth/utils/index.d.ts.map +1 -0
  116. package/dist/types/src/auth/utils/validateCertificates.d.ts +12 -0
  117. package/dist/types/src/auth/utils/validateCertificates.d.ts.map +1 -0
  118. package/dist/types/src/auth/utils/verifyNonce.d.ts +9 -0
  119. package/dist/types/src/auth/utils/verifyNonce.d.ts.map +1 -0
  120. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  121. package/dist/umd/bundle.js +1 -1
  122. package/docs/README.md +1 -0
  123. package/docs/auth.md +1119 -0
  124. package/package.json +13 -3
  125. package/src/auth/Peer.ts +600 -0
  126. package/src/auth/SessionManager.ts +71 -0
  127. package/src/auth/__tests/Peer.test.ts +599 -0
  128. package/src/auth/__tests/SessionManager.test.ts +87 -0
  129. package/src/auth/{Certificate.ts → certificates/Certificate.ts} +15 -8
  130. package/src/auth/certificates/MasterCertificate.ts +106 -0
  131. package/src/auth/certificates/VerifiableCertificate.ts +73 -0
  132. package/src/auth/certificates/__tests/Certificate.test.ts +282 -0
  133. package/src/auth/certificates/index.ts +3 -0
  134. package/src/auth/clients/AuthFetch.ts +482 -0
  135. package/src/auth/clients/index.ts +1 -0
  136. package/src/auth/index.ts +7 -1
  137. package/src/auth/transports/SimplifiedFetchTransport.ts +288 -0
  138. package/src/auth/transports/index.ts +1 -0
  139. package/src/auth/types.ts +41 -0
  140. package/src/auth/utils/__tests/cryptononce.test.ts +84 -0
  141. package/src/auth/utils/__tests/getVerifiableCertificates.test.ts +126 -0
  142. package/src/auth/utils/__tests/validateCertificates.test.ts +142 -0
  143. package/src/auth/utils/certificateHelpers.ts +86 -0
  144. package/src/auth/utils/createNonce.ts +16 -0
  145. package/src/auth/utils/getVerifiableCertificates.ts +40 -0
  146. package/src/auth/utils/index.ts +4 -0
  147. package/src/auth/utils/validateCertificates.ts +54 -0
  148. package/src/auth/utils/verifyNonce.ts +27 -0
  149. package/src/wallet/substrates/WalletWireProcessor.ts +1 -1
  150. package/src/wallet/substrates/WalletWireTransceiver.ts +1 -1
  151. package/dist/cjs/src/auth/Certificate.js.map +0 -1
  152. package/dist/esm/src/auth/Certificate.js.map +0 -1
  153. package/dist/types/src/auth/Certificate.d.ts.map +0 -1
  154. package/src/auth/__tests/Certificate.test.ts +0 -282
@@ -0,0 +1,86 @@
1
+ import { PrivateKey, SymmetricKey, Utils, Wallet, ProtoWallet } from "../../../mod.js"
2
+ import { MasterCertificate } from "../certificates/MasterCertificate.js"
3
+ import { VerifiableCertificate } from "../certificates/VerifiableCertificate.js"
4
+
5
+ /**
6
+ * Creates a Master Certificate by encrypting provided fields and generating a master keyring.
7
+ *
8
+ * @param {Wallet} wallet - The wallet instance used for encryption and public key retrieval.
9
+ * @param {Record<string, string>} fields - The certificate fields to encrypt.
10
+ * @param {string} certificateType - The type of the certificate being created.
11
+ * @param {string} certificateSerialNumber - The serial number of the certificate.
12
+ * @param {string} certifierPublicKey - The public key of the certifier.
13
+ * @returns {Promise<MasterCertificate>} A promise resolving to the created Master Certificate.
14
+ */
15
+ export async function createMasterCertificate(
16
+ wallet: Wallet,
17
+ fields: Record<string, string>,
18
+ certificateType: string,
19
+ certificateSerialNumber: string,
20
+ certifierPublicKey: string
21
+ ): Promise<MasterCertificate> {
22
+ const certificateFields: Record<string, string> = {}
23
+ const masterKeyring: Record<string, string> = {}
24
+
25
+ for (const fieldName in fields) {
26
+ const fieldSymmetricKey = SymmetricKey.fromRandom()
27
+ const encryptedFieldValue = fieldSymmetricKey.encrypt(Utils.toArray(fields[fieldName], 'utf8'))
28
+ certificateFields[fieldName] = Utils.toBase64(encryptedFieldValue as number[])
29
+
30
+ const encryptedFieldKey = await wallet.encrypt({
31
+ plaintext: fieldSymmetricKey.toArray(),
32
+ protocolID: [2, 'certificate field encryption'],
33
+ keyID: `${certificateSerialNumber} ${fieldName}`,
34
+ counterparty: 'self'
35
+ })
36
+ masterKeyring[fieldName] = Utils.toBase64(encryptedFieldKey.ciphertext)
37
+ }
38
+
39
+ return new MasterCertificate(
40
+ certificateType,
41
+ certificateSerialNumber,
42
+ (await wallet.getPublicKey({ identityKey: true })).publicKey,
43
+ certifierPublicKey,
44
+ 'revocationOutpoint',
45
+ certificateFields,
46
+ masterKeyring
47
+ )
48
+ }
49
+
50
+ /**
51
+ * Creates a Verifiable Certificate by signing a Master Certificate and generating a keyring for a verifier.
52
+ *
53
+ * @param {MasterCertificate} masterCertificate - The master certificate to convert into a verifiable certificate.
54
+ * @param {Wallet} wallet - The wallet instance used for generating a keyring for the verifier.
55
+ * @param {string} verifierIdentityKey - The identity key of the verifier.
56
+ * @param {string[]} fieldsToReveal - The list of fields to reveal to the verifier.
57
+ * @param {PrivateKey} certifierPrivateKey - The private key of the certifier for signing the certificate.
58
+ * @returns {Promise<VerifiableCertificate>} A promise resolving to the created Verifiable Certificate.
59
+ */
60
+ export async function createVerifiableCertificate(
61
+ masterCertificate: MasterCertificate,
62
+ wallet: Wallet,
63
+ verifierIdentityKey: string,
64
+ fieldsToReveal: string[],
65
+ certifierPrivateKey: PrivateKey
66
+ ): Promise<VerifiableCertificate> {
67
+ const certifierWallet = new ProtoWallet(certifierPrivateKey)
68
+ await masterCertificate.sign(certifierWallet)
69
+
70
+ const keyringForVerifier = await masterCertificate.createKeyringForVerifier(
71
+ wallet,
72
+ verifierIdentityKey,
73
+ fieldsToReveal
74
+ )
75
+
76
+ return new VerifiableCertificate(
77
+ masterCertificate.type,
78
+ masterCertificate.serialNumber,
79
+ masterCertificate.subject,
80
+ masterCertificate.certifier,
81
+ masterCertificate.revocationOutpoint,
82
+ masterCertificate.fields,
83
+ masterCertificate.signature,
84
+ keyringForVerifier
85
+ )
86
+ }
@@ -0,0 +1,16 @@
1
+ import { Utils, Random, Wallet } from '../../../mod.js'
2
+
3
+ /**
4
+ * Creates a nonce derived from a privateKey
5
+ * @param wallet
6
+ * @returns A random nonce derived with a wallet
7
+ */
8
+ export async function createNonce(wallet: Wallet): Promise<string> {
9
+ // Generate 16 random bytes for the first half of the data
10
+ const firstHalf = Random(16)
11
+ // Create an sha256 HMAC
12
+ const { hmac } = await wallet.createHmac({ protocolID: [2, 'server hmac'], keyID: Utils.toUTF8(firstHalf), data: firstHalf, counterparty: 'self' })
13
+ // Concatenate firstHalf and secondHalf as the nonce bytes
14
+ const nonceBytes = [...firstHalf, ...hmac]
15
+ return Utils.toBase64(nonceBytes)
16
+ }
@@ -0,0 +1,40 @@
1
+ import { VerifiableCertificate } from "../certificates/VerifiableCertificate.js"
2
+ import { Wallet } from "../../../mod.js"
3
+ import { RequestedCertificateSet } from "../types.js"
4
+
5
+ /**
6
+ * Retrieves an array of verifiable certificates based on the request.
7
+ *
8
+ * @private
9
+ * @param {RequestedCertificateSet} requestedCertificates - The set of certificates requested by the peer.
10
+ * @param {string} verifierIdentityKey - The public key of the verifier requesting the certificates.
11
+ * @returns {Promise<VerifiableCertificate[]>} An array of verifiable certificates.
12
+ */
13
+ export const getVerifiableCertificates = async (wallet: Wallet, requestedCertificates: RequestedCertificateSet, verifierIdentityKey: string): Promise<VerifiableCertificate[]> => {
14
+ // Find matching certificates we have
15
+ // Note: This may return multiple certificates that match the correct type.
16
+ const matchingCertificates = await wallet.listCertificates({
17
+ certifiers: requestedCertificates.certifiers,
18
+ types: Object.keys(requestedCertificates.types)
19
+ })
20
+
21
+ // For each certificate requested, create a verifiable cert with selectively revealed fields
22
+ return await Promise.all(
23
+ matchingCertificates.certificates.map(async certificate => {
24
+ const { keyringForVerifier } = await wallet.proveCertificate({
25
+ certificate,
26
+ fieldsToReveal: requestedCertificates.types[certificate.type],
27
+ verifier: verifierIdentityKey
28
+ })
29
+ return new VerifiableCertificate(
30
+ certificate.type,
31
+ certificate.serialNumber,
32
+ certificate.subject,
33
+ certificate.certifier,
34
+ certificate.revocationOutpoint,
35
+ certificate.fields,
36
+ certificate.signature,
37
+ keyringForVerifier
38
+ )
39
+ }))
40
+ }
@@ -0,0 +1,4 @@
1
+ export * from './verifyNonce.js'
2
+ export * from './createNonce.js'
3
+ export * from './getVerifiableCertificates.js'
4
+ export * from './validateCertificates.js'
@@ -0,0 +1,54 @@
1
+ import { Wallet } from "../../wallet/index.js"
2
+ import { AuthMessage, RequestedCertificateSet } from "../types.js"
3
+ import { VerifiableCertificate } from "../certificates/VerifiableCertificate.js"
4
+
5
+ /**
6
+ * Validates and processes the certificates received from a peer.
7
+ *
8
+ * @private
9
+ * @param {AuthMessage} message - The message containing the certificates to validate.
10
+ * @returns {Promise<void>}
11
+ * @throws Will throw an error if certificate validation or field decryption fails.
12
+ */
13
+ export const validateCertificates = async (verifierWallet: Wallet, message: AuthMessage, certificatesRequested?: RequestedCertificateSet): Promise<void> => {
14
+ await Promise.all(message.certificates.map(async (incomingCert: VerifiableCertificate) => {
15
+ if (incomingCert.subject !== message.identityKey) {
16
+ throw new Error(`The subject of one of your certificates ("${incomingCert.subject}") is not the same as the request sender ("${message.identityKey}").`)
17
+ }
18
+
19
+ // Verify Certificate structure and signature
20
+ const certToVerify = new VerifiableCertificate(
21
+ incomingCert.type,
22
+ incomingCert.serialNumber,
23
+ incomingCert.subject,
24
+ incomingCert.certifier,
25
+ incomingCert.revocationOutpoint,
26
+ incomingCert.fields,
27
+ incomingCert.signature,
28
+ incomingCert.keyring
29
+ )
30
+ const isValidCert = await certToVerify.verify()
31
+ if (!isValidCert) {
32
+ throw new Error(`The signature for the certificate with serial number ${certToVerify.serialNumber} is invalid!`)
33
+ }
34
+
35
+ // Check if the certificate matches requested certifiers, types, and fields
36
+ if (certificatesRequested) {
37
+ const { certifiers, types } = certificatesRequested
38
+
39
+ // Check certifier matches
40
+ if (!certifiers.includes(certToVerify.certifier)) {
41
+ throw new Error(`Certificate with serial number ${certToVerify.serialNumber} has an unrequested certifier: ${certToVerify.certifier}`)
42
+ }
43
+
44
+ // Check type and fields match requested
45
+ const requestedFields = types[certToVerify.type]
46
+ if (!requestedFields) {
47
+ throw new Error(`Certificate with type ${certToVerify.type} was not requested`)
48
+ }
49
+ }
50
+
51
+ // Attempt to decrypt fields
52
+ await certToVerify.decryptFields(verifierWallet)
53
+ }))
54
+ }
@@ -0,0 +1,27 @@
1
+ import { Utils, Wallet } from '../../../mod.js'
2
+
3
+ /**
4
+ * Verifies a nonce derived from a wallet
5
+ * @param nonce - A nonce to verify as a base64 string.
6
+ * @param wallet
7
+ * @returns The status of the validation
8
+ */
9
+ export async function verifyNonce(nonce: string, wallet: Wallet): Promise<boolean> {
10
+ // Convert nonce from base64 string to Uint8Array
11
+ const buffer = Utils.toArray(nonce, 'base64')
12
+
13
+ // Split the nonce buffer
14
+ const data = buffer.slice(0, 16)
15
+ const hmac = buffer.slice(16)
16
+
17
+ // Calculate the HMAC
18
+ const { valid } = await wallet.verifyHmac({
19
+ data,
20
+ hmac,
21
+ protocolID: [2, 'server hmac'],
22
+ keyID: Utils.toUTF8(data),
23
+ counterparty: 'self'
24
+ })
25
+
26
+ return valid
27
+ }
@@ -2,7 +2,7 @@ import { Wallet } from '../Wallet.interfaces.js'
2
2
  import WalletWire from './WalletWire.js'
3
3
  import { Utils } from '../../primitives/index.js'
4
4
  import calls from './WalletWireCalls.js'
5
- import Certificate from '../../auth/Certificate.js'
5
+ import Certificate from '../../auth/certificates/Certificate.js'
6
6
  import { SecurityLevel } from '../Wallet.interfaces.js'
7
7
 
8
8
  /**
@@ -1,6 +1,6 @@
1
1
  import { AcquireCertificateArgs, AcquireCertificateResult, SecurityLevel, Base64String, BasketStringUnder300Bytes, BEEF, BooleanDefaultFalse, BooleanDefaultTrue, Byte, CertificateFieldNameUnder50Bytes, CreateActionArgs, CreateActionResult, DescriptionString5to50Bytes, DiscoverCertificatesResult, EntityIconURLStringMax500Bytes, EntityNameStringMax100Bytes, HexString, InternalizeActionArgs, ISOTimestampString, KeyIDStringUnder800Bytes, LabelStringUnder300Bytes, ListActionsArgs, ListActionsResult, ListCertificatesResult, ListOutputsArgs, ListOutputsResult, OriginatorDomainNameStringUnder250Bytes, OutpointString, OutputTagStringUnder300Bytes, PositiveInteger, PositiveIntegerDefault10Max10000, PositiveIntegerMax10, PositiveIntegerOrZero, ProtocolString5To400Bytes, ProveCertificateArgs, ProveCertificateResult, PubKeyHex, SatoshiValue, SignActionArgs, SignActionResult, TXIDHexString, VersionString7To30Bytes, Wallet } from '../Wallet.interfaces.js'
2
2
  import WalletWire from './WalletWire.js'
3
- import Certificate from '../../auth/Certificate.js'
3
+ import { Certificate } from '../../auth/index.js'
4
4
  import { Utils } from '../../primitives/index.js'
5
5
  import calls, { CallType } from './WalletWireCalls.js'
6
6
  import { WalletError } from '../WalletError.js'
@@ -1 +0,0 @@
1
- {"version":3,"file":"Certificate.js","sourceRoot":"","sources":["../../../../src/auth/Certificate.ts"],"names":[],"mappings":";;;;;AAAA,qDAA8C;AAE9C,8EAAkD;AAElD;;;;GAIG;AACH,MAAqB,WAAW;IAoC9B;;;;;;;;;;OAUG;IACH,YACE,IAAkB,EAClB,YAA0B,EAC1B,OAAkB,EAClB,SAAoB,EACpB,kBAAkC,EAClC,MAAwD,EACxD,SAAqB;QAErB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAChC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAA;QAC5C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAE,mBAA4B,IAAI;QACrC,MAAM,MAAM,GAAG,IAAI,gBAAK,CAAC,MAAM,EAAE,CAAA;QAEjC,sCAAsC;QACtC,MAAM,SAAS,GAAG,gBAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;QACpD,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;QAEvB,8CAA8C;QAC9C,MAAM,iBAAiB,GAAG,gBAAK,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAA;QACpE,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAA;QAE/B,gDAAgD;QAChD,MAAM,YAAY,GAAG,gBAAK,CAAC,OAAO,CA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OAEG;IACH,IAAI,EAAE,YAAY,CAAA;IAElB;;OAEG;IACH,YAAY,EAAE,YAAY,CAAA;IAE1B;;OAEG;IACH,OAAO,EAAE,SAAS,CAAA;IAElB;;OAEG;IACH,SAAS,EAAE,SAAS,CAAA;IAEpB;;OAEG;IACH,kBAAkB,EAAE,cAAc,CAAA;IAElC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC,gCAAgC,EAAE,MAAM,CAAC,CAAA;IAExD;;MAEE;IACF,SAAS,CAAC,EAAE,SAAS,CAAA;IAErB;;;;;;;;;;OAUG;gBAED,IAAI,EAAE,YAAY,EAClB,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,SAAS,EAClB,SAAS,EAAE,SAAS,EACpB,kBAAkB,EAAE,cAAc,EAClC,MAAM,EAAE,MAAM,CAAC,gCAAgC,EAAE,MAAM,CAAC,EACxD,SAAS,CAAC,EAAE,SAAS;IAWvB;;;;;OAKG;IACH,KAAK,CAAE,gBAAgB,GAAE,OAAc,GAAG,MAAM,EAAE;IAkDlD;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAAE,GAAG,EAAE,MAAM,EAAE,GAAG,WAAW;IA6D3C;;;;OAIG;IACG,MAAM,IAAK,OAAO,CAAC,OAAO,CAAC;IAejC;;;;;OAKG;IACG,IAAI,CAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAS9C"}
@@ -1,282 +0,0 @@
1
- import Certificate from '../../../dist/cjs/src/auth/Certificate.js'
2
- import ProtoWallet from '../../../dist/cjs/src/wallet/ProtoWallet.js'
3
- import { Utils, PrivateKey } from '../../../dist/cjs/src/primitives/index.js'
4
-
5
- describe('Certificate', () => {
6
- // Sample data for testing
7
- const sampleType = Utils.toBase64(new Array(32).fill(1))
8
- const sampleSerialNumber = Utils.toBase64(new Array(32).fill(2))
9
- const sampleSubjectPrivateKey = PrivateKey.fromRandom()
10
- const sampleSubjectPubKey = sampleSubjectPrivateKey.toPublicKey().toString()
11
- const sampleCertifierPrivateKey = PrivateKey.fromRandom()
12
- const sampleCertifierPubKey = sampleCertifierPrivateKey.toPublicKey().toString()
13
- const sampleRevocationOutpoint = 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef.1'
14
- const sampleFields = {
15
- name: 'Alice',
16
- email: 'alice@example.com',
17
- organization: 'Example Corp'
18
- }
19
- const sampleFieldsEmpty = {}
20
-
21
- it('should construct a Certificate with valid data', () => {
22
- const certificate = new Certificate(
23
- sampleType,
24
- sampleSerialNumber,
25
- sampleSubjectPubKey,
26
- sampleCertifierPubKey,
27
- sampleRevocationOutpoint,
28
- sampleFields,
29
- undefined // No signature
30
- )
31
-
32
- expect(certificate.type).toEqual(sampleType)
33
- expect(certificate.serialNumber).toEqual(sampleSerialNumber)
34
- expect(certificate.subject).toEqual(sampleSubjectPubKey)
35
- expect(certificate.certifier).toEqual(sampleCertifierPubKey)
36
- expect(certificate.revocationOutpoint).toEqual(sampleRevocationOutpoint)
37
- expect(certificate.signature).toBeUndefined()
38
- expect(certificate.fields).toEqual(sampleFields)
39
- })
40
-
41
- it('should serialize and deserialize the Certificate without signature', () => {
42
- const certificate = new Certificate(
43
- sampleType,
44
- sampleSerialNumber,
45
- sampleSubjectPubKey,
46
- sampleCertifierPubKey,
47
- sampleRevocationOutpoint,
48
- sampleFields,
49
- undefined // No signature
50
- )
51
-
52
- const serialized = certificate.toBin(false) // Exclude signature
53
- const deserializedCertificate = Certificate.fromBin(serialized)
54
-
55
- expect(deserializedCertificate.type).toEqual(sampleType)
56
- expect(deserializedCertificate.serialNumber).toEqual(sampleSerialNumber)
57
- expect(deserializedCertificate.subject).toEqual(sampleSubjectPubKey)
58
- expect(deserializedCertificate.certifier).toEqual(sampleCertifierPubKey)
59
- expect(deserializedCertificate.revocationOutpoint).toEqual(sampleRevocationOutpoint)
60
- expect(deserializedCertificate.signature).toBeUndefined()
61
- expect(deserializedCertificate.fields).toEqual(sampleFields)
62
- })
63
-
64
- it('should serialize and deserialize the Certificate with signature', async () => {
65
- const certificate = new Certificate(
66
- sampleType,
67
- sampleSerialNumber,
68
- sampleSubjectPubKey,
69
- sampleCertifierPubKey,
70
- sampleRevocationOutpoint,
71
- sampleFields,
72
- undefined // No signature
73
- )
74
-
75
- // Sign the certificate
76
- const certifierWallet: ProtoWallet = new ProtoWallet(sampleCertifierPrivateKey)
77
- await certificate.sign(certifierWallet)
78
-
79
- const serialized = certificate.toBin(true) // Include signature
80
- const deserializedCertificate = Certificate.fromBin(serialized)
81
-
82
- expect(deserializedCertificate.type).toEqual(sampleType)
83
- expect(deserializedCertificate.serialNumber).toEqual(sampleSerialNumber)
84
- expect(deserializedCertificate.subject).toEqual(sampleSubjectPubKey)
85
- expect(deserializedCertificate.certifier).toEqual(sampleCertifierPubKey)
86
- expect(deserializedCertificate.revocationOutpoint).toEqual(sampleRevocationOutpoint)
87
- expect(deserializedCertificate.signature).toEqual(certificate.signature)
88
- expect(deserializedCertificate.fields).toEqual(sampleFields)
89
- })
90
-
91
- it('should sign the Certificate and verify the signature successfully', async () => {
92
- const certificate = new Certificate(
93
- sampleType,
94
- sampleSerialNumber,
95
- sampleSubjectPubKey,
96
- sampleCertifierPubKey,
97
- sampleRevocationOutpoint,
98
- sampleFields,
99
- undefined // No signature
100
- )
101
-
102
- // Sign the certificate
103
- const certifierWallet: ProtoWallet = new ProtoWallet(sampleCertifierPrivateKey)
104
- await certificate.sign(certifierWallet)
105
-
106
- // Verify the signature
107
- const isValid = await certificate.verify()
108
- expect(isValid).toBe(true)
109
- })
110
-
111
- it('should fail verification if the Certificate is tampered with', async () => {
112
- const certificate = new Certificate(
113
- sampleType,
114
- sampleSerialNumber,
115
- sampleSubjectPubKey,
116
- sampleCertifierPubKey,
117
- sampleRevocationOutpoint,
118
- sampleFields,
119
- undefined // No signature
120
- )
121
-
122
- // Sign the certificate
123
- const certifierWallet: ProtoWallet = new ProtoWallet(sampleCertifierPrivateKey)
124
- await certificate.sign(certifierWallet)
125
-
126
- // Tamper with the certificate (modify a field)
127
- certificate.fields.email = 'attacker@example.com'
128
-
129
- // Verify the signature
130
- await expect(certificate.verify()).rejects.toThrow()
131
- })
132
-
133
- it('should fail verification if the signature is missing', async () => {
134
- const certificate = new Certificate(
135
- sampleType,
136
- sampleSerialNumber,
137
- sampleSubjectPubKey,
138
- sampleCertifierPubKey,
139
- sampleRevocationOutpoint,
140
- sampleFields,
141
- undefined // No signature
142
- )
143
-
144
- // Verify the signature
145
- await expect(certificate.verify()).rejects.toThrow()
146
- })
147
-
148
- it('should fail verification if the signature is incorrect', async () => {
149
- const certificate = new Certificate(
150
- sampleType,
151
- sampleSerialNumber,
152
- sampleSubjectPubKey,
153
- sampleCertifierPubKey,
154
- sampleRevocationOutpoint,
155
- sampleFields,
156
- '3045022100cde229279465bb91992ccbc30bf6ed4eb8cdd9d517f31b30ff778d500d5400010220134f0e4065984f8668a642a5ad7a80886265f6aaa56d215d6400c216a4802177' // Incorrect signature
157
- )
158
-
159
- // Verify the signature
160
- await expect(certificate.verify()).rejects.toThrowErrorMatchingInlineSnapshot(`"Signature is not valid"`)
161
- })
162
-
163
- it('should handle certificates with empty fields', async () => {
164
- const certificate = new Certificate(
165
- sampleType,
166
- sampleSerialNumber,
167
- sampleSubjectPubKey,
168
- sampleCertifierPubKey,
169
- sampleRevocationOutpoint,
170
- sampleFieldsEmpty,
171
- undefined // No signature
172
- )
173
-
174
- // Sign the certificate
175
- const certifierWallet: ProtoWallet = new ProtoWallet(sampleCertifierPrivateKey)
176
- await certificate.sign(certifierWallet)
177
-
178
- // Serialize and deserialize
179
- const serialized = certificate.toBin(true)
180
- const deserializedCertificate = Certificate.fromBin(serialized)
181
-
182
- expect(deserializedCertificate.fields).toEqual(sampleFieldsEmpty)
183
-
184
- // Verify the signature
185
- const isValid = await deserializedCertificate.verify()
186
- expect(isValid).toBe(true)
187
- })
188
-
189
- it('should correctly handle serialization/deserialization when signature is excluded', () => {
190
- const certificate = new Certificate(
191
- sampleType,
192
- sampleSerialNumber,
193
- sampleSubjectPubKey,
194
- sampleCertifierPubKey,
195
- sampleRevocationOutpoint,
196
- sampleFields,
197
- 'deadbeef1234', // Placeholder signature
198
- )
199
-
200
- // Serialize without signature
201
- const serialized = certificate.toBin(false)
202
- const deserializedCertificate = Certificate.fromBin(serialized)
203
-
204
- expect(deserializedCertificate.signature).toBeUndefined() // Signature should be empty
205
- expect(deserializedCertificate.fields).toEqual(sampleFields)
206
- })
207
-
208
- it('should correctly handle certificates with long field names and values', async () => {
209
- const longFieldName = 'longFieldName_'.repeat(10) as any // Exceeding typical lengths
210
- const longFieldValue = 'longFieldValue_'.repeat(20)
211
- const fields = {
212
- [longFieldName]: longFieldValue
213
- }
214
-
215
- const certificate = new Certificate(
216
- sampleType,
217
- sampleSerialNumber,
218
- sampleSubjectPubKey,
219
- sampleCertifierPubKey,
220
- sampleRevocationOutpoint,
221
- fields,
222
- undefined // No signature
223
- )
224
-
225
- // Sign the certificate
226
- const certifierWallet: ProtoWallet = new ProtoWallet(sampleCertifierPrivateKey)
227
- await certificate.sign(certifierWallet)
228
-
229
- // Serialize and deserialize
230
- const serialized = certificate.toBin(true)
231
- const deserializedCertificate = Certificate.fromBin(serialized)
232
-
233
- expect(deserializedCertificate.fields).toEqual(fields)
234
-
235
- // Verify the signature
236
- const isValid = await deserializedCertificate.verify()
237
- expect(isValid).toBe(true)
238
- })
239
-
240
- it('should correctly serialize and deserialize the revocationOutpoint', () => {
241
- const certificate = new Certificate(
242
- sampleType,
243
- sampleSerialNumber,
244
- sampleSubjectPubKey,
245
- sampleCertifierPubKey,
246
- sampleRevocationOutpoint,
247
- sampleFields,
248
- undefined // No signature
249
- )
250
-
251
- const serialized = certificate.toBin(false)
252
- const deserializedCertificate = Certificate.fromBin(serialized)
253
-
254
- expect(deserializedCertificate.revocationOutpoint).toEqual(sampleRevocationOutpoint)
255
- })
256
-
257
- it('should correctly handle certificates with no fields', async () => {
258
- const certificate = new Certificate(
259
- sampleType,
260
- sampleSerialNumber,
261
- sampleSubjectPubKey,
262
- sampleCertifierPubKey,
263
- sampleRevocationOutpoint,
264
- {}, // No fields
265
- undefined // No signature
266
- )
267
-
268
- // Sign the certificate
269
- const certifierWallet: ProtoWallet = new ProtoWallet(sampleCertifierPrivateKey)
270
- await certificate.sign(certifierWallet)
271
-
272
- // Serialize and deserialize
273
- const serialized = certificate.toBin(true)
274
- const deserializedCertificate = Certificate.fromBin(serialized)
275
-
276
- expect(deserializedCertificate.fields).toEqual({})
277
-
278
- // Verify the signature
279
- const isValid = await deserializedCertificate.verify()
280
- expect(isValid).toBe(true)
281
- })
282
- })