@daski/x402-scheme 0.1.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/LICENSE +21 -0
- package/README.md +81 -0
- package/dist/binding.d.ts +37 -0
- package/dist/binding.d.ts.map +1 -0
- package/dist/binding.js +74 -0
- package/dist/binding.js.map +1 -0
- package/dist/canonical.d.ts +12 -0
- package/dist/canonical.d.ts.map +1 -0
- package/dist/canonical.js +53 -0
- package/dist/canonical.js.map +1 -0
- package/dist/eip712.d.ts +72 -0
- package/dist/eip712.d.ts.map +1 -0
- package/dist/eip712.js +61 -0
- package/dist/eip712.js.map +1 -0
- package/dist/errors.d.ts +34 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +32 -0
- package/dist/errors.js.map +1 -0
- package/dist/extensions.d.ts +29 -0
- package/dist/extensions.d.ts.map +1 -0
- package/dist/extensions.js +65 -0
- package/dist/extensions.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/lifecycle.d.ts +177 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +345 -0
- package/dist/lifecycle.js.map +1 -0
- package/dist/policy.d.ts +113 -0
- package/dist/policy.d.ts.map +1 -0
- package/dist/policy.js +357 -0
- package/dist/policy.js.map +1 -0
- package/dist/recipe.d.ts +40 -0
- package/dist/recipe.d.ts.map +1 -0
- package/dist/recipe.js +61 -0
- package/dist/recipe.js.map +1 -0
- package/dist/register.d.ts +36 -0
- package/dist/register.d.ts.map +1 -0
- package/dist/register.js +12 -0
- package/dist/register.js.map +1 -0
- package/dist/scheme.d.ts +92 -0
- package/dist/scheme.d.ts.map +1 -0
- package/dist/scheme.js +182 -0
- package/dist/scheme.js.map +1 -0
- package/dist/signRequest.d.ts +30 -0
- package/dist/signRequest.d.ts.map +1 -0
- package/dist/signRequest.js +83 -0
- package/dist/signRequest.js.map +1 -0
- package/dist/signer.d.ts +38 -0
- package/dist/signer.d.ts.map +1 -0
- package/dist/signer.js +12 -0
- package/dist/signer.js.map +1 -0
- package/package.json +53 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@daski/x402-scheme` — the composite Exact-EVM client plugin, and the
|
|
3
|
+
* policy validator both this package and `@daski/pay` sign through.
|
|
4
|
+
*
|
|
5
|
+
* The rule that shapes the whole surface: the server proposes, this package
|
|
6
|
+
* validates against its own expectations and recomputes, the wallet signs,
|
|
7
|
+
* and the gateway never sees the key. There is no exported "just sign this"
|
|
8
|
+
* function, and there never will be.
|
|
9
|
+
*/
|
|
10
|
+
export { parseOrderBinding, type OrderBinding, type OrderBindingV1, type OrderBindingV2, } from "./binding.js";
|
|
11
|
+
export { canonicalHash, canonicalJson } from "./canonical.js";
|
|
12
|
+
export { AUTHORIZATION_FIELDS, isClosedTransferWithAuthorizationTypes, TRANSFER_WITH_AUTHORIZATION_PRIMARY_TYPE, TRANSFER_WITH_AUTHORIZATION_TYPES, transferWithAuthorizationTypedData, type Eip712Domain, type TransferAuthorization, type TypedDataRequest, } from "./eip712.js";
|
|
13
|
+
export { PolicyRefusal, refuse, type PolicyCheck, type PolicyRefusalDetail, } from "./errors.js";
|
|
14
|
+
export { DASKI_ORDER_BINDING, DASKI_SIGN_REQUEST, issuedPaymentIdentifier, PAYMENT_IDENTIFIER, PAYMENT_IDENTIFIER_PATTERN, paymentEchoExtensions, withPaymentIdentifier, } from "./extensions.js";
|
|
15
|
+
export { LIFECYCLE_CLOCK_SKEW_SECONDS, MAX_LIFECYCLE_LIFETIME_SECONDS, ORDER_ACTION_TYPES, orderActionResourceUri, orderActionTypedData, validateOrderActionChallenge, validateWalletActionChallenge, WALLET_ACTION_TYPES, walletActionTypedData, type OrderAction, type OrderActionAuthorization, type OrderActionChallenge, type OrderActionExpectations, type WalletActionChallenge, type WalletActionExpectations, } from "./lifecycle.js";
|
|
16
|
+
export { bindingFromExtensions, DEFAULT_MAX_AUTHORIZATION_LIFETIME_SECONDS, DEFAULT_MAX_BACKDATE_SECONDS, DEFAULT_MIN_AUTHORIZATION_LIFETIME_SECONDS, formatUsdc, parseUsdcToAtomic, USDC_DECIMALS, validatePurchaseAuthorization, type PolicyConfig, type PurchaseExpectations, type SessionLedger, type SplitterEvidence, type SplitterResolver, type ValidatedPurchase, } from "./policy.js";
|
|
17
|
+
export { deriveBindingNonce, RECIPE_NONCE_DOMAIN_V1, RECIPE_NONCE_DOMAIN_V2, recipeNonce, recipeNonceV2, type RecipeNonceV1Input, type RecipeNonceV2Input, type RecipePaymentFacts, } from "./recipe.js";
|
|
18
|
+
export { registerDaskiExactEvmScheme, type RegisterOptions, type X402ClientLike } from "./register.js";
|
|
19
|
+
export { DaskiExactEvmScheme, type DaskiExactEvmSchemeOptions, type PaymentPayloadContextLike, type PaymentPayloadResultLike, type PaymentRequirementsLike, type PurchaseContextResolver, type SchemeNetworkClientLike, } from "./scheme.js";
|
|
20
|
+
export { parseSignRequest, proposedNonce, type ParsedSignRequest } from "./signRequest.js";
|
|
21
|
+
export { toClientEvmSigner, type SignerAdapter, type SignerDescription, } from "./signer.js";
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EACL,iBAAiB,EACjB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,cAAc,GACpB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE9D,OAAO,EACL,oBAAoB,EACpB,sCAAsC,EACtC,wCAAwC,EACxC,iCAAiC,EACjC,kCAAkC,EAClC,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,GACtB,MAAM,aA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AAC;AAErB,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE3F,OAAO,EACL,iBAAiB,EACjB,KAAK,aAAa,EAClB,KAAK,iBAAiB,GACvB,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@daski/x402-scheme` — the composite Exact-EVM client plugin, and the
|
|
3
|
+
* policy validator both this package and `@daski/pay` sign through.
|
|
4
|
+
*
|
|
5
|
+
* The rule that shapes the whole surface: the server proposes, this package
|
|
6
|
+
* validates against its own expectations and recomputes, the wallet signs,
|
|
7
|
+
* and the gateway never sees the key. There is no exported "just sign this"
|
|
8
|
+
* function, and there never will be.
|
|
9
|
+
*/
|
|
10
|
+
export { parseOrderBinding, } from "./binding.js";
|
|
11
|
+
export { canonicalHash, canonicalJson } from "./canonical.js";
|
|
12
|
+
export { AUTHORIZATION_FIELDS, isClosedTransferWithAuthorizationTypes, TRANSFER_WITH_AUTHORIZATION_PRIMARY_TYPE, TRANSFER_WITH_AUTHORIZATION_TYPES, transferWithAuthorizationTypedData, } from "./eip712.js";
|
|
13
|
+
export { PolicyRefusal, refuse, } from "./errors.js";
|
|
14
|
+
export { DASKI_ORDER_BINDING, DASKI_SIGN_REQUEST, issuedPaymentIdentifier, PAYMENT_IDENTIFIER, PAYMENT_IDENTIFIER_PATTERN, paymentEchoExtensions, withPaymentIdentifier, } from "./extensions.js";
|
|
15
|
+
export { LIFECYCLE_CLOCK_SKEW_SECONDS, MAX_LIFECYCLE_LIFETIME_SECONDS, ORDER_ACTION_TYPES, orderActionResourceUri, orderActionTypedData, validateOrderActionChallenge, validateWalletActionChallenge, WALLET_ACTION_TYPES, walletActionTypedData, } from "./lifecycle.js";
|
|
16
|
+
export { bindingFromExtensions, DEFAULT_MAX_AUTHORIZATION_LIFETIME_SECONDS, DEFAULT_MAX_BACKDATE_SECONDS, DEFAULT_MIN_AUTHORIZATION_LIFETIME_SECONDS, formatUsdc, parseUsdcToAtomic, USDC_DECIMALS, validatePurchaseAuthorization, } from "./policy.js";
|
|
17
|
+
export { deriveBindingNonce, RECIPE_NONCE_DOMAIN_V1, RECIPE_NONCE_DOMAIN_V2, recipeNonce, recipeNonceV2, } from "./recipe.js";
|
|
18
|
+
export { registerDaskiExactEvmScheme } from "./register.js";
|
|
19
|
+
export { DaskiExactEvmScheme, } from "./scheme.js";
|
|
20
|
+
export { parseSignRequest, proposedNonce } from "./signRequest.js";
|
|
21
|
+
export { toClientEvmSigner, } from "./signer.js";
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EACL,iBAAiB,GAIlB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE9D,OAAO,EACL,oBAAoB,EACpB,sCAAsC,EACtC,wCAAwC,EACxC,iCAAiC,EACjC,kCAAkC,GAInC,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,aAAa,EACb,MAAM,GAGP,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,uBAAuB,EACvB,kBAAkB,EAClB,0BAA0B,EAC1B,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,4BAA4B,EAC5B,8BAA8B,EAC9B,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACpB,4BAA4B,EAC5B,6BAA6B,EAC7B,mBAAmB,EACnB,qBAAqB,GAOtB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,qBAAqB,EACrB,0CAA0C,EAC1C,4BAA4B,EAC5B,0CAA0C,EAC1C,UAAU,EACV,iBAAiB,EACjB,aAAa,EACb,6BAA6B,GAO9B,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,WAAW,EACX,aAAa,GAId,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,2BAA2B,EAA6C,MAAM,eAAe,CAAC;AAEvG,OAAO,EACL,mBAAmB,GAOpB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAA0B,MAAM,kBAAkB,CAAC;AAE3F,OAAO,EACL,iBAAiB,GAGlB,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* §4.1 check 8 — the lifecycle variant of the policy validator.
|
|
3
|
+
*
|
|
4
|
+
* Order actions and wallet queries are authorized with their own EIP-712
|
|
5
|
+
* families. They move no money, but they do move *authority*, so they get the
|
|
6
|
+
* same treatment: closed type sets, an orderId that matches the order we
|
|
7
|
+
* meant to touch, method and URI hash inputs recomputed from what the CLI is
|
|
8
|
+
* actually about to call, and a short expiry.
|
|
9
|
+
*
|
|
10
|
+
* Because the gateway derives the challenge's `absoluteResourceUri` and
|
|
11
|
+
* `requestHash` deterministically, the bridge recomputes both rather than
|
|
12
|
+
* accepting them. A challenge that hashes a different request than the one we
|
|
13
|
+
* are about to send is a challenge for someone else's call.
|
|
14
|
+
*/
|
|
15
|
+
import { type Address, type Hex } from "viem";
|
|
16
|
+
import type { TypedDataRequest } from "./eip712.js";
|
|
17
|
+
/** Order lifecycle actions, as the gateway names them. */
|
|
18
|
+
export type OrderAction = "status" | "input" | "cancel" | "artifact" | "support" | "confirmation" | "revoke-confirmation";
|
|
19
|
+
/** The closed 9-field order-action family. */
|
|
20
|
+
export declare const ORDER_ACTION_TYPES: {
|
|
21
|
+
readonly OrderActionAuthorizationV1: readonly [{
|
|
22
|
+
readonly name: "orderIdHash";
|
|
23
|
+
readonly type: "bytes32";
|
|
24
|
+
}, {
|
|
25
|
+
readonly name: "actionHash";
|
|
26
|
+
readonly type: "bytes32";
|
|
27
|
+
}, {
|
|
28
|
+
readonly name: "methodHash";
|
|
29
|
+
readonly type: "bytes32";
|
|
30
|
+
}, {
|
|
31
|
+
readonly name: "absoluteResourceUriHash";
|
|
32
|
+
readonly type: "bytes32";
|
|
33
|
+
}, {
|
|
34
|
+
readonly name: "requestHash";
|
|
35
|
+
readonly type: "bytes32";
|
|
36
|
+
}, {
|
|
37
|
+
readonly name: "audienceHash";
|
|
38
|
+
readonly type: "bytes32";
|
|
39
|
+
}, {
|
|
40
|
+
readonly name: "nonce";
|
|
41
|
+
readonly type: "bytes32";
|
|
42
|
+
}, {
|
|
43
|
+
readonly name: "issuedAt";
|
|
44
|
+
readonly type: "uint64";
|
|
45
|
+
}, {
|
|
46
|
+
readonly name: "validBefore";
|
|
47
|
+
readonly type: "uint64";
|
|
48
|
+
}];
|
|
49
|
+
};
|
|
50
|
+
/** The closed 17-field wallet-action family, used by payer-scoped queries. */
|
|
51
|
+
export declare const WALLET_ACTION_TYPES: {
|
|
52
|
+
readonly WalletActionAuthorizationV1: readonly [{
|
|
53
|
+
readonly name: "payer";
|
|
54
|
+
readonly type: "address";
|
|
55
|
+
}, {
|
|
56
|
+
readonly name: "providerAgentId";
|
|
57
|
+
readonly type: "uint256";
|
|
58
|
+
}, {
|
|
59
|
+
readonly name: "serviceId";
|
|
60
|
+
readonly type: "bytes32";
|
|
61
|
+
}, {
|
|
62
|
+
readonly name: "providerControlProfileHash";
|
|
63
|
+
readonly type: "bytes32";
|
|
64
|
+
}, {
|
|
65
|
+
readonly name: "servicingAdmissionHash";
|
|
66
|
+
readonly type: "bytes32";
|
|
67
|
+
}, {
|
|
68
|
+
readonly name: "actionCatalogHash";
|
|
69
|
+
readonly type: "bytes32";
|
|
70
|
+
}, {
|
|
71
|
+
readonly name: "actionCatalogSchemaHash";
|
|
72
|
+
readonly type: "bytes32";
|
|
73
|
+
}, {
|
|
74
|
+
readonly name: "actionDefinitionHash";
|
|
75
|
+
readonly type: "bytes32";
|
|
76
|
+
}, {
|
|
77
|
+
readonly name: "actionCatalogEpoch";
|
|
78
|
+
readonly type: "uint64";
|
|
79
|
+
}, {
|
|
80
|
+
readonly name: "actionHash";
|
|
81
|
+
readonly type: "bytes32";
|
|
82
|
+
}, {
|
|
83
|
+
readonly name: "methodHash";
|
|
84
|
+
readonly type: "bytes32";
|
|
85
|
+
}, {
|
|
86
|
+
readonly name: "absoluteResourceUriHash";
|
|
87
|
+
readonly type: "bytes32";
|
|
88
|
+
}, {
|
|
89
|
+
readonly name: "requestHash";
|
|
90
|
+
readonly type: "bytes32";
|
|
91
|
+
}, {
|
|
92
|
+
readonly name: "audienceHash";
|
|
93
|
+
readonly type: "bytes32";
|
|
94
|
+
}, {
|
|
95
|
+
readonly name: "nonce";
|
|
96
|
+
readonly type: "bytes32";
|
|
97
|
+
}, {
|
|
98
|
+
readonly name: "issuedAt";
|
|
99
|
+
readonly type: "uint64";
|
|
100
|
+
}, {
|
|
101
|
+
readonly name: "validBefore";
|
|
102
|
+
readonly type: "uint64";
|
|
103
|
+
}];
|
|
104
|
+
};
|
|
105
|
+
/** The longest lifecycle authorization this bridge will sign. */
|
|
106
|
+
export declare const MAX_LIFECYCLE_LIFETIME_SECONDS = 300;
|
|
107
|
+
/** Tolerance for a gateway clock running slightly ahead of ours. */
|
|
108
|
+
export declare const LIFECYCLE_CLOCK_SKEW_SECONDS = 30;
|
|
109
|
+
export interface OrderActionChallenge {
|
|
110
|
+
orderId: string;
|
|
111
|
+
action: OrderAction;
|
|
112
|
+
method: "POST";
|
|
113
|
+
absoluteResourceUri: string;
|
|
114
|
+
requestHash: Hex;
|
|
115
|
+
nonce: Hex;
|
|
116
|
+
issuedAt: number;
|
|
117
|
+
validBefore: number;
|
|
118
|
+
}
|
|
119
|
+
export interface OrderActionAuthorization extends OrderActionChallenge {
|
|
120
|
+
signature: Hex;
|
|
121
|
+
}
|
|
122
|
+
/** What the CLI is about to do, stated before the challenge is read. */
|
|
123
|
+
export interface OrderActionExpectations {
|
|
124
|
+
/** The handle the CLI resolved from its own order store. */
|
|
125
|
+
orderHandle: string;
|
|
126
|
+
/** The action the CLI is performing. */
|
|
127
|
+
action: OrderAction;
|
|
128
|
+
/** The gateway base URL from the active profile. */
|
|
129
|
+
gatewayUrl: string;
|
|
130
|
+
/** The exact request body the CLI will send. */
|
|
131
|
+
request: Record<string, unknown>;
|
|
132
|
+
nowSeconds?: number;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* The URI the gateway derives for an order action. Recomputing it is what
|
|
136
|
+
* turns "the server said this URI" into "this URI is the one we would call".
|
|
137
|
+
*/
|
|
138
|
+
export declare function orderActionResourceUri(gatewayUrl: string, orderHandle: string, action: OrderAction): string;
|
|
139
|
+
/** Parses and validates an order-action challenge against §4.1 check 8. */
|
|
140
|
+
export declare function validateOrderActionChallenge(value: unknown, expectations: OrderActionExpectations): OrderActionChallenge;
|
|
141
|
+
/**
|
|
142
|
+
* The typed-data payload for a validated order-action challenge. Every hash
|
|
143
|
+
* input is computed here from the validated challenge — the signer is handed
|
|
144
|
+
* a message this package built, not one the gateway sent.
|
|
145
|
+
*/
|
|
146
|
+
export declare function orderActionTypedData(challenge: OrderActionChallenge, chainId: number, audience: string): TypedDataRequest;
|
|
147
|
+
export interface WalletActionExpectations {
|
|
148
|
+
/** The payer whose history is being read. */
|
|
149
|
+
payer: Address;
|
|
150
|
+
/** The wallet action, e.g. `list-orders`. */
|
|
151
|
+
action: string;
|
|
152
|
+
/** The gateway audience for the active profile. */
|
|
153
|
+
audience: string;
|
|
154
|
+
/** The exact request body the CLI will send. */
|
|
155
|
+
request: Record<string, unknown>;
|
|
156
|
+
/** True only for provider-scoped asset actions. */
|
|
157
|
+
requireProviderBinding: boolean;
|
|
158
|
+
nowSeconds?: number;
|
|
159
|
+
}
|
|
160
|
+
export interface WalletActionChallenge {
|
|
161
|
+
domain: {
|
|
162
|
+
name: string;
|
|
163
|
+
version: string;
|
|
164
|
+
chainId: number;
|
|
165
|
+
};
|
|
166
|
+
primaryType: "WalletActionAuthorizationV1";
|
|
167
|
+
message: Record<string, unknown>;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Validates a wallet-action challenge: closed 17-field message, our payer,
|
|
171
|
+
* our audience, our action, a short window, and — for the unbound variant —
|
|
172
|
+
* proof that every provider slot really is zeroed.
|
|
173
|
+
*/
|
|
174
|
+
export declare function validateWalletActionChallenge(value: unknown, chainId: number, expectations: WalletActionExpectations): WalletActionChallenge;
|
|
175
|
+
/** The typed-data payload for a validated wallet-action challenge. */
|
|
176
|
+
export declare function walletActionTypedData(challenge: WalletActionChallenge): TypedDataRequest;
|
|
177
|
+
//# sourceMappingURL=lifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../src/lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAsC,KAAK,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AAGlF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAKpD,0DAA0D;AAC1D,MAAM,MAAM,WAAW,GACnB,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,GACtD,cAAc,GAAG,qBAAqB,CAAC;AAE3C,8CAA8C;AAC9C,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAYrB,CAAC;AAEX,8EAA8E;AAC9E,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoBtB,CAAC;AAUX,iEAAiE;AACjE,eAAO,MAAM,8BAA8B,MAAM,CAAC;AAClD,oEAAoE;AACpE,eAAO,MAAM,4BAA4B,KAAK,CAAC;AAE/C,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IA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AC;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3D,WAAW,EAAE,6BAA6B,CAAC;IAC3C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,wBAAwB,GACrC,qBAAqB,CAmHvB;AAED,sEAAsE;AACtE,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,qBAAqB,GAAG,gBAAgB,CAcxF"}
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* §4.1 check 8 — the lifecycle variant of the policy validator.
|
|
3
|
+
*
|
|
4
|
+
* Order actions and wallet queries are authorized with their own EIP-712
|
|
5
|
+
* families. They move no money, but they do move *authority*, so they get the
|
|
6
|
+
* same treatment: closed type sets, an orderId that matches the order we
|
|
7
|
+
* meant to touch, method and URI hash inputs recomputed from what the CLI is
|
|
8
|
+
* actually about to call, and a short expiry.
|
|
9
|
+
*
|
|
10
|
+
* Because the gateway derives the challenge's `absoluteResourceUri` and
|
|
11
|
+
* `requestHash` deterministically, the bridge recomputes both rather than
|
|
12
|
+
* accepting them. A challenge that hashes a different request than the one we
|
|
13
|
+
* are about to send is a challenge for someone else's call.
|
|
14
|
+
*/
|
|
15
|
+
import { getAddress, keccak256, stringToHex } from "viem";
|
|
16
|
+
import { canonicalHash } from "./canonical.js";
|
|
17
|
+
import { refuse } from "./errors.js";
|
|
18
|
+
const DOC = "https://github.com/daski-io/buyer/blob/main/docs/policy.md#lifecycle";
|
|
19
|
+
const HEX32 = /^0x[0-9a-fA-F]{64}$/;
|
|
20
|
+
/** The closed 9-field order-action family. */
|
|
21
|
+
export const ORDER_ACTION_TYPES = {
|
|
22
|
+
OrderActionAuthorizationV1: [
|
|
23
|
+
{ name: "orderIdHash", type: "bytes32" },
|
|
24
|
+
{ name: "actionHash", type: "bytes32" },
|
|
25
|
+
{ name: "methodHash", type: "bytes32" },
|
|
26
|
+
{ name: "absoluteResourceUriHash", type: "bytes32" },
|
|
27
|
+
{ name: "requestHash", type: "bytes32" },
|
|
28
|
+
{ name: "audienceHash", type: "bytes32" },
|
|
29
|
+
{ name: "nonce", type: "bytes32" },
|
|
30
|
+
{ name: "issuedAt", type: "uint64" },
|
|
31
|
+
{ name: "validBefore", type: "uint64" },
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
/** The closed 17-field wallet-action family, used by payer-scoped queries. */
|
|
35
|
+
export const WALLET_ACTION_TYPES = {
|
|
36
|
+
WalletActionAuthorizationV1: [
|
|
37
|
+
{ name: "payer", type: "address" },
|
|
38
|
+
{ name: "providerAgentId", type: "uint256" },
|
|
39
|
+
{ name: "serviceId", type: "bytes32" },
|
|
40
|
+
{ name: "providerControlProfileHash", type: "bytes32" },
|
|
41
|
+
{ name: "servicingAdmissionHash", type: "bytes32" },
|
|
42
|
+
{ name: "actionCatalogHash", type: "bytes32" },
|
|
43
|
+
{ name: "actionCatalogSchemaHash", type: "bytes32" },
|
|
44
|
+
{ name: "actionDefinitionHash", type: "bytes32" },
|
|
45
|
+
{ name: "actionCatalogEpoch", type: "uint64" },
|
|
46
|
+
{ name: "actionHash", type: "bytes32" },
|
|
47
|
+
{ name: "methodHash", type: "bytes32" },
|
|
48
|
+
{ name: "absoluteResourceUriHash", type: "bytes32" },
|
|
49
|
+
{ name: "requestHash", type: "bytes32" },
|
|
50
|
+
{ name: "audienceHash", type: "bytes32" },
|
|
51
|
+
{ name: "nonce", type: "bytes32" },
|
|
52
|
+
{ name: "issuedAt", type: "uint64" },
|
|
53
|
+
{ name: "validBefore", type: "uint64" },
|
|
54
|
+
],
|
|
55
|
+
};
|
|
56
|
+
const ORDER_CHALLENGE_FIELDS = [
|
|
57
|
+
"orderId", "action", "method", "absoluteResourceUri", "requestHash",
|
|
58
|
+
"nonce", "issuedAt", "validBefore",
|
|
59
|
+
];
|
|
60
|
+
const WALLET_MESSAGE_FIELDS = WALLET_ACTION_TYPES.WalletActionAuthorizationV1
|
|
61
|
+
.map((field) => field.name);
|
|
62
|
+
/** The longest lifecycle authorization this bridge will sign. */
|
|
63
|
+
export const MAX_LIFECYCLE_LIFETIME_SECONDS = 300;
|
|
64
|
+
/** Tolerance for a gateway clock running slightly ahead of ours. */
|
|
65
|
+
export const LIFECYCLE_CLOCK_SKEW_SECONDS = 30;
|
|
66
|
+
/**
|
|
67
|
+
* The URI the gateway derives for an order action. Recomputing it is what
|
|
68
|
+
* turns "the server said this URI" into "this URI is the one we would call".
|
|
69
|
+
*/
|
|
70
|
+
export function orderActionResourceUri(gatewayUrl, orderHandle, action) {
|
|
71
|
+
const base = gatewayUrl.replace(/\/$/, "");
|
|
72
|
+
return `${base}/orders/${encodeURIComponent(orderHandle)}/actions/${action}`;
|
|
73
|
+
}
|
|
74
|
+
/** Parses and validates an order-action challenge against §4.1 check 8. */
|
|
75
|
+
export function validateOrderActionChallenge(value, expectations) {
|
|
76
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
77
|
+
refuse({
|
|
78
|
+
check: "lifecycle-binding",
|
|
79
|
+
code: "DASKI_LIFECYCLE_CHALLENGE_NOT_AN_OBJECT",
|
|
80
|
+
expected: "an order-action challenge object",
|
|
81
|
+
actual: Array.isArray(value) ? "an array" : typeof value,
|
|
82
|
+
remediation: `Retry the lifecycle call; see ${DOC}`,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
const challenge = value;
|
|
86
|
+
const keys = Object.keys(challenge).sort();
|
|
87
|
+
if (keys.join(",") !== [...ORDER_CHALLENGE_FIELDS].sort().join(",")) {
|
|
88
|
+
refuse({
|
|
89
|
+
check: "lifecycle-binding",
|
|
90
|
+
code: "DASKI_LIFECYCLE_CHALLENGE_OPEN_SHAPE",
|
|
91
|
+
expected: `exactly [${[...ORDER_CHALLENGE_FIELDS].sort().join(", ")}]`,
|
|
92
|
+
actual: `[${keys.join(", ")}]`,
|
|
93
|
+
remediation: `Upgrade @daski/x402-scheme; see ${DOC}`,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
if (typeof challenge.orderId !== "string" || challenge.orderId.length === 0 ||
|
|
97
|
+
typeof challenge.absoluteResourceUri !== "string" ||
|
|
98
|
+
!HEX32.test(String(challenge.requestHash)) || !HEX32.test(String(challenge.nonce)) ||
|
|
99
|
+
!Number.isSafeInteger(challenge.issuedAt) || !Number.isSafeInteger(challenge.validBefore)) {
|
|
100
|
+
refuse({
|
|
101
|
+
check: "lifecycle-binding",
|
|
102
|
+
code: "DASKI_LIFECYCLE_CHALLENGE_MALFORMED",
|
|
103
|
+
expected: "well-formed orderId, URI, hashes and timestamps",
|
|
104
|
+
actual: "one or more fields are malformed",
|
|
105
|
+
remediation: `Retry the lifecycle call; see ${DOC}`,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
if (challenge.method !== "POST") {
|
|
109
|
+
refuse({
|
|
110
|
+
check: "lifecycle-binding",
|
|
111
|
+
code: "DASKI_LIFECYCLE_METHOD_UNEXPECTED",
|
|
112
|
+
expected: "method POST",
|
|
113
|
+
actual: `method ${String(challenge.method)}`,
|
|
114
|
+
remediation: `See ${DOC}`,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
if (challenge.action !== expectations.action) {
|
|
118
|
+
refuse({
|
|
119
|
+
check: "lifecycle-binding",
|
|
120
|
+
code: "DASKI_LIFECYCLE_ACTION_MISMATCH",
|
|
121
|
+
expected: `action ${expectations.action}`,
|
|
122
|
+
actual: `action ${String(challenge.action)}`,
|
|
123
|
+
remediation: "The challenge authorizes a different action than the one requested. " +
|
|
124
|
+
`Do not sign it; see ${DOC}`,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
// The URI is derived, not declared: recompute and require equality. This is
|
|
128
|
+
// the check that stops a challenge from pointing our signature at another
|
|
129
|
+
// order or another host.
|
|
130
|
+
const expectedUri = orderActionResourceUri(expectations.gatewayUrl, expectations.orderHandle, expectations.action);
|
|
131
|
+
if (challenge.absoluteResourceUri !== expectedUri) {
|
|
132
|
+
refuse({
|
|
133
|
+
check: "lifecycle-binding",
|
|
134
|
+
code: "DASKI_LIFECYCLE_URI_MISMATCH",
|
|
135
|
+
expected: expectedUri,
|
|
136
|
+
actual: challenge.absoluteResourceUri,
|
|
137
|
+
remediation: "The challenge binds a resource URI we did not ask to call — a " +
|
|
138
|
+
`different order, action, or host. Do not sign it; see ${DOC}`,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
if (!/^https:\/\//.test(challenge.absoluteResourceUri)) {
|
|
142
|
+
refuse({
|
|
143
|
+
check: "lifecycle-binding",
|
|
144
|
+
code: "DASKI_LIFECYCLE_URI_NOT_HTTPS",
|
|
145
|
+
expected: "an https:// resource URI",
|
|
146
|
+
actual: challenge.absoluteResourceUri,
|
|
147
|
+
remediation: `See ${DOC}`,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
// Likewise the request hash: recompute it over the body we are about to send.
|
|
151
|
+
const expectedRequestHash = canonicalHash(expectations.request);
|
|
152
|
+
if (String(challenge.requestHash).toLowerCase() !== expectedRequestHash.toLowerCase()) {
|
|
153
|
+
refuse({
|
|
154
|
+
check: "lifecycle-binding",
|
|
155
|
+
code: "DASKI_LIFECYCLE_REQUEST_HASH_MISMATCH",
|
|
156
|
+
expected: `requestHash ${expectedRequestHash} (recomputed from the outgoing request)`,
|
|
157
|
+
actual: `requestHash ${String(challenge.requestHash)}`,
|
|
158
|
+
remediation: "The challenge commits to a different request body than the one we " +
|
|
159
|
+
`are about to send. Do not sign it; see ${DOC}`,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
assertShortLived(Number(challenge.issuedAt), Number(challenge.validBefore), expectations.nowSeconds);
|
|
163
|
+
return challenge;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* The typed-data payload for a validated order-action challenge. Every hash
|
|
167
|
+
* input is computed here from the validated challenge — the signer is handed
|
|
168
|
+
* a message this package built, not one the gateway sent.
|
|
169
|
+
*/
|
|
170
|
+
export function orderActionTypedData(challenge, chainId, audience) {
|
|
171
|
+
return {
|
|
172
|
+
domain: { name: "DaskiStandardOrder", version: "1", chainId },
|
|
173
|
+
types: ORDER_ACTION_TYPES,
|
|
174
|
+
primaryType: "OrderActionAuthorizationV1",
|
|
175
|
+
message: {
|
|
176
|
+
orderIdHash: keccak256(stringToHex(challenge.orderId)),
|
|
177
|
+
actionHash: keccak256(stringToHex(challenge.action)),
|
|
178
|
+
methodHash: keccak256(stringToHex(challenge.method)),
|
|
179
|
+
absoluteResourceUriHash: keccak256(stringToHex(challenge.absoluteResourceUri)),
|
|
180
|
+
requestHash: challenge.requestHash,
|
|
181
|
+
audienceHash: keccak256(stringToHex(audience)),
|
|
182
|
+
nonce: challenge.nonce,
|
|
183
|
+
issuedAt: BigInt(challenge.issuedAt),
|
|
184
|
+
validBefore: BigInt(challenge.validBefore),
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Validates a wallet-action challenge: closed 17-field message, our payer,
|
|
190
|
+
* our audience, our action, a short window, and — for the unbound variant —
|
|
191
|
+
* proof that every provider slot really is zeroed.
|
|
192
|
+
*/
|
|
193
|
+
export function validateWalletActionChallenge(value, chainId, expectations) {
|
|
194
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
195
|
+
refuse({
|
|
196
|
+
check: "lifecycle-binding",
|
|
197
|
+
code: "DASKI_WALLET_CHALLENGE_NOT_AN_OBJECT",
|
|
198
|
+
expected: "a wallet-action challenge object",
|
|
199
|
+
actual: Array.isArray(value) ? "an array" : typeof value,
|
|
200
|
+
remediation: `Retry the query; see ${DOC}`,
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
const challenge = value;
|
|
204
|
+
assertExactKeys(challenge, ["domain", "primaryType", "message"], "wallet challenge");
|
|
205
|
+
const domain = challenge.domain;
|
|
206
|
+
assertExactKeys(domain, ["name", "version", "chainId"], "wallet challenge domain");
|
|
207
|
+
const message = challenge.message;
|
|
208
|
+
assertExactKeys(message, WALLET_MESSAGE_FIELDS, "wallet challenge message");
|
|
209
|
+
if (domain.name !== "DaskiStandardWallet" || domain.version !== "1" ||
|
|
210
|
+
domain.chainId !== chainId) {
|
|
211
|
+
refuse({
|
|
212
|
+
check: "lifecycle-binding",
|
|
213
|
+
code: "DASKI_WALLET_DOMAIN_MISMATCH",
|
|
214
|
+
expected: `DaskiStandardWallet v1 on chain ${chainId}`,
|
|
215
|
+
actual: `${String(domain.name)} v${String(domain.version)} on chain ${String(domain.chainId)}`,
|
|
216
|
+
remediation: `See ${DOC}`,
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
if (challenge.primaryType !== "WalletActionAuthorizationV1") {
|
|
220
|
+
refuse({
|
|
221
|
+
check: "lifecycle-binding",
|
|
222
|
+
code: "DASKI_WALLET_PRIMARY_TYPE_MISMATCH",
|
|
223
|
+
expected: "WalletActionAuthorizationV1",
|
|
224
|
+
actual: String(challenge.primaryType),
|
|
225
|
+
remediation: `See ${DOC}`,
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
if (getAddress(String(message.payer)) !== getAddress(expectations.payer)) {
|
|
229
|
+
refuse({
|
|
230
|
+
check: "lifecycle-binding",
|
|
231
|
+
code: "DASKI_WALLET_PAYER_MISMATCH",
|
|
232
|
+
expected: `payer ${getAddress(expectations.payer)}`,
|
|
233
|
+
actual: `payer ${String(message.payer)}`,
|
|
234
|
+
remediation: `See ${DOC}`,
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
const expectedAction = keccak256(stringToHex(expectations.action));
|
|
238
|
+
if (String(message.actionHash).toLowerCase() !== expectedAction.toLowerCase()) {
|
|
239
|
+
refuse({
|
|
240
|
+
check: "lifecycle-binding",
|
|
241
|
+
code: "DASKI_WALLET_ACTION_MISMATCH",
|
|
242
|
+
expected: `actionHash for "${expectations.action}"`,
|
|
243
|
+
actual: `actionHash ${String(message.actionHash)}`,
|
|
244
|
+
remediation: `See ${DOC}`,
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
const expectedAudience = keccak256(stringToHex(expectations.audience));
|
|
248
|
+
if (String(message.audienceHash).toLowerCase() !== expectedAudience.toLowerCase()) {
|
|
249
|
+
refuse({
|
|
250
|
+
check: "lifecycle-binding",
|
|
251
|
+
code: "DASKI_WALLET_AUDIENCE_MISMATCH",
|
|
252
|
+
expected: `audienceHash for ${expectations.audience}`,
|
|
253
|
+
actual: `audienceHash ${String(message.audienceHash)}`,
|
|
254
|
+
remediation: "A signature bound to another audience could be replayed there. " +
|
|
255
|
+
`Do not sign it; see ${DOC}`,
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
const expectedRequestHash = canonicalHash(expectations.request);
|
|
259
|
+
if (String(message.requestHash).toLowerCase() !== expectedRequestHash.toLowerCase()) {
|
|
260
|
+
refuse({
|
|
261
|
+
check: "lifecycle-binding",
|
|
262
|
+
code: "DASKI_WALLET_REQUEST_HASH_MISMATCH",
|
|
263
|
+
expected: `requestHash ${expectedRequestHash} (recomputed from the outgoing request)`,
|
|
264
|
+
actual: `requestHash ${String(message.requestHash)}`,
|
|
265
|
+
remediation: `See ${DOC}`,
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
const zero = `0x${"00".repeat(32)}`;
|
|
269
|
+
const providerSlots = [
|
|
270
|
+
"serviceId", "providerControlProfileHash", "servicingAdmissionHash",
|
|
271
|
+
"actionCatalogHash", "actionCatalogSchemaHash", "actionDefinitionHash",
|
|
272
|
+
];
|
|
273
|
+
if (expectations.requireProviderBinding) {
|
|
274
|
+
if (String(message.providerAgentId) === "0" || message.serviceId === zero) {
|
|
275
|
+
refuse({
|
|
276
|
+
check: "lifecycle-binding",
|
|
277
|
+
code: "DASKI_WALLET_PROVIDER_BINDING_MISSING",
|
|
278
|
+
expected: "a provider-bound wallet challenge",
|
|
279
|
+
actual: "provider slots are zeroed",
|
|
280
|
+
remediation: `See ${DOC}`,
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
else if (String(message.providerAgentId) !== "0" ||
|
|
285
|
+
providerSlots.some((slot) => message[slot] !== zero) ||
|
|
286
|
+
Number(message.actionCatalogEpoch) !== 0) {
|
|
287
|
+
refuse({
|
|
288
|
+
check: "lifecycle-binding",
|
|
289
|
+
code: "DASKI_WALLET_UNEXPECTED_PROVIDER_BINDING",
|
|
290
|
+
expected: "an unbound wallet challenge with zeroed provider slots",
|
|
291
|
+
actual: "the challenge binds a provider we did not name",
|
|
292
|
+
remediation: "This would authorize a provider-scoped action under cover of a " +
|
|
293
|
+
`wallet query. Do not sign it; see ${DOC}`,
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
assertShortLived(Number(message.issuedAt), Number(message.validBefore), expectations.nowSeconds);
|
|
297
|
+
return challenge;
|
|
298
|
+
}
|
|
299
|
+
/** The typed-data payload for a validated wallet-action challenge. */
|
|
300
|
+
export function walletActionTypedData(challenge) {
|
|
301
|
+
const message = challenge.message;
|
|
302
|
+
return {
|
|
303
|
+
domain: challenge.domain,
|
|
304
|
+
types: WALLET_ACTION_TYPES,
|
|
305
|
+
primaryType: "WalletActionAuthorizationV1",
|
|
306
|
+
message: {
|
|
307
|
+
...message,
|
|
308
|
+
providerAgentId: BigInt(String(message.providerAgentId)),
|
|
309
|
+
actionCatalogEpoch: BigInt(String(message.actionCatalogEpoch)),
|
|
310
|
+
issuedAt: BigInt(String(message.issuedAt)),
|
|
311
|
+
validBefore: BigInt(String(message.validBefore)),
|
|
312
|
+
},
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
function assertShortLived(issuedAt, validBefore, nowSeconds) {
|
|
316
|
+
const now = nowSeconds ?? Math.floor(Date.now() / 1_000);
|
|
317
|
+
if (issuedAt > now + LIFECYCLE_CLOCK_SKEW_SECONDS ||
|
|
318
|
+
validBefore <= now ||
|
|
319
|
+
validBefore <= issuedAt ||
|
|
320
|
+
validBefore - issuedAt > MAX_LIFECYCLE_LIFETIME_SECONDS) {
|
|
321
|
+
refuse({
|
|
322
|
+
check: "lifecycle-binding",
|
|
323
|
+
code: "DASKI_LIFECYCLE_WINDOW_INVALID",
|
|
324
|
+
expected: `issuedAt within ${LIFECYCLE_CLOCK_SKEW_SECONDS}s of now and a lifetime ` +
|
|
325
|
+
`in (0, ${MAX_LIFECYCLE_LIFETIME_SECONDS}]s`,
|
|
326
|
+
actual: `issuedAt=${issuedAt} validBefore=${validBefore} now=${now}`,
|
|
327
|
+
remediation: "Expired, future-dated, or long-lived lifecycle challenges are refused. " +
|
|
328
|
+
`Check the local clock, then retry; see ${DOC}`,
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
function assertExactKeys(value, fields, label) {
|
|
333
|
+
const actual = Object.keys(value).sort();
|
|
334
|
+
const expected = [...fields].sort();
|
|
335
|
+
if (actual.join(",") !== expected.join(",")) {
|
|
336
|
+
refuse({
|
|
337
|
+
check: "lifecycle-binding",
|
|
338
|
+
code: "DASKI_LIFECYCLE_OPEN_SHAPE",
|
|
339
|
+
expected: `${label} to be exactly [${expected.join(", ")}]`,
|
|
340
|
+
actual: `[${actual.join(", ")}]`,
|
|
341
|
+
remediation: `Upgrade @daski/x402-scheme; see ${DOC}`,
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
//# sourceMappingURL=lifecycle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../src/lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,UAAU,EAAE,SAA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