@voiceflow/api-sdk 1.38.1 → 1.40.2
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/build/client.d.ts +1 -1
- package/build/client.js +3 -3
- package/build/client.js.map +1 -1
- package/build/index.d.ts +6 -8
- package/build/index.js +5 -14
- package/build/index.js.map +1 -1
- package/build/publicclient.d.ts +5 -3
- package/build/publicclient.js +2 -2
- package/build/publicclient.js.map +1 -1
- package/build/resources/analytics.d.ts +13 -4
- package/build/resources/analytics.js +39 -7
- package/build/resources/analytics.js.map +1 -1
- package/build/resources/fetcher.d.ts +12 -5
- package/build/resources/fetcher.js +3 -2
- package/build/resources/fetcher.js.map +1 -1
- package/build/resources/user.js +2 -7
- package/build/resources/user.js.map +1 -1
- package/build/utils/index.d.ts +1 -0
- package/build/utils/index.js +14 -0
- package/build/utils/index.js.map +1 -0
- package/build/utils/struct.d.ts +4 -0
- package/build/{utils.js → utils/struct.js} +2 -6
- package/build/utils/struct.js.map +1 -0
- package/package.json +3 -4
- package/build/utils.d.ts +0 -5
- package/build/utils.js.map +0 -1
package/build/client.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ClientOptions, PublicClient } from "./publicclient";
|
|
|
2
2
|
import { User } from "./resources";
|
|
3
3
|
export declare class Client extends PublicClient {
|
|
4
4
|
user: User;
|
|
5
|
-
constructor(
|
|
5
|
+
constructor(options: Omit<ClientOptions, 'authorization'> & {
|
|
6
6
|
authorization: string;
|
|
7
7
|
});
|
|
8
8
|
}
|
package/build/client.js
CHANGED
|
@@ -4,9 +4,9 @@ exports.Client = void 0;
|
|
|
4
4
|
const publicclient_1 = require("./publicclient");
|
|
5
5
|
const resources_1 = require("./resources");
|
|
6
6
|
class Client extends publicclient_1.PublicClient {
|
|
7
|
-
constructor(
|
|
8
|
-
super(
|
|
9
|
-
this.user = new resources_1.User(authorization);
|
|
7
|
+
constructor(options) {
|
|
8
|
+
super(options);
|
|
9
|
+
this.user = new resources_1.User(options.authorization);
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
exports.Client = Client;
|
package/build/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,iDAA6D;AAC7D,2CAAmC;AAEnC,MAAa,MAAO,SAAQ,2BAAY;IAGtC,YAAY,
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,iDAA6D;AAC7D,2CAAmC;AAEnC,MAAa,MAAO,SAAQ,2BAAY;IAGtC,YAAY,OAAyE;QACnF,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,CAAC,IAAI,GAAG,IAAI,gBAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAC9C,CAAC;CACF;AARD,wBAQC"}
|
package/build/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as s from 'superstruct';
|
|
2
2
|
import { Client } from "./client";
|
|
3
|
-
import
|
|
4
|
-
import { PublicClient } from "./publicclient";
|
|
3
|
+
import { ClientOptions, PublicClient } from "./publicclient";
|
|
5
4
|
export { Client } from "./client";
|
|
6
5
|
export * from "./models";
|
|
7
6
|
export { PublicClient } from "./publicclient";
|
|
@@ -13,10 +12,9 @@ export declare const SParams: s.Struct<{
|
|
|
13
12
|
clientKey: s.Struct<string, any>;
|
|
14
13
|
apiEndpoint: s.Struct<string, any>;
|
|
15
14
|
}>;
|
|
16
|
-
export declare type Options =
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
export declare type Params = s.StructType<typeof SParams> & Options;
|
|
15
|
+
export declare type Options = Pick<ClientOptions, 'options' | 'analyticsEncryption'>;
|
|
16
|
+
export interface Params extends s.StructType<typeof SParams>, Options {
|
|
17
|
+
}
|
|
20
18
|
export declare const SGenerateClientParams: s.Struct<{
|
|
21
19
|
authorization: string;
|
|
22
20
|
}, any>;
|
|
@@ -24,7 +22,7 @@ declare class ApiSDK {
|
|
|
24
22
|
private clientKey;
|
|
25
23
|
private apiEndpoint;
|
|
26
24
|
constructor({ clientKey, apiEndpoint }: Params);
|
|
27
|
-
generatePublicClient(
|
|
28
|
-
generateClient(
|
|
25
|
+
generatePublicClient(options?: Options): PublicClient;
|
|
26
|
+
generateClient(options: s.StructType<typeof SGenerateClientParams> & Options): Client;
|
|
29
27
|
}
|
|
30
28
|
export default ApiSDK;
|
package/build/index.js
CHANGED
|
@@ -40,21 +40,12 @@ class ApiSDK {
|
|
|
40
40
|
this.clientKey = clientKey;
|
|
41
41
|
this.apiEndpoint = apiEndpoint;
|
|
42
42
|
}
|
|
43
|
-
generatePublicClient(
|
|
44
|
-
return new publicclient_1.PublicClient({
|
|
45
|
-
options,
|
|
46
|
-
clientKey: this.clientKey,
|
|
47
|
-
apiEndpoint: this.apiEndpoint,
|
|
48
|
-
});
|
|
43
|
+
generatePublicClient(options = {}) {
|
|
44
|
+
return new publicclient_1.PublicClient(Object.assign(Object.assign({}, options), { clientKey: this.clientKey, apiEndpoint: this.apiEndpoint }));
|
|
49
45
|
}
|
|
50
|
-
generateClient(
|
|
51
|
-
s.assert({ authorization }, exports.SGenerateClientParams);
|
|
52
|
-
return new client_1.Client({
|
|
53
|
-
clientKey: this.clientKey,
|
|
54
|
-
options,
|
|
55
|
-
apiEndpoint: this.apiEndpoint,
|
|
56
|
-
authorization,
|
|
57
|
-
});
|
|
46
|
+
generateClient(options) {
|
|
47
|
+
s.assert({ authorization: options.authorization }, exports.SGenerateClientParams);
|
|
48
|
+
return new client_1.Client(Object.assign(Object.assign({}, options), { clientKey: this.clientKey, apiEndpoint: this.apiEndpoint }));
|
|
58
49
|
}
|
|
59
50
|
}
|
|
60
51
|
exports.default = ApiSDK;
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":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@
|
|
|
1
|
+
import { Crypto } from '@voiceflow/common';
|
|
1
2
|
import Fetch, { FetchConfig } from "./fetch";
|
|
2
3
|
import { Analytics, APIKey, Diagram, Program, Project, PrototypeProgram, Version } from "./resources";
|
|
3
|
-
export
|
|
4
|
+
export interface ClientOptions {
|
|
4
5
|
options?: FetchConfig;
|
|
5
6
|
clientKey: string;
|
|
6
7
|
apiEndpoint: string;
|
|
7
8
|
authorization?: string;
|
|
8
|
-
|
|
9
|
+
analyticsEncryption?: Crypto.Synchronous;
|
|
10
|
+
}
|
|
9
11
|
export declare class PublicClient {
|
|
10
12
|
fetch: Fetch;
|
|
11
13
|
project: Project;
|
|
@@ -15,5 +17,5 @@ export declare class PublicClient {
|
|
|
15
17
|
analytics: Analytics;
|
|
16
18
|
apiKey: APIKey;
|
|
17
19
|
prototypeProgram: PrototypeProgram;
|
|
18
|
-
constructor({ clientKey, apiEndpoint, authorization, options }: ClientOptions);
|
|
20
|
+
constructor({ clientKey, apiEndpoint, authorization, options, analyticsEncryption }: ClientOptions);
|
|
19
21
|
}
|
package/build/publicclient.js
CHANGED
|
@@ -7,14 +7,14 @@ exports.PublicClient = void 0;
|
|
|
7
7
|
const fetch_1 = __importDefault(require("./fetch"));
|
|
8
8
|
const resources_1 = require("./resources");
|
|
9
9
|
class PublicClient {
|
|
10
|
-
constructor({ clientKey, apiEndpoint, authorization, options }) {
|
|
10
|
+
constructor({ clientKey, apiEndpoint, authorization, options, analyticsEncryption }) {
|
|
11
11
|
this.fetch = new fetch_1.default({ clientKey, apiEndpoint, authorization, options });
|
|
12
12
|
this.apiKey = new resources_1.APIKey(this.fetch);
|
|
13
13
|
this.project = new resources_1.Project(this.fetch);
|
|
14
14
|
this.version = new resources_1.Version(this.fetch);
|
|
15
15
|
this.program = new resources_1.Program(this.fetch);
|
|
16
16
|
this.diagram = new resources_1.Diagram(this.fetch);
|
|
17
|
-
this.analytics = new resources_1.Analytics(this.fetch);
|
|
17
|
+
this.analytics = new resources_1.Analytics(this.fetch, { encryption: analyticsEncryption });
|
|
18
18
|
this.prototypeProgram = new resources_1.PrototypeProgram(this.fetch);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publicclient.js","sourceRoot":"","sources":["../src/publicclient.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"publicclient.js","sourceRoot":"","sources":["../src/publicclient.ts"],"names":[],"mappings":";;;;;;AAEA,oDAA6C;AAC7C,2CAAsG;AAUtG,MAAa,YAAY;IAiBvB,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,OAAO,EAAE,mBAAmB,EAAiB;QAChG,IAAI,CAAC,KAAK,GAAG,IAAI,eAAK,CAAC,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC,CAAC;QAE3E,IAAI,CAAC,MAAM,GAAG,IAAI,kBAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACrC,IAAI,CAAC,OAAO,GAAG,IAAI,mBAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvC,IAAI,CAAC,OAAO,GAAG,IAAI,mBAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvC,IAAI,CAAC,OAAO,GAAG,IAAI,mBAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvC,IAAI,CAAC,OAAO,GAAG,IAAI,mBAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvC,IAAI,CAAC,SAAS,GAAG,IAAI,qBAAS,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,UAAU,EAAE,mBAAmB,EAAE,CAAC,CAAC;QAChF,IAAI,CAAC,gBAAgB,GAAG,IAAI,4BAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3D,CAAC;CACF;AA5BD,oCA4BC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { Crypto } from '@voiceflow/common';
|
|
1
2
|
import type Fetch from "../fetch";
|
|
2
3
|
import Fetcher from './fetcher';
|
|
3
4
|
interface HashOptions<K> {
|
|
5
|
+
envIDs?: K[];
|
|
4
6
|
hashed?: K[];
|
|
5
7
|
teamhashed?: K[];
|
|
6
8
|
}
|
|
@@ -10,10 +12,17 @@ interface TrackOptions<P extends Record<string, any>, K extends keyof P> extends
|
|
|
10
12
|
interface IdentifyOptions<T extends Record<string, any>, K extends keyof T> extends HashOptions<K> {
|
|
11
13
|
traits: T;
|
|
12
14
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
interface AnalyticsOptions {
|
|
16
|
+
encryption?: Crypto.Synchronous;
|
|
17
|
+
}
|
|
18
|
+
declare class Analytics extends Fetcher<Analytics, AnalyticsOptions> {
|
|
19
|
+
private encryption?;
|
|
20
|
+
constructor(fetch: Fetch, options?: AnalyticsOptions);
|
|
21
|
+
private get shouldEncrypt();
|
|
22
|
+
private encryptedPayload;
|
|
23
|
+
protected _getEndpoint(): string;
|
|
24
|
+
track<P extends Record<string, any>, K extends keyof P>(event: string, { envIDs, hashed, teamhashed, properties }?: TrackOptions<P, K>): Promise<void>;
|
|
25
|
+
identify<T extends Record<string, any>, K extends keyof T>({ envIDs, traits, hashed, teamhashed, }: IdentifyOptions<T, K>): Promise<void>;
|
|
17
26
|
identifyWorkspace<T extends {
|
|
18
27
|
name: string;
|
|
19
28
|
}>(id: string, properties: T): Promise<void>;
|
|
@@ -5,18 +5,50 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const fetcher_1 = __importDefault(require("./fetcher"));
|
|
7
7
|
const ENDPOINT = 'analytics';
|
|
8
|
+
const ENCRYPTED_ENDPOINT = 'vf-ping';
|
|
8
9
|
class Analytics extends fetcher_1.default {
|
|
9
|
-
constructor(fetch) {
|
|
10
|
-
super({ fetch, clazz: Analytics, endpoint: ENDPOINT });
|
|
10
|
+
constructor(fetch, options = {}) {
|
|
11
|
+
super({ fetch, clazz: Analytics, endpoint: ENDPOINT, clazzOptions: options });
|
|
12
|
+
this.encryption = options.encryption;
|
|
11
13
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
get shouldEncrypt() {
|
|
15
|
+
return !!this.encryption;
|
|
14
16
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
encryptedPayload(data) {
|
|
18
|
+
if (!this.encryption) {
|
|
19
|
+
throw new Error('Encryption should be provided!');
|
|
20
|
+
}
|
|
21
|
+
return { message: this.encryption.encryptJSON(data) };
|
|
22
|
+
}
|
|
23
|
+
_getEndpoint() {
|
|
24
|
+
return this.shouldEncrypt ? ENCRYPTED_ENDPOINT : ENDPOINT;
|
|
25
|
+
}
|
|
26
|
+
async track(event, { envIDs, hashed, teamhashed, properties = {} } = {}) {
|
|
27
|
+
const payload = { event, envIDs, hashed, teamhashed, properties };
|
|
28
|
+
if (this.shouldEncrypt) {
|
|
29
|
+
await this.fetch.post(`${this._getEndpoint()}`, this.encryptedPayload(payload));
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
await this.fetch.post(`${this._getEndpoint()}/track`, payload);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async identify({ envIDs, traits, hashed, teamhashed, }) {
|
|
36
|
+
const payload = { traits, envIDs, hashed, teamhashed };
|
|
37
|
+
if (this.shouldEncrypt) {
|
|
38
|
+
await this.fetch.post(`${this._getEndpoint()}/user`, this.encryptedPayload(payload));
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
await this.fetch.post(`${this._getEndpoint()}/identify`, payload);
|
|
42
|
+
}
|
|
17
43
|
}
|
|
18
44
|
async identifyWorkspace(id, properties) {
|
|
19
|
-
|
|
45
|
+
const payload = Object.assign(Object.assign({}, properties), { id });
|
|
46
|
+
if (this.shouldEncrypt) {
|
|
47
|
+
await this.fetch.post(`${this._getEndpoint()}/workspace`, this.encryptedPayload(payload));
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
await this.fetch.post(`${this._getEndpoint()}/workspace/identify`, payload);
|
|
51
|
+
}
|
|
20
52
|
}
|
|
21
53
|
}
|
|
22
54
|
exports.default = Analytics;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics.js","sourceRoot":"","sources":["../../src/resources/analytics.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"analytics.js","sourceRoot":"","sources":["../../src/resources/analytics.ts"],"names":[],"mappings":";;;;;AAIA,wDAAgC;AAEhC,MAAM,QAAQ,GAAG,WAAW,CAAC;AAC7B,MAAM,kBAAkB,GAAG,SAAS,CAAC;AAoBrC,MAAM,SAAU,SAAQ,iBAAoC;IAG1D,YAAY,KAAY,EAAE,UAA4B,EAAE;QACtD,KAAK,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,CAAC;QAE9E,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IACvC,CAAC;IAED,IAAY,aAAa;QACvB,OAAO,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAEO,gBAAgB,CAAC,IAA6B;QACpD,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YACpB,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;SACnD;QAED,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;IACxD,CAAC;IAES,YAAY;QACpB,OAAO,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,QAAQ,CAAC;IAC5D,CAAC;IAEM,KAAK,CAAC,KAAK,CAChB,KAAa,EACb,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,EAAO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K,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,YAAY,EAAE,qBAAqB,EAAE,OAAO,CAAC,CAAC;SAC7E;IACH,CAAC;CACF;AAED,kBAAe,SAAS,CAAC"}
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import type Fetch from "../fetch";
|
|
2
|
-
|
|
2
|
+
declare type Clazz<Client, Options = undefined> = Options extends undefined ? new (fetch: Fetch) => Client : new (fetch: Fetch, options: Options) => Client;
|
|
3
|
+
interface BaseFetcherOptions<Client, Options = undefined> {
|
|
3
4
|
fetch: Fetch;
|
|
4
|
-
clazz:
|
|
5
|
+
clazz: Clazz<Client, Options>;
|
|
5
6
|
endpoint: string;
|
|
6
7
|
}
|
|
7
|
-
declare
|
|
8
|
+
export declare type FetcherOptions<Client, Options = undefined> = Options extends undefined ? BaseFetcherOptions<Client> & {
|
|
9
|
+
clazzOptions?: never;
|
|
10
|
+
} : BaseFetcherOptions<Client, Options> & {
|
|
11
|
+
clazzOptions: Options;
|
|
12
|
+
};
|
|
13
|
+
declare class Fetcher<Client, Options = undefined> {
|
|
8
14
|
private readonly clazz;
|
|
9
15
|
private endpoint;
|
|
16
|
+
private clazzOptions;
|
|
10
17
|
protected readonly fetch: Fetch;
|
|
11
|
-
constructor({ fetch, clazz, endpoint }: FetcherOptions<
|
|
18
|
+
constructor({ fetch, clazz, endpoint, clazzOptions }: FetcherOptions<Client, Options>);
|
|
12
19
|
protected _getEndpoint(): string;
|
|
13
|
-
options(options: Parameters<Fetch['initWithOptions']>[0]):
|
|
20
|
+
options(options: Parameters<Fetch['initWithOptions']>[0]): Client;
|
|
14
21
|
}
|
|
15
22
|
export default Fetcher;
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
class Fetcher {
|
|
4
|
-
constructor({ fetch, clazz, endpoint }) {
|
|
4
|
+
constructor({ fetch, clazz, endpoint, clazzOptions }) {
|
|
5
5
|
this.fetch = fetch;
|
|
6
6
|
this.clazz = clazz;
|
|
7
7
|
this.endpoint = endpoint;
|
|
8
|
+
this.clazzOptions = clazzOptions;
|
|
8
9
|
}
|
|
9
10
|
_getEndpoint() {
|
|
10
11
|
return this.endpoint;
|
|
11
12
|
}
|
|
12
13
|
options(options) {
|
|
13
14
|
const { clazz: Clazz } = this;
|
|
14
|
-
return new Clazz(this.fetch.initWithOptions(options));
|
|
15
|
+
return new Clazz(this.fetch.initWithOptions(options), this.clazzOptions);
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
18
|
exports.default = Fetcher;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetcher.js","sourceRoot":"","sources":["../../src/resources/fetcher.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"fetcher.js","sourceRoot":"","sources":["../../src/resources/fetcher.ts"],"names":[],"mappings":";;AAcA,MAAM,OAAO;IASX,YAAY,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAmC;QACnF,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,YAAY,GAAG,YAAuB,CAAC;IAC9C,CAAC;IAES,YAAY;QACpB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAEM,OAAO,CAAC,OAAgD;QAC7D,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;QAE9B,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAC3E,CAAC;CACF;AAED,kBAAe,OAAO,CAAC"}
|
package/build/resources/user.js
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.parseJWT = void 0;
|
|
7
|
-
const
|
|
8
|
-
const utils_1 = require("../utils");
|
|
4
|
+
const common_1 = require("@voiceflow/common");
|
|
9
5
|
const parseJWT = (token) => {
|
|
10
|
-
var _a;
|
|
11
6
|
const base64Url = token.split('.')[1];
|
|
12
7
|
if (!base64Url) {
|
|
13
8
|
throw new RangeError('Invalid JWT');
|
|
14
9
|
}
|
|
15
10
|
const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
|
|
16
|
-
const jsonPayload = decodeURIComponent(
|
|
11
|
+
const jsonPayload = decodeURIComponent(common_1.Crypto.Base64.decode(base64)
|
|
17
12
|
.split('')
|
|
18
13
|
.map((c) => `%${`00${c.charCodeAt(0).toString(16)}`.slice(-2)}`)
|
|
19
14
|
.join(''));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.js","sourceRoot":"","sources":["../../src/resources/user.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"user.js","sourceRoot":"","sources":["../../src/resources/user.ts"],"names":[],"mappings":";;;AAAA,8CAA2C;AAIpC,MAAM,QAAQ,GAAG,CAAI,KAAa,EAAK,EAAE;IAC9C,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAEtC,IAAI,CAAC,SAAS,EAAE;QACd,MAAM,IAAI,UAAU,CAAC,aAAa,CAAC,CAAC;KACrC;IAED,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC/D,MAAM,WAAW,GAAG,kBAAkB,CACpC,eAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;SACzB,KAAK,CAAC,EAAE,CAAC;SACT,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SAC/D,IAAI,CAAC,EAAE,CAAC,CACZ,CAAC;IAEF,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;AACjC,CAAC,CAAC;AAhBW,QAAA,QAAQ,YAgBnB;AASF,MAAM,IAAI;IAOR,YAAY,aAAqB;QAN1B,cAAS,GAAc,CAAC,CAAC;QAEzB,SAAI,GAAG,EAAE,CAAC;QAEV,UAAK,GAAG,EAAE,CAAC;QAGhB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE;YACjC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,gBAAQ,CAAY,aAAa,CAAC,CAAC;YAE/D,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;YACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;YACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;SACpB;IACH,CAAC;IAED,kDAAkD;IAClD,QAAQ,CAAC,aAAqB;QAC5B,OAAO,aAAa,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;CACF;AAED,kBAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './struct';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./struct"), exports);
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAyB"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as s from 'superstruct';
|
|
2
|
+
import type { BaseSchema, PutPostStruct, SchemeType } from "../types";
|
|
3
|
+
export declare const dynamicObject: <S extends BaseSchema>(schema: S) => s.Struct<Record<string, any> & import("../types").Flatten<{ [K_1 in import("@/types").RequiredKeys<{ [K in keyof S]: s.StructType<S[K]>; }>]: { [K in keyof S]: s.StructType<S[K]>; }[K_1]; } & { [K_2 in import("@/types").OptionalKeys<{ [K in keyof S]: s.StructType<S[K]>; }>]?: { [K in keyof S]: s.StructType<S[K]>; }[K_2] | undefined; }>, S>;
|
|
4
|
+
export declare const createPutAndPostStruct: <S extends BaseSchema, K_3 extends keyof import("../types").Flatten<{ [K_1 in import("@/types").RequiredKeys<{ [K in keyof S]: s.StructType<S[K]>; }>]: { [K in keyof S]: s.StructType<S[K]>; }[K_1]; } & { [K_2 in import("@/types").OptionalKeys<{ [K in keyof S]: s.StructType<S[K]>; }>]?: { [K in keyof S]: s.StructType<S[K]>; }[K_2] | undefined; }>, E extends keyof import("../types").Flatten<{ [K_1 in import("@/types").RequiredKeys<{ [K in keyof S]: s.StructType<S[K]>; }>]: { [K in keyof S]: s.StructType<S[K]>; }[K_1]; } & { [K_2 in import("@/types").OptionalKeys<{ [K in keyof S]: s.StructType<S[K]>; }>]?: { [K in keyof S]: s.StructType<S[K]>; }[K_2] | undefined; }> = never>(schema: S, idKey: K_3, excludedKeys: E[], isDynamic?: boolean | undefined) => PutPostStruct<S, K_3, E>;
|
|
@@ -19,7 +19,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.
|
|
22
|
+
exports.createPutAndPostStruct = exports.dynamicObject = void 0;
|
|
23
23
|
const s = __importStar(require("superstruct"));
|
|
24
24
|
const dynamicObject = (schema) => {
|
|
25
25
|
const Struct = s.object(schema);
|
|
@@ -49,8 +49,4 @@ const createPutAndPostStruct = (schema, idKey, excludedKeys, isDynamic) => {
|
|
|
49
49
|
: s.object(Object.assign(Object.assign({}, createScheme), { [idKey]: s.optional(schema[idKey]) }));
|
|
50
50
|
};
|
|
51
51
|
exports.createPutAndPostStruct = createPutAndPostStruct;
|
|
52
|
-
|
|
53
|
-
return typeof window === 'undefined' ? null : window;
|
|
54
|
-
};
|
|
55
|
-
exports.getWindow = getWindow;
|
|
56
|
-
//# sourceMappingURL=utils.js.map
|
|
52
|
+
//# sourceMappingURL=struct.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"struct.js","sourceRoot":"","sources":["../../src/utils/struct.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAiC;AAI1B,MAAM,aAAa,GAAG,CAAuB,MAAS,EAAoD,EAAE;IACjH,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAEhC,MAAM,CAAC,SAAS,GAAG,QAAQ,CAAC,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG;QAC/C,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAE1C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,IAAI,IAAI,EAAE;YAC9C,MAA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|
package/package.json
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voiceflow/api-sdk",
|
|
3
3
|
"description": "wrapper for creator-api",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.40.2",
|
|
5
5
|
"author": "Voiceflow",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/voiceflow/libs/issues"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@
|
|
11
|
-
"atob": "^2.1.2",
|
|
10
|
+
"@voiceflow/common": "6.8.1",
|
|
12
11
|
"axios": "^0.21.1",
|
|
13
12
|
"superstruct": "^0.10.12"
|
|
14
13
|
},
|
|
@@ -57,5 +56,5 @@
|
|
|
57
56
|
"test:unit": "NODE_ENV=test nyc --report-dir=nyc_coverage_unit ts-mocha --paths --config ./config/tests/.mocharc.json 'tests/**/*.unit.ts'"
|
|
58
57
|
},
|
|
59
58
|
"types": "build/index.d.ts",
|
|
60
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "1a82ee1a152801169af37a89a050433bdd535e88"
|
|
61
60
|
}
|
package/build/utils.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import * as s from 'superstruct';
|
|
2
|
-
import type { BaseSchema, PutPostStruct, SchemeType } from "./types";
|
|
3
|
-
export declare const dynamicObject: <S extends BaseSchema>(schema: S) => s.Struct<Record<string, any> & import("./types").Flatten<{ [K_1 in import("@/types").RequiredKeys<{ [K in keyof S]: s.StructType<S[K]>; }>]: { [K in keyof S]: s.StructType<S[K]>; }[K_1]; } & { [K_2 in import("@/types").OptionalKeys<{ [K in keyof S]: s.StructType<S[K]>; }>]?: { [K in keyof S]: s.StructType<S[K]>; }[K_2] | undefined; }>, S>;
|
|
4
|
-
export declare const createPutAndPostStruct: <S extends BaseSchema, K_3 extends keyof import("./types").Flatten<{ [K_1 in import("@/types").RequiredKeys<{ [K in keyof S]: s.StructType<S[K]>; }>]: { [K in keyof S]: s.StructType<S[K]>; }[K_1]; } & { [K_2 in import("@/types").OptionalKeys<{ [K in keyof S]: s.StructType<S[K]>; }>]?: { [K in keyof S]: s.StructType<S[K]>; }[K_2] | undefined; }>, E extends keyof import("./types").Flatten<{ [K_1 in import("@/types").RequiredKeys<{ [K in keyof S]: s.StructType<S[K]>; }>]: { [K in keyof S]: s.StructType<S[K]>; }[K_1]; } & { [K_2 in import("@/types").OptionalKeys<{ [K in keyof S]: s.StructType<S[K]>; }>]?: { [K in keyof S]: s.StructType<S[K]>; }[K_2] | undefined; }> = never>(schema: S, idKey: K_3, excludedKeys: E[], isDynamic?: boolean | undefined) => PutPostStruct<S, K_3, E>;
|
|
5
|
-
export declare const getWindow: () => (Window & typeof globalThis) | null;
|
package/build/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAiC;AAI1B,MAAM,aAAa,GAAG,CAAuB,MAAS,EAAoD,EAAE;IACjH,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAEhC,MAAM,CAAC,SAAS,GAAG,QAAQ,CAAC,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG;QAC/C,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAE1C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,IAAI,IAAI,EAAE;YAC9C,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;SAClB;aAAM;YACL,gDAAgD;YAChD,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE;gBACxB,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,GAAiC,CAAC,CAAC;gBAC/D,MAAM,CAAC,GAAG,KAAK,CAAC,GAAyB,CAAC,CAAC;gBAE3C,KAAK,CAAC,CAAC,G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