@starcite/sdk 0.0.4 → 0.0.6

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.cts CHANGED
@@ -890,7 +890,7 @@ declare class Starcite {
890
890
  * Creates or binds to a session.
891
891
  *
892
892
  * **With identity** (backend): creates a new session and/or mints a session
893
- * token for the given identity. Pass `id` to bind to an existing session.
893
+ * token for the given identity. Pass `id` to create-or-bind that session.
894
894
  *
895
895
  * **With token** (frontend): wraps an existing session token. The identity
896
896
  * and session id are decoded from the JWT.
package/dist/index.d.ts CHANGED
@@ -890,7 +890,7 @@ declare class Starcite {
890
890
  * Creates or binds to a session.
891
891
  *
892
892
  * **With identity** (backend): creates a new session and/or mints a session
893
- * token for the given identity. Pass `id` to bind to an existing session.
893
+ * token for the given identity. Pass `id` to create-or-bind that session.
894
894
  *
895
895
  * **With token** (frontend): wraps an existing session token. The identity
896
896
  * and session id are decoded from the JWT.
package/dist/index.js CHANGED
@@ -1646,7 +1646,20 @@ var Starcite = class {
1646
1646
  async sessionFromIdentity(input) {
1647
1647
  let sessionId = input.id;
1648
1648
  let record;
1649
- if (!sessionId) {
1649
+ if (sessionId) {
1650
+ try {
1651
+ record = await this.createSession({
1652
+ id: sessionId,
1653
+ creator_principal: input.identity.toCreatorPrincipal(),
1654
+ title: input.title,
1655
+ metadata: input.metadata
1656
+ });
1657
+ } catch (error) {
1658
+ if (!(error instanceof StarciteApiError && error.status === 409)) {
1659
+ throw error;
1660
+ }
1661
+ }
1662
+ } else {
1650
1663
  record = await this.createSession({
1651
1664
  creator_principal: input.identity.toCreatorPrincipal(),
1652
1665
  title: input.title,