@gopherium/react-auth 0.6.0 → 0.7.0

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.
@@ -130,24 +130,24 @@ async function restSetUserRole(id, role) {
130
130
  if (response.status === 401) {
131
131
  throw new UnauthorizedError('session expired');
132
132
  }
133
- const refusal = await refusalOf(response);
134
- if (refusal.code === 'role_insufficient') {
135
- throw new RoleRefusedError(refusal.message);
133
+ const failed = await errorOf(response);
134
+ if (failed.code === 'role_insufficient') {
135
+ throw new RoleRefusedError(failed.message);
136
136
  }
137
- if (refusal.code === 'self_role_refused') {
138
- throw new SelfRoleError(refusal.message);
137
+ if (failed.code === 'self_role_refused') {
138
+ throw new SelfRoleError(failed.message);
139
139
  }
140
- if (refusal.code === 'last_privileged_refused') {
141
- throw new LastPrivilegedError(refusal.message);
140
+ if (failed.code === 'last_privileged_refused') {
141
+ throw new LastPrivilegedError(failed.message);
142
142
  }
143
143
  throw new Error(`updating role failed with status ${response.status}`);
144
144
  }
145
145
  /**
146
146
  * Returns the code and message a refused response carries.
147
147
  * @param response - The refused HTTP response.
148
- * @returns The refusal code, if any, and its message.
148
+ * @returns The error code, if any, and its message.
149
149
  */
150
- async function refusalOf(response) {
150
+ async function errorOf(response) {
151
151
  try {
152
152
  const held = errorSchema.parse(await response.json());
153
153
  return { code: held.code, message: held.error };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gopherium/react-auth",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Session authentication for React apps backed by gouncer's authkit.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -48,7 +48,7 @@
48
48
  },
49
49
  "peerDependencies": {
50
50
  "@tanstack/react-query": "^5.101.2",
51
- "@testing-library/jest-dom": "^6.9.1",
51
+ "@testing-library/jest-dom": "^6.9.1 || ^7.0.0",
52
52
  "@testing-library/react": "^16.3.2",
53
53
  "@wordpress/i18n": ">=6.26.0 <7.0.0",
54
54
  "@wordpress/theme": ">=1.0.0 <2.0.0",
@@ -79,7 +79,7 @@
79
79
  },
80
80
  "devDependencies": {
81
81
  "@tanstack/react-query": "^5.101.2",
82
- "@testing-library/jest-dom": "^6.9.1",
82
+ "@testing-library/jest-dom": "^7.0.0",
83
83
  "@testing-library/react": "^16.3.2",
84
84
  "@testing-library/user-event": "^14.6.1",
85
85
  "@types/gettext-parser": "9.0.0",