Skip to content

Commit a3db13f

Browse files
author
Dikn
committed
version bump
1 parent 73ae860 commit a3db13f

20 files changed

+330
-112
lines changed

dist/amd/authService.js

+30-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
define(['exports', 'aurelia-framework', 'aurelia-http-client', './authentication', './baseConfig', './oAuth1', './oAuth2', './authUtils'], function (exports, _aureliaFramework, _aureliaHttpClient, _authentication, _baseConfig, _oAuth1, _oAuth2, _authUtils) {
1+
define(['exports', 'aurelia-framework', 'aurelia-fetch-client', './authentication', './baseConfig', './oAuth1', './oAuth2', './authUtils'], function (exports, _aureliaFramework, _aureliaFetchClient, _authentication, _baseConfig, _oAuth1, _oAuth2, _authUtils) {
22
'use strict';
33

44
Object.defineProperty(exports, '__esModule', {
@@ -28,8 +28,8 @@ define(['exports', 'aurelia-framework', 'aurelia-http-client', './authentication
2828
key: 'getMe',
2929
value: function getMe() {
3030
var profileUrl = this.auth.getProfileUrl();
31-
return this.http.createRequest(profileUrl).asGet().send().then(function (response) {
32-
return response.content;
31+
return this.http.fetch(profileUrl).then(status).then(toJson).then(function (response) {
32+
return response;
3333
});
3434
}
3535
}, {
@@ -58,7 +58,11 @@ define(['exports', 'aurelia-framework', 'aurelia-http-client', './authentication
5858
'password': password
5959
};
6060
}
61-
return this.http.createRequest(signupUrl).asPost().withContent(content).send().then(function (response) {
61+
62+
return this.http.fetch(signupUrl, {
63+
method: 'post',
64+
body: (0, _aureliaFetchClient.json)(content)
65+
}).then(status).then(toJson).then(function (response) {
6266
if (_this.config.loginOnSignup) {
6367
_this.auth.setToken(response);
6468
} else if (_this.config.signupRedirect) {
@@ -83,7 +87,10 @@ define(['exports', 'aurelia-framework', 'aurelia-http-client', './authentication
8387
};
8488
}
8589

86-
return this.http.createRequest(loginUrl).asPost().withContent(content).send().then(function (response) {
90+
return this.http.fetch(loginUrl, {
91+
method: 'post',
92+
body: (0, _aureliaFetchClient.json)(content)
93+
}).then(status).then(toJson).then(function (response) {
8794
_this2.auth.setToken(response);
8895
return response;
8996
});
@@ -114,21 +121,36 @@ define(['exports', 'aurelia-framework', 'aurelia-http-client', './authentication
114121
var unlinkUrl = this.config.baseUrl ? _authUtils2['default'].joinUrl(this.config.baseUrl, this.config.unlinkUrl) : this.config.unlinkUrl;
115122

116123
if (this.config.unlinkMethod === 'get') {
117-
return this.http.createRequest(unlinkUrl + provider).asGet().send().then(function (response) {
124+
return this.http.fetch(unlinkUrl + provider).then(status).then(toJson).then(function (response) {
118125
return response;
119126
});
120127
} else if (this.config.unlinkMethod === 'post') {
121-
return this.http.createRequest(unlinkUrl).asPost().withContent(provider).send().then(function (response) {
128+
return this.http.fetch(unlinkUrl, {
129+
method: 'post',
130+
body: (0, _aureliaFetchClient.json)(provider)
131+
}).then(status).then(toJson).then(function (response) {
122132
return response;
123133
});
124134
}
125135
}
126136
}]);
127137

128138
var _AuthService = AuthService;
129-
AuthService = (0, _aureliaFramework.inject)(_aureliaHttpClient.HttpClient, _authentication.Authentication, _oAuth1.OAuth1, _oAuth2.OAuth2, _baseConfig.BaseConfig)(AuthService) || AuthService;
139+
AuthService = (0, _aureliaFramework.inject)(_aureliaFetchClient.HttpClient, _authentication.Authentication, _oAuth1.OAuth1, _oAuth2.OAuth2, _baseConfig.BaseConfig)(AuthService) || AuthService;
130140
return AuthService;
131141
})();
132142

133143
exports.AuthService = AuthService;
144+
145+
function status(response) {
146+
if (response.status >= 200 && response.status < 300) {
147+
return Promise.resolve(response);
148+
} else {
149+
return Promise.reject(new Error(response.statusText));
150+
}
151+
}
152+
153+
function toJson(response) {
154+
return response.json();
155+
}
134156
});

dist/amd/authentication.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ define(['exports', 'aurelia-framework', './baseConfig', './storage', './authUtil
8080
}
8181

8282
if (!token && response) {
83-
token = this.config.tokenRoot && response.content[this.config.tokenRoot] ? response.content[this.config.tokenRoot][this.config.tokenName] : response.content[this.config.tokenName];
83+
token = this.config.tokenRoot && response[this.config.tokenRoot] ? response[this.config.tokenRoot][this.config.tokenName] : response[this.config.tokenName];
8484
}
8585

8686
if (!token) {
8787
var tokenPath = this.config.tokenRoot ? this.config.tokenRoot + '.' + this.config.tokenName : this.config.tokenName;
8888

89-
throw new Error('Expecting a token named "' + tokenPath + '" but instead got: ' + JSON.stringify(response.content));
89+
throw new Error('Expecting a token named "' + tokenPath + '" but instead got: ' + JSON.stringify(response));
9090
}
9191

9292
this.storage.set(tokenName, token);

dist/amd/oAuth1.js

+22-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
define(['exports', 'aurelia-framework', './authUtils', './storage', './popup', './baseConfig', 'aurelia-http-client'], function (exports, _aureliaFramework, _authUtils, _storage, _popup, _baseConfig, _aureliaHttpClient) {
1+
define(['exports', 'aurelia-framework', './authUtils', './storage', './popup', './baseConfig', 'aurelia-fetch-client'], function (exports, _aureliaFramework, _authUtils, _storage, _popup, _baseConfig, _aureliaFetchClient) {
22
'use strict';
33

44
Object.defineProperty(exports, '__esModule', {
@@ -41,7 +41,9 @@ define(['exports', 'aurelia-framework', './authUtils', './storage', './popup', '
4141
this.popup = this.popup.open('', this.defaults.name, this.defaults.popupOptions, this.defaults.redirectUri);
4242
}
4343
var self = this;
44-
return this.http.createRequest(serverUrl).asPost().send().then(function (response) {
44+
return this.http.fetch(serverUrl, {
45+
method: 'post'
46+
}).then(status).then(toJson).then(function (response) {
4547
if (self.config.platform === 'mobile') {
4648
self.popup = self.popup.open([self.defaults.authorizationEndpoint, self.buildQueryString(response.content)].join('?'), self.defaults.name, self.defaults.popupOptions, self.defaults.redirectUri);
4749
} else {
@@ -60,7 +62,11 @@ define(['exports', 'aurelia-framework', './authUtils', './storage', './popup', '
6062
value: function exchangeForToken(oauthData, userData) {
6163
var data = _authUtils2['default'].extend({}, userData, oauthData);
6264
var exchangeForTokenUrl = this.config.baseUrl ? _authUtils2['default'].joinUrl(this.config.baseUrl, this.defaults.url) : this.defaults.url;
63-
return this.http.createRequest(exchangeForTokenUrl).asPost().withCredentials(this.config.withCredentials).withContent(data).send().then(function (response) {
65+
return this.http.fetch(exchangeForTokenUrl, {
66+
method: 'post',
67+
body: (0, _aureliaFetchClient.json)(data),
68+
credentials: this.config.withCredentials
69+
}).then(status).then(toJson).then(function (response) {
6470
return response;
6571
});
6672
}
@@ -78,9 +84,21 @@ define(['exports', 'aurelia-framework', './authUtils', './storage', './popup', '
7884
}]);
7985

8086
var _OAuth1 = OAuth1;
81-
OAuth1 = (0, _aureliaFramework.inject)(_storage.Storage, _popup.Popup, _aureliaHttpClient.HttpClient, _baseConfig.BaseConfig)(OAuth1) || OAuth1;
87+
OAuth1 = (0, _aureliaFramework.inject)(_storage.Storage, _popup.Popup, _aureliaFetchClient.HttpClient, _baseConfig.BaseConfig)(OAuth1) || OAuth1;
8288
return OAuth1;
8389
})();
8490

8591
exports.OAuth1 = OAuth1;
92+
93+
function status(response) {
94+
if (response.status >= 200 && response.status < 300) {
95+
return Promise.resolve(response);
96+
} else {
97+
return Promise.reject(new Error(response.statusText));
98+
}
99+
}
100+
101+
function toJson(response) {
102+
return response.json();
103+
}
86104
});

dist/amd/oAuth2.js

+19-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
define(['exports', 'aurelia-framework', './authUtils', './storage', './popup', './baseConfig', 'aurelia-http-client'], function (exports, _aureliaFramework, _authUtils, _storage, _popup, _baseConfig, _aureliaHttpClient) {
1+
define(['exports', 'aurelia-framework', './authUtils', './storage', './popup', './baseConfig', 'aurelia-fetch-client'], function (exports, _aureliaFramework, _authUtils, _storage, _popup, _baseConfig, _aureliaFetchClient) {
22
'use strict';
33

44
Object.defineProperty(exports, '__esModule', {
@@ -89,7 +89,11 @@ define(['exports', 'aurelia-framework', './authUtils', './storage', './popup', '
8989

9090
var exchangeForTokenUrl = this.config.baseUrl ? _authUtils2['default'].joinUrl(this.config.baseUrl, this.defaults.url) : this.defaults.url;
9191

92-
return this.http.createRequest(exchangeForTokenUrl).asPost().withContent(data).withCredentials(this.config.withCredentials).send().then(function (response) {
92+
return this.http.fetch(exchangeForTokenUrl, {
93+
method: 'post',
94+
body: (0, _aureliaFetchClient.json)(data),
95+
credentials: this.config.withCredentials
96+
}).then(status).then(toJson).then(function (response) {
9397
return response;
9498
});
9599
}
@@ -130,9 +134,21 @@ define(['exports', 'aurelia-framework', './authUtils', './storage', './popup', '
130134
}]);
131135

132136
var _OAuth2 = OAuth2;
133-
OAuth2 = (0, _aureliaFramework.inject)(_storage.Storage, _popup.Popup, _aureliaHttpClient.HttpClient, _baseConfig.BaseConfig)(OAuth2) || OAuth2;
137+
OAuth2 = (0, _aureliaFramework.inject)(_storage.Storage, _popup.Popup, _aureliaFetchClient.HttpClient, _baseConfig.BaseConfig)(OAuth2) || OAuth2;
134138
return OAuth2;
135139
})();
136140

137141
exports.OAuth2 = OAuth2;
142+
143+
function status(response) {
144+
if (response.status >= 200 && response.status < 300) {
145+
return Promise.resolve(response);
146+
} else {
147+
return Promise.reject(new Error(response.statusText));
148+
}
149+
}
150+
151+
function toJson(response) {
152+
return response.json();
153+
}
138154
});

dist/commonjs/authService.js

+31-9
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
1212

1313
var _aureliaFramework = require('aurelia-framework');
1414

15-
var _aureliaHttpClient = require('aurelia-http-client');
15+
var _aureliaFetchClient = require('aurelia-fetch-client');
1616

1717
var _authentication = require('./authentication');
1818

@@ -41,8 +41,8 @@ var AuthService = (function () {
4141
key: 'getMe',
4242
value: function getMe() {
4343
var profileUrl = this.auth.getProfileUrl();
44-
return this.http.createRequest(profileUrl).asGet().send().then(function (response) {
45-
return response.content;
44+
return this.http.fetch(profileUrl).then(status).then(toJson).then(function (response) {
45+
return response;
4646
});
4747
}
4848
}, {
@@ -71,7 +71,11 @@ var AuthService = (function () {
7171
'password': password
7272
};
7373
}
74-
return this.http.createRequest(signupUrl).asPost().withContent(content).send().then(function (response) {
74+
75+
return this.http.fetch(signupUrl, {
76+
method: 'post',
77+
body: (0, _aureliaFetchClient.json)(content)
78+
}).then(status).then(toJson).then(function (response) {
7579
if (_this.config.loginOnSignup) {
7680
_this.auth.setToken(response);
7781
} else if (_this.config.signupRedirect) {
@@ -96,7 +100,10 @@ var AuthService = (function () {
96100
};
97101
}
98102

99-
return this.http.createRequest(loginUrl).asPost().withContent(content).send().then(function (response) {
103+
return this.http.fetch(loginUrl, {
104+
method: 'post',
105+
body: (0, _aureliaFetchClient.json)(content)
106+
}).then(status).then(toJson).then(function (response) {
100107
_this2.auth.setToken(response);
101108
return response;
102109
});
@@ -127,20 +134,35 @@ var AuthService = (function () {
127134
var unlinkUrl = this.config.baseUrl ? _authUtils2['default'].joinUrl(this.config.baseUrl, this.config.unlinkUrl) : this.config.unlinkUrl;
128135

129136
if (this.config.unlinkMethod === 'get') {
130-
return this.http.createRequest(unlinkUrl + provider).asGet().send().then(function (response) {
137+
return this.http.fetch(unlinkUrl + provider).then(status).then(toJson).then(function (response) {
131138
return response;
132139
});
133140
} else if (this.config.unlinkMethod === 'post') {
134-
return this.http.createRequest(unlinkUrl).asPost().withContent(provider).send().then(function (response) {
141+
return this.http.fetch(unlinkUrl, {
142+
method: 'post',
143+
body: (0, _aureliaFetchClient.json)(provider)
144+
}).then(status).then(toJson).then(function (response) {
135145
return response;
136146
});
137147
}
138148
}
139149
}]);
140150

141151
var _AuthService = AuthService;
142-
AuthService = (0, _aureliaFramework.inject)(_aureliaHttpClient.HttpClient, _authentication.Authentication, _oAuth1.OAuth1, _oAuth2.OAuth2, _baseConfig.BaseConfig)(AuthService) || AuthService;
152+
AuthService = (0, _aureliaFramework.inject)(_aureliaFetchClient.HttpClient, _authentication.Authentication, _oAuth1.OAuth1, _oAuth2.OAuth2, _baseConfig.BaseConfig)(AuthService) || AuthService;
143153
return AuthService;
144154
})();
145155

146-
exports.AuthService = AuthService;
156+
exports.AuthService = AuthService;
157+
158+
function status(response) {
159+
if (response.status >= 200 && response.status < 300) {
160+
return Promise.resolve(response);
161+
} else {
162+
return Promise.reject(new Error(response.statusText));
163+
}
164+
}
165+
166+
function toJson(response) {
167+
return response.json();
168+
}

dist/commonjs/authentication.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ var Authentication = (function () {
8787
}
8888

8989
if (!token && response) {
90-
token = this.config.tokenRoot && response.content[this.config.tokenRoot] ? response.content[this.config.tokenRoot][this.config.tokenName] : response.content[this.config.tokenName];
90+
token = this.config.tokenRoot && response[this.config.tokenRoot] ? response[this.config.tokenRoot][this.config.tokenName] : response[this.config.tokenName];
9191
}
9292

9393
if (!token) {
9494
var tokenPath = this.config.tokenRoot ? this.config.tokenRoot + '.' + this.config.tokenName : this.config.tokenName;
9595

96-
throw new Error('Expecting a token named "' + tokenPath + '" but instead got: ' + JSON.stringify(response.content));
96+
throw new Error('Expecting a token named "' + tokenPath + '" but instead got: ' + JSON.stringify(response));
9797
}
9898

9999
this.storage.set(tokenName, token);

dist/commonjs/oAuth1.js

+23-5
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var _popup = require('./popup');
2222

2323
var _baseConfig = require('./baseConfig');
2424

25-
var _aureliaHttpClient = require('aurelia-http-client');
25+
var _aureliaFetchClient = require('aurelia-fetch-client');
2626

2727
var OAuth1 = (function () {
2828
function OAuth1(storage, popup, http, config) {
@@ -52,7 +52,9 @@ var OAuth1 = (function () {
5252
this.popup = this.popup.open('', this.defaults.name, this.defaults.popupOptions, this.defaults.redirectUri);
5353
}
5454
var self = this;
55-
return this.http.createRequest(serverUrl).asPost().send().then(function (response) {
55+
return this.http.fetch(serverUrl, {
56+
method: 'post'
57+
}).then(status).then(toJson).then(function (response) {
5658
if (self.config.platform === 'mobile') {
5759
self.popup = self.popup.open([self.defaults.authorizationEndpoint, self.buildQueryString(response.content)].join('?'), self.defaults.name, self.defaults.popupOptions, self.defaults.redirectUri);
5860
} else {
@@ -71,7 +73,11 @@ var OAuth1 = (function () {
7173
value: function exchangeForToken(oauthData, userData) {
7274
var data = _authUtils2['default'].extend({}, userData, oauthData);
7375
var exchangeForTokenUrl = this.config.baseUrl ? _authUtils2['default'].joinUrl(this.config.baseUrl, this.defaults.url) : this.defaults.url;
74-
return this.http.createRequest(exchangeForTokenUrl).asPost().withCredentials(this.config.withCredentials).withContent(data).send().then(function (response) {
76+
return this.http.fetch(exchangeForTokenUrl, {
77+
method: 'post',
78+
body: (0, _aureliaFetchClient.json)(data),
79+
credentials: this.config.withCredentials
80+
}).then(status).then(toJson).then(function (response) {
7581
return response;
7682
});
7783
}
@@ -89,8 +95,20 @@ var OAuth1 = (function () {
8995
}]);
9096

9197
var _OAuth1 = OAuth1;
92-
OAuth1 = (0, _aureliaFramework.inject)(_storage.Storage, _popup.Popup, _aureliaHttpClient.HttpClient, _baseConfig.BaseConfig)(OAuth1) || OAuth1;
98+
OAuth1 = (0, _aureliaFramework.inject)(_storage.Storage, _popup.Popup, _aureliaFetchClient.HttpClient, _baseConfig.BaseConfig)(OAuth1) || OAuth1;
9399
return OAuth1;
94100
})();
95101

96-
exports.OAuth1 = OAuth1;
102+
exports.OAuth1 = OAuth1;
103+
104+
function status(response) {
105+
if (response.status >= 200 && response.status < 300) {
106+
return Promise.resolve(response);
107+
} else {
108+
return Promise.reject(new Error(response.statusText));
109+
}
110+
}
111+
112+
function toJson(response) {
113+
return response.json();
114+
}

0 commit comments

Comments
 (0)