@clavis.nexus/setup 1.0.2 → 2.0.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.ts CHANGED
@@ -1,5 +1,12 @@
1
- /** Steps that require a human (browser or infrastructure). */
2
- type NeedsHuman = "passkey" | "payment" | "dns" | "login";
1
+ /** App が新しい接続を受け付ける地域の単位です。この順に並べて保存します。 */
2
+ declare const APP_REGIONS: readonly ["JP", "US", "GB", "EEA"];
3
+ type AppRegion = (typeof APP_REGIONS)[number];
4
+
5
+ /**
6
+ * Steps that require a human (browser or infrastructure).
7
+ * `terms` is an agreement only the customer can give: the Customer Terms, or the provision of billing data for a card checkout.
8
+ */
9
+ type NeedsHuman = "passkey" | "payment" | "dns" | "login" | "terms";
3
10
  type SetupOrigins = {
4
11
  apiOrigin: string;
5
12
  idOrigin: string;
@@ -10,10 +17,16 @@ type DevelopersSession = {
10
17
  sub?: string;
11
18
  expiresAt?: number;
12
19
  };
13
- type SignProof = {
14
- v: 1;
15
- intent_type: "generic_sign";
16
- intent_id: string;
20
+ /**
21
+ * 本人向けの受領(`receipt@1`)。文型に Passkey で署名したものを Clavis が受け付けた副署です。
22
+ * Org の手続の本文に `receipt` として渡します。
23
+ */
24
+ type Receipt = {
25
+ type: "receipt@1";
26
+ statement: {
27
+ type: string;
28
+ [field: string]: unknown;
29
+ };
17
30
  [key: string]: unknown;
18
31
  };
19
32
  type HumanAction = {
@@ -29,6 +42,14 @@ type SetupResult<T> = {
29
42
  error: string;
30
43
  human?: HumanAction;
31
44
  };
45
+ /** 申告した設立地です。`terms_current` は、申告が今の組織の契約と DPA の版に結ばれているかです。 */
46
+ type OrgCardIncorporation = {
47
+ code: string;
48
+ at: number;
49
+ customer_terms_version: string;
50
+ dpa_version: string;
51
+ terms_current: boolean;
52
+ };
32
53
  type SetupStatusReport = {
33
54
  logged_in: boolean;
34
55
  sub?: string;
@@ -39,16 +60,62 @@ type SetupStatusReport = {
39
60
  org_status: string;
40
61
  setup_complete: boolean;
41
62
  signature_card: "unknown" | "active" | "inactive";
63
+ /** 署名のカードを止めている理由です(`signature_card` が `inactive` のとき)。 */
64
+ signature_card_blockers?: string[];
65
+ /** 設立地です。null は未申告です。カードを読めなかったときは省きます。 */
66
+ incorporation?: {
67
+ code: string;
68
+ terms_current: boolean;
69
+ } | null;
42
70
  apps: Array<{
43
71
  app_id: string;
44
72
  host: string;
45
73
  status: string;
46
74
  declaration_ok: boolean;
75
+ /** 新しい接続を受け付ける地域です。省いたときは、Clavis が受け付ける地域すべてです。 */
76
+ accepted_regions?: string[];
47
77
  }>;
48
78
  }>;
49
79
  };
50
80
  declare const DEFAULT_ORIGINS: SetupOrigins;
51
81
 
82
+ /** 署名のカードの Checkout に渡すものです。 */
83
+ type CardCheckoutOptions = {
84
+ /** `meter`(従量。既定)か `bundle`(月額の束)です。 */
85
+ offer?: "meter" | "bundle";
86
+ /**
87
+ * 顧客が、決済と請求のためのデータ提供(米国の Polar Software Inc. へ)に同意したときだけ true にします。
88
+ * 同意するかは顧客が決めます。SDK は既定で true にしません。
89
+ */
90
+ consentBillingData?: boolean;
91
+ /** 同意の文を見せる言語です(`en` か `ja`。既定は `en`)。購入の記録はこの言語の文に結ばれます。 */
92
+ lang?: "en" | "ja";
93
+ };
94
+
95
+ /**
96
+ * 署名する文型です。`type` は型 ID(`<名前>@<版>`)、ほかは型ごとに決まった欄です。
97
+ * Clavis は同じ材料から期待する文型を組み立て、JCS で一致しなければ受けません(400 `STATEMENT_MISMATCH`)。
98
+ * 欄の値は Clavis と同じ形にそろえて入れます(ドメインは小文字、地域は重複なし・昇順)。
99
+ */
100
+ type Statement = {
101
+ type: string;
102
+ [field: string]: unknown;
103
+ };
104
+
105
+ /**
106
+ * Org を作るときに顧客が申告し、同意する内容です。
107
+ * org-anchor-plan(challenge)と org-verify-anchor の両方に渡します。設立地の申告し直し(incorporation-set)も同じです。
108
+ */
109
+ type OrgCreationTerms = {
110
+ /** 設立地のコード。`JP`、`GB-EAW`、EEA の国コード、`US-XX` のいずれかです。 */
111
+ incorporation?: string;
112
+ /**
113
+ * 顧客が組織の契約(Customer Terms)とデータ処理契約(DPA)に同意したときだけ true にします。
114
+ * 同意するかは顧客が決めます。SDK は既定で true にしません。
115
+ */
116
+ acceptCustomerTerms?: boolean;
117
+ };
118
+
52
119
  type StoredSetupSession = {
53
120
  v: 1;
54
121
  origins: SetupOrigins;
@@ -80,12 +147,15 @@ type SetupClient = {
80
147
  cleared: true;
81
148
  }>>;
82
149
  status(): Promise<SetupResult<SetupStatusReport>>;
83
- orgAnchorPlan(domain: string, name?: string): Promise<SetupResult<{
150
+ /** terms: 設立地と、顧客の組織の契約への同意。どちらかが無いか、設立地が閉じていれば Passkey の前に断ります。 */
151
+ orgAnchorPlan(domain: string, name?: string, terms?: OrgCreationTerms): Promise<SetupResult<{
84
152
  domain: string;
85
153
  name?: string;
154
+ incorporation: string;
86
155
  nonce: string;
87
156
  exp: number;
88
- digest: string;
157
+ /** 公開マニフェストの `receipt` に署名した文型(`org.anchor.publish@1`) */
158
+ statement: Statement;
89
159
  well_known_url: string;
90
160
  txt_host: string;
91
161
  ceremony_url: string;
@@ -110,7 +180,7 @@ type SetupClient = {
110
180
  domain: string;
111
181
  nonce: string;
112
182
  name?: string;
113
- }): Promise<SetupResult<{
183
+ } & OrgCreationTerms): Promise<SetupResult<{
114
184
  org_id: string;
115
185
  org_status: string;
116
186
  }>>;
@@ -118,7 +188,21 @@ type SetupClient = {
118
188
  policy_revision_hash: string;
119
189
  already_active: boolean;
120
190
  }>>;
121
- cardCheckout(orgId: string): Promise<SetupResult<{
191
+ /**
192
+ * 設立地を申告します(Passkey)。申告は今の組織の契約と DPA の版に結ばれるため、顧客の同意が要ります。
193
+ * 組織の契約の版が新しくなったあと、購入の前に申告し直します。
194
+ */
195
+ incorporationSet(args: {
196
+ orgId: string;
197
+ } & OrgCreationTerms): Promise<SetupResult<{
198
+ incorporation: OrgCardIncorporation | null;
199
+ unchanged?: true;
200
+ }>>;
201
+ /**
202
+ * 署名のカードの Checkout を開きます。設立地が今の版で申告済みで、顧客が決済のためのデータ提供に同意していることが要ります。
203
+ * Passkey のあと、カードの入力は人間がブラウザで行います。
204
+ */
205
+ cardCheckout(orgId: string, opts?: CardCheckoutOptions): Promise<SetupResult<{
122
206
  url: string;
123
207
  human: HumanAction;
124
208
  }>>;
@@ -158,6 +242,18 @@ type SetupClient = {
158
242
  }): Promise<SetupResult<{
159
243
  declaration: unknown;
160
244
  }>>;
245
+ /**
246
+ * App が新しい接続を受け付ける地域を決めます(Passkey)。null で、Clavis が受け付ける地域すべてに戻します。
247
+ * 選べるのは、いま Clavis が受け付けている地域だけです。地域を絞っても、すでに接続している人はそのまま使えます。
248
+ */
249
+ appRegionsSet(args: {
250
+ orgId: string;
251
+ appId: string;
252
+ regions: readonly string[] | null;
253
+ }): Promise<SetupResult<{
254
+ accepted_regions: AppRegion[] | null;
255
+ unchanged?: true;
256
+ }>>;
161
257
  emitEnv(args: {
162
258
  appId: string;
163
259
  operatePrivateJwkJson?: string;
@@ -189,4 +285,4 @@ type OperateKeyPair = {
189
285
  };
190
286
  declare function generateOperateKeyPair(): Promise<OperateKeyPair>;
191
287
 
192
- export { type CreateSetupClientOptions, DEFAULT_ORIGINS, type DevelopersSession, type HumanAction, type NeedsHuman, SetupApiError, type SetupClient, type SetupOrigins, type SetupResult, type SetupStatusReport, type SignProof, clearSession, createSetupClient, defaultSessionPath, formatEnvExport, generateOperateKeyPair, loadSession, originsFromEnv, saveSession };
288
+ export { APP_REGIONS, type AppRegion, type CardCheckoutOptions, type CreateSetupClientOptions, DEFAULT_ORIGINS, type DevelopersSession, type HumanAction, type NeedsHuman, type OrgCreationTerms, type Receipt, SetupApiError, type SetupClient, type SetupOrigins, type SetupResult, type SetupStatusReport, clearSession, createSetupClient, defaultSessionPath, formatEnvExport, generateOperateKeyPair, loadSession, originsFromEnv, saveSession };