cozy-client 27.20.0 → 27.22.1
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.
- package/dist/CozyClient.js +131 -58
- package/dist/devtools/index.js +1 -0
- package/dist/models/document/documentTypeData.js +1 -1
- package/dist/models/document/locales/fr.json +1 -1
- package/dist/types.js +27 -1
- package/package.json +3 -3
- package/types/CozyClient.d.ts +27 -7
- package/types/types.d.ts +21 -1
package/dist/CozyClient.js
CHANGED
|
@@ -1942,7 +1942,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
1942
1942
|
/**
|
|
1943
1943
|
* Performs a complete OAuth flow, including updating the internal token at the end.
|
|
1944
1944
|
*
|
|
1945
|
-
* @param {
|
|
1945
|
+
* @param {OpenURLCallback} openURLCallback Receives the URL to present to the user as a parameter, and should return a promise that resolves with the URL the user was redirected to after accepting the permissions.
|
|
1946
1946
|
* @returns {Promise<object>} Contains the fetched token and the client information. These should be stored and used to restore the client.
|
|
1947
1947
|
*/
|
|
1948
1948
|
|
|
@@ -1960,18 +1960,15 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
1960
1960
|
return stackClient.register();
|
|
1961
1961
|
|
|
1962
1962
|
case 3:
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
break;
|
|
1966
|
-
}
|
|
1963
|
+
_context14.next = 5;
|
|
1964
|
+
return this.certifyFlagship();
|
|
1967
1965
|
|
|
1968
|
-
|
|
1969
|
-
return (
|
|
1966
|
+
case 5:
|
|
1967
|
+
return _context14.abrupt("return", this.authorize({
|
|
1968
|
+
openURLCallback: openURLCallback
|
|
1969
|
+
}));
|
|
1970
1970
|
|
|
1971
1971
|
case 6:
|
|
1972
|
-
return _context14.abrupt("return", this.authorize(openURLCallback));
|
|
1973
|
-
|
|
1974
|
-
case 7:
|
|
1975
1972
|
case "end":
|
|
1976
1973
|
return _context14.stop();
|
|
1977
1974
|
}
|
|
@@ -1985,61 +1982,135 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
1985
1982
|
|
|
1986
1983
|
return startOAuthFlow;
|
|
1987
1984
|
}()
|
|
1985
|
+
/**
|
|
1986
|
+
* Perform the Flagship certification process for verifying that the current running app is a genuine Cozy application
|
|
1987
|
+
*
|
|
1988
|
+
* This mechanism is described in https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/flagship-certification/README.md
|
|
1989
|
+
*/
|
|
1990
|
+
|
|
1988
1991
|
}, {
|
|
1989
|
-
key: "
|
|
1992
|
+
key: "certifyFlagship",
|
|
1990
1993
|
value: function () {
|
|
1991
|
-
var
|
|
1992
|
-
var stackClient
|
|
1993
|
-
|
|
1994
|
+
var _certifyFlagship2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15() {
|
|
1995
|
+
var stackClient;
|
|
1994
1996
|
return _regenerator.default.wrap(function _callee15$(_context15) {
|
|
1995
1997
|
while (1) {
|
|
1996
1998
|
switch (_context15.prev = _context15.next) {
|
|
1997
1999
|
case 0:
|
|
1998
|
-
|
|
2000
|
+
stackClient = this.getStackClient();
|
|
2001
|
+
|
|
2002
|
+
if (!stackClient.oauthOptions.shouldRequireFlagshipPermissions) {
|
|
2003
|
+
_context15.next = 4;
|
|
2004
|
+
break;
|
|
2005
|
+
}
|
|
2006
|
+
|
|
2007
|
+
_context15.next = 4;
|
|
2008
|
+
return (0, _flagshipCertification.certifyFlagship)(stackClient.oauthOptions.certificationConfig, this);
|
|
2009
|
+
|
|
2010
|
+
case 4:
|
|
2011
|
+
case "end":
|
|
2012
|
+
return _context15.stop();
|
|
2013
|
+
}
|
|
2014
|
+
}
|
|
2015
|
+
}, _callee15, this);
|
|
2016
|
+
}));
|
|
2017
|
+
|
|
2018
|
+
function certifyFlagship() {
|
|
2019
|
+
return _certifyFlagship2.apply(this, arguments);
|
|
2020
|
+
}
|
|
2021
|
+
|
|
2022
|
+
return certifyFlagship;
|
|
2023
|
+
}()
|
|
2024
|
+
/**
|
|
2025
|
+
* Creates an OAuth token with needed permissions for the current client.
|
|
2026
|
+
* The authorization page URL generation can be overriding by passing a function pointer as `openURLCallback` parameter
|
|
2027
|
+
* It is possible to skip the session creation process (when using an in-app browser) by passing a sessionCode (see https://docs.cozy.io/en/cozy-stack/auth/#post-authsession_code)
|
|
2028
|
+
*
|
|
2029
|
+
* @param {object} [options] - Authorization options
|
|
2030
|
+
* @param {OpenURLCallback} [options.openURLCallback] - Receives the URL to present to the user as a parameter, and should return a promise that resolves with the URL the user was redirected to after accepting the permissions.
|
|
2031
|
+
* @param {SessionCode} [options.sessionCode] - session code than can be added to the authorization URL to automatically create the session.
|
|
2032
|
+
* @param {PKCECodes} [options.pkceCodes] - code verifier and a code challenge that should be used in the PKCE verification process.
|
|
2033
|
+
* @returns {Promise<object>} Contains the fetched token and the client information. These should be stored and used to restore the client.
|
|
2034
|
+
*/
|
|
2035
|
+
|
|
2036
|
+
}, {
|
|
2037
|
+
key: "authorize",
|
|
2038
|
+
value: function () {
|
|
2039
|
+
var _authorize = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16() {
|
|
2040
|
+
var _ref6,
|
|
2041
|
+
_ref6$openURLCallback,
|
|
2042
|
+
openURLCallback,
|
|
2043
|
+
_ref6$sessionCode,
|
|
2044
|
+
sessionCode,
|
|
2045
|
+
_ref6$pkceCodes,
|
|
2046
|
+
pkceCodes,
|
|
2047
|
+
codeVerifier,
|
|
2048
|
+
codeChallenge,
|
|
2049
|
+
stackClient,
|
|
2050
|
+
stateCode,
|
|
2051
|
+
url,
|
|
2052
|
+
redirectedURL,
|
|
2053
|
+
code,
|
|
2054
|
+
token,
|
|
2055
|
+
_stackClient,
|
|
2056
|
+
_args16 = arguments;
|
|
2057
|
+
|
|
2058
|
+
return _regenerator.default.wrap(function _callee16$(_context16) {
|
|
2059
|
+
while (1) {
|
|
2060
|
+
switch (_context16.prev = _context16.next) {
|
|
2061
|
+
case 0:
|
|
2062
|
+
_ref6 = _args16.length > 0 && _args16[0] !== undefined ? _args16[0] : {}, _ref6$openURLCallback = _ref6.openURLCallback, openURLCallback = _ref6$openURLCallback === void 0 ? _mobile.authFunction : _ref6$openURLCallback, _ref6$sessionCode = _ref6.sessionCode, sessionCode = _ref6$sessionCode === void 0 ? undefined : _ref6$sessionCode, _ref6$pkceCodes = _ref6.pkceCodes, pkceCodes = _ref6$pkceCodes === void 0 ? {} : _ref6$pkceCodes;
|
|
2063
|
+
_context16.prev = 1;
|
|
2064
|
+
codeVerifier = pkceCodes.codeVerifier, codeChallenge = pkceCodes.codeChallenge;
|
|
1999
2065
|
stackClient = this.getStackClient();
|
|
2000
2066
|
stateCode = stackClient.generateStateCode();
|
|
2001
|
-
url = stackClient.getAuthCodeURL(
|
|
2002
|
-
|
|
2067
|
+
url = stackClient.getAuthCodeURL({
|
|
2068
|
+
stateCode: stateCode,
|
|
2069
|
+
scopes: undefined,
|
|
2070
|
+
sessionCode: sessionCode,
|
|
2071
|
+
codeChallenge: codeChallenge
|
|
2072
|
+
});
|
|
2073
|
+
_context16.next = 8;
|
|
2003
2074
|
return openURLCallback(url);
|
|
2004
2075
|
|
|
2005
|
-
case
|
|
2006
|
-
redirectedURL =
|
|
2076
|
+
case 8:
|
|
2077
|
+
redirectedURL = _context16.sent;
|
|
2007
2078
|
code = stackClient.getAccessCodeFromURL(redirectedURL, stateCode);
|
|
2008
|
-
|
|
2009
|
-
return stackClient.fetchAccessToken(code);
|
|
2079
|
+
_context16.next = 12;
|
|
2080
|
+
return stackClient.fetchAccessToken(code, undefined, undefined, codeVerifier);
|
|
2010
2081
|
|
|
2011
|
-
case
|
|
2012
|
-
token =
|
|
2082
|
+
case 12:
|
|
2083
|
+
token = _context16.sent;
|
|
2013
2084
|
stackClient.setToken(token);
|
|
2014
|
-
return
|
|
2085
|
+
return _context16.abrupt("return", {
|
|
2015
2086
|
token: token,
|
|
2016
2087
|
infos: stackClient.oauthOptions,
|
|
2017
2088
|
client: stackClient.oauthOptions // for compat with Authentication comp reasons
|
|
2018
2089
|
|
|
2019
2090
|
});
|
|
2020
2091
|
|
|
2021
|
-
case
|
|
2022
|
-
|
|
2023
|
-
|
|
2092
|
+
case 17:
|
|
2093
|
+
_context16.prev = 17;
|
|
2094
|
+
_context16.t0 = _context16["catch"](1);
|
|
2024
2095
|
|
|
2025
2096
|
/* if REGISTRATION_ABORT is emited, we have to unregister the client. */
|
|
2026
|
-
if (
|
|
2097
|
+
if (_context16.t0.message === _const.REGISTRATION_ABORT) {
|
|
2027
2098
|
_stackClient = this.getStackClient();
|
|
2028
2099
|
|
|
2029
2100
|
_stackClient.unregister();
|
|
2030
2101
|
}
|
|
2031
2102
|
|
|
2032
|
-
throw
|
|
2103
|
+
throw _context16.t0;
|
|
2033
2104
|
|
|
2034
|
-
case
|
|
2105
|
+
case 21:
|
|
2035
2106
|
case "end":
|
|
2036
|
-
return
|
|
2107
|
+
return _context16.stop();
|
|
2037
2108
|
}
|
|
2038
2109
|
}
|
|
2039
|
-
},
|
|
2110
|
+
}, _callee16, this, [[1, 17]]);
|
|
2040
2111
|
}));
|
|
2041
2112
|
|
|
2042
|
-
function authorize(
|
|
2113
|
+
function authorize() {
|
|
2043
2114
|
return _authorize.apply(this, arguments);
|
|
2044
2115
|
}
|
|
2045
2116
|
|
|
@@ -2055,7 +2126,9 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2055
2126
|
}, {
|
|
2056
2127
|
key: "renewAuthorization",
|
|
2057
2128
|
value: function renewAuthorization() {
|
|
2058
|
-
return this.authorize(
|
|
2129
|
+
return this.authorize({
|
|
2130
|
+
openURLCallback: _mobile.authFunction
|
|
2131
|
+
});
|
|
2059
2132
|
}
|
|
2060
2133
|
/**
|
|
2061
2134
|
* Sets the internal store of the client. Use this when you want to have cozy-client's
|
|
@@ -2083,9 +2156,9 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2083
2156
|
}, {
|
|
2084
2157
|
key: "setStore",
|
|
2085
2158
|
value: function setStore(store) {
|
|
2086
|
-
var
|
|
2087
|
-
|
|
2088
|
-
force =
|
|
2159
|
+
var _ref7 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
2160
|
+
_ref7$force = _ref7.force,
|
|
2161
|
+
force = _ref7$force === void 0 ? false : _ref7$force;
|
|
2089
2162
|
|
|
2090
2163
|
if (store === undefined) {
|
|
2091
2164
|
throw new Error('Store is undefined');
|
|
@@ -2109,19 +2182,19 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2109
2182
|
}, {
|
|
2110
2183
|
key: "checkForRevocation",
|
|
2111
2184
|
value: function () {
|
|
2112
|
-
var _checkForRevocation = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
2113
|
-
return _regenerator.default.wrap(function
|
|
2185
|
+
var _checkForRevocation = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17() {
|
|
2186
|
+
return _regenerator.default.wrap(function _callee17$(_context17) {
|
|
2114
2187
|
while (1) {
|
|
2115
|
-
switch (
|
|
2188
|
+
switch (_context17.prev = _context17.next) {
|
|
2116
2189
|
case 0:
|
|
2117
|
-
return
|
|
2190
|
+
return _context17.abrupt("return", this.stackClient.checkForRevocation());
|
|
2118
2191
|
|
|
2119
2192
|
case 1:
|
|
2120
2193
|
case "end":
|
|
2121
|
-
return
|
|
2194
|
+
return _context17.stop();
|
|
2122
2195
|
}
|
|
2123
2196
|
}
|
|
2124
|
-
},
|
|
2197
|
+
}, _callee17, this);
|
|
2125
2198
|
}));
|
|
2126
2199
|
|
|
2127
2200
|
function checkForRevocation() {
|
|
@@ -2279,10 +2352,10 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2279
2352
|
var _this10 = this;
|
|
2280
2353
|
|
|
2281
2354
|
this.ensureStore();
|
|
2282
|
-
Object.entries(data).forEach(function (
|
|
2283
|
-
var
|
|
2284
|
-
doctype =
|
|
2285
|
-
data =
|
|
2355
|
+
Object.entries(data).forEach(function (_ref8) {
|
|
2356
|
+
var _ref9 = (0, _slicedToArray2.default)(_ref8, 2),
|
|
2357
|
+
doctype = _ref9[0],
|
|
2358
|
+
data = _ref9[1];
|
|
2286
2359
|
|
|
2287
2360
|
_this10.dispatch((0, _store.receiveQueryResult)(null, {
|
|
2288
2361
|
data: data
|
|
@@ -2334,28 +2407,28 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2334
2407
|
}, {
|
|
2335
2408
|
key: "fromOldOAuthClient",
|
|
2336
2409
|
value: function () {
|
|
2337
|
-
var _fromOldOAuthClient = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
2410
|
+
var _fromOldOAuthClient = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee18(oldClient, options) {
|
|
2338
2411
|
var credentials, oauthOptions;
|
|
2339
|
-
return _regenerator.default.wrap(function
|
|
2412
|
+
return _regenerator.default.wrap(function _callee18$(_context18) {
|
|
2340
2413
|
while (1) {
|
|
2341
|
-
switch (
|
|
2414
|
+
switch (_context18.prev = _context18.next) {
|
|
2342
2415
|
case 0:
|
|
2343
2416
|
if (!oldClient._oauth) {
|
|
2344
|
-
|
|
2417
|
+
_context18.next = 8;
|
|
2345
2418
|
break;
|
|
2346
2419
|
}
|
|
2347
2420
|
|
|
2348
|
-
|
|
2421
|
+
_context18.next = 3;
|
|
2349
2422
|
return oldClient.authorize();
|
|
2350
2423
|
|
|
2351
2424
|
case 3:
|
|
2352
|
-
credentials =
|
|
2425
|
+
credentials = _context18.sent;
|
|
2353
2426
|
oauthOptions = {
|
|
2354
2427
|
oauth: credentials.client,
|
|
2355
2428
|
token: credentials.token,
|
|
2356
2429
|
scope: credentials.token.scope
|
|
2357
2430
|
};
|
|
2358
|
-
return
|
|
2431
|
+
return _context18.abrupt("return", new CozyClient(_objectSpread(_objectSpread({
|
|
2359
2432
|
uri: oldClient._url
|
|
2360
2433
|
}, oauthOptions), options)));
|
|
2361
2434
|
|
|
@@ -2364,13 +2437,13 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2364
2437
|
|
|
2365
2438
|
case 9:
|
|
2366
2439
|
case "end":
|
|
2367
|
-
return
|
|
2440
|
+
return _context18.stop();
|
|
2368
2441
|
}
|
|
2369
2442
|
}
|
|
2370
|
-
},
|
|
2443
|
+
}, _callee18);
|
|
2371
2444
|
}));
|
|
2372
2445
|
|
|
2373
|
-
function fromOldOAuthClient(
|
|
2446
|
+
function fromOldOAuthClient(_x17, _x18) {
|
|
2374
2447
|
return _fromOldOAuthClient.apply(this, arguments);
|
|
2375
2448
|
}
|
|
2376
2449
|
|
|
@@ -2464,7 +2537,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2464
2537
|
CozyClient.hooks = CozyClient.hooks || {};
|
|
2465
2538
|
CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
|
|
2466
2539
|
|
|
2467
|
-
CozyClient.version = "27.
|
|
2540
|
+
CozyClient.version = "27.22.1";
|
|
2468
2541
|
|
|
2469
2542
|
_microee.default.mixin(CozyClient);
|
|
2470
2543
|
|
package/dist/devtools/index.js
CHANGED
|
@@ -67,7 +67,7 @@ var activityLabels = ['personal_sporting_licence', 'other_activity_document'];
|
|
|
67
67
|
* @type {Array<FinanceLabels>}
|
|
68
68
|
*/
|
|
69
69
|
|
|
70
|
-
var financeLabels = ['tax_return', 'tax_notice', 'tax_timetable', 'receipt', 'other_tax_document', 'bank_details', 'bank_statement', 'loan_agreement', 'payment_proof_family_allowance', 'other_bank_document', 'other_revenue'];
|
|
70
|
+
var financeLabels = ['tax_return', 'tax_notice', 'tax_timetable', 'pay_sheet', 'receipt', 'other_tax_document', 'bank_details', 'bank_statement', 'loan_agreement', 'payment_proof_family_allowance', 'other_bank_document', 'other_revenue'];
|
|
71
71
|
/**
|
|
72
72
|
* @type {Array<InvoiceLabels>}
|
|
73
73
|
*/
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"pay_sheet": "Fiche de paie",
|
|
47
47
|
"unemployment_benefit": "Allocations chômage",
|
|
48
48
|
"pension": "Retraite",
|
|
49
|
-
"other_revenue": "Autres
|
|
49
|
+
"other_revenue": "Autres revenus",
|
|
50
50
|
"gradebook": "Bulletin de notes",
|
|
51
51
|
"student_card": "Carte d'étudiant",
|
|
52
52
|
"school_attendance_certificate": "Certificat de scolarité",
|
package/dist/types.js
CHANGED
|
@@ -294,7 +294,7 @@ var _dsl = require("./queries/dsl");
|
|
|
294
294
|
*
|
|
295
295
|
* @typedef {'driver_license'|'vehicle_registration'|'car_insurance'|'mechanic_invoice'|'transport_invoice'|'other_transport_document'} TransportLabels
|
|
296
296
|
*
|
|
297
|
-
* @typedef {'tax_return'|'tax_notice'|'tax_timetable'|'receipt'|'other_tax_document'|'bank_details'|'bank_statement'|'loan_agreement'|'other_bank_document'|'payment_proof_family_allowance'|'other_revenue'} FinanceLabels
|
|
297
|
+
* @typedef {'tax_return'|'tax_notice'|'tax_timetable'|'pay_sheet'|'receipt'|'other_tax_document'|'bank_details'|'bank_statement'|'loan_agreement'|'other_bank_document'|'payment_proof_family_allowance'|'other_revenue'} FinanceLabels
|
|
298
298
|
*
|
|
299
299
|
* @typedef {'phone_invoice'|'isp_invoice'|'telecom_invoice'|'energy_invoice'|'water_invoice'|'appliance_invoice'|'web_service_invoice'|'restaurant_invoice'|'work_invoice'|'transport_invoice'|'health_invoice'|'other_invoice'} InvoiceLabels
|
|
300
300
|
*
|
|
@@ -302,5 +302,31 @@ var _dsl = require("./queries/dsl");
|
|
|
302
302
|
*
|
|
303
303
|
* @typedef {IdentityLabel|FamilyLabel|WorkStudyLabels|HealthLabels|HomeLabels|TransportLabels|FinanceLabels|InvoiceLabels|ActivityLabels} ItemsLabels
|
|
304
304
|
*/
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Receives the URL to present to the user as a parameter, and should return a promise that resolves with the URL the user was redirected to after accepting the permissions.
|
|
308
|
+
*
|
|
309
|
+
* @callback OpenURLCallback
|
|
310
|
+
* @param {string} url - URL to present to the user
|
|
311
|
+
*/
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* A session code generated by the cozy-stack that can be used to create a session
|
|
315
|
+
*
|
|
316
|
+
* More information: https://docs.cozy.io/en/cozy-stack/auth/#post-authsession_code
|
|
317
|
+
*
|
|
318
|
+
* @typedef {string} SessionCode
|
|
319
|
+
*/
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* An object containing a code verifier and a code challenge that can be used in a
|
|
323
|
+
* PKCE verification process
|
|
324
|
+
*
|
|
325
|
+
* More information: https://docs.cozy.io/en/cozy-stack/auth/#pkce-extension
|
|
326
|
+
*
|
|
327
|
+
* @typedef {object} PKCECodes
|
|
328
|
+
* @property {string} [codeVerifier]
|
|
329
|
+
* @property {string} [codeChallenge]
|
|
330
|
+
*/
|
|
305
331
|
var _default = {};
|
|
306
332
|
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-client",
|
|
3
|
-
"version": "27.
|
|
3
|
+
"version": "27.22.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.node.js",
|
|
6
6
|
"browser": "dist/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"cozy-device-helper": "^1.12.0",
|
|
22
22
|
"cozy-flags": "2.7.1",
|
|
23
23
|
"cozy-logger": "^1.6.0",
|
|
24
|
-
"cozy-stack-client": "^27.
|
|
24
|
+
"cozy-stack-client": "^27.21.0",
|
|
25
25
|
"json-stable-stringify": "^1.0.1",
|
|
26
26
|
"lodash": "^4.17.13",
|
|
27
27
|
"microee": "^0.0.6",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"react-native-ios11-devicecheck": "https://github.com/cozy/react-native-devicecheck#app-attest-v0.1"
|
|
72
72
|
},
|
|
73
73
|
"sideEffects": false,
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "b0652ecd7383d34c8468b492b858049ed0aef10c"
|
|
75
75
|
}
|
package/types/CozyClient.d.ts
CHANGED
|
@@ -558,15 +558,32 @@ declare class CozyClient {
|
|
|
558
558
|
/**
|
|
559
559
|
* Performs a complete OAuth flow, including updating the internal token at the end.
|
|
560
560
|
*
|
|
561
|
-
* @param {
|
|
561
|
+
* @param {OpenURLCallback} openURLCallback Receives the URL to present to the user as a parameter, and should return a promise that resolves with the URL the user was redirected to after accepting the permissions.
|
|
562
562
|
* @returns {Promise<object>} Contains the fetched token and the client information. These should be stored and used to restore the client.
|
|
563
563
|
*/
|
|
564
|
-
startOAuthFlow(openURLCallback:
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
564
|
+
startOAuthFlow(openURLCallback: OpenURLCallback): Promise<object>;
|
|
565
|
+
/**
|
|
566
|
+
* Perform the Flagship certification process for verifying that the current running app is a genuine Cozy application
|
|
567
|
+
*
|
|
568
|
+
* This mechanism is described in https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/flagship-certification/README.md
|
|
569
|
+
*/
|
|
570
|
+
certifyFlagship(): Promise<void>;
|
|
571
|
+
/**
|
|
572
|
+
* Creates an OAuth token with needed permissions for the current client.
|
|
573
|
+
* The authorization page URL generation can be overriding by passing a function pointer as `openURLCallback` parameter
|
|
574
|
+
* It is possible to skip the session creation process (when using an in-app browser) by passing a sessionCode (see https://docs.cozy.io/en/cozy-stack/auth/#post-authsession_code)
|
|
575
|
+
*
|
|
576
|
+
* @param {object} [options] - Authorization options
|
|
577
|
+
* @param {OpenURLCallback} [options.openURLCallback] - Receives the URL to present to the user as a parameter, and should return a promise that resolves with the URL the user was redirected to after accepting the permissions.
|
|
578
|
+
* @param {SessionCode} [options.sessionCode] - session code than can be added to the authorization URL to automatically create the session.
|
|
579
|
+
* @param {PKCECodes} [options.pkceCodes] - code verifier and a code challenge that should be used in the PKCE verification process.
|
|
580
|
+
* @returns {Promise<object>} Contains the fetched token and the client information. These should be stored and used to restore the client.
|
|
581
|
+
*/
|
|
582
|
+
authorize({ openURLCallback, sessionCode, pkceCodes }?: {
|
|
583
|
+
openURLCallback?: OpenURLCallback;
|
|
584
|
+
sessionCode?: SessionCode;
|
|
585
|
+
pkceCodes?: PKCECodes;
|
|
586
|
+
}): Promise<object>;
|
|
570
587
|
/**
|
|
571
588
|
* Renews the token if, for instance, new permissions are required or token
|
|
572
589
|
* has expired.
|
|
@@ -677,6 +694,9 @@ import { QueryResult } from "./types";
|
|
|
677
694
|
import ObservableQuery from "./ObservableQuery";
|
|
678
695
|
import { HydratedDocument } from "./types";
|
|
679
696
|
import { QueryState } from "./types";
|
|
697
|
+
import { OpenURLCallback } from "./types";
|
|
698
|
+
import { SessionCode } from "./types";
|
|
699
|
+
import { PKCECodes } from "./types";
|
|
680
700
|
import { ReduxStore } from "./types";
|
|
681
701
|
import { CozyClient as SnapshotClient } from "./testing/snapshots";
|
|
682
702
|
import { OldCozyClient } from "./types";
|
package/types/types.d.ts
CHANGED
|
@@ -324,8 +324,28 @@ export type WorkStudyLabels = "resume" | "diploma" | "work_contract" | "pay_shee
|
|
|
324
324
|
export type HealthLabels = "work_disability_recognition" | "health_certificate" | "health_book" | "national_health_insurance_card" | "health_insurance_card" | "prescription" | "health_invoice" | "national_health_insurance_right_certificate" | "pregnancy_medical_certificate" | "other_health_document";
|
|
325
325
|
export type HomeLabels = "phone_invoice" | "isp_invoice" | "telecom_invoice" | "energy_invoice" | "water_invoice" | "house_sale_agreeement" | "building_permit" | "technical_diagnostic_record" | "lease" | "rent_receipt" | "house_insurance" | "work_quote" | "work_invoice" | "other_house_document" | "unfit_for_habitation_declaration" | "accommodation_proof";
|
|
326
326
|
export type TransportLabels = "driver_license" | "vehicle_registration" | "car_insurance" | "mechanic_invoice" | "transport_invoice" | "other_transport_document";
|
|
327
|
-
export type FinanceLabels = "payment_proof_family_allowance" | "tax_return" | "tax_notice" | "tax_timetable" | "receipt" | "other_tax_document" | "bank_details" | "bank_statement" | "loan_agreement" | "other_bank_document" | "other_revenue";
|
|
327
|
+
export type FinanceLabels = "payment_proof_family_allowance" | "pay_sheet" | "tax_return" | "tax_notice" | "tax_timetable" | "receipt" | "other_tax_document" | "bank_details" | "bank_statement" | "loan_agreement" | "other_bank_document" | "other_revenue";
|
|
328
328
|
export type InvoiceLabels = "health_invoice" | "phone_invoice" | "isp_invoice" | "telecom_invoice" | "energy_invoice" | "water_invoice" | "work_invoice" | "transport_invoice" | "appliance_invoice" | "web_service_invoice" | "restaurant_invoice" | "other_invoice";
|
|
329
329
|
export type ActivityLabels = "personal_sporting_licence" | "other_activity_document";
|
|
330
330
|
export type ItemsLabels = "resume" | "identity_photo" | "national_id_card" | "passport" | "residence_permit" | "family_record_book" | "birth_certificate" | "driver_license" | "other_identity_document" | "citizen_registration_certificate" | "personal_sporting_licence" | "wedding" | "pacs" | "divorce" | "large_family_card" | "caf" | "other_family_document" | "payment_proof_family_allowance" | "diploma" | "work_contract" | "pay_sheet" | "unemployment_benefit" | "pension" | "gradebook" | "student_card" | "motivation_letter" | "other_work_document" | "work_disability_recognition" | "school_attendance_certificate" | "health_certificate" | "health_book" | "national_health_insurance_card" | "health_insurance_card" | "prescription" | "health_invoice" | "national_health_insurance_right_certificate" | "pregnancy_medical_certificate" | "other_health_document" | "phone_invoice" | "isp_invoice" | "telecom_invoice" | "energy_invoice" | "water_invoice" | "house_sale_agreeement" | "building_permit" | "technical_diagnostic_record" | "lease" | "rent_receipt" | "house_insurance" | "work_quote" | "work_invoice" | "other_house_document" | "unfit_for_habitation_declaration" | "accommodation_proof" | "vehicle_registration" | "car_insurance" | "mechanic_invoice" | "transport_invoice" | "other_transport_document" | "tax_return" | "tax_notice" | "tax_timetable" | "receipt" | "other_tax_document" | "bank_details" | "bank_statement" | "loan_agreement" | "other_bank_document" | "other_revenue" | "appliance_invoice" | "web_service_invoice" | "restaurant_invoice" | "other_invoice" | "other_activity_document";
|
|
331
|
+
/**
|
|
332
|
+
* Receives the URL to present to the user as a parameter, and should return a promise that resolves with the URL the user was redirected to after accepting the permissions.
|
|
333
|
+
*/
|
|
334
|
+
export type OpenURLCallback = (url: string) => any;
|
|
335
|
+
/**
|
|
336
|
+
* A session code generated by the cozy-stack that can be used to create a session
|
|
337
|
+
*
|
|
338
|
+
* More information: https://docs.cozy.io/en/cozy-stack/auth/#post-authsession_code
|
|
339
|
+
*/
|
|
340
|
+
export type SessionCode = string;
|
|
341
|
+
/**
|
|
342
|
+
* An object containing a code verifier and a code challenge that can be used in a
|
|
343
|
+
* PKCE verification process
|
|
344
|
+
*
|
|
345
|
+
* More information: https://docs.cozy.io/en/cozy-stack/auth/#pkce-extension
|
|
346
|
+
*/
|
|
347
|
+
export type PKCECodes = {
|
|
348
|
+
codeVerifier?: string;
|
|
349
|
+
codeChallenge?: string;
|
|
350
|
+
};
|
|
331
351
|
import { QueryDefinition } from "./queries/dsl";
|