@autentikar/step 2.0.0-alpha.9 → 2.1.0-alpha.11
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/context.d.ts +7 -10
- package/dist/context.js +3 -17
- package/dist/index-vDg-Bas4.d.ts +246 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +217 -0
- package/package.json +9 -1
package/dist/context.d.ts
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
|
+
import { S as StorageItem, a as Step } from './index-vDg-Bas4.js';
|
|
2
|
+
import 'file-type/core';
|
|
3
|
+
import 'zod';
|
|
4
|
+
|
|
1
5
|
interface Storage {
|
|
2
6
|
save(name: string, content: Buffer, instance: string): Promise<StorageItem>;
|
|
3
7
|
get(key: string): Promise<StorageItem | undefined>;
|
|
4
8
|
}
|
|
5
|
-
type PersistentType = "FILESYSTEM" | "MONGODB" | "S3" | "NFS" | "S3-MRAP" | "CDN";
|
|
6
|
-
declare class StorageItem {
|
|
7
|
-
readonly path: string;
|
|
8
|
-
readonly type: PersistentType;
|
|
9
|
-
readonly buffer: Buffer;
|
|
10
|
-
readonly fileUrl: string;
|
|
11
|
-
constructor(path: string, type: PersistentType, buffer: Buffer, fileUrl: string);
|
|
12
|
-
getBase64(): string;
|
|
13
|
-
}
|
|
14
9
|
|
|
15
10
|
type KVKind = "INSTANCE" | "STEP";
|
|
16
11
|
interface KV {
|
|
@@ -28,8 +23,10 @@ interface Preference {
|
|
|
28
23
|
|
|
29
24
|
interface System {
|
|
30
25
|
get<TValue = unknown>(name: string): Promise<TValue | undefined>;
|
|
26
|
+
stage(): string;
|
|
31
27
|
}
|
|
32
28
|
|
|
29
|
+
declare let step: Step;
|
|
33
30
|
declare let params: Params;
|
|
34
31
|
/** @deprecated use system. */
|
|
35
32
|
declare let preference: Preference;
|
|
@@ -37,4 +34,4 @@ declare let system: System;
|
|
|
37
34
|
declare let kv: KV;
|
|
38
35
|
declare let asset: Storage;
|
|
39
36
|
|
|
40
|
-
export { type KV, type Params, type Preference, type Storage,
|
|
37
|
+
export { type KV, type Params, type Preference, Step, type Storage, type System, asset, kv, params, preference, step, system };
|
package/dist/context.js
CHANGED
|
@@ -20,29 +20,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/context.ts
|
|
21
21
|
var context_exports = {};
|
|
22
22
|
__export(context_exports, {
|
|
23
|
-
StorageItem: () => StorageItem,
|
|
24
23
|
asset: () => asset,
|
|
25
24
|
kv: () => kv,
|
|
26
25
|
params: () => params,
|
|
27
26
|
preference: () => preference,
|
|
27
|
+
step: () => step,
|
|
28
28
|
system: () => system
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(context_exports);
|
|
31
|
-
|
|
32
|
-
// src/type/asset.ts
|
|
33
|
-
var StorageItem = class {
|
|
34
|
-
constructor(path, type, buffer, fileUrl) {
|
|
35
|
-
this.path = path;
|
|
36
|
-
this.type = type;
|
|
37
|
-
this.buffer = buffer;
|
|
38
|
-
this.fileUrl = fileUrl;
|
|
39
|
-
}
|
|
40
|
-
getBase64() {
|
|
41
|
-
return this.buffer.toString("base64");
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
// src/context.ts
|
|
31
|
+
var step;
|
|
46
32
|
var params;
|
|
47
33
|
var preference;
|
|
48
34
|
var system;
|
|
@@ -50,10 +36,10 @@ var kv;
|
|
|
50
36
|
var asset;
|
|
51
37
|
// Annotate the CommonJS export names for ESM import in node:
|
|
52
38
|
0 && (module.exports = {
|
|
53
|
-
StorageItem,
|
|
54
39
|
asset,
|
|
55
40
|
kv,
|
|
56
41
|
params,
|
|
57
42
|
preference,
|
|
43
|
+
step,
|
|
58
44
|
system
|
|
59
45
|
});
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import * as file_type_core from 'file-type/core';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
interface Step {
|
|
5
|
+
params<TValue = unknown>(extend?: unknown): Promise<TValue | undefined>;
|
|
6
|
+
milestone(type: string, status: string, success: boolean): Promise<void>;
|
|
7
|
+
future(type: string, id: string, ttl: number): Promise<void>;
|
|
8
|
+
/** @deprecated Use addStepData*/
|
|
9
|
+
identity(organization_id: string, instance_id: string, link_session: string | undefined, identity: IdentityDto, data: StepIdentityData): Promise<any>;
|
|
10
|
+
addStepData(link_session: string | undefined, identity: IdentityDto, data: StepIdentityData): Promise<any>;
|
|
11
|
+
getStepData<T = StepIdentityData["type"]>(type: T, link_session: string | undefined): Promise<Extract<StepIdentityData, {
|
|
12
|
+
type: T;
|
|
13
|
+
}> | undefined>;
|
|
14
|
+
addVendorStat(params: {
|
|
15
|
+
vendor: string;
|
|
16
|
+
service: string;
|
|
17
|
+
amount?: number;
|
|
18
|
+
transaction_id: string;
|
|
19
|
+
meta?: Record<string, unknown>;
|
|
20
|
+
}): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface AutentikarRequestInit extends RequestInit {
|
|
24
|
+
host: string;
|
|
25
|
+
staging: Staging;
|
|
26
|
+
organization?: {
|
|
27
|
+
id: string;
|
|
28
|
+
alias: string;
|
|
29
|
+
};
|
|
30
|
+
step?: {
|
|
31
|
+
id: string;
|
|
32
|
+
};
|
|
33
|
+
flow?: {
|
|
34
|
+
id: string;
|
|
35
|
+
webhook: string | undefined;
|
|
36
|
+
};
|
|
37
|
+
instance?: {
|
|
38
|
+
id: string;
|
|
39
|
+
};
|
|
40
|
+
output?: Record<string, string>;
|
|
41
|
+
link_session: string | undefined;
|
|
42
|
+
params?: unknown;
|
|
43
|
+
}
|
|
44
|
+
declare class AutentikarRequest extends Request {
|
|
45
|
+
readonly organization?: AutentikarRequestInit["organization"];
|
|
46
|
+
readonly step?: AutentikarRequestInit["step"];
|
|
47
|
+
readonly instance?: AutentikarRequestInit["instance"];
|
|
48
|
+
readonly staging?: Staging;
|
|
49
|
+
readonly link_session: string | undefined;
|
|
50
|
+
readonly params?: unknown;
|
|
51
|
+
readonly output?: Record<string, string>;
|
|
52
|
+
readonly host?: string;
|
|
53
|
+
readonly flow: {
|
|
54
|
+
id: string;
|
|
55
|
+
webhook: string | undefined;
|
|
56
|
+
} | undefined;
|
|
57
|
+
constructor(input: RequestInfo, init?: AutentikarRequestInit);
|
|
58
|
+
}
|
|
59
|
+
interface AutentikarResponseInit extends ResponseInit {
|
|
60
|
+
success: boolean;
|
|
61
|
+
akStatus: string;
|
|
62
|
+
data: {
|
|
63
|
+
output: unknown;
|
|
64
|
+
} & Record<string, unknown>;
|
|
65
|
+
next: string | undefined;
|
|
66
|
+
error?: string;
|
|
67
|
+
}
|
|
68
|
+
declare class AutentikarResponse extends Response {
|
|
69
|
+
readonly success: boolean | undefined;
|
|
70
|
+
readonly akStatus: string | undefined;
|
|
71
|
+
readonly data: ({
|
|
72
|
+
output: unknown;
|
|
73
|
+
} & Record<string, unknown>) | undefined;
|
|
74
|
+
readonly next: string | undefined;
|
|
75
|
+
readonly error: string | undefined;
|
|
76
|
+
constructor(bodyInit?: BodyInit | null, init?: AutentikarResponseInit);
|
|
77
|
+
static json(data: any, init: AutentikarResponseInit): AutentikarResponse;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
type StepIdentityData = {
|
|
81
|
+
type: "SOURCE_FACE_2D";
|
|
82
|
+
face: string;
|
|
83
|
+
} | {
|
|
84
|
+
type: "DOCUMENT";
|
|
85
|
+
doc_type: IdentityDto["doc_type"];
|
|
86
|
+
images: {
|
|
87
|
+
front: string;
|
|
88
|
+
back?: string;
|
|
89
|
+
};
|
|
90
|
+
} | {
|
|
91
|
+
type: "CARD";
|
|
92
|
+
doc_type: IdentityDto["doc_type"];
|
|
93
|
+
images: {
|
|
94
|
+
face: string;
|
|
95
|
+
front: string;
|
|
96
|
+
back?: string;
|
|
97
|
+
};
|
|
98
|
+
} | {
|
|
99
|
+
type: "FACE";
|
|
100
|
+
provider: "FACETEC" | "IDENTY" | "2D" | ({} & string);
|
|
101
|
+
audit_low?: string;
|
|
102
|
+
audit: string;
|
|
103
|
+
map?: string;
|
|
104
|
+
} | {
|
|
105
|
+
type: "EMAIL";
|
|
106
|
+
email: string;
|
|
107
|
+
} | {
|
|
108
|
+
type: "CELLPHONE";
|
|
109
|
+
cellphone: string;
|
|
110
|
+
country?: string;
|
|
111
|
+
} | {
|
|
112
|
+
type: "CONSENT";
|
|
113
|
+
value: "OWN" | "AUTENTIKAR" | "NONE";
|
|
114
|
+
text?: string;
|
|
115
|
+
consent_id: string;
|
|
116
|
+
};
|
|
117
|
+
declare class StepRequest implements Step {
|
|
118
|
+
private step;
|
|
119
|
+
constructor(params: Step);
|
|
120
|
+
addStepData(link_session: string | undefined, identity: IdentityDto, data: StepIdentityData): Promise<any>;
|
|
121
|
+
getStepData<T = StepIdentityData["type"]>(type: T, link_session: string | undefined): Promise<Extract<StepIdentityData, {
|
|
122
|
+
type: T;
|
|
123
|
+
}> | undefined>;
|
|
124
|
+
addVendorStat(params: {
|
|
125
|
+
vendor: string;
|
|
126
|
+
service: string;
|
|
127
|
+
amount?: number;
|
|
128
|
+
transaction_id: string;
|
|
129
|
+
meta?: Record<string, unknown>;
|
|
130
|
+
}): Promise<void>;
|
|
131
|
+
future(type: string, id: string, ttl: number): Promise<void>;
|
|
132
|
+
milestone(type: string, status: string, success: boolean): Promise<void>;
|
|
133
|
+
params<TValue = unknown>(extend?: unknown): Promise<TValue | undefined>;
|
|
134
|
+
identity(organization_id: string, instance_id: string, link_session: string | undefined, identity: IdentityDto, data: StepIdentityData): Promise<any>;
|
|
135
|
+
}
|
|
136
|
+
declare const AppEnvironmentsSchema: z.ZodObject<{
|
|
137
|
+
STAGING: z.ZodEnum<["LOCAL", "QA", "PROD"]>;
|
|
138
|
+
STEP_TYPE: z.ZodString;
|
|
139
|
+
}, "strip", z.ZodTypeAny, {
|
|
140
|
+
STAGING: "LOCAL" | "QA" | "PROD";
|
|
141
|
+
STEP_TYPE: string;
|
|
142
|
+
}, {
|
|
143
|
+
STAGING: "LOCAL" | "QA" | "PROD";
|
|
144
|
+
STEP_TYPE: string;
|
|
145
|
+
}>;
|
|
146
|
+
declare const IdentitySchemaDto: z.ZodObject<{
|
|
147
|
+
country: z.ZodString;
|
|
148
|
+
doc_type: z.ZodString;
|
|
149
|
+
id_num: z.ZodString;
|
|
150
|
+
}, "strip", z.ZodTypeAny, {
|
|
151
|
+
country: string;
|
|
152
|
+
doc_type: string;
|
|
153
|
+
id_num: string;
|
|
154
|
+
}, {
|
|
155
|
+
country: string;
|
|
156
|
+
doc_type: string;
|
|
157
|
+
id_num: string;
|
|
158
|
+
}>;
|
|
159
|
+
type IdentityDto = z.infer<typeof IdentitySchemaDto>;
|
|
160
|
+
type AppEnvironments = z.infer<typeof AppEnvironmentsSchema>;
|
|
161
|
+
type Staging = AppEnvironments["STAGING"];
|
|
162
|
+
type MethodContextOrganization = {
|
|
163
|
+
id: string;
|
|
164
|
+
};
|
|
165
|
+
type MethodContextFlow = {
|
|
166
|
+
id: string;
|
|
167
|
+
webhook: string | undefined;
|
|
168
|
+
};
|
|
169
|
+
type MethodContextInstance = {
|
|
170
|
+
id: string;
|
|
171
|
+
};
|
|
172
|
+
type MethodContextStep = {
|
|
173
|
+
params: unknown;
|
|
174
|
+
};
|
|
175
|
+
type PersistentType = "FILESYSTEM" | "MONGODB" | "S3" | "NFS" | "S3-MRAP" | "CDN";
|
|
176
|
+
declare class StorageItem {
|
|
177
|
+
readonly path: string;
|
|
178
|
+
readonly type: PersistentType;
|
|
179
|
+
readonly buffer: Buffer;
|
|
180
|
+
readonly fileUrl: string;
|
|
181
|
+
readonly contentType: string | undefined;
|
|
182
|
+
constructor(path: string, type: PersistentType, buffer: Buffer, fileUrl: string, contentType: string | undefined);
|
|
183
|
+
getBase64(): string;
|
|
184
|
+
getContenType(): Promise<file_type_core.MimeType | "unknown">;
|
|
185
|
+
}
|
|
186
|
+
type Method = (req: AutentikarRequest) => Promise<AutentikarResponse>;
|
|
187
|
+
type Resource = (req: AutentikarRequest) => Promise<AutentikarResponse>;
|
|
188
|
+
type AppEnvVariables = {
|
|
189
|
+
instance: {
|
|
190
|
+
id: string;
|
|
191
|
+
session: string | undefined;
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
type AppEnv = {
|
|
195
|
+
Bindings: AppEnvironments;
|
|
196
|
+
Variables: AppEnvVariables;
|
|
197
|
+
};
|
|
198
|
+
declare class StepDefinition {
|
|
199
|
+
readonly id: string;
|
|
200
|
+
readonly type: string;
|
|
201
|
+
readonly prev_step: string;
|
|
202
|
+
readonly user_interaction: boolean;
|
|
203
|
+
readonly return_result: boolean;
|
|
204
|
+
readonly end_after_processing: undefined | {
|
|
205
|
+
dispatch: "NO";
|
|
206
|
+
} | {
|
|
207
|
+
dispatch: "AUTO";
|
|
208
|
+
};
|
|
209
|
+
readonly params: Record<string, string> | undefined;
|
|
210
|
+
readonly output: Record<string, string> | undefined;
|
|
211
|
+
readonly milestone: undefined | {
|
|
212
|
+
cloud_hidden?: boolean;
|
|
213
|
+
call_webhook?: boolean;
|
|
214
|
+
};
|
|
215
|
+
constructor(id: string, type: string, prev_step: string, user_interaction: boolean, return_result: boolean, end_after_processing: undefined | {
|
|
216
|
+
dispatch: "NO";
|
|
217
|
+
} | {
|
|
218
|
+
dispatch: "AUTO";
|
|
219
|
+
}, params: Record<string, string> | undefined, output: Record<string, string> | undefined, milestone: undefined | {
|
|
220
|
+
cloud_hidden?: boolean;
|
|
221
|
+
call_webhook?: boolean;
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
declare class StepInstance {
|
|
225
|
+
readonly id: string;
|
|
226
|
+
readonly expires_at: number | undefined;
|
|
227
|
+
constructor(id: string, expires_at: number | undefined);
|
|
228
|
+
isExpired(): boolean | 0 | undefined;
|
|
229
|
+
}
|
|
230
|
+
declare class FlowContext {
|
|
231
|
+
readonly id: string;
|
|
232
|
+
readonly webhook: string | undefined;
|
|
233
|
+
constructor(id: string, webhook: string | undefined);
|
|
234
|
+
}
|
|
235
|
+
declare class StepContext {
|
|
236
|
+
readonly org: string;
|
|
237
|
+
readonly flow: FlowContext;
|
|
238
|
+
readonly step: StepDefinition;
|
|
239
|
+
readonly instance: StepInstance;
|
|
240
|
+
readonly expires_at: number | undefined;
|
|
241
|
+
readonly params: unknown;
|
|
242
|
+
constructor(org: string, flow: FlowContext, step: StepDefinition, instance: StepInstance, expires_at: number | undefined, params: unknown);
|
|
243
|
+
isExpired(): boolean | 0 | undefined;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export { AutentikarRequest as A, FlowContext as F, IdentitySchemaDto as I, type MethodContextOrganization as M, type PersistentType as P, type Resource as R, StorageItem as S, type Step as a, AutentikarResponse as b, type StepIdentityData as c, StepRequest as d, type IdentityDto as e, type AppEnvironments as f, type Staging as g, type MethodContextFlow as h, type MethodContextInstance as i, type MethodContextStep as j, type Method as k, type AppEnvVariables as l, type AppEnv as m, StepDefinition as n, StepInstance as o, StepContext as p };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import 'file-type/core';
|
|
2
|
+
import 'zod';
|
|
3
|
+
export { m as AppEnv, l as AppEnvVariables, f as AppEnvironments, A as AutentikarRequest, b as AutentikarResponse, F as FlowContext, e as IdentityDto, I as IdentitySchemaDto, k as Method, h as MethodContextFlow, i as MethodContextInstance, M as MethodContextOrganization, j as MethodContextStep, P as PersistentType, R as Resource, g as Staging, p as StepContext, n as StepDefinition, c as StepIdentityData, o as StepInstance, d as StepRequest, S as StorageItem } from './index-vDg-Bas4.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
|
+
AutentikarRequest: () => AutentikarRequest,
|
|
34
|
+
AutentikarResponse: () => AutentikarResponse,
|
|
35
|
+
FlowContext: () => FlowContext,
|
|
36
|
+
IdentitySchemaDto: () => IdentitySchemaDto,
|
|
37
|
+
StepContext: () => StepContext,
|
|
38
|
+
StepDefinition: () => StepDefinition,
|
|
39
|
+
StepInstance: () => StepInstance,
|
|
40
|
+
StepRequest: () => StepRequest,
|
|
41
|
+
StorageItem: () => StorageItem
|
|
42
|
+
});
|
|
43
|
+
module.exports = __toCommonJS(src_exports);
|
|
44
|
+
var import_zod = require("zod");
|
|
45
|
+
var import_file_type = __toESM(require("file-type"));
|
|
46
|
+
|
|
47
|
+
// src/autentikar-fetch.ts
|
|
48
|
+
var AutentikarRequest = class extends Request {
|
|
49
|
+
organization;
|
|
50
|
+
step;
|
|
51
|
+
instance;
|
|
52
|
+
staging;
|
|
53
|
+
link_session;
|
|
54
|
+
params;
|
|
55
|
+
output;
|
|
56
|
+
host;
|
|
57
|
+
flow;
|
|
58
|
+
constructor(input, init) {
|
|
59
|
+
super(input, init);
|
|
60
|
+
this.organization = init?.organization;
|
|
61
|
+
this.step = init?.step;
|
|
62
|
+
this.instance = init?.instance;
|
|
63
|
+
this.staging = init?.staging;
|
|
64
|
+
this.link_session = init?.link_session;
|
|
65
|
+
this.params = init?.params;
|
|
66
|
+
this.output = init?.output;
|
|
67
|
+
this.host = init?.host;
|
|
68
|
+
this.flow = init?.flow;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
var AutentikarResponse = class _AutentikarResponse extends Response {
|
|
72
|
+
success;
|
|
73
|
+
akStatus;
|
|
74
|
+
data;
|
|
75
|
+
next;
|
|
76
|
+
error;
|
|
77
|
+
constructor(bodyInit, init) {
|
|
78
|
+
super(bodyInit, init);
|
|
79
|
+
this.success = init?.success;
|
|
80
|
+
this.akStatus = init?.akStatus;
|
|
81
|
+
this.data = init?.data;
|
|
82
|
+
this.next = init?.next;
|
|
83
|
+
this.error = init?.error;
|
|
84
|
+
}
|
|
85
|
+
static json(data, init) {
|
|
86
|
+
const body = JSON.stringify(data);
|
|
87
|
+
const headers = new Headers(init.headers || {});
|
|
88
|
+
headers.set("Content-Type", "application/json");
|
|
89
|
+
return new _AutentikarResponse(body, {
|
|
90
|
+
...init,
|
|
91
|
+
headers
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
// src/index.ts
|
|
97
|
+
var StepRequest = class {
|
|
98
|
+
step;
|
|
99
|
+
constructor(params) {
|
|
100
|
+
this.step = params;
|
|
101
|
+
}
|
|
102
|
+
async addStepData(link_session, identity, data) {
|
|
103
|
+
return this.step.addStepData(link_session, identity, data);
|
|
104
|
+
}
|
|
105
|
+
async getStepData(type, link_session) {
|
|
106
|
+
return this.step.getStepData(type, link_session);
|
|
107
|
+
}
|
|
108
|
+
addVendorStat(params) {
|
|
109
|
+
return this.step.addVendorStat(params);
|
|
110
|
+
}
|
|
111
|
+
future(type, id, ttl) {
|
|
112
|
+
return this.step.future(type, id, ttl);
|
|
113
|
+
}
|
|
114
|
+
milestone(type, status, success) {
|
|
115
|
+
return this.step.milestone(type, status, success);
|
|
116
|
+
}
|
|
117
|
+
params(extend) {
|
|
118
|
+
return this.step.params(extend);
|
|
119
|
+
}
|
|
120
|
+
identity(organization_id, instance_id, link_session, identity, data) {
|
|
121
|
+
return this.step.identity(
|
|
122
|
+
organization_id,
|
|
123
|
+
instance_id,
|
|
124
|
+
link_session,
|
|
125
|
+
identity,
|
|
126
|
+
data
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
var AppEnvironmentsSchema = import_zod.z.object({
|
|
131
|
+
STAGING: import_zod.z.enum(["LOCAL", "QA", "PROD"]),
|
|
132
|
+
STEP_TYPE: import_zod.z.string()
|
|
133
|
+
});
|
|
134
|
+
var IdentitySchemaDto = import_zod.z.object({
|
|
135
|
+
country: import_zod.z.string(),
|
|
136
|
+
doc_type: import_zod.z.string(),
|
|
137
|
+
id_num: import_zod.z.string()
|
|
138
|
+
});
|
|
139
|
+
async function getContentTypeFromBuffer(buffer) {
|
|
140
|
+
const type = await import_file_type.default.fromBuffer(buffer);
|
|
141
|
+
if (type) {
|
|
142
|
+
return type.mime;
|
|
143
|
+
} else {
|
|
144
|
+
return "unknown";
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
var StorageItem = class {
|
|
148
|
+
constructor(path, type, buffer, fileUrl, contentType) {
|
|
149
|
+
this.path = path;
|
|
150
|
+
this.type = type;
|
|
151
|
+
this.buffer = buffer;
|
|
152
|
+
this.fileUrl = fileUrl;
|
|
153
|
+
this.contentType = contentType;
|
|
154
|
+
}
|
|
155
|
+
getBase64() {
|
|
156
|
+
return this.buffer.toString("base64");
|
|
157
|
+
}
|
|
158
|
+
getContenType() {
|
|
159
|
+
return getContentTypeFromBuffer(this.buffer);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
var StepDefinition = class {
|
|
163
|
+
constructor(id, type, prev_step, user_interaction, return_result, end_after_processing, params, output, milestone) {
|
|
164
|
+
this.id = id;
|
|
165
|
+
this.type = type;
|
|
166
|
+
this.prev_step = prev_step;
|
|
167
|
+
this.user_interaction = user_interaction;
|
|
168
|
+
this.return_result = return_result;
|
|
169
|
+
this.end_after_processing = end_after_processing;
|
|
170
|
+
this.params = params;
|
|
171
|
+
this.output = output;
|
|
172
|
+
this.milestone = milestone;
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
var StepInstance = class {
|
|
176
|
+
constructor(id, expires_at) {
|
|
177
|
+
this.id = id;
|
|
178
|
+
this.expires_at = expires_at;
|
|
179
|
+
}
|
|
180
|
+
// public isInvalid() {
|
|
181
|
+
// return this.expires_at && this.expires_at < Date.now();
|
|
182
|
+
// }
|
|
183
|
+
isExpired() {
|
|
184
|
+
return this.expires_at && this.expires_at < Date.now();
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
var FlowContext = class {
|
|
188
|
+
constructor(id, webhook) {
|
|
189
|
+
this.id = id;
|
|
190
|
+
this.webhook = webhook;
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
var StepContext = class {
|
|
194
|
+
constructor(org, flow, step, instance, expires_at, params) {
|
|
195
|
+
this.org = org;
|
|
196
|
+
this.flow = flow;
|
|
197
|
+
this.step = step;
|
|
198
|
+
this.instance = instance;
|
|
199
|
+
this.expires_at = expires_at;
|
|
200
|
+
this.params = params;
|
|
201
|
+
}
|
|
202
|
+
isExpired() {
|
|
203
|
+
return this.expires_at && this.expires_at < Date.now();
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
207
|
+
0 && (module.exports = {
|
|
208
|
+
AutentikarRequest,
|
|
209
|
+
AutentikarResponse,
|
|
210
|
+
FlowContext,
|
|
211
|
+
IdentitySchemaDto,
|
|
212
|
+
StepContext,
|
|
213
|
+
StepDefinition,
|
|
214
|
+
StepInstance,
|
|
215
|
+
StepRequest,
|
|
216
|
+
StorageItem
|
|
217
|
+
});
|
package/package.json
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autentikar/step",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0-alpha.11",
|
|
4
4
|
"description": "",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
7
7
|
],
|
|
8
8
|
"exports": {
|
|
9
|
+
".": "./dist/index.js",
|
|
9
10
|
"./context": "./dist/context.js",
|
|
10
11
|
"./package.json": "./package.json"
|
|
11
12
|
},
|
|
12
13
|
"typesVersions": {
|
|
13
14
|
"*": {
|
|
15
|
+
".": [
|
|
16
|
+
"./dist/index.d.ts"
|
|
17
|
+
],
|
|
14
18
|
"context": [
|
|
15
19
|
"./dist/context.d.ts"
|
|
16
20
|
]
|
|
@@ -28,5 +32,9 @@
|
|
|
28
32
|
"@types/node": "^20.11.5",
|
|
29
33
|
"tsup": "^8.0.1",
|
|
30
34
|
"typescript": "^5.2.2"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"file-type": "16.5.3",
|
|
38
|
+
"zod": "^3.22.4"
|
|
31
39
|
}
|
|
32
40
|
}
|