@companieshouse/api-sdk-node 2.0.38 → 2.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { IHttpClient } from "../../http";
|
|
2
2
|
import { RefreshTokenData } from "./types";
|
|
3
|
-
import Resource from "../resource";
|
|
3
|
+
import Resource, { ApiErrorResponse } from "../resource";
|
|
4
4
|
export default class {
|
|
5
5
|
private readonly client;
|
|
6
6
|
constructor(client: IHttpClient);
|
|
7
|
-
refresh(refreshToken: string, grantType: string, clientId: string, clientSecret: string): Promise<Resource<RefreshTokenData
|
|
7
|
+
refresh(refreshToken: string, grantType: string, clientId: string, clientSecret: string): Promise<Resource<RefreshTokenData> | ApiErrorResponse>;
|
|
8
8
|
}
|
|
@@ -15,21 +15,18 @@ class default_1 {
|
|
|
15
15
|
}
|
|
16
16
|
refresh(refreshToken, grantType, clientId, clientSecret) {
|
|
17
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
const url = `/oauth2/token?grant_type=${grantType}&refresh_token=${refreshToken}&client_id=${clientId}
|
|
19
|
-
`&client_secret=${clientSecret}`;
|
|
18
|
+
const url = `/oauth2/token?grant_type=${grantType}&refresh_token=${refreshToken}&client_id=${clientId}&client_secret=${clientSecret}`;
|
|
20
19
|
const response = yield this.client.httpPost(url);
|
|
21
|
-
const resource = {
|
|
22
|
-
httpStatusCode: response.status
|
|
23
|
-
};
|
|
24
20
|
if (response.error) {
|
|
25
|
-
return
|
|
21
|
+
return {
|
|
22
|
+
httpStatusCode: response.status,
|
|
23
|
+
errors: [response.error]
|
|
24
|
+
};
|
|
26
25
|
}
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
expires_in: body.expires_in,
|
|
30
|
-
token_type: body.token_type,
|
|
31
|
-
access_token: body.access_token
|
|
26
|
+
const resource = {
|
|
27
|
+
httpStatusCode: response.status
|
|
32
28
|
};
|
|
29
|
+
resource.resource = Object.assign({}, response.body);
|
|
33
30
|
return resource;
|
|
34
31
|
});
|
|
35
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/services/refresh-token/service.ts"],"names":[],"mappings":";;;;;;;;;;;AAIA;IACI,YAA8B,MAAmB;QAAnB,WAAM,GAAN,MAAM,CAAa;IAAG,CAAC;IAExC,OAAO,
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/services/refresh-token/service.ts"],"names":[],"mappings":";;;;;;;;;;;AAIA;IACI,YAA8B,MAAmB;QAAnB,WAAM,GAAN,MAAM,CAAa;IAAG,CAAC;IAExC,OAAO,CAChB,YAAoB,EACpB,SAAiB,EACjB,QAAgB,EAChB,YAAoB;;YAEpB,MAAM,GAAG,GAAG,4BAA4B,SAAS,kBAAkB,YAAY,cAAc,QAAQ,kBAAkB,YAAY,EAAE,CAAC;YAEtI,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;YAEjD,IAAI,QAAQ,CAAC,KAAK,EAAE;gBAChB,OAAO;oBACH,cAAc,EAAE,QAAQ,CAAC,MAAM;oBAC/B,MAAM,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC;iBAC3B,CAAC;aACL;YACD,MAAM,QAAQ,GAA+B;gBACzC,cAAc,EAAE,QAAQ,CAAC,MAAM;aAClC,CAAC;YAEF,QAAQ,CAAC,QAAQ,qBAAQ,QAAQ,CAAC,IAAI,CAAE,CAAC;YAEzC,OAAO,QAAQ,CAAC;QACpB,CAAC;KAAA;CACJ;AA3BD,4BA2BC"}
|