@kubun/plugin-credential 0.17.3 → 0.17.5

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.
Files changed (2) hide show
  1. package/lib/service.js +29 -8
  2. package/package.json +5 -5
package/lib/service.js CHANGED
@@ -1,14 +1,7 @@
1
1
  import { isSigningIdentity, normalizeDID } from '@kokuin/token';
2
- import { CredentialAliasAlreadyBound, CredentialBindNotAuthorized, CredentialEntryAlreadyAliased, CredentialInvalidEntry, CredentialKeyVersionMismatch, CredentialNotFound, CredentialSupersededBranch, createCredentialAPI, createCredentialManager } from '@kubun/credential';
2
+ import { CredentialAliasAlreadyBound, CredentialBindNotAuthorized, CredentialEntryAlreadyAliased, CredentialInvalidEntry, CredentialKeyVersionMismatch, CredentialNotFound, CredentialSupersededBranch, createCredentialAPI, createCredentialManager, wrappableDID } from '@kubun/credential';
3
3
  import { authorizeRead, authorizeWrite, ServiceAuthorizationError } from '@kubun/plugin-service-server';
4
4
  import { credentialStoreDefinition, getCredentialStore } from '@kubun/store-credential';
5
- // The spelling of a DID that can be encrypted to. A did:peer:4 identity carries a
6
- // longForm that resolves the agreement key; its short id resolves none. For
7
- // did:key the two forms are identical.
8
- function wrappableDID(identity) {
9
- const longForm = identity.longForm;
10
- return typeof longForm === 'string' ? longForm : identity.id;
11
- }
12
5
  // The service boundary has no CREDENTIAL_* → KB* mapping; toHandlerError forwards
13
6
  // a thrown error's `code` only when it is already a registered KubunErrorCode,
14
7
  // preserving `data`. This maps the known credential outcomes to an envelope code
@@ -158,6 +151,15 @@ function readAccountPeek(raw) {
158
151
  proceed: ()=>readSeam.getCredential(param.providerName, param.ownerDID)
159
152
  });
160
153
  },
154
+ 'credential/get-ref': (context)=>{
155
+ const param = context.param;
156
+ return authorizeRead({
157
+ context,
158
+ subject: param.ownerDID,
159
+ emptyResult: null,
160
+ proceed: ()=>readSeam.getCredentialRef(param.providerName, param.ownerDID)
161
+ });
162
+ },
161
163
  // The same vault read as `credential/get` — the DB credential API, which
162
164
  // never refreshes a token — narrowed to the provider account and the
163
165
  // granted scopes: no token material leaves the vault on a peek.
@@ -218,6 +220,19 @@ function readAccountPeek(raw) {
218
220
  await writeInTx((seam)=>seam.setCredential(param.providerName, param.ownerDID, param.credential));
219
221
  return null;
220
222
  },
223
+ 'credential/refresh-entry': async (context)=>{
224
+ const param = context.param;
225
+ await authorizeWrite({
226
+ context,
227
+ subject: param.ownerDID
228
+ });
229
+ return writeInTx(async (seam)=>{
230
+ // The authorized alias must still name the entry being refreshed.
231
+ const ref = await seam.getCredentialRef(param.providerName, param.ownerDID);
232
+ if (ref?.entryID !== param.entryID) return 'absent';
233
+ return seam.setCredentialForEntry(param);
234
+ });
235
+ },
221
236
  'credential/delete': async (context)=>{
222
237
  const param = context.param;
223
238
  await authorizeWrite({
@@ -248,6 +263,9 @@ function readAccountPeek(raw) {
248
263
  'credential/get': {
249
264
  allow: true
250
265
  },
266
+ 'credential/get-ref': {
267
+ allow: true
268
+ },
251
269
  'credential/peek': {
252
270
  allow: true
253
271
  },
@@ -260,6 +278,9 @@ function readAccountPeek(raw) {
260
278
  'credential/refresh': {
261
279
  allow: true
262
280
  },
281
+ 'credential/refresh-entry': {
282
+ allow: true
283
+ },
263
284
  'credential/delete': {
264
285
  allow: true
265
286
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubun/plugin-credential",
3
- "version": "0.17.3",
3
+ "version": "0.17.5",
4
4
  "license": "see LICENSE.md",
5
5
  "sideEffects": false,
6
6
  "type": "module",
@@ -15,15 +15,15 @@
15
15
  ],
16
16
  "dependencies": {
17
17
  "@kokuin/token": "^0.5.0",
18
- "@kubun/credential": "^0.17.3",
18
+ "@kubun/credential": "^0.17.4",
19
19
  "@kubun/db": "^0.17.0",
20
- "@kubun/engine": "^0.17.2",
20
+ "@kubun/engine": "^0.17.3",
21
21
  "@kubun/graphql": "^0.17.2",
22
22
  "@kubun/hlc": "^0.17.0",
23
23
  "@kubun/id": "^0.17.0",
24
24
  "@kubun/plugin-service-api": "^0.17.1",
25
25
  "@kubun/plugin-service-server": "^0.17.1",
26
- "@kubun/protocol": "^0.17.1",
26
+ "@kubun/protocol": "^0.17.2",
27
27
  "@kubun/store-credential": "^0.17.4",
28
28
  "@sozai/codec": "^0.4.0",
29
29
  "@sozai/runtime": "^0.1.0",
@@ -35,7 +35,7 @@
35
35
  "@kokuin/capability": "^0.3.0",
36
36
  "@kokuin/controller": "^0.1.0",
37
37
  "@kubun/db-better-sqlite": "^0.17.0",
38
- "@kubun/service-credential-api": "^0.17.2",
38
+ "@kubun/service-credential-api": "^0.17.3",
39
39
  "@kubun/store-controller": "^0.17.0",
40
40
  "@kubun/store-graph": "^0.17.1",
41
41
  "@kubun/test-utils": "^0.0.0"