-
Notifications
You must be signed in to change notification settings - Fork 3
chore: remove references to any in src/keri/core directory #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feat/agenting_type_hints
Are you sure you want to change the base?
Changes from 21 commits
4d389f7
56a35f5
c003c1b
8016535
1679dc6
98b637f
508b1eb
0663bbe
025ed27
63ed799
8b4c712
911318d
84d5c3d
82d077e
7c9bcd7
9acdffe
2756a67
7a0e185
cfd9227
d74ba14
50384d4
7656c87
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ dist | |
# IntelliJ Project Files | ||
.idea | ||
coverage/* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { execSync } from 'child_process'; | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
|
||
const specUrl = process.env.SPEC_URL; | ||
const outputFile = path.resolve('src/types/keria-api-schema.ts'); | ||
|
||
if (!specUrl) { | ||
console.log('⚠️ Skipping OpenAPI type generation: SPEC_URL is not set.'); | ||
process.exit(0); | ||
} | ||
|
||
console.log(`📦 Generating types from ${specUrl}`); | ||
execSync(`npx openapi-typescript "${specUrl}" --output ${outputFile} --enum`, { | ||
stdio: 'inherit', | ||
}); | ||
|
||
// Read the full file | ||
const fullContent = fs.readFileSync(outputFile, 'utf8'); | ||
|
||
// Extract the `export interface components { ... }` block | ||
const componentsMatch = fullContent.match(/export interface components \{[\s\S]+?\n\}/); | ||
|
||
// Extract all `export enum ... { ... }` blocks | ||
const enumMatches = [...fullContent.matchAll(/export enum [\w\d_]+ \{[\s\S]+?\n\}/g)]; | ||
|
||
if (!componentsMatch) { | ||
console.error("❌ Could not find 'export interface components' block."); | ||
process.exit(1); | ||
} | ||
|
||
// Combine the interface and enums | ||
const enumsText = enumMatches.map(m => m[0]).join('\n\n'); | ||
const cleaned = `// AUTO-GENERATED: Only components and enums retained from OpenAPI schema\n\n${enumsText}\n\n${componentsMatch[0]}\n`; | ||
|
||
fs.writeFileSync(outputFile, cleaned, 'utf8'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
import { Cipher } from '../core/cipher.ts'; | ||
import { b, Ilks, Serials, Vrsn_1_0 } from '../core/core.ts'; | ||
import { Decrypter } from '../core/decrypter.ts'; | ||
import { Diger } from '../core/diger.ts'; | ||
import { Encrypter } from '../core/encrypter.ts'; | ||
import { incept, InceptEventSAD, interact, InteractEventSAD, rotate } from '../core/eventing.ts'; | ||
import { SaltyCreator } from '../core/manager.ts'; | ||
import { Salter, Tier } from '../core/salter.ts'; | ||
import { MtrDex } from '../core/matter.ts'; | ||
import { Diger } from '../core/diger.ts'; | ||
import { incept, rotate, interact } from '../core/eventing.ts'; | ||
import { CesrNumber } from '../core/number.ts'; | ||
import { Salter, Tier } from '../core/salter.ts'; | ||
import { Seqner } from '../core/seqner.ts'; | ||
import { Serder } from '../core/serder.ts'; | ||
import { Signer } from '../core/signer.ts'; | ||
import { Tholder } from '../core/tholder.ts'; | ||
import { Ilks, b, Serials, Vrsn_1_0 } from '../core/core.ts'; | ||
import { Verfer } from '../core/verfer.ts'; | ||
import { Encrypter } from '../core/encrypter.ts'; | ||
import { Decrypter } from '../core/decrypter.ts'; | ||
import { Cipher } from '../core/cipher.ts'; | ||
import { Seqner } from '../core/seqner.ts'; | ||
import { CesrNumber } from '../core/number.ts'; | ||
|
||
/** | ||
* Agent is a custodial entity that can be used in conjuntion with a local Client to establish the | ||
|
@@ -128,7 +129,7 @@ export class Controller { | |
/** | ||
* Either the current establishment event, inception or rotation, or the interaction event used for delegation approval. | ||
*/ | ||
public serder: Serder; | ||
public serder: Serder<InteractEventSAD | InceptEventSAD>; | ||
/** | ||
* Current public keys formatted in fully-qualified Base64. | ||
* @private | ||
|
@@ -227,11 +228,12 @@ export class Controller { | |
|
||
approveDelegation(_agent: Agent) { | ||
const seqner = new Seqner({ sn: _agent.sn }); | ||
const anchor = { i: _agent.pre, s: seqner.snh, d: _agent.said }; | ||
const sn = new CesrNumber({}, undefined, this.serder.sad['s']).num + 1; | ||
const anchor = { i: _agent.pre, s: seqner.snh, d: _agent.said! }; | ||
const sn = | ||
new CesrNumber({}, undefined, String(this.serder.sad['s'])).num + 1; | ||
this.serder = interact({ | ||
pre: this.serder.pre, | ||
dig: this.serder.sad['d'], | ||
dig: this.serder.sad['d']!, | ||
|
||
sn: sn, | ||
data: [anchor], | ||
version: Vrsn_1_0, | ||
|
@@ -265,7 +267,10 @@ export class Controller { | |
wits: [], | ||
}); | ||
} else { | ||
return new Serder({ sad: state.controller['ee'] }); | ||
return new Serder({ | ||
sad: state.controller['ee'], | ||
d: '', | ||
}); | ||
} | ||
} | ||
|
||
|
@@ -386,7 +391,7 @@ export class Controller { | |
const signers = []; | ||
for (const prx of prxs) { | ||
const cipher = new Cipher({ qb64: prx }); | ||
const dsigner = decrypter.decrypt(null, cipher, true); | ||
const dsigner = decrypter.decrypt(null, cipher, true) as Signer; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reminder to myself: the initiation of CESR instances is very hard to work with in TypeScript. We should be able to know this decrypter returns |
||
signers.push(dsigner); | ||
nprxs.push(encrypter.encrypt(b(dsigner.qb64)).qb64); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Sotatek-Patrick-Vu is currently working on the typing for
ee
Serders (establishment events). I think we could narrow the typing here and we'd know exactly the format ofsad
so we'd knowsad.s
is a string. That'd be better but requires some coordination.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the status here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated