Skip to content

Commit

Permalink
fix(pushnotification): revert change in pr 952
Browse files Browse the repository at this point in the history
  • Loading branch information
powerful23 committed Jun 4, 2018
2 parents 4381fc1 + f8fddbe commit 257fc40
Show file tree
Hide file tree
Showing 11 changed files with 130 additions and 23 deletions.
13 changes: 13 additions & 0 deletions packages/amazon-cognito-identity-js/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,21 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

**Note:** Version bump only for package amazon-cognito-identity-js

<<<<<<< HEAD
<a name="2.0.7"></a>
## [2.0.7](https://github.com/aws/aws-amplify/compare/amazon-cognito-identity-js@2.0.7-unstable.32...amazon-cognito-identity-js@2.0.7) (2018-06-01)
=======
<a name="2.0.7-unstable.34"></a>
## [2.0.7-unstable.34](https://github.com/aws/aws-amplify/compare/amazon-cognito-identity-js@2.0.7-unstable.33...amazon-cognito-identity-js@2.0.7-unstable.34) (2018-06-04)




**Note:** Version bump only for package amazon-cognito-identity-js

<a name="2.0.7-unstable.33"></a>
## [2.0.7-unstable.33](https://github.com/aws/aws-amplify/compare/amazon-cognito-identity-js@2.0.7-unstable.32...amazon-cognito-identity-js@2.0.7-unstable.33) (2018-06-02)
>>>>>>> origin


Expand Down
5 changes: 5 additions & 0 deletions packages/aws-amplify-react-native/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

**Note:** Version bump only for package aws-amplify-react-native

<<<<<<< HEAD
<a name="0.2.13"></a>
## [0.2.13](https://github.com/aws/aws-amplify/compare/aws-amplify-react-native@0.2.13-unstable.12...aws-amplify-react-native@0.2.13) (2018-06-01)
=======
<a name="0.2.13-unstable.13"></a>
## [0.2.13-unstable.13](https://github.com/aws/aws-amplify/compare/aws-amplify-react-native@0.2.13-unstable.12...aws-amplify-react-native@0.2.13-unstable.13) (2018-06-02)
>>>>>>> origin


Expand Down
4 changes: 2 additions & 2 deletions packages/aws-amplify-react-native/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ allprojects {
apply plugin: "com.android.library"

android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
minSdkVersion 16
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,13 +289,6 @@ public void sendToNotificationCentre(Bundle bundle) {
}
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
String channelId = bundle.getString("android_channel_id");
if (channelId != null) {
notification.setChannelId(channelId);
}
}

int notificationID = Integer.parseInt(notificationIdString);

PendingIntent pendingIntent = PendingIntent.getActivity(context, notificationID, intent,
Expand Down
4 changes: 4 additions & 0 deletions packages/aws-amplify-react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
"rimraf": "^2.6.2"
},
"dependencies": {
<<<<<<< HEAD
"aws-amplify": "^0.4.3",
=======
"aws-amplify": "^0.4.2-unstable.33",
>>>>>>> origin
"axios": "^0.17.1",
"babel-preset-es2015": "^6.24.1"
},
Expand Down
13 changes: 13 additions & 0 deletions packages/aws-amplify-react/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,21 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

**Note:** Version bump only for package aws-amplify-react

<<<<<<< HEAD
<a name="0.1.48"></a>
## [0.1.48](https://github.com/aws/aws-amplify/compare/aws-amplify-react@0.1.48-unstable.30...aws-amplify-react@0.1.48) (2018-06-01)
=======
<a name="0.1.48-unstable.32"></a>
## [0.1.48-unstable.32](https://github.com/aws/aws-amplify/compare/aws-amplify-react@0.1.48-unstable.31...aws-amplify-react@0.1.48-unstable.32) (2018-06-04)




**Note:** Version bump only for package aws-amplify-react

<a name="0.1.48-unstable.31"></a>
## [0.1.48-unstable.31](https://github.com/aws/aws-amplify/compare/aws-amplify-react@0.1.48-unstable.30...aws-amplify-react@0.1.48-unstable.31) (2018-06-02)
>>>>>>> origin


Expand Down
4 changes: 4 additions & 0 deletions packages/aws-amplify-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@
"graphql": "0.13.0"
},
"dependencies": {
<<<<<<< HEAD
"aws-amplify": "^0.4.3",
=======
"aws-amplify": "^0.4.2-unstable.33",
>>>>>>> origin
"qrcode.react": "^0.8.0",
"regenerator-runtime": "^0.11.1"
}
Expand Down
18 changes: 18 additions & 0 deletions packages/aws-amplify/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

### Bug Fixes

<<<<<<< HEAD
* **aws-amplify:** Fix missing ServiceWorker export ([46069e2](https://github.com/aws/aws-amplify/commit/46069e2))
* **aws-amplify:** Fix missing ServiceWorker export ([acbf754](https://github.com/aws/aws-amplify/commit/acbf754))

Expand All @@ -22,6 +23,23 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline


**Note:** Version bump only for package aws-amplify
=======
* **API:** query string for non signed requests ([#801](https://github.com/aws/aws-amplify/issues/801)) ([6746368](https://github.com/aws/aws-amplify/commit/6746368))




<a name="0.4.2-unstable.31"></a>
## [0.4.2-unstable.31](https://github.com/aws/aws-amplify/compare/aws-amplify@0.4.2-unstable.30...aws-amplify@0.4.2-unstable.31) (2018-06-02)


### Bug Fixes

* **aws-amplify:** Fix missing ServiceWorker export ([acbf754](https://github.com/aws/aws-amplify/commit/acbf754))



>>>>>>> origin
<a name="0.4.2-unstable.30"></a>
## [0.4.2-unstable.30](https://github.com/aws/aws-amplify/compare/aws-amplify@0.4.2-unstable.29...aws-amplify@0.4.2-unstable.30) (2018-06-01)
Expand Down
54 changes: 53 additions & 1 deletion packages/aws-amplify/__tests__/API/API-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ describe('API test', () => {
"method": "GET",
"path": "/",
"signerServiceInfo": undefined,
"url": "https://www.amazonaws.compath"
"url": "https://www.amazonaws.compath/"
} , undefined);

});
Expand Down Expand Up @@ -486,6 +486,58 @@ describe('API test', () => {
expect(spyonSigner).toBeCalledWith( expectedParams, creds2 , { region: 'us-east-1', service: 'execute-api'});
});

test('query-string on init-custom-auth', async () => {
const resp = {data: [{name: 'Bob'}]};

const options = {
aws_project_region: 'region',
aws_cloud_logic_custom
};

const api = new API(options);
const creds = {
secretAccessKey: 'secret',
accessKeyId: 'access',
sessionToken: 'token'
};

const creds2 = {
secret_key: 'secret',
access_key: 'access',
session_token: 'token'
};

const spyon = jest.spyOn(Auth, 'currentCredentials').mockImplementation(() => {
return new Promise((res, rej) => {
res(creds);
});
});

const spyon3 = jest.spyOn(RestClient.prototype, 'endpoint').mockImplementationOnce(() => {
return 'endpoint';
});
const spyonRequest = jest.spyOn(RestClient.prototype, '_request').mockImplementationOnce(() => {
return { headers: {}};
});

const spyAxios = jest.spyOn(axios, 'default').mockImplementationOnce(() => {
return new Promise((res, rej) => {
res(resp);
});
});

const init = {
queryStringParameters: {
'ke:y3': 'val:ue 3'
},
headers: {
Authorization: 'apikey'
}
}
await api.get('apiName', '/items', init);
const expectedParams = {"data": null, "headers": {"Authorization": "apikey"}, "host": undefined, "method": "GET", "path": "/", "signerServiceInfo": undefined, "url": "endpoint/items?ke%3Ay3=val%3Aue%203"};
expect(spyonRequest).toBeCalledWith( expectedParams, undefined );
});
test('query-string on init and url', async () => {
const resp = {data: [{name: 'Bob'}]};

Expand Down
4 changes: 4 additions & 0 deletions packages/aws-amplify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@
"@types/paho-mqtt": "^1.0.3",
"@types/zen-observable": "^0.5.3",
"amazon-cognito-auth-js": "^1.1.9",
<<<<<<< HEAD
"amazon-cognito-identity-js": "^2.0.8",
=======
"amazon-cognito-identity-js": "^2.0.7-unstable.35",
>>>>>>> origin
"aws-sdk": "2.198.0",
"axios": "^0.17.0",
"graphql": "0.13.0",
Expand Down
27 changes: 14 additions & 13 deletions packages/aws-amplify/src/API/RestClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import axios from 'axios';
import Platform from '../Common/Platform';

const logger = new Logger('RestClient'),
url = require('url');
urlLib = require('url');

/**
* HTTP Client for REST requests. Send and receive JSON data.
Expand Down Expand Up @@ -101,6 +101,16 @@ export class RestClient {

params.headers = { ...libraryHeaders, ...(custom_header),...extraParams.headers };

// Intentionally discarding search
const { search, ...parsedUrl } = urlLib.parse(url, true, true);
params.url = urlLib.format({
...parsedUrl,
query: {
...parsedUrl.query,
...(extraParams.queryStringParameters || {})
}
});

// Do not sign the request if client has added 'Authorization' header,
// which means custom authorizer.
if (typeof params.headers['Authorization'] !== 'undefined') {
Expand All @@ -112,10 +122,11 @@ export class RestClient {
// tslint:disable-next-line:align
}, {});
return this._request(params, isAllResponse);

}

return Auth.currentCredentials()
.then(credentials => this._signed({...params, ...extraParams}, credentials, isAllResponse));
.then(credentials => this._signed({ ...params, ...extraParams }, credentials, isAllResponse));
}

/**
Expand Down Expand Up @@ -219,17 +230,7 @@ export class RestClient {
private _signed(params, credentials, isAllResponse) {

const { signerServiceInfo: signerServiceInfoParams, ...otherParams } = params;

// Intentionally discarding search
const { search, ...parsedUrl } = url.parse(otherParams.url, true, true);
otherParams.url = url.format({
...parsedUrl,
query: {
...parsedUrl.query,
...(otherParams.queryStringParameters || {})
}
});


const endpoint_region: string = this._region || this._options.region;
const endpoint_service: string = this._service || this._options.service;

Expand Down

0 comments on commit 257fc40

Please sign in to comment.