@actioncodes/protocol 1.2.2 → 2.0.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.
Files changed (144) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +318 -33
  3. package/dist/ActionCodesProtocol.d.ts +37 -0
  4. package/dist/ActionCodesProtocol.d.ts.map +1 -0
  5. package/dist/adapters/BaseChainAdapter.d.ts +22 -0
  6. package/dist/adapters/BaseChainAdapter.d.ts.map +1 -0
  7. package/dist/adapters/SolanaAdapter.d.ts +44 -0
  8. package/dist/adapters/SolanaAdapter.d.ts.map +1 -0
  9. package/dist/constants.d.ts +6 -8
  10. package/dist/constants.d.ts.map +1 -1
  11. package/dist/errors.d.ts +63 -0
  12. package/dist/errors.d.ts.map +1 -0
  13. package/dist/index.cjs +3 -0
  14. package/dist/index.cjs.map +25 -0
  15. package/dist/index.d.ts +10 -8
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +3 -36
  18. package/dist/index.js.map +25 -0
  19. package/dist/strategy/DelegationStrategy.d.ts +45 -0
  20. package/dist/strategy/DelegationStrategy.d.ts.map +1 -0
  21. package/dist/strategy/WalletStrategy.d.ts +8 -0
  22. package/dist/strategy/WalletStrategy.d.ts.map +1 -0
  23. package/dist/types.d.ts +40 -0
  24. package/dist/types.d.ts.map +1 -0
  25. package/dist/utils/canonical.d.ts +5 -0
  26. package/dist/utils/canonical.d.ts.map +1 -0
  27. package/dist/utils/crypto.d.ts +13 -0
  28. package/dist/utils/crypto.d.ts.map +1 -0
  29. package/dist/utils/protocolMeta.d.ts +16 -0
  30. package/dist/utils/protocolMeta.d.ts.map +1 -0
  31. package/docs/ActionCodesProtocol/README.md +11 -0
  32. package/docs/ActionCodesProtocol/classes/ActionCodesProtocol.md +147 -0
  33. package/docs/README.md +10 -50
  34. package/docs/adapters/BaseChainAdapter/README.md +20 -0
  35. package/docs/adapters/BaseChainAdapter/classes/BaseChainAdapter.md +56 -0
  36. package/docs/adapters/BaseChainAdapter/interfaces/BaseContext.md +17 -0
  37. package/docs/adapters/BaseChainAdapter/interfaces/ChainAdapter.md +33 -0
  38. package/docs/adapters/BaseChainAdapter/type-aliases/ChainContext.md +23 -0
  39. package/docs/adapters/NodeCryptoAdapter/README.md +15 -0
  40. package/docs/adapters/NodeCryptoAdapter/classes/NodeCryptoAdapter.md +254 -0
  41. package/docs/adapters/NodeCryptoAdapter/type-aliases/NodeCryptoContext.md +27 -0
  42. package/docs/adapters/SolanaAdapter/README.md +16 -0
  43. package/docs/adapters/SolanaAdapter/classes/SolanaAdapter.md +190 -0
  44. package/docs/adapters/SolanaAdapter/type-aliases/SolanaContext.md +27 -0
  45. package/docs/adapters/SolanaAdapter/type-aliases/SolanaTransaction.md +13 -0
  46. package/docs/constants/README.md +8 -13
  47. package/docs/constants/variables/CODE_CHARSET_DIGITS.md +11 -0
  48. package/docs/constants/variables/CODE_DEFAULT_LENGTH.md +11 -0
  49. package/docs/constants/variables/CODE_MAX_LENGTH.md +11 -0
  50. package/docs/constants/variables/CODE_MIN_LENGTH.md +11 -0
  51. package/docs/constants/variables/PROTOCOL_META_MAX_BYTES.md +11 -0
  52. package/docs/constants/variables/PROTOCOL_NORMALIZATION.md +11 -0
  53. package/docs/constants/variables/SUPPORTED_CHAINS.md +3 -3
  54. package/docs/errors/README.md +22 -0
  55. package/docs/errors/classes/ExpiredCodeError.md +695 -0
  56. package/docs/errors/classes/InvalidCodeFormatError.md +691 -0
  57. package/docs/errors/classes/InvalidPubkeyFormatError.md +691 -0
  58. package/docs/errors/classes/InvalidSignatureError.md +687 -0
  59. package/docs/errors/classes/MetaMismatchError.md +695 -0
  60. package/docs/errors/classes/MissingMetaError.md +681 -0
  61. package/docs/errors/classes/ProtocolError.md +637 -0
  62. package/docs/errors/classes/TransactionNotSignedByIntendedOwnerError.md +691 -0
  63. package/docs/errors/enumerations/ProtocolErrorCode.md +121 -0
  64. package/docs/index/README.md +83 -41
  65. package/docs/modules.md +12 -9
  66. package/docs/strategy/WalletStrategy/README.md +11 -0
  67. package/docs/strategy/WalletStrategy/classes/WalletStrategy.md +67 -0
  68. package/docs/types/README.md +14 -0
  69. package/docs/types/interfaces/ActionCode.md +65 -0
  70. package/docs/types/interfaces/CanonicalMessageParts.md +33 -0
  71. package/docs/types/interfaces/CodeGenerationConfig.md +33 -0
  72. package/docs/types/interfaces/CodeGenerationResult.md +25 -0
  73. package/docs/utils/canonical/README.md +16 -0
  74. package/docs/utils/canonical/functions/serializeCanonical.md +21 -0
  75. package/docs/utils/canonical/variables/CANONICAL_MESSAGE_PREFIX.md +11 -0
  76. package/docs/utils/canonical/variables/CANONICAL_MESSAGE_VERSION.md +11 -0
  77. package/docs/utils/crypto/README.md +18 -0
  78. package/docs/utils/crypto/functions/base32EncodeCrockford.md +21 -0
  79. package/docs/utils/crypto/functions/codeHash.md +21 -0
  80. package/docs/utils/crypto/functions/digestToDigits.md +25 -0
  81. package/docs/utils/crypto/functions/generateRandomSecret.md +15 -0
  82. package/docs/utils/crypto/functions/hkdfSha256.md +35 -0
  83. package/docs/utils/crypto/functions/hmacSha256.md +25 -0
  84. package/docs/utils/crypto/functions/sha256.md +21 -0
  85. package/docs/utils/crypto/functions/truncateBits.md +25 -0
  86. package/docs/utils/protocolMeta/README.md +21 -0
  87. package/docs/utils/protocolMeta/functions/buildProtocolMeta.md +21 -0
  88. package/docs/utils/protocolMeta/functions/parseProtocolMeta.md +21 -0
  89. package/docs/utils/protocolMeta/functions/validateProtocolMetaFormat.md +21 -0
  90. package/docs/utils/protocolMeta/interfaces/ProtocolMetaFields.md +41 -0
  91. package/docs/utils/protocolMeta/variables/SCHEME.md +11 -0
  92. package/package.json +42 -47
  93. package/dist/actioncode.d.ts +0 -120
  94. package/dist/actioncode.d.ts.map +0 -1
  95. package/dist/actioncode.js +0 -186
  96. package/dist/adapters/base.d.ts +0 -93
  97. package/dist/adapters/base.d.ts.map +0 -1
  98. package/dist/adapters/base.js +0 -65
  99. package/dist/adapters/solana/index.d.ts +0 -2
  100. package/dist/adapters/solana/index.d.ts.map +0 -1
  101. package/dist/adapters/solana/index.js +0 -30
  102. package/dist/adapters/solana/solana.d.ts +0 -113
  103. package/dist/adapters/solana/solana.d.ts.map +0 -1
  104. package/dist/adapters/solana/solana.js +0 -537
  105. package/dist/codegen.d.ts +0 -76
  106. package/dist/codegen.d.ts.map +0 -1
  107. package/dist/codegen.js +0 -211
  108. package/dist/constants.js +0 -24
  109. package/dist/meta.d.ts +0 -54
  110. package/dist/meta.d.ts.map +0 -1
  111. package/dist/meta.js +0 -104
  112. package/dist/protocol.d.ts +0 -179
  113. package/dist/protocol.d.ts.map +0 -1
  114. package/dist/protocol.js +0 -390
  115. package/docs/_media/LICENSE +0 -201
  116. package/docs/_media/README.md +0 -28
  117. package/docs/actioncode/README.md +0 -21
  118. package/docs/actioncode/classes/ActionCode.md +0 -430
  119. package/docs/actioncode/interfaces/ActionCodeFields.md +0 -89
  120. package/docs/actioncode/interfaces/ActionCodeMetadata.md +0 -25
  121. package/docs/actioncode/interfaces/ActionCodeTransaction.md +0 -57
  122. package/docs/actioncode/type-aliases/ActionCodeStatus.md +0 -11
  123. package/docs/adapters/base/README.md +0 -11
  124. package/docs/adapters/base/classes/BaseChainAdapter.md +0 -396
  125. package/docs/adapters/solana/README.md +0 -19
  126. package/docs/adapters/solana/solana/README.md +0 -15
  127. package/docs/adapters/solana/solana/classes/SolanaAdapter.md +0 -506
  128. package/docs/adapters/solana/solana/type-aliases/SolanaTransaction.md +0 -13
  129. package/docs/codegen/README.md +0 -11
  130. package/docs/codegen/classes/CodeGenerator.md +0 -341
  131. package/docs/constants/type-aliases/SupportedChain.md +0 -11
  132. package/docs/constants/variables/CODE_LENGTH.md +0 -11
  133. package/docs/constants/variables/CODE_TTL.md +0 -11
  134. package/docs/constants/variables/MAX_PREFIX_LENGTH.md +0 -11
  135. package/docs/constants/variables/MIN_PREFIX_LENGTH.md +0 -11
  136. package/docs/constants/variables/PROTOCOL_CODE_PREFIX.md +0 -11
  137. package/docs/constants/variables/PROTOCOL_PREFIX.md +0 -11
  138. package/docs/constants/variables/PROTOCOL_VERSION.md +0 -11
  139. package/docs/meta/README.md +0 -15
  140. package/docs/meta/classes/ProtocolMetaParser.md +0 -177
  141. package/docs/meta/interfaces/ProtocolMetaV1.md +0 -59
  142. package/docs/protocol/README.md +0 -51
  143. package/docs/protocol/classes/ActionCodesProtocol.md +0 -676
  144. package/docs/protocol/interfaces/ProtocolConfig.md +0 -71
@@ -1,396 +0,0 @@
1
- [**@actioncodes/protocol**](../../../README.md)
2
-
3
- ***
4
-
5
- [@actioncodes/protocol](../../../modules.md) / [adapters/base](../README.md) / BaseChainAdapter
6
-
7
- # Class: `abstract` BaseChainAdapter\<T\>
8
-
9
- Defined in: [adapters/base.ts:9](https://github.com/otaprotocol/actioncodes/blob/7fa582d3aecdeca51131d2fc9eec0802298f9a4d/src/adapters/base.ts#L9)
10
-
11
- Base adapter class for chain-specific protocol meta operations
12
-
13
- ## Extended by
14
-
15
- - [`SolanaAdapter`](../../solana/solana/classes/SolanaAdapter.md)
16
-
17
- ## Type Parameters
18
-
19
- ### T
20
-
21
- `T` = `any`
22
-
23
- Chain-specific transaction type
24
-
25
- ## Constructors
26
-
27
- ### Constructor
28
-
29
- > **new BaseChainAdapter**\<`T`\>(): `BaseChainAdapter`\<`T`\>
30
-
31
- #### Returns
32
-
33
- `BaseChainAdapter`\<`T`\>
34
-
35
- ## Properties
36
-
37
- ### chain
38
-
39
- > `abstract` `readonly` **chain**: `string`
40
-
41
- Defined in: [adapters/base.ts:10](https://github.com/otaprotocol/actioncodes/blob/7fa582d3aecdeca51131d2fc9eec0802298f9a4d/src/adapters/base.ts#L10)
42
-
43
- ## Methods
44
-
45
- ### decodeMeta()
46
-
47
- > `abstract` **decodeMeta**(`tx`): `null` \| [`ProtocolMetaV1`](../../../meta/interfaces/ProtocolMetaV1.md)
48
-
49
- Defined in: [adapters/base.ts:24](https://github.com/otaprotocol/actioncodes/blob/7fa582d3aecdeca51131d2fc9eec0802298f9a4d/src/adapters/base.ts#L24)
50
-
51
- Decode protocol meta from chain-specific transaction
52
-
53
- #### Parameters
54
-
55
- ##### tx
56
-
57
- `T`
58
-
59
- Chain-specific transaction
60
-
61
- #### Returns
62
-
63
- `null` \| [`ProtocolMetaV1`](../../../meta/interfaces/ProtocolMetaV1.md)
64
-
65
- Decoded ProtocolMetaV1 or null
66
-
67
- ***
68
-
69
- ### detectTampering()
70
-
71
- > **detectTampering**(`tx`, `authorities`, `expectedPrefix`): `boolean`
72
-
73
- Defined in: [adapters/base.ts:58](https://github.com/otaprotocol/actioncodes/blob/7fa582d3aecdeca51131d2fc9eec0802298f9a4d/src/adapters/base.ts#L58)
74
-
75
- Detect tampered transactions by cross-checking metadata
76
-
77
- #### Parameters
78
-
79
- ##### tx
80
-
81
- `T`
82
-
83
- Chain-specific transaction
84
-
85
- ##### authorities
86
-
87
- `string`[]
88
-
89
- Array of valid protocol authority identifiers
90
-
91
- ##### expectedPrefix
92
-
93
- `string` = `'DEFAULT'`
94
-
95
- Expected protocol prefix
96
-
97
- #### Returns
98
-
99
- `boolean`
100
-
101
- True if transaction is valid and not tampered
102
-
103
- ***
104
-
105
- ### encodeMeta()
106
-
107
- > `abstract` **encodeMeta**(`meta`): `any`
108
-
109
- Defined in: [adapters/base.ts:17](https://github.com/otaprotocol/actioncodes/blob/7fa582d3aecdeca51131d2fc9eec0802298f9a4d/src/adapters/base.ts#L17)
110
-
111
- Encode protocol meta for this chain
112
-
113
- #### Parameters
114
-
115
- ##### meta
116
-
117
- [`ProtocolMetaV1`](../../../meta/interfaces/ProtocolMetaV1.md)
118
-
119
- ProtocolMetaV1 object
120
-
121
- #### Returns
122
-
123
- `any`
124
-
125
- Chain-specific encoded data
126
-
127
- ***
128
-
129
- ### getCodeSignatureMessage()
130
-
131
- > **getCodeSignatureMessage**(`code`, `timestamp`, `prefix`): `string`
132
-
133
- Defined in: [adapters/base.ts:104](https://github.com/otaprotocol/actioncodes/blob/7fa582d3aecdeca51131d2fc9eec0802298f9a4d/src/adapters/base.ts#L104)
134
-
135
- Get the code signature message
136
-
137
- #### Parameters
138
-
139
- ##### code
140
-
141
- `string`
142
-
143
- The code to sign
144
-
145
- ##### timestamp
146
-
147
- `number`
148
-
149
- The timestamp of the code
150
-
151
- ##### prefix
152
-
153
- `string` = `PROTOCOL_CODE_PREFIX`
154
-
155
- The prefix of the code
156
-
157
- #### Returns
158
-
159
- `string`
160
-
161
- The code signature message
162
-
163
- ***
164
-
165
- ### hasIssuerSignature()
166
-
167
- > `abstract` **hasIssuerSignature**(`tx`, `issuer`): `boolean`
168
-
169
- Defined in: [adapters/base.ts:49](https://github.com/otaprotocol/actioncodes/blob/7fa582d3aecdeca51131d2fc9eec0802298f9a4d/src/adapters/base.ts#L49)
170
-
171
- Check if the issuer has signed the transaction
172
-
173
- #### Parameters
174
-
175
- ##### tx
176
-
177
- `T`
178
-
179
- Chain-specific transaction
180
-
181
- ##### issuer
182
-
183
- `string`
184
-
185
- Issuer public key to check
186
-
187
- #### Returns
188
-
189
- `boolean`
190
-
191
- True if issuer has signed
192
-
193
- ***
194
-
195
- ### injectMeta()
196
-
197
- > `abstract` **injectMeta**(`serializedTx`, `meta`): `string`
198
-
199
- Defined in: [adapters/base.ts:32](https://github.com/otaprotocol/actioncodes/blob/7fa582d3aecdeca51131d2fc9eec0802298f9a4d/src/adapters/base.ts#L32)
200
-
201
- Inject protocol meta into chain-specific transaction
202
-
203
- #### Parameters
204
-
205
- ##### serializedTx
206
-
207
- `string`
208
-
209
- Serialized transaction string
210
-
211
- ##### meta
212
-
213
- [`ProtocolMetaV1`](../../../meta/interfaces/ProtocolMetaV1.md)
214
-
215
- ProtocolMetaV1 object
216
-
217
- #### Returns
218
-
219
- `string`
220
-
221
- Serialized transaction with injected meta
222
-
223
- ***
224
-
225
- ### signWithProtocolKey()
226
-
227
- > `abstract` **signWithProtocolKey**(`actionCode`, `key`): `Promise`\<[`ActionCode`](../../../actioncode/classes/ActionCode.md)\>
228
-
229
- Defined in: [adapters/base.ts:126](https://github.com/otaprotocol/actioncodes/blob/7fa582d3aecdeca51131d2fc9eec0802298f9a4d/src/adapters/base.ts#L126)
230
-
231
- Sign the transaction with the protocol key using a callback approach
232
- This method should be implemented by each chain-specific adapter to handle
233
- the chain's specific signing mechanism asynchronously
234
-
235
- #### Parameters
236
-
237
- ##### actionCode
238
-
239
- [`ActionCode`](../../../actioncode/classes/ActionCode.md)
240
-
241
- ##### key
242
-
243
- `any`
244
-
245
- #### Returns
246
-
247
- `Promise`\<[`ActionCode`](../../../actioncode/classes/ActionCode.md)\>
248
-
249
- Promise that resolves to the signed transaction
250
-
251
- ***
252
-
253
- ### validate()
254
-
255
- > `abstract` **validate**(`tx`, `authorities`, `expectedPrefix?`): `boolean`
256
-
257
- Defined in: [adapters/base.ts:41](https://github.com/otaprotocol/actioncodes/blob/7fa582d3aecdeca51131d2fc9eec0802298f9a4d/src/adapters/base.ts#L41)
258
-
259
- Validate transaction with protocol meta and authority list
260
-
261
- #### Parameters
262
-
263
- ##### tx
264
-
265
- `T`
266
-
267
- Chain-specific transaction
268
-
269
- ##### authorities
270
-
271
- `string`[]
272
-
273
- Array of valid protocol authority identifiers
274
-
275
- ##### expectedPrefix?
276
-
277
- `string`
278
-
279
- Expected protocol prefix (default: 'DEFAULT')
280
-
281
- #### Returns
282
-
283
- `boolean`
284
-
285
- True if transaction is valid
286
-
287
- ***
288
-
289
- ### validateSignedMessage()
290
-
291
- > `abstract` **validateSignedMessage**(`message`, `signedMessage`, `pubkey`): `boolean`
292
-
293
- Defined in: [adapters/base.ts:138](https://github.com/otaprotocol/actioncodes/blob/7fa582d3aecdeca51131d2fc9eec0802298f9a4d/src/adapters/base.ts#L138)
294
-
295
- #### Parameters
296
-
297
- ##### message
298
-
299
- `string`
300
-
301
- ##### signedMessage
302
-
303
- `string`
304
-
305
- ##### pubkey
306
-
307
- `string`
308
-
309
- #### Returns
310
-
311
- `boolean`
312
-
313
- ***
314
-
315
- ### validateTransactionIntegrity()
316
-
317
- > `abstract` `protected` **validateTransactionIntegrity**(`tx`, `meta`): `boolean`
318
-
319
- Defined in: [adapters/base.ts:95](https://github.com/otaprotocol/actioncodes/blob/7fa582d3aecdeca51131d2fc9eec0802298f9a4d/src/adapters/base.ts#L95)
320
-
321
- Chain-specific transaction integrity validation
322
- Override this method for additional validation logic
323
-
324
- #### Parameters
325
-
326
- ##### tx
327
-
328
- `T`
329
-
330
- Chain-specific transaction
331
-
332
- ##### meta
333
-
334
- [`ProtocolMetaV1`](../../../meta/interfaces/ProtocolMetaV1.md)
335
-
336
- Decoded protocol meta
337
-
338
- #### Returns
339
-
340
- `boolean`
341
-
342
- True if transaction integrity is valid
343
-
344
- ***
345
-
346
- ### verifyCodeSignature()
347
-
348
- > `abstract` **verifyCodeSignature**(`actionCode`): `boolean`
349
-
350
- Defined in: [adapters/base.ts:115](https://github.com/otaprotocol/actioncodes/blob/7fa582d3aecdeca51131d2fc9eec0802298f9a4d/src/adapters/base.ts#L115)
351
-
352
- Verify the code signature
353
- This is specific to the chain and should be implemented by the concrete adapter
354
- It will be used to verify the code signature for the action code if the right wallet is used to sign the code
355
-
356
- #### Parameters
357
-
358
- ##### actionCode
359
-
360
- [`ActionCode`](../../../actioncode/classes/ActionCode.md)
361
-
362
- The action code to verify
363
-
364
- #### Returns
365
-
366
- `boolean`
367
-
368
- True if the code signature is valid
369
-
370
- ***
371
-
372
- ### verifyFinalizedTransaction()
373
-
374
- > `abstract` **verifyFinalizedTransaction**(`tx`, `actionCode`): `boolean`
375
-
376
- Defined in: [adapters/base.ts:136](https://github.com/otaprotocol/actioncodes/blob/7fa582d3aecdeca51131d2fc9eec0802298f9a4d/src/adapters/base.ts#L136)
377
-
378
- Verify the finalized transaction
379
-
380
- #### Parameters
381
-
382
- ##### tx
383
-
384
- `any`
385
-
386
- The finalized transaction to verify
387
-
388
- ##### actionCode
389
-
390
- [`ActionCode`](../../../actioncode/classes/ActionCode.md)
391
-
392
- #### Returns
393
-
394
- `boolean`
395
-
396
- True if the transaction is valid
@@ -1,19 +0,0 @@
1
- [**@actioncodes/protocol**](../../README.md)
2
-
3
- ***
4
-
5
- [@actioncodes/protocol](../../modules.md) / adapters/solana
6
-
7
- # adapters/solana
8
-
9
- ## References
10
-
11
- ### SolanaAdapter
12
-
13
- Re-exports [SolanaAdapter](solana/classes/SolanaAdapter.md)
14
-
15
- ***
16
-
17
- ### SolanaTransaction
18
-
19
- Re-exports [SolanaTransaction](solana/type-aliases/SolanaTransaction.md)
@@ -1,15 +0,0 @@
1
- [**@actioncodes/protocol**](../../../README.md)
2
-
3
- ***
4
-
5
- [@actioncodes/protocol](../../../modules.md) / adapters/solana/solana
6
-
7
- # adapters/solana/solana
8
-
9
- ## Classes
10
-
11
- - [SolanaAdapter](classes/SolanaAdapter.md)
12
-
13
- ## Type Aliases
14
-
15
- - [SolanaTransaction](type-aliases/SolanaTransaction.md)