bsv-bap 0.0.1 → 0.0.3

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 (71) hide show
  1. package/dist/api.d.ts +10 -0
  2. package/dist/apiTypes.d.ts +36 -0
  3. package/dist/{src/constants.d.ts → constants.d.ts} +2 -2
  4. package/dist/{src/id.d.ts → id.d.ts} +13 -32
  5. package/dist/index.cjs +2 -0
  6. package/dist/index.cjs.map +1 -0
  7. package/dist/index.d.ts +234 -0
  8. package/dist/index.modern.js +2 -0
  9. package/dist/index.modern.js.map +1 -0
  10. package/dist/index.module.js +2 -0
  11. package/dist/index.module.js.map +1 -0
  12. package/dist/index.umd.js +2 -0
  13. package/dist/index.umd.js.map +1 -0
  14. package/dist/{src/interface.d.ts → interface.d.ts} +8 -4
  15. package/dist/{src/poa.d.ts → poa.d.ts} +1 -1
  16. package/dist/{src/utils.d.ts → utils.d.ts} +0 -1
  17. package/package.json +30 -57
  18. package/.babelrc +0 -20
  19. package/.eslintrc +0 -46
  20. package/babel.config.js +0 -6
  21. package/bun.lockb +0 -0
  22. package/coverage/clover.xml +0 -6
  23. package/coverage/coverage-final.json +0 -1
  24. package/coverage/lcov-report/base.css +0 -224
  25. package/coverage/lcov-report/block-navigation.js +0 -87
  26. package/coverage/lcov-report/favicon.png +0 -0
  27. package/coverage/lcov-report/index.html +0 -101
  28. package/coverage/lcov-report/prettify.css +0 -1
  29. package/coverage/lcov-report/prettify.js +0 -2
  30. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  31. package/coverage/lcov-report/sorter.js +0 -196
  32. package/coverage/lcov-report/src/constants.ts.html +0 -113
  33. package/coverage/lcov-report/src/id.ts.html +0 -2207
  34. package/coverage/lcov-report/src/index.html +0 -156
  35. package/coverage/lcov-report/src/index.ts.html +0 -1877
  36. package/coverage/lcov-report/src/utils.ts.html +0 -404
  37. package/coverage/lcov-report/tests/data/index.html +0 -111
  38. package/coverage/lcov-report/tests/data/keys.js.html +0 -86
  39. package/coverage/lcov.info +0 -0
  40. package/dist/jest.config.d.ts +0 -8
  41. package/dist/src/index.d.ts +0 -238
  42. package/dist/typescript-npm-package.cjs.d.ts +0 -554
  43. package/dist/typescript-npm-package.cjs.js +0 -1320
  44. package/dist/typescript-npm-package.cjs.js.map +0 -1
  45. package/dist/typescript-npm-package.esm.d.ts +0 -554
  46. package/dist/typescript-npm-package.esm.js +0 -1312
  47. package/dist/typescript-npm-package.esm.js.map +0 -1
  48. package/dist/typescript-npm-package.umd.d.ts +0 -554
  49. package/dist/typescript-npm-package.umd.js +0 -110193
  50. package/dist/typescript-npm-package.umd.js.map +0 -1
  51. package/jest.config.ts +0 -196
  52. package/jsdoc.json +0 -16
  53. package/rollup.config.js +0 -64
  54. package/setup-jest.js +0 -1
  55. package/src/README.md +0 -80
  56. package/src/attributes.json +0 -119
  57. package/src/constants.ts +0 -11
  58. package/src/id.ts +0 -783
  59. package/src/index.ts +0 -631
  60. package/src/interface.ts +0 -26
  61. package/src/poa.ts +0 -9
  62. package/src/utils.ts +0 -111
  63. package/tests/data/ids.json +0 -30
  64. package/tests/data/keys.js +0 -2
  65. package/tests/data/old-ids.json +0 -25
  66. package/tests/data/test-vectors.json +0 -122
  67. package/tests/id.test.js +0 -286
  68. package/tests/index.test.js +0 -335
  69. package/tests/regression.test.js +0 -28
  70. package/tests/utils.test.js +0 -27
  71. package/tsconfig.json +0 -17
@@ -1,238 +0,0 @@
1
- /// <reference types="node" />
2
- import { HD } from "@bsv/sdk";
3
- import "node-fetch";
4
- import { BAP_ID } from "./id";
5
- import type { Attestation, PathPrefix } from "./interface";
6
- /**
7
- * BAP class
8
- *
9
- * Creates an instance of the BAP class and uses the given HDPrivateKey for all BAP operations.
10
- *
11
- * @param HDPrivateKey
12
- */
13
- export declare const BAP: {
14
- new (HDPrivateKey: string, token?: string): {
15
- "__#1030@#HDPrivateKey": HD;
16
- "__#1030@#ids": {
17
- [key: string]: BAP_ID;
18
- };
19
- "__#1030@#BAP_SERVER": string;
20
- "__#1030@#BAP_TOKEN": string;
21
- "__#1030@#lastIdPath": string;
22
- readonly lastIdPath: string;
23
- /**
24
- * Get the public key of the given childPath, or of the current HDPrivateKey of childPath is empty
25
- *
26
- * @param childPath Full derivation path for this child
27
- * @returns {*}
28
- */
29
- getPublicKey(childPath?: string): string;
30
- /**
31
- * Get the public key of the given childPath, or of the current HDPrivateKey of childPath is empty
32
- *
33
- * @param childPath Full derivation path for this child
34
- * @returns {*}
35
- */
36
- getHdPublicKey(childPath?: string): string;
37
- BAP_SERVER: string;
38
- BAP_TOKEN: string;
39
- /**
40
- * This function verifies that the given bapId matches the given root address
41
- * This is used as a data integrity check
42
- *
43
- * @param bapId BAP_ID instance
44
- */
45
- checkIdBelongs(bapId: BAP_ID): boolean;
46
- /**
47
- * Returns a list of all the identity keys that are stored in this instance
48
- *
49
- * @returns {string[]}
50
- */
51
- listIds(): string[];
52
- /**
53
- * Create a new Id and link it to this BAP instance
54
- *
55
- * This function uses the length of the #ids of this class to determine the next valid path.
56
- * If not all ids related to this HDPrivateKey have been loaded, determine the path externally
57
- * and pass it to newId when creating a new ID.
58
- *
59
- * @param path
60
- * @param identityAttributes
61
- * @param idSeed
62
- * @returns {*}
63
- */
64
- newId(path?: string, identityAttributes?: any, idSeed?: string): BAP_ID;
65
- /**
66
- * Remove identity
67
- *
68
- * @param idKey
69
- * @returns {*}
70
- */
71
- removeId(idKey: string): void;
72
- /**
73
- * Get the next valid path for the used HDPrivateKey and loaded #ids
74
- *
75
- * @returns {string}
76
- */
77
- getNextValidPath(): PathPrefix;
78
- /**
79
- * Get a certain Id
80
- *
81
- * @param identityKey
82
- * @returns {null}
83
- */
84
- getId(identityKey: string): BAP_ID | null;
85
- /**
86
- * This function is used when manipulating ID's, adding or removing attributes etc
87
- * First create an id through this class and then use getId to get it. Then you can add/edit or
88
- * increment the signing path and then re-set it with this function.
89
- *
90
- * Note: when you getId() from this class, you will be working on the same object as this class
91
- * has and any changes made will be propagated to the id in this class. When you call exportIds
92
- * your new changes will also be included, without having to setId().
93
- *
94
- * @param bapId
95
- */
96
- setId(bapId: BAP_ID): void;
97
- /**
98
- * This function is used to import IDs and attributes from some external storage
99
- *
100
- * The ID information should NOT be stored together with the HD private key !
101
- *
102
- * @param idData Array of ids that have been exported
103
- * @param encrypted Whether the data should be treated as being encrypted (default true)
104
- */
105
- importIds(idData: any, encrypted?: boolean): void;
106
- /**
107
- * Export all the IDs of this instance for external storage
108
- *
109
- * By default this function will encrypt the data, using a derivative child of the main HD key
110
- *
111
- * @param encrypted Whether the data should be encrypted (default true)
112
- * @returns {[]|*}
113
- */
114
- exportIds(encrypted?: boolean): any;
115
- /**
116
- * Encrypt a string of data
117
- *
118
- * @param string
119
- * @returns {string}
120
- */
121
- encrypt(string: string): string;
122
- /**
123
- * Decrypt a string of data
124
- *
125
- * @param string
126
- * @returns {string}
127
- */
128
- decrypt(string: string): string;
129
- /**
130
- * Sign an attestation for a user
131
- *
132
- * @param attestationHash The computed attestation hash for the user - this should be calculated with the BAP_ID class for an identity for the user
133
- * @param identityKey The identity key we are using for the signing
134
- * @param counter
135
- * @param dataString Optional data string that will be appended to the BAP attestation
136
- * @returns {string[]}
137
- */
138
- signAttestationWithAIP(attestationHash: string, identityKey: string, counter?: number, dataString?: string): string[];
139
- /**
140
- * Verify an AIP signed attestation for a user
141
- *
142
- * [
143
- * '0x6a',
144
- * '0x31424150537561506e66476e53424d33474c56397968785564596534764762644d54',
145
- * '0x415454455354',
146
- * '0x33656166366361396334313936356538353831366439336439643034333136393032376633396661623034386333633031333663343364663635376462383761',
147
- * '0x30',
148
- * '0x7c',
149
- * '0x313550636948473232534e4c514a584d6f5355615756693757537163376843667661',
150
- * '0x424954434f494e5f4543445341',
151
- * '0x31477531796d52567a595557634638776f6f506a7a4a4c764d383550795a64655876',
152
- * '0x20ef60c5555001ddb1039bb0f215e46571fcb39ee46f48b089d1c08b0304dbcb3366d8fdf8bafd82be24b5ac42dcd6a5e96c90705dd42e3ad918b1b47ac3ce6ac2'
153
- * ]
154
- *
155
- * @param tx Array of hex values for the OP_RETURN values
156
- * @returns {{}}
157
- */
158
- verifyAttestationWithAIP(tx: string[]): Attestation;
159
- /**
160
- * For BAP attestations we use all fields for the attestation
161
- *
162
- * @param attestationHash
163
- * @param counter
164
- * @param address
165
- * @param signature
166
- * @param dataString Optional data string that will be appended to the BAP attestation
167
- * @returns {[string]}
168
- */
169
- createAttestationTransaction(attestationHash: string, counter: number, address: string, signature: string, dataString?: string): string[];
170
- /**
171
- * This is a re-creation of how the bitcoinfiles-sdk creates a hash to sign for AIP
172
- *
173
- * @param attestationHash
174
- * @param counter
175
- * @param dataString Optional data string
176
- * @returns {Buffer}
177
- */
178
- getAttestationBuffer(attestationHash: string, counter?: number, dataString?: string): Buffer;
179
- /**
180
- * Verify that the identity challenge is signed by the address
181
- *
182
- * @param message Buffer or utf-8 string
183
- * @param address Bitcoin address of signee
184
- * @param signature Signature base64 string
185
- *
186
- * @return boolean
187
- */
188
- verifySignature(message: string | Buffer, address: string, signature: string): boolean;
189
- /**
190
- * Check whether the given transaction (BAP OP_RETURN) is valid, is signed and that the
191
- * identity signing is also valid at the time of signing
192
- *
193
- * @param idKey
194
- * @param address
195
- * @param challenge
196
- * @param signature
197
- *
198
- * @returns {Promise<boolean|*>}
199
- */
200
- verifyChallengeSignature(idKey: string, address: string, challenge: string, signature: string): Promise<boolean>;
201
- /**
202
- * Check whether the given transaction (BAP OP_RETURN) is valid, is signed and that the
203
- * identity signing is also valid at the time of signing
204
- *
205
- * @param tx
206
- * @returns {Promise<boolean|*>}
207
- */
208
- isValidAttestationTransaction(tx: string[]): Promise<any>;
209
- /**
210
- * Get all signing keys for the given idKey
211
- *
212
- * @param address
213
- * @returns {Promise<*>}
214
- */
215
- getIdentityFromAddress(address: string): Promise<any>;
216
- /**
217
- * Get all signing keys for the given idKey
218
- *
219
- * @param idKey
220
- * @returns {Promise<*>}
221
- */
222
- getIdentity(idKey: string): Promise<any>;
223
- /**
224
- * Get all attestations for the given attestation hash
225
- *
226
- * @param attestationHash
227
- */
228
- getAttestationsForHash(attestationHash: string): Promise<any>;
229
- /**
230
- * Helper function to get attestation from a BAP API server
231
- *
232
- * @param apiUrl
233
- * @param apiData
234
- * @returns {Promise<any>}
235
- */
236
- getApiData(apiUrl: string, apiData: any): Promise<any>;
237
- };
238
- };