@learncard/expiration-plugin 1.2.33 → 1.2.35
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/expiration-plugin.cjs.development.cjs +7 -1
- package/dist/expiration-plugin.cjs.development.cjs.map +2 -2
- package/dist/expiration-plugin.cjs.production.min.cjs +1 -1
- package/dist/expiration-plugin.cjs.production.min.cjs.map +3 -3
- package/dist/expiration-plugin.esm.js +7 -1
- package/dist/expiration-plugin.esm.js.map +2 -2
- package/dist/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +11 -1
|
@@ -29,7 +29,13 @@ var expirationPlugin = /* @__PURE__ */ __name((learnCard) => ({
|
|
|
29
29
|
displayName: "Expiration Extension",
|
|
30
30
|
description: "Adds a check to make sure credentials aren't expired when verifying them",
|
|
31
31
|
methods: {
|
|
32
|
-
verifyCredential: /* @__PURE__ */ __name(async (_learnCard, credential,
|
|
32
|
+
verifyCredential: /* @__PURE__ */ __name(async (_learnCard, credential, _options) => {
|
|
33
|
+
const options = { ..._options };
|
|
34
|
+
if (!options.checks) {
|
|
35
|
+
options.checks = ["proof"];
|
|
36
|
+
if (credential.credentialStatus) options.checks.push("credentialStatus");
|
|
37
|
+
if (credential.credentialSchema) options.checks.push("credentialSchema");
|
|
38
|
+
}
|
|
33
39
|
const verificationCheck = await learnCard.invoke.verifyCredential(credential, options);
|
|
34
40
|
if (credential.expirationDate && /* @__PURE__ */ new Date() > new Date(credential.expirationDate)) {
|
|
35
41
|
verificationCheck.errors.push("expiration error: Credential is expired");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["import { VerifyExtension } from '@learncard/vc-plugin';\nimport { LearnCard } from '@learncard/core';\nimport { ExpirationPlugin } from './types';\n\nexport * from './types';\n\n/**\n * @group Plugins\n */\nexport const expirationPlugin = (\n learnCard: LearnCard<any, any, VerifyExtension>\n): ExpirationPlugin => ({\n name: 'Expiration',\n displayName: 'Expiration Extension',\n description: \"Adds a check to make sure credentials aren't expired when verifying them\",\n methods: {\n verifyCredential: async (_learnCard, credential,
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AASO,IAAM,mBAAmB,wBAC5B,eACoB;AAAA,EACpB,MAAM;AAAA,EACN,aAAa;AAAA,EACb,aAAa;AAAA,EACb,SAAS;AAAA,IACL,kBAAkB,8BAAO,YAAY,YAAY,
|
|
4
|
+
"sourcesContent": ["import { VerifyExtension } from '@learncard/vc-plugin';\nimport { LearnCard } from '@learncard/core';\nimport { ExpirationPlugin } from './types';\n\nexport * from './types';\n\n/**\n * @group Plugins\n */\nexport const expirationPlugin = (\n learnCard: LearnCard<any, any, VerifyExtension>\n): ExpirationPlugin => ({\n name: 'Expiration',\n displayName: 'Expiration Extension',\n description: \"Adds a check to make sure credentials aren't expired when verifying them\",\n methods: {\n verifyCredential: async (_learnCard, credential, _options) => {\n // Default the DIDKit checks here too, not only in the VC plugin: verify-only\n // LearnCards (`initLearnCard()` with no seed) have no VC plugin, and without\n // this a revoked credential's status list is never consulted.\n const options = { ..._options };\n if (!options.checks) {\n options.checks = ['proof'];\n if (credential.credentialStatus) options.checks.push('credentialStatus');\n if (credential.credentialSchema) options.checks.push('credentialSchema');\n }\n\n const verificationCheck = await learnCard.invoke.verifyCredential(credential, options);\n\n if (credential.expirationDate && new Date() > new Date(credential.expirationDate)) {\n verificationCheck.errors.push('expiration error: Credential is expired');\n } else if (credential.validFrom && new Date() < new Date(credential.validFrom)) {\n verificationCheck.errors.push('expiration error: Credential is not valid yet');\n } else if (credential.validUntil && new Date() > new Date(credential.validUntil)) {\n verificationCheck.errors.push('expiration error: Credential is no longer valid');\n } else {\n verificationCheck.checks.push('expiration');\n }\n\n return verificationCheck;\n },\n },\n});\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AASO,IAAM,mBAAmB,wBAC5B,eACoB;AAAA,EACpB,MAAM;AAAA,EACN,aAAa;AAAA,EACb,aAAa;AAAA,EACb,SAAS;AAAA,IACL,kBAAkB,8BAAO,YAAY,YAAY,aAAa;AAI1D,YAAM,UAAU,EAAE,GAAG,SAAS;AAC9B,UAAI,CAAC,QAAQ,QAAQ;AACjB,gBAAQ,SAAS,CAAC,OAAO;AACzB,YAAI,WAAW,iBAAkB,SAAQ,OAAO,KAAK,kBAAkB;AACvE,YAAI,WAAW,iBAAkB,SAAQ,OAAO,KAAK,kBAAkB;AAAA,MAC3E;AAEA,YAAM,oBAAoB,MAAM,UAAU,OAAO,iBAAiB,YAAY,OAAO;AAErF,UAAI,WAAW,kBAAkB,oBAAI,KAAK,IAAI,IAAI,KAAK,WAAW,cAAc,GAAG;AAC/E,0BAAkB,OAAO,KAAK,yCAAyC;AAAA,MAC3E,WAAW,WAAW,aAAa,oBAAI,KAAK,IAAI,IAAI,KAAK,WAAW,SAAS,GAAG;AAC5E,0BAAkB,OAAO,KAAK,+CAA+C;AAAA,MACjF,WAAW,WAAW,cAAc,oBAAI,KAAK,IAAI,IAAI,KAAK,WAAW,UAAU,GAAG;AAC9E,0BAAkB,OAAO,KAAK,iDAAiD;AAAA,MACnF,OAAO;AACH,0BAAkB,OAAO,KAAK,YAAY;AAAA,MAC9C;AAEA,aAAO;AAAA,IACX,GAxBkB;AAAA,EAyBtB;AACJ,IAjCgC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var o=Object.defineProperty;var
|
|
1
|
+
"use strict";var o=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var s=(r,i)=>o(r,"name",{value:i,configurable:!0});var d=(r,i)=>{for(var e in i)o(r,e,{get:i[e],enumerable:!0})},h=(r,i,e,t)=>{if(i&&typeof i=="object"||typeof i=="function")for(let n of l(i))!c.call(r,n)&&n!==e&&o(r,n,{get:()=>i[n],enumerable:!(t=p(i,n))||t.enumerable});return r};var x=r=>h(o({},"__esModule",{value:!0}),r);var m={};d(m,{expirationPlugin:()=>f});module.exports=x(m);var f=s(r=>({name:"Expiration",displayName:"Expiration Extension",description:"Adds a check to make sure credentials aren't expired when verifying them",methods:{verifyCredential:s(async(i,e,t)=>{let n={...t};n.checks||(n.checks=["proof"],e.credentialStatus&&n.checks.push("credentialStatus"),e.credentialSchema&&n.checks.push("credentialSchema"));let a=await r.invoke.verifyCredential(e,n);return e.expirationDate&&new Date>new Date(e.expirationDate)?a.errors.push("expiration error: Credential is expired"):e.validFrom&&new Date<new Date(e.validFrom)?a.errors.push("expiration error: Credential is not valid yet"):e.validUntil&&new Date>new Date(e.validUntil)?a.errors.push("expiration error: Credential is no longer valid"):a.checks.push("expiration"),a},"verifyCredential")}}),"expirationPlugin");
|
|
2
2
|
//# sourceMappingURL=expiration-plugin.cjs.production.min.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["import { VerifyExtension } from '@learncard/vc-plugin';\nimport { LearnCard } from '@learncard/core';\nimport { ExpirationPlugin } from './types';\n\nexport * from './types';\n\n/**\n * @group Plugins\n */\nexport const expirationPlugin = (\n learnCard: LearnCard<any, any, VerifyExtension>\n): ExpirationPlugin => ({\n name: 'Expiration',\n displayName: 'Expiration Extension',\n description: \"Adds a check to make sure credentials aren't expired when verifying them\",\n methods: {\n verifyCredential: async (_learnCard, credential,
|
|
5
|
-
"mappings": "4dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAA,eAAAC,EAAAH,GASO,IAAMI,EAAmBC,EAC5BC,IACoB,CACpB,KAAM,aACN,YAAa,uBACb,YAAa,2EACb,QAAS,CACL,iBAAkBD,EAAA,MAAOE,EAAYC,EAAYC,
|
|
6
|
-
"names": ["index_exports", "__export", "expirationPlugin", "__toCommonJS", "expirationPlugin", "__name", "learnCard", "_learnCard", "credential", "options", "verificationCheck"]
|
|
4
|
+
"sourcesContent": ["import { VerifyExtension } from '@learncard/vc-plugin';\nimport { LearnCard } from '@learncard/core';\nimport { ExpirationPlugin } from './types';\n\nexport * from './types';\n\n/**\n * @group Plugins\n */\nexport const expirationPlugin = (\n learnCard: LearnCard<any, any, VerifyExtension>\n): ExpirationPlugin => ({\n name: 'Expiration',\n displayName: 'Expiration Extension',\n description: \"Adds a check to make sure credentials aren't expired when verifying them\",\n methods: {\n verifyCredential: async (_learnCard, credential, _options) => {\n // Default the DIDKit checks here too, not only in the VC plugin: verify-only\n // LearnCards (`initLearnCard()` with no seed) have no VC plugin, and without\n // this a revoked credential's status list is never consulted.\n const options = { ..._options };\n if (!options.checks) {\n options.checks = ['proof'];\n if (credential.credentialStatus) options.checks.push('credentialStatus');\n if (credential.credentialSchema) options.checks.push('credentialSchema');\n }\n\n const verificationCheck = await learnCard.invoke.verifyCredential(credential, options);\n\n if (credential.expirationDate && new Date() > new Date(credential.expirationDate)) {\n verificationCheck.errors.push('expiration error: Credential is expired');\n } else if (credential.validFrom && new Date() < new Date(credential.validFrom)) {\n verificationCheck.errors.push('expiration error: Credential is not valid yet');\n } else if (credential.validUntil && new Date() > new Date(credential.validUntil)) {\n verificationCheck.errors.push('expiration error: Credential is no longer valid');\n } else {\n verificationCheck.checks.push('expiration');\n }\n\n return verificationCheck;\n },\n },\n});\n"],
|
|
5
|
+
"mappings": "4dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAA,eAAAC,EAAAH,GASO,IAAMI,EAAmBC,EAC5BC,IACoB,CACpB,KAAM,aACN,YAAa,uBACb,YAAa,2EACb,QAAS,CACL,iBAAkBD,EAAA,MAAOE,EAAYC,EAAYC,IAAa,CAI1D,IAAMC,EAAU,CAAE,GAAGD,CAAS,EACzBC,EAAQ,SACTA,EAAQ,OAAS,CAAC,OAAO,EACrBF,EAAW,kBAAkBE,EAAQ,OAAO,KAAK,kBAAkB,EACnEF,EAAW,kBAAkBE,EAAQ,OAAO,KAAK,kBAAkB,GAG3E,IAAMC,EAAoB,MAAML,EAAU,OAAO,iBAAiBE,EAAYE,CAAO,EAErF,OAAIF,EAAW,gBAAkB,IAAI,KAAS,IAAI,KAAKA,EAAW,cAAc,EAC5EG,EAAkB,OAAO,KAAK,yCAAyC,EAChEH,EAAW,WAAa,IAAI,KAAS,IAAI,KAAKA,EAAW,SAAS,EACzEG,EAAkB,OAAO,KAAK,+CAA+C,EACtEH,EAAW,YAAc,IAAI,KAAS,IAAI,KAAKA,EAAW,UAAU,EAC3EG,EAAkB,OAAO,KAAK,iDAAiD,EAE/EA,EAAkB,OAAO,KAAK,YAAY,EAGvCA,CACX,EAxBkB,mBAyBtB,CACJ,GAjCgC",
|
|
6
|
+
"names": ["index_exports", "__export", "expirationPlugin", "__toCommonJS", "expirationPlugin", "__name", "learnCard", "_learnCard", "credential", "_options", "options", "verificationCheck"]
|
|
7
7
|
}
|
|
@@ -7,7 +7,13 @@ var expirationPlugin = /* @__PURE__ */ __name((learnCard) => ({
|
|
|
7
7
|
displayName: "Expiration Extension",
|
|
8
8
|
description: "Adds a check to make sure credentials aren't expired when verifying them",
|
|
9
9
|
methods: {
|
|
10
|
-
verifyCredential: /* @__PURE__ */ __name(async (_learnCard, credential,
|
|
10
|
+
verifyCredential: /* @__PURE__ */ __name(async (_learnCard, credential, _options) => {
|
|
11
|
+
const options = { ..._options };
|
|
12
|
+
if (!options.checks) {
|
|
13
|
+
options.checks = ["proof"];
|
|
14
|
+
if (credential.credentialStatus) options.checks.push("credentialStatus");
|
|
15
|
+
if (credential.credentialSchema) options.checks.push("credentialSchema");
|
|
16
|
+
}
|
|
11
17
|
const verificationCheck = await learnCard.invoke.verifyCredential(credential, options);
|
|
12
18
|
if (credential.expirationDate && /* @__PURE__ */ new Date() > new Date(credential.expirationDate)) {
|
|
13
19
|
verificationCheck.errors.push("expiration error: Credential is expired");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["import { VerifyExtension } from '@learncard/vc-plugin';\nimport { LearnCard } from '@learncard/core';\nimport { ExpirationPlugin } from './types';\n\nexport * from './types';\n\n/**\n * @group Plugins\n */\nexport const expirationPlugin = (\n learnCard: LearnCard<any, any, VerifyExtension>\n): ExpirationPlugin => ({\n name: 'Expiration',\n displayName: 'Expiration Extension',\n description: \"Adds a check to make sure credentials aren't expired when verifying them\",\n methods: {\n verifyCredential: async (_learnCard, credential,
|
|
5
|
-
"mappings": ";;;;AASO,IAAM,mBAAmB,wBAC5B,eACoB;AAAA,EACpB,MAAM;AAAA,EACN,aAAa;AAAA,EACb,aAAa;AAAA,EACb,SAAS;AAAA,IACL,kBAAkB,8BAAO,YAAY,YAAY,
|
|
4
|
+
"sourcesContent": ["import { VerifyExtension } from '@learncard/vc-plugin';\nimport { LearnCard } from '@learncard/core';\nimport { ExpirationPlugin } from './types';\n\nexport * from './types';\n\n/**\n * @group Plugins\n */\nexport const expirationPlugin = (\n learnCard: LearnCard<any, any, VerifyExtension>\n): ExpirationPlugin => ({\n name: 'Expiration',\n displayName: 'Expiration Extension',\n description: \"Adds a check to make sure credentials aren't expired when verifying them\",\n methods: {\n verifyCredential: async (_learnCard, credential, _options) => {\n // Default the DIDKit checks here too, not only in the VC plugin: verify-only\n // LearnCards (`initLearnCard()` with no seed) have no VC plugin, and without\n // this a revoked credential's status list is never consulted.\n const options = { ..._options };\n if (!options.checks) {\n options.checks = ['proof'];\n if (credential.credentialStatus) options.checks.push('credentialStatus');\n if (credential.credentialSchema) options.checks.push('credentialSchema');\n }\n\n const verificationCheck = await learnCard.invoke.verifyCredential(credential, options);\n\n if (credential.expirationDate && new Date() > new Date(credential.expirationDate)) {\n verificationCheck.errors.push('expiration error: Credential is expired');\n } else if (credential.validFrom && new Date() < new Date(credential.validFrom)) {\n verificationCheck.errors.push('expiration error: Credential is not valid yet');\n } else if (credential.validUntil && new Date() > new Date(credential.validUntil)) {\n verificationCheck.errors.push('expiration error: Credential is no longer valid');\n } else {\n verificationCheck.checks.push('expiration');\n }\n\n return verificationCheck;\n },\n },\n});\n"],
|
|
5
|
+
"mappings": ";;;;AASO,IAAM,mBAAmB,wBAC5B,eACoB;AAAA,EACpB,MAAM;AAAA,EACN,aAAa;AAAA,EACb,aAAa;AAAA,EACb,SAAS;AAAA,IACL,kBAAkB,8BAAO,YAAY,YAAY,aAAa;AAI1D,YAAM,UAAU,EAAE,GAAG,SAAS;AAC9B,UAAI,CAAC,QAAQ,QAAQ;AACjB,gBAAQ,SAAS,CAAC,OAAO;AACzB,YAAI,WAAW,iBAAkB,SAAQ,OAAO,KAAK,kBAAkB;AACvE,YAAI,WAAW,iBAAkB,SAAQ,OAAO,KAAK,kBAAkB;AAAA,MAC3E;AAEA,YAAM,oBAAoB,MAAM,UAAU,OAAO,iBAAiB,YAAY,OAAO;AAErF,UAAI,WAAW,kBAAkB,oBAAI,KAAK,IAAI,IAAI,KAAK,WAAW,cAAc,GAAG;AAC/E,0BAAkB,OAAO,KAAK,yCAAyC;AAAA,MAC3E,WAAW,WAAW,aAAa,oBAAI,KAAK,IAAI,IAAI,KAAK,WAAW,SAAS,GAAG;AAC5E,0BAAkB,OAAO,KAAK,+CAA+C;AAAA,MACjF,WAAW,WAAW,cAAc,oBAAI,KAAK,IAAI,IAAI,KAAK,WAAW,UAAU,GAAG;AAC9E,0BAAkB,OAAO,KAAK,iDAAiD;AAAA,MACnF,OAAO;AACH,0BAAkB,OAAO,KAAK,YAAY;AAAA,MAC9C;AAEA,aAAO;AAAA,IACX,GAxBkB;AAAA,EAyBtB;AACJ,IAjCgC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
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,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,cAAc,SAAS,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,gBAAgB,GACzB,WAAW,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,eAAe,CAAC,KAChD,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,cAAc,SAAS,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,gBAAgB,GACzB,WAAW,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,eAAe,CAAC,KAChD,gBA+BD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@learncard/expiration-plugin",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.35",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
},
|
|
48
48
|
"types": "./dist/index.d.ts",
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@learncard/core": "9.4.
|
|
51
|
-
"@learncard/vc-plugin": "^1.
|
|
50
|
+
"@learncard/core": "9.4.35",
|
|
51
|
+
"@learncard/vc-plugin": "^1.6.1",
|
|
52
52
|
"why-is-node-running": "^2.2.2"
|
|
53
53
|
},
|
|
54
54
|
"sideEffects": false
|
package/src/index.ts
CHANGED
|
@@ -14,7 +14,17 @@ export const expirationPlugin = (
|
|
|
14
14
|
displayName: 'Expiration Extension',
|
|
15
15
|
description: "Adds a check to make sure credentials aren't expired when verifying them",
|
|
16
16
|
methods: {
|
|
17
|
-
verifyCredential: async (_learnCard, credential,
|
|
17
|
+
verifyCredential: async (_learnCard, credential, _options) => {
|
|
18
|
+
// Default the DIDKit checks here too, not only in the VC plugin: verify-only
|
|
19
|
+
// LearnCards (`initLearnCard()` with no seed) have no VC plugin, and without
|
|
20
|
+
// this a revoked credential's status list is never consulted.
|
|
21
|
+
const options = { ..._options };
|
|
22
|
+
if (!options.checks) {
|
|
23
|
+
options.checks = ['proof'];
|
|
24
|
+
if (credential.credentialStatus) options.checks.push('credentialStatus');
|
|
25
|
+
if (credential.credentialSchema) options.checks.push('credentialSchema');
|
|
26
|
+
}
|
|
27
|
+
|
|
18
28
|
const verificationCheck = await learnCard.invoke.verifyCredential(credential, options);
|
|
19
29
|
|
|
20
30
|
if (credential.expirationDate && new Date() > new Date(credential.expirationDate)) {
|