From d90b71dde9a12a89e1aa55bb4e541bd430cb0f06 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Thu, 7 Apr 2016 17:44:43 -0700 Subject: [PATCH] better type-checking --- lib/oauth1.hoon | 3 ++- lib/oauth2.hoon | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/oauth1.hoon b/lib/oauth1.hoon index 1424f68e5d..0badb0e593 100644 --- a/lib/oauth1.hoon +++ b/lib/oauth1.hoon @@ -189,6 +189,7 @@ ++ standard |* {done/* save/$-(token *)} :: save/$-(token _done) |% + ++ save ^-($-(token _done) ^save) :: shadow(type canary) ++ core-move $^({sec-move _done} sec-move) :: stateful :: :: use token to sign authorization header. expects: @@ -230,7 +231,7 @@ :: If a valid access token has been returned, save it ++ bak-save-token |= a/httr ^- core-move - ?: (bad-response p.a) + ?: (bad-response p.a) [%give a] :: [%redo ~] :: handle 4xx? =+ access-token=(grab-token-response a) [[%redo ~] (save `token`[%access-token access-token])] diff --git a/lib/oauth2.hoon b/lib/oauth2.hoon index 23d91274c5..adc7932a66 100644 --- a/lib/oauth2.hoon +++ b/lib/oauth2.hoon @@ -58,6 +58,8 @@ :: ++ auth-url |= {scopes/(list @t) url/$@(@t purl)} ^- purl + ~& [%oauth-warning "Make sure this urbit ". + "is running on {(earn our-host `~ ~)}"] %+ add-query:interpolate url %- quay:hep-to-cab :~ state+?.(state-usr '' (pack usr /'')) @@ -68,8 +70,6 @@ :: ++ our-host .^(hart %e /(scot %p our)/host/fake) ++ redirect-uri - ~& [%oauth-warning "Make sure this urbit ". - "is running on {(earn our-host `~ ~)}"] %- crip %- earn %^ interpolate 'https://our-host/~/ac/:domain/:user/in' `our-host @@ -132,8 +132,9 @@ -- :: ++ standard - |* {done/* save/$-(token *)} :: save/$-(token _done) + |* {done/* save/$-(token *)} |% + ++ save ^-($-(token _done) ^save) :: shadow(type canary) ++ core-move $^({sec-move _done} sec-move) :: stateful :: ++ out-add-query-param @@ -165,9 +166,10 @@ -- :: ++ standard-refreshing - |* {done/* ref/refresh save/$-({token refresh} *)} :: $-(both-tokens _done) + |* {done/* ref/refresh save/$-({token refresh} *)} =+ s=(standard done |=(tok/token (save tok ref))) |% + ++ save ^-($-(both-tokens _done) ^save) :: shadow(type canary) ++ core-move $^({sec-move _done} sec-move) :: stateful :: :: See ++out-add-query-param:standard