@absolutejs/auth 0.38.0 → 0.40.0-beta.0
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.ts +6 -0
- package/dist/index.js +705 -204
- package/dist/index.js.map +13 -9
- package/dist/oidc/config.d.ts +2 -0
- package/dist/oidc/inMemoryVciStores.d.ts +3 -0
- package/dist/oidc/routes.d.ts +1 -0
- package/dist/oidc/vci.d.ts +159 -0
- package/dist/oidc/vciRoutes.d.ts +92 -0
- package/dist/vc/sdJwt.d.ts +37 -0
- package/package.json +1 -1
package/dist/oidc/config.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { RouteString } from '../types';
|
|
2
2
|
import { type SigningKey } from './keys';
|
|
3
3
|
import type { OnClientRegistration } from './registration';
|
|
4
|
+
import type { VciConfig } from './vci';
|
|
4
5
|
import type { AuthorizationCodeStore, BackchannelAuthStore, ClientAssertionJtiStore, ClientRegistrationTokenStore, DeviceAuthorizationStore, InitialAccessTokenStore, LogoutDeliveryStore, OAuthClient, OAuthClientStore, OidcRefreshTokenStore, PushedAuthorizationRequestStore } from './types';
|
|
5
6
|
export declare const DEFAULT_OIDC_ROUTE: RouteString;
|
|
6
7
|
export type OidcProviderConfig<UserType> = {
|
|
@@ -66,6 +67,7 @@ export type OidcProviderConfig<UserType> = {
|
|
|
66
67
|
refreshTokenStore: OidcRefreshTokenStore;
|
|
67
68
|
refreshTokenTtlMs?: number;
|
|
68
69
|
signingKey: SigningKey;
|
|
70
|
+
vciConfig?: VciConfig;
|
|
69
71
|
};
|
|
70
72
|
export type TokenExchangeResult = {
|
|
71
73
|
error: 'invalid_grant' | 'invalid_scope';
|
package/dist/oidc/routes.d.ts
CHANGED
|
@@ -76,6 +76,7 @@ export declare const oidcProviderRoutes: <UserType>(config: OidcProviderConfig<U
|
|
|
76
76
|
client_assertion?: string | undefined;
|
|
77
77
|
client_assertion_type?: string | undefined;
|
|
78
78
|
code_verifier?: string | undefined;
|
|
79
|
+
'pre-authorized_code'?: string | undefined;
|
|
79
80
|
subject_token?: string | undefined;
|
|
80
81
|
subject_token_type?: string | undefined;
|
|
81
82
|
};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import type { RouteString } from '../types';
|
|
2
|
+
import { type SigningKey } from './keys';
|
|
3
|
+
export declare const PRE_AUTHORIZED_CODE_GRANT = "urn:ietf:params:oauth:grant-type:pre-authorized_code";
|
|
4
|
+
export type CredentialConfiguration = {
|
|
5
|
+
format: 'vc+sd-jwt';
|
|
6
|
+
id: string;
|
|
7
|
+
display?: Array<{
|
|
8
|
+
locale?: string;
|
|
9
|
+
name: string;
|
|
10
|
+
}>;
|
|
11
|
+
order?: string[];
|
|
12
|
+
claims?: Record<string, {
|
|
13
|
+
display?: Array<{
|
|
14
|
+
locale?: string;
|
|
15
|
+
name: string;
|
|
16
|
+
}>;
|
|
17
|
+
}>;
|
|
18
|
+
vct: string;
|
|
19
|
+
};
|
|
20
|
+
export type CredentialOffer = {
|
|
21
|
+
clientId: string;
|
|
22
|
+
configurationId: string;
|
|
23
|
+
createdAt: number;
|
|
24
|
+
expiresAt: number;
|
|
25
|
+
preAuthorizedCodeHash: string;
|
|
26
|
+
redeemed: boolean;
|
|
27
|
+
userId: string;
|
|
28
|
+
};
|
|
29
|
+
export type CredentialOfferStore = {
|
|
30
|
+
consumeOffer: (preAuthorizedCodeHash: string) => Promise<CredentialOffer | undefined>;
|
|
31
|
+
saveOffer: (offer: CredentialOffer) => Promise<void>;
|
|
32
|
+
};
|
|
33
|
+
export type CredentialNonceRecord = {
|
|
34
|
+
expiresAt: number;
|
|
35
|
+
nonceHash: string;
|
|
36
|
+
};
|
|
37
|
+
export type CredentialNonceStore = {
|
|
38
|
+
consumeNonce: (nonceHash: string) => Promise<CredentialNonceRecord | undefined>;
|
|
39
|
+
saveNonce: (record: CredentialNonceRecord) => Promise<void>;
|
|
40
|
+
};
|
|
41
|
+
export type VciConfig = {
|
|
42
|
+
accessTokenTtlMs?: number;
|
|
43
|
+
credentialConfigurations: CredentialConfiguration[];
|
|
44
|
+
credentialNonceStore?: CredentialNonceStore;
|
|
45
|
+
credentialOfferStore: CredentialOfferStore;
|
|
46
|
+
nonceTtlMs?: number;
|
|
47
|
+
offerTtlMs?: number;
|
|
48
|
+
resolveCredentialClaims: (context: {
|
|
49
|
+
configurationId: string;
|
|
50
|
+
userId: string;
|
|
51
|
+
}) => Promise<Record<string, unknown>> | Record<string, unknown>;
|
|
52
|
+
resolveProtectedClaims?: (context: {
|
|
53
|
+
configurationId: string;
|
|
54
|
+
userId: string;
|
|
55
|
+
}) => Promise<Record<string, unknown>> | Record<string, unknown>;
|
|
56
|
+
signingKey?: SigningKey;
|
|
57
|
+
vciRoute?: RouteString;
|
|
58
|
+
};
|
|
59
|
+
export declare const DEFAULT_VCI_ROUTE: RouteString;
|
|
60
|
+
export declare const createCredentialOffer: ({ clientId, configurationId, now, store, ttlMs, userId }: {
|
|
61
|
+
clientId: string;
|
|
62
|
+
configurationId: string;
|
|
63
|
+
now?: number;
|
|
64
|
+
store: CredentialOfferStore;
|
|
65
|
+
ttlMs?: number;
|
|
66
|
+
userId: string;
|
|
67
|
+
}) => Promise<{
|
|
68
|
+
offer: CredentialOffer;
|
|
69
|
+
preAuthorizedCode: string;
|
|
70
|
+
}>;
|
|
71
|
+
export type PreAuthExchangeResult = {
|
|
72
|
+
error: 'expired_token' | 'invalid_grant';
|
|
73
|
+
ok: false;
|
|
74
|
+
} | {
|
|
75
|
+
access_token: string;
|
|
76
|
+
c_nonce?: string;
|
|
77
|
+
c_nonce_expires_in?: number;
|
|
78
|
+
expires_in: number;
|
|
79
|
+
ok: true;
|
|
80
|
+
token_type: 'Bearer';
|
|
81
|
+
};
|
|
82
|
+
export declare const exchangePreAuthorizedCode: ({ config, issuer, now, preAuthorizedCode, signingKey }: {
|
|
83
|
+
config: VciConfig;
|
|
84
|
+
issuer: string;
|
|
85
|
+
now?: number;
|
|
86
|
+
preAuthorizedCode: string;
|
|
87
|
+
signingKey: SigningKey;
|
|
88
|
+
}) => Promise<{
|
|
89
|
+
error: "expired_token" | "invalid_grant";
|
|
90
|
+
ok: false;
|
|
91
|
+
} | {
|
|
92
|
+
access_token: string;
|
|
93
|
+
c_nonce?: string;
|
|
94
|
+
c_nonce_expires_in?: number;
|
|
95
|
+
expires_in: number;
|
|
96
|
+
ok: true;
|
|
97
|
+
token_type: "Bearer";
|
|
98
|
+
}>;
|
|
99
|
+
export type CredentialIssueInput = {
|
|
100
|
+
accessToken: string;
|
|
101
|
+
proofJwt?: string;
|
|
102
|
+
requestedFormat?: 'vc+sd-jwt';
|
|
103
|
+
};
|
|
104
|
+
export type CredentialIssueResult = {
|
|
105
|
+
credential: string;
|
|
106
|
+
format: 'vc+sd-jwt';
|
|
107
|
+
ok: true;
|
|
108
|
+
} | {
|
|
109
|
+
error: 'invalid_credential_request' | 'invalid_proof' | 'invalid_token' | 'unsupported_credential_format';
|
|
110
|
+
ok: false;
|
|
111
|
+
};
|
|
112
|
+
export declare const buildIssuerMetadata: ({ config, issuer, vciRoute }: {
|
|
113
|
+
config: VciConfig;
|
|
114
|
+
issuer: string;
|
|
115
|
+
vciRoute: RouteString;
|
|
116
|
+
}) => {
|
|
117
|
+
credential_configurations_supported: {
|
|
118
|
+
[k: string]: {
|
|
119
|
+
claims: Record<string, {
|
|
120
|
+
display?: Array<{
|
|
121
|
+
locale?: string;
|
|
122
|
+
name: string;
|
|
123
|
+
}>;
|
|
124
|
+
}> | undefined;
|
|
125
|
+
credential_signing_alg_values_supported: string[];
|
|
126
|
+
cryptographic_binding_methods_supported: string[];
|
|
127
|
+
display: {
|
|
128
|
+
locale?: string;
|
|
129
|
+
name: string;
|
|
130
|
+
}[] | undefined;
|
|
131
|
+
format: "vc+sd-jwt";
|
|
132
|
+
order: string[] | undefined;
|
|
133
|
+
proof_types_supported: {
|
|
134
|
+
jwt: {
|
|
135
|
+
proof_signing_alg_values_supported: string[];
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
vct: string;
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
credential_endpoint: string;
|
|
142
|
+
credential_issuer: string;
|
|
143
|
+
nonce_endpoint: string | undefined;
|
|
144
|
+
token_endpoint: string;
|
|
145
|
+
};
|
|
146
|
+
export declare const issueCredential: ({ config, input, issuer, now, signingKey }: {
|
|
147
|
+
config: VciConfig;
|
|
148
|
+
input: CredentialIssueInput;
|
|
149
|
+
issuer: string;
|
|
150
|
+
now?: number;
|
|
151
|
+
signingKey: SigningKey;
|
|
152
|
+
}) => Promise<{
|
|
153
|
+
credential: string;
|
|
154
|
+
format: "vc+sd-jwt";
|
|
155
|
+
ok: true;
|
|
156
|
+
} | {
|
|
157
|
+
error: "invalid_credential_request" | "invalid_proof" | "invalid_token" | "unsupported_credential_format";
|
|
158
|
+
ok: false;
|
|
159
|
+
}>;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Elysia } from 'elysia';
|
|
2
|
+
import type { SigningKey } from './keys';
|
|
3
|
+
import { type VciConfig } from './vci';
|
|
4
|
+
export declare const vciRoutes: ({ issuerUrl, signingKey, vciConfig }: {
|
|
5
|
+
issuerUrl: string;
|
|
6
|
+
signingKey: SigningKey;
|
|
7
|
+
vciConfig: VciConfig;
|
|
8
|
+
}) => Elysia<"", {
|
|
9
|
+
decorator: {};
|
|
10
|
+
store: {};
|
|
11
|
+
derive: {};
|
|
12
|
+
resolve: {};
|
|
13
|
+
}, {
|
|
14
|
+
typebox: {};
|
|
15
|
+
error: {};
|
|
16
|
+
}, {
|
|
17
|
+
schema: {};
|
|
18
|
+
standaloneSchema: {};
|
|
19
|
+
macro: {};
|
|
20
|
+
macroFn: {};
|
|
21
|
+
parser: {};
|
|
22
|
+
response: {};
|
|
23
|
+
}, {
|
|
24
|
+
".well-known": {
|
|
25
|
+
"openid-credential-issuer": {
|
|
26
|
+
get: {
|
|
27
|
+
body: unknown;
|
|
28
|
+
params: {};
|
|
29
|
+
query: unknown;
|
|
30
|
+
headers: unknown;
|
|
31
|
+
response: {
|
|
32
|
+
200: Response;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
} & {
|
|
38
|
+
[x: string]: {
|
|
39
|
+
credential: {
|
|
40
|
+
post: {
|
|
41
|
+
body: {
|
|
42
|
+
format?: "vc+sd-jwt" | undefined;
|
|
43
|
+
proof?: {
|
|
44
|
+
jwt: string;
|
|
45
|
+
proof_type: "jwt";
|
|
46
|
+
} | undefined;
|
|
47
|
+
};
|
|
48
|
+
params: {};
|
|
49
|
+
query: unknown;
|
|
50
|
+
headers: unknown;
|
|
51
|
+
response: {
|
|
52
|
+
200: Response;
|
|
53
|
+
422: {
|
|
54
|
+
type: "validation";
|
|
55
|
+
on: string;
|
|
56
|
+
summary?: string;
|
|
57
|
+
message?: string;
|
|
58
|
+
found?: unknown;
|
|
59
|
+
property?: string;
|
|
60
|
+
expected?: string;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
} & {
|
|
67
|
+
[x: string]: {
|
|
68
|
+
nonce: {
|
|
69
|
+
post: {
|
|
70
|
+
body: unknown;
|
|
71
|
+
params: {};
|
|
72
|
+
query: unknown;
|
|
73
|
+
headers: unknown;
|
|
74
|
+
response: {
|
|
75
|
+
200: Response;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
}, {
|
|
81
|
+
derive: {};
|
|
82
|
+
resolve: {};
|
|
83
|
+
schema: {};
|
|
84
|
+
standaloneSchema: {};
|
|
85
|
+
response: {};
|
|
86
|
+
}, {
|
|
87
|
+
derive: {};
|
|
88
|
+
resolve: {};
|
|
89
|
+
schema: {};
|
|
90
|
+
standaloneSchema: {};
|
|
91
|
+
response: {};
|
|
92
|
+
}>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type SigningKey } from '../oidc/keys';
|
|
2
|
+
declare const toBase64Url: (bytes: ArrayBuffer | Uint8Array) => string;
|
|
3
|
+
declare const fromBase64Url: (value: string) => Uint8Array<ArrayBuffer>;
|
|
4
|
+
export type SdDisclosure = {
|
|
5
|
+
claimName: string;
|
|
6
|
+
claimValue: unknown;
|
|
7
|
+
encoded: string;
|
|
8
|
+
salt: string;
|
|
9
|
+
};
|
|
10
|
+
export type SdJwtVcIssueInput = {
|
|
11
|
+
base: Record<string, unknown>;
|
|
12
|
+
holderJwk?: JsonWebKey;
|
|
13
|
+
selective: Record<string, unknown>;
|
|
14
|
+
signingKey: SigningKey;
|
|
15
|
+
};
|
|
16
|
+
export declare const issueSdJwtVc: (input: SdJwtVcIssueInput) => Promise<string>;
|
|
17
|
+
export type ParsedSdJwtVc = {
|
|
18
|
+
disclosures: string[];
|
|
19
|
+
jwt: string;
|
|
20
|
+
keyBindingJwt: string | undefined;
|
|
21
|
+
};
|
|
22
|
+
export declare const parseSdJwtVc: (token: string) => ParsedSdJwtVc;
|
|
23
|
+
export declare const presentSdJwtVc: (parsed: ParsedSdJwtVc, selectedClaims: string[], keyBindingJwt?: string) => string;
|
|
24
|
+
export type VerifiedSdJwtVc = {
|
|
25
|
+
cnf: {
|
|
26
|
+
jwk: JsonWebKey;
|
|
27
|
+
} | undefined;
|
|
28
|
+
disclosedClaims: Record<string, unknown>;
|
|
29
|
+
keyBindingJwt: string | undefined;
|
|
30
|
+
protectedClaims: Record<string, unknown>;
|
|
31
|
+
};
|
|
32
|
+
export type SdJwtVcVerifyInput = {
|
|
33
|
+
issuerPublicJwk: JsonWebKey;
|
|
34
|
+
token: string;
|
|
35
|
+
};
|
|
36
|
+
export declare const verifySdJwtVc: (input: SdJwtVcVerifyInput) => Promise<VerifiedSdJwtVc | undefined>;
|
|
37
|
+
export { fromBase64Url, toBase64Url };
|
package/package.json
CHANGED