@@ -3019,6 +3019,110 @@ if (typeof chrome === 'object' && typeof chrome.identity === 'object' && chrome.
30193019
30203020} ) ( ) ; 
30213021
3022+ ( function ( hello )  { 
3023+ 
3024+ 	hello . init ( { 
3025+ 
3026+ 		bitbucket : { 
3027+ 
3028+ 			name : 'BitBucket' , 
3029+ 
3030+ 			oauth : { 
3031+ 				version : 2 , 
3032+ 				auth : 'https://bitbucket.org/site/oauth2/authorize' , 
3033+ 				grant : 'https://bitbucket.org/site/oauth2/access_token' , 
3034+ 				response_type : 'code' 
3035+ 			} , 
3036+ 
3037+ 			scope : { 
3038+ 				email : 'user:email' 
3039+ 			} , 
3040+ 
3041+ 			base : 'https://api.bitbucket.org/2.0/' , 
3042+ 
3043+ 			get : { 
3044+ 				me : 'user' , 
3045+ 				'me/friends' : 'user/following?per_page=@{limit|100}' , 
3046+ 				'me/following' : 'user/following?per_page=@{limit|100}' , 
3047+ 				'me/followers' : 'user/followers?per_page=@{limit|100}' , 
3048+ 				'me/like' : 'user/starred?per_page=@{limit|100}' 
3049+ 			} , 
3050+ 
3051+ 			wrap : { 
3052+ 				me : function ( o ,  headers )  { 
3053+ 
3054+ 					formatError ( o ,  headers ) ; 
3055+ 					formatUser ( o ) ; 
3056+ 
3057+ 					return  o ; 
3058+ 				} , 
3059+ 
3060+ 				'default' : function ( o ,  headers ,  req )  { 
3061+ 
3062+ 					formatError ( o ,  headers ) ; 
3063+ 
3064+ 					if  ( Array . isArray ( o ) )  { 
3065+ 						o  =  { data :o } ; 
3066+ 					} 
3067+ 
3068+ 					if  ( o . data )  { 
3069+ 						paging ( o ,  headers ,  req ) ; 
3070+ 						o . data . forEach ( formatUser ) ; 
3071+ 					} 
3072+ 
3073+ 					return  o ; 
3074+ 				} 
3075+ 			} , 
3076+ 
3077+ 			xhr : function ( p )  { 
3078+ 
3079+ 				if  ( p . method  !==  'get'  &&  p . data )  { 
3080+ 
3081+ 					// Serialize payload as JSON 
3082+ 					p . headers  =  p . headers  ||  { } ; 
3083+ 					p . headers [ 'Content-Type' ]  =  'application/json' ; 
3084+ 					if  ( typeof  ( p . data )  ===  'object' )  { 
3085+ 						p . data  =  JSON . stringify ( p . data ) ; 
3086+ 					} 
3087+ 				} 
3088+ 
3089+ 				return  true ; 
3090+ 			} 
3091+ 		} 
3092+ 	} ) ; 
3093+ 
3094+ 	function  formatError ( o ,  headers )  { 
3095+ 		var  code  =  headers  ? headers . statusCode  : ( o  &&  'meta'  in  o  &&  'status'  in  o . meta  &&  o . meta . status ) ; 
3096+ 		if  ( ( code  ===  401  ||  code  ===  403 ) )  { 
3097+ 			o . error  =  { 
3098+ 				code : 'access_denied' , 
3099+ 				message : o . message  ||  ( o . data  ? o . data . message  : 'Could not get response' ) 
3100+ 			} ; 
3101+ 			delete  o . message ; 
3102+ 		} 
3103+ 	} 
3104+ 
3105+ 	function  formatUser ( o )  { 
3106+ 		if  ( o . id )  { 
3107+ 			o . thumbnail  =  o . picture  =  o . avatar_url ; 
3108+ 			o . name  =  o . login ; 
3109+ 		} 
3110+ 	} 
3111+ 
3112+ 	function  paging ( res ,  headers ,  req )  { 
3113+ 		if  ( res . data  &&  res . data . length  &&  headers  &&  headers . Link )  { 
3114+ 			var  next  =  headers . Link . match ( / < ( .* ?) > ; \s * r e l = \" n e x t \" / ) ; 
3115+ 			if  ( next )  { 
3116+ 				res . paging  =  { 
3117+ 					next : next [ 1 ] 
3118+ 				} ; 
3119+ 			} 
3120+ 		} 
3121+ 	} 
3122+ 
3123+ } ) ( hello ) ; 
3124+ 
3125+ 
30223126( function ( hello )  { 
30233127
30243128	// OAuth1 
0 commit comments