@authme/core 2.4.2 → 2.4.6

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/index.cjs CHANGED
@@ -49,7 +49,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
49
49
  }
50
50
 
51
51
  var name = "@authme/core";
52
- var version$1 = "2.4.2";
52
+ var version$1 = "2.4.6";
53
53
  var peerDependencies = {
54
54
  "core-js": "^3.6.0"
55
55
  };
@@ -65,6 +65,19 @@ const version = packageInfo.version;
65
65
  (_a = (_b = window)[_c = Symbol.for('authme-sdk')]) !== null && _a !== void 0 ? _a : _b[_c] = {};
66
66
  window[Symbol.for('authme-sdk')][packageInfo.name] = version;
67
67
 
68
+ function requestLoggingWapper() {
69
+ let loggingFuncInstance = undefined;
70
+ return {
71
+ setRequestLoggingFunc: func => {
72
+ loggingFuncInstance = func;
73
+ },
74
+ getRequestLoggingFunc: () => loggingFuncInstance
75
+ };
76
+ }
77
+ const {
78
+ setRequestLoggingFunc,
79
+ getRequestLoggingFunc
80
+ } = requestLoggingWapper();
68
81
  function tryLoadAndParseJsonAsync(response) {
69
82
  return __awaiter(this, void 0, void 0, function* () {
70
83
  try {
@@ -102,6 +115,7 @@ function sendRequest(url, method = 'GET', {
102
115
  sdkInfo = [`sdk-version: ${version}`, util.getUserAgent()].join(';')
103
116
  } = {}) {
104
117
  return __awaiter(this, void 0, void 0, function* () {
118
+ const requestLoggingFunction = getRequestLoggingFunc();
105
119
  const options = Object.assign(Object.assign({
106
120
  method
107
121
  }, typeof body !== undefined ? {
@@ -118,7 +132,13 @@ function sendRequest(url, method = 'GET', {
118
132
  let resp;
119
133
  try {
120
134
  const normalizedUrl = baseUrl ? new URL(url, baseUrl).toString() : url;
121
- resp = yield fetch(normalizedUrl.toString(), options);
135
+ resp = requestLoggingFunction ? yield requestLoggingFunction(() => fetch(normalizedUrl.toString(), options), {
136
+ runFunction: util.RUN_FUNCTION_NAME.API_REQUEST,
137
+ message: {
138
+ url: normalizedUrl.toString(),
139
+ options
140
+ }
141
+ }) : yield fetch(normalizedUrl.toString(), options);
122
142
  } catch (error) {
123
143
  throw new util.AuthmeError(util.ErrorCode.NETWORK_ERROR, error);
124
144
  }
@@ -566,10 +586,6 @@ Object.defineProperty(exports, 'ErrorCode', {
566
586
  enumerable: true,
567
587
  get: function () { return util.ErrorCode; }
568
588
  });
569
- Object.defineProperty(exports, 'debugLog', {
570
- enumerable: true,
571
- get: function () { return util.debugLog; }
572
- });
573
589
  exports.EventListenerService = EventListenerService;
574
590
  exports.TrackingEvent = TrackingEvent;
575
591
  exports.core = core;
@@ -579,5 +595,6 @@ exports.getSessionId = getSessionId;
579
595
  exports.getTranslateInstance = getTranslateInstance;
580
596
  exports.sendRequest = sendRequest;
581
597
  exports.setAccessToken = setAccessToken;
598
+ exports.setRequestLoggingFunc = setRequestLoggingFunc;
582
599
  exports.setSessionId = setSessionId;
583
600
  exports.version = version;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { Storage, getUserAgent, AuthmeError, ErrorCode, STORAGE_KEY, decodeToken, useState, getDeviceInfo, getSystemInfo } from '@authme/util';
2
- export { AuthmeError, ErrorCode, debugLog } from '@authme/util';
1
+ import { Storage, getUserAgent, RUN_FUNCTION_NAME, AuthmeError, ErrorCode, STORAGE_KEY, decodeToken, useState, getDeviceInfo, getSystemInfo } from '@authme/util';
2
+ export { AuthmeError, ErrorCode } from '@authme/util';
3
3
  import 'core-js/modules/es.object.assign.js';
4
4
  import 'core-js/modules/es.regexp.to-string.js';
5
5
  import 'core-js/modules/es.array.iterator.js';
@@ -46,7 +46,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
46
46
  }
47
47
 
48
48
  var name = "@authme/core";
49
- var version$1 = "2.4.2";
49
+ var version$1 = "2.4.6";
50
50
  var peerDependencies = {
51
51
  "core-js": "^3.6.0"
52
52
  };
@@ -62,6 +62,19 @@ const version = packageInfo.version;
62
62
  (_a = (_b = window)[_c = Symbol.for('authme-sdk')]) !== null && _a !== void 0 ? _a : _b[_c] = {};
63
63
  window[Symbol.for('authme-sdk')][packageInfo.name] = version;
64
64
 
65
+ function requestLoggingWapper() {
66
+ let loggingFuncInstance = undefined;
67
+ return {
68
+ setRequestLoggingFunc: func => {
69
+ loggingFuncInstance = func;
70
+ },
71
+ getRequestLoggingFunc: () => loggingFuncInstance
72
+ };
73
+ }
74
+ const {
75
+ setRequestLoggingFunc,
76
+ getRequestLoggingFunc
77
+ } = requestLoggingWapper();
65
78
  function tryLoadAndParseJsonAsync(response) {
66
79
  return __awaiter(this, void 0, void 0, function* () {
67
80
  try {
@@ -99,6 +112,7 @@ function sendRequest(url, method = 'GET', {
99
112
  sdkInfo = [`sdk-version: ${version}`, getUserAgent()].join(';')
100
113
  } = {}) {
101
114
  return __awaiter(this, void 0, void 0, function* () {
115
+ const requestLoggingFunction = getRequestLoggingFunc();
102
116
  const options = Object.assign(Object.assign({
103
117
  method
104
118
  }, typeof body !== undefined ? {
@@ -115,7 +129,13 @@ function sendRequest(url, method = 'GET', {
115
129
  let resp;
116
130
  try {
117
131
  const normalizedUrl = baseUrl ? new URL(url, baseUrl).toString() : url;
118
- resp = yield fetch(normalizedUrl.toString(), options);
132
+ resp = requestLoggingFunction ? yield requestLoggingFunction(() => fetch(normalizedUrl.toString(), options), {
133
+ runFunction: RUN_FUNCTION_NAME.API_REQUEST,
134
+ message: {
135
+ url: normalizedUrl.toString(),
136
+ options
137
+ }
138
+ }) : yield fetch(normalizedUrl.toString(), options);
119
139
  } catch (error) {
120
140
  throw new AuthmeError(ErrorCode.NETWORK_ERROR, error);
121
141
  }
@@ -555,4 +575,4 @@ function generateStatus(params = {}) {
555
575
  };
556
576
  }
557
577
 
558
- export { AuthmeLanguage, EventListenerService, Feature, StatusAction, StatusDescription, StatusEvent, StatusView, TrackingEvent, core, generateStatus, getAccessToken, getSessionId, getTranslateInstance, sendRequest, setAccessToken, setSessionId, version };
578
+ export { AuthmeLanguage, EventListenerService, Feature, StatusAction, StatusDescription, StatusEvent, StatusView, TrackingEvent, core, generateStatus, getAccessToken, getSessionId, getTranslateInstance, sendRequest, setAccessToken, setRequestLoggingFunc, setSessionId, version };
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@authme/core",
3
- "version": "2.4.2",
3
+ "version": "2.4.6",
4
4
  "peerDependencies": {
5
5
  "core-js": "^3.6.0",
6
- "@authme/util": "2.4.2",
6
+ "@authme/util": "2.4.6",
7
7
  "rxjs": "7.5.7",
8
8
  "uuid": "8.3.2"
9
9
  },
package/src/index.d.ts CHANGED
@@ -2,7 +2,6 @@ export * from './lib/core';
2
2
  export * from './lib/model';
3
3
  export * from './lib/data-access';
4
4
  export * from './lib/translate';
5
- export * from './lib/authme-log';
6
5
  export * from './lib/enum/language.enum';
7
6
  export * from './lib/features';
8
7
  export { version } from './lib/version';
@@ -1,3 +1,7 @@
1
+ import { DebugLog } from '@authme/util';
2
+ declare type LoggingFunc = (fun: () => Promise<any>, logParams?: Partial<DebugLog<any>>) => Promise<any>;
3
+ declare const setRequestLoggingFunc: (func: LoggingFunc) => void;
4
+ export { setRequestLoggingFunc };
1
5
  export interface RequestOptions {
2
6
  header: {
3
7
  [header: string]: string;
@@ -1 +0,0 @@
1
- export { debugLog } from '@authme/util';