@selfxyz/enterprise-sdk 0.1.0 → 0.1.1
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/README.md +2 -2
- package/dist/index.d.ts +17 -19
- package/dist/index.js +57 -58
- package/package.json +1 -4
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ const self = new SelfClient({ apiKey: process.env.SELF_API_KEY! });
|
|
|
30
30
|
|
|
31
31
|
const session = await self.sessions.create({
|
|
32
32
|
flowId: '<your-flow-uuid>',
|
|
33
|
-
externalUuid: 'user-
|
|
33
|
+
externalUuid: '<user-uuid>',
|
|
34
34
|
});
|
|
35
35
|
|
|
36
36
|
// Redirect the end user here:
|
|
@@ -93,6 +93,6 @@ try {
|
|
|
93
93
|
|
|
94
94
|
## License
|
|
95
95
|
|
|
96
|
-
Licensed under the [Business Source License 1.1](
|
|
96
|
+
Licensed under the [Business Source License 1.1](https://github.com/selfxyz/self/blob/main/app/LICENSE). © 2025 Socialconnect Labs, Inc.
|
|
97
97
|
|
|
98
98
|
On **2029-06-11** the license converts automatically to the **Apache License, Version 2.0**.
|
package/dist/index.d.ts
CHANGED
|
@@ -46,21 +46,21 @@ declare const verificationStorageCommitted: z.ZodObject<{
|
|
|
46
46
|
type: z.ZodLiteral<"verification.storage_committed">;
|
|
47
47
|
verification_id: z.ZodString;
|
|
48
48
|
external_uuid: z.ZodString;
|
|
49
|
-
storage_uri: z.ZodString
|
|
49
|
+
storage_uri: z.ZodNullable<z.ZodString>;
|
|
50
50
|
credential_id: z.ZodString;
|
|
51
51
|
committed_at: z.ZodString;
|
|
52
52
|
}, "strip", z.ZodTypeAny, {
|
|
53
53
|
type: "verification.storage_committed";
|
|
54
54
|
verification_id: string;
|
|
55
55
|
external_uuid: string;
|
|
56
|
-
storage_uri: string;
|
|
56
|
+
storage_uri: string | null;
|
|
57
57
|
credential_id: string;
|
|
58
58
|
committed_at: string;
|
|
59
59
|
}, {
|
|
60
60
|
type: "verification.storage_committed";
|
|
61
61
|
verification_id: string;
|
|
62
62
|
external_uuid: string;
|
|
63
|
-
storage_uri: string;
|
|
63
|
+
storage_uri: string | null;
|
|
64
64
|
credential_id: string;
|
|
65
65
|
committed_at: string;
|
|
66
66
|
}>;
|
|
@@ -72,15 +72,15 @@ declare const verificationStorageFailed: z.ZodObject<{
|
|
|
72
72
|
failed_at: z.ZodString;
|
|
73
73
|
}, "strip", z.ZodTypeAny, {
|
|
74
74
|
type: "verification.storage_failed";
|
|
75
|
-
error: string;
|
|
76
75
|
verification_id: string;
|
|
77
76
|
external_uuid: string;
|
|
77
|
+
error: string;
|
|
78
78
|
failed_at: string;
|
|
79
79
|
}, {
|
|
80
80
|
type: "verification.storage_failed";
|
|
81
|
-
error: string;
|
|
82
81
|
verification_id: string;
|
|
83
82
|
external_uuid: string;
|
|
83
|
+
error: string;
|
|
84
84
|
failed_at: string;
|
|
85
85
|
}>;
|
|
86
86
|
declare const webhookEvent: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
@@ -127,21 +127,21 @@ declare const webhookEvent: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
|
127
127
|
type: z.ZodLiteral<"verification.storage_committed">;
|
|
128
128
|
verification_id: z.ZodString;
|
|
129
129
|
external_uuid: z.ZodString;
|
|
130
|
-
storage_uri: z.ZodString
|
|
130
|
+
storage_uri: z.ZodNullable<z.ZodString>;
|
|
131
131
|
credential_id: z.ZodString;
|
|
132
132
|
committed_at: z.ZodString;
|
|
133
133
|
}, "strip", z.ZodTypeAny, {
|
|
134
134
|
type: "verification.storage_committed";
|
|
135
135
|
verification_id: string;
|
|
136
136
|
external_uuid: string;
|
|
137
|
-
storage_uri: string;
|
|
137
|
+
storage_uri: string | null;
|
|
138
138
|
credential_id: string;
|
|
139
139
|
committed_at: string;
|
|
140
140
|
}, {
|
|
141
141
|
type: "verification.storage_committed";
|
|
142
142
|
verification_id: string;
|
|
143
143
|
external_uuid: string;
|
|
144
|
-
storage_uri: string;
|
|
144
|
+
storage_uri: string | null;
|
|
145
145
|
credential_id: string;
|
|
146
146
|
committed_at: string;
|
|
147
147
|
}>, z.ZodObject<{
|
|
@@ -152,15 +152,15 @@ declare const webhookEvent: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
|
152
152
|
failed_at: z.ZodString;
|
|
153
153
|
}, "strip", z.ZodTypeAny, {
|
|
154
154
|
type: "verification.storage_failed";
|
|
155
|
-
error: string;
|
|
156
155
|
verification_id: string;
|
|
157
156
|
external_uuid: string;
|
|
157
|
+
error: string;
|
|
158
158
|
failed_at: string;
|
|
159
159
|
}, {
|
|
160
160
|
type: "verification.storage_failed";
|
|
161
|
-
error: string;
|
|
162
161
|
verification_id: string;
|
|
163
162
|
external_uuid: string;
|
|
163
|
+
error: string;
|
|
164
164
|
failed_at: string;
|
|
165
165
|
}>]>;
|
|
166
166
|
type VerificationCompletedPayload = z.infer<typeof verificationCompleted>;
|
|
@@ -185,8 +185,8 @@ declare const createSessionBody: z.ZodObject<{
|
|
|
185
185
|
}, {
|
|
186
186
|
flowId: string;
|
|
187
187
|
externalUuid: string;
|
|
188
|
-
expiresInSeconds?: number | undefined;
|
|
189
188
|
metadata?: Record<string, unknown> | undefined;
|
|
189
|
+
expiresInSeconds?: number | undefined;
|
|
190
190
|
successUrl?: string | undefined;
|
|
191
191
|
failureUrl?: string | undefined;
|
|
192
192
|
}>;
|
|
@@ -254,9 +254,9 @@ declare const sessionDetailResponse: z.ZodObject<{
|
|
|
254
254
|
}>;
|
|
255
255
|
}, "strip", z.ZodTypeAny, {
|
|
256
256
|
id: string;
|
|
257
|
-
status: "valid" | "
|
|
258
|
-
externalUuid: string;
|
|
257
|
+
status: "valid" | "invalid" | "error" | "expired" | "pending";
|
|
259
258
|
metadata: Record<string, unknown> | null;
|
|
259
|
+
externalUuid: string;
|
|
260
260
|
flowVersionId: string;
|
|
261
261
|
createdAt: string;
|
|
262
262
|
expiresAt: string;
|
|
@@ -270,9 +270,9 @@ declare const sessionDetailResponse: z.ZodObject<{
|
|
|
270
270
|
};
|
|
271
271
|
}, {
|
|
272
272
|
id: string;
|
|
273
|
-
status: "valid" | "
|
|
274
|
-
externalUuid: string;
|
|
273
|
+
status: "valid" | "invalid" | "error" | "expired" | "pending";
|
|
275
274
|
metadata: Record<string, unknown> | null;
|
|
275
|
+
externalUuid: string;
|
|
276
276
|
flowVersionId: string;
|
|
277
277
|
createdAt: string;
|
|
278
278
|
expiresAt: string;
|
|
@@ -291,9 +291,7 @@ type SessionDetailResponse = z.infer<typeof sessionDetailResponse>;
|
|
|
291
291
|
interface SelfClientOptions {
|
|
292
292
|
/** Bearer API key (e.g. `sk_live_...`). */
|
|
293
293
|
apiKey: string;
|
|
294
|
-
/**
|
|
295
|
-
environment?: 'test' | 'live';
|
|
296
|
-
/** Override the base URL (default: `https://api.self.xyz`). */
|
|
294
|
+
/** Override the base URL (default: `https://edge.dashboard.self.xyz`). */
|
|
297
295
|
baseUrl?: string;
|
|
298
296
|
}
|
|
299
297
|
/**
|
|
@@ -303,7 +301,7 @@ interface SelfClientOptions {
|
|
|
303
301
|
* const self = new SelfClient({ apiKey: 'sk_live_...' });
|
|
304
302
|
* const session = await self.sessions.create({
|
|
305
303
|
* flowId: '<uuid>',
|
|
306
|
-
* externalUuid: '
|
|
304
|
+
* externalUuid: '<uuid>',
|
|
307
305
|
* });
|
|
308
306
|
* console.log(session.verificationUrl);
|
|
309
307
|
* ```
|
package/dist/index.js
CHANGED
|
@@ -13,62 +13,6 @@ var SelfApiError = class extends Error {
|
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
// src/client.ts
|
|
17
|
-
var SelfClient = class {
|
|
18
|
-
apiKey;
|
|
19
|
-
baseUrl;
|
|
20
|
-
sessions;
|
|
21
|
-
constructor(options) {
|
|
22
|
-
if (!options.apiKey) {
|
|
23
|
-
throw new Error("apiKey is required");
|
|
24
|
-
}
|
|
25
|
-
this.apiKey = options.apiKey;
|
|
26
|
-
this.baseUrl = (options.baseUrl ?? "https://api.self.xyz").replace(/\/+$/, "");
|
|
27
|
-
this.sessions = {
|
|
28
|
-
create: (params) => this.createSession(params),
|
|
29
|
-
get: (id) => this.getSession(id)
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
async request(method, path, body) {
|
|
33
|
-
const url = `${this.baseUrl}${path}`;
|
|
34
|
-
const res = await fetch(url, {
|
|
35
|
-
method,
|
|
36
|
-
headers: {
|
|
37
|
-
Authorization: `Bearer ${this.apiKey}`,
|
|
38
|
-
"Content-Type": "application/json",
|
|
39
|
-
Accept: "application/json"
|
|
40
|
-
},
|
|
41
|
-
...body !== void 0 ? { body: JSON.stringify(body) } : {}
|
|
42
|
-
});
|
|
43
|
-
const text = await res.text();
|
|
44
|
-
let json;
|
|
45
|
-
try {
|
|
46
|
-
json = JSON.parse(text);
|
|
47
|
-
} catch {
|
|
48
|
-
json = void 0;
|
|
49
|
-
}
|
|
50
|
-
if (!res.ok) {
|
|
51
|
-
const envelope = json;
|
|
52
|
-
throw new SelfApiError(res.status, {
|
|
53
|
-
code: envelope?.error?.code ?? "unknown_error",
|
|
54
|
-
message: envelope?.error?.message ?? (text || res.statusText),
|
|
55
|
-
...envelope?.error?.details ? { details: envelope.error.details } : {}
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
return json;
|
|
59
|
-
}
|
|
60
|
-
createSession(params) {
|
|
61
|
-
return this.request("POST", "/v1/sessions", params);
|
|
62
|
-
}
|
|
63
|
-
getSession(id) {
|
|
64
|
-
return this.request("GET", `/v1/sessions/${encodeURIComponent(id)}`);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
// src/webhooks.ts
|
|
69
|
-
import { z as z6 } from "zod";
|
|
70
|
-
import { Webhook } from "svix";
|
|
71
|
-
|
|
72
16
|
// ../schemas/dist/stripe-events.js
|
|
73
17
|
import { z } from "zod";
|
|
74
18
|
var stripeEventBase = z.object({
|
|
@@ -237,7 +181,7 @@ var verificationStorageCommitted = z3.object({
|
|
|
237
181
|
type: z3.literal("verification.storage_committed"),
|
|
238
182
|
verification_id: z3.string(),
|
|
239
183
|
external_uuid: z3.string(),
|
|
240
|
-
storage_uri: z3.string(),
|
|
184
|
+
storage_uri: z3.string().nullable(),
|
|
241
185
|
credential_id: z3.string(),
|
|
242
186
|
committed_at: z3.string().datetime()
|
|
243
187
|
});
|
|
@@ -258,7 +202,7 @@ var webhookEvent = z3.discriminatedUnion("type", [
|
|
|
258
202
|
import { z as z4 } from "zod";
|
|
259
203
|
var createSessionBody = z4.object({
|
|
260
204
|
flowId: z4.string().uuid(),
|
|
261
|
-
externalUuid: z4.string().
|
|
205
|
+
externalUuid: z4.string().uuid(),
|
|
262
206
|
expiresInSeconds: z4.number().int().min(60).max(86400).default(3600),
|
|
263
207
|
metadata: z4.record(z4.unknown()).optional().refine((val) => !val || JSON.stringify(val).length <= 4096, {
|
|
264
208
|
message: "metadata must be 4KB or less when serialized"
|
|
@@ -300,7 +244,62 @@ var sessionDetailResponse = z5.object({
|
|
|
300
244
|
})
|
|
301
245
|
});
|
|
302
246
|
|
|
247
|
+
// src/client.ts
|
|
248
|
+
var SelfClient = class {
|
|
249
|
+
apiKey;
|
|
250
|
+
baseUrl;
|
|
251
|
+
sessions;
|
|
252
|
+
constructor(options) {
|
|
253
|
+
if (!options.apiKey) {
|
|
254
|
+
throw new Error("apiKey is required");
|
|
255
|
+
}
|
|
256
|
+
this.apiKey = options.apiKey;
|
|
257
|
+
this.baseUrl = (options.baseUrl ?? "https://edge.dashboard.self.xyz").replace(/\/+$/, "");
|
|
258
|
+
this.sessions = {
|
|
259
|
+
create: (params) => this.createSession(params),
|
|
260
|
+
get: (id) => this.getSession(id)
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
async request(method, path, body) {
|
|
264
|
+
const url = `${this.baseUrl}${path}`;
|
|
265
|
+
const res = await fetch(url, {
|
|
266
|
+
method,
|
|
267
|
+
headers: {
|
|
268
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
269
|
+
"Content-Type": "application/json",
|
|
270
|
+
Accept: "application/json"
|
|
271
|
+
},
|
|
272
|
+
...body !== void 0 ? { body: JSON.stringify(body) } : {}
|
|
273
|
+
});
|
|
274
|
+
const text = await res.text();
|
|
275
|
+
let json;
|
|
276
|
+
try {
|
|
277
|
+
json = JSON.parse(text);
|
|
278
|
+
} catch {
|
|
279
|
+
json = void 0;
|
|
280
|
+
}
|
|
281
|
+
if (!res.ok) {
|
|
282
|
+
const envelope = json;
|
|
283
|
+
throw new SelfApiError(res.status, {
|
|
284
|
+
code: envelope?.error?.code ?? "unknown_error",
|
|
285
|
+
message: envelope?.error?.message ?? (text || res.statusText),
|
|
286
|
+
...envelope?.error?.details ? { details: envelope.error.details } : {}
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
return json;
|
|
290
|
+
}
|
|
291
|
+
async createSession(params) {
|
|
292
|
+
createSessionBody.parse(params);
|
|
293
|
+
return this.request("POST", "/v1/sessions", params);
|
|
294
|
+
}
|
|
295
|
+
getSession(id) {
|
|
296
|
+
return this.request("GET", `/v1/sessions/${encodeURIComponent(id)}`);
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
|
|
303
300
|
// src/webhooks.ts
|
|
301
|
+
import { z as z6 } from "zod";
|
|
302
|
+
import { Webhook } from "svix";
|
|
304
303
|
var forwardCompatibleEvent = z6.discriminatedUnion("type", [
|
|
305
304
|
verificationCompleted.passthrough(),
|
|
306
305
|
verificationStorageCommitted.passthrough(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@selfxyz/enterprise-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Node/TS SDK for Self.xyz enterprise verification — session creation, webhook signature verification, typed payloads.",
|
|
5
5
|
"license": "BUSL-1.1",
|
|
6
6
|
"homepage": "https://self.xyz",
|
|
@@ -22,9 +22,6 @@
|
|
|
22
22
|
"main": "dist/index.js",
|
|
23
23
|
"types": "dist/index.d.ts",
|
|
24
24
|
"publishConfig": {
|
|
25
|
-
"name": "@selfxyz/enterprise-sdk",
|
|
26
|
-
"main": "dist/index.js",
|
|
27
|
-
"types": "dist/index.d.ts",
|
|
28
25
|
"access": "public"
|
|
29
26
|
},
|
|
30
27
|
"files": [
|