mppx 0.17.4 → 0.17.6
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/CHANGELOG.md +18 -0
- package/README.md +15 -0
- package/dist/cli/cli.js +141 -137
- package/dist/cli/stripe.d.ts +53 -0
- package/dist/cli/stripe.js +241 -0
- package/dist/client/Mppx.js +1 -0
- package/dist/extensions/identity/email-otp/Constants.d.ts +16 -0
- package/dist/extensions/identity/email-otp/Constants.js +16 -0
- package/dist/extensions/identity/email-otp/Types.d.ts +12 -0
- package/dist/extensions/identity/email-otp/Types.js +2 -0
- package/dist/extensions/identity/email-otp/client/index.d.ts +116 -0
- package/dist/extensions/identity/email-otp/client/index.js +119 -0
- package/dist/extensions/identity/email-otp/index.d.ts +17 -0
- package/dist/extensions/identity/email-otp/index.js +16 -0
- package/dist/extensions/identity/email-otp/internal/Attestation.d.ts +66 -0
- package/dist/extensions/identity/email-otp/internal/Attestation.js +128 -0
- package/dist/extensions/identity/email-otp/internal/Constants.d.ts +20 -0
- package/dist/extensions/identity/email-otp/internal/Constants.js +20 -0
- package/dist/extensions/identity/email-otp/internal/Jwks.d.ts +30 -0
- package/dist/extensions/identity/email-otp/internal/Jwks.js +114 -0
- package/dist/extensions/identity/email-otp/internal/Prover.d.ts +46 -0
- package/dist/extensions/identity/email-otp/internal/Prover.js +168 -0
- package/dist/extensions/identity/email-otp/internal/Types.d.ts +48 -0
- package/dist/extensions/identity/email-otp/internal/Types.js +2 -0
- package/dist/extensions/identity/email-otp/internal/Verifier.d.ts +56 -0
- package/dist/extensions/identity/email-otp/internal/Verifier.js +116 -0
- package/dist/extensions/identity/email-otp/server/index.d.ts +48 -0
- package/dist/extensions/identity/email-otp/server/index.js +56 -0
- package/dist/extensions/identity/index.d.ts +2 -0
- package/dist/extensions/identity/index.js +2 -0
- package/dist/identity/Callback.d.ts +47 -0
- package/dist/identity/Callback.js +64 -0
- package/dist/identity/index.d.ts +1 -0
- package/dist/identity/index.js +1 -0
- package/dist/internal/version.d.ts +2 -2
- package/dist/internal/version.js +1 -1
- package/dist/proxy/internal/Headers.js +2 -0
- package/dist/tempo/server/internal/html.gen.js +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type * as Identity from '../../../../identity/Types.js';
|
|
2
|
+
import type { MaybePromise } from '../../../../internal/types.js';
|
|
3
|
+
import type * as Types from './Types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Creates a request-stage verifier for one type of identity attestation from one issuer.
|
|
6
|
+
*
|
|
7
|
+
* A request without a matching `Identity-Attestation` is rejected with 401 and an
|
|
8
|
+
* `Identity-Attestation-Required` header naming the type and issuer, which a
|
|
9
|
+
* client prover answers by obtaining an attestation and retrying. Attestations of
|
|
10
|
+
* other types or issuers in the same header are left to their own verifiers.
|
|
11
|
+
*
|
|
12
|
+
* An attestation is a bearer proof bound to this server's origin until it
|
|
13
|
+
* expires; it says what the issuer checked, not what the subject may do.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const email = Attestation.Server.verifier({
|
|
18
|
+
* audience: 'https://api.example',
|
|
19
|
+
* issuer: 'https://issuer.example',
|
|
20
|
+
* type: 'email',
|
|
21
|
+
* })
|
|
22
|
+
* mppx.charge({ amount: '1', identity: [email] })
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function verifier(config: verifier.Config): Identity.Verifier<Types.Verified>;
|
|
26
|
+
export declare namespace verifier {
|
|
27
|
+
type Config = {
|
|
28
|
+
/** Accepted attestation type, such as `email`. */
|
|
29
|
+
type: string;
|
|
30
|
+
/** Trusted issuer URL. */
|
|
31
|
+
issuer: string;
|
|
32
|
+
/**
|
|
33
|
+
* This server's public origin, such as `https://api.example`, which attestations must be bound to.
|
|
34
|
+
*
|
|
35
|
+
* A function may derive it from the request, but only where the platform
|
|
36
|
+
* guarantees the request's host (such as a Cloudflare Worker route): many
|
|
37
|
+
* Node servers build the URL from the client's `Host` header, which would let
|
|
38
|
+
* another server's attestation through.
|
|
39
|
+
*/
|
|
40
|
+
audience: string | ((request: Request) => string);
|
|
41
|
+
/** Resolves issuer keys. Defaults to the issuer's JSON Web Key Set. */
|
|
42
|
+
keyResolver?: Types.KeyResolver | undefined;
|
|
43
|
+
/** Fetch used for the default JSON Web Key Set resolver. */
|
|
44
|
+
fetch?: typeof globalThis.fetch | undefined;
|
|
45
|
+
/** Oldest accepted `iat`, in seconds before now. Defaults to the attestation's own `exp`. */
|
|
46
|
+
maxAge?: number | undefined;
|
|
47
|
+
/** Clock tolerance in seconds. @default 60 */
|
|
48
|
+
clockTolerance?: number | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Applies the route's policy to verified claims. Return a reason to reject
|
|
51
|
+
* the request with 403, or `undefined` to accept it.
|
|
52
|
+
*/
|
|
53
|
+
validate?: ((claims: Types.Claims, request: Request) => MaybePromise<string | undefined>) | undefined;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=Verifier.d.ts.map
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { serializeList, Token } from 'structured-headers';
|
|
2
|
+
import * as Attestation from './Attestation.js';
|
|
3
|
+
import { Constants } from './Constants.js';
|
|
4
|
+
import * as Jwks from './Jwks.js';
|
|
5
|
+
/**
|
|
6
|
+
* Creates a request-stage verifier for one type of identity attestation from one issuer.
|
|
7
|
+
*
|
|
8
|
+
* A request without a matching `Identity-Attestation` is rejected with 401 and an
|
|
9
|
+
* `Identity-Attestation-Required` header naming the type and issuer, which a
|
|
10
|
+
* client prover answers by obtaining an attestation and retrying. Attestations of
|
|
11
|
+
* other types or issuers in the same header are left to their own verifiers.
|
|
12
|
+
*
|
|
13
|
+
* An attestation is a bearer proof bound to this server's origin until it
|
|
14
|
+
* expires; it says what the issuer checked, not what the subject may do.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* const email = Attestation.Server.verifier({
|
|
19
|
+
* audience: 'https://api.example',
|
|
20
|
+
* issuer: 'https://issuer.example',
|
|
21
|
+
* type: 'email',
|
|
22
|
+
* })
|
|
23
|
+
* mppx.charge({ amount: '1', identity: [email] })
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export function verifier(config) {
|
|
27
|
+
const issuer = config.issuer.replace(/\/+$/, '');
|
|
28
|
+
if (!Attestation.isIssuer(issuer))
|
|
29
|
+
throw new TypeError('Attestation issuer must be an https URL (http only on localhost).');
|
|
30
|
+
for (const [name, value] of [
|
|
31
|
+
['clockTolerance', config.clockTolerance],
|
|
32
|
+
['maxAge', config.maxAge],
|
|
33
|
+
])
|
|
34
|
+
if (value !== undefined && !(Number.isSafeInteger(value) && value >= 0))
|
|
35
|
+
throw new TypeError(`Attestation ${name} must be a non-negative integer of seconds.`);
|
|
36
|
+
const keyResolver = config.keyResolver ?? Jwks.resolver({ fetch: config.fetch });
|
|
37
|
+
const required = {
|
|
38
|
+
[Constants.requiredHeader]: serializeList([
|
|
39
|
+
[new Token(config.type), new Map([['issuer', issuer]])],
|
|
40
|
+
]),
|
|
41
|
+
};
|
|
42
|
+
return {
|
|
43
|
+
stage: 'request',
|
|
44
|
+
async verify(request) {
|
|
45
|
+
const audience = origin(typeof config.audience === 'function' ? config.audience(request) : config.audience);
|
|
46
|
+
// At most `maxCandidates` distinct tokens are verified, latest expiry first,
|
|
47
|
+
// so repeated or forged tokens cost a bounded number of signature checks.
|
|
48
|
+
// A stray forged token does not hide a valid one, but whoever controls the
|
|
49
|
+
// header can always withhold a valid token, so the bound is not a guarantee
|
|
50
|
+
// against that sender. Without a usable one, the first is verified so its
|
|
51
|
+
// rejection says why.
|
|
52
|
+
const now = Math.floor(Date.now() / 1_000);
|
|
53
|
+
const tolerance = config.clockTolerance ?? Constants.clockTolerance;
|
|
54
|
+
const candidates = Attestation.parseHeader(request.headers.get(Constants.header))
|
|
55
|
+
.map((token) => ({ token, claims: Attestation.decode(token)?.claims }))
|
|
56
|
+
.filter(({ claims }) => claims?.iss === issuer && claims.type === config.type);
|
|
57
|
+
const usable = candidates
|
|
58
|
+
.filter(({ claims }) => claims?.aud === audience && (claims.exp ?? 0) > now - tolerance)
|
|
59
|
+
.sort((a, b) => (b.claims?.exp ?? 0) - (a.claims?.exp ?? 0));
|
|
60
|
+
const tokens = [
|
|
61
|
+
...new Set((usable.length > 0 ? usable : candidates).map(({ token }) => token)),
|
|
62
|
+
].slice(0, usable.length > 0 ? maxCandidates : 1);
|
|
63
|
+
if (tokens.length === 0)
|
|
64
|
+
return {
|
|
65
|
+
status: 'missing',
|
|
66
|
+
code: 401,
|
|
67
|
+
headers: required,
|
|
68
|
+
reason: `An identity attestation of type "${config.type}" is required.`,
|
|
69
|
+
};
|
|
70
|
+
let reason = 'The identity attestation is invalid.';
|
|
71
|
+
let unavailable;
|
|
72
|
+
let forbidden;
|
|
73
|
+
for (const token of tokens) {
|
|
74
|
+
const result = await Attestation.verify(token, {
|
|
75
|
+
audience,
|
|
76
|
+
clockTolerance: config.clockTolerance,
|
|
77
|
+
issuer,
|
|
78
|
+
keyResolver,
|
|
79
|
+
maxAge: config.maxAge,
|
|
80
|
+
type: config.type,
|
|
81
|
+
});
|
|
82
|
+
// 503 rather than 401, so a client keeps its attestation instead of
|
|
83
|
+
// discarding it and asking for a new code while the issuer is down.
|
|
84
|
+
// A later token may still verify, so an outage is answered only if none does.
|
|
85
|
+
if (result.status === 'invalid' && result.unavailable) {
|
|
86
|
+
unavailable ??= result.reason;
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (result.status === 'invalid') {
|
|
90
|
+
reason = result.reason;
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
const rejected = await config.validate?.(result.claims, request);
|
|
94
|
+
// A later attestation, such as another address, may still be allowed.
|
|
95
|
+
if (rejected) {
|
|
96
|
+
forbidden ??= rejected;
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
return { status: 'valid', value: { claims: result.claims } };
|
|
100
|
+
}
|
|
101
|
+
if (forbidden)
|
|
102
|
+
return { status: 'invalid', code: 403, reason: forbidden };
|
|
103
|
+
if (unavailable)
|
|
104
|
+
return { status: 'invalid', code: 503, reason: unavailable };
|
|
105
|
+
// The client may obtain a fresh attestation and retry.
|
|
106
|
+
return { status: 'invalid', code: 401, headers: required, reason };
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/** Most distinct attestations of one type and issuer verified per request. */
|
|
111
|
+
const maxCandidates = 3;
|
|
112
|
+
/** An audience as the origin attestations carry, so `https://api.example/` matches. */
|
|
113
|
+
function origin(audience) {
|
|
114
|
+
return URL.canParse(audience) ? new URL(audience).origin : audience;
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=Verifier.js.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type * as Identity from '../../../../identity/Types.js';
|
|
2
|
+
import type { MaybePromise } from '../../../../internal/types.js';
|
|
3
|
+
import type * as AttestationTypes from '../internal/Types.js';
|
|
4
|
+
import type * as Types from '../Types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Creates a request-stage verifier that requires a verified email address.
|
|
7
|
+
*
|
|
8
|
+
* A request without one gets 401 with `Identity-Attestation-Required: email;issuer="…"`.
|
|
9
|
+
* The client obtains an attestation from the issuer with a one-time code sent to
|
|
10
|
+
* the address and sends it in `Identity-Attestation`. `allow` applies the
|
|
11
|
+
* route's policy, such as a domain allowlist.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const email = EmailOtp.Server.verifier({
|
|
16
|
+
* audience: 'https://api.example',
|
|
17
|
+
* issuer: 'https://issuer.example',
|
|
18
|
+
* allow: (email) => email.endsWith('@example.com'),
|
|
19
|
+
* })
|
|
20
|
+
* const result = await mppx.charge({ amount: '1', identity: [email] })(request)
|
|
21
|
+
* if (result.status === 200) result.identity?.get(email)?.email
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function verifier(config: verifier.Config): Identity.Verifier<Types.VerifiedEmail>;
|
|
25
|
+
export declare namespace verifier {
|
|
26
|
+
type Config = {
|
|
27
|
+
/** Trusted issuer URL. */
|
|
28
|
+
issuer: string;
|
|
29
|
+
/** Accepts or rejects (403) a verified, lowercased email address. Defaults to any. */
|
|
30
|
+
allow?: ((email: string, request: Request) => MaybePromise<boolean>) | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* This server's public origin, such as `https://api.example`, which attestations must be bound to.
|
|
33
|
+
*
|
|
34
|
+
* A function may derive it from the request only where the platform
|
|
35
|
+
* guarantees the request's host (such as a Cloudflare Worker route).
|
|
36
|
+
*/
|
|
37
|
+
audience: string | ((request: Request) => string);
|
|
38
|
+
/** Resolves issuer keys. Defaults to the issuer's JSON Web Key Set. */
|
|
39
|
+
keyResolver?: AttestationTypes.KeyResolver | undefined;
|
|
40
|
+
/** Fetch used for the default JSON Web Key Set resolver. */
|
|
41
|
+
fetch?: typeof globalThis.fetch | undefined;
|
|
42
|
+
/** Oldest accepted attestation, in seconds since it was issued. Defaults to its own expiry. */
|
|
43
|
+
maxAge?: number | undefined;
|
|
44
|
+
/** Clock tolerance in seconds. @default 60 */
|
|
45
|
+
clockTolerance?: number | undefined;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Constants } from '../Constants.js';
|
|
2
|
+
import * as Attestation from '../internal/Verifier.js';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a request-stage verifier that requires a verified email address.
|
|
5
|
+
*
|
|
6
|
+
* A request without one gets 401 with `Identity-Attestation-Required: email;issuer="…"`.
|
|
7
|
+
* The client obtains an attestation from the issuer with a one-time code sent to
|
|
8
|
+
* the address and sends it in `Identity-Attestation`. `allow` applies the
|
|
9
|
+
* route's policy, such as a domain allowlist.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const email = EmailOtp.Server.verifier({
|
|
14
|
+
* audience: 'https://api.example',
|
|
15
|
+
* issuer: 'https://issuer.example',
|
|
16
|
+
* allow: (email) => email.endsWith('@example.com'),
|
|
17
|
+
* })
|
|
18
|
+
* const result = await mppx.charge({ amount: '1', identity: [email] })(request)
|
|
19
|
+
* if (result.status === 200) result.identity?.get(email)?.email
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export function verifier(config) {
|
|
23
|
+
const inner = Attestation.verifier({
|
|
24
|
+
audience: config.audience,
|
|
25
|
+
clockTolerance: config.clockTolerance,
|
|
26
|
+
fetch: config.fetch,
|
|
27
|
+
issuer: config.issuer,
|
|
28
|
+
keyResolver: config.keyResolver,
|
|
29
|
+
maxAge: config.maxAge,
|
|
30
|
+
type: Constants.type,
|
|
31
|
+
async validate(claims, request) {
|
|
32
|
+
if (!config.allow || (await config.allow(claims.sub.toLowerCase(), request)))
|
|
33
|
+
return undefined;
|
|
34
|
+
return 'This email address is not allowed.';
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
return {
|
|
38
|
+
stage: 'request',
|
|
39
|
+
async verify(request, context) {
|
|
40
|
+
const result = await inner.verify(request, context);
|
|
41
|
+
if (result.status !== 'valid')
|
|
42
|
+
return result;
|
|
43
|
+
const { claims } = result.value;
|
|
44
|
+
return {
|
|
45
|
+
status: 'valid',
|
|
46
|
+
value: {
|
|
47
|
+
email: claims.sub.toLowerCase(),
|
|
48
|
+
expiresAt: new Date(claims.exp * 1_000),
|
|
49
|
+
id: claims.jti,
|
|
50
|
+
issuer: claims.iss,
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** Email address verification with a one-time code. */
|
|
2
|
+
export * as EmailOtp from './email-otp/index.js';
|
|
1
3
|
/** Client and server adapters for the TAP agent-recognition signature profile. */
|
|
2
4
|
export * as Tap from './tap/index.js';
|
|
3
5
|
/** Client and server adapters for the Web Bot Auth HTTPS-directory profile. */
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** Email address verification with a one-time code. */
|
|
2
|
+
export * as EmailOtp from './email-otp/index.js';
|
|
1
3
|
/** Client and server adapters for the TAP agent-recognition signature profile. */
|
|
2
4
|
export * as Tap from './tap/index.js';
|
|
3
5
|
/** Client and server adapters for the Web Bot Auth HTTPS-directory profile. */
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { MaybePromise } from '../internal/types.js';
|
|
2
|
+
import type * as Types from './Types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a request-stage verifier from a function, such as a lookup in your
|
|
5
|
+
* own database, session store or KYC provider.
|
|
6
|
+
*
|
|
7
|
+
* `verify` returns the caller's identity, which the route handler reads with
|
|
8
|
+
* `result.identity.get(verifier)`; `undefined` or `null` when the request carries none
|
|
9
|
+
* (401, with `challenge` headers if set); or throws a {@link Rejection} to
|
|
10
|
+
* reject the identity it carries.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const customer = Identity.from({
|
|
15
|
+
* async verify(request) {
|
|
16
|
+
* const key = request.headers.get('X-Api-Key')
|
|
17
|
+
* if (!key) return undefined
|
|
18
|
+
* const row = await db.customerByKey(key)
|
|
19
|
+
* if (!row) throw new Identity.Rejection('Unknown API key.', { code: 403 })
|
|
20
|
+
* return row
|
|
21
|
+
* },
|
|
22
|
+
* })
|
|
23
|
+
* mppx.charge({ amount: '1', identity: [customer] })
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function from<value>(config: from.Config<value>): Types.Verifier<value>;
|
|
27
|
+
export declare namespace from {
|
|
28
|
+
type Config<value> = {
|
|
29
|
+
/**
|
|
30
|
+
* Returns the request's verified identity, `undefined` or `null` when it carries none,
|
|
31
|
+
* or throws a {@link Rejection} to reject the one it carries.
|
|
32
|
+
*/
|
|
33
|
+
verify: (request: Request) => MaybePromise<value | null | undefined>;
|
|
34
|
+
/** Headers sent with a rejection, telling the client what identity to present. */
|
|
35
|
+
challenge?: HeadersInit | undefined;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/** Rejects an identity a {@link from} verifier was given. */
|
|
39
|
+
export declare class Rejection extends Error {
|
|
40
|
+
readonly name = "Rejection";
|
|
41
|
+
/** HTTP status of the rejection. @default 401 */
|
|
42
|
+
readonly code: number;
|
|
43
|
+
constructor(message: string, options?: {
|
|
44
|
+
code?: number | undefined;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=Callback.d.ts.map
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a request-stage verifier from a function, such as a lookup in your
|
|
3
|
+
* own database, session store or KYC provider.
|
|
4
|
+
*
|
|
5
|
+
* `verify` returns the caller's identity, which the route handler reads with
|
|
6
|
+
* `result.identity.get(verifier)`; `undefined` or `null` when the request carries none
|
|
7
|
+
* (401, with `challenge` headers if set); or throws a {@link Rejection} to
|
|
8
|
+
* reject the identity it carries.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const customer = Identity.from({
|
|
13
|
+
* async verify(request) {
|
|
14
|
+
* const key = request.headers.get('X-Api-Key')
|
|
15
|
+
* if (!key) return undefined
|
|
16
|
+
* const row = await db.customerByKey(key)
|
|
17
|
+
* if (!row) throw new Identity.Rejection('Unknown API key.', { code: 403 })
|
|
18
|
+
* return row
|
|
19
|
+
* },
|
|
20
|
+
* })
|
|
21
|
+
* mppx.charge({ amount: '1', identity: [customer] })
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export function from(config) {
|
|
25
|
+
return {
|
|
26
|
+
stage: 'request',
|
|
27
|
+
async verify(request) {
|
|
28
|
+
let value;
|
|
29
|
+
try {
|
|
30
|
+
value = await config.verify(request);
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
if (!(error instanceof Rejection))
|
|
34
|
+
throw error;
|
|
35
|
+
return {
|
|
36
|
+
status: 'invalid',
|
|
37
|
+
code: error.code,
|
|
38
|
+
headers: config.challenge,
|
|
39
|
+
reason: error.message,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
// A lookup that found nothing often returns null: treat it as no identity.
|
|
43
|
+
if (value === undefined || value === null)
|
|
44
|
+
return {
|
|
45
|
+
status: 'missing',
|
|
46
|
+
code: 401,
|
|
47
|
+
headers: config.challenge,
|
|
48
|
+
reason: 'Identity verification is required.',
|
|
49
|
+
};
|
|
50
|
+
return { status: 'valid', value };
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/** Rejects an identity a {@link from} verifier was given. */
|
|
55
|
+
export class Rejection extends Error {
|
|
56
|
+
name = 'Rejection';
|
|
57
|
+
/** HTTP status of the rejection. @default 401 */
|
|
58
|
+
code;
|
|
59
|
+
constructor(message, options = {}) {
|
|
60
|
+
super(message);
|
|
61
|
+
this.code = options.code ?? 401;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=Callback.js.map
|
package/dist/identity/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * as Client from './Client.js';
|
|
2
2
|
export * as Server from './Server.js';
|
|
3
3
|
export { anyOf } from './Server.js';
|
|
4
|
+
export { from, Rejection } from './Callback.js';
|
|
4
5
|
export * as Store from '../Store.js';
|
|
5
6
|
export type * from './Types.js';
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/identity/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Current mppx package version. */
|
|
2
|
-
export declare const version = "0.17.
|
|
2
|
+
export declare const version = "0.17.6";
|
|
3
3
|
/** Canonical SDK identifier for this mppx release. */
|
|
4
|
-
export declare const sdkIdentifier = "mppx/0.17.
|
|
4
|
+
export declare const sdkIdentifier = "mppx/0.17.6";
|
|
5
5
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/internal/version.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Generated by scripts/sync-version.ts.
|
|
2
2
|
/** Current mppx package version. */
|
|
3
|
-
export const version = '0.17.
|
|
3
|
+
export const version = '0.17.6';
|
|
4
4
|
/** Canonical SDK identifier for this mppx release. */
|
|
5
5
|
export const sdkIdentifier = `mppx/${version}`;
|
|
6
6
|
//# sourceMappingURL=version.js.map
|
|
@@ -11,6 +11,8 @@ const hopByHopHeaders = new Set([
|
|
|
11
11
|
// Payment credentials are consumed by the proxy and must never reach upstream services.
|
|
12
12
|
const paymentHeaders = new Set([
|
|
13
13
|
'accept-payment',
|
|
14
|
+
'identity-attestation',
|
|
15
|
+
'identity-attestation-required',
|
|
14
16
|
'authorization',
|
|
15
17
|
'payment-authorization',
|
|
16
18
|
'payment-receipt',
|