@actioncodes/protocol 1.0.1 → 1.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 (28) hide show
  1. package/README.md +1 -1
  2. package/dist/codegen.d.ts +20 -7
  3. package/dist/codegen.d.ts.map +1 -1
  4. package/dist/codegen.js +107 -15
  5. package/docs/README.md +1 -1
  6. package/docs/actioncode/classes/ActionCode.md +23 -23
  7. package/docs/actioncode/interfaces/ActionCodeFields.md +11 -11
  8. package/docs/actioncode/interfaces/ActionCodeMetadata.md +3 -3
  9. package/docs/actioncode/interfaces/ActionCodeTransaction.md +4 -4
  10. package/docs/actioncode/type-aliases/ActionCodeStatus.md +1 -1
  11. package/docs/adapters/base/classes/BaseChainAdapter.md +10 -10
  12. package/docs/adapters/solana/solana/classes/SolanaAdapter.md +12 -12
  13. package/docs/adapters/solana/solana/type-aliases/SolanaTransaction.md +1 -1
  14. package/docs/codegen/classes/CodeGenerator.md +75 -23
  15. package/docs/constants/type-aliases/SupportedChain.md +1 -1
  16. package/docs/constants/variables/CODE_LENGTH.md +1 -1
  17. package/docs/constants/variables/CODE_TTL.md +1 -1
  18. package/docs/constants/variables/MAX_PREFIX_LENGTH.md +1 -1
  19. package/docs/constants/variables/MIN_PREFIX_LENGTH.md +1 -1
  20. package/docs/constants/variables/PROTOCOL_CODE_PREFIX.md +1 -1
  21. package/docs/constants/variables/PROTOCOL_PREFIX.md +1 -1
  22. package/docs/constants/variables/PROTOCOL_VERSION.md +1 -1
  23. package/docs/constants/variables/SUPPORTED_CHAINS.md +1 -1
  24. package/docs/meta/classes/ProtocolMetaParser.md +6 -6
  25. package/docs/meta/interfaces/ProtocolMetaV1.md +7 -7
  26. package/docs/protocol/classes/ActionCodesProtocol.md +21 -21
  27. package/docs/protocol/interfaces/ProtocolConfig.md +7 -7
  28. package/package.json +1 -1
@@ -6,7 +6,7 @@
6
6
 
7
7
  # Class: `abstract` BaseChainAdapter\<T\>
8
8
 
9
- Defined in: [adapters/base.ts:9](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/adapters/base.ts#L9)
9
+ Defined in: [adapters/base.ts:9](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/adapters/base.ts#L9)
10
10
 
11
11
  Base adapter class for chain-specific protocol meta operations
12
12
 
@@ -38,7 +38,7 @@ Chain-specific transaction type
38
38
 
39
39
  > `abstract` `readonly` **chain**: `string`
40
40
 
41
- Defined in: [adapters/base.ts:10](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/adapters/base.ts#L10)
41
+ Defined in: [adapters/base.ts:10](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/adapters/base.ts#L10)
42
42
 
43
43
  ## Methods
44
44
 
@@ -46,7 +46,7 @@ Defined in: [adapters/base.ts:10](https://github.com/otaprotocol/actioncodes/blo
46
46
 
47
47
  > `abstract` **decode**(`tx`): `null` \| [`ProtocolMetaV1`](../../../meta/interfaces/ProtocolMetaV1.md)
48
48
 
49
- Defined in: [adapters/base.ts:24](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/adapters/base.ts#L24)
49
+ Defined in: [adapters/base.ts:24](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/adapters/base.ts#L24)
50
50
 
51
51
  Decode protocol meta from chain-specific transaction
52
52
 
@@ -70,7 +70,7 @@ Decoded ProtocolMetaV1 or null
70
70
 
71
71
  > **detectTampering**(`tx`, `authorities`, `expectedPrefix`): `boolean`
72
72
 
73
- Defined in: [adapters/base.ts:50](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/adapters/base.ts#L50)
73
+ Defined in: [adapters/base.ts:50](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/adapters/base.ts#L50)
74
74
 
75
75
  Detect tampered transactions by cross-checking metadata
76
76
 
@@ -106,7 +106,7 @@ True if transaction is valid and not tampered
106
106
 
107
107
  > `abstract` **encode**(`meta`): `any`
108
108
 
109
- Defined in: [adapters/base.ts:17](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/adapters/base.ts#L17)
109
+ Defined in: [adapters/base.ts:17](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/adapters/base.ts#L17)
110
110
 
111
111
  Encode protocol meta for this chain
112
112
 
@@ -130,7 +130,7 @@ Chain-specific encoded data
130
130
 
131
131
  > **getCodeSignatureMessage**(`code`, `timestamp`, `prefix`): `string`
132
132
 
133
- Defined in: [adapters/base.ts:96](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/adapters/base.ts#L96)
133
+ Defined in: [adapters/base.ts:96](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/adapters/base.ts#L96)
134
134
 
135
135
  Get the code signature message
136
136
 
@@ -166,7 +166,7 @@ The code signature message
166
166
 
167
167
  > `abstract` **hasIssuerSignature**(`tx`, `issuer`): `boolean`
168
168
 
169
- Defined in: [adapters/base.ts:41](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/adapters/base.ts#L41)
169
+ Defined in: [adapters/base.ts:41](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/adapters/base.ts#L41)
170
170
 
171
171
  Check if the issuer has signed the transaction
172
172
 
@@ -196,7 +196,7 @@ True if issuer has signed
196
196
 
197
197
  > `abstract` **validate**(`tx`, `authorities`, `expectedPrefix?`): `boolean`
198
198
 
199
- Defined in: [adapters/base.ts:33](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/adapters/base.ts#L33)
199
+ Defined in: [adapters/base.ts:33](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/adapters/base.ts#L33)
200
200
 
201
201
  Validate transaction with protocol meta and authority list
202
202
 
@@ -232,7 +232,7 @@ True if transaction is valid
232
232
 
233
233
  > `abstract` `protected` **validateTransactionIntegrity**(`tx`, `meta`): `boolean`
234
234
 
235
- Defined in: [adapters/base.ts:87](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/adapters/base.ts#L87)
235
+ Defined in: [adapters/base.ts:87](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/adapters/base.ts#L87)
236
236
 
237
237
  Chain-specific transaction integrity validation
238
238
  Override this method for additional validation logic
@@ -263,7 +263,7 @@ True if transaction integrity is valid
263
263
 
264
264
  > `abstract` **verifyCodeSignature**(`actionCode`): `boolean`
265
265
 
266
- Defined in: [adapters/base.ts:107](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/adapters/base.ts#L107)
266
+ Defined in: [adapters/base.ts:107](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/adapters/base.ts#L107)
267
267
 
268
268
  Verify the code signature
269
269
  This is specific to the chain and should be implemented by the concrete adapter
@@ -6,7 +6,7 @@
6
6
 
7
7
  # Class: SolanaAdapter
8
8
 
9
- Defined in: [adapters/solana/solana.ts:24](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/adapters/solana/solana.ts#L24)
9
+ Defined in: [adapters/solana/solana.ts:24](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/adapters/solana/solana.ts#L24)
10
10
 
11
11
  Simple Solana adapter for protocol meta operations
12
12
  Supports both legacy and versioned transactions
@@ -35,7 +35,7 @@ Supports both legacy and versioned transactions
35
35
 
36
36
  > `readonly` **chain**: `"solana"` = `'solana'`
37
37
 
38
- Defined in: [adapters/solana/solana.ts:27](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/adapters/solana/solana.ts#L27)
38
+ Defined in: [adapters/solana/solana.ts:27](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/adapters/solana/solana.ts#L27)
39
39
 
40
40
  #### Overrides
41
41
 
@@ -47,7 +47,7 @@ Defined in: [adapters/solana/solana.ts:27](https://github.com/otaprotocol/action
47
47
 
48
48
  > **decode**(`tx`): `null` \| [`ProtocolMetaV1`](../../../../meta/interfaces/ProtocolMetaV1.md)
49
49
 
50
- Defined in: [adapters/solana/solana.ts:44](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/adapters/solana/solana.ts#L44)
50
+ Defined in: [adapters/solana/solana.ts:44](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/adapters/solana/solana.ts#L44)
51
51
 
52
52
  Decode protocol meta from Solana transaction (legacy or versioned)
53
53
 
@@ -75,7 +75,7 @@ Decoded ProtocolMetaV1 or null if not found
75
75
 
76
76
  > **decodeFromBase64**(`base64String`): `null` \| [`ProtocolMetaV1`](../../../../meta/interfaces/ProtocolMetaV1.md)
77
77
 
78
- Defined in: [adapters/solana/solana.ts:205](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/adapters/solana/solana.ts#L205)
78
+ Defined in: [adapters/solana/solana.ts:205](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/adapters/solana/solana.ts#L205)
79
79
 
80
80
  Decode protocol meta from base64 string (for backward compatibility)
81
81
 
@@ -99,7 +99,7 @@ Decoded ProtocolMetaV1 or null
99
99
 
100
100
  > **detectTampering**(`tx`, `authorities`, `expectedPrefix`): `boolean`
101
101
 
102
- Defined in: [adapters/base.ts:50](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/adapters/base.ts#L50)
102
+ Defined in: [adapters/base.ts:50](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/adapters/base.ts#L50)
103
103
 
104
104
  Detect tampered transactions by cross-checking metadata
105
105
 
@@ -139,7 +139,7 @@ True if transaction is valid and not tampered
139
139
 
140
140
  > **encode**(`meta`): `TransactionInstruction`
141
141
 
142
- Defined in: [adapters/solana/solana.ts:34](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/adapters/solana/solana.ts#L34)
142
+ Defined in: [adapters/solana/solana.ts:34](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/adapters/solana/solana.ts#L34)
143
143
 
144
144
  Encode protocol meta as a Solana memo instruction
145
145
 
@@ -167,7 +167,7 @@ TransactionInstruction for the memo
167
167
 
168
168
  > **getCodeSignatureMessage**(`code`, `timestamp`, `prefix`): `string`
169
169
 
170
- Defined in: [adapters/base.ts:96](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/adapters/base.ts#L96)
170
+ Defined in: [adapters/base.ts:96](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/adapters/base.ts#L96)
171
171
 
172
172
  Get the code signature message
173
173
 
@@ -207,7 +207,7 @@ The code signature message
207
207
 
208
208
  > **hasIssuerSignature**(`tx`, `issuer`): `boolean`
209
209
 
210
- Defined in: [adapters/solana/solana.ts:72](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/adapters/solana/solana.ts#L72)
210
+ Defined in: [adapters/solana/solana.ts:72](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/adapters/solana/solana.ts#L72)
211
211
 
212
212
  Check if the issuer has signed the transaction
213
213
 
@@ -241,7 +241,7 @@ True if issuer has signed
241
241
 
242
242
  > **validate**(`tx`, `authorities`, `expectedPrefix`): `boolean`
243
243
 
244
- Defined in: [adapters/solana/solana.ts:62](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/adapters/solana/solana.ts#L62)
244
+ Defined in: [adapters/solana/solana.ts:62](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/adapters/solana/solana.ts#L62)
245
245
 
246
246
  Validate transaction with protocol meta and authority list
247
247
 
@@ -281,7 +281,7 @@ True if transaction is valid
281
281
 
282
282
  > **validateFromBase64**(`base64String`, `authorities`, `expectedPrefix`): `boolean`
283
283
 
284
- Defined in: [adapters/solana/solana.ts:228](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/adapters/solana/solana.ts#L228)
284
+ Defined in: [adapters/solana/solana.ts:228](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/adapters/solana/solana.ts#L228)
285
285
 
286
286
  Validate base64 transaction (for backward compatibility)
287
287
 
@@ -317,7 +317,7 @@ True if transaction is valid
317
317
 
318
318
  > `protected` **validateTransactionIntegrity**(`tx`, `meta`): `boolean`
319
319
 
320
- Defined in: [adapters/solana/solana.ts:179](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/adapters/solana/solana.ts#L179)
320
+ Defined in: [adapters/solana/solana.ts:179](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/adapters/solana/solana.ts#L179)
321
321
 
322
322
  Validate Solana transaction integrity with additional checks
323
323
 
@@ -351,7 +351,7 @@ True if transaction integrity is valid
351
351
 
352
352
  > **verifyCodeSignature**(`actionCode`): `boolean`
353
353
 
354
- Defined in: [adapters/solana/solana.ts:245](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/adapters/solana/solana.ts#L245)
354
+ Defined in: [adapters/solana/solana.ts:245](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/adapters/solana/solana.ts#L245)
355
355
 
356
356
  Verify the code signature
357
357
  This is specific to the chain and should be implemented by the concrete adapter
@@ -8,6 +8,6 @@
8
8
 
9
9
  > **SolanaTransaction** = `Transaction` \| `VersionedTransaction`
10
10
 
11
- Defined in: [adapters/solana/solana.ts:18](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/adapters/solana/solana.ts#L18)
11
+ Defined in: [adapters/solana/solana.ts:18](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/adapters/solana/solana.ts#L18)
12
12
 
13
13
  Solana transaction type union
@@ -6,7 +6,7 @@
6
6
 
7
7
  # Class: CodeGenerator
8
8
 
9
- Defined in: [codegen.ts:4](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/codegen.ts#L4)
9
+ Defined in: [codegen.ts:4](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/codegen.ts#L4)
10
10
 
11
11
  ## Constructors
12
12
 
@@ -24,7 +24,7 @@ Defined in: [codegen.ts:4](https://github.com/otaprotocol/actioncodes/blob/fa975
24
24
 
25
25
  > `static` **CODE\_DIGITS**: `number` = `CODE_LENGTH`
26
26
 
27
- Defined in: [codegen.ts:6](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/codegen.ts#L6)
27
+ Defined in: [codegen.ts:6](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/codegen.ts#L6)
28
28
 
29
29
  ***
30
30
 
@@ -32,7 +32,7 @@ Defined in: [codegen.ts:6](https://github.com/otaprotocol/actioncodes/blob/fa975
32
32
 
33
33
  > `static` **MAX\_PREFIX\_LENGTH**: `number`
34
34
 
35
- Defined in: [codegen.ts:8](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/codegen.ts#L8)
35
+ Defined in: [codegen.ts:8](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/codegen.ts#L8)
36
36
 
37
37
  ***
38
38
 
@@ -40,7 +40,7 @@ Defined in: [codegen.ts:8](https://github.com/otaprotocol/actioncodes/blob/fa975
40
40
 
41
41
  > `static` **MIN\_PREFIX\_LENGTH**: `number`
42
42
 
43
- Defined in: [codegen.ts:7](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/codegen.ts#L7)
43
+ Defined in: [codegen.ts:7](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/codegen.ts#L7)
44
44
 
45
45
  ***
46
46
 
@@ -48,7 +48,7 @@ Defined in: [codegen.ts:7](https://github.com/otaprotocol/actioncodes/blob/fa975
48
48
 
49
49
  > `static` **TIME\_WINDOW\_MS**: `number` = `CODE_TTL`
50
50
 
51
- Defined in: [codegen.ts:5](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/codegen.ts#L5)
51
+ Defined in: [codegen.ts:5](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/codegen.ts#L5)
52
52
 
53
53
  ## Methods
54
54
 
@@ -56,7 +56,7 @@ Defined in: [codegen.ts:5](https://github.com/otaprotocol/actioncodes/blob/fa975
56
56
 
57
57
  > `static` **deriveCodeHash**(`pubkey`, `prefix`, `timestamp?`): `string`
58
58
 
59
- Defined in: [codegen.ts:72](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/codegen.ts#L72)
59
+ Defined in: [codegen.ts:167](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/codegen.ts#L167)
60
60
 
61
61
  Derive the full SHA-256 hash for storage or encryption key generation
62
62
 
@@ -70,9 +70,9 @@ Solana wallet public key (base58)
70
70
 
71
71
  ##### prefix
72
72
 
73
- `string` = `"DEFAULT"`
73
+ `string` = `PROTOCOL_CODE_PREFIX`
74
74
 
75
- Optional namespace prefix (default: "DEFAULT")
75
+ Optional namespace prefix (default: PROTOCOL_CODE_PREFIX)
76
76
 
77
77
  ##### timestamp?
78
78
 
@@ -92,7 +92,7 @@ Full SHA-256 hash string
92
92
 
93
93
  > `static` **generateCode**(`pubkey`, `prefix`, `timestamp`): `object`
94
94
 
95
- Defined in: [codegen.ts:42](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/codegen.ts#L42)
95
+ Defined in: [codegen.ts:123](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/codegen.ts#L123)
96
96
 
97
97
  Generate a deterministic 8-digit code based on public key, prefix, and timestamp
98
98
 
@@ -106,9 +106,9 @@ Solana wallet public key (base58)
106
106
 
107
107
  ##### prefix
108
108
 
109
- `string` = `"DEFAULT"`
109
+ `string` = `PROTOCOL_CODE_PREFIX`
110
110
 
111
- Optional namespace prefix (default: "DEFAULT")
111
+ Optional namespace prefix (default: PROTOCOL_CODE_PREFIX)
112
112
 
113
113
  ##### timestamp
114
114
 
@@ -134,13 +134,17 @@ Object containing code, issuedAt, and expiresAt timestamps
134
134
 
135
135
  > **issuedAt**: `number`
136
136
 
137
+ #### Throws
138
+
139
+ Error if generated code is invalid
140
+
137
141
  ***
138
142
 
139
143
  ### getExpectedCode()
140
144
 
141
145
  > `static` **getExpectedCode**(`pubkey`, `timestamp`, `prefix`): `string`
142
146
 
143
- Defined in: [codegen.ts:91](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/codegen.ts#L91)
147
+ Defined in: [codegen.ts:186](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/codegen.ts#L186)
144
148
 
145
149
  Get the expected code for a given public key and timestamp
146
150
 
@@ -160,15 +164,15 @@ UNIX timestamp in milliseconds
160
164
 
161
165
  ##### prefix
162
166
 
163
- `string` = `"DEFAULT"`
167
+ `string` = `PROTOCOL_CODE_PREFIX`
164
168
 
165
- Optional namespace prefix (default: "DEFAULT")
169
+ Optional namespace prefix (default: PROTOCOL_CODE_PREFIX)
166
170
 
167
171
  #### Returns
168
172
 
169
173
  `string`
170
174
 
171
- 8-digit numeric string
175
+ Full code string with prefix + 8 digits
172
176
 
173
177
  ***
174
178
 
@@ -176,7 +180,7 @@ Optional namespace prefix (default: "DEFAULT")
176
180
 
177
181
  > `static` **isValidTimestamp**(`timestamp`): `boolean`
178
182
 
179
- Defined in: [codegen.ts:124](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/codegen.ts#L124)
183
+ Defined in: [codegen.ts:228](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/codegen.ts#L228)
180
184
 
181
185
  Check if a timestamp falls within a valid time window
182
186
 
@@ -200,9 +204,9 @@ True if timestamp is valid
200
204
 
201
205
  > `static` **normalizePrefix**(`prefix`): `string`
202
206
 
203
- Defined in: [codegen.ts:27](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/codegen.ts#L27)
207
+ Defined in: [codegen.ts:107](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/codegen.ts#L107)
204
208
 
205
- Normalize prefix - convert "DEFAULT" to empty string, validate others
209
+ Normalize prefix - convert PROTOCOL_CODE_PREFIX to empty string, validate others
206
210
 
207
211
  #### Parameters
208
212
 
@@ -228,7 +232,7 @@ Error if prefix is invalid
228
232
 
229
233
  > `static` **validateCode**(`code`, `pubkey`, `timestamp`, `prefix`): `boolean`
230
234
 
231
- Defined in: [codegen.ts:107](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/codegen.ts#L107)
235
+ Defined in: [codegen.ts:202](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/codegen.ts#L202)
232
236
 
233
237
  Validate if a code matches the expected code for a given public key and timestamp
234
238
 
@@ -238,7 +242,7 @@ Validate if a code matches the expected code for a given public key and timestam
238
242
 
239
243
  `string`
240
244
 
241
- The code to validate
245
+ The code to validate (can include prefix)
242
246
 
243
247
  ##### pubkey
244
248
 
@@ -254,9 +258,9 @@ UNIX timestamp in milliseconds
254
258
 
255
259
  ##### prefix
256
260
 
257
- `string` = `"DEFAULT"`
261
+ `string` = `PROTOCOL_CODE_PREFIX`
258
262
 
259
- Optional namespace prefix (default: "DEFAULT")
263
+ Optional namespace prefix (default: PROTOCOL_CODE_PREFIX)
260
264
 
261
265
  #### Returns
262
266
 
@@ -266,11 +270,59 @@ True if code matches expected code and timestamp is valid
266
270
 
267
271
  ***
268
272
 
273
+ ### validateCodeDigits()
274
+
275
+ > `static` **validateCodeDigits**(`code`): `boolean`
276
+
277
+ Defined in: [codegen.ts:67](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/codegen.ts#L67)
278
+
279
+ Validate that the numeric part of a code is exactly 8 digits
280
+
281
+ #### Parameters
282
+
283
+ ##### code
284
+
285
+ `string`
286
+
287
+ The code to validate (can include prefix)
288
+
289
+ #### Returns
290
+
291
+ `boolean`
292
+
293
+ True if numeric part is valid, false otherwise
294
+
295
+ ***
296
+
297
+ ### validateCodeFormat()
298
+
299
+ > `static` **validateCodeFormat**(`code`): `boolean`
300
+
301
+ Defined in: [codegen.ts:26](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/codegen.ts#L26)
302
+
303
+ Validate generated code format (prefix + exactly 8 digits)
304
+
305
+ #### Parameters
306
+
307
+ ##### code
308
+
309
+ `string`
310
+
311
+ The code to validate
312
+
313
+ #### Returns
314
+
315
+ `boolean`
316
+
317
+ True if code is valid, false otherwise
318
+
319
+ ***
320
+
269
321
  ### validatePrefix()
270
322
 
271
323
  > `static` **validatePrefix**(`prefix`): `boolean`
272
324
 
273
- Defined in: [codegen.ts:15](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/codegen.ts#L15)
325
+ Defined in: [codegen.ts:15](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/codegen.ts#L15)
274
326
 
275
327
  Validate prefix format
276
328
 
@@ -8,4 +8,4 @@
8
8
 
9
9
  > **SupportedChain** = *typeof* [`SUPPORTED_CHAINS`](../variables/SUPPORTED_CHAINS.md)\[`number`\]
10
10
 
11
- Defined in: [constants.ts:9](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/constants.ts#L9)
11
+ Defined in: [constants.ts:9](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/constants.ts#L9)
@@ -8,4 +8,4 @@
8
8
 
9
9
  > `const` **CODE\_LENGTH**: `8` = `8`
10
10
 
11
- Defined in: [constants.ts:3](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/constants.ts#L3)
11
+ Defined in: [constants.ts:3](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/constants.ts#L3)
@@ -8,4 +8,4 @@
8
8
 
9
9
  > `const` **CODE\_TTL**: `number`
10
10
 
11
- Defined in: [constants.ts:4](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/constants.ts#L4)
11
+ Defined in: [constants.ts:4](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/constants.ts#L4)
@@ -8,4 +8,4 @@
8
8
 
9
9
  > `const` **MAX\_PREFIX\_LENGTH**: `12` = `12`
10
10
 
11
- Defined in: [constants.ts:7](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/constants.ts#L7)
11
+ Defined in: [constants.ts:7](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/constants.ts#L7)
@@ -8,4 +8,4 @@
8
8
 
9
9
  > `const` **MIN\_PREFIX\_LENGTH**: `3` = `3`
10
10
 
11
- Defined in: [constants.ts:6](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/constants.ts#L6)
11
+ Defined in: [constants.ts:6](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/constants.ts#L6)
@@ -8,4 +8,4 @@
8
8
 
9
9
  > `const` **PROTOCOL\_CODE\_PREFIX**: `"DEFAULT"` = `"DEFAULT"`
10
10
 
11
- Defined in: [constants.ts:5](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/constants.ts#L5)
11
+ Defined in: [constants.ts:5](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/constants.ts#L5)
@@ -8,4 +8,4 @@
8
8
 
9
9
  > `const` **PROTOCOL\_PREFIX**: `"actioncodes"` = `"actioncodes"`
10
10
 
11
- Defined in: [constants.ts:2](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/constants.ts#L2)
11
+ Defined in: [constants.ts:2](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/constants.ts#L2)
@@ -8,4 +8,4 @@
8
8
 
9
9
  > `const` **PROTOCOL\_VERSION**: `"1"` = `"1"`
10
10
 
11
- Defined in: [constants.ts:1](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/constants.ts#L1)
11
+ Defined in: [constants.ts:1](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/constants.ts#L1)
@@ -8,4 +8,4 @@
8
8
 
9
9
  > `const` **SUPPORTED\_CHAINS**: readonly \[`"solana"`\]
10
10
 
11
- Defined in: [constants.ts:8](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/constants.ts#L8)
11
+ Defined in: [constants.ts:8](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/constants.ts#L8)
@@ -6,7 +6,7 @@
6
6
 
7
7
  # Class: ProtocolMetaParser
8
8
 
9
- Defined in: [meta.ts:19](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/meta.ts#L19)
9
+ Defined in: [meta.ts:19](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/meta.ts#L19)
10
10
 
11
11
  Protocol meta parser for structured memo/message parsing
12
12
 
@@ -26,7 +26,7 @@ Protocol meta parser for structured memo/message parsing
26
26
 
27
27
  > `static` **fromInitiator**(`initiator`, `iss`, `prefix`, `params?`, `timestamp?`): [`ProtocolMetaV1`](../interfaces/ProtocolMetaV1.md)
28
28
 
29
- Defined in: [meta.ts:74](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/meta.ts#L74)
29
+ Defined in: [meta.ts:74](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/meta.ts#L74)
30
30
 
31
31
  Create protocol meta from code and parameters
32
32
 
@@ -74,7 +74,7 @@ ProtocolMeta object
74
74
 
75
75
  > `static` **parse**(`metaString`): `null` \| [`ProtocolMetaV1`](../interfaces/ProtocolMetaV1.md)
76
76
 
77
- Defined in: [meta.ts:27](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/meta.ts#L27)
77
+ Defined in: [meta.ts:27](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/meta.ts#L27)
78
78
 
79
79
  Parse protocol meta from string
80
80
 
@@ -98,7 +98,7 @@ Parsed ProtocolMeta object or null if invalid
98
98
 
99
99
  > `static` **serialize**(`meta`): `string`
100
100
 
101
- Defined in: [meta.ts:55](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/meta.ts#L55)
101
+ Defined in: [meta.ts:55](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/meta.ts#L55)
102
102
 
103
103
  Serialize ProtocolMeta to string
104
104
 
@@ -122,7 +122,7 @@ Serialized protocol meta string
122
122
 
123
123
  > `static` **validateCode**(`meta`, `timestamp?`): `boolean`
124
124
 
125
- Defined in: [meta.ts:99](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/meta.ts#L99)
125
+ Defined in: [meta.ts:99](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/meta.ts#L99)
126
126
 
127
127
  Validate if a code matches the protocol meta
128
128
 
@@ -152,7 +152,7 @@ True if the meta is valid
152
152
 
153
153
  > `static` **validateMetaFromString**(`metaString`, `timestamp?`): `boolean`
154
154
 
155
- Defined in: [meta.ts:110](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/meta.ts#L110)
155
+ Defined in: [meta.ts:110](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/meta.ts#L110)
156
156
 
157
157
  Validate if a code matches the protocol meta by parsing from string
158
158
 
@@ -6,7 +6,7 @@
6
6
 
7
7
  # Interface: ProtocolMetaV1
8
8
 
9
- Defined in: [meta.ts:7](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/meta.ts#L7)
9
+ Defined in: [meta.ts:7](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/meta.ts#L7)
10
10
 
11
11
  Protocol meta structure for code verification
12
12
 
@@ -16,7 +16,7 @@ Protocol meta structure for code verification
16
16
 
17
17
  > **id**: `string`
18
18
 
19
- Defined in: [meta.ts:11](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/meta.ts#L11)
19
+ Defined in: [meta.ts:11](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/meta.ts#L11)
20
20
 
21
21
  ***
22
22
 
@@ -24,7 +24,7 @@ Defined in: [meta.ts:11](https://github.com/otaprotocol/actioncodes/blob/fa975e9
24
24
 
25
25
  > **initiator**: `string`
26
26
 
27
- Defined in: [meta.ts:10](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/meta.ts#L10)
27
+ Defined in: [meta.ts:10](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/meta.ts#L10)
28
28
 
29
29
  ***
30
30
 
@@ -32,7 +32,7 @@ Defined in: [meta.ts:10](https://github.com/otaprotocol/actioncodes/blob/fa975e9
32
32
 
33
33
  > `optional` **iss**: `string`
34
34
 
35
- Defined in: [meta.ts:12](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/meta.ts#L12)
35
+ Defined in: [meta.ts:12](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/meta.ts#L12)
36
36
 
37
37
  ***
38
38
 
@@ -40,7 +40,7 @@ Defined in: [meta.ts:12](https://github.com/otaprotocol/actioncodes/blob/fa975e9
40
40
 
41
41
  > `optional` **params**: `string`
42
42
 
43
- Defined in: [meta.ts:13](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/meta.ts#L13)
43
+ Defined in: [meta.ts:13](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/meta.ts#L13)
44
44
 
45
45
  ***
46
46
 
@@ -48,7 +48,7 @@ Defined in: [meta.ts:13](https://github.com/otaprotocol/actioncodes/blob/fa975e9
48
48
 
49
49
  > **prefix**: `string`
50
50
 
51
- Defined in: [meta.ts:9](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/meta.ts#L9)
51
+ Defined in: [meta.ts:9](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/meta.ts#L9)
52
52
 
53
53
  ***
54
54
 
@@ -56,4 +56,4 @@ Defined in: [meta.ts:9](https://github.com/otaprotocol/actioncodes/blob/fa975e9d
56
56
 
57
57
  > **version**: `string`
58
58
 
59
- Defined in: [meta.ts:8](https://github.com/otaprotocol/actioncodes/blob/fa975e9d2d8d3ff72314243f62c7c4bd689877da/src/meta.ts#L8)
59
+ Defined in: [meta.ts:8](https://github.com/otaprotocol/actioncodes/blob/007a9e0d8a0303f8bd7d2ee1ee5ee3e0ff8d987c/src/meta.ts#L8)