Skip to content

Commit

Permalink
Include channel in requestPasswordReset mutation, refactor auth refre…
Browse files Browse the repository at this point in the history
…sh flow (#135)

* Include channel in requestPasswordReset mutation

* Update tests

* Add confirmAccount mutation

* Hide tokens

* Move all auth token logic to fetch wrapper

* Temporary debug logs

* Logout only after saleor unsuccesfull token refresh with error code

* Remove debug logs

Co-authored-by: Marek Choiński <[email protected]>
  • Loading branch information
jwm0 and MarekChoinski authored Sep 30, 2021
1 parent 22da403 commit ae849fd
Show file tree
Hide file tree
Showing 29 changed files with 1,288 additions and 1,182 deletions.
10 changes: 10 additions & 0 deletions apollo.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
client: {
includes: ["src/**/*.ts"],
name: "sdk",
service: {
localSchemaFile: "schema.graphql",
name: "saleor",
},
},
};
219 changes: 203 additions & 16 deletions recordings/auth-api_3443157535/can-register_2974577650/recording.har
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
},
"entries": [
{
"_id": "7009236e3c63dca609e922646a6722e0",
"_id": "3c476eae871dd15bff26d4adebb246ef",
"_order": 0,
"cache": {},
"request": {
"bodySize": 528,
"bodySize": 444,
"cookies": [],
"headers": [
{
Expand All @@ -28,7 +28,7 @@
{
"_fromType": "array",
"name": "content-length",
"value": "528"
"value": "444"
},
{
"_fromType": "array",
Expand All @@ -47,33 +47,180 @@
},
{
"name": "host",
"value": "jwt-expire-test.api.saleor.rocks"
"value": "master.staging.saleor.cloud"
}
],
"headersSize": 308,
"headersSize": 281,
"httpVersion": "HTTP/1.1",
"method": "POST",
"postData": {
"mimeType": "application/json",
"params": [],
"text": "{\"operationName\":\"register\",\"variables\":{\"input\":{\"channel\":\"default-channel\"}},\"query\":\"fragment AccountErrorFragment on AccountError {\\n code\\n field\\n message\\n __typename\\n}\\n\\nmutation register($input: AccountRegisterInput!) {\\n accountRegister(input: $input) {\\n errors {\\n ...AccountErrorFragment\\n __typename\\n }\\n requiresConfirmation\\n __typename\\n }\\n}\\n\"}"
"text": "{\"operationName\":\"refreshToken\",\"variables\":{},\"query\":\"fragment AccountErrorFragment on AccountError {\\n code\\n field\\n message\\n __typename\\n}\\n\\nmutation refreshToken($csrfToken: String, $refreshToken: String) {\\n tokenRefresh(csrfToken: $csrfToken, refreshToken: $refreshToken) {\\n token\\n user {\\n id\\n __typename\\n }\\n errors {\\n ...AccountErrorFragment\\n __typename\\n }\\n __typename\\n }\\n}\\n\"}"
},
"queryString": [],
"url": "https://jwt-expire-test.api.saleor.rocks/graphql/"
"url": "https://master.staging.saleor.cloud/graphql/"
},
"response": {
"bodySize": 108,
"bodySize": 220,
"content": {
"mimeType": "application/json",
"size": 108,
"text": "{\"data\": {\"accountRegister\": {\"errors\": [], \"requiresConfirmation\": true, \"__typename\": \"AccountRegister\"}}}"
"size": 220,
"text": "{\"data\":{\"tokenRefresh\":{\"user\":null,\"errors\":[{\"code\":\"JWT_MISSING_TOKEN\",\"field\":\"refreshToken\",\"message\":\"Missing refreshToken\",\"__typename\":\"AccountError\"}],\"__typename\":\"RefreshToken\"}}}"
},
"cookies": [],
"headers": [
{
"name": "content-type",
"value": "application/json"
},
{
"name": "content-length",
"value": "220"
},
{
"name": "connection",
"value": "close"
},
{
"name": "server",
"value": "CloudFront"
},
{
"name": "date",
"value": "Mon, 13 Sep 2021 14:25:28 GMT"
"value": "Thu, 30 Sep 2021 16:12:48 GMT"
},
{
"name": "x-content-type-options",
"value": "nosniff"
},
{
"name": "referrer-policy",
"value": "same-origin"
},
{
"name": "vary",
"value": "Origin, Access-Control-Request-Headers, Access-Control-Request-Method"
},
{
"name": "x-xss-protection",
"value": "1"
},
{
"name": "x-frame-options",
"value": "DENY"
},
{
"name": "strict-transport-security",
"value": "max-age=31536000; includeSubDomains"
},
{
"name": "x-edge-origin-shield-skipped",
"value": "0"
},
{
"name": "x-cache",
"value": "Miss from cloudfront"
},
{
"name": "via",
"value": "1.1 7d96f66bed58c00decdf9696146921d8.cloudfront.net (CloudFront)"
},
{
"name": "x-amz-cf-pop",
"value": "BUD50-C1"
},
{
"name": "x-amz-cf-id",
"value": "fUB2FUPKUIMyMJnfFrCfeVD5TAezNvKxi7yp0Vei-wUduTR3JJJhsA=="
}
],
"headersSize": 609,
"httpVersion": "HTTP/1.1",
"redirectURL": "",
"status": 200,
"statusText": "OK"
},
"startedDateTime": "2021-09-30T16:12:48.335Z",
"time": 455,
"timings": {
"blocked": -1,
"connect": -1,
"dns": -1,
"receive": 0,
"send": 0,
"ssl": -1,
"wait": 455
}
},
{
"_id": "1dde70a5ec77b592ac5c6d3c90dcaa07",
"_order": 0,
"cache": {},
"request": {
"bodySize": 523,
"cookies": [],
"headers": [
{
"_fromType": "array",
"name": "accept",
"value": "*/*"
},
{
"_fromType": "array",
"name": "content-type",
"value": "application/json"
},
{
"_fromType": "array",
"name": "authorization-bearer",
"value": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2MzMwMjE0NDIsImlzcyI6Im1hc3Rlci5zdGFnaW5nLnNhbGVvci5jbG91ZCIsIm93bmVyIjoic2FsZW9yIiwiZXhwIjoxNjMzMDIxNzQyLCJ0b2tlbiI6Ik0yaXJGbXpWQVNSMyIsImVtYWlsIjoidGVzdGVycytkYXNoYm9hcmRAc2FsZW9yLmlvIiwidHlwZSI6ImFjY2VzcyIsInVzZXJfaWQiOiJWWE5sY2pveE1ETXoiLCJpc19zdGFmZiI6dHJ1ZX0._O_tZgzpLgty3GDGVaOeWq0wO-dkb4UicnglTGfhLh0"
},
{
"_fromType": "array",
"name": "content-length",
"value": "523"
},
{
"_fromType": "array",
"name": "user-agent",
"value": "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"
},
{
"_fromType": "array",
"name": "accept-encoding",
"value": "gzip,deflate"
},
{
"_fromType": "array",
"name": "connection",
"value": "close"
},
{
"name": "host",
"value": "master.staging.saleor.cloud"
}
],
"headersSize": 661,
"httpVersion": "HTTP/1.1",
"method": "POST",
"postData": {
"mimeType": "application/json",
"params": [],
"text": "{\"operationName\":\"register\",\"variables\":{\"input\":{\"channel\":\"default-channel\"}},\"query\":\"fragment AccountErrorFragment on AccountError {\\n code\\n field\\n message\\n __typename\\n}\\n\\nmutation register($input: AccountRegisterInput!) {\\n accountRegister(input: $input) {\\n errors {\\n ...AccountErrorFragment\\n __typename\\n }\\n requiresConfirmation\\n __typename\\n }\\n}\\n\"}"
},
"queryString": [],
"url": "https://master.staging.saleor.cloud/graphql/"
},
"response": {
"bodySize": 108,
"content": {
"mimeType": "application/json",
"size": 108,
"text": "{\"data\":{\"accountRegister\":{\"errors\":[],\"requiresConfirmation\":true,\"__typename\":\"AccountRegister\"}}}"
},
"cookies": [],
"headers": [
{
"name": "content-type",
"value": "application/json"
Expand All @@ -88,7 +235,11 @@
},
{
"name": "server",
"value": "uvicorn"
"value": "CloudFront"
},
{
"name": "date",
"value": "Thu, 30 Sep 2021 17:04:04 GMT"
},
{
"name": "x-content-type-options",
Expand All @@ -97,24 +248,60 @@
{
"name": "referrer-policy",
"value": "same-origin"
},
{
"name": "vary",
"value": "Origin, Access-Control-Request-Headers, Access-Control-Request-Method"
},
{
"name": "x-xss-protection",
"value": "1"
},
{
"name": "x-frame-options",
"value": "DENY"
},
{
"name": "strict-transport-security",
"value": "max-age=31536000; includeSubDomains"
},
{
"name": "x-edge-origin-shield-skipped",
"value": "0"
},
{
"name": "x-cache",
"value": "Miss from cloudfront"
},
{
"name": "via",
"value": "1.1 3b6239c61689b2727182c34a97307648.cloudfront.net (CloudFront)"
},
{
"name": "x-amz-cf-pop",
"value": "BUD50-C1"
},
{
"name": "x-amz-cf-id",
"value": "I41aGGgsIrSZwCEm6kO5ccqyDT6lIft6AeKTm5rtMP6lDucxXv8_ow=="
}
],
"headersSize": 191,
"headersSize": 609,
"httpVersion": "HTTP/1.1",
"redirectURL": "",
"status": 200,
"statusText": "OK"
},
"startedDateTime": "2021-09-13T14:25:24.311Z",
"time": 4528,
"startedDateTime": "2021-09-30T17:04:03.606Z",
"time": 906,
"timings": {
"blocked": -1,
"connect": -1,
"dns": -1,
"receive": 0,
"send": 0,
"ssl": -1,
"wait": 4528
"wait": 906
}
}
],
Expand Down
Loading

0 comments on commit ae849fd

Please sign in to comment.