@originator-profile/opvc 0.5.5 → 0.6.0-beta.2
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/README.md +477 -225
- package/bin/dev.cmd +1 -1
- package/bin/dev.ts +1 -1
- package/dist/commands/ca/{sign.mjs → sign.js} +2 -2
- package/dist/commands/ca/{unsigned.mjs → unsigned.js} +2 -2
- package/dist/commands/{sign.mjs → sign.js} +1 -1
- package/dist/commands/wsp/sign.d.ts +29 -0
- package/dist/commands/wsp/sign.js +93 -0
- package/dist/commands/wsp/{unsigned.mjs → unsigned.js} +24 -3
- package/dist/{content-attestation-duY49Hxp.mjs → content-attestation-Dd-YcVIv.js} +3 -16
- package/dist/help.d.ts +11 -0
- package/dist/help.js +16 -0
- package/dist/{index.d.mts → index.d.ts} +30 -19
- package/dist/{index.mjs → index.js} +2 -2
- package/dist/timing-options-BWzawYM4.js +19 -0
- package/dist/website-profile-Brt0iuRN.js +60 -0
- package/package.json +22 -18
- package/dist/website-profile-B3Q2-h2n.mjs +0 -28
- /package/dist/{chunk-CfYAbeIz.mjs → chunk-pbuEa-1d.js} +0 -0
- /package/dist/commands/ca/{sign.d.mts → sign.d.ts} +0 -0
- /package/dist/commands/ca/{unsigned.d.mts → unsigned.d.ts} +0 -0
- /package/dist/commands/key-gen/{index.d.mts → index.d.ts} +0 -0
- /package/dist/commands/key-gen/{index.mjs → index.js} +0 -0
- /package/dist/commands/{sign.d.mts → sign.d.ts} +0 -0
- /package/dist/commands/wsp/{unsigned.d.mts → unsigned.d.ts} +0 -0
- /package/dist/{flags-BGhMpQzg.mjs → flags-BSM3ANoc.js} +0 -0
package/bin/dev.cmd
CHANGED
package/bin/dev.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as sign } from "../../content-attestation-
|
|
2
|
-
import { r as privateKey, t as expirationDate } from "../../flags-
|
|
1
|
+
import { n as sign } from "../../content-attestation-Dd-YcVIv.js";
|
|
2
|
+
import { r as privateKey, t as expirationDate } from "../../flags-BSM3ANoc.js";
|
|
3
3
|
import { Command, Flags } from "@oclif/core";
|
|
4
4
|
import fs from "node:fs/promises";
|
|
5
5
|
//#region src/commands/ca/sign.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as unsignedCa } from "../../content-attestation-
|
|
2
|
-
import { t as expirationDate } from "../../flags-
|
|
1
|
+
import { r as unsignedCa } from "../../content-attestation-Dd-YcVIv.js";
|
|
2
|
+
import { t as expirationDate } from "../../flags-BSM3ANoc.js";
|
|
3
3
|
import { Command, Flags } from "@oclif/core";
|
|
4
4
|
import fs from "node:fs/promises";
|
|
5
5
|
//#region src/commands/ca/unsigned.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as opId, r as privateKey, t as expirationDate } from "../flags-
|
|
1
|
+
import { n as opId, r as privateKey, t as expirationDate } from "../flags-BSM3ANoc.js";
|
|
2
2
|
import { fetchAndSetDigestSri } from "@originator-profile/sign";
|
|
3
3
|
import { addYears } from "date-fns";
|
|
4
4
|
import { Command, Flags } from "@oclif/core";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
import * as _$_oclif_core_interfaces0 from "@oclif/core/interfaces";
|
|
3
|
+
|
|
4
|
+
//#region src/commands/wsp/sign.d.ts
|
|
5
|
+
declare class WspSign extends Command {
|
|
6
|
+
static summary: string;
|
|
7
|
+
static description: string;
|
|
8
|
+
static flags: {
|
|
9
|
+
identity: _$_oclif_core_interfaces0.OptionFlag<{
|
|
10
|
+
[x: string]: unknown;
|
|
11
|
+
kty: string;
|
|
12
|
+
kid: string;
|
|
13
|
+
use?: string | undefined;
|
|
14
|
+
key_ops?: string[] | undefined;
|
|
15
|
+
alg?: string | undefined;
|
|
16
|
+
x5u?: string | undefined;
|
|
17
|
+
x5c?: string[] | undefined;
|
|
18
|
+
x5t?: string | undefined;
|
|
19
|
+
"x5t#S256"?: string | undefined;
|
|
20
|
+
}, _$_oclif_core_interfaces0.CustomOptions>;
|
|
21
|
+
input: _$_oclif_core_interfaces0.OptionFlag<string, _$_oclif_core_interfaces0.CustomOptions>;
|
|
22
|
+
"issued-at": _$_oclif_core_interfaces0.OptionFlag<string | undefined, _$_oclif_core_interfaces0.CustomOptions>;
|
|
23
|
+
"expired-at": _$_oclif_core_interfaces0.OptionFlag<Date | undefined, _$_oclif_core_interfaces0.CustomOptions>;
|
|
24
|
+
};
|
|
25
|
+
static examples: string[];
|
|
26
|
+
run(): Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { WspSign };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { t as sign } from "../../website-profile-Brt0iuRN.js";
|
|
2
|
+
import { r as privateKey, t as expirationDate } from "../../flags-BSM3ANoc.js";
|
|
3
|
+
import { Command, Flags } from "@oclif/core";
|
|
4
|
+
import fs from "node:fs/promises";
|
|
5
|
+
//#region src/commands/wsp/sign.ts
|
|
6
|
+
const exampleWebsiteProfile = {
|
|
7
|
+
"@context": [
|
|
8
|
+
"https://www.w3.org/ns/credentials/v2",
|
|
9
|
+
"https://originator-profile.org/ns/credentials/v1",
|
|
10
|
+
"https://originator-profile.org/ns/cip/v1",
|
|
11
|
+
{ "@language": "ja" }
|
|
12
|
+
],
|
|
13
|
+
type: ["VerifiableCredential", "WebsiteProfile"],
|
|
14
|
+
issuer: "dns:example.com",
|
|
15
|
+
credentialSubject: {
|
|
16
|
+
id: "https://media.example.com/",
|
|
17
|
+
type: "WebSite",
|
|
18
|
+
name: "<Webサイトのタイトル>",
|
|
19
|
+
description: "<Webサイトの説明>",
|
|
20
|
+
image: {
|
|
21
|
+
id: "https://media.example.com/image.png",
|
|
22
|
+
digestSRI: "sha256-Upwn7gYMuRmJlD1ZivHk876vXHzokXrwXj50VgfnMnY="
|
|
23
|
+
},
|
|
24
|
+
allowedOrigin: ["https://media.example.com"]
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const exampleMultilingualWebsiteProfile = [exampleWebsiteProfile, {
|
|
28
|
+
...exampleWebsiteProfile,
|
|
29
|
+
"@context": [
|
|
30
|
+
"https://www.w3.org/ns/credentials/v2",
|
|
31
|
+
"https://originator-profile.org/ns/credentials/v1",
|
|
32
|
+
"https://originator-profile.org/ns/cip/v1",
|
|
33
|
+
{ "@language": "en" }
|
|
34
|
+
],
|
|
35
|
+
credentialSubject: {
|
|
36
|
+
...exampleWebsiteProfile.credentialSubject,
|
|
37
|
+
name: "<Website title>",
|
|
38
|
+
description: "<Website description>"
|
|
39
|
+
}
|
|
40
|
+
}];
|
|
41
|
+
var WspSign = class WspSign extends Command {
|
|
42
|
+
static summary = "Website Profile の作成";
|
|
43
|
+
static description = `\
|
|
44
|
+
Website Profile に署名します。
|
|
45
|
+
入力が単一オブジェクトの場合は JWT を、配列の場合は JWT の配列を標準出力に出力します。
|
|
46
|
+
配列入力時は全要素が同一の issuer / credentialSubject.id を持ち、
|
|
47
|
+
@context の @language がそれぞれ異なる必要があります。`;
|
|
48
|
+
static flags = {
|
|
49
|
+
identity: privateKey({ required: true }),
|
|
50
|
+
input: Flags.string({
|
|
51
|
+
summary: "入力ファイルのパス (JSON 形式)",
|
|
52
|
+
helpValue: "<filepath>",
|
|
53
|
+
description: `\
|
|
54
|
+
Website Profile (WSP) の例:
|
|
55
|
+
|
|
56
|
+
${JSON.stringify(exampleWebsiteProfile, null, " ")}
|
|
57
|
+
|
|
58
|
+
多言語 Website Profile (配列) の例:
|
|
59
|
+
|
|
60
|
+
${JSON.stringify(exampleMultilingualWebsiteProfile, null, " ")}`,
|
|
61
|
+
required: true
|
|
62
|
+
}),
|
|
63
|
+
"issued-at": Flags.string({ description: "発行日時 (ISO 8601)" }),
|
|
64
|
+
"expired-at": expirationDate()
|
|
65
|
+
};
|
|
66
|
+
static examples = [`\
|
|
67
|
+
$ <%= config.bin %> <%= command.id %> \\
|
|
68
|
+
-i account-key.example.priv.json \\
|
|
69
|
+
--input website-profile.example.json`, `\
|
|
70
|
+
$ <%= config.bin %> <%= command.id %> \\
|
|
71
|
+
-i account-key.example.priv.json \\
|
|
72
|
+
--input website-profile.multilingual.example.json`];
|
|
73
|
+
async run() {
|
|
74
|
+
const { flags } = await this.parse(WspSign);
|
|
75
|
+
const inputBuffer = await fs.readFile(flags.input);
|
|
76
|
+
const input = JSON.parse(inputBuffer.toString());
|
|
77
|
+
if (Array.isArray(input)) {
|
|
78
|
+
const result = await sign(input, flags.identity, {
|
|
79
|
+
issuedAt: flags["issued-at"],
|
|
80
|
+
expiredAt: flags["expired-at"]
|
|
81
|
+
});
|
|
82
|
+
this.logJson(result);
|
|
83
|
+
} else {
|
|
84
|
+
const jwt = await sign(input, flags.identity, {
|
|
85
|
+
issuedAt: flags["issued-at"],
|
|
86
|
+
expiredAt: flags["expired-at"]
|
|
87
|
+
});
|
|
88
|
+
this.log(jwt);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
//#endregion
|
|
93
|
+
export { WspSign };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as expirationDate } from "../../flags-
|
|
1
|
+
import { n as unsignedWsp } from "../../website-profile-Brt0iuRN.js";
|
|
2
|
+
import { t as expirationDate } from "../../flags-BSM3ANoc.js";
|
|
3
3
|
import { Command, Flags } from "@oclif/core";
|
|
4
4
|
import fs from "node:fs/promises";
|
|
5
5
|
//#region src/commands/wsp/unsigned.ts
|
|
@@ -24,6 +24,23 @@ const exampleWebsiteProfile = {
|
|
|
24
24
|
allowedOrigin: ["<Web サイトのオリジン (形式: https://<ホスト名>)>"]
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
|
+
const exampleMultilingualWebsiteProfile = [{
|
|
28
|
+
...exampleWebsiteProfile,
|
|
29
|
+
"@context": [
|
|
30
|
+
"https://www.w3.org/ns/credentials/v2",
|
|
31
|
+
"https://originator-profile.org/ns/credentials/v1",
|
|
32
|
+
"https://originator-profile.org/ns/cip/v1",
|
|
33
|
+
{ "@language": "ja" }
|
|
34
|
+
]
|
|
35
|
+
}, {
|
|
36
|
+
...exampleWebsiteProfile,
|
|
37
|
+
"@context": [
|
|
38
|
+
"https://www.w3.org/ns/credentials/v2",
|
|
39
|
+
"https://originator-profile.org/ns/credentials/v1",
|
|
40
|
+
"https://originator-profile.org/ns/cip/v1",
|
|
41
|
+
{ "@language": "en" }
|
|
42
|
+
]
|
|
43
|
+
}];
|
|
27
44
|
var WspUnsigned = class WspUnsigned extends Command {
|
|
28
45
|
static summary = "未署名 Website Profile の取得";
|
|
29
46
|
static description = "標準出力に未署名 Website Profile を出力します。";
|
|
@@ -34,7 +51,11 @@ var WspUnsigned = class WspUnsigned extends Command {
|
|
|
34
51
|
description: `\
|
|
35
52
|
Website Profile の例:
|
|
36
53
|
|
|
37
|
-
${JSON.stringify(exampleWebsiteProfile, null, " ")}
|
|
54
|
+
${JSON.stringify(exampleWebsiteProfile, null, " ")}
|
|
55
|
+
|
|
56
|
+
多言語の Website Profile (配列) の例:
|
|
57
|
+
|
|
58
|
+
${JSON.stringify(exampleMultilingualWebsiteProfile, null, " ")}`,
|
|
38
59
|
required: true
|
|
39
60
|
}),
|
|
40
61
|
"issued-at": Flags.string({ description: "発行日時 (ISO 8601)" }),
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { t as __exportAll } from "./chunk-
|
|
1
|
+
import { t as __exportAll } from "./chunk-pbuEa-1d.js";
|
|
2
|
+
import { t as parseDates } from "./timing-options-BWzawYM4.js";
|
|
2
3
|
import { JSDOM } from "jsdom";
|
|
3
|
-
import { parseExpirationDate } from "@originator-profile/core";
|
|
4
4
|
import { UnsignedContentAttestation } from "@originator-profile/model";
|
|
5
5
|
import { fetchAndSetDigestSri, fetchAndSetTargetIntegrity, signCa } from "@originator-profile/sign";
|
|
6
|
-
import {
|
|
6
|
+
import { getUnixTime } from "date-fns";
|
|
7
7
|
import { BadRequestError } from "http-errors-enhanced";
|
|
8
8
|
//#region src/document-provider.ts
|
|
9
9
|
async function documentProvider({ type, content = "" }) {
|
|
@@ -28,19 +28,6 @@ var content_attestation_exports = /* @__PURE__ */ __exportAll({
|
|
|
28
28
|
signByServer: () => signByServer,
|
|
29
29
|
unsignedCa: () => unsignedCa
|
|
30
30
|
});
|
|
31
|
-
function assertValidDate(value, fieldName) {
|
|
32
|
-
if (Number.isNaN(value.getTime())) throw new BadRequestError(`${fieldName} must be a valid date.`);
|
|
33
|
-
}
|
|
34
|
-
function parseDates({ issuedAt: issuedAtDateOrString = /* @__PURE__ */ new Date(), expiredAt: expiredAtDateOrString = addYears(/* @__PURE__ */ new Date(), 1) }) {
|
|
35
|
-
const issuedAt = new Date(issuedAtDateOrString);
|
|
36
|
-
const expiredAt = typeof expiredAtDateOrString === "string" ? parseExpirationDate(expiredAtDateOrString) : new Date(expiredAtDateOrString);
|
|
37
|
-
assertValidDate(issuedAt, "issuedAt");
|
|
38
|
-
assertValidDate(expiredAt, "expiredAt");
|
|
39
|
-
return {
|
|
40
|
-
issuedAt,
|
|
41
|
-
expiredAt
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
31
|
/**
|
|
45
32
|
* 未署名 Content Attestation の取得
|
|
46
33
|
* @param uca 未署名 Content Attestation オブジェクト
|
package/dist/help.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CommandHelp, Help as Help$1 } from "@oclif/core/help";
|
|
2
|
+
|
|
3
|
+
//#region src/help.d.ts
|
|
4
|
+
declare class IndentPreservingCommandHelp extends CommandHelp {
|
|
5
|
+
wrap(body: string, spacing?: number): string;
|
|
6
|
+
}
|
|
7
|
+
declare class Help extends Help$1 {
|
|
8
|
+
CommandHelpClass: typeof IndentPreservingCommandHelp;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { Help as default };
|
package/dist/help.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CommandHelp, Help as Help$1 } from "@oclif/core/help";
|
|
2
|
+
import wrapAnsi from "wrap-ansi";
|
|
3
|
+
//#region src/help.ts
|
|
4
|
+
var IndentPreservingCommandHelp = class extends CommandHelp {
|
|
5
|
+
wrap(body, spacing = this.indentSpacing) {
|
|
6
|
+
return wrapAnsi(this.render(body), this.opts.maxWidth - spacing, {
|
|
7
|
+
hard: true,
|
|
8
|
+
trim: false
|
|
9
|
+
}).split("\n").map((l) => l.trimEnd()).join("\n");
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
var Help = class extends Help$1 {
|
|
13
|
+
CommandHelpClass = IndentPreservingCommandHelp;
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { Help as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Jwk, RawTarget, UnsignedContentAttestation, UnsignedWebsiteProfile } from "@originator-profile/model";
|
|
2
|
-
import { DocumentProvider } from "@originator-profile/sign";
|
|
1
|
+
import { Jwk, RawTarget, UnsignedContentAttestation, UnsignedWebsiteProfile, UnsignedWebsiteProfileSet } from "@originator-profile/model";
|
|
2
|
+
import { DocumentProvider, UnsignedWebsiteProfileInput } from "@originator-profile/sign";
|
|
3
3
|
|
|
4
4
|
//#region src/document-provider.d.ts
|
|
5
5
|
declare function documentProvider$1({
|
|
@@ -18,14 +18,16 @@ type HashAlgorithm = "sha256" | "sha384" | "sha512";
|
|
|
18
18
|
* representations for cryptographic operations. These algorithms are referenced by name when
|
|
19
19
|
* working with hashing functions in Web Crypto APIs.
|
|
20
20
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
type ContentAttestationTimingOptions = {
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/timing-options.d.ts
|
|
23
|
+
type TimingOptions = {
|
|
25
24
|
issuedAt?: Date | string;
|
|
26
25
|
expiredAt?: Date | string;
|
|
27
26
|
};
|
|
28
|
-
|
|
27
|
+
declare namespace content_attestation_d_exports {
|
|
28
|
+
export { sign$1 as sign, signByServer, unsignedCa };
|
|
29
|
+
}
|
|
30
|
+
type UnsignedCaOptions = TimingOptions & {
|
|
29
31
|
integrityAlg?: HashAlgorithm;
|
|
30
32
|
documentProvider?: DocumentProvider;
|
|
31
33
|
};
|
|
@@ -47,7 +49,7 @@ declare function unsignedCa(uca: UnsignedContentAttestation, {
|
|
|
47
49
|
* @throws {BadRequestError} 入力が UnsignedContentAttestation スキーマに適合しない場合/検証対象のコンテンツが存在しない/コンテンツにアクセスできない/Integrityの計算に失敗
|
|
48
50
|
* @return Content Attestation
|
|
49
51
|
*/
|
|
50
|
-
declare function sign(uca: UnsignedContentAttestation, privateKey: Jwk, options?:
|
|
52
|
+
declare function sign$1(uca: UnsignedContentAttestation, privateKey: Jwk, options?: TimingOptions): Promise<string>;
|
|
51
53
|
/**
|
|
52
54
|
* CA server 経由で Content Attestation を作成
|
|
53
55
|
* @param uca 未署名 Content Attestation オブジェクト
|
|
@@ -65,20 +67,29 @@ declare function signByServer(uca: UnsignedContentAttestation, {
|
|
|
65
67
|
accessToken: string;
|
|
66
68
|
}): Promise<string>;
|
|
67
69
|
declare namespace website_profile_d_exports {
|
|
68
|
-
export { unsignedWsp };
|
|
70
|
+
export { sign, unsignedWsp };
|
|
69
71
|
}
|
|
70
72
|
/**
|
|
71
73
|
* 未署名 Website Profile の取得
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
74
|
+
*
|
|
75
|
+
* 配列を渡した場合、全要素が同一の `issuer` と `credentialSubject.id` を持ち、
|
|
76
|
+
* `@context` の `@language` がそれぞれ異なることを検証します。
|
|
77
|
+
*
|
|
78
|
+
* @param uwsp 未署名 Website Profile オブジェクト (単一または配列)
|
|
79
|
+
* @throws {BadRequestError} 配列入力の整合性違反や入力が UnsignedWebsiteProfile スキーマに適合しない場合
|
|
80
|
+
* @return 未署名 Website Profile (配列入力時は配列)
|
|
75
81
|
*/
|
|
76
|
-
declare function unsignedWsp(uwsp:
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
declare function unsignedWsp<U extends UnsignedWebsiteProfileInput>(uwsp: U, options: TimingOptions): Promise<U extends unknown[] ? UnsignedWebsiteProfileSet : UnsignedWebsiteProfile>;
|
|
83
|
+
/**
|
|
84
|
+
* Website Profile への署名
|
|
85
|
+
*
|
|
86
|
+
* 配列を渡した場合、各要素を個別に署名して JWT 文字列の配列を返します。
|
|
87
|
+
*
|
|
88
|
+
* @param uwsp 未署名 Website Profile (単一または配列)
|
|
89
|
+
* @param privateKey プライベート鍵
|
|
90
|
+
* @throws {BadRequestError} 配列入力の整合性違反や入力が UnsignedWebsiteProfile スキーマに適合しない場合
|
|
91
|
+
* @return 単一入力時は JWT 文字列、配列入力時は JWT 文字列の配列
|
|
92
|
+
*/
|
|
93
|
+
declare function sign<U extends UnsignedWebsiteProfileInput>(uwsp: U, privateKey: Jwk, options?: TimingOptions): Promise<U extends unknown[] ? string[] : string>;
|
|
83
94
|
//#endregion
|
|
84
95
|
export { content_attestation_d_exports as ContentAttestation, website_profile_d_exports as WebsiteProfile, documentProvider$1 as documentProvider };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { i as documentProvider, t as content_attestation_exports } from "./content-attestation-
|
|
2
|
-
import {
|
|
1
|
+
import { i as documentProvider, t as content_attestation_exports } from "./content-attestation-Dd-YcVIv.js";
|
|
2
|
+
import { r as website_profile_exports } from "./website-profile-Brt0iuRN.js";
|
|
3
3
|
export { content_attestation_exports as ContentAttestation, website_profile_exports as WebsiteProfile, documentProvider };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { addYears } from "date-fns";
|
|
2
|
+
import { BadRequestError } from "http-errors-enhanced";
|
|
3
|
+
import { parseExpirationDate } from "@originator-profile/core";
|
|
4
|
+
//#region src/timing-options.ts
|
|
5
|
+
function assertValidDate(value, fieldName) {
|
|
6
|
+
if (Number.isNaN(value.getTime())) throw new BadRequestError(`${fieldName} must be a valid date.`);
|
|
7
|
+
}
|
|
8
|
+
function parseDates({ issuedAt: issuedAtDateOrString = /* @__PURE__ */ new Date(), expiredAt: expiredAtDateOrString = addYears(/* @__PURE__ */ new Date(), 1) }) {
|
|
9
|
+
const issuedAt = new Date(issuedAtDateOrString);
|
|
10
|
+
const expiredAt = typeof expiredAtDateOrString === "string" ? parseExpirationDate(expiredAtDateOrString) : new Date(expiredAtDateOrString);
|
|
11
|
+
assertValidDate(issuedAt, "issuedAt");
|
|
12
|
+
assertValidDate(expiredAt, "expiredAt");
|
|
13
|
+
return {
|
|
14
|
+
issuedAt,
|
|
15
|
+
expiredAt
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { parseDates as t };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { t as __exportAll } from "./chunk-pbuEa-1d.js";
|
|
2
|
+
import { t as parseDates } from "./timing-options-BWzawYM4.js";
|
|
3
|
+
import { UnsignedWebsiteProfileInput, fetchAndSetDigestSri, signWsp } from "@originator-profile/sign";
|
|
4
|
+
import { getUnixTime } from "date-fns";
|
|
5
|
+
import { BadRequestError } from "http-errors-enhanced";
|
|
6
|
+
//#region src/website-profile.ts
|
|
7
|
+
var website_profile_exports = /* @__PURE__ */ __exportAll({
|
|
8
|
+
sign: () => sign,
|
|
9
|
+
unsignedWsp: () => unsignedWsp
|
|
10
|
+
});
|
|
11
|
+
/**
|
|
12
|
+
* 未署名 Website Profile の取得
|
|
13
|
+
*
|
|
14
|
+
* 配列を渡した場合、全要素が同一の `issuer` と `credentialSubject.id` を持ち、
|
|
15
|
+
* `@context` の `@language` がそれぞれ異なることを検証します。
|
|
16
|
+
*
|
|
17
|
+
* @param uwsp 未署名 Website Profile オブジェクト (単一または配列)
|
|
18
|
+
* @throws {BadRequestError} 配列入力の整合性違反や入力が UnsignedWebsiteProfile スキーマに適合しない場合
|
|
19
|
+
* @return 未署名 Website Profile (配列入力時は配列)
|
|
20
|
+
*/
|
|
21
|
+
async function unsignedWsp(uwsp, options) {
|
|
22
|
+
const timing = parseDates(options);
|
|
23
|
+
async function build(u) {
|
|
24
|
+
await fetchAndSetDigestSri("sha256", u.credentialSubject.image);
|
|
25
|
+
return {
|
|
26
|
+
...u,
|
|
27
|
+
iss: u.issuer,
|
|
28
|
+
sub: u.credentialSubject.id,
|
|
29
|
+
iat: getUnixTime(timing.issuedAt),
|
|
30
|
+
exp: getUnixTime(timing.expiredAt)
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
UnsignedWebsiteProfileInput.parse(uwsp);
|
|
35
|
+
if (Array.isArray(uwsp)) return await Promise.all(uwsp.map(build));
|
|
36
|
+
return await build(uwsp);
|
|
37
|
+
} catch (e) {
|
|
38
|
+
throw new BadRequestError(e.message, { cause: e });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Website Profile への署名
|
|
43
|
+
*
|
|
44
|
+
* 配列を渡した場合、各要素を個別に署名して JWT 文字列の配列を返します。
|
|
45
|
+
*
|
|
46
|
+
* @param uwsp 未署名 Website Profile (単一または配列)
|
|
47
|
+
* @param privateKey プライベート鍵
|
|
48
|
+
* @throws {BadRequestError} 配列入力の整合性違反や入力が UnsignedWebsiteProfile スキーマに適合しない場合
|
|
49
|
+
* @return 単一入力時は JWT 文字列、配列入力時は JWT 文字列の配列
|
|
50
|
+
*/
|
|
51
|
+
async function sign(uwsp, privateKey, options = {}) {
|
|
52
|
+
const timing = parseDates(options);
|
|
53
|
+
try {
|
|
54
|
+
return await signWsp(uwsp, privateKey, timing);
|
|
55
|
+
} catch (e) {
|
|
56
|
+
throw new BadRequestError(e.message, { cause: e });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
export { unsignedWsp as n, website_profile_exports as r, sign as t };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@originator-profile/opvc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0-beta.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://docs.originator-profile.org",
|
|
6
6
|
"repository": {
|
|
@@ -19,14 +19,14 @@
|
|
|
19
19
|
"LICENSE",
|
|
20
20
|
"NOTICE"
|
|
21
21
|
],
|
|
22
|
-
"bin": "bin/run.js",
|
|
23
22
|
"exports": {
|
|
24
|
-
"types": "./dist/index.d.
|
|
25
|
-
"default": "./dist/index.
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"default": "./dist/index.js"
|
|
26
25
|
},
|
|
27
26
|
"oclif": {
|
|
28
27
|
"bin": "opvc",
|
|
29
28
|
"commands": "dist/commands",
|
|
29
|
+
"helpClass": "./dist/help",
|
|
30
30
|
"repositoryPrefix": "<%- repo %>/blob/v<%- version %>/packages/opvc/<%- commandPath %>",
|
|
31
31
|
"plugins": [
|
|
32
32
|
"@oclif/plugin-help"
|
|
@@ -39,26 +39,30 @@
|
|
|
39
39
|
"http-errors-enhanced": "^4.0.2",
|
|
40
40
|
"jose": "^6.2.2",
|
|
41
41
|
"jsdom": "^29.0.1",
|
|
42
|
-
"
|
|
43
|
-
"@originator-profile/
|
|
44
|
-
"@originator-profile/model": "0.
|
|
45
|
-
"@originator-profile/
|
|
46
|
-
"@originator-profile/sign": "0.
|
|
42
|
+
"wrap-ansi": "^9.0.2",
|
|
43
|
+
"@originator-profile/core": "0.6.0-beta.2",
|
|
44
|
+
"@originator-profile/model": "0.6.0-beta.2",
|
|
45
|
+
"@originator-profile/cryptography": "0.6.0-beta.2",
|
|
46
|
+
"@originator-profile/sign": "0.6.0-beta.2",
|
|
47
|
+
"@originator-profile/securing-mechanism": "0.6.0-beta.2"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
|
-
"@types/node": "
|
|
50
|
-
"eslint": "
|
|
51
|
-
"oclif": "
|
|
52
|
-
"tsdown": "
|
|
53
|
-
"typescript": "
|
|
54
|
-
"websri": "
|
|
55
|
-
"@originator-profile/tsconfig": "0.
|
|
56
|
-
"eslint-config-originator-profile": "0.
|
|
50
|
+
"@types/node": "25.6.0",
|
|
51
|
+
"eslint": "10.2.0",
|
|
52
|
+
"oclif": "4.23.0",
|
|
53
|
+
"tsdown": "0.21.7",
|
|
54
|
+
"typescript": "6.0.2",
|
|
55
|
+
"websri": "1.0.1",
|
|
56
|
+
"@originator-profile/tsconfig": "0.6.0-beta.2",
|
|
57
|
+
"eslint-config-originator-profile": "0.6.0-beta.2"
|
|
57
58
|
},
|
|
58
59
|
"scripts": {
|
|
59
60
|
"build": "tsdown && oclif manifest && oclif readme",
|
|
60
61
|
"lint": "eslint --fix .",
|
|
61
62
|
"type-check": "tsc",
|
|
62
|
-
"test": "node --
|
|
63
|
+
"test": "node --test"
|
|
64
|
+
},
|
|
65
|
+
"bin": {
|
|
66
|
+
"opvc": "bin/run.js"
|
|
63
67
|
}
|
|
64
68
|
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { t as __exportAll } from "./chunk-CfYAbeIz.mjs";
|
|
2
|
-
import { parseExpirationDate } from "@originator-profile/core";
|
|
3
|
-
import { UnsignedWebsiteProfile } from "@originator-profile/model";
|
|
4
|
-
import { fetchAndSetDigestSri } from "@originator-profile/sign";
|
|
5
|
-
import { addYears, getUnixTime } from "date-fns";
|
|
6
|
-
//#region src/website-profile.ts
|
|
7
|
-
var website_profile_exports = /* @__PURE__ */ __exportAll({ unsignedWsp: () => unsignedWsp });
|
|
8
|
-
/**
|
|
9
|
-
* 未署名 Website Profile の取得
|
|
10
|
-
* @param uwsp 未署名 Website Profile オブジェクト
|
|
11
|
-
* @throws {Error} 入力が UnsignedWebsiteProfile スキーマに適合しない場合
|
|
12
|
-
* @return 未署名 Website Profile オブジェクト
|
|
13
|
-
*/
|
|
14
|
-
async function unsignedWsp(uwsp, { issuedAt: issuedAtDateOrString = /* @__PURE__ */ new Date(), expiredAt: expiredAtDateOrString = addYears(/* @__PURE__ */ new Date(), 1) }) {
|
|
15
|
-
UnsignedWebsiteProfile.parse(uwsp);
|
|
16
|
-
const issuedAt = new Date(issuedAtDateOrString);
|
|
17
|
-
const expiredAt = typeof expiredAtDateOrString === "string" ? parseExpirationDate(expiredAtDateOrString) : expiredAtDateOrString;
|
|
18
|
-
await fetchAndSetDigestSri("sha256", uwsp.credentialSubject.image);
|
|
19
|
-
return {
|
|
20
|
-
iss: uwsp.issuer,
|
|
21
|
-
sub: uwsp.credentialSubject.id,
|
|
22
|
-
iat: getUnixTime(issuedAt),
|
|
23
|
-
exp: getUnixTime(expiredAt),
|
|
24
|
-
...uwsp
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
//#endregion
|
|
28
|
-
export { website_profile_exports as n, unsignedWsp as t };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|