Skip to content
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

reel: fixing meta and url scries, token rotation, and extra metadata #279

Merged
merged 4 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 33 additions & 14 deletions desk/app/reel.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,27 @@
%reel-describe
?> =(our.bowl src.bowl)
=+ !<([id=cord =metadata:reel] vase)
?~ (~(has by stable-id) id) `this
:: the token here is a temporary identifier for the metadata
=/ old-token (~(get by stable-id) id)
=. fields.metadata
%- ~(gas by fields.metadata)
:~ ['bite-type' '2']
['inviter' (scot %p src.bowl)]
['group' id]
==
:: the nonce here is a temporary identifier for the metadata
:: a new one will be assigned by the bait provider and returned to us
=/ new-fields (~(put by fields.metadata) 'bite-type' '2')
=/ new-metadata metadata(fields new-fields)
=/ =nonce:reel (scot %da now.bowl)
=. our-metadata (~(put by our-metadata) nonce new-metadata)
:: delete old metadata if we have an existing token for this id
=? our-metadata ?=(^ old-token)
(~(del by our-metadata) u.old-token)
=. our-metadata (~(put by our-metadata) nonce metadata)
=. open-describes (~(put in open-describes) nonce)
=. stable-id (~(put by stable-id) id nonce)
:_ this
~[[%pass /describe %agent [civ %bait] %poke %bait-describe !>([nonce new-metadata])]]
%+ welp
?~ old-token ~
~[[%pass /undescribe %agent [civ %bait] %poke %bait-undescribe !>(u.old-token)]]
~[[%pass /describe %agent [civ %bait] %poke %bait-describe !>([nonce metadata])]]
::
%reel-confirmation
?> =(civ src.bowl)
Expand Down Expand Up @@ -229,21 +239,30 @@
=/ has (~(has in open-link-requests) [(slav %p ship.pole) name.pole])
``json+!>([%b has])
::
[%x any %metadata token=@ ~]
=/ =metadata:reel (fall (~(get by our-metadata) token.pole) *metadata:reel)
[%x %v1 %metadata ship=@ name=@ ~]
=/ id (rap 3 ship.pole '/' name.pole ~)
=/ token (~(get by stable-id) id)
?~ token [~ ~]
=/ =metadata:reel (fall (~(get by our-metadata) u.token) *metadata:reel)
``reel-metadata+!>(metadata)
::
[%x %v0 %metadata name=@ ~]
:: old style tokens are directly in metadata
=/ id (rap 3 (scot %p our.bowl) '/' name.pole ~)
=/ =metadata:reel (fall (~(get by our-metadata) id) *metadata:reel)
``reel-metadata+!>(metadata)
::
[%x any %token-url token=*]
=/ =token:reel (crip (join '/' token.pole))
=/ =token:reel (crip +:(spud token.pole))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this meaningfully different from the +join implementation?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was giving me errors I think? don't quite remember

=/ url (url-for-token vic token)
``reel-token-url+!>(url)
``json+!>(s+url)
::
[%x %v1 %id-url id=*]
=/ id (crip (join '/' id.pole))
=/ id (crip +:(spud id.pole))
?~ token=(~(get by stable-id) id)
``reel-token-url+!>('')
=/ url (cat 3 vic id)
``reel-token-url+!>(url)
``json+!>(s+'')
=/ url (cat 3 vic u.token)
``json+!>(s+url)
==
::
++ on-arvo
Expand Down
2 changes: 1 addition & 1 deletion desk/ted/reel/set-ship.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
=/ url
?: =(vic 'https://tlon.network/lure/')
"https://tlon.network/v1/lure/bait/who"
"{(trip vic)}/bait/who"
"{(trip vic)}bait/who"
;< =json bind:m (fetch-json url)
=/ =ship (slav %p (so:dejs:format json))
;< ~ bind:m (poke [our %reel] reel-command+!>([%set-ship ship]))
Expand Down
2 changes: 1 addition & 1 deletion desk/tests/app/reel.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
=/ m (mare ,~)
;< * bind:m (do-init dap reel-agent)
;< * bind:m (jab-bowl |=(b=bowl b(our ~dev, src ~dev, now *@da)))
=/ =metadata:r [%test (my ['inviter' '~dev'] ~)]
=/ =metadata:r [%test (my ['inviter' '~dev'] ['group' '~bus/reel-test'] ~)]
=/ describe [token metadata]
;< caz=(list card) bind:m (do-poke %reel-describe !>(describe))
;< bw=bowl bind:m get-bowl
Expand Down
Loading