@kokuin/browser 0.1.1 → 0.1.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/lib/identity.js +8 -7
- package/package.json +4 -3
package/lib/identity.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { createTracer, KokuinAttributeKeys, KokuinSpanNames } from '@kokuin/otel';
|
|
1
2
|
import { CODECS, getDID } from '@kokuin/token';
|
|
2
3
|
import { p256 } from '@noble/curves/nist.js';
|
|
3
4
|
import { b64uFromJSON, fromUTF, toB64U } from '@sozai/codec';
|
|
4
5
|
import { getLogger } from '@sozai/log';
|
|
5
|
-
import {
|
|
6
|
+
import { withSpan } from '@sozai/otel';
|
|
6
7
|
import { BrowserKeyStore } from './store.js';
|
|
7
8
|
import { getPublicKey } from './utils.js';
|
|
8
9
|
const tracer = createTracer('keystore.browser');
|
|
@@ -60,9 +61,9 @@ async function createBrowserSigningIdentity(keyPair) {
|
|
|
60
61
|
};
|
|
61
62
|
}
|
|
62
63
|
export async function provideSigningIdentity(keyID, useStore) {
|
|
63
|
-
return withSpan(tracer,
|
|
64
|
+
return withSpan(tracer, KokuinSpanNames.KEYSTORE_GET_OR_CREATE, {
|
|
64
65
|
attributes: {
|
|
65
|
-
[
|
|
66
|
+
[KokuinAttributeKeys.KEYSTORE_STORE_TYPE]: 'browser'
|
|
66
67
|
}
|
|
67
68
|
}, async (span)=>{
|
|
68
69
|
const storePromise = useStore == null || typeof useStore === 'string' ? BrowserKeyStore.open(useStore) : Promise.resolve(useStore);
|
|
@@ -71,14 +72,14 @@ export async function provideSigningIdentity(keyID, useStore) {
|
|
|
71
72
|
const existing = await entry.getAsync();
|
|
72
73
|
if (existing != null) {
|
|
73
74
|
const identity = await createBrowserSigningIdentity(existing);
|
|
74
|
-
span.setAttribute(
|
|
75
|
-
span.setAttribute(
|
|
75
|
+
span.setAttribute(KokuinAttributeKeys.AUTH_DID, identity.id);
|
|
76
|
+
span.setAttribute(KokuinAttributeKeys.KEYSTORE_KEY_CREATED, false);
|
|
76
77
|
return identity;
|
|
77
78
|
}
|
|
78
79
|
const keyPair = await entry.provideAsync();
|
|
79
80
|
const identity = await createBrowserSigningIdentity(keyPair);
|
|
80
|
-
span.setAttribute(
|
|
81
|
-
span.setAttribute(
|
|
81
|
+
span.setAttribute(KokuinAttributeKeys.AUTH_DID, identity.id);
|
|
82
|
+
span.setAttribute(KokuinAttributeKeys.KEYSTORE_KEY_CREATED, true);
|
|
82
83
|
logger.info('New identity generated: {did}', {
|
|
83
84
|
did: identity.id
|
|
84
85
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kokuin/browser",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Key store for browser",
|
|
6
6
|
"keywords": [
|
|
@@ -29,8 +29,9 @@
|
|
|
29
29
|
"@sozai/async": "^0.1.0",
|
|
30
30
|
"@sozai/codec": "^0.1.0",
|
|
31
31
|
"@sozai/log": "^0.1.0",
|
|
32
|
-
"@sozai/otel": "^0.
|
|
33
|
-
"@kokuin/token": "^0.1.
|
|
32
|
+
"@sozai/otel": "^0.2.0",
|
|
33
|
+
"@kokuin/token": "^0.1.1",
|
|
34
|
+
"@kokuin/otel": "^0.1.0"
|
|
34
35
|
},
|
|
35
36
|
"scripts": {
|
|
36
37
|
"build:clean": "del lib",
|