@kubun/service-credential-api 0.17.2 → 0.17.3

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/lib/adapter.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type Client } from '@enkaku/client';
2
- import type { AliasBindingCredentialProvider, CredentialProvider, ProviderAccount } from '@kubun/credential-types';
2
+ import type { AliasBindingCredentialProvider, CredentialProvider, EntryPairedCredentialProvider, ProviderAccount } from '@kubun/credential-types';
3
3
  import type { CredentialServiceProtocol } from './index.js';
4
4
  /**
5
5
  * What a storage-only account peek discloses: the provider account and the
@@ -22,4 +22,4 @@ export type CredentialProviderWithProvenance = CredentialProvider & {
22
22
  writerDID: string | null;
23
23
  } | null>;
24
24
  };
25
- export declare function toCredentialProvider(client: Client<CredentialServiceProtocol>): CredentialProviderWithProvenance & AliasBindingCredentialProvider & Required<Pick<CredentialProviderWithProvenance, 'peekAccount'>>;
25
+ export declare function toCredentialProvider(client: Client<CredentialServiceProtocol>): CredentialProviderWithProvenance & AliasBindingCredentialProvider & EntryPairedCredentialProvider & Required<Pick<CredentialProviderWithProvenance, 'peekAccount'>>;
package/lib/adapter.js CHANGED
@@ -18,6 +18,28 @@ export function toCredentialProvider(client) {
18
18
  });
19
19
  return raw == null ? null : deserializeCredential(raw);
20
20
  },
21
+ async getCredentialRef (providerName, ownerDID) {
22
+ const ref = await client.request('credential/get-ref', {
23
+ param: {
24
+ providerName,
25
+ ownerDID
26
+ }
27
+ });
28
+ return ref == null ? null : {
29
+ credential: deserializeCredential(ref.credential),
30
+ entryID: ref.entryID
31
+ };
32
+ },
33
+ setCredentialForEntry ({ providerName, ownerDID, entryID, credential }) {
34
+ return client.request('credential/refresh-entry', {
35
+ param: {
36
+ providerName,
37
+ ownerDID,
38
+ entryID,
39
+ credential: serializeCredential(credential)
40
+ }
41
+ });
42
+ },
21
43
  async peekAccount (providerName, ownerDID) {
22
44
  let peeked;
23
45
  try {
package/lib/index.d.ts CHANGED
@@ -24,6 +24,39 @@ export declare const credentialServiceProtocol: {
24
24
  }];
25
25
  };
26
26
  };
27
+ readonly 'credential/get-ref': {
28
+ readonly type: "request";
29
+ readonly param: {
30
+ readonly type: "object";
31
+ readonly properties: {
32
+ readonly providerName: {
33
+ readonly type: "string";
34
+ };
35
+ readonly ownerDID: {
36
+ readonly type: "string";
37
+ };
38
+ };
39
+ readonly required: readonly ["providerName", "ownerDID"];
40
+ readonly additionalProperties: false;
41
+ };
42
+ readonly result: {
43
+ readonly anyOf: [{
44
+ readonly type: "object";
45
+ readonly properties: {
46
+ readonly credential: {
47
+ readonly type: "string";
48
+ };
49
+ readonly entryID: {
50
+ readonly type: "string";
51
+ };
52
+ };
53
+ readonly required: readonly ["credential", "entryID"];
54
+ readonly additionalProperties: false;
55
+ }, {
56
+ readonly type: "null";
57
+ }];
58
+ };
59
+ };
27
60
  readonly 'credential/peek': {
28
61
  readonly type: "request";
29
62
  readonly param: {
@@ -165,6 +198,32 @@ export declare const credentialServiceProtocol: {
165
198
  readonly type: "null";
166
199
  };
167
200
  };
201
+ readonly 'credential/refresh-entry': {
202
+ readonly type: "request";
203
+ readonly param: {
204
+ readonly type: "object";
205
+ readonly properties: {
206
+ readonly providerName: {
207
+ readonly type: "string";
208
+ };
209
+ readonly ownerDID: {
210
+ readonly type: "string";
211
+ };
212
+ readonly entryID: {
213
+ readonly type: "string";
214
+ };
215
+ readonly credential: {
216
+ readonly type: "string";
217
+ };
218
+ };
219
+ readonly required: readonly ["providerName", "ownerDID", "entryID", "credential"];
220
+ readonly additionalProperties: false;
221
+ };
222
+ readonly result: {
223
+ readonly type: "string";
224
+ readonly enum: readonly ["updated", "absent"];
225
+ };
226
+ };
168
227
  readonly 'credential/delete': {
169
228
  readonly type: "request";
170
229
  readonly param: {
package/lib/index.js CHANGED
@@ -12,7 +12,8 @@ export { CREDENTIAL_PEEK_UNSUPPORTED, CredentialPeekUnsupportedError } from './e
12
12
  // Enkaku message `sub` — the host rejects a `sub` that differs from `iss`, so a
13
13
  // caller acting for another owner carries that owner in the param, not the
14
14
  // envelope. Serialized credential bytes cross as a UTF string; the vault stores
15
- // the ciphertext, never the plaintext. Writes ack with `null`.
15
+ // the ciphertext, never the plaintext. Entry-scoped writes report their outcome;
16
+ // the other writes ack with `null`.
16
17
  export const credentialServiceProtocol = {
17
18
  'credential/get': {
18
19
  type: 'request',
@@ -43,6 +44,48 @@ export const credentialServiceProtocol = {
43
44
  ]
44
45
  }
45
46
  },
47
+ 'credential/get-ref': {
48
+ type: 'request',
49
+ param: {
50
+ type: 'object',
51
+ properties: {
52
+ providerName: {
53
+ type: 'string'
54
+ },
55
+ ownerDID: {
56
+ type: 'string'
57
+ }
58
+ },
59
+ required: [
60
+ 'providerName',
61
+ 'ownerDID'
62
+ ],
63
+ additionalProperties: false
64
+ },
65
+ result: {
66
+ anyOf: [
67
+ {
68
+ type: 'object',
69
+ properties: {
70
+ credential: {
71
+ type: 'string'
72
+ },
73
+ entryID: {
74
+ type: 'string'
75
+ }
76
+ },
77
+ required: [
78
+ 'credential',
79
+ 'entryID'
80
+ ],
81
+ additionalProperties: false
82
+ },
83
+ {
84
+ type: 'null'
85
+ }
86
+ ]
87
+ }
88
+ },
46
89
  // Storage-only, non-refreshing read of the stored credential's provider
47
90
  // account and the scopes it was granted — and nothing else: no token
48
91
  // material crosses the wire. The server
@@ -234,6 +277,40 @@ export const credentialServiceProtocol = {
234
277
  type: 'null'
235
278
  }
236
279
  },
280
+ 'credential/refresh-entry': {
281
+ type: 'request',
282
+ param: {
283
+ type: 'object',
284
+ properties: {
285
+ providerName: {
286
+ type: 'string'
287
+ },
288
+ ownerDID: {
289
+ type: 'string'
290
+ },
291
+ entryID: {
292
+ type: 'string'
293
+ },
294
+ credential: {
295
+ type: 'string'
296
+ }
297
+ },
298
+ required: [
299
+ 'providerName',
300
+ 'ownerDID',
301
+ 'entryID',
302
+ 'credential'
303
+ ],
304
+ additionalProperties: false
305
+ },
306
+ result: {
307
+ type: 'string',
308
+ enum: [
309
+ 'updated',
310
+ 'absent'
311
+ ]
312
+ }
313
+ },
237
314
  'credential/delete': {
238
315
  type: 'request',
239
316
  param: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubun/service-credential-api",
3
- "version": "0.17.2",
3
+ "version": "0.17.3",
4
4
  "keywords": [],
5
5
  "license": "see LICENSE.md",
6
6
  "sideEffects": false,
@@ -17,7 +17,7 @@
17
17
  "dependencies": {
18
18
  "@enkaku/client": "^0.21.2",
19
19
  "@enkaku/protocol": "^0.21.1",
20
- "@kubun/credential": "^0.17.3",
20
+ "@kubun/credential": "^0.17.4",
21
21
  "@kubun/credential-types": "^0.17.2"
22
22
  },
23
23
  "publishConfig": {