@vidos-id/openid4vc-issuer-web-shared 0.0.0-test1
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/index.d.mts +143 -0
- package/dist/index.mjs +92 -0
- package/package.json +36 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/schemas.d.ts
|
|
4
|
+
declare const jsonObjectSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
5
|
+
declare const sessionUserSchema: z.ZodObject<{
|
|
6
|
+
id: z.ZodString;
|
|
7
|
+
username: z.ZodNullable<z.ZodString>;
|
|
8
|
+
name: z.ZodString;
|
|
9
|
+
isAnonymous: z.ZodBoolean;
|
|
10
|
+
createdAt: z.ZodString;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
declare const sessionResponseSchema: z.ZodObject<{
|
|
13
|
+
user: z.ZodNullable<z.ZodObject<{
|
|
14
|
+
id: z.ZodString;
|
|
15
|
+
username: z.ZodNullable<z.ZodString>;
|
|
16
|
+
name: z.ZodString;
|
|
17
|
+
isAnonymous: z.ZodBoolean;
|
|
18
|
+
createdAt: z.ZodString;
|
|
19
|
+
}, z.core.$strip>>;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
declare const templateKindSchema: z.ZodEnum<{
|
|
22
|
+
custom: "custom";
|
|
23
|
+
predefined: "predefined";
|
|
24
|
+
}>;
|
|
25
|
+
declare const templateSchema: z.ZodObject<{
|
|
26
|
+
id: z.ZodString;
|
|
27
|
+
ownerUserId: z.ZodString;
|
|
28
|
+
name: z.ZodString;
|
|
29
|
+
kind: z.ZodEnum<{
|
|
30
|
+
custom: "custom";
|
|
31
|
+
predefined: "predefined";
|
|
32
|
+
}>;
|
|
33
|
+
credentialConfigurationId: z.ZodString;
|
|
34
|
+
vct: z.ZodString;
|
|
35
|
+
defaultClaims: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
36
|
+
createdAt: z.ZodString;
|
|
37
|
+
updatedAt: z.ZodString;
|
|
38
|
+
}, z.core.$strip>;
|
|
39
|
+
declare const createTemplateInputSchema: z.ZodObject<{
|
|
40
|
+
name: z.ZodString;
|
|
41
|
+
vct: z.ZodString;
|
|
42
|
+
defaultClaims: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
43
|
+
}, z.core.$strip>;
|
|
44
|
+
declare const deleteResponseSchema: z.ZodObject<{
|
|
45
|
+
ok: z.ZodLiteral<true>;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
declare const updateTemplateInputSchema: z.ZodObject<{
|
|
48
|
+
name: z.ZodOptional<z.ZodString>;
|
|
49
|
+
vct: z.ZodOptional<z.ZodString>;
|
|
50
|
+
defaultClaims: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
51
|
+
}, z.core.$strip>;
|
|
52
|
+
declare const issuanceStateSchema: z.ZodEnum<{
|
|
53
|
+
offered: "offered";
|
|
54
|
+
redeeming: "redeeming";
|
|
55
|
+
redeemed: "redeemed";
|
|
56
|
+
expired: "expired";
|
|
57
|
+
redemption_failed: "redemption_failed";
|
|
58
|
+
}>;
|
|
59
|
+
declare const issuanceStatusValueSchema: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>, z.ZodLiteral<2>]>;
|
|
60
|
+
declare const issuanceSchema: z.ZodObject<{
|
|
61
|
+
id: z.ZodString;
|
|
62
|
+
ownerUserId: z.ZodString;
|
|
63
|
+
templateId: z.ZodString;
|
|
64
|
+
credentialConfigurationId: z.ZodString;
|
|
65
|
+
vct: z.ZodString;
|
|
66
|
+
claims: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
67
|
+
state: z.ZodEnum<{
|
|
68
|
+
offered: "offered";
|
|
69
|
+
redeeming: "redeeming";
|
|
70
|
+
redeemed: "redeemed";
|
|
71
|
+
expired: "expired";
|
|
72
|
+
redemption_failed: "redemption_failed";
|
|
73
|
+
}>;
|
|
74
|
+
status: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>, z.ZodLiteral<2>]>;
|
|
75
|
+
offerUri: z.ZodString;
|
|
76
|
+
statusListId: z.ZodString;
|
|
77
|
+
statusListIndex: z.ZodNumber;
|
|
78
|
+
credential: z.ZodNullable<z.ZodString>;
|
|
79
|
+
createdAt: z.ZodString;
|
|
80
|
+
updatedAt: z.ZodString;
|
|
81
|
+
}, z.core.$strip>;
|
|
82
|
+
declare const createIssuanceInputSchema: z.ZodObject<{
|
|
83
|
+
templateId: z.ZodString;
|
|
84
|
+
claims: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
85
|
+
status: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>, z.ZodLiteral<2>]>>;
|
|
86
|
+
}, z.core.$strip>;
|
|
87
|
+
declare const updateIssuanceStatusInputSchema: z.ZodObject<{
|
|
88
|
+
status: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>, z.ZodLiteral<2>]>;
|
|
89
|
+
}, z.core.$strip>;
|
|
90
|
+
declare const issuanceDetailSchema: z.ZodObject<{
|
|
91
|
+
issuance: z.ZodObject<{
|
|
92
|
+
id: z.ZodString;
|
|
93
|
+
ownerUserId: z.ZodString;
|
|
94
|
+
templateId: z.ZodString;
|
|
95
|
+
credentialConfigurationId: z.ZodString;
|
|
96
|
+
vct: z.ZodString;
|
|
97
|
+
claims: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
98
|
+
state: z.ZodEnum<{
|
|
99
|
+
offered: "offered";
|
|
100
|
+
redeeming: "redeeming";
|
|
101
|
+
redeemed: "redeemed";
|
|
102
|
+
expired: "expired";
|
|
103
|
+
redemption_failed: "redemption_failed";
|
|
104
|
+
}>;
|
|
105
|
+
status: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>, z.ZodLiteral<2>]>;
|
|
106
|
+
offerUri: z.ZodString;
|
|
107
|
+
statusListId: z.ZodString;
|
|
108
|
+
statusListIndex: z.ZodNumber;
|
|
109
|
+
credential: z.ZodNullable<z.ZodString>;
|
|
110
|
+
createdAt: z.ZodString;
|
|
111
|
+
updatedAt: z.ZodString;
|
|
112
|
+
}, z.core.$strip>;
|
|
113
|
+
qrPayload: z.ZodString;
|
|
114
|
+
}, z.core.$strip>;
|
|
115
|
+
declare const appErrorSchema: z.ZodObject<{
|
|
116
|
+
error: z.ZodString;
|
|
117
|
+
message: z.ZodString;
|
|
118
|
+
}, z.core.$strip>;
|
|
119
|
+
type SessionResponse = z.infer<typeof sessionResponseSchema>;
|
|
120
|
+
type Template = z.infer<typeof templateSchema>;
|
|
121
|
+
type CreateTemplateInput = z.infer<typeof createTemplateInputSchema>;
|
|
122
|
+
type UpdateTemplateInput = z.infer<typeof updateTemplateInputSchema>;
|
|
123
|
+
type Issuance = z.infer<typeof issuanceSchema>;
|
|
124
|
+
type CreateIssuanceInput = z.infer<typeof createIssuanceInputSchema>;
|
|
125
|
+
type UpdateIssuanceStatusInput = z.infer<typeof updateIssuanceStatusInputSchema>;
|
|
126
|
+
type IssuanceDetail = z.infer<typeof issuanceDetailSchema>;
|
|
127
|
+
type DeleteResponse = z.infer<typeof deleteResponseSchema>;
|
|
128
|
+
//#endregion
|
|
129
|
+
//#region src/status.d.ts
|
|
130
|
+
type TokenStatusValue = 0 | 1 | 2;
|
|
131
|
+
declare const ACTIVE_TOKEN_STATUS = 0;
|
|
132
|
+
declare const REVOKED_TOKEN_STATUS = 1;
|
|
133
|
+
declare const SUSPENDED_TOKEN_STATUS = 2;
|
|
134
|
+
declare const TOKEN_STATUS_LABELS_BY_VALUE: {
|
|
135
|
+
readonly 0: "active";
|
|
136
|
+
readonly 1: "revoked";
|
|
137
|
+
readonly 2: "suspended";
|
|
138
|
+
};
|
|
139
|
+
type TokenStatusLabel = (typeof TOKEN_STATUS_LABELS_BY_VALUE)[keyof typeof TOKEN_STATUS_LABELS_BY_VALUE];
|
|
140
|
+
declare function getTokenStatusLabel(status: TokenStatusValue): string;
|
|
141
|
+
declare const KNOWN_TOKEN_STATUSES: readonly [0, 1, 2];
|
|
142
|
+
//#endregion
|
|
143
|
+
export { ACTIVE_TOKEN_STATUS, CreateIssuanceInput, CreateTemplateInput, DeleteResponse, Issuance, IssuanceDetail, KNOWN_TOKEN_STATUSES, REVOKED_TOKEN_STATUS, SUSPENDED_TOKEN_STATUS, SessionResponse, Template, TokenStatusLabel, TokenStatusValue, UpdateIssuanceStatusInput, UpdateTemplateInput, appErrorSchema, createIssuanceInputSchema, createTemplateInputSchema, deleteResponseSchema, getTokenStatusLabel, issuanceDetailSchema, issuanceSchema, issuanceStateSchema, issuanceStatusValueSchema, jsonObjectSchema, sessionResponseSchema, sessionUserSchema, templateKindSchema, templateSchema, updateIssuanceStatusInputSchema, updateTemplateInputSchema };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region src/status.ts
|
|
3
|
+
const ACTIVE_TOKEN_STATUS = 0;
|
|
4
|
+
const REVOKED_TOKEN_STATUS = 1;
|
|
5
|
+
const SUSPENDED_TOKEN_STATUS = 2;
|
|
6
|
+
const TOKEN_STATUS_LABELS_BY_VALUE = {
|
|
7
|
+
[0]: "active",
|
|
8
|
+
[1]: "revoked",
|
|
9
|
+
[2]: "suspended"
|
|
10
|
+
};
|
|
11
|
+
function getTokenStatusLabel(status) {
|
|
12
|
+
return TOKEN_STATUS_LABELS_BY_VALUE[status] ?? String(status);
|
|
13
|
+
}
|
|
14
|
+
const KNOWN_TOKEN_STATUSES = [
|
|
15
|
+
0,
|
|
16
|
+
1,
|
|
17
|
+
2
|
|
18
|
+
];
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/schemas.ts
|
|
21
|
+
const jsonObjectSchema = z.record(z.string(), z.unknown());
|
|
22
|
+
const sessionUserSchema = z.object({
|
|
23
|
+
id: z.string().min(1),
|
|
24
|
+
username: z.string().min(1).nullable(),
|
|
25
|
+
name: z.string().min(1),
|
|
26
|
+
isAnonymous: z.boolean(),
|
|
27
|
+
createdAt: z.string().datetime()
|
|
28
|
+
});
|
|
29
|
+
const sessionResponseSchema = z.object({ user: sessionUserSchema.nullable() });
|
|
30
|
+
const templateKindSchema = z.enum(["predefined", "custom"]);
|
|
31
|
+
const templateSchema = z.object({
|
|
32
|
+
id: z.string().min(1),
|
|
33
|
+
ownerUserId: z.string().min(1),
|
|
34
|
+
name: z.string().min(1),
|
|
35
|
+
kind: templateKindSchema,
|
|
36
|
+
credentialConfigurationId: z.string().min(1),
|
|
37
|
+
vct: z.string().min(1),
|
|
38
|
+
defaultClaims: jsonObjectSchema,
|
|
39
|
+
createdAt: z.string().datetime(),
|
|
40
|
+
updatedAt: z.string().datetime()
|
|
41
|
+
});
|
|
42
|
+
const createTemplateInputSchema = z.object({
|
|
43
|
+
name: z.string().min(1),
|
|
44
|
+
vct: z.string().min(1),
|
|
45
|
+
defaultClaims: jsonObjectSchema
|
|
46
|
+
});
|
|
47
|
+
const deleteResponseSchema = z.object({ ok: z.literal(true) });
|
|
48
|
+
const updateTemplateInputSchema = createTemplateInputSchema.partial().refine((value) => Object.keys(value).length > 0, "At least one field is required");
|
|
49
|
+
const issuanceStateSchema = z.enum([
|
|
50
|
+
"offered",
|
|
51
|
+
"redeeming",
|
|
52
|
+
"redeemed",
|
|
53
|
+
"expired",
|
|
54
|
+
"redemption_failed"
|
|
55
|
+
]);
|
|
56
|
+
const issuanceStatusValueSchema = z.union([
|
|
57
|
+
z.literal(KNOWN_TOKEN_STATUSES[0]),
|
|
58
|
+
z.literal(KNOWN_TOKEN_STATUSES[1]),
|
|
59
|
+
z.literal(KNOWN_TOKEN_STATUSES[2])
|
|
60
|
+
]);
|
|
61
|
+
const issuanceSchema = z.object({
|
|
62
|
+
id: z.string().min(1),
|
|
63
|
+
ownerUserId: z.string().min(1),
|
|
64
|
+
templateId: z.string().min(1),
|
|
65
|
+
credentialConfigurationId: z.string().min(1),
|
|
66
|
+
vct: z.string().min(1),
|
|
67
|
+
claims: jsonObjectSchema,
|
|
68
|
+
state: issuanceStateSchema,
|
|
69
|
+
status: issuanceStatusValueSchema,
|
|
70
|
+
offerUri: z.string().min(1),
|
|
71
|
+
statusListId: z.string().min(1),
|
|
72
|
+
statusListIndex: z.number().int().nonnegative(),
|
|
73
|
+
credential: z.string().min(1).nullable(),
|
|
74
|
+
createdAt: z.string().datetime(),
|
|
75
|
+
updatedAt: z.string().datetime()
|
|
76
|
+
});
|
|
77
|
+
const createIssuanceInputSchema = z.object({
|
|
78
|
+
templateId: z.string().min(1),
|
|
79
|
+
claims: jsonObjectSchema.optional(),
|
|
80
|
+
status: issuanceStatusValueSchema.default(0)
|
|
81
|
+
});
|
|
82
|
+
const updateIssuanceStatusInputSchema = z.object({ status: issuanceStatusValueSchema });
|
|
83
|
+
const issuanceDetailSchema = z.object({
|
|
84
|
+
issuance: issuanceSchema,
|
|
85
|
+
qrPayload: z.string().min(1)
|
|
86
|
+
});
|
|
87
|
+
const appErrorSchema = z.object({
|
|
88
|
+
error: z.string().min(1),
|
|
89
|
+
message: z.string().min(1)
|
|
90
|
+
});
|
|
91
|
+
//#endregion
|
|
92
|
+
export { ACTIVE_TOKEN_STATUS, KNOWN_TOKEN_STATUSES, REVOKED_TOKEN_STATUS, SUSPENDED_TOKEN_STATUS, appErrorSchema, createIssuanceInputSchema, createTemplateInputSchema, deleteResponseSchema, getTokenStatusLabel, issuanceDetailSchema, issuanceSchema, issuanceStateSchema, issuanceStatusValueSchema, jsonObjectSchema, sessionResponseSchema, sessionUserSchema, templateKindSchema, templateSchema, updateIssuanceStatusInputSchema, updateTemplateInputSchema };
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vidos-id/openid4vc-issuer-web-shared",
|
|
3
|
+
"version": "0.0.0-test1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"engines": {
|
|
6
|
+
"node": ">=20"
|
|
7
|
+
},
|
|
8
|
+
"main": "./dist/index.mjs",
|
|
9
|
+
"types": "./dist/index.d.mts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"development": {
|
|
13
|
+
"types": "./src/index.ts",
|
|
14
|
+
"default": "./src/index.ts"
|
|
15
|
+
},
|
|
16
|
+
"types": "./dist/index.d.mts",
|
|
17
|
+
"default": "./dist/index.mjs"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsdown",
|
|
22
|
+
"check-types": "tsc --noEmit --project tsconfig.json",
|
|
23
|
+
"publish": "bun publish",
|
|
24
|
+
"test": "bun --conditions=development test --pass-with-no-tests"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist"
|
|
28
|
+
],
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"registry": "https://registry.npmjs.org/",
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"zod": "^4.3.6"
|
|
35
|
+
}
|
|
36
|
+
}
|