-
-
Notifications
You must be signed in to change notification settings - Fork 300
feat: KYC controller #9615
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
Merged
Merged
feat: KYC controller #9615
Changes from all commits
Commits
Show all changes
60 commits
Select commit
Hold shift + click to select a range
1166c0c
feat: init KYC controller and add logic from mobile repo
Akaryatrh 18c67ef
feat: update readme with architecture doc
Akaryatrh 400b874
feat: add product support + automatic calls to kyc required and sumsu…
Akaryatrh 9b3de4c
fix: geoCountry not updated issue
Akaryatrh 133fa9b
fix: previously selected product is not reset
Akaryatrh 89ac0b4
fix: issue with sumsub complete status
Akaryatrh 3392d00
feat: update lock file
Akaryatrh 3de6713
fix: issue with old accessToken and state update while controller has…
Akaryatrh 49ec4f1
fix: another race condition
Akaryatrh 20cff98
fix: add links in changelog
Akaryatrh abc47a6
fix: lint issue
Akaryatrh 461473d
fix: dedupe dependencies
Akaryatrh 41275fc
fix: cursor comments + state management
Akaryatrh cb246ed
fix: session state issue
Akaryatrh 194d216
fix: lockfile after rebase
Akaryatrh 85a764f
fix: review again state management
Akaryatrh ed8497c
feat: update architecture section of readme
Akaryatrh 3d2cf99
feat: update codeowner files
Akaryatrh 2c4805d
fix: lint issues
Akaryatrh 1983026
replace idosSessionId with sessionId
jiexi a1fcb5b
Initial key derivation, wrapping, and submission
jiexi b9bc735
add ukycCapabilityToken submission
jiexi 02afb3a
WIP
jiexi cf28727
Merge branch 'main' into feat/kyc-controller
jiexi 966ca62
Fix key wrapping. Fix idosSessionId param
jiexi 9c0dee1
Merge branch 'jl/kyc-controller-fix-nonce' into feat/kyc-controller
jiexi 8eee01d
rename fetchApplicantAccessToken to createJourney
jiexi 40bb435
polling status
jiexi 9b99126
Merge remote-tracking branch 'origin/main' into feat/kyc-controller
Akaryatrh 54b16fd
feat: update lockfile after merge with main
Akaryatrh f69ee7e
fix: lint issues
Akaryatrh 3c32929
fix: codeowner issue
Akaryatrh e35605e
fix: deps constraints
Akaryatrh dda438f
fix: eslint file-extension-in-import
Akaryatrh 166c8b1
fix: import lint issue
Akaryatrh f4b81bc
fix: deps version
Akaryatrh 7cfb7a3
fix: messenger action type check
Akaryatrh 1d983a3
feat: expose as a temporary solution kycstatus and finalstatus on rel…
Akaryatrh e31c5ed
Merge remote-tracking branch 'origin/main' into feat/kyc-controller
Akaryatrh 2664c92
fix: remove barrel files and useless exports
Akaryatrh 26b1ded
feat: refactor kyc service to base service pattern
Akaryatrh 7e5464c
feat: add comments about vendorProcessing
Akaryatrh f17b9ea
fix: remove type cast
Akaryatrh 11969e2
feat: move architecture info to a dedicated .md file
Akaryatrh 52875be
feat: remove trailing logs
Akaryatrh ade32c8
feat: baseUrl is now mandatory for KYC service initialization
Akaryatrh 2be2775
feat: remove base64ToBytes from crypto ts and move encoding file one …
Akaryatrh 6b7da84
fix: yarn constraints
Akaryatrh 801e098
fix: bump dependency for constraint
Akaryatrh ece1fef
fix: missing entry in readme
Akaryatrh 81246f6
Adjusting the storage token to the spec
BjornGunnarsson e57e5c3
Creating a test token script
BjornGunnarsson 7a443d1
use global fetch
jiexi 2c8b829
make fractalEncryptionBaseUrl required
jiexi 853970c
remove !baseUrl runtime check
jiexi 2bb59a3
remove bearerToken assert
jiexi 3a1a13e
lint
jiexi f112a53
fix: apply oxfmt formatting to kyc-controller
jiexi f4afa86
changelog
jiexi 5a29cbb
Merge branch 'main' into feat/kyc-controller
jiexi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
packages/kyc-controller/scripts/mint-ukyc-test-token.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| /** | ||
| * CLI to mint a UKYC `storage_access_token` for testing UKYC Storage. | ||
| * | ||
| * All real logic lives in the tested `mintUkycTestToken`; this is a thin | ||
| * argument-parsing wrapper that prints the result as JSON. | ||
| * | ||
| * Usage (from the package root, via the `mint:ukyc-token` script): | ||
| * yarn workspace @metamask/kyc-controller run mint:ukyc-token -- \ | ||
| * --operations read,write --expires-in 4h [--secret <hex>] \ | ||
| * [--presenter client|idos-relay] [--session-id <id>] | ||
| * | ||
| * Reuse the printed `localUserSecret` (pass it back via --secret) to keep the | ||
| * same `storageId` and controlling key across runs. | ||
| */ | ||
| import process from 'node:process'; | ||
|
|
||
| import type { | ||
| UkycStorageOperation, | ||
| UkycTokenPresenter, | ||
| } from '../src/ukyc/storageAccessToken.js'; | ||
| import { mintUkycTestToken } from '../src/ukyc/testToken.js'; | ||
| import type { MintUkycTestTokenParams } from '../src/ukyc/testToken.js'; | ||
|
|
||
| /** | ||
| * Parses `--flag value` and `--flag=value` pairs into a map. Flags without a | ||
| * following value are treated as booleans (`"true"`). | ||
| * | ||
| * @param argv - Raw CLI arguments (typically `process.argv.slice(2)`). | ||
| * @returns The parsed flags keyed by name (without the leading `--`). | ||
| */ | ||
| function parseFlags(argv: string[]): Record<string, string> { | ||
| const flags: Record<string, string> = {}; | ||
| let i = 0; | ||
| while (i < argv.length) { | ||
| const arg = argv[i]; | ||
| if (!arg.startsWith('--')) { | ||
| i += 1; | ||
| continue; | ||
| } | ||
| const body = arg.slice(2); | ||
| const eq = body.indexOf('='); | ||
| if (eq !== -1) { | ||
| flags[body.slice(0, eq)] = body.slice(eq + 1); | ||
| i += 1; | ||
| continue; | ||
| } | ||
| const next = argv[i + 1]; | ||
| if (next !== undefined && !next.startsWith('--')) { | ||
| flags[body] = next; | ||
| i += 2; | ||
| } else { | ||
| flags[body] = 'true'; | ||
| i += 1; | ||
| } | ||
| } | ||
| return flags; | ||
| } | ||
|
|
||
| /** | ||
| * Parses a duration like `4h`, `30m`, `90s`, or a bare number of seconds. | ||
| * | ||
| * @param value - The duration string. | ||
| * @returns The duration in milliseconds. | ||
| */ | ||
| function parseDurationMs(value: string): number { | ||
| const match = /^(\d+)(s|m|h|d)?$/u.exec(value); | ||
| if (!match) { | ||
| throw new Error(`invalid --expires-in duration: ${value}`); | ||
| } | ||
| const amount = Number(match[1]); | ||
| const unitMs = { s: 1000, m: 60_000, h: 3_600_000, d: 86_400_000 }; | ||
| return amount * unitMs[(match[2] ?? 's') as keyof typeof unitMs]; | ||
| } | ||
|
|
||
| const flags = parseFlags(process.argv.slice(2)); | ||
|
|
||
| const params: MintUkycTestTokenParams = {}; | ||
|
|
||
| if (flags.secret) { | ||
| params.localUserSecret = flags.secret; | ||
| } | ||
| if (flags.operations) { | ||
| params.operations = flags.operations | ||
| .split(',') | ||
| .map((op) => op.trim()) as UkycStorageOperation[]; | ||
| } | ||
| if (flags.presenter) { | ||
| params.presenter = flags.presenter as UkycTokenPresenter; | ||
| } | ||
| if (flags['session-id']) { | ||
| params.sessionId = flags['session-id']; | ||
| } | ||
| if (flags['issued-at']) { | ||
| params.issuedAt = new Date(flags['issued-at']); | ||
| } | ||
| if (flags['expires-at']) { | ||
| params.expiresAt = new Date(flags['expires-at']); | ||
| } else if (flags['expires-in']) { | ||
| const issuedAt = params.issuedAt ?? new Date(); | ||
| params.issuedAt = issuedAt; | ||
| params.expiresAt = new Date( | ||
| issuedAt.getTime() + parseDurationMs(flags['expires-in']), | ||
| ); | ||
| } | ||
|
|
||
| const result = mintUkycTestToken(params); | ||
|
|
||
| console.log(JSON.stringify(result, null, 2)); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
FYI, it's best to keep this README short and sweet for people to read. Minimally the README should explain the purpose of this controller and offer guidance on how it's intended to be used. If you need something for agents, maybe try adding it to AGENTS.md? If you need to explain the architecture maybe try ARCHITECTURE.md?
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.
Done, I created a dedicated architecture doc, thx for proposal 👍