code: func NewSession(resp *apitypes.Self) (*Session, error) {
  	switch resp.Type {
  	case apitypes.UserSession:
  		if _, ok := resp.Identity.(envelope.UserInf); !ok {
  			return nil, errors.New("Identity must be a user object")
  		}
  		if _, ok := resp.Auth.(envelope.UserInf); !ok {
  			return nil, errors.New("Auth must be a user object")
  		}
  	case apitypes.MachineSession:
  		if _, ok := resp.Identity.(*envelope.Machine); !ok {
  			return nil, errors.New("Identity must be a machine object")
  		}
  		if _, ok := resp.Auth.(*envelope.MachineToken); !ok {
  			return nil, errors.New("Auth must be a machine token object")
  		}
  
  	default:
  		return nil, errors.New("did not recognize session type")
  	}
  
  	return &Session{
  		sessionType: resp.Type,
  		identity:    resp.Identity,
  		auth:        resp.Auth,
  	}, nil
  }
docs: // NewSession returns a new session constructed from the payload of the current
  // identity as returned from the Daemon