@learncard/vc-plugin 1.5.12 → 1.6.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.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/refreshCredential.d.ts +13 -0
- package/dist/refreshCredential.d.ts.map +1 -0
- package/dist/refreshCredential.fetch.d.ts +13 -0
- package/dist/refreshCredential.fetch.d.ts.map +1 -0
- package/dist/refreshCredential.fetch.test.d.ts +2 -0
- package/dist/refreshCredential.fetch.test.d.ts.map +1 -0
- package/dist/refreshCredential.test.d.ts +2 -0
- package/dist/refreshCredential.test.d.ts.map +1 -0
- package/dist/types.d.ts +32 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/vc-plugin.cjs.development.cjs +626 -1
- package/dist/vc-plugin.cjs.development.cjs.map +4 -4
- package/dist/vc-plugin.cjs.production.min.cjs +1 -1
- package/dist/vc-plugin.cjs.production.min.cjs.map +4 -4
- package/dist/vc-plugin.esm.js +635 -1
- package/dist/vc-plugin.esm.js.map +4 -4
- package/dist/vc.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/index.ts +1 -0
- package/src/refreshCredential.fetch.test.ts +110 -0
- package/src/refreshCredential.fetch.ts +159 -0
- package/src/refreshCredential.test.ts +1144 -0
- package/src/refreshCredential.ts +931 -0
- package/src/types.ts +36 -0
- package/src/vc.ts +2 -0
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AACnC,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CredentialRefreshResult, VC } from '@learncard/types';
|
|
2
|
+
import { RefreshCredentialOptions, VCDependentLearnCard, VCImplicitLearnCard } from './types';
|
|
3
|
+
/** Rejects loopback, private, link-local, multicast, reserved, and cloud-metadata IPv4 ranges */
|
|
4
|
+
export declare const isPrivateOrReservedIPv4: (ip: string) => boolean;
|
|
5
|
+
/** Rejects loopback, private/transition, link-local, multicast, documentation, and mapped-private IPv6 */
|
|
6
|
+
export declare const isPrivateOrReservedIPv6: (raw: string) => boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Holder-side refresh primitive. See the module docblock for the safety contract.
|
|
9
|
+
*
|
|
10
|
+
* Never includes the current credential or its claims in request headers or logs.
|
|
11
|
+
*/
|
|
12
|
+
export declare const refreshCredential: (_initLearnCard: VCDependentLearnCard) => (_learnCard: VCImplicitLearnCard, credential: VC, options?: RefreshCredentialOptions) => Promise<CredentialRefreshResult>;
|
|
13
|
+
//# sourceMappingURL=refreshCredential.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refreshCredential.d.ts","sourceRoot":"","sources":["../src/refreshCredential.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,uBAAuB,EAGvB,EAAE,EAGL,MAAM,kBAAkB,CAAC;AAS1B,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AA6F9F,iGAAiG;AACjG,eAAO,MAAM,uBAAuB,GAAI,IAAI,MAAM,KAAG,OAqBpD,CAAC;AA8DF,0GAA0G;AAC1G,eAAO,MAAM,uBAAuB,GAAI,KAAK,MAAM,KAAG,OA0BrD,CAAC;AAmeF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,gBAAgB,oBAAoB,MAW9D,YAAY,mBAAmB,EAC/B,YAAY,EAAE,EACd,UAAS,wBAA6B,KACvC,OAAO,CAAC,uBAAuB,CA8MrC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type PinnedAddress = {
|
|
2
|
+
address: string;
|
|
3
|
+
family: 4 | 6;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Fetches through an already-validated IP address in Node without changing the URL
|
|
7
|
+
* hostname. Keeping the original URL lets Node perform SNI and certificate hostname
|
|
8
|
+
* verification against the refresh endpoint while the custom lookup prevents a
|
|
9
|
+
* second, potentially rebound DNS answer from selecting the socket destination.
|
|
10
|
+
* Browsers do not expose connection-level DNS controls and therefore use native fetch.
|
|
11
|
+
*/
|
|
12
|
+
export declare const fetchWithPinnedAddress: (url: URL, init: RequestInit, pinnedAddress?: PinnedAddress) => Promise<Response>;
|
|
13
|
+
//# sourceMappingURL=refreshCredential.fetch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refreshCredential.fetch.d.ts","sourceRoot":"","sources":["../src/refreshCredential.fetch.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAA;CAAE,CAAC;AA0C/D;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,GAC/B,KAAK,GAAG,EACR,MAAM,WAAW,EACjB,gBAAgB,aAAa,KAC9B,OAAO,CAAC,QAAQ,CAyGlB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refreshCredential.fetch.test.d.ts","sourceRoot":"","sources":["../src/refreshCredential.fetch.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refreshCredential.test.d.ts","sourceRoot":"","sources":["../src/refreshCredential.test.ts"],"names":[],"mappings":""}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UnsignedVC, VC, UnsignedVP, VP, VerificationCheck, DidDocument, JWKWithPrivateKey } from '@learncard/types';
|
|
1
|
+
import { UnsignedVC, VC, UnsignedVP, VP, VerificationCheck, DidDocument, JWKWithPrivateKey, CredentialRefreshResult } from '@learncard/types';
|
|
2
2
|
import { Plugin, LearnCard } from '@learncard/core';
|
|
3
3
|
import { ProofOptions, InputMetadata } from '@learncard/didkit-plugin';
|
|
4
4
|
/** @group VC Plugin */
|
|
@@ -20,6 +20,37 @@ export type VCPluginMethods = {
|
|
|
20
20
|
getTestVc: (subject?: string) => UnsignedVC;
|
|
21
21
|
getTestVp: (credential?: VC) => Promise<UnsignedVP>;
|
|
22
22
|
getDidAuthVp: (options?: ProofOptions) => Promise<VP | string>;
|
|
23
|
+
refreshCredential: (credential: VC, options?: RefreshCredentialOptions) => Promise<CredentialRefreshResult>;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Options for the generic holder-side credential refresh primitive.
|
|
27
|
+
*
|
|
28
|
+
* @group VC Plugin
|
|
29
|
+
*/
|
|
30
|
+
export type RefreshCredentialOptions = {
|
|
31
|
+
/** Previously seen ETag validator for the credential; sent as `If-None-Match` */
|
|
32
|
+
etag?: string;
|
|
33
|
+
/** Per-request timeout in milliseconds (default 10_000) */
|
|
34
|
+
timeoutMs?: number;
|
|
35
|
+
/** Maximum number of followed redirects (default 3) */
|
|
36
|
+
maxRedirects?: number;
|
|
37
|
+
/** Maximum accepted response size in bytes (default 1 MiB) */
|
|
38
|
+
maxResponseBytes?: number;
|
|
39
|
+
/**
|
|
40
|
+
* Explicit local-development opt-in allowing plain-HTTP endpoints. HTTPS is required
|
|
41
|
+
* unless this is set.
|
|
42
|
+
*/
|
|
43
|
+
allowInsecureHttp?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Explicit local-development opt-in allowing private, loopback, or link-local
|
|
46
|
+
* endpoint addresses. Never enable this for credentials from untrusted issuers.
|
|
47
|
+
*/
|
|
48
|
+
allowPrivateAddresses?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Hostname resolution override used for SSRF checks. Defaults to Node's DNS resolver
|
|
51
|
+
* in Node runtimes; browsers skip DNS resolution and reject only unsafe host literals.
|
|
52
|
+
*/
|
|
53
|
+
resolveHost?: (hostname: string) => Promise<string[]>;
|
|
23
54
|
};
|
|
24
55
|
/** @group VC Plugin */
|
|
25
56
|
export type VCDependentLearnCard = LearnCard<any, any, VCPluginDependentMethods>;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,UAAU,EACV,EAAE,EACF,UAAU,EACV,EAAE,EACF,iBAAiB,EACjB,WAAW,EACX,iBAAiB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,UAAU,EACV,EAAE,EACF,UAAU,EACV,EAAE,EACF,iBAAiB,EACjB,WAAW,EACX,iBAAiB,EACjB,uBAAuB,EAC1B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEvE,uBAAuB;AACvB,MAAM,MAAM,wBAAwB,GAAG;IACnC,uBAAuB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACvF,uBAAuB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1D,eAAe,EAAE,CACb,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,iBAAiB,KACzB,OAAO,CAAC,EAAE,CAAC,CAAC;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