mirror of
https://github.com/selfxyz/self.git
synced 2026-01-09 22:58:20 -05:00
* docs: record app integration progress * docs: consolidate mobile SDK migration tracking * docs: humanize migration tracking and merge prompts * docs: add common consolidation tasks * docs: reprioritize migration tasks * docs: soften migration plan tone * docs: detail agent prompts with file paths * docs: catalog Linear tasks for SDK * updates * remove artifact management
5.3 KiB
5.3 KiB
Task Prompts
This file offers quick pointers for anyone picking up work from the migration plan. Use it to get oriented, then dive into the code.
Pre-flight checks
Run these before opening a PR:
yarn workspace @selfxyz/mobile-sdk-alpha nice
yarn workspace @selfxyz/mobile-sdk-alpha types
yarn workspace @selfxyz/mobile-sdk-alpha test
yarn workspace @selfxyz/mobile-sdk-alpha build
yarn lint
yarn build
Migration tasks
3. Integrate SDK into /app
- In
app/src/providers/passportDataProvider.tsxreplace local MRZ helpers withextractMRZInfofrom@selfxyz/mobile-sdk-alpha/mrzandparseNFCResponsefrom@selfxyz/mobile-sdk-alpha/nfc. - Update
app/src/components/native/PassportCamera.tsxandapp/src/utils/nfcScanner.tsto use the SDK exports. - Run
yarn workspace @selfxyz/mobile-app build && yarn workspace @selfxyz/mobile-app test.
4. Proof input generation
- Move
generateTEEInputsRegisterandgenerateTEEInputsDisclosefromapp/src/utils/proving/provingInputs.tsinto new files underpackages/mobile-sdk-alpha/src/proving/register.tsandpackages/mobile-sdk-alpha/src/proving/disclose.ts. - Replace
useProtocolStorewith agetTree(document, kind)callback so helpers are stateless. - Add tests in
packages/mobile-sdk-alpha/tests/proving.{register,disclose}.test.ts.
5. Crypto adapters
- Create
src/adapters/crypto/index.tsexporting aCryptoAdapterinterface withgetRandomValues,digestandtimingSafeEqual. - Implement
src/adapters/crypto/webcrypto.tsandsrc/adapters/crypto/noble.tsand wire runtime detection insrc/adapters/crypto/index.ts. - Add parity tests in
tests/crypto.test.tsensuring both adapters produce identical results.
6. TEE session management
- Implement
WsAdapterinsrc/adapters/ws/websocket.tswrappingWebSocketwith abort, timeout, and progress callbacks. - Export the adapter through
src/adapters/index.ts. - Add tests under
tests/ws.test.tsusing a mocked server intests/ws.server.ts.
7. Attestation verification
- Port
parseCertificateSimpleand PCR0 utilities fromcommon/src/utils/certificate_parsing/intosrc/attestation/verify.ts. - Expose
verifyAttestation(cert: ArrayBuffer, quote: ArrayBuffer)that returns the public key. - Cover the verifier with unit tests in
tests/attestation.test.ts.
8. Protocol synchronization
- Add
src/protocol/sync.tswithfetchProtocolTrees(fetchPage, cache)to paginate and cache trees. - Verify roots against
@selfxyz/common/utils/provingand honorRetry-Afterheaders. - Write tests in
tests/protocol.test.tswith a fake server.
9. React Native providers and hooks
- Move
app/src/providers/selfClientProvider.tsxintosrc/context.tsxand expose aSelfClientProviderthat accepts adapter instances (crypto,ws,storage,logger). - Add hooks like
useSelfClientanduseDocumentsinsrc/hooks/. - Remove the wrapper from the app and import the provider directly from the SDK.
10. Batteries-included components
- Create
src/components/Scanner.tsxusinguseScannerandSelfClientProvider. - Add
src/components/ScanButton.tsxthat triggers MRZ and NFC flows with optional adapter props. - Document usage in
docs/components.md.
11. Sample applications
- Scaffold
examples/react-native/andexamples/web/showcasing scan → proof flows. - Include iOS
OpenPassportURL scheme setup inexamples/react-native/README.md. - Ensure both samples use the published SDK rather than local files.
12. In-SDK lightweight demo
- Add
demo/inside the package withApp.tsxusingSelfClientProviderand theming hooks. - Provide run instructions in
demo/README.mdforyarn demo iosandyarn demo android. - Wire demo entry in
package.jsonscripts.
Architecture tasks
4. SDK lifecycle management
- Refactor
src/client.tssocreateSelfClientbecomesclass SelfClientwithinitialize()anddeinitialize()methods. - Persist configuration on the instance rather than module globals.
- Update exports in
src/index.ts.
5. Package targets
- Add a
"./web"entry topackage.json#exportspointing todist/web/index.jswhile keeping React Native as the default. - Update
tsup.config.tsto produce a web build target. - Note possible future targets (Capacitor, Cordova) in comments.
6. Dogfood in /app
- Update
app/src/utils/proving/provingMachine.tsand screens inapp/src/screens/prove/to consume SDK methods. - Remove deprecated MRZ utilities from the app and import from
@selfxyz/mobile-sdk-alpha. - Confirm flows via
yarn workspace @selfxyz/mobile-app test.
7. Android demo app
- Create
examples/android-demo/with React Native CLI, wiring scanning and proof generation through the SDK. - Provide setup instructions in
examples/android-demo/README.md. - Link the demo in the main
README.md.
Consolidation toward @selfxyz/common
- Move
calculateContentHashand related catalog helpers fromapp/src/providers/passportDataProvider.tsxtocommon/src/utils/documents/and re-export via@selfxyz/common. - Pull keychain wrappers like
storeDocumentintocommon/src/utils/storage/passport.ts. - Publish shared analytics/auth adapters (currently in
app/src/utils/analytics.tsandapp/src/providers/authProvider.tsx) through a new package and re-export types from@selfxyz/common.