@webority/mobile-support 0.0.12 → 0.0.13

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.
@@ -3,7 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.toSupportApiError = exports.encodeBase64 = exports.createSupportClient = exports.SupportApiError = exports.OFFLINE_MESSAGE = exports.GENERIC_MESSAGE = void 0;
6
+ exports.toSupportApiError = exports.createSupportClient = exports.SupportApiError = exports.OFFLINE_MESSAGE = exports.GENERIC_MESSAGE = void 0;
7
+ var _mobileCore = require("@webority/mobile-core");
7
8
  /**
8
9
  * The slice of an HTTP client the support client needs. The app's signed-in
9
10
  * axios instance (mobile-core's `userClient`, or its own) satisfies it as is, so
@@ -56,22 +57,6 @@ const UPLOAD_TIMEOUT_MS = 300000;
56
57
  const MULTIPART = {
57
58
  'Content-Type': 'multipart/form-data'
58
59
  };
59
- const B64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
60
- const encodeBase64 = buffer => {
61
- const bytes = new Uint8Array(buffer);
62
- let out = '';
63
- for (let i = 0; i < bytes.length; i += 3) {
64
- const b0 = bytes[i];
65
- const b1 = i + 1 < bytes.length ? bytes[i + 1] : undefined;
66
- const b2 = i + 2 < bytes.length ? bytes[i + 2] : undefined;
67
- out += B64[b0 >> 2];
68
- out += B64[(b0 & 0x03) << 4 | (b1 ?? 0) >> 4];
69
- out += b1 === undefined ? '=' : B64[(b1 & 0x0f) << 2 | (b2 ?? 0) >> 6];
70
- out += b2 === undefined ? '=' : B64[b2 & 0x3f];
71
- }
72
- return out;
73
- };
74
- exports.encodeBase64 = encodeBase64;
75
60
  const appendParts = (form, field, parts) => {
76
61
  for (const part of parts ?? []) {
77
62
  // React Native's FormData takes a { uri, name, type } object as a file part.
@@ -153,7 +138,7 @@ const createSupportClient = (http, basePath = '/api/support') => {
153
138
  getAttachmentBytes: getBytes,
154
139
  getAttachmentDataUri: async attachment => {
155
140
  const bytes = await getBytes(attachment.id);
156
- return `data:${attachment.contentType};base64,${encodeBase64(bytes)}`;
141
+ return `data:${attachment.contentType};base64,${(0, _mobileCore.encodeBase64)(bytes)}`;
157
142
  },
158
143
  confirmAction: token => call(() => http.post(`${base}/actions/confirm`, {
159
144
  token
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ import { encodeBase64 } from '@webority/mobile-core';
4
+
3
5
  /**
4
6
  * The slice of an HTTP client the support client needs. The app's signed-in
5
7
  * axios instance (mobile-core's `userClient`, or its own) satisfies it as is, so
@@ -50,21 +52,6 @@ const UPLOAD_TIMEOUT_MS = 300000;
50
52
  const MULTIPART = {
51
53
  'Content-Type': 'multipart/form-data'
52
54
  };
53
- const B64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
54
- export const encodeBase64 = buffer => {
55
- const bytes = new Uint8Array(buffer);
56
- let out = '';
57
- for (let i = 0; i < bytes.length; i += 3) {
58
- const b0 = bytes[i];
59
- const b1 = i + 1 < bytes.length ? bytes[i + 1] : undefined;
60
- const b2 = i + 2 < bytes.length ? bytes[i + 2] : undefined;
61
- out += B64[b0 >> 2];
62
- out += B64[(b0 & 0x03) << 4 | (b1 ?? 0) >> 4];
63
- out += b1 === undefined ? '=' : B64[(b1 & 0x0f) << 2 | (b2 ?? 0) >> 6];
64
- out += b2 === undefined ? '=' : B64[b2 & 0x3f];
65
- }
66
- return out;
67
- };
68
55
  const appendParts = (form, field, parts) => {
69
56
  for (const part of parts ?? []) {
70
57
  // React Native's FormData takes a { uri, name, type } object as a file part.
@@ -32,7 +32,6 @@ export declare class SupportApiError extends Error {
32
32
  }
33
33
  /** Turns whatever the HTTP client threw into a SupportApiError. */
34
34
  export declare const toSupportApiError: (error: unknown) => SupportApiError;
35
- export declare const encodeBase64: (buffer: ArrayBuffer) => string;
36
35
  export interface SupportClient {
37
36
  readonly basePath: string;
38
37
  getConfig(): Promise<SupportContactInfo>;
@@ -32,7 +32,6 @@ export declare class SupportApiError extends Error {
32
32
  }
33
33
  /** Turns whatever the HTTP client threw into a SupportApiError. */
34
34
  export declare const toSupportApiError: (error: unknown) => SupportApiError;
35
- export declare const encodeBase64: (buffer: ArrayBuffer) => string;
36
35
  export interface SupportClient {
37
36
  readonly basePath: string;
38
37
  getConfig(): Promise<SupportContactInfo>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/mobile-support",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "description": "Customer support tickets for Webority React Native apps: the support API client, hooks, ticket screens, contact card and a report-an-issue button that attaches a screenshot.",
5
5
  "keywords": [
6
6
  "react-native",
@@ -70,7 +70,7 @@
70
70
  "typecheck": "tsc --noEmit"
71
71
  },
72
72
  "peerDependencies": {
73
- "@webority/mobile-core": ">=0.0.26 <0.1.0",
73
+ "@webority/mobile-core": ">=0.0.27 <0.1.0",
74
74
  "@webority/mobile-ui": ">=0.0.36 <0.1.0",
75
75
  "expo": ">=57.0.0",
76
76
  "expo-clipboard": ">=57.0.0",